Jump to content

  • Log In with Google      Sign In   
  • Create Account

Interested in a FREE copy of HTML5 game maker Construct 2?

We'll be giving away three Personal Edition licences in next Tuesday's GDNet Direct email newsletter!

Sign up from the right-hand sidebar on our homepage and read Tuesday's newsletter for details!


We're also offering banner ads on our site from just $5! 1. Details HERE. 2. GDNet+ Subscriptions HERE. 3. Ad upload HERE.


#ActualMarkS

Posted 05 July 2013 - 10:49 PM

Solved. I blame this on 4 days of less than 3 hours of sleep per night. Ha. 
 
When I draw, I was doing: 
 
glDrawArrays(GL_TRIANGLES, 1, this.numVerts);
 
I step over the first degenerate vertex as I should. The problem was that, stupid me, this.numVerts was being calculated wrong.. 
 
I was doing:
 
this.numVerts = this.vbuffer.position() / 8;
 
instead of 
 
this.numVerts = this.vbuffer.position() / 12;
 
You'll see my blocks hold 12 floats per vertex.

That would do it as well! Been there, done that. And quite recently! dry.png 
 

I suppose it's useful to know that if you tell glDrawArrays(GL_TRIANGLES, 1, x); where x is larger than the currently bound buffer, you can and will overrun it and spill over into surrounding memory.


Well, yes. This is no different than accessing an array out of bounds on a CPU. You'll successfully access the data outside of the array, but the result will not be what you expect.
 
I do stand by what I said about using glBufferSubData...
 
glBufferData

glBufferData creates a new data store for the buffer object currently bound to target. Any pre-existing data store is deleted. The new data store is created with the specified size in bytes and usage.

 
glBufferSubData

glBufferSubData redefines some or all of the data store for the buffer object currently bound to target. Data starting at byte offset offset and extending for size bytes is copied to the data store from the memory pointed to by data. An error is thrown if offset and size together define a range beyond the bounds of the buffer object's data store.

When replacing the entire data store, consider using glBufferSubData rather than completely recreating the data store with glBufferData. This avoids the cost of reallocating the data store.


You *can* use glBufferData, but you'll see a performance drop as it has to delete the data and then create a new data store. glBufferSubData works within the existing buffer's memory store and doesn't do any expensive memory allocation/management.

#4MarkS

Posted 05 July 2013 - 10:47 PM

Solved. I blame this on 4 days of less than 3 hours of sleep per night. Ha. 
 
When I draw, I was doing: 
 
glDrawArrays(GL_TRIANGLES, 1, this.numVerts);
 
I step over the first degenerate vertex as I should. The problem was that, stupid me, this.numVerts was being calculated wrong.. 
 
I was doing:
 
this.numVerts = this.vbuffer.position() / 8;
 
instead of 
 
this.numVerts = this.vbuffer.position() / 12;
 
You'll see my blocks hold 12 floats per vertex.

That would do it as well! Been there, done that. And quite recently! dry.png 
 

I suppose it's useful to know that if you tell glDrawArrays(GL_TRIANGLES, 1, x); where x is larger than the currently bound buffer, you can and will overrun it and spill over into surrounding memory.


Well, yes. This is no different than accessing an array out of bounds on a CPU. You'll successfully access the data outside of the array, but the result will not be what you expect.
 
I do stand by what I said about using glBufferSubData...
 
glBufferData

glBufferData creates a new data store for the buffer object currently bound to target. Any pre-existing data store is deleted. The new data store is created with the specified size in bytes and usage.

 

glBufferSubData

glBufferSubData redefines some or all of the data store for the buffer object currently bound to target. Data starting at byte offset offset and extending for size bytes is copied to the data store from the memory pointed to by data. An error is thrown if offset and size together define a range beyond the bounds of the buffer object's data store.


You *can* use glBufferData, but you'll see a performance drop as it has to delete the data and then create a new data store. glBufferSubData works within the existing buffer's memory store and doesn't do any expensive memory allocation/management.


#3MarkS

Posted 05 July 2013 - 10:47 PM

Solved. I blame this on 4 days of less than 3 hours of sleep per night. Ha. 
 
When I draw, I was doing: 
 
glDrawArrays(GL_TRIANGLES, 1, this.numVerts);
 
I step over the first degenerate vertex as I should. The problem was that, stupid me, this.numVerts was being calculated wrong.. 
 
I was doing:
 
this.numVerts = this.vbuffer.position() / 8;
 
instead of 
 
this.numVerts = this.vbuffer.position() / 12;
 
You'll see my blocks hold 12 floats per vertex.

That would do it as well! Been there, done that. And quite recently! dry.png 
 

I suppose it's useful to know that if you tell glDrawArrays(GL_TRIANGLES, 1, x); where x is larger than the currently bound buffer, you can and will overrun it and spill over into surrounding memory.


Well, yes. This is no different than accessing an array out of bounds on a CPU. You'll successfully access the data outside of the array, but the result will not be what you expect.
 
I do stand by what i said about using glBufferSubData...
 
glBufferData

glBufferData creates a new data store for the buffer object currently bound to target. Any pre-existing data store is deleted. The new data store is created with the specified size in bytes and usage.

 

glBufferSubData

glBufferSubData redefines some or all of the data store for the buffer object currently bound to target. Data starting at byte offset offset and extending for size bytes is copied to the data store from the memory pointed to by data. An error is thrown if offset and size together define a range beyond the bounds of the buffer object's data store.


You can use glBufferData, but you'll see a performance drop as it has to delete the data and then create a new data store. glBufferSubData works within the existing buffer's memory store and doesn't do any expensive memory allocation/management.


#2MarkS

Posted 05 July 2013 - 10:46 PM

Solved. I blame this on 4 days of less than 3 hours of sleep per night. Ha. 
 
When I draw, I was doing: 
 
glDrawArrays(GL_TRIANGLES, 1, this.numVerts);
 
I step over the first degenerate vertex as I should. The problem was that, stupid me, this.numVerts was being calculated wrong.. 
 
I was doing:
 
this.numVerts = this.vbuffer.position() / 8;
 
instead of 
 
this.numVerts = this.vbuffer.position() / 12;
 
You'll see my blocks hold 12 floats per vertex.

That would do it as well! Been there, done that. And quite recently! dry.png 
 

I suppose it's useful to know that if you tell glDrawArrays(GL_TRIANGLES, 1, x); where x is larger than the currently bound buffer, you can and will overrun it and spill over into surrounding memory.

Well, yes. This is no different than accessing an array out of bounds on a CPU. You'll successfully access the data outside of the array, but the result will not be what you expect.
 
I do stand by what i said about using glBufferSubData...
 
glBufferDataglBufferData[/url]

glBufferData creates a new data store for the buffer object currently bound to target. Any pre-existing data store is deleted. The new data store is created with the specified size in bytes and usage.

glBufferSubDataglBufferSubData[/url]

glBufferSubData redefines some or all of the data store for the buffer object currently bound to target. Data starting at byte offset offset and extending for size bytes is copied to the data store from the memory pointed to by data. An error is thrown if offset and size together define a range beyond the bounds of the buffer object's data store.

You can use glBufferData, but you'll see a performance drop as it has to delete the data and then create a new data store. glBufferSubData works within the existing buffer's memory store and doesn't do any expensive memory allocation/management.

#1MarkS

Posted 05 July 2013 - 10:38 PM

Solved. I blame this on 4 days of less than 3 hours of sleep per night. Ha. 
 
When I draw, I was doing: 
 
glDrawArrays(GL_TRIANGLES, 1, this.numVerts);
 
I step over the first degenerate vertex as I should. The problem was that, stupid me, this.numVerts was being calculated wrong.. 
 
I was doing:
 
this.numVerts = this.vbuffer.position() / 8;
 
instead of 
 
this.numVerts = this.vbuffer.position() / 12;
 
You'll see my blocks hold 12 floats per vertex.

That would do it as well! Been there, done that. And quite recently! dry.png 
 

I suppose it's useful to know that if you tell glDrawArrays(GL_TRIANGLES, 1, x); where x is larger than the currently bound buffer, you can and will overrun it and spill over into surrounding memory.


Well, yes. This is no different than accessing an array out of bounds on a CPU. You'll successfully access the data outside of the array, but the result will not be what you expect.


PARTNERS