VBO representation problem

Hi!

I made an application that read a heightmap from an image. the heightmap was represented by calling lots of times glVertex3f()…
here I show the result:

http://img17.imageshack.us/img17/9341/withoutvbo.jpg

I have rewrote the application using VBO but I’m having some trouble beacuse the render is not correct:

http://img147.imageshack.us/img147/9003/withvbo.jpg

but when I change the polygon mode to GL_POINTS I can see better results:

http://img21.imageshack.us/img21/7040/withvbopoints.jpg

The application computes the index array for the triangles and the normals.
where could be the reason of this problem?

Thanks in advance :smiley:

I add my draw function:


	float shininess = 15.0f;
	float diffuseColor[3] = {0.929524f, 0.796542f, 0.178823f};
	float specularColor[4] = {1.00000f, 0.980392f, 0.549020f, 1.0f};
	glMaterialf(GL_FRONT_AND_BACK, GL_SHININESS, shininess); 
	glMaterialfv(GL_FRONT_AND_BACK, GL_SPECULAR, specularColor);

	glColorMaterial(GL_FRONT_AND_BACK, GL_AMBIENT_AND_DIFFUSE);
	glColor3fv(diffuseColor);

	glEnableClientState(GL_NORMAL_ARRAY);
	glEnableClientState(GL_VERTEX_ARRAY);

	glDrawElements(GL_TRIANGLE_STRIP, mIndexCount, GL_UNSIGNED_SHORT, NULL);
	glDisableClientState(GL_VERTEX_ARRAY);
	glDisableClientState(GL_NORMAL_ARRAY);

I think I have a problem calculating the index array. I show you the code:



	int vIndex=0;

	for (int i=0;i<mSizeX-1;i++)
	{
		for (int j=0;j<mSizeZ-1;j++)
		{
			teapotIndices2[vIndex++] = (i*256 + j);
			teapotIndices2[vIndex++] = ((i+1)*256 + j);
			teapotIndices2[vIndex++] = (i*256 + j + 1);
			teapotIndices2[vIndex++] = (i*256 + j + 1);
			teapotIndices2[vIndex++] = ((i+1)*256 + j);
			teapotIndices2[vIndex++] = ((i+1)*256 + j + 1);
		}
	}

any help would be appreciate :slight_smile:

do you even know what a triangle strip is?
RTFM.

knackered is right, you have a misunderstanding in how strips works.
As for your code, you can simply change GL_TRIANGLE_STRIP to GL_TRIANGLES, and everything would be fine.
If you want to use strips, you should construct your index array in another fashion.

thanks for the replies.

I have RTFM and I see the triangle strip is not that obvious to construct.

I was very confused

thanks

get a new manual.
the red book explains it very well.
http://unreal.srk.fer.hr/theredbook/chapter02.html