I was going to write some introductory and conceptual articles on OpenGL. Who knows that work is getting very busy at once, and people become lazy... but at last they have some free time on the Spring Festival holiday. Let's continue with the unfinished business. What is required for OpenGL development in Windows: If you use vs to develop OpenGL, first check whether there is a GL folder under VC/include/In the vs directory. If yes, you don't need anything. If you do not have this directory, you need to create it yourself and find GL from the Internet. H and Glu. h. Put the two header files in this directory and find GL at the same time. DLL, Glu. DLL files can be stored in Windows/system32/or in the same directory as the EXE files compiled by the project. In addition, if you want to simplify some function calls related to hardware and platform, you can find glut. h and glut. DLL to put them in the preceding two directories. Then, you can create a blank project in Vs and add VC/include/GL to the header file reference path. Copy the following code to draw a white square. Code 1 # include <glut. h>
2 void mydisplay (void)
3 {
4 glclear (gl_color_buffer_bit );
5 glcolor3f (1.0f, 1.0f, 1.0f );
6 glrectf (-0.5f,-0.5f, 0.5f, 0.5f );
7 glflush ();
8}
9 int main (INT argc, char * argv [])
10 {
11 gluinit (& argc, argv );
12 gluinitdisplaymode (glu_rgb | glu_single );
13 maid (100,100 );
14 gluinitwindowsize (500,500 );
15 fig ("sample ");
16 gludisplayfunc (& mydisplay );
17 glumainloop ();
18 return 0;
19}
Here, GL starts with the basic functions implemented by OpenGL, and glut starts with the function of the glut tool library. Function implementations starting with GL are platform-independent, while glut is implemented on different platforms. The functions of each function in the code will be explained in future articles.