From: Ash Tyndall Date: Fri, 21 Oct 2011 06:28:13 +0000 (+0800) Subject: (no commit message) X-Git-Url: https://git.ucc.asn.au/?a=commitdiff_plain;h=893757ee1bb56fd26df3f84fb66403d17f27a801;p=atyndall%2Fcits2231.git --- diff --git a/globals.c b/globals.c index 62d486f..0124faf 100644 --- a/globals.c +++ b/globals.c @@ -94,4 +94,7 @@ GLfloat zoom = 0.0, rotate = 0.0; GLfloat zoomFactor = 0.2, rotateFactor = 0.5; /* Beginning width, height */ -int width = 500, height = 500; \ No newline at end of file +int width = 500, height = 500; + +/* Texture state tracking */ +int currentGroundTexture = 0, currentMeshTexture = 0; \ No newline at end of file diff --git a/globals.h b/globals.h index 4c6c086..b3d0d6b 100644 --- a/globals.h +++ b/globals.h @@ -85,4 +85,7 @@ extern int width, height; extern GLfloat zoom, rotate; extern GLfloat zoomFactor, rotateFactor; +/* Texture state tracking */ +extern int currentGroundTexture, currentMeshTexture; + #endif /* GLOBALS_H */ \ No newline at end of file diff --git a/helper.c b/helper.c index ec880e8..0f711c2 100644 --- a/helper.c +++ b/helper.c @@ -210,8 +210,8 @@ int makeSubmenuFromArray( const char *menuEntries[], unsigned int menuEntriesSiz * Draw a floor by looping over the floorSize and squareSize variables */ void drawFloor() { - getTexture(2); - glBindTexture(GL_TEXTURE_2D, 2); + getTexture(currentGroundTexture); + glBindTexture(GL_TEXTURE_2D, currentGroundTexture); glBegin(GL_QUADS); for ( int x = -floorSize; x < floorSize; x++ ) { for ( int z = -floorSize; z < floorSize; z++ ) { diff --git a/scene.c b/scene.c index b9d9c07..2bf72a3 100644 --- a/scene.c +++ b/scene.c @@ -129,7 +129,8 @@ void processTextureEvents(int id) { * @param id ID of ground texture selected */ void processGTextureEvents(int id) { - + currentGroundTexture = id; + glutPostRedisplay(); } /** @@ -169,7 +170,7 @@ void makeMenu() { //glutAddMenuEntry("Rotation/Texture Scale", M_ROTATION_TEXTURE_SCALE); //glutAddSubMenu("Material", materialMenu); //glutAddSubMenu("Texture", textureMenu); - //glutAddSubMenu("Ground texture", gTextureMenu); + glutAddSubMenu("Ground texture", gTextureMenu); //glutAddSubMenu("Lights", lightMenu); glutAddMenuEntry("Exit", M_EXIT);