PDA

View Full Version : Multitexturing trouble



06-22-2004, 12:01 AM
I have two texture units and one ordinary texture.
The problem is that when I try to render the object with the ordinary texture on it, it instead has the texture unit, that I have used before on another object, rendered to it.
Some one has told me to disable multitexturing, but I can't find out how to do this. Please could someone help me.
Tera_Dragon

CrazyButcher
06-22-2004, 03:05 AM
multitexturing means that the object you draw can have 2 or more textures at once

like one texture for colors, and another one for shadows (lightmap)

texture units = the amount of textures your graphicscard can handle with a single pass

---

so whatever your problem is doesnt sound like multitexturing, because one has to specifically enable it and set it up, which needs use of extensions and so on

not really sure what the exact problem is, posting code would help
but for now just make sure you bind your texture before you render the object...

06-22-2004, 04:26 AM
I am using multitexturing, that's why I asked ;)

I've solved the problem now. What I was doing wrong is when I was setting the texCoords I was putting the wrong texture object name.

06-22-2004, 05:36 AM
Do I have to use some thing like

glActiveTextureARB(GL_TEXTURE1_ARB);
glDisable(GL_TEXTURE_2D);
glActiveTextureARB(GL_TEXTURE0_ARB);
glEnable(GL_TEXTURE_2D);when I want to use just one of the textures on an object, or not use on texture unit and use another two?
Or could I have normal textures (not texture units) as well as texture units on different objects at the same time? I have tried to do this but the normal texture is always rendered white.

CrazyButcher
06-22-2004, 11:18 PM
with "normal" texture you mean just a your average colored texture or ?

the general opengl would just always use the first texture unit
to my knowledge if you want to use only one texture, it should be placed in the first unit
then disable the second, as you do it

be aware that when using texturecoord arrays that you need to enable/disable them with glClientActive...
and set pointers for each active unit as well.

06-23-2004, 02:21 AM
If a usual texture (or normal as I said), just uses the first texture unit how come you can have lots of textures?

I also have to enable/disable every texture unit if I want to just display one on an object, even though I only put one texture unit when I am setting the coords.


be aware that when using texturecoord arrays that you need to enable/disable them with glClientActive...
and set pointers for each active unit as well. Could you just give me a link to an easy tutorial on this?

Aeluned
06-23-2004, 05:33 AM
Originally posted by <Tera_Dragon>:
I have two texture units and one ordinary texture.
You seem to be confused and/or you are confusing me. What does that mean?
A texture unit can be thought of as a 'Texture Layer'. With your first texture unit you lay down your first texture,
with your second you lay down the second texture, etc...



The problem is that when I try to render the object with the ordinary texture on it, it instead has the texture unit, that I have used before on another object, rendered to it.
Some one has told me to disable multitexturing, but I can't find out how to do this.
You're not binding the correct texture.
you rendered some previous geometry with a given texture bound. Make sure you're binding the correct texture before you render your new geometry.
MultiTexturing isn't something you enable/disable, it's something you explicitly do by setting the active texture unit and issuing calls to glMultiTexCoord or passing these tex coords in a texture coord array.
what you have to be careful of is ensuring that you're setting the correct active texture (texture unit) and that you have the correct texture bound for each texture unit.
You'll also find that you're going to want to set your TexEnv methods for each texture unit.

a quick primer (2nd link from Google):
http://tfpsly.planet-d.net/english/3d/multitexturing.html

CrazyButcher
06-23-2004, 10:43 PM
for example this would set pointers for all tex units


for (n = 0; n < g_GLState.capTexUnits; n++){
glActiveTextureARB( GL_TEXTURE0_ARB +n);
glClientActiveTextureARB( GL_TEXTURE0_ARB +n);
glEnableClientState(GL_TEXTURE_COORD_ARRAY);
glTexCoordPointer(2,GL_FLOAT,12*sizeof(GLfloat),&amp;p ointvert[0]);
}likely just calling clientActiveTexture without activeTexture.. would be enough, but I saw it crash on a sis driver when client was called without active texture bound to same unit

the rest enables vertex arrays and sets pointers
be aware so that now the active texture would be the last unit, so maybe changing order or whatnot would be better