Słuchajcie ... Więc tak - nie wiem, co zrobiłem, ale działa ;)
1.Zainstalowałem Code::Blocks z Centrum Oprogramowania Ubuntu
2.Zainstalowałem za pomocą polecenia: sudo apt-get install libgl1-mesa-dev
w Code::Blocks stworzyłem nowy projekt OpenGL, wcisnąłem F9 i przykładowy kod działa. Mam jednak plik (kod znaleziony w sieci):
Kopiuj
#include <GL/glut.h>
#define window_width 640
#define window_height 480
void main_loop_function()
{
static float angle;
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
glLoadIdentity();
glTranslatef(0,0, -10);
glRotatef(angle, 0, 0, 1);
glBegin(GL_QUADS);
glColor3ub(255, 000, 000); glVertex2f(-1, 1);
glColor3ub(000, 255, 000); glVertex2f( 1, 1);
glColor3ub(000, 000, 255); glVertex2f( 1, -1);
glColor3ub(255, 255, 000); glVertex2f(-1, -1);
glEnd();
glutSwapBuffers();
angle+=0.25;
}
void GL_Setup(int width, int height)
{
glViewport( 0, 0, width, height );
glMatrixMode( GL_PROJECTION );
glEnable( GL_DEPTH_TEST );
gluPerspective( 45, (float)width/height, .1, 100 );
glMatrixMode( GL_MODELVIEW );
}
int main(int argc, char** argv) {
glutInit(&argc, argv);
glutInitWindowSize(window_width, window_height);
glutInitDisplayMode(GLUT_RGB | GLUT_DOUBLE);
glutCreateWindow("GLUT Example!!!");
glutIdleFunc(main_loop_function);
GL_Setup(window_width, window_height);
glutMainLoop();
}
Jednak po wydaniu polecenia w konsoli:
Kopiuj
sth.cpp:1: fatal error: GL/glut.h: Nie ma takiego pliku ani katalogu
compilation terminated.
Powyższy kod kompilowałem za pomocą polecenia: g++ sth.cpp -lglut