Untitled

Published June 10, 2006
Advertisement
Fucking hell, I give up for tonight. I've been trying all night to get OpenGL VBO (Vertex Buffer Objects) to work, and haven't been successful. The data is loaded right. The textures are bound. The VBO's are enabled. The calls are made, no errors are raised.

Nothing is rendered.

So I'm like "okay, I could just be :tard: about VBO's since I've never used them before", so I switch over to using vertex arrays as my backup plan. For the OpenGL-inexperienced, that basically means commenting out a line of code and switching like 3 pointers around. Big deal.

The changes are made, yet nothing changes.

...

So now I'm like "fucking fuck fuck OpenGL fucking hell DIE DIE DIE". Here's the code of death that I'm working with right now - see if you can see an error (because I can't)

#pragma pack( 1 )struct _Vertex {	float x, y;	float tu, tv;	float r, g, b;};#pragma pack()typedef std::vector<_Vertex> DataBuffer;DataBuffer _pendingData;int        _primCount;	glEnableClientState( GL_VERTEX_ARRAY );	glEnableClientState( GL_COLOR_ARRAY );	glEnableClientState( GL_TEXTURE_COORD_ARRAY );	glBindTexture( GL_TEXTURE_2D, _texture.tex );	//glBindBufferARB( GL_ARRAY_BUFFER, _bufferID );	glVertexPointer( 2, GL_FLOAT, sizeof( _Vertex ), &_pendingData.front() + (int)( 0 ) );	glTexCoordPointer( 2, GL_FLOAT, sizeof( _Vertex ), &_pendingData.front() + (int)( 2*sizeof( float ) ) );	glColorPointer( 3, GL_FLOAT, sizeof( _Vertex ), &_pendingData.front() + (int)( 4*sizeof( float ) ) );	glDrawArrays( GL_TRIANGLES, 0, _primCount );	glDisableClientState( GL_TEXTURE_COORD_ARRAY );	glDisableClientState( GL_COLOR_ARRAY );	glDisableClientState( GL_VERTEX_ARRAY );

Given - _pendingData is filled with correct data information, _texture.tex is a valid loaded texture, and _primCount contains the correct number of vertices in the array. The clearcolor is set to magenta, so its not like stuff is rendering in black and hiding on a black background.

I think I'm done with this shit for tonight, going to go binge on something. If you see an error fell free to comment, if not, I'm ripping out the whole wrapper class, comparing to old code, and fucking unit testing that whore until she bleeds.
Previous Entry Untitled
Next Entry Untitled
0 likes 1 comments

Comments

kwijibo
glDrawArrays() wants data in seperates arrays (hence "draw arrays"). So you want something like;
glEnableClientState( GL_VERTEX_ARRAY );
glEnableClientState( GL_COLOR_ARRAY );
glEnableClientState( GL_TEXTURE_COORD_ARRAY );

glBindTexture( GL_TEXTURE_2D, _texture.tex );
glVertexPointer( 2, GL_FLOAT, sizeof( _Vertex ), VertexArray );
glTexCoordPointer( 2, GL_FLOAT, sizeof( _Vertex ), TexCoordArray );
glColorPointer( 3, GL_FLOAT, sizeof( _Vertex ), ColourArray );
glDrawArrays( GL_TRIANGLES, 0, _primCount );

glDisableClientState( GL_TEXTURE_COORD_ARRAY );
glDisableClientState( GL_COLOR_ARRAY );
glDisableClientState( GL_VERTEX_ARRAY );

You can do things using interleaved arrays like you wanted in the example. but I've never done it. Look up glInterleavedArrays(), that might be some help.
June 12, 2006 07:11 PM
You must log in to join the conversation.
Don't have a GameDev.net account? Sign up!
Profile
Author
Advertisement

Latest Entries

Untitled

5309 views

Untitled

1043 views

Untitled

1185 views

Untitled

1100 views

Untitled

1145 views

Untitled

1429 views

Untitled

1098 views

Untitled

999 views

Untitled

1003 views

Untitled

1183 views
Advertisement