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:
- Include <gl/glutH>
- void init(void)
- {
- Glclearcolor(0. 0, 0. 0, 0. 0, 0. 0);
- Glmatrixmode(gl_projection);
- Glortho(-5, 5,-5, 5, 5,);
- Glmatrixmode(Gl_modelview);
- Glulookat(0, 0,ten, 0, 0, 0, 0, 1, 0);
- return;
- }
- void display(void)
- {
- Glclear(gl_color_buffer_bit);
- glcolor3f(1. 0, 0, 0);
- Glutwireteapot(3);
- Glflush();
- return;
- }
- int main(int argc, char*argv[])
- {
- Glutinit(&argc, argv);
- Glutinitdisplaymode(Glut_rgb | Glut_single);
- Glutinitwindowposition(0, 0);
- Glutinitwindowsize(a);
- Glutcreatewindow("OpenGL 3D View");
- Init();
- Glutdisplayfunc(display);
- Glutmainloop();
- return 0;
- }
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