Ejemplo n.º 1
0
/*!
    \fn
    \brief    Sets the Visibility callback for the current window.
    \ingroup  deprecated
    \param    callback    Client hook for visibility changes.

              OpenGLUT may call this function when your window's
              visbility status has changed.  \a status can take
              on two values: \a GLUT_NOT_VISIBLE or \a GLUT_VISIBLE .
              If any pixel of your window (including descendants) is
              visible, your window is \a GLUT_VISIBLE .

              The callback is bound to the <i>current window</i>.

    \note     This is not a polling mechanism.  You are only informed
              of transitions that OpenGLUT observes while your
              callback is in place.
    \note     This function appears to be superceded by
              glutWindowStatusFunc().
    \note     This callback is mutually exclusive of glutWindowStatusFunc().
    \see      glutWindowStatusFunc()
*/
void OGAPIENTRY glutVisibilityFunc( void( *callback )( int status ) )
{
    SET_CALLBACK( Visibility );

    if( callback )
        glutWindowStatusFunc( oghVisibility );
    else
        glutWindowStatusFunc( NULL );
}
Ejemplo n.º 2
0
void GLUTAPIENTRY
glutVisibilityFunc(GLUTvisibilityCB visibilityFunc)
{
  __glutCurrentWindow->visibility = visibilityFunc;
  if (visibilityFunc)
    glutWindowStatusFunc(visibilityHelper);
  else
    glutWindowStatusFunc(NULL);
}
Ejemplo n.º 3
0
void FGAPIENTRY glutVisibilityFunc( FGCBVisibility callback )
{
    FREEGLUT_EXIT_IF_NOT_INITIALISED ( "glutVisibilityFunc" );
    SET_CALLBACK( Visibility );

    if( callback )
        glutWindowStatusFunc( fghVisibility );
    else
        glutWindowStatusFunc( NULL );
}
Ejemplo n.º 4
0
void GLUTAPIENTRY
glutVisibilityFunc(GLUTvisibilityCB visibilityFunc)
{
  __glutCurrentWindow->visibility = visibilityFunc;

  if (visibilityFunc)
  {    glutWindowStatusFunc(visibilityHelper);
#if defined(__OS2PM__)
       if(__glutCurrentWindow->shownState >= 0)
       {  visibilityHelper(__glutCurrentWindow->shownState);
       }
#endif
  }
  else
    glutWindowStatusFunc(NULL);
}
Ejemplo n.º 5
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
}
Ejemplo n.º 6
0
/*
 * Class:     gruenewa_opengl_GLUT__
 * Method:    glutWindowStatusFunc
 * Signature: (Lscala/Function1;)V
 */
JNIEXPORT void JNICALL Java_gruenewa_opengl_GLUT_00024_glutWindowStatusFunc
  (JNIEnv * jenv, jobject jobj, jobject arg1) {

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

  // fixme remove old obj if exists

  glutWindowStatusFunc_obj = (*jenv)->NewGlobalRef(jenv, arg1);
  return glutWindowStatusFunc(glutWindowStatusFuncCallback);

}
Ejemplo n.º 7
0
//GlutInstace Class Constructor(Default and 5 argument version)
Glut2D::Glut2D(const std::string& windowCaption,const int windowWidth,const int windowHeight,void(*timer)(Glut2D&),
    const unsigned int timerTime,void(*display)(Glut2D&)):camera(),_windowID(-1),_windowWidth(windowWidth),_windowHeight(windowHeight),
    _active(false),_timer(timer),_timerTime(timerTime),_display(display),_dt(0.0),_ot(0.0),_mouseX(0),_mouseY(0)
{
    //Check Timer Function
    if(!_timer)
    {
        throw std::runtime_error("Glut2D - Invalid timer function!!!");
    }

    //Check Display Function
    if(!_display)
    {
        throw std::runtime_error("Glut2D - Invalid display function!!!");
    }

    //Add to Static Vector
    _instance.push_back(this);

    //Set Window Size and Create Window
    glutInitWindowSize(_windowWidth,_windowHeight);
    _windowID=glutCreateWindow(windowCaption.c_str());

    //Input Functions
    glutKeyboardFunc(keyboardDown);
	glutKeyboardUpFunc(keyboardUp);
	glutSpecialFunc(specialDown);
	glutSpecialUpFunc(specialUp);
	glutMouseFunc(mouse);
	glutEntryFunc(mouseEntry);
	glutMotionFunc(motion);
	glutPassiveMotionFunc(motion);

	glutSetKeyRepeat(GLUT_KEY_REPEAT_OFF);

    //Window Functions
	glutReshapeFunc(Glut2D::reshape);
	glutWindowStatusFunc(Glut2D::windowStatus);

	//Timer Function
	glutTimerFunc(_timerTime,Glut2D::timer,0);

	//Display Function
	glutDisplayFunc(Glut2D::display);

	//Enable Color Key Transparency
    glEnable(GL_ALPHA_TEST);
        glAlphaFunc(GL_GREATER,0.0);
    glEnable(GL_BLEND);
        glBlendFunc(GL_SRC_ALPHA,GL_ONE_MINUS_SRC_ALPHA);
}
Ejemplo n.º 8
0
	/*
	Creates the actual window based on the window properties 
	set in the configuration struct.
	*/
	bool createWindow(void)
	{
		
		// Set up our window to have a color buffer and have it double buffered.
		glutInitDisplayMode(GLUT_RGBA | GLUT_DOUBLE);

		// Set the size and position of the window.
		glutInitWindowSize(c->x_res, c->y_res);
		glutInitWindowPosition(c->win_x, c->win_y);
		
		// Create the window.
		glutCreateWindow(c->title);

		// Give the window an icon
		glutSetIconTitle("assets\\images\\dependent\\icon.png");

		// Remove the cursor when it is over the window.
		glutSetCursor(GLUT_CURSOR_NONE);

		// Store the fullscreen variable for switching awareness.
		fullscreen = c->fullscr;

		// Make the window fullscreen if necessary.
		if(fullscreen) glutFullScreen();

		// Set a basic clear color for OpenGL.
		glClearColor(c->clr_r, c->clr_g, c->clr_b, 1);

		// Enable alpha rendering.
		glEnable(GL_BLEND);
		glBlendFunc(GL_SRC_ALPHA,GL_ONE_MINUS_SRC_ALPHA);

		// F*****G ENABLE DEPTH TESTING.
		glEnable(GL_DEPTH_TEST);
		glDepthFunc(GL_LEQUAL);

		// Enable texturing.
		glEnable(GL_TEXTURE_2D);

		// Set the viewport to take up the entire window.
		glViewport(0, 0, c->x_res/2, c->y_res);

		// Pass in our callbacks.
		glutDisplayFunc(render);
		glutIdleFunc(render);
		glutWindowStatusFunc(visibilityFunc);

		// If everything's gone well up until this point, we can return true.
		return true;
	}
Ejemplo n.º 9
0
Game::Game() : univers(), simulator(&univers)
{
        glClearColor(BACKGROUND_COLOR);

#ifdef FULLSCREEN
                glutFullScreen();
#endif
        
        
        setSimulator(&simulator);
        setUnivers(&univers);
        
	Vvector pos(0, 0, 0);
	Vvector addx(10, 0, 0);
	Vvector addy(0, 10, 0);
	
	for (int i = 0; i < 48; i++) {
	for (int j = 0; j < 48; j++) {
		this->univers.addPlanet("Torus", pos);
		pos += addx;
	}
		pos = Vvector(0, pos.y() + addy.y(), pos.z());
	}
	
	
        {
                glutIgnoreKeyRepeat(GLUT_KEY_REPEAT_DEFAULT);
                glutTimerFunc(KEY_REPEAT_PERIOD, keyboard, 0);
        }
        {
                glutReshapeFunc(windowResizingHandler);
                glutWindowStatusFunc(windowStatusHandler);
#ifdef __APPLE__
                glutWMCloseFunc(windowClosingHandler);
#endif
                glutDisplayFunc(displayHandler);
        }
}
Ejemplo n.º 10
0
int main(int argc, char* argv[])
{
    int border, caption;
    glutInit( &argc, argv );
    glutInitDisplayMode( GLUT_RGB | GLUT_DOUBLE /*| GLUT_BORDERLESS*/); // do try as well with GLUT_BORDERLESS and GLUT_CAPTIONLESS
    glutSetOption(GLUT_ACTION_ON_WINDOW_CLOSE,GLUT_ACTION_GLUTMAINLOOP_RETURNS);
    
    /* Get border and caption size of default window style */
    border  = glutGet(GLUT_WINDOW_BORDER_WIDTH);
    caption = glutGet(GLUT_WINDOW_HEADER_HEIGHT);
    printf("default window style border: %dpx, caption: %dpx\n",border,caption);

    /* NB: The window position you request is the outer top-left of the
     * window, the client area is at a different position if the window has
     * borders and/or a title bar.
     */
    glutInitWindowPosition(150,250);
    glutInitWindowSize(200,200);

    nWindow = glutCreateWindow("test");
    glutSetIconTitle("test icon title");
    printf("main window id: %d\n", nWindow);

    glutKeyboardFunc( SampleKeyboard );
    glutDisplayFunc( Redisplay );
    glutReshapeFunc( Reshape );
    glutPositionFunc( Position );
    glutWindowStatusFunc( WindowStatus );

    glutTimerFunc(300, Timer, 0);

    glutMainLoop();
    printf("glutMainLoop returned\n");

    return EXIT_SUCCESS;
}
Ejemplo n.º 11
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;
}
Ejemplo n.º 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);

#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;
}
Ejemplo n.º 13
0
void helper_glutWindowStatusFunc(IScriptFunction * scriptFunction)
{
	getCurrentCallbackData()->windowStatus.reset(scriptFunction);
	glutWindowStatusFunc(&callback_glutWindowStatusFunc);
}
Ejemplo n.º 14
0
void SampleKeyboard( unsigned char cChar, int nMouseX, int nMouseY )
{
    switch (cChar)
    {
    case 27:
        glutLeaveMainLoop();

        break;


    case 'f':
    case 'F':
        printf("main window toggle fullscreen\n");
        glutFullScreenToggle();

        break;


    case 'r':
    case 'R':
        if (nChildWindow!=-1 && cChar=='r') /* Capital R always resizes the main window*/
        {
            glutSetWindow(nChildWindow);
            printf("child window resize\n");
            if (!bChildSizeDone)
                glutReshapeWindow(glutGet(GLUT_WINDOW_WIDTH)+50,glutGet(GLUT_WINDOW_HEIGHT)+50);
            else
                glutReshapeWindow(glutGet(GLUT_WINDOW_WIDTH)-50,glutGet(GLUT_WINDOW_HEIGHT)-50);
            bChildSizeDone = !bChildSizeDone;
        }
        else
        {
            glutSetWindow(nWindow);
            printf("main window resize\n");
            if (glutGet(GLUT_WINDOW_WIDTH)<400)
                glutReshapeWindow(600,300);
            else
                glutReshapeWindow(300,300);
        }

        break;


    case 'm':
    case 'M':
        if (nChildWindow!=-1 && cChar=='m') /* Capital M always moves the main window*/
        {
            glutSetWindow(nChildWindow);
            /* The window position you request is relative to the top-left
             * corner of the client area of the parent window.
             */
            if (!bChildPosDone)
                glutPositionWindow(glutGet(GLUT_WINDOW_X)+50,glutGet(GLUT_WINDOW_Y)+50);
            else
                glutPositionWindow(glutGet(GLUT_WINDOW_X)-50,glutGet(GLUT_WINDOW_Y)-50);
            bChildPosDone = !bChildPosDone;
        }
        else
        {
            glutSetWindow(nWindow);
            printf("main window position\n");
            /* The window position you request is the outer top-left of the window,
             * the client area is at a different position if the window has borders
             * and/or a title bar.
             */
            if (glutGet(GLUT_WINDOW_X)<400)
                glutPositionWindow(600,300);
            else
                glutPositionWindow(300,300);
        }

        break;


    case 'd':
    case 'D':
        if (nChildWindow!=-1 && cChar=='d') /* Capital D always moves+resizes the main window*/
        {
            glutSetWindow(nChildWindow);
            if (!bChildPosDone)
                glutPositionWindow(glutGet(GLUT_WINDOW_X)+50,glutGet(GLUT_WINDOW_Y)+50);
            else
                glutPositionWindow(glutGet(GLUT_WINDOW_X)-50,glutGet(GLUT_WINDOW_Y)-50);
            bChildPosDone = !bChildPosDone;
            if (!bChildSizeDone)
                glutReshapeWindow(glutGet(GLUT_WINDOW_WIDTH)+50,glutGet(GLUT_WINDOW_HEIGHT)+50);
            else
                glutReshapeWindow(glutGet(GLUT_WINDOW_WIDTH)-50,glutGet(GLUT_WINDOW_HEIGHT)-50);
            bChildSizeDone = !bChildSizeDone;
        }
        else
        {
            if (glutGet(GLUT_WINDOW_X)<400)
                glutPositionWindow(600,300);
            else
                glutPositionWindow(300,300);
            if (glutGet(GLUT_WINDOW_WIDTH)<400)
                glutReshapeWindow(600,300);
            else
                glutReshapeWindow(300,300);
        }
        break;


    case 'c':
    case 'C':
        if (nChildWindow==-1)
        {
            int width  = glutGet(GLUT_WINDOW_WIDTH);
            int height = glutGet(GLUT_WINDOW_HEIGHT);

            /* open child window */
            printf("open child window\n");

            nChildWindow = glutCreateSubWindow(nWindow,(int)(width*.35),(int)(height*.35),(int)(width*.3),(int)(height*.3));
            glutKeyboardFunc( SampleKeyboard );
            glutDisplayFunc( Redisplay );
            glutReshapeFunc( Reshape );
            glutPositionFunc( Position );
            glutWindowStatusFunc( WindowStatus );
        }
        else
        {
            /* close child window */
            printf("close child window\n");
            glutSetWindow(nWindow);
            glutDestroyWindow(nChildWindow);
            nChildWindow = -1;
            bChildSizeDone = GL_FALSE;
            bChildPosDone  = GL_FALSE;
        }
        break;


    case 'i':
    case 'I':
        glutIconifyWindow();
        glutTimerFunc(1500, ChangeTitleTimer, 0);
        break;


    case 'h':
    case 'H':
        if (nChildWindow!=-1 && cChar=='h') /* Capital H always hides the main window*/
        {
            glutSetWindow(nChildWindow);
            glutTimerFunc(2000, UnhideTimer, nChildWindow);
        }
        else
        {
            glutSetWindow(nWindow);
            glutTimerFunc(2000, UnhideTimer, nWindow);
        }
        glutHideWindow();
        break;

    case 'p':
    case 'P':
        if (nChildWindow!=-1 && cChar=='p') /* Capital P always changes pointer for the main window*/
        {
            glutSetWindow(nChildWindow);
            if (glutGet(GLUT_WINDOW_CURSOR)==GLUT_CURSOR_TOP_SIDE)
                glutSetCursor(GLUT_CURSOR_RIGHT_ARROW);
            else
                glutSetCursor(GLUT_CURSOR_TOP_SIDE);
        }
        else
        {
            glutSetWindow(nWindow);
            if (glutGet(GLUT_WINDOW_CURSOR)==GLUT_CURSOR_CYCLE)
                glutSetCursor(GLUT_CURSOR_RIGHT_ARROW);
            else
                glutSetCursor(GLUT_CURSOR_CYCLE);
        }
        break;

    default:
        break;
    }
}