pspgl - VBO problems

Discuss the development of new homebrew software, tools and libraries.

Moderators: cheriff, TyRaNiD

Post Reply
Kojima
Posts: 275
Joined: Mon Jun 26, 2006 3:49 am

pspgl - VBO problems

Post by Kojima »

I'm trying to write a vbo visualizer for raptor, but for some reason it crashes everytime I try to upload the texcoord's. The initial vertex buffer send works fine, so I'm not sure what could be causing it.

Here's the code. it crashes right after I log "Sending uv data". No error screen, just a blank screen for 20 seconds followed by an automatic power-down.

Code: Select all

class VL_VertexBufferObject : public Visualizer
{
public:
	virtual Visualizer * RequestNew()
	{
		return (Visualizer *) new VL_VertexBufferObject;
	}
	virtual void CreateResources()
	{
		Logger->Log("Creating VBO resources.\n");
		glGenBuffersARB( 1, &_vbuf );
		glGenBuffersARB( 1, &_tbuf );
		glGenBuffersARB( 1, &_uvbuf );
		Logger->Log("Created.\n");
	}
	
	virtual void SyncData()
	{
		Logger->Log("Syncing data.\n");
		glBindBufferARB( GL_ARRAY_BUFFER_ARB, _vbuf );	
		Logger->Log("Sending data.\n");
		glBufferDataARB( GL_ARRAY_BUFFER_ARB, _vertc*3*sizeof(float), (void *)_verts, GL_STATIC_DRAW_ARB );
		Logger->Log("Sent.\n");	
		_mat->_texs.start();
		int stage = 0;
		while( _mat->_texs.next() == true )
		{
			if( stage == 0 )
			{
				Texture *tex = _mat->_texs.get();
				Logger->Log("Binding uvbuf\n");
				glBindBufferARB( GL_ARRAY_BUFFER_ARB,_uvbuf );	
				Logger->Log("Bound.\n");
				Logger->Log("Sending uv data.\n");
				glBufferDataARB( GL_ARRAY_BUFFER_ARB, _vertc*3*sizeof(float),(void *)_coords[tex->_coordset]->_uv, GL_STATIC_DRAW_ARB );
				Logger->Log("Sent.\n");
			}
			stage++;
		}		
		Logger->Log("Synced.\n");
	}
	
	virtual void Bind()
	{
		Logger->Log("Binding VBO\n");
		glEnableClientState( GL_VERTEX_ARRAY );	
		glEnableClientState(GL_TEXTURE_COORD_ARRAY);
						
		glBindBufferARB( GL_ARRAY_BUFFER_ARB, _vbuf );
		glVertexPointer( 3,GL_FLOAT,0,(char *)NULL);
		glBindBufferARB( GL_ARRAY_BUFFER_ARB, _vbuf );
		glTexCoordPointer( 3,GL_FLOAT,0,(char *)NULL);
		Logger->Log("Bound.\n");
	}
	
	virtual void Unbind()
	{
		Logger->Log("Unbinding.\n");
		glDisableClientState( GL_VERTEX_ARRAY );	
		glDisableClientState(GL_TEXTURE_COORD_ARRAY);
		Logger->Log("Unbound.\n");	
	}
	virtual void Render()
	{
		Logger->Log("Rendering VBO \n");
		glDrawElements(GL_TRIANGLES,_tric*3,GL_UNSIGNED_INT,_tris);
		Logger->Log("Rendered.\n");
	}
	GLuint _vbuf;
	GLuint _tbuf;
	GLuint _uvbuf;
};

Here's the logger output.

Code: Select all

System Logger 
Loaded texture.back1.bmp 
Loaded jpg star1.jpg 
Loading b3d ship1.b3d 
Tag=BB3D 
BB3DTex File:HopperUV.tif 
Loaded texture.HopperUV.tif 
Loaded.
Loadb3d returned valid entity.
Loaded texture.fnt1.bmp 
Entities:2 
Got Entity.
Creating VBO resources.
Created.
Syncing data.
Sending data.
Sent.
Binding uvbuf
Bound.
Sending uv data.

Post Reply