OpenGL extensions and multiple texture maps under windows

Source: Internet
Author: User

Environment: windows8.1

Reference:

Http://www.cnblogs.com/madfrog/archive/2010/06/25/1765243.html

http://blog.csdn.net/xiangyunl/article/details/7933549

If you are developing OpenGL programs under the Windows platform, the OpenGL library that comes with the system is 1.1, and if you want to use a 1.2 or higher version of OpenGL Library, you can only use OpenGL extensions. Because of the D3D relationship,Windows is not very positive about OpenGL support.

OpenGL Extension Library types:

Specific reference: http://www.cnblogs.com/madfrog/archive/2010/06/25/1765243.html

(1) Using Glext

You need the wglgetprocaddress function to get a pointer to the extension function.

(2) using the Glew library

OpenGL starting from 3.0, all implementations are provided by the graphics card manufacturer. But the official organization just publishes the standard only, because does not have the craved cognition, harms I everywhere to look for the DLL. Glew is a cross-platform, C + + extension library based on the OpenGL graphics interface. All the friends who use OpenGL know that Window currently only supports OpenGL1.1, but OpenGL is now more than 2.0, to use these advanced features of OpenGL, you must download the latest extensions, in addition, different graphics companies will also publish some only the home card support extension functions, you want to use this number, you have to find the latest Glext.h, with the Glew extension library, you'll never have to worry about finding a function interface, because Glew can automatically identify all of the OpenGL advanced extensions supported by your platform. That is, you can use all the functions of GL,GLU,GLEXT,WGL,GLX as long as you include a glew.h header file. Glew supports various operating systems currently in vogue (including Windows, Linux, Mac OS X, FreeBSD, Irix, and Solaris)

(3) using the Glee Library

The following is mainly about the multi-texture mapping of the Glew library

1. Glew Initialization

Glenum err = Glewinit ();

Err = 0 indicates success

Main point: This function is initialized after glut initialization.

   Glutinit (&ARGC, argv); Glutinitdisplaymode (glut_double | Glut_rgba | Glut_multisample);     Glutinitwindowposition (+);     Glutinitwindowsize (WindowWidth, windowheight);     Glutcreatewindow (windowtitle);     Glutdisplayfunc (&display); Set the keyboard response function Glutkeyboardfunc (&presskeyboard); Set the Special Keyboard response function Glutspecialfunc (&specialkey); Glutreshapefunc (&reshape); Glenum err = Glewinit ();



2. Turn on multiple textures

Here is a multi-texture-opening code with two textures multiplied:

 Glactivetexture (GL_TEXTURE0); Glenable (gl_texture_2d); Glbindtexture (gl_texture_2d, Texground); Simply Sample The texture Gltexenvi (gl_texture_env, Gl_texture_env_mode, gl_replace); Glactivetexture (Gl_texture1); Glenable (gl_texture_2d); Glbindtexture (gl_texture_2d, Windowtex); Gltexenvi (gl_texture_env, Gl_texture_env_mode, gl_combine);   Sample RGB, multiply by previous texunit result Gltexenvi (gl_texture_env, Gl_combine_rgb, gl_modulate); Modulate RGB with RGB Gltexenvi (gl_texture_env, Gl_source0_rgb, gl_previous); Gltexenvi (gl_texture_env, Gl_source1_rgb, gl_texture); Gltexenvi (gl_texture_env, Gl_operand0_rgb, Gl_src_color); Gltexenvi (gl_texture_env, Gl_operand1_rgb, Gl_src_color);  Sample ALPHA, multiply by previous texunit result Gltexenvi (gl_texture_env, Gl_combine_alpha, gl_modulate); Modulate Alpha with Alpha Gltexenvi (gl_texture_env, Gl_source0_alpha, gl_previous); Gltexenvi (gl_texture_env, Gl_source1_alpha, gl_texture); Gltexenvi (gl_texture_env, Gl_operand0_alpha, GL_src_alpha); Gltexenvi (gl_texture_env, Gl_operand1_alpha, Gl_src_alpha);


3. Disabling multiple textures

Here's the code to disable multiple textures:

Glactivetexture (GL_TEXTURE0); gldisable (gl_texture_2d); Glactivetexture (Gl_texture1); gldisable (GL_TEXTURE_2D);


Note the point:

The following code can determine the OpenGL version and supported extensions

Const glubyte* openglversion = glgetstring (gl_version);

Const glubyte* extensions = glgetstring (gl_extensions);



OpenGL extensions and multiple texture maps under windows

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.