Part of the Khronos Group
OpenGL.org

The Industry's Foundation for High Performance Graphics

from games to virtual reality, mobile phones to supercomputers

Results 1 to 7 of 7

Thread: Light shader and texture (in display lists...)

Hybrid View

  1. #1
    Intern Newbie
    Join Date
    Oct 2010
    Posts
    47

    Light shader and texture (in display lists...)

    Hello,

    I had an old code like this :
    glColor(c);
    glCallList(l);


    I replaced it with :
    LoadShader();
    SendColor with glUniform
    glCallList(l)
    ;

    But in some display lists there are textures. And in these cases my shader does not render the texture...
    I have seen today that in classical code the textures are sent to the shader.

    I can not change the display lists code (lot of old existing code...).

    1- What can I do to obtain the correct rendering (I am a beginner...) ?
    2- Is there a solution with minor change in the display lists ?

    Thanks for your advices.

  2. #2
    Senior Member OpenGL Guru Dark Photon's Avatar
    Join Date
    Oct 2004
    Location
    Druidia
    Posts
    3,124
    Quote Originally Posted by AllForum View Post
    1- What can I do to obtain the correct rendering (I am a beginner...) ?
    2- Is there a solution with minor change in the display lists ?
    It depends what all is in the display list and what exactly you're trying to do.

  3. #3
    Intern Newbie
    Join Date
    Oct 2010
    Posts
    47
    The display lists draw geometry with old opengl 1.1 functions :
    - they set geometry attributes : line width, line stipple, polygon stipple or texture
    - they draw the geometry with basic functions and glutess
    they draw text : i do not understand the code but it seems to be only geometry (wglUseFontOutlines, gl_quads and glutess).

    The shader I added is a simple phong shader to add light.
    And I suppressed the glcolor because I learned here that it's wrong to use old opengl 1.1 functions.
    But I did not thought to the textures... I did not read things about textures when I read how a shader works...

    And I use opengl 2.0 or 2.1...

  4. #4
    Intern Newbie
    Join Date
    Oct 2010
    Posts
    47
    Hello,

    I am trying something but it does not work yet. I would like to know if it may work :

    - I create a display list and store the textureID used during the display list creation.

    When I render :
    - Send textureID with glUniform to the fragment shader
    - glCallList(l);

    In the fragment shader I retrieve the texel :
    - vec4 texel = texture2D(TextureID, gl_TexCoord[0].st);

    Does this work ?
    If yes I will search why the texture is black...

    Thanks

  5. #5
    Senior Member OpenGL Pro Aleksandar's Avatar
    Join Date
    Jul 2009
    Posts
    1,067
    The answer is: NO.
    The first parameter of texture2D is not a texture ID. Setting texture inside DL is generaly a bad idea.

  6. #6
    Senior Member OpenGL Pro Aleksandar's Avatar
    Join Date
    Jul 2009
    Posts
    1,067
    Let me explain the previous answer a little bit better...
    The first parameter of the texture2D is a sampler. A sampler defines which texture unit will be used for the texture lookup.
    To associate a texture to a texture unit you should use glActiveTexture(...);/glBindTexture(...); pair. The value in the sampler should be the value set in glActiveTexture(value) (or to bi more precise, value-GL_TEXTURE0). As you can see, glBindTexture(...) should be call explicitly in GL code.

    Considering DLs, binding textures should be done outside of them. There are different problems if you do in in a compiled DL. From very slow execution to different anomalies. Try to pull them out of DLs to see if there are any improvements.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •