GLvoid DrawMap(GLvoid)
{
TilesInGame *ActMapElement=NULL;
glLoadIdentity(); // Reset The Current Modelview Matrix
glColor3f(1.0f,1.0f,1.0f);
glEnable(GL_TEXTURE_2D);
glTranslatef(-2.0f,-2.0f,-25.0f);
glRotatef(MapRoty,0,1.0f,0);
glRotatef(MapRotx,1.0f,0,0);
for(int x=0;x<GridCountx;x++)
{
for(int z=0;z<GridCounty;z++)
{
if((ActMapElement=GetMapElement(x,z))!=NULL)
{
glBindTexture(GL_TEXTURE_2D, texture[ActMapElement->Texture]);
glBegin(GL_TRIANGLES);
glTexCoord2f(0.0f,1.0f);glVertex3d(MapRelx+ActMapElement->Posx, ActMapElement->Height, MapRelz+ActMapElement->Posz);
glTexCoord2f(1.0f,1.0f);glVertex3d(MapRelx+ActMapElement->Posx, ActMapElement->Height, MapRelz+ActMapElement->Posz+1.0f);
glTexCoord2f(1.0f,0.0f);glVertex3d(MapRelx+ActMapElement->Posx+1.0f,ActMapElement->Height, MapRelz+ActMapElement->Posz+1.0f);
glTexCoord2f(1.0f,0.0f);glVertex3d(MapRelx+ActMapElement->Posx+1.0f,ActMapElement->Height, MapRelz+ActMapElement->Posz+1.0f);
glTexCoord2f(0.0f,0.0f);glVertex3d(MapRelx+ActMapElement->Posx+1.0f,ActMapElement->Height, MapRelz+ActMapElement->Posz);
glTexCoord2f(0.0f,1.0f);glVertex3d(MapRelx+ActMapElement->Posx, ActMapElement->Height, MapRelz+ActMapElement->Posz);
glEnd();
}
}
}
glDisable(GL_TEXTURE_2D);
}
Problem with objects being drawn wrong
Hello everyone,
I have following problem, I can't seem to solve:
When I call the function below, I want to draw a series of of Quads (consisting of two Triangles) with a texture on it to create a game map (comparable with Zelda, but with "a little 3D").
The whole thing draws just fine, but some "quads" that should be underneath another are drawn above it - it somehow overwrites the higher quad although it has a lower y (height) value. Sorry, I don't know how to explain it exactly.
I tried sorting my quads by height (y axis), that the scene will be drawn from top to bottom, but that didn't solve the problem either.
Can anyone see something I must have missed?
A little addition:
My scene is set up like this (Top view):
z axis
|
|
|
|
|
|
|
+---------------- x axis
y Axis is used for the height of a "quad"
My scene is set up like this (Top view):
z axis
|
|
|
|
|
|
|
+---------------- x axis
y Axis is used for the height of a "quad"
This topic is closed to new replies.
Advertisement
Popular Topics
Advertisement