OpenGL is an interface to graphics hardware. The GL stands for Graphics Library. It provides commands for specifying geometric objects in two or three dimensions, and for controlling how these objects are drawn on the display. Objects, in this case, are points, lines, polygons, images, and bitmaps.
How to Install in Microsoft Visual Studio:
After downloading glut-3.7.6-bin.zip
- Copy all the .h files into the C:\Program Files\Microsoft SDKs\Windows\v6.1\Include\GL folder. This should be glut.h, freeglut.h, freeglut_ext.h, and freeglut_std.h.
- Copy all the .lib files into the C:\Program Files\Microsoft SDKs\Windows\v6.1\Lib folder. This should be freeglut.lib and glut32.lib.
- Copy all the .dll files into the C:\Windows\system32 folder. This should be freeglut.dll and glut32.dll.
For Details:
http://thoughtsfrommylife.com/article-748-OpenGL_and_Visual_Studio_Express_2008
Open a c++ project in VS 2005/2008/2000
Select win32 Console Applocation
Click Finish.
Then Copy the program & Run it.
Let me know if u face any problem.
#include
/*
* triangle.c -- A simple example of OpenGL and GLUT.
*/
#include
void displayCB(void) /* function called whenever redisplay needed */
{
glClear(GL_COLOR_BUFFER_BIT); /* clear the display */
glColor3f(1.0, 1.0, 1.0); /* set current color to white */
glBegin(GL_POLYGON); /* draw filled triangle */
glVertex2i(200,125); /* specify each vertex of triangle */
glVertex2i(100,375);
glVertex2i(300,375);
glEnd(); /* OpenGL draws the filled triangle */
glFlush(); /* Complete any pending operations */
}
void keyCB(unsigned char key, int x, int y) /* called on key press */
{
if( key == 'q' ) exit(0);
}
int main(int argc, char *argv[])
{
int win;
glutInit(&argc, argv); /* initialize GLUT system */
glutInitDisplayMode(GLUT_RGB);
glutInitWindowSize(400,500); /* width=400pixels height=500pixels */
win = glutCreateWindow("Triangle"); /* create window */
/* from this point on the current window is win */
glClearColor(0.0,0.0,0.0,0.0); /* set background to black */
gluOrtho2D(0,400,0,500); /* how object is mapped to window */
glutDisplayFunc(displayCB); /* set window's display callback */
glutKeyboardFunc(keyCB); /* set window's key callback */
glutMainLoop(); /* start processing events... */
/* execution never reaches this point */
return 0;
}
Comments