PDA

View Full Version : Multitexturing Problems



31337
12-22-2002, 11:30 PM
First of all - sorry for the constant pestering. Since I've been on break I've literally been coding for like 15 hours a day so as you can image, the more coding time you have is directly proportional to how many problems you run into http://www.opengl.org/discussion_boards/ubb/smile.gif

Ok here's my problem: I'm using this far out method of multitexturing with Glext.h or something that I'm TOTALLY unsatisfied with. In openGL 2.0 they'd better standardize multitexturing because this method seems really lame. However its the best I can do right now so here's the deal, the code I'm having problems with looks like this:



glActiveTextureARB = (PFNGLACTIVETEXTUREARBPROC) wglGetProcAddress("glActiveTextureARB");
glClientActiveTextureARB = (PFNGLACTIVETEXTUREARBPROC) wglGetProcAddress("glClientActiveTextureARB");

// Here we make sure that the functions were loaded properly
if(!glActiveTextureARB | | !glClientActiveTextureARB)
{
cout << "YOUR VIDEO CARD DOESNT LIKE MULTITEXTURING!" << endl;
}

glMultiTexCoord2fARB = (PFNGLMULTITEXCOORD2FARBPROC)
wglGetProcAddress("glMultiTexCoord2fARB");
glActiveTextureARB = (PFNGLACTIVETEXTUREARBPROC)
wglGetProcAddress("glActiveTextureARB");
glClientActiveTextureARB = (PFNGLCLIENTACTIVETEXTUREARBPROC)
wglGetProcAddress("glClientActiveTextureARB");

Thats in my bspLoader function at the top.




int BSP::renderFace(int index) {
tBSPFace *face = &amp;faces[index];
glColor3f(1, 1, 1);
glEnable(GL_TEXTURE_2D);

glActiveTextureARB(GL_TEXTURE0_ARB);
glEnable(GL_TEXTURE_2D);
glBindTexture(GL_TEXTURE_2D, m_textures[face->textureID]);

glActiveTextureARB(GL_TEXTURE1_ARB);
glEnable(GL_TEXTURE_2D);
glBindTexture(GL_TEXTURE_2D, light[face->lightmapID]);

glDrawArrays(GL_TRIANGLE_FAN, face->vertexIndex, face->numOfVerts);
return DONE;
}

int BSP::drawBSP(int mode) {
glPushMatrix();
/* Setup the multitexturing */



glClientActiveTextureARB(GL_TEXTURE0_ARB);
glTexCoordPointer(2, GL_FLOAT, sizeof(tBSPVertex), &amp;(vertices[0].vTextureCoord));

glClientActiveTextureARB(GL_TEXTURE1_ARB);
glTexCoordPointer(2, GL_FLOAT, sizeof(tBSPVertex), &amp;(vertices[0].vLightmapCoord));

glEnableClientState(GL_TEXTURE_COORD_ARRAY);

// Setup our vertex array settings
glVertexPointer(3, GL_FLOAT, sizeof(tBSPVertex), &amp;(vertices[0].vPosition));
glEnableClientState(GL_VERTEX_ARRAY);
for(int i = 0; i<numFaces; i++) {
renderFace(i);
}
glPopMatrix();
return DONE;
}


and thats what my draw face and draw BSP functions look like. Now my problem is I get REALLY weird looking texturing results. The purpose here is to multitexture each face with a proper lightmap and with a detail texture. When I uncomment the lightmap texturing, the detail texture loads fine. When I uncomment the detail texture, everything turns grey. Is this normal? Is this what a lightmap is supposed to look like?

The next strange phenomonon is that I'm also drawing an md2 model on screen. When I comment out the detail texture the textureing on the md2 works fine (single texture). When I put the detail texture in along with the lightmap, it breaks the texturing on the md2 and makes it completely black.

Does anybody have any idea whats going so terribly, terribly wrong here? Thanks so much

31337
12-22-2002, 11:32 PM
Hah I forgot to mention what happens when I have them both turned on. Then I get some polygons with apparently no lightmap and a detail texture, and some polygons with a lightmap and no detail texture.