Jump to content
  • Advertisement
Sign in to follow this  
SimonS

OpenGL Using buffers

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

I have a problem when I use buffers to cash memory on GPU. The program crash with code: 0xC0000005 mNumIndices is 36 and mNumVertices is 24. Here´s my "bind" code:
	glGenBuffers(1, &mElemBuffer);
	glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, mElemBuffer );
	glBufferData(GL_ELEMENT_ARRAY_BUFFER, mNumIndices * sizeof(GLuint),
                     mIndices, GL_STATIC_DRAW);

	glGenBuffers(1, &mArrBuffer);
	glBindBuffer(GL_ARRAY_BUFFER, mElemBuffer );
	glBufferData(GL_ARRAY_BUFFER, mNumVertices * sizeof(GLfloat), mVertices,
                     GL_STATIC_DRAW);

	glBindBuffer(GL_ARRAY_BUFFER, 0);
	glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, 0 );
When I draw my box I use this code:
	glBindBuffer(GL_ARRAY_BUFFER,	      mArrBuffer);
	glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, mElemBuffer);

        ...

	glDrawElements( GL_TRIANGLES, mNumIndices, GL_UNSIGNED_INT, mIndices );

	glBindBuffer(GL_ARRAY_BUFFER, 0);
	glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, 0);
If I comment the two glBindBuffer before rendering, it works. But then I dont use the buffers. Hmm .. Please help me. New to OpenGL. Btw, its OpenGLES 2.0. But that doesnt matter I think. [Edited by - SimonS on January 20, 2009 10:59:13 AM]

Share this post


Link to post
Share on other sites
Advertisement
Quote:

glGenBuffers(1, &mArrBuffer);
glBindBuffer(GL_ARRAY_BUFFER, mElemBuffer );
glBufferData(GL_ARRAY_BUFFER, mNumVertices * sizeof(GLfloat), mVertices, GL_STATIC_DRAW);

Looks like a typo. You didn't bind your mArrBuffer.

Share this post


Link to post
Share on other sites
Quote:
Original post by KulSeran
Quote:

glGenBuffers(1, &mArrBuffer);
glBindBuffer(GL_ARRAY_BUFFER, mElemBuffer );
glBufferData(GL_ARRAY_BUFFER, mNumVertices * sizeof(GLfloat), mVertices, GL_STATIC_DRAW);

Looks like a typo. You didn't bind your mArrBuffer.


Thanks for answering.
I fixed that, but still the same problem :(

Share this post


Link to post
Share on other sites
Quote:
Original post by SimonS

glDrawElements( GL_TRIANGLES, mNumIndices, GL_UNSIGNED_INT, mIndices );




Unless you choose some particular indices, you shuld pass NULL (or 0) as the last parameter when an index buffer is bound.

Share this post


Link to post
Share on other sites
Quote:
Original post by rozz666
Quote:
Original post by SimonS

glDrawElements( GL_TRIANGLES, mNumIndices, GL_UNSIGNED_INT, mIndices );




Unless you choose some particular indices, you shuld pass NULL (or 0) as the last parameter when an index buffer is bound.


Okej, thanx. But the problem is still. I`ve fixed the two you mentioned.

Share this post


Link to post
Share on other sites
According to their specification (from khronos.org)

2.8 Vertex Arrays
you would have to use glVertexAtrribPointer
glEnableVertexAttribArray( uint index );
glDisableVertexAttribArray( uint index );

so glVertexPointer and the rest are killed off. Good idea.

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.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!