void processNormalKeys(unsigned char key, int xx, int yy) {

	glutSetMenu(mainMenu);
	switch (key) {
		case 27:
			glutDestroyMenu(mainMenu);
			glutDestroyMenu(fillMenu);
			glutDestroyMenu(colorMenu);
			glutDestroyMenu(shrinkMenu);
			exit(0);
			break;

		case 's':
			if (!menuFlag)
			  glutChangeToSubMenu(2,"Shrink",shrinkMenu);
			break;
		case 'c':
			if (!menuFlag)
				glutChangeToSubMenu(2,"Color",colorMenu);
			break;
              
	}
	if (key == 27)
		exit(0);
      
}
Esempio n. 2
0
void ProcessMenu(int value)
{
    if (value >= (TOTAL_SHAPES+TOTAL_SHADER_SETS+1))
    {
        char menuEntry[128];
        whichBumpmap = value - TOTAL_SHAPES - TOTAL_SHADER_SETS - 1;
        sprintf(menuEntry, "Choose bumpmap (currently \"%s\")", bumpmapNames[whichBumpmap]);
        glutSetMenu(mainMenu);
        glutChangeToSubMenu(3, menuEntry, bumpmapMenu);
        glBindTexture(GL_TEXTURE_2D, whichBumpmap);
    }
    else if (value >= (TOTAL_SHAPES+1))
    {
        char menuEntry[128];
        whichShader = value - TOTAL_SHAPES - 1;
        sprintf(menuEntry, "Choose shader (currently \"%s\")", shaderNames[whichShader]);
        glutSetMenu(mainMenu);
        glutChangeToSubMenu(2, menuEntry, shaderMenu);
        glUseProgram(progObj[whichShader]);
    }
    else
    {
        char menuEntry[128];
        whichShape = value - 1;
        sprintf(menuEntry, "Choose shape (currently \"%s\")", shapeNames[whichShape]);
        glutSetMenu(mainMenu);
        glutChangeToSubMenu(1, menuEntry, shapeMenu);
    }

    // Refresh the Window
    glutPostRedisplay();
}
Esempio n. 3
0
void normalKeyboard(unsigned char key, int xx, int yy)
{

	glutSetMenu(mainMenu);
	switch (key) {
		case 27:
			glutDestroyMenu(mainMenu);
			glutDestroyMenu(fillMenu);
			glutDestroyMenu(colorMenu);
			glutDestroyMenu(shrinkMenu);
			exit(0);
			break;

		case 's':
			if (!menuFlag)
			  glutChangeToSubMenu(2,"Shrink",shrinkMenu);
			break;
		case 'c':
			if (!menuFlag)
				glutChangeToSubMenu(2,"Color",colorMenu);
			break;
	}
	if (key == 27)
        if (glutGameModeGet(GLUT_GAME_MODE_ACTIVE) != 0)
				glutLeaveGameMode();
		exit(0);
}
Esempio n. 4
0
void ProcessMenu(int value)
{
    whichShader = value - 1;
    {
        char menuEntry[128];
        sprintf(menuEntry, "Choose shader set (currently \"%s\")", shaderNames[whichShader]);
        glutSetMenu(mainMenu);
        glutChangeToSubMenu(1, menuEntry, shaderMenu);
    }
    glUseProgram(progObj[whichShader]);

    // Refresh the Window
    glutPostRedisplay();
}
Esempio n. 5
0
/* ARGSUSED1 */
void
gokey(unsigned char key, int x, int y)
{
  char str[100];
  int mods;

  mods = glutGetModifiers();
  printf("key = %d, mods = 0x%x\n", key, mods);
  if (mods & GLUT_ACTIVE_ALT) {
    switch (key) {
    case '1':
      printf("Change to sub menu 1\n");
      glutChangeToSubMenu(1, "sub 1", submenu);
      break;
    case '2':
      printf("Change to sub menu 2\n");
      glutChangeToSubMenu(2, "sub 2", submenu);
      break;
    case '3':
      printf("Change to sub menu 3\n");
      glutChangeToSubMenu(3, "sub 3", submenu);
      break;
    case '4':
      printf("Change to sub menu 4\n");
      glutChangeToSubMenu(4, "sub 4", submenu);
      break;
    case '5':
      printf("Change to sub menu 5\n");
      glutChangeToSubMenu(5, "sub 5", submenu);
      break;
    }
  } else {
    switch (key) {
    case '1':
      printf("Change to menu entry 1\n");
      glutChangeToMenuEntry(1, "entry 1", 1);
      break;
    case '2':
      printf("Change to menu entry 2\n");
      glutChangeToMenuEntry(2, "entry 2", 2);
      break;
    case '3':
      printf("Change to menu entry 3\n");
      glutChangeToMenuEntry(3, "entry 3", 3);
      break;
    case '4':
      printf("Change to menu entry 4\n");
      glutChangeToMenuEntry(4, "entry 4", 4);
      break;
    case '5':
      printf("Change to menu entry 5\n");
      glutChangeToMenuEntry(5, "entry 5", 5);
      break;
    case 'a':
    case 'A':
      printf("Adding menu entry %d\n", item);
      sprintf(str, "added entry %d", item);
      glutAddMenuEntry(str, item);
      item++;
      break;
    case 's':
    case 'S':
      printf("Adding submenu %d\n", item);
      sprintf(str, "added submenu %d", item);
      glutAddSubMenu(str, submenu);
      item++;
      break;
    case 'q':
      printf("Remove 1\n");
      glutRemoveMenuItem(1);
      break;
    case 'w':
      printf("Remove 2\n");
      glutRemoveMenuItem(2);
      break;
    case 'e':
      printf("Remove 3\n");
      glutRemoveMenuItem(3);
      break;
    case 'r':
      printf("Remove 4\n");
      glutRemoveMenuItem(4);
      break;
    case 't':
      printf("Remove 5\n");
      glutRemoveMenuItem(5);
      break;
    }
  }
}
Esempio n. 6
0
void ProcessMenu(int value)
{
    whichShader = value - 1;
    {
        char menuEntry[128];
        sprintf(menuEntry, "Choose vertex shader (currently \"%s\")", shaderNames[whichShader]);
        glutSetMenu(mainMenu);
        glutChangeToSubMenu(1, menuEntry, shaderMenu);
    }
    glUseProgram(progObj[whichShader]);
    if (whichShader == SEPSPEC)
    {
        // Separate specular shader needs
        // primary and secondary colors summed
        glEnable(GL_COLOR_SUM);
    }
    else
    {
        glDisable(GL_COLOR_SUM);
    }
    if (whichShader == FOGCOORD)
    {
        // Fogcoord shader needs fixed
        // functionality fog enabled
        glEnable(GL_FOG);
    }
    else
    {
        glDisable(GL_FOG);
    }
    if (whichShader == PTSIZE)
    {
        // Fogcoord shader needs fixed
        // functionality fog enabled
        glPolygonMode(GL_FRONT_AND_BACK, GL_POINT);
        glEnable(GL_VERTEX_PROGRAM_POINT_SIZE);
        glEnable(GL_POINT_SMOOTH);
        glEnable(GL_BLEND);
    }
    else
    {
        glPolygonMode(GL_FRONT_AND_BACK, GL_FILL);
        glDisable(GL_VERTEX_PROGRAM_POINT_SIZE);
        glDisable(GL_POINT_SMOOTH);
        glDisable(GL_BLEND);
    }
    // Disable all texturing, then reenable as needed
    glActiveTexture(GL_TEXTURE3);
    glDisable(GL_TEXTURE_1D);
    glActiveTexture(GL_TEXTURE2);
    glDisable(GL_TEXTURE_1D);
    glActiveTexture(GL_TEXTURE1);
    glDisable(GL_TEXTURE_1D);
    glActiveTexture(GL_TEXTURE0);
    glDisable(GL_TEXTURE_1D);
    if ((whichShader == TEXSPEC) || (whichShader == STRETCH))
    {
        // texture specular shaders needs 1D pow map
        glActiveTexture(GL_TEXTURE0);
        glEnable(GL_TEXTURE_1D);
    }
    else if (whichShader == THREELIGHTS)
    {
        // 3 lights shader needs 1D pow map on all 3 units
        glActiveTexture(GL_TEXTURE3);
        glEnable(GL_TEXTURE_1D);
        glActiveTexture(GL_TEXTURE2);
        glEnable(GL_TEXTURE_1D);
        glActiveTexture(GL_TEXTURE1);
        glEnable(GL_TEXTURE_1D);
        glActiveTexture(GL_TEXTURE0);
    }

    // Refresh the Window
    glutPostRedisplay();
}
/*
 * Class:     gruenewa_opengl_GLUT__
 * Method:    glutChangeToSubMenu
 * Signature: (ILjava/lang/String;I)V
 */
JNIEXPORT void JNICALL Java_gruenewa_opengl_GLUT_00024_glutChangeToSubMenu
  (JNIEnv * jenv, jobject jobj, jint arg1, jobject arg2, jint arg3) {
   glutChangeToSubMenu(arg1, (*jenv)->GetDirectBufferAddress(jenv, arg2), arg3); 
}