weird program crash

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);
glBindTexture(GL_TEXTURE_2D, tile);
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);

heres my display function that translates the camera position etc
void display()
glTranslatef(cameraX, cameraY, 1); //move the camera

I take it i’ve done something stupid but not sure what.

tile = loadTextures(“tile.raw”,128,128); // this should never be done more than once ! otherwise it will fill up the texture video ram

The following is much less problematic :
glEnable(GL_TEXTURE_2D); // no need to do it every frame unless you switch it off at one time
glBindTexture(GL_TEXTURE_2D, tile); // no need to do it every frame unless you want to bind a different texture

:slight_smile: Oh I see. I did feel it was probably something to do with memory. I’ll have to rearrange my code a bit. Thanks for the help.