Skip to main content
gamedev.net
🔒 Locked

Problem rendering polygons

Started by Ruudje Apr 12, 2005 at 11:57 AM 4 replies 2.2k views
Original Post
Ruudje
Ruudje
Hi all. A real question this time: I have a class which stores some arrays, providing my program with vertex points and polygon information (which 3 vertices to use for 1 polygon)

	register int i;
	for(i = 0; i < test->GetModelMeshPtr()->i_PolygonCount; i++)
	{
	//glVertex3f(test->GetModelMeshPtr()->Vertices[test->GetModelMeshPtr()->Polygons.x].x, test->GetModelMeshPtr()->Vertices[test->GetModelMeshPtr()->Polygons.x].y, test->GetModelMeshPtr()->Vertices[test->GetModelMeshPtr()->Polygons.x].z);
		//glVertex3f(test->GetModelMeshPtr()->Vertices[test->GetModelMeshPtr()->Polygons.y].x, test->GetModelMeshPtr()->Vertices[test->GetModelMeshPtr()->Polygons.y].y, test->GetModelMeshPtr()->Vertices[test->GetModelMeshPtr()->Polygons.y].z);
		//glVertex3f(test->GetModelMeshPtr()->Vertices[test->GetModelMeshPtr()->Polygons.z].x, test->GetModelMeshPtr()->Vertices[test->GetModelMeshPtr()->Polygons.z].y, test->GetModelMeshPtr()->Vertices[test->GetModelMeshPtr()->Polygons.z].z);

		int v = test->GetModelMeshPtr()->Polygons.x;
		glVertex3f(test->GetModelMeshPtr()->Vertices[v].x, test->GetModelMeshPtr()->Vertices[v].y, test->GetModelMeshPtr()->Vertices[v].z);
		
		v = test->GetModelMeshPtr()->Polygons.y;
		glVertex3f(test->GetModelMeshPtr()->Vertices[v].x, test->GetModelMeshPtr()->Vertices[v].y, test->GetModelMeshPtr()->Vertices[v].z);
		
		v = test->GetModelMeshPtr()->Polygons.z;
		glVertex3f(test->GetModelMeshPtr()->Vertices[v].x, test->GetModelMeshPtr()->Vertices[v].y, test->GetModelMeshPtr()->Vertices[v].z);
	}


Each model-mesh currently is created holding a dummy model, a simple pyramid. The uncommented code works. But the commented code results in compiler errors. Can someone explain to me what is wrong with it, or why it can't be done? Tnx in advance
mike25025
mike25025
What errors are you getting?
Ruudje
Ruudje
Per line of glVertex3f (so times 3) I get:

E:\Game Engine\Main.cpp(26) : error C2108: subscript is not of integral type
E:\Game Engine\Main.cpp(26) : error C2228: left of '.x' must have class/struct/union type
E:\Game Engine\Main.cpp(26) : error C2108: subscript is not of integral type
E:\Game Engine\Main.cpp(26) : error C2228: left of '.y' must have class/struct/union type
E:\Game Engine\Main.cpp(26) : error C2108: subscript is not of integral type
E:\Game Engine\Main.cpp(26) : error C2228: left of '.z' must have class/struct/union type
mike25025
mike25025
Try this
glVertex3f(test->GetModelMeshPtr()->Vertices[(int)test->GetModelMeshPtr()->Polygons.x].x,test->GetModelMeshPtr()->Vertices[(int)test->GetModelMeshPtr()->Polygons.x].y,test->GetModelMeshPtr()->Vertices[(int)test->GetModelMeshPtr()->Polygons.x].z);
Ruudje
Ruudje
It works. Thank you! So, my only failure was that I didn't force it to an integer?
mike25025
mike25025
Quote:
Original post by Ruudje
So, my only failure was that I didn't force it to an integer?

Yes. I make this mistake a lot so dont fell bad.

Topic Locked

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

Sign in to reply to this topic.