Display list with 2 texture maps?


Based on some great advice gained here I am moving on at a pace and my app is going well…

I have a question concerning texture maps and display lists.

I pre-bulid various displaylists which contain scalar results normalized and texture mapped… I.e

glNewList 10, lstCompile
…glBegin bmTriangles
…glTexCoord2f 0.555, 0
…glVertex3f 0, 0, 0

…ETC x10000


Note the texture value per vertex. This will be mapped to a texture array that will be modified in code so that the user can change colours etc

Now the question.

I also want to display the polygon edges via glPolygonOffset using a black outline and I would like to use the display list created.

Basically I can’t get it to work.

I define a black texture map but when I run my code it seems to work with either the original map or black map but not both.

In pseudo code this is what I want to do

  1. Display polygons in display list as filled using texture1 (fancy colours)
  2. Display polygons in display list as line boundaries using solid black texture (texture2)
  3. Render model to screen

This is the kind of thing I am doing (it doesn’t work)

…glBindTexture GL_TEXTURE_2D, bitmapImage(0, 0, 0)
…glPolygonMode faceFrontAndBack, pgmFILL
…glDisable glcPolygonOffsetFill
…glCallList 10

…glBindTexture GL_TEXTURE_2D, Black(0, 0, 0)
…glPolygonMode faceFrontAndBack, pgmLine
…glEnable glcPolygonOffsetFill
…glPolygonOffset 1, 1
…glCallList 10

Am I on the right line?

Or should I just build a copy of the display list without the textures to plot the outlines (seems way crude to have to copy the display list)

Many thanks as always


Dude, you used the wrong polygon offset mode.

glBindTexture GL_TEXTURE_2D, Black(0, 0, 0)
glPolygonMode faceFrontAndBack, pgmLine
glEnable glcPolygonOffsetFill does not affect line mode!
glPolygonOffset 1, 1 // Screen space! This would push the lines in.
glCallList 10

You could also push the filled geomtry in and render the polygonmode lines with no offset.

There is no need to render textured if you just want single color outlines. Just disable textures and lighting and set the color to black.
(I don’t use your language this is pseudo code.)

glBindTexture GL_TEXTURE_2D, bitmapImage(0, 0, 0) 
glPolygonMode faceFrontAndBack, pgmFILL
glPolygonOffset 1, 1 // push in
glEnable glcPolygonOffsetFill
glCallList 10
glDisable glcPolygonOffsetFill

glDisable GL_TEXTURE_2D
glDisable GL_LIGHTING // if needed
glColor3f 0.0f, 0.0f, 0.0f
glPolygonMode faceFrontAndBack, pgmLine
glCallList 10

Add enables and disables according to your OpenGL state you need elsewhere.

>>Dude, you used the wrong polygon offset mode.

Oops :slight_smile:

Hey thanks Relic

Right, i’m on it… I may come back with other questions as I get my head round whats going on.

Anyway thanks again. I appreciate the lightning quick reply.



The following code (more or less as per your reply) - works ok

    glEnable GL_TEXTURE_2D
    glEnable GL_LIGHTING
    glPolygonMode faceFrontAndBack, pgmFILL
    glEnable glcPolygonOffsetFill
    glPolygonOffset 1, 1
    glCallList 10

    glDisable GL_TEXTURE_2D
    glDisable GL_LIGHTING
    glDisable glcPolygonOffsetFill
    glPolygonMode faceFrontAndBack, pgmLine
    glColor3f 0, 1, 1
    glCallList 10

But I have found that I need lighting on for it to work.

If I comment out glEnable GL_LIGHTING the texture mapping doesn’t work and the model is rendered in the the last colour set (Cyan in the above example)

I don’t really want lighting in this app.
I can get the texture mapping working without lighting but not with the glPolygonMode faceFrontAndBack, pgmLine stuff.

Is there something ‘obvious’ wrong with my method?



1.) If lighting is on, the glColor should not have an effect, materials are used in that case, unless you have enabled GL_COLOR_MATERIAL.
2.) Lighting only works correctly if you have specified correct normals at your vertices! You have none, it uses the last state, default is (0,0,1).
3.) The texture environment default is GL_MODULATE. If you don’t want your textures being modulated by the primary color of your objects, which is calculated by lighting or set with glColor if lighting is off, you need to use a different glTexEnv mode like GL_REPLACE or GL_DECAL which use the pure texture colors (replace does something with the alpha though).

Means: Remove all glEnable(GL_LIGHTING) and glDisable(GL_LIGHTING) and set glTexEnvi(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_DECAL); during initialisation. You could also set all objects’ colors back to the default white before modulating it with the texture, which has the same effect.


100% spot on… I am not worthy

You have saved me much grief and I owe you a beer or two.



Work in progress.

Thanks to all who helped.


I still have masses to learn but I’m getting there

You’re welcome. :smiley:
I mixed up replace and decal. Decal mode is the one using the alpha. Better use GL_REPLACE.