If you want to use OpenGL for development in Windows, you will encounter a problem. The OpenGL version provided by Microsoft is 1.1, and the later version is not provided. (why? Because people want to promote their own Dx and despise him !), If you want to use some advanced functions, you can only use OpenGL extensions. There are many types of extensions. OpenGL has a big advantage, that is, its scalability and glext. H and glew. h pay attention to the reference sequence when referencing the two header files, glext. The declaration of H should be behind glut. h, and the declaration of glew. H should be behind glut. H. We need to initialize it when using glew. h.
Glenum err = glewinit ();
If (glew_ OK! = ERR)
{
Messageboxa (null, "error", "my window", 1 );
}
Maybe we are very confused. Why can't the examples of multi-layer textures in OpenGL redbooks be used? Why can't they use the code written in windows? When I add glext. H: The header file is. It is found that glactivetexturearb and glmultitexcoord2farb are not defined. Check the nehe code and find the problem. The windows program does not find the entry addresses of the two functions. First declare the function pointer.
Pfnglactivetexturearbproc glactivetexturearb = NULL;
Pfnglmultitexcoord2farbproc glmultitexcoord2farb = NULL;
Then initialize it in our init function.
Glmultitexcoord2farb = (pfnglmultitexcoord2farbproc) wglgetprocaddress ("glmultitexcoord2farb ");
Glactivetexturearb = (pfnglactivetexturearbproc) wglgetprocaddress ("glactivetexturearb ");
Then compile it. OK. No problem.
However, we found that the result is very dark, because the texture environment we set is gltexenvi (gl_texture_env, gl_texture_env_mode, gl_modulate) glmodulate. I believe everyone understands what this parameter means, to change his practical effects, we have to work on it ......
It's not because we didn't do it ......, It is easy