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

Thread: Noob question about uniform arrays, how to fill them?

  1. #1
    Junior Member Newbie
    Join Date
    Apr 2010
    Posts
    10

    Question Noob question about uniform arrays, how to fill them?

    If I want to fill a uniform array of structures, do I have no choice but to retrieve the location of each variable within each structure of the array? (so I can submit the uniform values individually like a regular uniform variable)

    glGetUniformLocation(programId, "test[0].a");
    glGetUniformLocation(programId, "test[0].b");
    glGetUniformLocation(programId, "test[0].c");
    glGetUniformLocation(programId, "test[1].a");
    glGetUniformLocation(programId, "test[1].b");
    glGetUniformLocation(programId, "test[1].c");
    .
    .
    .
    glGetUniformLocation(programId, "test[n].a");
    glGetUniformLocation(programId, "test[n].b");
    glGetUniformLocation(programId, "test[n].c");


    Like that?
    Is there an alternative like filling a buffer object or something similar?

    Thanks in advance.

  2. #2
    Junior Member Newbie
    Join Date
    Oct 2012
    Posts
    12
    No, it should be simplier, declare array in shader and then move the whole content by using one of the functions glUniform (see details here http://www.opengl.org/sdk/docs/man/xhtml/glUniform.xml).

    In general, by glGetUniformLocation you are getting a kind of a reference to the uniform variable, then you use glUniform to push the value to the GPU, such value can be array. For arrays use glUniform1fv or similar type of functions.

Tags for this Thread

Posting Permissions

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