Jump to content
  • Advertisement
Sign in to follow this  
NekoCode

OpenGL Real-time vertex array data update

This topic is 1523 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

Hey guys & girls,

 

I am sorry for my previous thread, actually it was wrong one. 

 

In rendering loop I got something like this:

ModelFace *pFace = faces[faceNumber];
 
glUseProgram( modelProg->id );
glBindVertexArray( vao );
glBindBuffer(GL_ARRAY_BUFFER, bspvbo);
glEnableVertexAttribArray(0);
glBufferData(GL_ARRAY_BUFFER, sizeof(ModelVertex) * pFace->vertexCount, &(vertices[pFace->firstVertexIndex].position), GL_STATIC_DRAW);
glVertexAttribPointer(0, 3, GL_FLOAT, GL_FALSE, sizeof(ModelVertex), 0);
glBindBuffer(GL_ARRAY_BUFFER, 0);
 
glDrawElements(GL_TRIANGLES, pFace->numMeshIndices, GL_UNSIGNED_INT, &(meshIndices[pFace->firstMeshIndex]) );
glUseProgram(0);
glBindVertexArray( 0 );
 

On OpenGL ES 3.0 it works great, but nothing on desktop OpenGL 3.0 ( core ).

I tried another tests with glDrawArrays and it WORKS. But not with glDrawElements. How to update its data?

 

EDIT: Solved! Sorry 

Added this

  glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, ibuffer);
    glBufferData(GL_ELEMENT_ARRAY_BUFFER, pFace->numMeshIndices * sizeof(uint), &meshIndices[pFace->firstMeshIndex], GL_STATIC_DRAW);

 

and changed last parameter of glDrawElements to NULL.

Edited by NekoCode

Share this post


Link to post
Share on other sites
Advertisement
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

GameDev.net is your game development community. Create an account for your GameDev Portfolio and participate in the largest developer community in the games industry.

Sign me up!