Jump to content
  • Advertisement

Archived

This topic is now archived and is closed to further replies.

VanKurt

Getting started with VBO

This topic is 5573 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''m having some trouble with implanting the VBO extension. Here is a little code snippet, which shows how I render a quad. But the problem is that nothing appears on the screen. So I must have done something wrong ;-) !! BUt because of the fact that these extensions are too well documented I cannot find out what the problem is....
	// Allocate memory

	vec *data;
	data = new vec[4];

	// Fill data

	data[0].x = 0; data[0].y = 0; data[0].z = 0;
	data[1].x = 6; data[1].y = 0; data[1].z = 0;
	data[2].x = 6; data[2].y = 6; data[2].z = 0;
	data[3].x = 0; data[3].y = 6; data[3].z = 0;

	// Create buffer object

	glBindBufferARB( GL_ARRAY_BUFFER_ARB, 1 );
	// Initialize data store of buffer object

	glBufferDataARB( GL_ARRAY_BUFFER_ARB, 4, data, GL_STATIC_DRAW_ARB);

	// free data

	delete data;


	// Define arrays

	glBindBufferARB( GL_ARRAY_BUFFER_ARB, 1);
	glVertexPointer( 3, GL_FLOAT, 0, BUFFER_OFFSET(0) );
	// Enable arrays

	glEnableClientState(GL_VERTEX_ARRAY);
	// Draw arrays

	glDrawArrays( GL_QUADS, 0, 4 );
	// Disable arrays

	glDisableClientState( GL_VERTEX_ARRAY );


	// Delete buffer object

	GLuint buffer[1] = {1};
	glDeleteBuffersARB( 1, buffer );
Thanks!!!

Share this post


Link to post
Share on other sites
Advertisement
i have no idea of VBO yet but is there something like

glGenBuffer
textures and OpenAL use this as well

Share this post


Link to post
Share on other sites
I think ur size parameter is incorrect (according to the spec it should be in basic machine units (bytes))

If you still have more problems take a look at the vbo example at

http://www.delphi3d.net/

It''s in Delphi but it''s really straight forward. Also if all else fails, try commenting out the vbo stuff (so ur just using normal vertex array) just to see if it''s not anything else. hope it helps.

Share this post


Link to post
Share on other sites
Yeah, the size should be in bytes, not the number of elements in the array that you specify ( you are actually specifying a pointer to the start of the memory that you want to be copied, and the size of that memory ). So put 48 in there ( assuming you're using floats in your vec structure ).

[edit: can't add up]

Death of one is a tragedy, death of a million is just a statistic.

[edited by - python_regious on June 17, 2003 6:26:58 PM]

Share this post


Link to post
Share on other sites

  • 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!