Results 1 to 2 of 2

Thread: Updating part of a uniform array

  1. #1

    Updating part of a uniform array

    Hi,

    Is it possible to partially update a uniform array?
    For example, the shader contains:

    uniform float foo[10];

    And I want to update a single element.

    According to the man page of glUniform*v it should be possible but there is only a pointer to the data and a count.

    Thanks,

    Etay

  2. #2
    Newbie Frequent Contributor
    Join Date
    Mar 2016
    Posts
    896

    Re: Updating part of a uniform array

    I've not tried this, but according to glGetUniformLocation you need to obtain the location of foo[5] and then can use that to update it with something like:

    Code :
    float new_value = 5.f;
    GLint foo5_loc = glGetUniformLocation(progId, "foo[5]");
    glUniform1fv(foo5_loc, 1, &new_value);

Similar Threads

  1. Updating multiple uniform block variables
    By rguerrero in forum OpenGL: GLSL
    Replies: 0
    Last Post: 11-30-2018, 10:55 AM
  2. Replies: 0
    Last Post: 04-24-2014, 09:28 AM
  3. Is bind/map array alone when part of vao ok?
    By doug65536 in forum OpenGL: Basic Coding
    Replies: 5
    Last Post: 10-13-2011, 08:18 AM
  4. upload struct array to uniform block array?
    By Schnulla in forum OpenGL: Basic Coding
    Replies: 5
    Last Post: 07-27-2010, 03:32 PM
  5. Updating array of vertex coordinates
    By S4pphire in forum OpenGL: Basic Coding
    Replies: 4
    Last Post: 09-08-2004, 05:47 PM

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