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 3 of 3

Thread: Updating uniforms between sets of primitives

  1. #1
    Junior Member Newbie
    Join Date
    Dec 2012
    Location
    Germany
    Posts
    6

    Updating uniforms between sets of primitives

    Hello,

    I'm currently rendering geometry stored in indexed vbos and managed by vaos. I use glDrawElements to draw the vbo on the screen.
    Now I've got the problem that I store different (more complex) geometry in one vbo. Each of these geometries requires the same type of uniforms but in order to render each one properly I need to change the uniform between those sets of primitves which form one of my geometries.

    I've read several wiki-entries mentioning that changing uniforms between draw-calls on one vbo is possible but I don't see how to do it with drawElements.
    Can someone help me?

    Thank you,
    GreenOwl

  2. #2
    Senior Member OpenGL Pro
    Join Date
    Apr 2010
    Location
    Germany
    Posts
    1,099
    Setting constant memory values is possible at any time while a shader program is active. It has nothing to do with the bound VBO or VAO. You can go crazy on a shader program and not issue a single draw call, and you can draw 1000s of objects without changing the program or anything associated with this program. The only interaction points between programs and vertex buffer objects are established by binding attributes to indices associated with shader inputs. Show us the code you have and we'll see what you can do.

  3. #3
    Senior Member OpenGL Pro Aleksandar's Avatar
    Join Date
    Jul 2009
    Posts
    1,067
    Quote Originally Posted by GreenOwl View Post
    I've read several wiki-entries mentioning that changing uniforms between draw-calls on one vbo is possible but I don't see how to do it with drawElements.
    Why do you think glDrawElements differs from any other draw call? Changing uniforms between draw calls is as simple as follows:
    Code :
    glUniform*(...);
    glDrawElements(...);
    glUniform*(...);
    glDrawElements(...);
    glUniform*(...);
    glDrawElements(...);

    On the other hand, if you want to change a uniform value during a draw call, that is impossible. That is a case where attributes take part...

Posting Permissions

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