Results 1 to 8 of 8

Thread: Display list with 2 texture maps?

  1. #1
    Member Newbie
    Join Date
    Mar 2005
    Posts
    47

    Display list with 2 texture maps?

    Guys

    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

    ......glEnd
    glEndList

    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)

    glPushMatrix
    .....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
    glPopMatrix

    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

    Julian

  2. #2
    Senior Member OpenGL Guru Relic's Avatar
    Join Date
    Apr 2000
    Posts
    2,450

    Re: Display list with 2 texture maps?

    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.)
    Code :
    glPushMatrix
    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
    glPopMatrix
    Add enables and disables according to your OpenGL state you need elsewhere.

  3. #3
    Member Newbie
    Join Date
    Mar 2005
    Posts
    47

    Re: Display list with 2 texture maps?

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

    Oops

    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.

    Julian

  4. #4
    Member Newbie
    Join Date
    Mar 2005
    Posts
    47

    Re: Display list with 2 texture maps?

    Relic

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

    glPushMatrix
    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
    glPopMatrix

    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?

    Thanks

    Julian

  5. #5
    Senior Member OpenGL Guru Relic's Avatar
    Join Date
    Apr 2000
    Posts
    2,450

    Re: Display list with 2 texture maps?

    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.

  6. #6
    Member Newbie
    Join Date
    Mar 2005
    Posts
    47

    Re: Display list with 2 texture maps?

    Astounding

    100% spot on....... I am not worthy

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

    Thanks

    Julian

  7. #7
    Member Newbie
    Join Date
    Mar 2005
    Posts
    47

    Re: Display list with 2 texture maps?

    Work in progress.

    Thanks to all who helped.

    http://www.cadfem.com/ogl7.gif

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

  8. #8
    Senior Member OpenGL Guru Relic's Avatar
    Join Date
    Apr 2000
    Posts
    2,450

    Re: Display list with 2 texture maps?

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

Similar Threads

  1. texture in display list and texture coords in VBO
    By adrien in forum OpenGL: Advanced Coding
    Replies: 0
    Last Post: 10-28-2005, 12:24 AM
  2. Display list corruption when list created in shared library
    By Michael Wouters in forum OpenGL: Advanced Coding
    Replies: 2
    Last Post: 09-16-2005, 10:55 PM
  3. Texture objects -inside- display list
    By P88_Razor in forum OpenGL: Basic Coding
    Replies: 7
    Last Post: 01-22-2003, 11:49 PM
  4. freeing up texture memory needed when freeing up display list?
    By architekt in forum OpenGL: Basic Coding
    Replies: 1
    Last Post: 05-27-2002, 12:48 AM
  5. 98->2000 error in bezier texture in display list
    By in forum OpenGL: Basic Coding
    Replies: 1
    Last Post: 09-25-2001, 06:41 AM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Proudly hosted by Digital Ocean