Skip to main content
gamedev.net
🔒 Locked

multi-tex problems

Started by Tera_Dragon Jan 22, 2005 at 3:59 PM 9 replies 900+ views
Original Post
Tera_Dragon
Tera_Dragon
I have a model that uses normal 2D texturing and a terrain that uses multi-texturing. The probelm is that when I try to render both the model and the terrain only the terrain's textures render properly. The model is just grey. If I don't load the terrain though the model is rendered correctly. I have just worked out that this only occurs when I use GL_TEXTURE1_ARB. I can use GL_TEXTURE0_ARB without any trouble. I got these from the gametutorials height_map3 tutorial... #define GL_TEXTURE0_ARB 0x84C0 #define GL_TEXTURE1_ARB 0x84C1 I'm playing with the code as I'm writting this, and I've just found out that if I don't disable one of the GL_TEXTURE#_ARB then the model will be rendered with that texture. Is it somehow over writting the model texture? Thanks in advance for any help Tera_Dragon EDIT: If I don't disable GL_TEXTURE1_ARB then the model is rendered black...
____________________________________________________________Programmers Resource Central
Kalidor
Kalidor
Make sure that when you render the model only the texture unit that it uses is enabled and that it is the current texture unit. Other than that I can't help much without seeing some relevant code.
Tera_Dragon
Tera_Dragon
What do you mean by the texture unit? I have a texture class that keeps the texture ID of each texture. If you don't mean that then please tell me what you do mean.
After loading the textures that I will be using for multi-texturing, and before rendering them, I use the following:

glActiveTextureARB(GL_TEXTURE0_ARB);
glEnable(GL_TEXTURE_2D);
texture.bind();

glActiveTextureARB(GL_TEXTURE1_ARB);
glEnable(GL_TEXTURE_2D);
glTexEnvi(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_COMBINE_ARB);
glTexEnvi(GL_TEXTURE_ENV, GL_RGB_SCALE_ARB, 2);
detailTexture.bind();


Also, after rendering the terrain I use:

glActiveTextureARB(GL_TEXTURE0_ARB);
glDisable(GL_TEXTURE_2D);

glActiveTextureARB(GL_TEXTURE1_ARB);
glDisable(GL_TEXTURE_2D);


Please tell me if you need any more info.
____________________________________________________________Programmers Resource Central
nts
nts
Texture unit or TMU (Texture Mapping Unit) is what you enable and disable for multiple texture support with glActiveTextureARB.

What the above post meant was that make sure you only have unit 0 active when rendering the model. Make sure it (unit 0) is enabled and correctly bound to the texture.

btw you should also use
glActiveTextureARB(...);glClientActiveTextureARB(...);

when enabling and disabling the units
Tera_Dragon
Tera_Dragon
So should I change what GL_TEXTURE1_ARB everytime I am rendering a different texture? So that in one frame it could be used for the textures of eg 15 different models?
What does glClientActiveTextureARB() do?

EDIT: I have the model texturing working now, thanks! [:D] However i would still like to know what glClientActiveTextureARB() is.
____________________________________________________________Programmers Resource Central
nts
nts
Quote:
Original post by Tera_Dragon
However i would still like to know what glClientActiveTextureARB() is.


It'll allow you to have a different texture coordinates array for each texture unit (must enable the texture coord array for each unit aswell).
Gorax
Gorax
I seriously doubt that what zix99 does works correctly. All that'd be doing is setting the current active texture to 0, which isn't even a texture. I have encountered problems when trying to render single-textured surfaces with textures still active, so I'd stick with the way you're doing it, since I've had no problems doing it that way.
zedzeek
zedzeek
glActiveTextureARB(GL_TEXTURE0_ARB);
...
...
glActiveTextureARB(GL_TEXTURE1_ARB);
glDisable(GL_TEXTURE_2D);
i think the problem is youve left texunit 1 as the current active unit

glActiveTextureARB(GL_TEXTURE0_ARB);
glEnable(GL_TEXTURE_2D);
texture.bind();
glActiveTextureARB(GL_TEXTURE1_ARB);
glEnable(GL_TEXTURE_2D);
glTexEnvi(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_COMBINE_ARB);
glTexEnvi(GL_TEXTURE_ENV, GL_RGB_SCALE_ARB, 2);
detailTexture.bind();

Also, after rendering the terrain I use:

glActiveTextureARB(GL_TEXTURE1_ARB); <-- 1
glDisable(GL_TEXTURE_2D);

glActiveTextureARB(GL_TEXTURE0_ARB);
glDisable(GL_TEXTURE_2D); <-- u prolly want to keep this enabled though

Topic Locked

This topic has been locked by a moderator. New replies are not allowed.

Sign in to reply to this topic.