Skip to main content
GameDev.net gamedev.net
🔒 Locked

Vertex Buffer Problem

Started by LordAsm Jan 8, 2007 at 7:53 AM 0 replies 950+ views
Original Post
LordAsm
LordAsm
Hi, I'm displaying some test triangles using VBO, and I'm having some strange behaviour: There should appear 2 small triangles, then 1 big, then 2 small and finally 1 big again. The code I use to display the scene is: (note that using glBegin - glEnd, the triangles work fine)
        gluLookAt(sm->ActiveCam->getEye().x, sm->ActiveCam->getEye().y, sm->ActiveCam->getEye().z, sm->ActiveCam->getLookat().x, sm->ActiveCam->getLookat().y, sm->ActiveCam->getLookat().z, 0, 1, 0);
	//sm->ActiveCam->Translate(-0.05f);
	//sm->ActiveCam->Rotate(1.0f,0.0f,1.0f,0.0f);
	// ***************** 
	sncsize = sm->getAttachedItems();
	glEnableClientState( GL_VERTEX_ARRAY );
	for (int i=0;i<sncsize;i++) {
		// Parse list and get vertex list
		vlist = sm->Node->draw();
		glPushMatrix();	
		glVertexPointer(3, GL_FLOAT, 0, vlist->Vertices);
		glTranslatef(8.0f*i, 0.0f, 0.0f);
		glDrawArrays(GL_TRIANGLES, 0, vlist->VertexCount*3);
		glPopMatrix();
		vlist = NULL;
	}
	// ***************** 
	glDisableClientState(GL_VERTEX_ARRAY);     
	SwapBuffers(hDC);		

Any ideas of WHY I'm getting this??? -Roger-
_neutrin0_
_neutrin0_
Your glDrawArrays(GL_TRIANGLES, 0, vlist->VertexCount*3); seems to be suspect.

When you say vlist->VertexCount, is this the number to vertices or is the number of primitives? If you are drawing 6 triangles with 3 vertices each, the call should be glDrawArrays(GL_TRIANGLES, 0, 18);
++ My::Game ++

Topic Locked

This topic has been locked by a moderator. New replies are not allowed.

Sign in to reply to this topic.