Multi-Texturing and .... normal texturing?

Hi, im slowly learning openGL and upto now ive been doing ok, but now got stuck.

Ive done all the basics and made a simple level editor / loader ETC but upto now only used single textures on objects.

So ive had a go at terrain generation from height maps which is all fine, i managed to texture it, along with a few cubes and a skybox.

So… i decided in the calllist for the terrain, i decided to change it to use multitextures?

and the problems i am left with have completly confused me, and i cannot see why its happening.

So… the problems im left with… ALL objects in the scene are now being textured with unit1’s texture (cubes and skybox), the terrain is being textured fine with multi-textures,

And they all look like they have darkened up, which i think is to do the line…


BTW, this might look strange, as im using lua, but its very similer as you will know.

So, what might be causing the problems?

All 3 objects (cube, skybox and terrain) are in individual calllists, created before the draw loop, and then i simply Push & Pop each calllist in the main draw loop?

Its as if that as soon as i “active” a texture unit, it disables the use of just single normal texturing?


Push and pop call lists? You mean push and pop the matrix stack right?

Anyhoo, your problem. the active texture must be set for unit 0 and unit 1 when adjusting it.

Your symptoms suggest that you have assumed in your code or the display lists you build that unit 0 is the active texture target on entry but unit 1 may still be active when entering your texture setup.

The active texture unit is a piece of state that is set, it is not encapsulated in the display list, only calls to set this state are captured by the display list.

So you may have unit 0 as the actuve texture when you build your display list, but unless your display list explicitly sets the active texture to 0 or your code invoking the list sets it to 0 first, any texture calls will be applied to the active texture lying around in the pipe. And I bet your multitexture code leaves texture unit 1 not texture unit 0 as the active texture unit when you exit your lists.

Ok, so i think i undrstand now… It still seems though that when i use more units on my terrain, its either making all other objects dim in brightness or its like coloring the objects with a shade of the next units texture?

I dont get it? Basically, if i call my create terrian function and use only 1 texture, everything is fine, the terrain, skybox and cube all with different textures. I then call the terrain with 2 textures, and the whole scene like dims?


That’s NOT what I said.

The active texture unit is a state variable. It is not capured in a display list unless you call glActiveTexture at the start of that display lists.

There is no such thing as pushing and popping display lists. Whatever state is changed in the pipeline hangs around. unless you explicitlu push and pop that state for example with the matrix stack.

This is why OpenGL is called a state machine and why display lists just encapsulate changes to that state machine, NOT the state itself.

P.S. whether your scene dims with a second texture is dependent on what you do with teh texture. it should not be doing anything you don’t expect with the wrong texture. Whenever you are not using a texture unit the state should be set to glDisable for that unused unit.