Multitexture Crashes

Member
Posts: 509
Joined: 2002.05
Post: #1
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 -

PHP Code:
glDisableGL_LIGHTING );
            
            
glActiveTextureARBGL_TEXTURE0_ARB );
            
glEnableGL_TEXTURE_2D );
            
glBindTextureGL_TEXTURE_2Dgv->texture[4] );
            
// TEXTURE-UNIT #1:
            
glActiveTextureARBGL_TEXTURE1_ARB );
            
glEnableGL_TEXTURE_2D );
            
glBindTextureGL_TEXTURE_2Dgv->texture[5] );

            for (
0theQuadCount[i]; j++)
            {
                                
glMultiTexCoord2fARBGL_TEXTURE0_ARB, (theVertex[theQuad[  i  ][  j  ].w]/1024.0), (theVertex[2+theQuad[  i  ][  j  ].w])/1024.0);
                
glMultiTexCoord2fARBGL_TEXTURE1_ARBtheUV[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]);
                                
glMultiTexCoord2fARBGL_TEXTURE0_ARB, (theVertex[theQuad[  i  ][  j  ].x]/1024.0), (theVertex[2+theQuad[  i  ][  j  ].x])/1024.0);
                
glMultiTexCoord2fARBGL_TEXTURE1_ARBtheUV[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]);
                                
glMultiTexCoord2fARBGL_TEXTURE0_ARB, (theVertex[theQuad[  i  ][  j  ].y]/1024.0), (theVertex[2+theQuad[  i  ][  j  ].y])/1024.0);
                
glMultiTexCoord2fARBGL_TEXTURE1_ARBtheUV[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]);
                
                
glMultiTexCoord2fARBGL_TEXTURE0_ARB, (theVertex[theQuad[  i  ][  j  ].z]/1024.0), (theVertex[2+theQuad[  i  ][  j  ].z])/1024.0);
                
glMultiTexCoord2fARBGL_TEXTURE1_ARBtheUV[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:
glBindTextureGL_TEXTURE_2DtexturetextureOn ] );
            
glTexParameteriGL_TEXTURE_2DGL_TEXTURE_MAG_FILTERGL_LINEAR );
            
glTexParameteriGL_TEXTURE_2DGL_TEXTURE_MIN_FILTER,GL_LINEAR_MIPMAP_NEAREST );
            
gluBuild2DMipmapsGL_TEXTURE_2DGL_RGBsize[textureOn], size[textureOn], GL_RGB,GL_UNSIGNED_BYTE, [imageRep[textureOnbitmapData]); 


Load lightmap -
PHP Code:
glBindTexture(GL_TEXTURE_2DtexturetextureOn ]);
            
glPixelStorei(GL_UNPACK_ALIGNMENT1);
            
glTexParameteri(GL_TEXTURE_2DGL_TEXTURE_WRAP_SGL_REPEAT);
            
glTexParameteri(GL_TEXTURE_2DGL_TEXTURE_WRAP_TGL_REPEAT);
            
glTexParameteri(GL_TEXTURE_2DGL_TEXTURE_MAG_FILTERGL_LINEAR);
            
glTexParameteri(GL_TEXTURE_2DGL_TEXTURE_MIN_FILTERGL_LINEAR);
            
glTexEnvi(GL_TEXTURE_ENVGL_TEXTURE_ENV_MODEGL_MODULATE);
            
glTexImage2D(GL_TEXTURE_2D03size[textureOn],size[textureOn], 0GL_RGBGL_UNSIGNED_BYTE, [imageRep[textureOnbitmapData]); 
Quote this message in a reply
Sage
Posts: 1,232
Joined: 2002.10
Post: #2
Well, where does it crash? At glTexImage? Do you really want an RGB detail texture? Usually they are greyscale.
Quote this message in a reply
Member
Posts: 509
Joined: 2002.05
Post: #3
It crashes on this line

PHP Code:
                glVertex3f(theVertex[theQuad[  i  ][  j  ].w],theVertex[1+theQuad[  i  ][  j  ].w],theVertex[2+theQuad[  i  ][  j  ].w]); 
, here are the threads -

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.
Quote this message in a reply
Sage
Posts: 1,232
Joined: 2002.10
Post: #4
In that case, check your i and j; you're probably going past the end of your array.
Quote this message in a reply
Member
Posts: 509
Joined: 2002.05
Post: #5
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?
Quote this message in a reply
Sage
Posts: 1,232
Joined: 2002.10
Post: #6
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.
Quote this message in a reply
Member
Posts: 509
Joined: 2002.05
Post: #7
Doh, I forgot a GL_Begin, it got deleted while I was changing the code.

EDIT : Fixed, Thanks!
Quote this message in a reply
Post Reply 

Possibly Related Threads...
Thread: Author Replies: Views: Last Post
  Cocoa: NSRectFillListWithColors crashes Lycander 0 1,916 Aug 23, 2009 10:33 PM
Last Post: Lycander
  Full Screen OpenGL Crashes Blacktiger 13 7,527 Feb 19, 2009 02:39 PM
Last Post: backslash
  (OpenGL) How could I use MultiTexture ? zookgems 2 8,412 Jan 20, 2009 07:20 PM
Last Post: zookgems
  Multitexture support on mac NYGhost 9 4,483 Oct 30, 2003 09:25 PM
Last Post: Mars_999
  Probelms with multitexture vertex arrays Bossa Nova 2 2,822 Jun 24, 2003 04:06 PM
Last Post: Bossa Nova