Hey all and thanks for taking the time to read about my problem.
I am trying to implement a simple tile drawing function, I have searched Gdnet and found: http://www.gamedev.net/reference/articles/article1256.asp however I already had pretty much the same as this.
The problem is that my program becomes somewhat non-responsive when I use the function. I have tried using a Sleep (1); and changed a bunch of things around and still not working : /.
// I made this function to make it a little easier to draw a sqaure
void DrawTile(GLfloat x,GLfloat y)
{
glBegin(GL_QUADS);
glTexCoord2f(0.0f, 0.0f); glVertex3f(x, y, 0.0f);
glTexCoord2f(1.0f, 0.0f); glVertex3f(x + 1, y, 0.0f);
glTexCoord2f(1.0f, 1.0f); glVertex3f(x + 1, y + 1, 0.0f);
glTexCoord2f(0.0f, 1.0f); glVertex3f(x, y + 1, 0.0f);
glEnd();
}
// This is the function to draw the tiles (duh)
bool TileDrawer(GLvoid)
{
int tile; // What tile are we drawing!?
// Display the map.
for (int y=0; y < MAP_SIZEY; y++)
{
for (int x=0; x < MAP_SIZEX; x++)
{
tile = TileMapA[y][x];
switch (tile)
{
case 1:
WallA.LoadToTexture();
DrawTile(x,y);
break;
case 2:
FloorA.LoadToTexture();
DrawTile(x,y);
}
}
}
return (true);
}
// Here is the main loop.
while(!done) // Loop That Runs While done=FALSE
{
..... // Code you dont need to see
// Draw The Scene. Watch For ESC Key And Quit Messages From DrawGLScene()
if ((active && !DrawGLScene()) || keys[VK_ESCAPE])// Active? Was There A Quit Received?
{
done=TRUE; // ESC or DrawGLScene Signalled A Quit
}
else // Not Time To Quit, Update Screen
{
SwapBuffers(hDC); // Swap Buffers (Double Buffering)
}
Also I'm doing this in Dev-C++, It's a personal preference.
[Edited by - CRYP7IK on July 13, 2007 9:33:16 PM]