• ### Announcements

#### Archived

This topic is now archived and is closed to further replies.

# loadin in a map and rendering it??

## Recommended Posts

werdy666    743
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;
return false;
// map size info above...

for (int i = 0; i <28; i++)
{
for (int j = 0; j <25; j++)
{
mapdata[i][j] = value1;
}
}
// map data is now in mapdata[x][y]


rendering....

for (int j=0;j<28;j++)
{
for (int k=24;k>-1;k--)
{
glBindTexture(GL_TEXTURE_2D, texture[(mapdata[j][k])].texID);
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