Python,C,C++ and JAVA programs for CBSE, ISC, B.Tech and I.T Computer Science and MCA students

The Programming Project: open GL Programming in LINUX

Monday, May 5, 2014

open GL Programming in LINUX


To compile a program (using open GL graphics library) in Linux, go to the current directory where the program is residing say test.c. type the following command gcc -o xyz test.c -lglut -lGLU -lGL -lGLU make sure you have the open GL library installed! After the execution of the command a output file with name xyz will be created in the current directory. To run the output file type in the following command ./xyz

To sum up consider a program vinod.c in the folder Graphics, to execute it perform the following steps.
administrator@ubuntu:~/Graphics$ gcc -o vin vinod.c -lglut -lGLU -lGL -lGLU
administrator@ubuntu:~/Graphics$ ./vin


Here is an example of a simple program which will just create a window with a text

#include <GL/glut.h>
void
display(void) {
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
glutSwapBuffers();
}
int main(int argc, char **argv) {
glutInit(&argc, argv);
glutInitDisplayMode(GLUT_DOUBLE | GLUT_RGB | GLUT_DEPTH);
glutCreateWindow("MY FIRST GRAPHICS PROGRAM");
glutDisplayFunc(display);
glutMainLoop();
return 0;
}

No comments:

Post a Comment