I am having trouble loading in a map i made with mappy32 and displaying it using opengl. I appear to get rubbish instead of my map i created. here is my map loading function and rendering function. If someone could tell me where i am going wrong it would be greatly appreciated!
map loading
int value1=0;
ifstream load;
load.open("maze1.map", ios::binary);
if (load.fail())
return false;
// map size info above...
for (int i = 0; i <28; i++)
{
for (int j = 0; j <25; j++)
{
load.read((char*)&value1, 1);
mapdata[i][j] = value1;
}
}
// map data is now in mapdata[x][y]
load.close();
rendering....
for (int j=0;j<28;j++)
{
for (int k=24;k>-1;k--)
{
glBindTexture(GL_TEXTURE_2D, texture[(mapdata[j][k])].texID);
glBegin(GL_QUADS);
glTexCoord2d(0.0,1.0);
glVertex3f(j-0.5f, -k+0.5f, 0.0f);
glTexCoord2d(1.0,1.0);
glVertex3f(j+0.5f, -k+0.5f, 0.0f);
glTexCoord2d(1.0,0.0);
glVertex3f(j+0.5f, -k-0.5f, 0.0f);
glTexCoord2d(0.0,0.0);
glVertex3f(j-0.5f, -k-0.5f, 0.0f);
glEnd();
}
}
mapdata[28][25] is an array i create. I am sticking with the one size map for the time being.
the map file is just saved with mappy32 and each byte represents a tile. At this stage there are only 2 tiles. So its either 0 or 1 that gets passed into mapdata[][].
If u need more code just ask!
Werdy666