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: glUniform: Matrix representation

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

    glUniform: Matrix representation

    Hello,

    I'm using OpenGL with C++ through glew. Two simple questions:
    1) What format does the matrix (as GLfloat[]) for the function glUniformMatrix__ has to have? I couldn't find any information in the doc nor google.
    2) Is the following safe to do:
    Code :
    GLfloat* vertexBuffer = new GLfloat[dynamicSize];
    glBufferData(GL_ARRAY_BUFFER, dynamicSize * 4, vertexBuffer, GL_STATIC_DRAW);
    delete[] vertexBuffer;
    I ask, because I read somewhere, that OpenGL calls aren't necessarily issued instantly and the pointer might be invalid if the "upload into vram" happens to late.

    Thanks!

  2. #2
    Member Regular Contributor
    Join Date
    Jun 2013
    Posts
    474
    Quote Originally Posted by GreenOwl View Post
    1) What format does the matrix (as GLfloat[]) for the function glUniformMatrix__ has to have?
    It's just MxN floats, e.g. 16 floats for glUniformMatrix4fv(), 6 floats for glUniformMatrix2x3fv(), etc. The elements are in column-major order if the "transpose" argument is false or row-major order if it's true. The interpretation of the matrix is up to the shader.

    Quote Originally Posted by GreenOwl View Post
    2) Is the following safe to do:
    Code :
    GLfloat* vertexBuffer = new GLfloat[dynamicSize];
    glBufferData(GL_ARRAY_BUFFER, dynamicSize * 4, vertexBuffer, GL_STATIC_DRAW);
    delete[] vertexBuffer;
    Yes.
    Quote Originally Posted by GreenOwl View Post
    I ask, because I read somewhere, that OpenGL calls aren't necessarily issued instantly and the pointer might be invalid if the "upload into vram" happens to late.
    Apart from the gl*Pointer functions (glVertexPointer etc), any data referenced by a pointer will be copied before the function returns. In the case of the gl*Pointer functions, the data will be copied before the corresponding draw call (glDrawArrays etc) returns.

Posting Permissions

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