Jump to content
  • Advertisement
Sign in to follow this  
Lator

Multitexturing runtime error

This topic is 3649 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

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?

Share this post


Link to post
Share on other sites
Advertisement
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.

Share this post


Link to post
Share on other sites
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?

Share this post


Link to post
Share on other sites
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).

Share this post


Link to post
Share on other sites
Yes, it included to glext.h:
#ifndef GL_ARB_multitexture
#define GL_ARB_multitexture 1
#ifdef GL_GLEXT_PROTOTYPES
GLAPI 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...

Share this post


Link to post
Share on other sites
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()):
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?

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

Participate in the game development conversation and more when you create an account on GameDev.net!

Sign me up!