Jump to content
  • Advertisement
Sign in to follow this  
regart

VBOs, Visually Blank Objects?

This topic is 4146 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 trying to implement VBO's into a 2D engine I worte a few years back and I'm not having much luck. I believe I have set the VBO up correctly but I'm getting nothing other than a blank screen. Any Suggestions? Here is the initialisation code for the VBOs
this->m_Pos_Verts_ptr = new class clsVert[this->ml_RenderListLength * 4];
		this->m_Texture_Verts_ptr = new class clsVert[this->ml_RenderListLength * 4];
        
		this->m_LastPos_Verts_ptr = this->m_Pos_Verts_ptr;
		this->m_LastTexture_Verts_ptr = this->m_Texture_Verts_ptr;

		for (iL = this->L.begin();
				iL != this->L.end();
				++ iL)
		{		
			this->m_LastPos_Verts_ptr->mf_X = (*iL)->Get_X();
			this->m_LastPos_Verts_ptr->mf_Y = (*iL)->Get_Y() + (*iL)->Get_Height();

			++ this->m_LastPos_Verts_ptr;

			this->m_LastTexture_Verts_ptr->mf_X = 0.0f;
			this->m_LastTexture_Verts_ptr->mf_Y = 1.0f;

			++ this->m_LastTexture_Verts_ptr;

			this->m_LastPos_Verts_ptr->mf_X = (*iL)->Get_X() + (*iL)->Get_Width();
			this->m_LastPos_Verts_ptr->mf_Y = (*iL)->Get_Y() + (*iL)->Get_Height();

			++ this->m_LastPos_Verts_ptr;

			this->m_LastTexture_Verts_ptr->mf_X = 1.0f;
			this->m_LastTexture_Verts_ptr->mf_Y = 1.0f;

			++ this->m_LastTexture_Verts_ptr;

			this->m_LastPos_Verts_ptr->mf_X = (*iL)->Get_X() + (*iL)->Get_Width();
			this->m_LastPos_Verts_ptr->mf_Y = (*iL)->Get_Y();

			++ this->m_LastPos_Verts_ptr;

			this->m_LastTexture_Verts_ptr->mf_X = 1.0f;
			this->m_LastTexture_Verts_ptr->mf_Y = 0.0f;

			++ this->m_LastTexture_Verts_ptr;

			this->m_LastPos_Verts_ptr->mf_X = (*iL)->Get_X();
			this->m_LastPos_Verts_ptr->mf_Y = (*iL)->Get_Y();

			++ this->m_LastPos_Verts_ptr;

			this->m_LastTexture_Verts_ptr->mf_X = 0.0f;
			this->m_LastTexture_Verts_ptr->mf_Y = 0.0f;

			++ this->m_LastTexture_Verts_ptr;

		}

		//9-5-2007 PH Generate and Bind VBO
		glGenBuffersARB(1, &ml_VBOID);	
		glBindBufferARB(GL_ARRAY_BUFFER_ARB, ml_VBOID);
		
		//10-5-2007 Populate vbo
		glBufferDataARB( GL_ARRAY_BUFFER_ARB, this->ml_RenderListLength * 4 * sizeof(class clsVert), this->m_Pos_Verts_ptr, GL_STATIC_DRAW_ARB);

		// Generate And Bind The Texture Coordinate Buffer
		glGenBuffersARB( 1, &this->ml_Texture_VBOID );					
		glBindBufferARB( GL_ARRAY_BUFFER_ARB, this->ml_Texture_VBOID );		
		// Load The Data
		glBufferDataARB( GL_ARRAY_BUFFER_ARB, ml_RenderListLength * 4 * sizeof(class clsVert), this->m_Texture_Verts_ptr, GL_STATIC_DRAW_ARB );
and the following is the draw routine
	glBindBufferARB( GL_ARRAY_BUFFER_ARB, this->ml_VBOID );
	glVertexPointer( 2, GL_FLOAT, 0, this->m_Pos_Verts_ptr  );		// Set The Vertex Pointer To The Vertex Buffer

	glBindBufferARB( GL_ARRAY_BUFFER_ARB, this->ml_Texture_VBOID );
	glTexCoordPointer( 2, GL_FLOAT, 0, this->m_LastTexture_Verts_ptr );		// Set The TexCoord Pointer To The TexCoord Buffer
	
	glDrawArrays( GL_QUADS, 0, this->ml_RenderListLength * 4 );		// Draw All Of The Triangles 

	//clean up
	glDisableClientState( GL_VERTEX_ARRAY );
	glDisableClientState( GL_TEXTURE_COORD_ARRAY );

Share this post


Link to post
Share on other sites
Advertisement
This is resolved

I forgot to include glEnableClientState()

and after using
glVertexPointer( 2, GL_FLOAT, 0, (char *) NULL );

it all worked fine

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!