Multitexture Crashes
I am going to try to make a lightmap plus a detail texture for my terrain engine, and I can not get it to render without crashing. It just loads the window and then crashes with a signal 11 (I think it was 11). Here is my code -
EDIT : The 1 texture code works fine, so the data should be correct.
Render -
Load detail -
Load lightmap -
EDIT : The 1 texture code works fine, so the data should be correct.
Render -
PHP Code:
glDisable( GL_LIGHTING );
glActiveTextureARB( GL_TEXTURE0_ARB );
glEnable( GL_TEXTURE_2D );
glBindTexture( GL_TEXTURE_2D, gv->texture[4] );
// TEXTURE-UNIT #1:
glActiveTextureARB( GL_TEXTURE1_ARB );
glEnable( GL_TEXTURE_2D );
glBindTexture( GL_TEXTURE_2D, gv->texture[5] );
for (j = 0; j < theQuadCount[i]; j++)
{
glMultiTexCoord2fARB( GL_TEXTURE0_ARB, (theVertex[theQuad[ i ][ j ].w]/1024.0), (theVertex[2+theQuad[ i ][ j ].w])/1024.0);
glMultiTexCoord2fARB( GL_TEXTURE1_ARB, theUV[theQuad[ i ][ j ].a]/div,theUV[1+theQuad[ i ][ j ].a]/div );
glVertex3f(theVertex[theQuad[ i ][ j ].w],theVertex[1+theQuad[ i ][ j ].w],theVertex[2+theQuad[ i ][ j ].w]);
glMultiTexCoord2fARB( GL_TEXTURE0_ARB, (theVertex[theQuad[ i ][ j ].x]/1024.0), (theVertex[2+theQuad[ i ][ j ].x])/1024.0);
glMultiTexCoord2fARB( GL_TEXTURE1_ARB, theUV[theQuad[ i ][ j ].b]/div,theUV[1+theQuad[ i ][ j ].b]/div );
glVertex3f(theVertex[theQuad[ i ][ j ].x],theVertex[1+theQuad[ i ][ j ].x],theVertex[2+theQuad[ i ][ j ].x]);
glMultiTexCoord2fARB( GL_TEXTURE0_ARB, (theVertex[theQuad[ i ][ j ].y]/1024.0), (theVertex[2+theQuad[ i ][ j ].y])/1024.0);
glMultiTexCoord2fARB( GL_TEXTURE1_ARB, theUV[theQuad[ i ][ j ].c]/div,theUV[1+theQuad[ i ][ j ].c]/div );
glVertex3f(theVertex[theQuad[ i ][ j ].y],theVertex[1+theQuad[ i ][ j ].y],theVertex[2+theQuad[ i ][ j ].y]);
glMultiTexCoord2fARB( GL_TEXTURE0_ARB, (theVertex[theQuad[ i ][ j ].z]/1024.0), (theVertex[2+theQuad[ i ][ j ].z])/1024.0);
glMultiTexCoord2fARB( GL_TEXTURE1_ARB, theUV[theQuad[ i ][ j ].d]/div,theUV[1+theQuad[ i ][ j ].d]/div );
glVertex3f(theVertex[theQuad[ i ][ j ].z],theVertex[1+theQuad[ i ][ j ].z],theVertex[2+theQuad[ i ][ j ].z]);
}
glEnd();
Load detail -
PHP Code:
glBindTexture( GL_TEXTURE_2D, texture[ textureOn ] );
glTexParameteri( GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR );
glTexParameteri( GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER,GL_LINEAR_MIPMAP_NEAREST );
gluBuild2DMipmaps( GL_TEXTURE_2D, GL_RGB, size[textureOn], size[textureOn], GL_RGB,GL_UNSIGNED_BYTE, [imageRep[textureOn] bitmapData]);
Load lightmap -
PHP Code:
glBindTexture(GL_TEXTURE_2D, texture[ textureOn ]);
glPixelStorei(GL_UNPACK_ALIGNMENT, 1);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_REPEAT);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_REPEAT);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR);
glTexEnvi(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_MODULATE);
glTexImage2D(GL_TEXTURE_2D, 0, 3, size[textureOn],size[textureOn], 0, GL_RGB, GL_UNSIGNED_BYTE, [imageRep[textureOn] bitmapData]);
Well, where does it crash? At glTexImage? Do you really want an RGB detail texture? Usually they are greyscale.
It crashes on this line
, here are the threads -
The texture is just as much of a surface type map as a light map, if not more. It will be nice to have a surface map pre-calculated instead of doing lighting at runtime with normals.
PHP Code:
glVertex3f(theVertex[theQuad[ i ][ j ].w],theVertex[1+theQuad[ i ][ j ].w],theVertex[2+theQuad[ i ][ j ].w]);
PHP Code:
#0 0x04bb1bd8 in gldDestroyQuery
#1 0x025bad5c in Stage3<true>::doIt(GLDContextRec*, Vertex const*, Vertex const*, Vertex const*, Vertex const*)
#2 0x02559d34 in Stage3<true>::doIt(GLDContextRec*, Vertex const*, Vertex const*, Vertex const*, Vertex const*)
The texture is just as much of a surface type map as a light map, if not more. It will be nice to have a surface map pre-calculated instead of doing lighting at runtime with normals.
In that case, check your i and j; you're probably going past the end of your array.
Everythinghad a value of 0x0, and I am sure thats not the problem because it is the same exact loop code as one right before it that works (the one that uses a single texture).
Also, this code started as the NeHe basecode, and I checked number 22 which uses bump map multitexturing and I am getting the same error symptoms, window shows for a second and then crashes.
Do I need to do any other setup to get the second texture unit to work?
Also, this code started as the NeHe basecode, and I checked number 22 which uses bump map multitexturing and I am getting the same error symptoms, window shows for a second and then crashes.
Do I need to do any other setup to get the second texture unit to work?
The OSX port of NeHe lesson 22 has obvious memory problems in -LoadGLTextures (it is using data after freeing it.) If you fix that, the multitexturing works fine.
There's no other setup you need to do besides turning on texturing and binding for each texture unit.
There's no other setup you need to do besides turning on texturing and binding for each texture unit.
Doh, I forgot a GL_Begin, it got deleted while I was changing the code.
EDIT : Fixed, Thanks!
EDIT : Fixed, Thanks!
Possibly Related Threads...
| Thread: | Author | Replies: | Views: | Last Post | |
| Cocoa: NSRectFillListWithColors crashes | Lycander | 0 | 1,701 |
Aug 23, 2009 10:33 PM Last Post: Lycander |
|
| Full Screen OpenGL Crashes | Blacktiger | 13 | 6,543 |
Feb 19, 2009 02:39 PM Last Post: backslash |
|
| (OpenGL) How could I use MultiTexture ? | zookgems | 2 | 7,198 |
Jan 20, 2009 07:20 PM Last Post: zookgems |
|
| Multitexture support on mac | NYGhost | 9 | 4,127 |
Oct 30, 2003 09:25 PM Last Post: Mars_999 |
|
| Probelms with multitexture vertex arrays | Bossa Nova | 2 | 2,551 |
Jun 24, 2003 04:06 PM Last Post: Bossa Nova |
|

