Example #1
0
static VALUE
glut_MenuStatusFunc(VALUE self, VALUE callback) {
  menustatus_func = rb_glut_check_callback(self, callback);

	if (NIL_P(menustatus_func))
		glutMenuStatusFunc(NULL);
	else
		glutMenuStatusFunc(glut_MenuStatusFuncCallback0);

	return Qnil;
}
void createPopupMenus() {

	shrinkMenu = glutCreateMenu(processShrinkMenu);
	glutAddMenuEntry("Shrink", SHRINK);
	glutAddMenuEntry("NORMAL", NORMAL);

	fillMenu = glutCreateMenu(processFillMenu);
	glutAddMenuEntry("Fill", FILL);
	glutAddMenuEntry("Line", LINE);

	colorMenu = glutCreateMenu(processColorMenu);
	glutAddMenuEntry("Red", RED);
	glutAddMenuEntry("Blue", BLUE);
	glutAddMenuEntry("Green", GREEN);
	glutAddMenuEntry("Orange", ORANGE);

	mainMenu = glutCreateMenu(processMainMenu);
	glutAddSubMenu("Polygon Mode", fillMenu);
	glutAddSubMenu("Color", colorMenu);

	// attach the menu to the right button
	glutAttachMenu(GLUT_RIGHT_BUTTON);

	// this will allow us to know if the menu is active
	glutMenuStatusFunc(processMenuStatus);
}
Example #3
0
/*  Main Loop
 *  Open window with initial window size, title bar, 
 *  RGBA display mode, and handle input events.
 */
int
main(int argc, char **argv)
{
  int submenu;

  glutInit(&argc, argv);
  glutInitWindowSize(W, H);
  glutInitDisplayMode(GLUT_DOUBLE | GLUT_RGB | GLUT_DEPTH);
  glutCreateWindow(argv[0]);
  myinit();
  glutReshapeFunc(myReshape);
  glutDisplayFunc(display);
  submenu = glutCreateMenu(polygon_mode);
  glutAddMenuEntry("Filled", 1);
  glutAddMenuEntry("Outline", 2);
  glutCreateMenu(main_menu);
  glutAddMenuEntry("Quit", 666);
  glutAddSubMenu("Polygon mode", submenu);
  glutAttachMenu(GLUT_RIGHT_BUTTON);
  glutPassiveMotionFunc(passive);
  glutEntryFunc(entry);
  glutMenuStatusFunc(mstatus);
  glutMainLoop();
  return 0;             /* ANSI C requires main to return int. */
}
Example #4
0
static void registerCallbacks ()
{
  glutIdleFunc(gst_glut_IdleFunc);
  glutKeyboardFunc(gst_glut_KeyboardFunc);
  glutSpecialFunc(gst_glut_SpecialFunc);
  glutReshapeFunc(gst_glut_ReshapeFunc);
  glutVisibilityFunc(gst_glut_VisibilityFunc);
  glutDisplayFunc(gst_glut_DisplayFunc); 
  glutMouseFunc(gst_glut_MouseFunc);
  glutMotionFunc(gst_glut_MotionFunc);
  glutPassiveMotionFunc(gst_glut_PassiveMotionFunc);
  glutEntryFunc(gst_glut_EntryFunc);
  glutKeyboardUpFunc(gst_glut_KeyboardUpFunc);
  glutSpecialUpFunc(gst_glut_SpecialUpFunc);
  glutMenuStateFunc(gst_glut_MenuStateFunc);
  glutMenuStatusFunc(gst_glut_MenuStatusFunc);
  glutOverlayDisplayFunc(gst_glut_OverlayDisplayFunc);
  glutWindowStatusFunc(gst_glut_WindowStatusFunc);
  glutSpaceballMotionFunc(gst_glut_SpaceballMotionFunc);
  glutSpaceballRotateFunc(gst_glut_SpaceballRotateFunc);
  glutSpaceballButtonFunc(gst_glut_SpaceballButtonFunc);
  glutButtonBoxFunc(gst_glut_ButtonBoxFunc);
  glutDialsFunc(gst_glut_DialsFunc);
  glutTabletMotionFunc(gst_glut_TabletMotionFunc);
  glutTabletButtonFunc(gst_glut_TabletButtonFunc);
  glutWMCloseFunc(gst_glut_WMCloseFunc);

#if 0
  glutJoystickFunc(gst_glut_JoystickFunc);
  glutMouseWheelFunc(gst_glut_MouseWheelFunc);
  glutCloseFunc(gst_glut_CloseFunc);
  glutMenuDestroyFunc(gst_glut_MenuDestroyFunc);
#endif
}
Example #5
0
/**
* Function: 
* Register callback functions to handle basic window and global
* events. These functions are called by glut to handle the particular
* types of events. The code provides examples of registering event 
* handle functions for different types of events. 
*/
static void registerCallBacks()
{
	glutKeyboardFunc(KeyboardCB); // callback for ascii character input
	glutKeyboardUpFunc(KeyboardUpCB);
	glutDisplayFunc(RenderSceneCB); // callback for window redisplay
	glutIdleFunc(IdleCB); // idle callback
	glutVisibilityFunc(VisibilityCB); // callback for visibility changes
	glutReshapeFunc(ReshapeCB); // callback for window size changes
	glutMenuStatusFunc(menuStatusCB); // callback for menu exposures

} // end registerCallBacks
/*
 * Class:     gruenewa_opengl_GLUT__
 * Method:    glutMenuStatusFunc
 * Signature: (Lscala/Function3;)V
 */
JNIEXPORT void JNICALL Java_gruenewa_opengl_GLUT_00024_glutMenuStatusFunc
  (JNIEnv * jenv, jobject jobj, jobject arg1) {

  if(jvm == NULL) {
    (*jenv)->GetJavaVM(jenv, &jvm);
  }

  // fixme remove old obj if exists

  glutMenuStatusFunc_obj = (*jenv)->NewGlobalRef(jenv, arg1);
  return glutMenuStatusFunc(glutMenuStatusFuncCallback);

}
void createPopupMenus() {

    lightMenu_one = glutCreateMenu(processLightMenu_one);
    glutAddMenuEntry("Off",0);
    glutAddMenuEntry("White Light",1);
    glutAddMenuEntry("Red Light",2);
    glutAddMenuEntry("Blue Light",3);
    glutAddMenuEntry("Green Light",4);


    lightMenu_two = glutCreateMenu(processLightMenu_two);
    glutAddMenuEntry("Off",0);
    glutAddMenuEntry("White Light",1);
    glutAddMenuEntry("Red Light",2);
    glutAddMenuEntry("Blue Light",3);
    glutAddMenuEntry("Green Light",4);


    lightMenu_three = glutCreateMenu(processLightMenu_three);
    glutAddMenuEntry("Off",0);
    glutAddMenuEntry("White Light",1);
    glutAddMenuEntry("Red Light",2);
    glutAddMenuEntry("Blue Light",3);
    glutAddMenuEntry("Green Light",4);

    materialsMenu = glutCreateMenu (processMaterialsMenu);
    glutAddMenuEntry("Gold",GLD);
    glutAddMenuEntry("Silver",SVR);
    glutAddMenuEntry("Copper",CPR);


    elementsMenu = glutCreateMenu (processElementsMenu);
    glutAddMenuEntry("Ambient only",AMB);
    glutAddMenuEntry("Ambient and Diffuse",DIF);
    glutAddMenuEntry("Ambient, Diffuse and Specular",SPC);

    mainMenu = glutCreateMenu(processMainMenu);

    glutAddSubMenu("Light 1", lightMenu_one);
    glutAddSubMenu("Light 2", lightMenu_two);
    glutAddSubMenu("Light 3", lightMenu_three);
    glutAddSubMenu("Material Properties", materialsMenu);
    glutAddSubMenu("Light Elements", elementsMenu);
    glutAddMenuEntry("Quit",0);
    // attach the menu to the right button
    glutAttachMenu(GLUT_RIGHT_BUTTON);

    // this will allow us to know if the menu is active
    glutMenuStatusFunc(processMenuStatus);
}
Example #8
0
void
time6(int value)
{
  if (value != 6) {
    printf("FAIL: time6 expected 6\n");
    exit(1);
  }
  glutMenuStateFunc(mstatus);
  glutMenuStatusFunc(mstatus2);
  glutCreateMenu(menu2);
  glutAddMenuEntry("name", 46);
  glutAttachMenu(GLUT_LEFT_BUTTON);
  glutAttachMenu(GLUT_MIDDLE_BUTTON);
  glutAttachMenu(GLUT_RIGHT_BUTTON);
  printf("Pop up menu with any mouse button and select the item\n");
}
Example #9
0
void createPopupMenus() {

    fontMenu = glutCreateMenu(processFontMenu);

	//glutAddMenuEntry("BITMAP_8_BY_13 ",INT_GLUT_BITMAP_8_BY_13 );
	//glutAddMenuEntry("BITMAP_9_BY_15",INT_GLUT_BITMAP_9_BY_15 );
	//glutAddMenuEntry("BITMAP_TIMES_ROMAN_10 ",INT_GLUT_BITMAP_TIMES_ROMAN_10  );
	//glutAddMenuEntry("BITMAP_TIMES_ROMAN_24",INT_GLUT_BITMAP_TIMES_ROMAN_24  );
	//glutAddMenuEntry("BITMAP_HELVETICA_10 ",INT_GLUT_BITMAP_HELVETICA_10  );
	//glutAddMenuEntry("BITMAP_HELVETICA_12",INT_GLUT_BITMAP_HELVETICA_12  );
	//glutAddMenuEntry("BITMAP_HELVETICA_18",INT_GLUT_BITMAP_HELVETICA_18 );

	glutAddMenuEntry("STROKE_ROMAN",1 );
    glutAddMenuEntry("STROKE_MONO_ROMAN",2 );

	shrinkMenu = glutCreateMenu(processShrinkMenu);

	glutAddMenuEntry("Shrink",SHRINK);
	glutAddMenuEntry("Normal",NORMAL);

	fillMenu = glutCreateMenu(processFillMenu);

	glutAddMenuEntry("Fill",FILL);
	glutAddMenuEntry("Line",LINE);

	colorMenu = glutCreateMenu(processColorMenu);
	glutAddMenuEntry("Red",RED);
	glutAddMenuEntry("Blue",BLUE);
	glutAddMenuEntry("Green",GREEN);
	glutAddMenuEntry("Orange",ORANGE);

	mainMenu = glutCreateMenu(processMainMenu);

	glutAddSubMenu("Polygon Mode", fillMenu);
	glutAddSubMenu("Color", colorMenu);
	glutAddSubMenu("Scale", shrinkMenu);
	glutAddSubMenu("Font", fontMenu);
	// attach the menu to the right button
	glutAttachMenu(GLUT_RIGHT_BUTTON);

	// this will allow us to know if the menu is active
	glutMenuStatusFunc(processMenuStatus);
}
Example #10
0
void main(int argc, char **argv)
{
	estado.doubleBuffer=GL_TRUE;

	glutInit(&argc, argv);
	glutInitWindowPosition(0, 0);
	glutInitWindowSize(LARGURA_CAMPO, ALTURA_CAMPO);
	glutInitDisplayMode(((estado.doubleBuffer) ? GLUT_DOUBLE : GLUT_SINGLE) | GLUT_RGB);
	if (glutCreateWindow("Ping-Pong") == GL_FALSE)
		exit(1);

	Init();

	imprime_ajuda();

	// Registar callbacks do GLUT

	// callbacks de janelas/desenho
	glutReshapeFunc(Reshape);
	glutDisplayFunc(Draw);

	// Callbacks de teclado
	glutKeyboardFunc(Key);
	glutKeyboardUpFunc(KeyUp);
	glutSpecialFunc(SpecialKey);
	glutSpecialUpFunc(SpecialKeyUp);

	// callbacks timer/idle
	glutTimerFunc(estado.delayMovimento, Timer, 0);
	glutTimerFunc(estado.delayTeclas, TimerTeclas, 0);

	//Menus
	cria_menu();
	glutMenuStatusFunc(MenuStatus);

	// COMECAR...
	glutMainLoop();
}
Example #11
0
int
main(int argc, char **argv)
{
  int win, menu;
  int marray[NUM];
  int warray[NUM];
  int i, j;
  GLint isIndex;

  glutInit(&argc, argv);
  glutInitWindowPosition(10, 10);
  glutInitWindowSize(200, 200);
  glutInitDisplayMode(GLUT_SINGLE | GLUT_RGB | GLUT_DEPTH);
  win = glutCreateWindow("test2");
  glGetIntegerv(GL_INDEX_MODE, &isIndex);
  if (isIndex != 0) {
    printf("FAIL: window should be RGBA\n");
    exit(1);
  }
  glutSetWindow(win);
  glutDisplayFunc(display);
  menu = glutCreateMenu(menuSelect);
  glutSetMenu(menu);
  glutReshapeFunc(NULL);
  glutReshapeFunc(NULL);
  glutKeyboardFunc(NULL);
  glutKeyboardFunc(NULL);
  glutMouseFunc(NULL);
  glutMouseFunc(NULL);
  glutMotionFunc(NULL);
  glutMotionFunc(NULL);
  glutVisibilityFunc(NULL);
  glutVisibilityFunc(NULL);
  glutMenuStateFunc(NULL);
  glutMenuStateFunc(NULL);
  glutMenuStatusFunc(NULL);
  glutMenuStatusFunc(NULL);
  glutSpecialFunc(NULL);
  glutSpecialFunc(NULL);
  glutSpaceballMotionFunc(NULL);
  glutSpaceballMotionFunc(NULL);
  glutSpaceballRotateFunc(NULL);
  glutSpaceballRotateFunc(NULL);
  glutSpaceballButtonFunc(NULL);
  glutSpaceballButtonFunc(NULL);
  glutButtonBoxFunc(NULL);
  glutButtonBoxFunc(NULL);
  glutDialsFunc(NULL);
  glutDialsFunc(NULL);
  glutTabletMotionFunc(NULL);
  glutTabletMotionFunc(NULL);
  glutTabletButtonFunc(NULL);
  glutTabletButtonFunc(NULL);
  for (i = 0; i < NUM; i++) {
    marray[i] = glutCreateMenu(menuSelect);
    warray[i] = glutCreateWindow("test");
    glutDisplayFunc(display);
    for (j = 0; j < i; j++) {
      glutAddMenuEntry("Hello", 1);
      glutAddSubMenu("Submenu", menu);
    }
    if (marray[i] != glutGetMenu()) {
      printf("FAIL: current menu not %d\n", marray[i]);
      exit(1);
    }
    if (warray[i] != glutGetWindow()) {
      printf("FAIL: current window not %d\n", warray[i]);
      exit(1);
    }
    glutDisplayFunc(NeverVoid);
    glutVisibilityFunc(NeverValue);
    glutHideWindow();
  }
  for (i = 0; i < NUM; i++) {
    glutDestroyMenu(marray[i]);
    glutDestroyWindow(warray[i]);
  }
  glutTimerFunc(500, timer, 42);
  head = glutGet(GLUT_ELAPSED_TIME);
  glutIdleFunc(idle);
  glutMainLoop();
  return 0;             /* ANSI C requires main to return int. */
}
Example #12
0
/////////////////////////////////////////////////////////
// createMess
//
/////////////////////////////////////////////////////////
bool gemglutwindow :: create(void)
{
  if(m_window) {
    error("window already made!");
    return false;
  }


#ifdef FREEGLUT
  // display list sharing (with FreeGLUT)
  if(s_windowmap.size()>0) {
    std::map<int,gemglutwindow*>::iterator it = s_windowmap.begin();
    gemglutwindow*other=NULL;
    other=it->second;
    if(other && other->makeCurrent()) {
      glutSetOption(GLUT_RENDERING_CONTEXT, GLUT_USE_CURRENT_CONTEXT );
    }
  }
#endif

  unsigned int mode=GLUT_RGB | GLUT_DEPTH;
  if(2==m_buffer)
    mode|=GLUT_DOUBLE;
  else
    mode|=GLUT_SINGLE;

  glutInitDisplayMode(mode);

  m_window=glutCreateWindow(m_title.c_str());
  s_windowmap[m_window]=this;

  glutDisplayFunc   (&gemglutwindow::displayCb);
  glutVisibilityFunc(&gemglutwindow::visibleCb);

  glutCloseFunc     (&gemglutwindow::closeCb);
#ifdef FREEGLUT
  glutSetOption(GLUT_ACTION_ON_WINDOW_CLOSE, GLUT_ACTION_GLUTMAINLOOP_RETURNS);
#endif

  glutKeyboardFunc(&gemglutwindow::keyboardCb);
  glutSpecialFunc(&gemglutwindow::specialCb);
  glutReshapeFunc(&gemglutwindow::reshapeCb);
  glutMouseFunc(&gemglutwindow::mouseCb);
  glutMotionFunc(&gemglutwindow::motionCb);
  glutPassiveMotionFunc(&gemglutwindow::passivemotionCb);
  glutEntryFunc(&gemglutwindow::entryCb);
  glutKeyboardUpFunc(&gemglutwindow::keyboardupCb);
  glutSpecialUpFunc(&gemglutwindow::specialupCb);
  glutJoystickFunc(&gemglutwindow::joystickCb, 20);

  glutMenuStateFunc(&gemglutwindow::menustateCb);
  glutMenuStatusFunc(&gemglutwindow::menustatusCb);

  glutWindowStatusFunc(&gemglutwindow::windowstatusCb);

  //  glutNameFunc(&gemglutwindow::nameCb);

  if(!createGemWindow()) {
    destroyMess();
    return false;
  }
  titleMess(m_title);
  fullscreenMess(m_fullscreen);

  dispatch();
  return true;
}
Example #13
0
/////////////////////////////////////////////////////////
// createMess
//
/////////////////////////////////////////////////////////
bool gemglutwindow :: create(void)
{
  if(m_window) {
    error("window already made!");
    return false;
  }


#ifdef FREEGLUT
  // display list sharing (with FreeGLUT)
  if(s_windowmap.size()>0) {
    std::map<int,gemglutwindow*>::iterator it = s_windowmap.begin();
    gemglutwindow*other=NULL;
    other=it->second;
    if(other && other->makeCurrent()) {
      glutSetOption(GLUT_RENDERING_CONTEXT, GLUT_USE_CURRENT_CONTEXT );
    }
  }
#endif

  unsigned int mode=GLUT_RGB | GLUT_DEPTH;
  if(2==m_buffer)
    mode|=GLUT_DOUBLE;
  else
    mode|=GLUT_SINGLE;

  glutInitDisplayMode(mode);

#ifdef FREEGLUT
  //  glutSetOption(GLUT_ACTION_ON_WINDOW_CLOSE, GLUT_ACTION_GLUTMAINLOOP_RETURNS);
  glutSetOption(GLUT_ACTION_ON_WINDOW_CLOSE, GLUT_ACTION_CONTINUE_EXECUTION);
  glutSetOption(GLUT_INIT_WINDOW_X, m_xoffset);
  glutSetOption(GLUT_INIT_WINDOW_Y, m_yoffset);
  glutSetOption(GLUT_INIT_WINDOW_WIDTH, m_width);
  glutSetOption(GLUT_INIT_WINDOW_HEIGHT, m_height);
#endif

  m_window=glutCreateWindow(m_title.c_str());
  s_windowmap[m_window]=this;

  glutReshapeWindow(m_width, m_height);
  glutPositionWindow(m_xoffset, m_yoffset);

  glutCloseFunc     (&closeCb);

  glutKeyboardFunc(&keyboardCb);
  glutSpecialFunc(&specialCb);
  glutReshapeFunc(&reshapeCb);
  glutKeyboardUpFunc(&keyboardupCb);
  glutSpecialUpFunc(&specialupCb);
  glutJoystickFunc(&joystickCb, 20);

  glutMenuStateFunc(&menustateCb);
  glutMenuStatusFunc(&menustatusCb);

  glutWindowStatusFunc(&windowstatusCb);

#if (defined GLUT_HAS_MULTI) && (GLUT_HAS_MULTI > 0)
  glutMultiEntryFunc(multiEntryCb);
  glutMultiButtonFunc(multiButtonCb);
  glutMultiMotionFunc(multiMotionCb);
  glutMultiPassiveFunc(multiPassivemotionCb);
#else
  glutEntryFunc(&entryCb);
  glutMouseFunc(&mouseCb);
  glutMotionFunc(&motionCb);
  glutPassiveMotionFunc(&passivemotionCb);
#endif

  //  glutNameFunc(&nameCb);
  glutDisplayFunc   (&displayCb);
  glutVisibilityFunc(&visibleCb);


  if(!createGemWindow()) {
    destroyMess();
    return false;
  }
  titleMess(m_title);
  fullscreenMess(m_fullscreen);

  dispatch();
  return true;
}
Example #14
0
void helper_glutMenuStatusFunc(IScriptFunction * scriptFunction)
{
	getCurrentCallbackData()->menuStatus.reset(scriptFunction);
	glutMenuStatusFunc(&callback_glutMenuStatusFunc);
}
Example #15
0
void create_menu()
{
    int objects_id = glutCreateMenu(canvas_menu);
    glutAddMenuEntry(" Box         ", 1);
    glutAddMenuEntry(" Cylinder    ", 2);
    glutAddMenuEntry(" Sphere      ", 3);
    glutAddMenuEntry(" Pyramid     ", 4);
    glutAddMenuEntry(" Model       ", 5);


    // TODO Assignment 3: uncomment this
    /*int lights_id = glutCreateMenu(canvas_menu);
    glutAddMenuEntry(" Toggle Draw ", 6);
    glutAddMenuEntry(" Directional ", 7);
    glutAddMenuEntry(" Point       ", 8);
    glutAddMenuEntry(" Spot        ", 9);*/

    int camera_id = glutCreateMenu(canvas_menu);
    glutAddMenuEntry(" Fovy        ", 10);
    glutAddMenuEntry(" Aspect      ", 11);
    glutAddMenuEntry(" Width       ", 12);
    glutAddMenuEntry(" Height      ", 13);
    glutAddMenuEntry(" Near        ", 14);
    glutAddMenuEntry(" Far         ", 15);
    glutAddMenuEntry(" Toggle Draw ", 16);
    glutAddMenuEntry(" Clear Focus ", 17);
    glutAddMenuEntry(" Ortho       ", 18);
    glutAddMenuEntry(" Frustum     ", 19);
    glutAddMenuEntry(" Perspective ", 20);

    int mode_id = glutCreateMenu(canvas_menu);
    glutAddMenuEntry(" Point       ", 21);
    glutAddMenuEntry(" Line        ", 22);
    // TODO Assignment 2: uncomment this
    //glutAddMenuEntry(" Fill        ", 23);


    // TODO Assignment 3: uncomment this
    /*int ambient_id = glutCreateMenu(color_menu);
    glutAddMenuEntry(" Red         ", 0);
    glutAddMenuEntry(" Orange      ", 1);
    glutAddMenuEntry(" Yellow      ", 2);
    glutAddMenuEntry(" Green       ", 3);
    glutAddMenuEntry(" Blue        ", 4);
    glutAddMenuEntry(" Indigo      ", 5);
    glutAddMenuEntry(" Violet      ", 6);
    glutAddMenuEntry(" Black       ", 7);
    glutAddMenuEntry(" White       ", 8);
    glutAddMenuEntry(" Brown       ", 9);

    int diffuse_id = glutCreateMenu(color_menu);
    glutAddMenuEntry(" Red         ", 10);
    glutAddMenuEntry(" Orange      ", 11);
    glutAddMenuEntry(" Yellow      ", 12);
    glutAddMenuEntry(" Green       ", 13);
    glutAddMenuEntry(" Blue        ", 14);
    glutAddMenuEntry(" Indigo      ", 15);
    glutAddMenuEntry(" Violet      ", 16);
    glutAddMenuEntry(" Black       ", 17);
    glutAddMenuEntry(" White       ", 18);
    glutAddMenuEntry(" Brown       ", 19);

    int specular_id = glutCreateMenu(color_menu);
    glutAddMenuEntry(" Red         ", 20);
    glutAddMenuEntry(" Orange      ", 21);
    glutAddMenuEntry(" Yellow      ", 22);
    glutAddMenuEntry(" Green       ", 23);
    glutAddMenuEntry(" Blue        ", 24);
    glutAddMenuEntry(" Indigo      ", 25);
    glutAddMenuEntry(" Violet      ", 26);
    glutAddMenuEntry(" Black       ", 27);
    glutAddMenuEntry(" White       ", 28);
    glutAddMenuEntry(" Brown       ", 29);

    int attenuation_id = glutCreateMenu(attenuation_menu);
    glutAddMenuEntry(" Range 7     ",  0);
    glutAddMenuEntry(" Range 13    ",  1);
    glutAddMenuEntry(" Range 20    ",  2);
    glutAddMenuEntry(" Range 32    ",  3);
    glutAddMenuEntry(" Range 50    ",  4);
    glutAddMenuEntry(" Range 65    ",  5);
    glutAddMenuEntry(" Range 100   ",  6);
    glutAddMenuEntry(" Range 160   ",  7);
    glutAddMenuEntry(" Range 200   ",  8);
    glutAddMenuEntry(" Range 325   ",  9);
    glutAddMenuEntry(" Range 600   ",  10);
    glutAddMenuEntry(" Range 3250  ",  11);


    int shading_id = glutCreateMenu(canvas_menu);
    glutAddMenuEntry(" Flat        ", 25);
    glutAddMenuEntry(" Smooth      ", 26);*/

    // TODO Assignment 2: uncomment this
    /*int culling_id = glutCreateMenu(canvas_menu);
    glutAddMenuEntry(" None        ", 28);
    glutAddMenuEntry(" Back        ", 29);
    glutAddMenuEntry(" Front       ", 30);*/

    int normal_id = glutCreateMenu(canvas_menu);
    glutAddMenuEntry(" None        ", 31);
    glutAddMenuEntry(" Face        ", 32);
    glutAddMenuEntry(" Vertex      ", 33);

    canvas_menu_id = glutCreateMenu(canvas_menu);
    glutAddSubMenu  (" Objects     ", objects_id);
    // TODO Assignment 3: uncomment this
    //glutAddSubMenu  (" Lights      ", lights_id);
    glutAddSubMenu  (" Cameras     ", camera_id);
    glutAddSubMenu  (" Polygon     ", mode_id);
    // TODO Assignment 3: uncomment this
    //glutAddSubMenu  (" Shading     ", shading_id);
    // TODO Assignment 2: uncomment this
    //glutAddSubMenu  (" Culling     ", culling_id);
    glutAddSubMenu  (" Normals     ", normal_id);
    glutAddMenuEntry(" Quit        ", 0);

    // TODO Assignment 3: uncomment this
    /*int material_menu_id = glutCreateMenu(object_menu);
    glutAddMenuEntry(" White       ", 10);
    glutAddMenuEntry(" Gouraud     ", 9);
    glutAddMenuEntry(" Phong       ", 8);
    glutAddMenuEntry(" Custom      ", 7);*/
    // TODO Assignment 4: uncomment this
    //glutAddMenuEntry(" Texture     ", 6);

    object_menu_id = glutCreateMenu(object_menu);
    // TODO Assignment 3: uncomment this
    //glutAddSubMenu  (" Material    ", material_menu_id);
    glutAddMenuEntry(" Set Focus   ", 5);
    glutAddMenuEntry(" Translate   ", 1);
    glutAddMenuEntry(" Rotate      ", 2);
    glutAddMenuEntry(" Scale       ", 3);
    glutAddMenuEntry(" Delete      ", 0);

    // TODO Assignment 3: uncomment this
    /*light_menu_id = glutCreateMenu(object_menu);
    glutAddSubMenu  (" Ambient     ", ambient_id);
    glutAddSubMenu  (" Diffuse     ", diffuse_id);
    glutAddSubMenu  (" Specular    ", specular_id);
    glutAddSubMenu  (" Attenuation ", attenuation_id);
    glutAddMenuEntry(" Set Focus   ", 5);
    glutAddMenuEntry(" Translate   ", 1);
    glutAddMenuEntry(" Rotate      ", 2);
    glutAddMenuEntry(" Delete      ", 0);*/

    camera_menu_id = glutCreateMenu(object_menu);
    glutAddMenuEntry(" Set Active  ", 4);
    glutAddMenuEntry(" Set Focus   ", 5);
    glutAddMenuEntry(" Translate   ", 1);
    glutAddMenuEntry(" Rotate      ", 2);
    glutAddMenuEntry(" Scale       ", 3);
    glutAddMenuEntry(" Delete      ", 0);

    glutSetMenu(canvas_menu_id);
    glutAttachMenu(GLUT_RIGHT_BUTTON);

    glutMenuStatusFunc(menustatusfunc);
}
Example #16
0
/*
 * The sample's entry point
 */
int main( int argc, char** argv )
{
    int menuID, subMenuA, subMenuB;

    glutInitDisplayString( "stencil~2 rgb double depth>=16 samples" );
    glutInitDisplayMode( GLUT_RGB | GLUT_DOUBLE | GLUT_DEPTH );
    glutInitWindowPosition( 100, 100 );

    glutInit( &argc, argv );

    glutSetOption(GLUT_ACTION_ON_WINDOW_CLOSE,GLUT_ACTION_GLUTMAINLOOP_RETURNS);
    glutMenuStatusFunc( SampleMenuStatus );
    glutIdleFunc( SampleIdle );

    subMenuA = glutCreateMenu( SampleMenu );
    glutAddMenuEntry( "Sub menu A1 (01)", 1 );
    glutAddMenuEntry( "Sub menu A2 (02)", 2 );
    glutAddMenuEntry( "Sub menu A3 (03)", 3 );

    subMenuB = glutCreateMenu( SampleMenu );
    glutAddMenuEntry( "Sub menu B1 (04)", 4 );
    glutAddMenuEntry( "Sub menu B2 (05)", 5 );
    glutAddMenuEntry( "Sub menu B3 (06)", 6 );
    glutAddSubMenu( "Going to sub menu A", subMenuA );

    menuID = glutCreateMenu( SampleMenu );
    glutAddMenuEntry( "Entry one",   1 );
    glutAddMenuEntry( "Entry two",   2 );
    glutAddMenuEntry( "Entry three", 3 );
    glutAddMenuEntry( "Entry four",  4 );
    glutAddMenuEntry( "Entry five",  5 );
    glutAddSubMenu( "Enter sub menu A", subMenuA );
    glutAddSubMenu( "Enter sub menu B", subMenuB );

    g_mainwin1 = glutCreateWindow( "Hello world!" );
    glutDisplayFunc( SampleDisplay );
    glutReshapeFunc( SampleReshape );
    glutKeyboardFunc( SampleKeyboard );
    glutSpecialFunc( SampleSpecial );
    glutEntryFunc( SampleEntry );
    glutAttachMenu( GLUT_LEFT_BUTTON );

    glutInitWindowPosition( 200, 200 );
    g_mainwin2 = glutCreateWindow( "I am not Jan B." );
    glutDisplayFunc( SampleDisplay );
    glutReshapeFunc( SampleReshape );
    glutKeyboardFunc( SampleKeyboard );
    glutSpecialFunc( SampleSpecial );
    glutEntryFunc( SampleEntry );
    glutAttachMenu( GLUT_LEFT_BUTTON );
    glutSetMenu(subMenuA);
    glutAttachMenu( GLUT_RIGHT_BUTTON );

    g_sw1=glutCreateSubWindow(g_mainwin2,200,0,100,100);
    glutDisplayFunc( SampleDisplay );
    glutSetMenu(subMenuB);
    glutAttachMenu( GLUT_LEFT_BUTTON );

    g_sw2=glutCreateSubWindow(g_sw1,50,0,50,50);
    glutDisplayFunc( SampleDisplay );
    glutSetMenu(menuID);
    glutAttachMenu( GLUT_RIGHT_BUTTON );

    printf( "Testing game mode string parsing, don't panic!\n" );
    glutGameModeString( "320x240:32@100" );
    glutGameModeString( "640x480:16@72" );
    glutGameModeString( "1024x768" );
    glutGameModeString( ":32@120" );
    glutGameModeString( "Toudi glupcze, Danwin bedzie moj!" );

    glutGameModeString( "640x480:37@300" );    /* this one should fail */
    glutEnterGameMode();

    glutGameModeString( "800x600" );    /* this one is likely to succeed */
    g_gamemodewin = glutEnterGameMode();

    if (glutGameModeGet(GLUT_GAME_MODE_ACTIVE))
        g_InGameMode = 1;
    glutDisplayFunc( SampleDisplay );
    glutReshapeFunc( SampleReshape );
    glutKeyboardFunc( SampleGameModeKeyboard );
    glutEntryFunc( SampleEntry );
    glutSetMenu(menuID);
    glutAttachMenu( GLUT_LEFT_BUTTON );

    printf( "current window is %ix%i at (%i,%i)\n",
            glutGet( GLUT_WINDOW_WIDTH ), glutGet( GLUT_WINDOW_HEIGHT ),
            glutGet( GLUT_WINDOW_X ), glutGet( GLUT_WINDOW_Y )
          );

    /*
     * Describe pixel format
     */
    printf("The current window has %i red bits, %i green bits, %i blue bits and %i alpha bits for a total buffer size of %i bits\n",glutGet(GLUT_WINDOW_RED_SIZE),glutGet(GLUT_WINDOW_GREEN_SIZE),glutGet(GLUT_WINDOW_BLUE_SIZE),glutGet(GLUT_WINDOW_ALPHA_SIZE),glutGet(GLUT_WINDOW_BUFFER_SIZE));
    printf("It furthermore has %i depth bits and %i stencil bits\n",glutGet(GLUT_WINDOW_DEPTH_SIZE),glutGet(GLUT_WINDOW_STENCIL_SIZE));

    /*
     * Enter the main FreeGLUT processing loop
     */
    glutMainLoop();

    /*
     * returned from mainloop after window closed
     * see glutSetOption(GLUT_ACTION_ON_WINDOW_CLOSE,GLUT_ACTION_GLUTMAINLOOP_RETURNS); above
     */
    printf( "glutMainLoop() termination works fine!\n" );

    return EXIT_SUCCESS;
}
Example #17
0
void InitOpenGL(void){
  int type;
  int err;

  PRINTF("%s",_("Initializing OpenGL\n"));
  
  type = GLUT_RGB|GLUT_DEPTH;
  if(buffertype==GLUT_DOUBLE){
    type |= GLUT_DOUBLE;
  }
  else{
    type |= GLUT_SINGLE;
  }

//  glutInitDisplayMode(GLUT_STEREO);
  if(stereoactive==1){
    if(glutGet(GLUT_DISPLAY_MODE_POSSIBLE)==1){
      videoSTEREO=1;
      type |= GLUT_STEREO;
    }
    else{
      videoSTEREO=0;
      fprintf(stderr,"*** Error: video hardware does not support stereo\n");
    }
  }

#ifdef _DEBUG
  PRINTF("%s",_("   Initializing Glut display mode - "));
#endif
  glutInitDisplayMode(type);
#ifdef _DEBUG
  PRINTF("%s\n",_("initialized"));
#endif

  CheckMemory;
#ifdef _DEBUG
  PRINTF("%s\n",_("   creating window"));
#endif
  mainwindow_id=glutCreateWindow("");
#ifdef _DEBUG
  PRINTF("%s\n",_("   window created"));
#endif

#ifdef _DEBUG
  PRINTF("%s",_("   Initializing callbacks - "));
#endif
  glutSpecialUpFunc(specialkeyboard_up_CB);
  glutKeyboardUpFunc(keyboard_up_CB);
  glutKeyboardFunc(keyboard_CB);
  glutMouseFunc(mouse_CB);
  glutSpecialFunc(specialkeyboard_CB);
  glutMotionFunc(motion_CB);
  glutReshapeFunc(Reshape_CB);
  glutDisplayFunc(Display_CB);
  glutVisibilityFunc(NULL);
  glutMenuStatusFunc(MenuStatus_CB);
#ifdef _DEBUG
  PRINTF("%s\n",_("initialized"));
#endif

  opengl_version = get_opengl_version(opengl_version_label);

  err=0;  
 #ifdef pp_GPU
  err=glewInit();
  if(err==GLEW_OK){
    err=0;
  }
  else{
    PRINTF("   GLEW initialization failed\n");
    err=1;
  }
  if(err==0){
    if(disable_gpu==1){
      err=1;
    }
    else{
      err=init_shaders();
    }
#ifdef _DEBUG
    if(err==0){
      PRINTF("%s\n",_("   GPU shader initialization succeeded"));
    }
#endif
    if(err!=0){
      PRINTF("%s\n",_("   GPU shader initialization failed"));
    }
  }
#endif
#ifdef pp_CULL
  if(err==0){
    err=init_cull_exts();
#ifdef _DEBUG
    if(err==0){
      PRINTF("%s\n",_("   Culling extension initialization succeeded"));
    }
#endif
    if(err!=0){
      PRINTF("%s\n",_("   Culling extension initialization failed"));
    }
  }
#endif

  light_position0[0]=1.0f;
  light_position0[1]=1.0f;
  light_position0[2]=4.0f; 
  light_position0[3]=0.f;

  light_position1[0]=-1.0f;
  light_position1[1]=1.0f;
  light_position1[2]=4.0f;
  light_position1[3]=0.f;

  glLightModeli(GL_LIGHT_MODEL_TWO_SIDE,GL_TRUE);
  updateLights(light_position0,light_position1);

  {
    glGetIntegerv(GL_RED_BITS,&nredbits);    
    glGetIntegerv(GL_GREEN_BITS,&ngreenbits);
    glGetIntegerv(GL_BLUE_BITS,&nbluebits);

    nredshift = 8 - nredbits;
    if(nredshift<0)nredshift=0;
    ngreenshift = 8 - ngreenbits;
    if(ngreenshift<0)ngreenshift=0;
    nblueshift=8-nbluebits;
    if(nblueshift<0)nblueshift=0;
  }
  opengldefined=1;
  PRINTF("%s",_("OpenGL initialization completed\n\n"));
}