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: Doubt about initialize mesh

  1. #1
    Junior Member Newbie
    Join Date
    Jan 2013
    Posts
    7

    Doubt about initialize mesh

    Hi!
    If I change the value of the vertices from a mesh after call this code, Must I calling it again?:

    Code :
     glGenVertexArrays(1, &BufferIds[0]);
     
        ExitOnGLError("ERROR: No se puede generar el VAO");
        glBindVertexArray(BufferIds[0]);
        ExitOnGLError("ERROR: No se puede bindear el VAO");
     
        // Activamos dos vertex attribute locations
        glEnableVertexAttribArray(0);
        glEnableVertexAttribArray(1);
        ExitOnGLError("ERROR: No se puede activar los vertex attributes");
     
        // Creamos los VBO
        glGenBuffers(2, &BufferIds[1]);
        ExitOnGLError("ERROR: No se pueden generar los buffer objects");
     
        // Bindeamos el VBO al VAO
        glBindBuffer(GL_ARRAY_BUFFER, BufferIds[1]);
        glBufferData(GL_ARRAY_BUFFER, vtn.size()*sizeof(VertexTextureNormal), &vtn[0], GL_STATIC_DRAW);
        ExitOnGLError("ERROR: No se puede bindear el VBO al VAO");
     
        glVertexAttribPointer(0, 4, GL_FLOAT, GL_FALSE, sizeof(vtn[0]) ,0);
        glVertexAttribPointer(1, 2, GL_FLOAT, GL_FALSE, sizeof(vtn[0]) , (GLvoid*) sizeof(vtn[0].position));
        ExitOnGLError("ERROR: Could not set VAO attributes");
     
        // Creamos el IBO
        glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, BufferIds[2]);
        glBufferData(GL_ELEMENT_ARRAY_BUFFER, indices.size() * sizeof(GLuint), &indices.front(), GL_STATIC_DRAW);
        ExitOnGLError("ERROR: No se puede bindear el IBO al VAO");
     
        glBindVertexArray(0);

  2. #2
    Senior Member OpenGL Pro BionicBytes's Avatar
    Join Date
    Mar 2009
    Location
    UK, London
    Posts
    1,170
    Quote Originally Posted by shotoreaper View Post
    If I change the value of the vertices from a mesh after call this code, Must I calling it again?:
    I don't think you need to redine the VAO if you're just going to fill up the same buffer objects with new data.
    If that's what you are doing, then you may want to reconsider the GL_STATIC_DRAW hint - as that's best used for cases when the data is never changed.

  3. #3
    Junior Member Newbie
    Join Date
    Jan 2013
    Posts
    7
    Im going to see if the program works if I use GL_DYNAMIC_DRAW and glBufferSubData to change the data.

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
  •