Advertisement

using textured and multitextured polygons together

Started by July 30, 2003 07:55 AM
3 comments, last by Hybrid666 21 years, 7 months ago
hi, i cant get multitexturing and normal texturing working together! im designing a program that renders x number of polygons, and they can either have 1 texture, and be multitextured. my single textured polygons work fine with the rendring code: if(texture) glBindTexture(GL_TEXTURE_2D, *texture); glBegin(GL_TRIANGLE_FAN); glNormal3dv(plane.normal().v); for(int i=0; i.t); glVertex3dv(points.p); } glEnd(); where texture is a pointer to a texture. my multitexturing func looks like this: glActiveTextureARB(GL_TEXTURE0_ARB); glEnable(GL_TEXTURE_2D); glBindTexture(GL_TEXTURE_2D, *texture); for(int h=1; h<=layers; h++) { glActiveTextureARB(GL_TEXTURE0_ARB+h); glEnable(GL_TEXTURE_2D); glBindTexture(GL_TEXTURE_2D, *multitextures[h-1]); } glBegin(GL_TRIANGLE_FAN); glNormal3dv(plane.normal().v); for(int i=0; i<count; i++) { for(int j=0; j<=layers; j++) { glMultiTexCoord2dvARB(GL_TEXTURE0_ARB+j, points.t); } glVertex3dv(points.p); } glEnd(); its a derived function from my polygon class, so it binds the first tex, then binds any multitextures with a loop. seem ok so far? sorry for long post.. almost there <img src="smile.gif" width=15 height=15 align=middle> my texture loading seems to cause the problem tho.. i load a texture normally with a function, and if i want to load a multitexture i use this function: static bool BuildMultiTexture(char *szPathName, GLuint &texid, bool clamp) { //build the normal texture if(!BuildTexture(szPathName, texid, clamp)) return false; //configure multitexturing options glBindTexture(GL_TEXTURE_2D, texid); glTexEnvi(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_ADD); return true; } as soon as i load a texture using this, all my textures dont show up, whether im rendering single, or multi-textured polys any ideas? im a bit of a n00b with multitexturing, any help wud b much appreciated <img src="sad.gif" width=15 height=15 align=middle> hybrid </i>
try this

//firstTexture
glActiveTextureARB(GL_TEXTURE0_ARB);
glEnable(GL_TEXTURE_2D);
glBindTexture(GL_TEXTURE_2D, m_texture[0]);

//second Texture
glActiveTextureARB(GL_TEXTURE1_ARB);
glEnable(GL_TEXTURE_2D);
glBindTexture(GL_TEXTURE_2D, m_texture[1]);

render multitexture

glActiveTextureARB(GL_TEXTURE1_ARB);
glDisable(GL_TEXTURE_2D);

glActiveTextureARB(GL_TEXTURE0_ARB);
glDisable(GL_TEXTURE_2D);

render ''normal'' texture

hope this helps
Advertisement
nah, tried it, but no luck

i reckon th problem lies with the texture loading..

wen iteste multitexturign it worked, and normal texturing works too, its just wen after i load the multitexture, i can no longer render ANY type of textured object

my "BuildTexture(...)" func is v similar to NeHe''s tex loading in his IPicture Basecode, and my multitexture loadign code is:

static bool BuildMultiTexture(char *szPathName, GLuint &texid, bool clamp)
{
//build the normal texture
if(!BuildTexture(szPathName, texid, clamp))
return false;

//configure multitexturing options
glBindTexture(GL_TEXTURE_2D, texid);
glTexEnvi(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_ADD);
return true;
}

is it ok to build a multitexture like this? and is there anythign else i need to do:

enable multitexturing
build normal texture
build multitexture
render normal textured poly
render multitextured poly

its as soon as i build the multitextured poly, it all goes to shit
ok, just found out that excluding the line:
glTexEnvi(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_ADD);

eliminates the problem of no textures showing up, but now my multitextured poloy only shows up one tex unit (i know this is because i havnt blended the two textures cos iv commented out that line above)

so... this give any1 any clues?

do i need to write out a totally specific multitex func, or am i ok to use a normal tex loading func and then tag on the multitex commands at the end like iv done?

cheers
hybrid
No time to look through your code or help in detail, but gametutorials.com have a multitexturing tutorial (in the OpenGL section) that you might find useful. Actually there are 2 multitexturing tuts, one is "Multitexturing" in section 2 (http://www.gametutorials.com/Tutorials/opengl/OpenGL_Pg2.htm) the other is "Detail texturing" in section 4 (http://www.gametutorials.com/Tutorials/opengl/OpenGL_Pg4.htm). Either/both of them might help you.

This topic is closed to new replies.

Advertisement