Multitexturing runtime error
Hi.
It's need the multitexturing in the program. I created function's pointers, initialized them with wglGetProcAddress() and program had been compiled without errors. But in runtime there is the errors "Unhanled exception at 0x00000000 ..." at functions glMultiTexCoord2f() and glActiveTextureARB(). So, if to comment these functions program works properly.
What's the problem?
When calling wglGetProcAddress(), make sure it's return value is not NULL. If it is, you're doing something wrong and we'll need to see more code to help you further.
Had checked it up - yes, every returned parameter is NULL.
Program is too big for entire including, so I will write out just important parts of it:
I included <glext.h> and created pointers as globals like this:
PFNGLACTIVETEXTUREARBPROC glActiveTextureARB;
PFNGLMULTITEXCOORD2FARBPROC glMultiTexCoord2f;
And initialized them in WM_CREATE (before than any of these functions can be used):
glActiveTextureARB = (PFNGLACTIVETEXTUREARBPROC) wglGetProcAddress("glActiveTextureARB");
glMultiTexCoord2f = (PFNGLMULTITEXCOORD2FARBPROC) wglGetProcAddress("glMultiTexCoord2f");
I tried to use function's pointers as (*glActiveTextureARB)... but it did not helped (but what's the matter if pointers are NULL).
What can be wrong?
Program is too big for entire including, so I will write out just important parts of it:
I included <glext.h> and created pointers as globals like this:
PFNGLACTIVETEXTUREARBPROC glActiveTextureARB;
PFNGLMULTITEXCOORD2FARBPROC glMultiTexCoord2f;
And initialized them in WM_CREATE (before than any of these functions can be used):
glActiveTextureARB = (PFNGLACTIVETEXTUREARBPROC) wglGetProcAddress("glActiveTextureARB");
glMultiTexCoord2f = (PFNGLMULTITEXCOORD2FARBPROC) wglGetProcAddress("glMultiTexCoord2f");
I tried to use function's pointers as (*glActiveTextureARB)... but it did not helped (but what's the matter if pointers are NULL).
What can be wrong?
According to this you can call GetLastError() to get more information about the error.
I'm not very experienced with OpenGL so I don't know what else to suggest, except making sure that you initialize OpenGL properly. Also, it might help if you post the initialization code. If you do, post it using source tags (see the FAQ to learn how to do that).
I'm not very experienced with OpenGL so I don't know what else to suggest, except making sure that you initialize OpenGL properly. Also, it might help if you post the initialization code. If you do, post it using source tags (see the FAQ to learn how to do that).
Are you sure those are in your version of glext? I got the latest one and most the handles did not have ARB attached so i used an older version.
Yes, it included to glext.h:
and so on...
#ifndef GL_ARB_multitexture#define GL_ARB_multitexture 1#ifdef GL_GLEXT_PROTOTYPESGLAPI void APIENTRY glActiveTextureARB (GLenum);GLAPI void APIENTRY glClientActiveTextureARB (GLenum);GLAPI void APIENTRY glMultiTexCoord1dARB (GLenum, GLdouble);GLAPI void APIENTRY glMultiTexCoord1dvARB (GLenum, const GLdouble *);GLAPI void APIENTRY glMultiTexCoord1fARB (GLenum, GLfloat);GLAPI void APIENTRY glMultiTexCoord1fvARB (GLenum, const GLfloat *);GLAPI void APIENTRY glMultiTexCoord1iARB (GLenum, GLint);GLAPI void APIENTRY glMultiTexCoord1ivARB (GLenum, const GLint *);GLAPI void APIENTRY glMultiTexCoord1sARB (GLenum, GLshort);GLAPI void APIENTRY glMultiTexCoord1svARB (GLenum, const GLshort *);GLAPI void APIENTRY glMultiTexCoord2dARB (GLenum, GLdouble, GLdouble);
and so on...
I found out the mistake.
In InitGL() functions I have all initializations and, at first, there was a function call SetTimer() and after that call InitGL() function was not executing further because of WM_TIMER where is all my painting code which uses texturing function's pointers which was not initialized. So, I moved SetTimer() to the end of the InitGL() function and program began to work properly.
But, anyway, there is no texture mapping. Here is code:
Loading texture (only once in InitGL()):
And texture mapping (every WM_PAINT):
But texture does not imposing. But if to comment glBindTexture() functions (or replace "1" by "0") evrething works properly. So, as I think, texture are applyed to 0 (default) texture. What means that multitexturing does not works properly.
What's wrong?
In InitGL() functions I have all initializations and, at first, there was a function call SetTimer() and after that call InitGL() function was not executing further because of WM_TIMER where is all my painting code which uses texturing function's pointers which was not initialized. So, I moved SetTimer() to the end of the InitGL() function and program began to work properly.
But, anyway, there is no texture mapping. Here is code:
Loading texture (only once in InitGL()):
ilLoadImage("Sunset.jpg");int imageWidth = ilGetInteger(IL_IMAGE_WIDTH);int imageHeight = ilGetInteger(IL_IMAGE_HEIGHT);glActiveTextureARB(GL_TEXTURE0_ARB);glEnable(GL_TEXTURE_2D);glBindTexture(GL_TEXTURE_2D, 1);glTexImage2D(GL_TEXTURE_2D, 0, GL_RGB, imageWidth, imageHeight, 0, GL_RGB, GL_UNSIGNED_BYTE, ilGetData());
And texture mapping (every WM_PAINT):
glActiveTextureARB(GL_TEXTURE0_ARB);glEnable(GL_TEXTURE_2D);glBindTexture(GL_TEXTURE_2D, 1);glBegin(GL_QUADS);glMultiTexCoord2f(GL_TEXTURE0_ARB, 1, 1);glTexCoord2f(1, 1);glVertex3d(1, 1, 1);glMultiTexCoord2f(GL_TEXTURE0_ARB, 1, 0);glTexCoord2f(1, 0);glVertex3d(1, 0, 1);glMultiTexCoord2f(GL_TEXTURE0_ARB, 0, 0);glTexCoord2f(0, 0);glVertex3d(-1, 0, 1);glMultiTexCoord2f(GL_TEXTURE0_ARB, 0, 1);glTexCoord2f(0, 1);glVertex3d(-1, 1, 1);glEnd();glDisable(GL_TEXTURE_2D);
But texture does not imposing. But if to comment glBindTexture() functions (or replace "1" by "0") evrething works properly. So, as I think, texture are applyed to 0 (default) texture. What means that multitexturing does not works properly.
What's wrong?
This topic is closed to new replies.
Advertisement
Popular Topics
Advertisement