Jump to content

  • Log In with Google      Sign In   
  • Create Account


#ActualTheChubu

Posted 03 May 2013 - 06:15 AM

All right. Now more on updating data and such... I have a barebones renderer right now, barely able to draw a heightmap, some soft shading, and a few more things. 

 

I have everything that needs to be sent to the GPU duplicated. Once in a regular float[] array and another in a FloatBuffer. So before sending it to the GPU, I update it (ie, grab float[] data, write it on the FloatBuffer) and make my draw call.

 

Now, this is done with a dirty flag. If you manipulate the array in some way, it gets "dirty" so the update call makes the copy to the buffer, otherwise it does nothing. Actually my math stuff is awfully coupled with OpenGL stuff since matrices and vectors contain both an array with the data and a lazily initializated buffer.

 

Anyway, point is, duplicate data. Do you write directly on the Float/Int/etc Buffers always or you have a "frontend" in the way of a regular array and then update it on a buffer?

 

I understand that Buffer objects have backing arrays already, but the direct buffers needed for OpenGL interop aren't guaranteed to have those.


#1TheChubu

Posted 03 May 2013 - 06:14 AM

I see.

 

Now, I have a barebones renderer right now, barely able to draw a heightmap, some soft shading, and a few more things. 

 

I have everything that needs to be sent to the GPU duplicated. Once in a regular float[] array and another in a FloatBuffer. So before sending it to the GPU, I update it (ie, grab float[] data, write it on the FloatBuffer) and make my draw call.

 

Now, this is done with a dirty flag. If you manipulate the array in some way, it gets "dirty" so the update call makes the copy to the buffer, otherwise it does nothing. Actually my math stuff is awfully coupled with OpenGL stuff since matrices and vectors contain both an array with the data and a lazily initializated buffer.

 

Anyway, point is, duplicate data. Do you write directly on the Float/Int/etc Buffers always or you have a "frontend" in the way of a regular array and then update it on a buffer?

 

I understand that Buffer objects have backing arrays already, but the direct buffers needed for OpenGL interop aren't guaranteed to have those.


PARTNERS