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

rendering error? glDrawArrays

Started by sjoerd222 Jan 23, 2007 at 6:40 AM 0 replies 500+ views
Original Post
sjoerd222
sjoerd222
Hi guys I'm trying to render a landscape. And I reallized I render some lines that should not be rendered ( I see it when only drawing in linemode). My rendering command looks like the following: Informations: polbufferID -> landscape (as you see, vectors,normals, texcoords) unitbufferID -> a tirangle (as you see vectors, texcoords) drawstartIDX = 0; drawendIDX = Amount of Points in the Landscape Code:

{
		glEnable( GL_TEXTURE_2D );
		glEnable (GL_LIGHT1); 
		//glEnable (GL_LIGHTING);
		glEnableClientState( GL_VERTEX_ARRAY );	
		glEnableClientState( GL_TEXTURE_COORD_ARRAY );
		glEnableClientState(GL_NORMAL_ARRAY ); 

		glBindBufferARB( GL_ARRAY_BUFFER_ARB, polbufferID);

		glVertexPointer(3, GL_FLOAT, 8*sizeof(GLfloat), bufferOffset(sizeof(GLfloat)*0));
		glNormalPointer(GL_FLOAT, 8*sizeof(GLfloat), bufferOffset(sizeof(GLfloat)*3));
 		glTexCoordPointer(2, GL_FLOAT, 8*sizeof(GLfloat), bufferOffset(sizeof(GLfloat)*6));

		glDrawArrays( GL_TRIANGLES, drawstartIDX,drawendIDX);


		glDisableClientState( GL_VERTEX_ARRAY );
		glDisableClientState( GL_TEXTURE_COORD_ARRAY );
		glDisableClientState(GL_NORMAL_ARRAY );

		//UNIT PROTOTYPE
		glEnableClientState( GL_VERTEX_ARRAY );	
		glEnableClientState( GL_TEXTURE_COORD_ARRAY );
		glBindBufferARB(GL_ARRAY_BUFFER_ARB, unitbufferID);
		glVertexPointer(3, GL_FLOAT, 5*sizeof(GLfloat), bufferOffset(sizeof(GLfloat)*0));
		glTexCoordPointer(2, GL_FLOAT, 5*sizeof(GLfloat), bufferOffset(sizeof(GLfloat)*3));
		glDrawArrays( GL_TRIANGLES, 0, 3);
		glDisableClientState( GL_TEXTURE_COORD_ARRAY );
		glDisableClientState( GL_TEXTURE_COORD_ARRAY );
		//endUNIT PROTOTYPE

		glDisable(GL_TEXTURE_2D);
		glDisable (GL_LIGHT1); 
		glDisable
}

A strange thing happening is that the application sometimes runs too fast, meaning, if I move the Camera sometimes it move incredible fast, sometimes normal. But when I tried to render the Triangle(unitbufferID) callling glDrawArrays(GL_TRIANGLES,0,9) I got a weird picture, but the camera moved with correct speed. Now I ask you if you know whats going wrong. I'm a real newbie :-P thanks you for your help!!!
May the force be with... me! :-D

Topic Locked

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

Sign in to reply to this topic.