Tile-problem
Hello,
I was wondering if I could get some help with this tile-thingy Im building..
Look at the picture here: http://www16.brinkster.com/ironmax/tilegralle.gif
The picture shows 3 simple test-tiles which seems to end up the wrong way from my 10*10 array:
char map[MAP_SIZEY][MAP_SIZEX] =
{
{1, 1, 1, 1, 1, 1, 1, 1, 1, 1},
{1, 0, 0, 0, 0, 0, 0, 0, 0, 1},
{1, 0, 2, 2, 2, 2, 2, 2, 0, 1},
{1, 0, 0, 0, 0, 0, 0, 0, 0, 1},
{1, 0, 0, 2, 0, 0, 2, 0, 0, 1},
{1, 0, 0, 0, 2, 2, 0, 0, 0, 1},
{1, 0, 0, 0, 0, 0, 0, 0, 0, 1},
{1, 0, 0, 0, 0, 0, 0, 0, 0, 1},
{1, 0, 0, 0, 0, 0, 0, 0, 0, 1},
{1, 1, 1, 1, 1, 1, 1, 1, 1, 1},
};
If you can see, the tiles seems to be drawn the wrong way in the y-axis, still they are accurately turned to the camera.. I am lost.
Here''s the draw function:
for(int y = 0; y < MAP_SIZEY; y++)
{
for(int x = 0; x < MAP_SIZEX; x++)
{
tile = map[y][x];
glBindTexture(GL_TEXTURE_2D, texture[tile]);
glBegin(GL_QUADS);
glTexCoord2f(0.0f, 0.0f); glVertex3f(float(x), float(y), 0.0f);
glTexCoord2f(1.0f, 0.0f); glVertex3f(float(x + 1), float(y), 0.0f);
glTexCoord2f(1.0f, 1.0f); glVertex3f(float(x + 1), float(y + 1.0f), 0.0f);
glTexCoord2f(0.0f, 1.0f); glVertex3f(float(x), float(y + 1.0f), 0.0f);
glEnd();
}
}
Im sure there is some minor typo I''ve put down, but I don''t know what, this is my first experiment with tiles, sorry for the messed up code.
To me it looks like you have the way your ortho mode is set up not the way you wanted...looks like your orgin 0,0 is bottom left and you probably want it top left try
glOrtho(0.0f,width, height, 0.0f, -1.0f, 1.0f);
and see if that helps you.
glOrtho(0.0f,width, height, 0.0f, -1.0f, 1.0f);
and see if that helps you.
Thanks, didn''t think about that, I was using perspective followed by gluLookAt from my last project
But now another problem occured.. all the tiles end up in one tiny heep in the top left corner :/
But now another problem occured.. all the tiles end up in one tiny heep in the top left corner :/
This topic is closed to new replies.
Advertisement
Popular Topics
Advertisement