Jump to content
  • Advertisement
Sign in to follow this  

Difference when enabling index buffer before and after GL_ARRAY_BUFFER

This topic is 977 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

Hi all,


I tried to find this explanation in the books but could not find anything.



The problem.

When I turn on index buffer after GL_ARRAY_BUFFER. Everythings renders properly

	for (int i = 0; i < model.meshes.size(); i++)
		MD5Mesh* m = &model.meshes[i];
		m->UpdateMesh(m, jointFrame, nullptr, m->deformInfo);
		deformInfo_t* vert = m->deformInfo;
		drawVert* vertD = vert->verts;

		glBindTexture(GL_TEXTURE_2D, tex_id[i]);


		buffer[i].Update(vert->verts, sizeof(vertD[0]) * vert->numSourceVerts);
		glDrawElements(GL_TRIANGLES, m->deformInfo->numIndexes, GL_UNSIGNED_INT, (void*)0);




But when I enable index buffer before enabling GL_ARRAY_BUFFER. I get this



Any ideas why it is like this?


Share this post

Link to post
Share on other sites

You should show how EnableVAO, EnableVBO and Update methods are implemented. And what is the code for failing render? Since you grouped VAO and vertex buffer lines together, I guess you just bound the index buffer before binding the VAO. Just remember that the VAO should be bound first, because the buffers are bound to it.


Share this post

Link to post
Share on other sites
Yes, the current GL_ELEMENT_ARRAY_BUFFER binding is part of the VAO state, so if you change the VAO you'll change that binding, which is most likely what's happening here.

Share this post

Link to post
Share on other sites

First test for an error code, maybe something is screwd up.

Secondly, VAO is created to be bound at first so all you have to do is bind the VAO and not all of the VBO's.

Only the first call to bindings should include the VBOS so openGL knows which buffers are bound to your array.

Lastly, It's easy to do something wrong when dealing with buffers, I'll need to know what kind of update you do in update()...

I might think it probably takes the wrong information. Again depends on how you arrange it.

Edited by WoopsASword

Share this post

Link to post
Share on other sites
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!