OpenGL Multitexturing - glActiveTexture - NULL

I started a new project in which I want to use multitexturing. I have already done multixexturing and support my version of OpenGL

In the title I:

GLuint m_TerrainTexture[3];//heightmap, texture map and detail map GLuint m_SkyboxTexture[5]; //left, front, right, back and top textures PFNGLMULTITEXCOORD2FARBPROC glMultiTexCoord2fARB; PFNGLACTIVETEXTUREARBPROC glActiveTexture; 

In the constructor, I have:

 glActiveTexture = (PFNGLACTIVETEXTUREARBPROC) wglGetProcAddress((LPCSTR)"glActiveTextureARB"); glMultiTexCoord2fARB = (PFNGLMULTITEXCOORD2FARBPROC) wglGetProcAddress((LPCSTR)"glMultiTexCoord2fARB"); if(!glActiveTexture || !glMultiTexCoord2fARB) { MessageBox(NULL, "multitexturing failed", "OGL_D3D Error", MB_OK); } glActiveTexture( GL_TEXTURE0_ARB ); ... 

This displays the “multitexturing failed” message box, and the contents of glActiveTexture is 0x00000000

when it hits glActiveTexture (GL_TEXTURE0_ARB); I get an access violation error

I am using an MVC chart, so this is all in my terrain view class

+4
source share
4 answers

You have indicated your code for downloading extensions, as shown below:

 PFNGLMULTITEXCOORD2FARBPROC glMultiTexCoord2fARB; PFNGLACTIVETEXTUREARBPROC glActiveTexture; glActiveTexture = (PFNGLACTIVETEXTUREARBPROC) wglGetProcAddress((LPCSTR)"glActiveTextureARB"); glMultiTexCoord2fARB = (PFNGLMULTITEXCOORD2FARBPROC) wglGetProcAddress((LPCSTR)"glMultiTexCoord2fARB"); 

This is very problematic since it can override existing characters. The (dynamic) linker will eventually overcome this. For example, it may happen that the assignment of the pointer variable glActiveTexture happens in some place, but whenever a function with the same name is called, it calls something related from somewhere else.

In C, you usually use a combination of preprocessor macros and a custom prefix to avoid this problem, without having to configure large parts of the code.

 PFNGLMULTITEXCOORD2FARBPROC myglMultiTexCoord2fARB; #define glMultiTexCoord2fARB myglMultiTexCoord2fARB PFNGLACTIVETEXTUREARBPROC myglActiveTexture; #define glActiveTexture myglActiveTexture glActiveTexture = (PFNGLACTIVETEXTUREARBPROC) wglGetProcAddress((LPCSTR)"glActiveTextureARB"); glMultiTexCoord2fARB = (PFNGLMULTITEXCOORD2FARBPROC) wglGetProcAddress((LPCSTR)"glMultiTexCoord2fARB"); 

I really don't know of any other reason why something should fail if you have an active rendering context and extensions are supported.

+1
source

GLEE - a dead library; It has not been updated for a long time.

GLEW is a library for loading thin extensions, but it has some problems with the kernel 3.2 and higher.

I would suggest GL3W . Beauty is that it is renewed; it downloads and analyzes the headers on its own. The downside is that you need to install Python 2.6 to create a bootloader. But otherwise it gives good results.

+1
source

I recommend GLEW / GLEE for extension management.

0
source

The Rastertek tutorial has the full setup necessary for wglGetProcAddress to work. GLEW doesn't work for me either, I tried everything I could think of, and I asked a lot of people about it, but it just didn't work in VS 2012, not to mention the huge disappointment I experienced when I wanted to compile the shader.

0
source

All Articles