Sign in to follow this  
  • entries
    570
  • comments
    2427
  • views
    216025

Untitled

Sign in to follow this  
Mushu

60 views

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.
Sign in to follow this  


1 Comment


Recommended Comments

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.

Share this comment


Link to comment

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now