Jump to content

  • Log In with Google      Sign In   
  • Create Account


#Actualslicer4ever

Posted 19 January 2013 - 04:35 AM

to add to L. Spiro's answer, when updating the vbo(which should be dynamic), do not use glBufferData, instead map the buffer, and write the values like so:

 

 

//assumed that everything is setup for drawing. 
MyVertexStruct *VBOMap = (MyVertexStruct*)
glMapBuffer(GL_ARRAY_BUFFER, GL_WRITE_ONLY); 
int o=0; 
for(int i=0;i<ParticlesCount;i++,o+=sizeof(MyVertexStruct)){   
 if(o>=BufferSize){    
  glUnMapBuffer(GL_ARRAY_BUFFER);    
  glDrawArrays(GL_TRIANGLES, 0, o);    
  VBOMap = (MyVertexStruct*)glMapBuffer(GL_ARRAY_BUFFER, GL_WRITE_ONLY);    
  o=0;
 }
 (VBOMap+o).xyz = Particle[i].xyz;
}
glUnMapBuffer(GL_ARRAY_BUFFER);
glDrawArrays(GL_TRIANGLES, 0, o)
//other stuff.

#2slicer4ever

Posted 19 January 2013 - 04:34 AM

to add to L. Spiro's answer, when updating the vbo(which should be dynamic), do not use glBufferData, instead map the buffer, and write the values like so:

 

//assumed that everything is setup for drawing. MyVertexStruct *VBOMap = (MyVertexStruct*)glMapBuffer(GL_ARRAY_BUFFER, GL_WRITE_ONLY); int o=0; for(int i=0;i<ParticlesCount;i++,o+=sizeof(MyVertexStruct)){   if(o>=BufferSize){    glUnMapBuffer(GL_ARRAY_BUFFER);    glDrawArrays(GL_TRIANGLES, 0, o);    VBOMap = (MyVertexStruct*)glMapBuffer(GL_ARRAY_BUFFER, GL_WRITE_ONLY);    o=0;
 }
  (VBOMap+o).xyz = Particle[i].xyz;
}
glUnMapBuffer(GL_ARRAY_BUFFER);
glDrawArrays(GL_TRIANGLES, 0, o)
//other stuff.


#1slicer4ever

Posted 19 January 2013 - 04:34 AM

to add to L. Spiro's answer, when updating the vbo(which should be dynamic), do not use glBufferData, instead map the buffer, and write the values like so:

 

[code=auto:0]//assumed that everything is setup for drawing.
MyVertexStruct *VBOMap = (MyVertexStruct*)glMapBuffer(GL_ARRAY_BUFFER, GL_WRITE_ONLY);
int o=0;
for(int i=0;i<ParticlesCount;i++,o+=sizeof(MyVertexStruct)){
  if(o>=BufferSize){
   glUnMapBuffer(GL_ARRAY_BUFFER);
   glDrawArrays(GL_TRIANGLES, 0, o);
   VBOMap = (MyVertexStruct*)glMapBuffer(GL_ARRAY_BUFFER, GL_WRITE_ONLY);
   o=0;

 }

  (VBOMap+o).xyz = Particle[i].xyz;

}

glUnMapBuffer(GL_ARRAY_BUFFER);

glDrawArrays(GL_TRIANGLES, 0, o)

//other stuff.


PARTNERS