Note that there are some explanatory texts on larger screens.

plurals
  1. POOpenGL ES: glBufferSubData fills meshes into VBO/IBO, then glDrawElements renders only the first mesh instead of all of them
    text
    copied!<p>My problem seems to be really simple but I just can't get the reason behind it:</p> <ul> <li>I have a vertex and an index buffer that get filled in with glBufferSubData. There are a couple of meshes that get filled in one-by-one into this big VBO and its corresponding IBO</li> <li>Then I try to render those small meshes with glDrawElements one-by-one</li> </ul> <p>Problem is, only first mesh gets rendered - and multiple times - in places where each of those different meshes should be!!!</p> <p>Following info may be useful:</p> <p>I create VBO this way</p> <pre><code>gl.glGenBuffers(1, buffers_, 0); gl.glBindBuffer(GL11.GL_ARRAY_BUFFER, buffers_[0]); gl.glBufferData(GL11.GL_ARRAY_BUFFER, sizeInBytes, null, GL11.GL_DYNAMIC_DRAW); </code></pre> <p>Then each mesh is filled into the VBO like this</p> <pre><code>gl.glBindBuffer(GL11.GL_ARRAY_BUFFER, name); gl.glBufferSubData(GL11.GL_ARRAY_BUFFER, startOffsetInBytes, numBytesToCopy, nioBuffer); </code></pre> <p>And meshes are rendered in this fasion</p> <ul> <li>bind VBO/IBO and set appropriate client states</li> <li>then set vertex, normal, and texcoord "pointers" - they point at the beginning of VBO plus their offsets in vertex "structure"</li> <li>and call <code>gl.glDrawElements(GL10.GL_TRIANGLES, indicesNum, GL10.GL_UNSIGNED_SHORT, startIndexOffsetInBytes);</code></li> <li>then finally, unbind VBO/IBO and disable client states</li> </ul> <p>I debugged the code and I'm sure that <code>sizeInBytes</code>, <code>startOffsetInBytes</code>, <code>numBytesToCopy</code> and <code>startIndexOffsetInBytes</code> are correct values (in bytes:))) and <code>indicesNum</code> is the number of indices/vertices in the mesh (to render).</p> <p>One suspicious place is setting vertex/normal/texcoord pointers - they get set only once - and set to the beginning of the VBO. Maybe I need to set them each time before calling glDrawElements?</p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload