(no commit message)
authorAsh Tyndall <[email protected]>
Fri, 21 Oct 2011 06:28:13 +0000 (14:28 +0800)
committerAsh Tyndall <[email protected]>
Fri, 21 Oct 2011 06:28:13 +0000 (14:28 +0800)
globals.c
globals.h
helper.c
scene.c

index 62d486f..0124faf 100644 (file)
--- 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 */
 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
index 4c6c086..b3d0d6b 100644 (file)
--- a/globals.h
+++ b/globals.h
@@ -85,4 +85,7 @@ extern int width, height;
 extern GLfloat zoom, rotate;
 extern GLfloat zoomFactor, rotateFactor;
 
 extern GLfloat zoom, rotate;
 extern GLfloat zoomFactor, rotateFactor;
 
+/* Texture state tracking */
+extern int currentGroundTexture, currentMeshTexture;
+
 #endif /* GLOBALS_H */
\ No newline at end of file
 #endif /* GLOBALS_H */
\ No newline at end of file
index ec880e8..0f711c2 100644 (file)
--- 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() {
  * 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++ ) {
        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 (file)
--- a/scene.c
+++ b/scene.c
@@ -129,7 +129,8 @@ void processTextureEvents(int id) {
  * @param id ID of ground texture selected\r
  */\r
 void processGTextureEvents(int id) {\r
  * @param id ID of ground texture selected\r
  */\r
 void processGTextureEvents(int id) {\r
-\r
+  currentGroundTexture = id;\r
+  glutPostRedisplay();\r
 }\r
 \r
 /**\r
 }\r
 \r
 /**\r
@@ -169,7 +170,7 @@ void makeMenu() {
   //glutAddMenuEntry("Rotation/Texture Scale", M_ROTATION_TEXTURE_SCALE);\r
   //glutAddSubMenu("Material", materialMenu);\r
   //glutAddSubMenu("Texture", textureMenu);\r
   //glutAddMenuEntry("Rotation/Texture Scale", M_ROTATION_TEXTURE_SCALE);\r
   //glutAddSubMenu("Material", materialMenu);\r
   //glutAddSubMenu("Texture", textureMenu);\r
-  //glutAddSubMenu("Ground texture", gTextureMenu);\r
+  glutAddSubMenu("Ground texture", gTextureMenu);\r
   //glutAddSubMenu("Lights", lightMenu);\r
   glutAddMenuEntry("Exit", M_EXIT);\r
 \r
   //glutAddSubMenu("Lights", lightMenu);\r
   glutAddMenuEntry("Exit", M_EXIT);\r
 \r

UCC git Repository :: git.ucc.asn.au