Use and configuration of Code::blocks+opengl under Ubuntu

Source: Internet
Author: User

Operating system: Ubuntu 15.04

GCC version 4.9.2

OpenGL installation

sudo apt-get install build-essential libgl1-mesa-dev libglu1-mesa-dev Freeglut3-dev

Test:

  1. Include <gl/glutH>

  2. void init(void)
  3. {
  4. Glclearcolor(0. 0, 0. 0, 0. 0, 0. 0);
  5. Glmatrixmode(gl_projection);
  6. Glortho(-5, 5,-5, 5, 5,);
  7. Glmatrixmode(Gl_modelview);
  8. Glulookat(0, 0,ten, 0, 0, 0, 0, 1, 0);

  9. return;
  10. }

  11. void display(void)
  12. {
  13. Glclear(gl_color_buffer_bit);
  14. glcolor3f(1. 0, 0, 0);
  15. Glutwireteapot(3);
  16. Glflush();

  17. return;
  18. }

  19. int main(int argc, char*argv[])
  20. {
  21. Glutinit(&argc, argv);
  22. Glutinitdisplaymode(Glut_rgb | Glut_single);
  23. Glutinitwindowposition(0, 0);
  24. Glutinitwindowsize(a);
  25. Glutcreatewindow("OpenGL 3D View");
  26. Init();
  27. Glutdisplayfunc(display);
  28. Glutmainloop();

  29. return 0;
  30. }

Save As TEST.c and execute

Gcc-o Test Test.c-lgl-lglu-lglut
./test

Install Codebelocks:

$ sudo apt-get install Codeblocks

Set compiler

"Settings"->compiler. Choose the gun GCC Compiler

Set the OpenGL library path

"Settings"->compiler. Select linker Settings-Link libraries and add

/usr/lib/libglut.so/usr/lib/libglu.so/usr/lib/libgl.so

Copy the corresponding library into the/usr/lib/

$ sudo cp/usr/lib/i386-linux-gnu/libglut.so/usr/lib/libglut.so$ sudo cp/usr/lib/i386-linux-gnu/libglu.so/usr/lib/ libglu.so$ sudo cp/usr/lib/i386-linux-gnu/mesa/libgl.so/usr/lib/libgl.so

Set the interface style of Codeblocks
Turn off Codeblocks software and open ~/.codeblocks/default.conf

Open the connection portal to copy the code behind the connection to ~/.codeblocks/default.conf and save it. You can back up the next file before copying

Open "Settings"->editor, click on the left syntax highlighting, choose color theme for Vim (of course, you can choose other themes, the theme is very good)

Because there are no cursors in these topics (in fact the cursor color is the same as the background color), you need to set the next cursor

Open "Settings"->editor, click on the left margins and caret, select caret in the style of line,width is 3, color is red (these parameters can be selected according to their preferences, mainly color can not be the same as the background colors, Otherwise you will not find the cursor)

Use and configuration of Code::blocks+opengl under Ubuntu

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.