/* Called by GLUT whenever a key is pressed. */ void keyboard(unsigned char key, int x, int y) { switch(key) { case 'q': case 'Q': case 27: // ASCII code for Escape key dgr_exit(); exit(EXIT_SUCCESS); break; } /* Whenever any key is pressed, request that display() get * called. */ glutPostRedisplay(); }
/* Called by GLUT whenever a key is pressed. */ void keyboard(unsigned char key, int x, int y) { switch(key) { case 'q': case 'Q': case 27: // ASCII code for Escape key dgr_exit(); exit(0); break; case 'f': // full screen glutFullScreen(); break; case 'F': // switch to window from full screen mode glutPositionWindow(0,0); break; case 'a': paddleA.xpos -= .01; clampPaddles(); break; case 's': paddleA.ready = true; break; case 'd': paddleA.xpos += .01; clampPaddles(); break; case 'j': paddleB.xpos -= .01; clampPaddles(); break; case 'k': paddleB.ready = true; break; case 'l': paddleB.xpos += .01; clampPaddles(); break; } }
/** Called by GLUT whenever a key is pressed. */ void keyboard(unsigned char key, int x, int y) { switch(key) { case 'q': case 'Q': case 27: // ASCII code for Escape key dgr_exit(); exit(EXIT_SUCCESS); break; case 'f': // full screen glutFullScreen(); break; case 'F': // switch to window from full screen mode glutPositionWindow(0,0); break; } /* Whenever any key is pressed, request that display() get * called. */ glutPostRedisplay(); }
/* Called by GLUT whenever a key is pressed. */ void keyboard(unsigned char key, int x, int y) { switch(key) { case 'q': case 'Q': case 27: // ASCII code for Escape key dgr_exit(); exit(EXIT_SUCCESS); break; case 's': // swap the left & right images { GLuint tmp; tmp = texIdLeft; texIdLeft = texIdRight; texIdRight = tmp; break; } } /* Whenever any key is pressed, request that display() get * called. */ glutPostRedisplay(); }
/* Called by GLUT whenever a key is pressed. */ void keyboard(unsigned char key, int x, int y) { switch(key) { case 'q': case 'Q': case 27: // ASCII code for Escape key dgr_exit(); exit(EXIT_SUCCESS); break; case 'f': // full screen glutFullScreen(); break; case 'F': // switch to window from full screen mode glutPositionWindow(0,0); break; case 'r': { // Reload GLSL program from disk kuhl_delete_program(program); program = kuhl_create_program(GLSL_VERT_FILE, GLSL_FRAG_FILE); /* Apply the program to the model geometry */ kuhl_geometry_program(modelgeom, program, KG_FULL_LIST); /* and the fps label*/ kuhl_geometry_program(&labelQuad, program, KG_FULL_LIST); break; } case 'w': { // Toggle between wireframe and solid int polygonMode; glGetIntegerv(GL_POLYGON_MODE, &polygonMode); if(polygonMode == GL_LINE) glPolygonMode(GL_FRONT_AND_BACK, GL_FILL); else glPolygonMode(GL_FRONT_AND_BACK, GL_LINE); break; } case 'p': { // Toggle between points and solid int polygonMode; glGetIntegerv(GL_POLYGON_MODE, &polygonMode); if(polygonMode == GL_POINT) glPolygonMode(GL_FRONT_AND_BACK, GL_FILL); else glPolygonMode(GL_FRONT_AND_BACK, GL_POINT); break; } case 'c': { // Toggle front, back, and no culling int cullMode; glGetIntegerv(GL_CULL_FACE_MODE, &cullMode); if(glIsEnabled(GL_CULL_FACE)) { if(cullMode == GL_FRONT) { glCullFace(GL_BACK); printf("Culling: Culling back faces; drawing front faces\n"); } else { glDisable(GL_CULL_FACE); printf("Culling: No culling; drawing all faces.\n"); } } else { glEnable(GL_CULL_FACE); glCullFace(GL_FRONT); printf("Culling: Culling front faces; drawing back faces\n"); } kuhl_errorcheck(); break; } case '+': // increase size of points and width of lines { GLfloat currentPtSize; GLfloat sizeRange[2]; glGetFloatv(GL_POINT_SIZE, ¤tPtSize); glGetFloatv(GL_SMOOTH_POINT_SIZE_RANGE, sizeRange); GLfloat temp = currentPtSize+1; if(temp > sizeRange[1]) temp = sizeRange[1]; glPointSize(temp); printf("Point size is %f (can be between %f and %f)\n", temp, sizeRange[0], sizeRange[1]); kuhl_errorcheck(); GLfloat currentLineWidth; GLfloat widthRange[2]; glGetFloatv(GL_LINE_WIDTH, ¤tLineWidth); glGetFloatv(GL_SMOOTH_LINE_WIDTH_RANGE, widthRange); temp = currentLineWidth+1; if(temp > widthRange[1]) temp = widthRange[1]; glLineWidth(temp); printf("Line width is %f (can be between %f and %f)\n", temp, widthRange[0], widthRange[1]); kuhl_errorcheck(); break; } case '-': // decrease size of points and width of lines { GLfloat currentPtSize; GLfloat sizeRange[2]; glGetFloatv(GL_POINT_SIZE, ¤tPtSize); glGetFloatv(GL_SMOOTH_POINT_SIZE_RANGE, sizeRange); GLfloat temp = currentPtSize-1; if(temp < sizeRange[0]) temp = sizeRange[0]; glPointSize(temp); printf("Point size is %f (can be between %f and %f)\n", temp, sizeRange[0], sizeRange[1]); kuhl_errorcheck(); GLfloat currentLineWidth; GLfloat widthRange[2]; glGetFloatv(GL_LINE_WIDTH, ¤tLineWidth); glGetFloatv(GL_SMOOTH_LINE_WIDTH_RANGE, widthRange); temp = currentLineWidth-1; if(temp < widthRange[0]) temp = widthRange[0]; glLineWidth(temp); printf("Line width is %f (can be between %f and %f)\n", temp, widthRange[0], widthRange[1]); kuhl_errorcheck(); break; } case ' ': // Toggle different sections of the GLSL fragment shader renderStyle++; if(renderStyle > 9) renderStyle = 0; switch(renderStyle) { case 0: printf("Render style: Diffuse (headlamp light)\n"); break; case 1: printf("Render style: Texture (color is used on non-textured geometry)\n"); break; case 2: printf("Render style: Texture+diffuse (color is used on non-textured geometry)\n"); break; case 3: printf("Render style: Vertex color\n"); break; case 4: printf("Render style: Vertex color + diffuse (headlamp light)\n"); break; case 5: printf("Render style: Normals\n"); break; case 6: printf("Render style: Texture coordinates\n"); break; case 7: printf("Render style: Front (green) and back (red) faces based on winding\n"); break; case 8: printf("Render style: Front (green) and back (red) based on normals\n"); break; case 9: printf("Render style: Depth (white=far; black=close)\n"); break; } break; } /* Whenever any key is pressed, request that display() get * called. */ glutPostRedisplay(); }
/* Called by GLUT whenever a key is pressed. */ void keyboard(unsigned char key, int x, int y) { switch(key) { case 'q': case 'Q': case 27: // ASCII code for Escape key dgr_exit(); exit(EXIT_SUCCESS); break; case '+': // increase size of points and width of lines { GLfloat currentPtSize; GLfloat sizeRange[2]; glGetFloatv(GL_POINT_SIZE, ¤tPtSize); glGetFloatv(GL_SMOOTH_POINT_SIZE_RANGE, sizeRange); GLfloat temp = currentPtSize+1; if(temp > sizeRange[1]) temp = sizeRange[1]; glPointSize(temp); printf("Point size is %f (can be between %f and %f)\n", temp, sizeRange[0], sizeRange[1]); kuhl_errorcheck(); GLfloat currentLineWidth; GLfloat widthRange[2]; glGetFloatv(GL_LINE_WIDTH, ¤tLineWidth); glGetFloatv(GL_SMOOTH_LINE_WIDTH_RANGE, widthRange); temp = currentLineWidth+1; if(temp > widthRange[1]) temp = widthRange[1]; glLineWidth(temp); printf("Line width is %f (can be between %f and %f)\n", temp, widthRange[0], widthRange[1]); kuhl_errorcheck(); break; } case '-': // decrease size of points and width of lines { GLfloat currentPtSize; GLfloat sizeRange[2]; glGetFloatv(GL_POINT_SIZE, ¤tPtSize); glGetFloatv(GL_SMOOTH_POINT_SIZE_RANGE, sizeRange); GLfloat temp = currentPtSize-1; if(temp < sizeRange[0]) temp = sizeRange[0]; glPointSize(temp); printf("Point size is %f (can be between %f and %f)\n", temp, sizeRange[0], sizeRange[1]); kuhl_errorcheck(); GLfloat currentLineWidth; GLfloat widthRange[2]; glGetFloatv(GL_LINE_WIDTH, ¤tLineWidth); glGetFloatv(GL_SMOOTH_LINE_WIDTH_RANGE, widthRange); temp = currentLineWidth-1; if(temp < widthRange[0]) temp = widthRange[0]; glLineWidth(temp); printf("Line width is %f (can be between %f and %f)\n", temp, widthRange[0], widthRange[1]); kuhl_errorcheck(); break; } case 'x': explode(); break; case 'z': update(); break; case ' ': // Toggle different sections of the GLSL fragment shader renderStyle++; if(renderStyle > 9) renderStyle = 0; switch(renderStyle) { case 0: printf("Render style: Diffuse (headlamp light)\n"); break; case 1: printf("Render style: Texture (color is used on non-textured geometry)\n"); break; case 2: printf("Render style: Texture+diffuse (color is used on non-textured geometry)\n"); break; case 3: printf("Render style: Vertex color\n"); break; case 4: printf("Render style: Vertex color + diffuse (headlamp light)\n"); break; case 5: printf("Render style: Normals\n"); break; case 6: printf("Render style: Texture coordinates\n"); break; case 7: printf("Render style: Front (green) and back (red) faces based on winding\n"); break; case 8: printf("Render style: Front (green) and back (red) based on normals\n"); break; case 9: printf("Render style: Depth (white=far; black=close)\n"); break; } break; } /* Whenever any key is pressed, request that display() get * called. */ glutPostRedisplay(); }