
How to set OpenGL in Windows XP / Visual Studio 2005.NET
by AskBargains.com
1)Go to http://www.xmission.com/~nate/glut.html download glut-3.7.6-bin.zip (117 KB)
2)Unzip the glut-3.7.6-bin.zip (117 KB) files\
3)Copy glut32.dll file to C:\Windows\System
4)copy glut32.lib file to C:\Program Files\Microsoft Visual Studio 8\VC\PlatformSDK\lib
5)Copy glut.h file to C:\Program Files\Microsoft Visual Studio 8\VC\PlatformSDK\include\gl
6)Open Visual Studio 2005.NET
7.
8. Right click on the project (TestOpenGL) and click Properties.
9 ) . Right click on the project (TestOpenGL) Add -> Add New Item and add C++ File (.cpp)
10 ) Add this testing code in “TestOpenGL.cpp”
#include
void init (void)
{
glClearColor (1.0, 1.0, 1.0, 0.0); // Set display-window color to white.
glMatrixMode (GL_PROJECTION); // Set projection parameters.
gluOrtho2D (0.0, 200.0, 0.0, 150.0);
}
void lineSegment (void)
{
glClear (GL_COLOR_BUFFER_BIT); // Clear display window.
glColor3f (1.0, 0.0, 1.0); // Set line segment color to red.
glBegin (GL_LINES);
glVertex2i (180, 15); // Specify line-segment geometry.
glVertex2i (10, 145);
glEnd ( );
glFlush ( ); // Process all OpenGL routines as quickly as possible.
}
void main (int argc, char** argv)
{
glutInit (&argc, argv); // Initialize GLUT.
glutInitDisplayMode (GLUT_SINGLE GLUT_RGB); // Set display mode.
glutInitWindowPosition (350, 100); // Set top-left display-window position.
glutInitWindowSize (400, 500); // Set display-window width and height.
glutCreateWindow ("An Example OpenGL Program"); // Create display window.
init ( ); // Execute initialization procedure.
glutDisplayFunc (lineSegment); // Send graphics to display window.
glutMainLoop ( ); // Display everything and wait.
}
The result will be like this
I also found this video OpenGL Tutorial #0a: Getting OpenGL Set Up on Windows on internet, sorry, I could not found the author's name .
No comments:
Post a Comment