Advertisement
dmilicev

graphic in C C++ CodeBlocks v1.c

Oct 19th, 2019
356
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 3.37 KB | None | 0 0
  1. /*
  2.  
  3. Graphic in C, C++, CodeBlocks v1.c
  4.  
  5.  
  6. Graphic in C, C++, CodeBlocks:
  7.  
  8. Note also that initgraph() and the other graphic functions belonged to the
  9. ancient Turbo-C/C++ compilers for MS-DOS. Using those nowadays via WinBGIm
  10. is not the best choice to learn graphics programming.
  11.  
  12. Graphics-Library for C/C++ in CodeBlocks
  13.  
  14. How to use graphics in CodeBlocks?
  15.  
  16. https://www.google.com/search?q=how+to+use+graphics+in+codeblocks&rlz=1C1PRFC_enRS707RS707&oq=how+to+graphics+in+c+codebloks&aqs=chrome.2.69i57j0l5.27373j1j7&sourceid=chrome&ie=UTF-8
  17.  
  18. https://medium.com/@sagarganiga468/use-graphics-h-in-code-blocks-fe6ae3d8d4c2
  19.  
  20. https://github.com/SagarGaniga/Graphics-Library
  21.  
  22. https://codeload.github.com/SagarGaniga/Graphics-Library/zip/master
  23.  
  24. https://www.codeproject.com/Questions/1255636/Using-graphics-h-in-codeblocks
  25.  
  26. https://github.com/SagarGaniga/computer-graphics
  27.  
  28. Graphics-Library
  29. Download required libraries from
  30. https://github.com/SagarGaniga/Graphics-Library
  31.  
  32. It is a tradition to use Turbo C for graphic in C/CPP.
  33. But it's also a pain in the neck.
  34.  
  35. Here we are using Code::Blocks IDE, which will ease out our work.
  36.  
  37. Steps to run graphic code in CodeBlocks
  38.  
  39. 1. Install Code::Blocks
  40. Make sure you have installed Code::Blocks IDE on your machine.
  41. If you don't have this IDE or have any issue with compiler download and install it from here.
  42. http://sourceforge.net/projects/codeblocks/files/Binaries/16.01/Windows/codeblocks-16.01mingw-setup.exe
  43.  
  44. 2. Download the required header files
  45. We need few files to be included in the lib folder of Code::Blocks.
  46. Download the files from here
  47. https://github.com/SagarGaniga/Graphics-Library
  48.  
  49. 3. Include graphics.h and winbgim.h
  50. Copy and Paste the graphics.h and winbgim.h files into include folder of Code::Blocks directory.
  51. Path: C:\Program Files (x86)\CodeBlocks\MinGW\include
  52.  
  53. 4. Include libbgi.a
  54. Copy and paste libbgi.a file in the lib folder of Code:Blocks
  55. Path: C:\Program Files (x86)\CodeBlocks\MinGW\lib
  56.  
  57. 5. Add Link Libraries in Linker Setting
  58. In the Code::Blocks application go to, Settings > Compiler
  59. In the Global Compiler setting, click on the Linker Settings
  60. In Link Libraries, Add and browse to C:\Program Files (x86)\CodeBlocks\MinGW\lib\ and select libbgi.a.
  61. Paste this in the Other Linker Option tab of Linker Settings (i.e. on the right-hand side)
  62. -lbgi -lgdi32 -lcomdlg32 -luuid -loleaut32 -lole32
  63.  
  64. Save the setting and restart the application
  65.  
  66. To test the setting copy paste any computer graphics code from
  67. https://github.com/SagarGaniga/computer-graphics
  68.  
  69. Note:
  70. Save code in cpp extension !
  71.  
  72. Don’t forget to include graphics.h
  73.  
  74. Enjoy Computer Graphics :)
  75.  
  76. https://www.codeproject.com/Questions/1255636/Using-graphics-h-in-codeblocks
  77. I am getting warning: Deprecated conversion from string constant to char Pass NULL instead of an empty string. The reason you got this warning (it is a warning and not an error) is that you pass a string literal which is const by definition but the function parameter is not const (char *).
  78. Note also that initgraph() and the other graphic functions belonged to the
  79. ancient Turbo-C/C++ compilers for MS-DOS. Using those nowadays via WinBGIm is
  80. not the best choice to learn graphics programming.
  81.  
  82. */
  83.  
  84. #include<stdio.h>
  85. #include<graphics.h>
  86.  
  87. int main(void)
  88. {
  89.    int gd=0,gm;
  90.  
  91.    initgraph(&gd,&gm,NULL);
  92.  
  93.    circle(100,80,30);
  94.  
  95.    getch();
  96.    closegraph();
  97. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement