Ok i’m new here so hello everyone.
I have a problem with a 2d game I’ve just started if anyone would care to help me. I’m using the Windows API for my window, event handling etc. The game it a top down view of a house and i just created the floor of the house which is a large quad and then applied a tile texture to it. I have also added handling so I can move the camera around the screen with the arrow keys. When I start the program it works fine but then about 1 minute later the textured quad disappears and I can only see a black background and the camera keys don’t work anymore.
This is the code to draw the floor and texture it
//draws the play environment: walls, floor etc
void Environment::drawBuilding()
{
tile = loadTextures(“tile.raw”,128,128);
glEnable(GL_TEXTURE_2D);
glBindTexture(GL_TEXTURE_2D, tile);
glBegin(GL_QUADS);
glTexCoord2f(0.0,0.0); glVertex2d(100,100);
glTexCoord2f(15.0,0.0); glVertex2d(1100,100);
glTexCoord2f(15.0,13.0); glVertex2d(1100,900);
glTexCoord2f(0.0,13.0); glVertex2d(100,900);
glEnd();
}
heres my display function that translates the camera position etc
void display()
{
glClearColor(0.0f,0.55f,0.0f,1.0f);
glClear(GL_COLOR_BUFFER_BIT);
glLoadIdentity();
glTranslatef(cameraX, cameraY, 1); //move the camera
envObj.drawBuilding();
}
I take it i’ve done something stupid but not sure what.