Beispiel #1
0
void fgPlatformInitialize( const char* displayName )
{
    fgDisplay.pDisplay.display = wl_display_connect( NULL );

    if( fgDisplay.pDisplay.display == NULL )
        fgError( "failed to connect to a Wayland compositor" );

    fgDisplay.pDisplay.registry = wl_display_get_registry(
                                    fgDisplay.pDisplay.display );
    wl_registry_add_listener( fgDisplay.pDisplay.registry,
                              &fghRegistryListener,
                              &fgDisplay.pDisplay );
    wl_display_roundtrip( fgDisplay.pDisplay.display );

    if( fgDisplay.pDisplay.compositor == NULL ||
        fgDisplay.pDisplay.shell == NULL ||
        fgDisplay.pDisplay.seat == NULL ||
        fgDisplay.pDisplay.shm == NULL )
          fgError( "failed to discover all needed compositor interfaces" );

    fghInitialiseCursorTheme();

    fghPlatformInitializeEGL();

    /* Get start time */
    fgState.Time = fgSystemTime();

    fgState.Initialised = GL_TRUE;

    atexit(fgDeinitialize);

    /* InputDevice uses GlutTimerFunc(), so fgState.Initialised must be TRUE */
    fgPlatformInitialiseInputDevices();
}
Beispiel #2
0
/*
 * A call to this function should initialize all the display stuff...
 */
void fgPlatformInitialize( const char* displayName )
{
    fgDisplay.pDisplay.Display = XOpenDisplay( displayName );

    if( fgDisplay.pDisplay.Display == NULL )
        fgError( "failed to open display '%s'", XDisplayName( displayName ) );

    if ( fgState.XSyncSwitch )
        XSynchronize(fgDisplay.pDisplay.Display, True);

#ifdef EGL_VERSION_1_0
    fghPlatformInitializeEGL();
#else
    if( !glXQueryExtension( fgDisplay.pDisplay.Display, NULL, NULL ) )
        fgError( "OpenGL GLX extension not supported by display '%s'",
            XDisplayName( displayName ) );

    /* This forces AMD Catalyst drivers to initialize and register a shutdown
     * function, which must be done before our own call to atexit to prevent
     * a crash if glutMainLoop is not called or is not exited cleanly.
     * (see bug #206)
     */
    glXQueryExtensionsString( fgDisplay.pDisplay.Display,
        DefaultScreen( fgDisplay.pDisplay.Display ));
#endif

    fgDisplay.pDisplay.Screen = DefaultScreen( fgDisplay.pDisplay.Display );
    fgDisplay.pDisplay.RootWindow = RootWindow(
        fgDisplay.pDisplay.Display,
        fgDisplay.pDisplay.Screen
    );

    fgDisplay.ScreenWidth  = DisplayWidth(
        fgDisplay.pDisplay.Display,
        fgDisplay.pDisplay.Screen
    );
    fgDisplay.ScreenHeight = DisplayHeight(
        fgDisplay.pDisplay.Display,
        fgDisplay.pDisplay.Screen
    );

    fgDisplay.ScreenWidthMM = DisplayWidthMM(
        fgDisplay.pDisplay.Display,
        fgDisplay.pDisplay.Screen
    );
    fgDisplay.ScreenHeightMM = DisplayHeightMM(
        fgDisplay.pDisplay.Display,
        fgDisplay.pDisplay.Screen
    );

    fgDisplay.pDisplay.Connection = ConnectionNumber( fgDisplay.pDisplay.Display );

    /* Create the window deletion atom */
    fgDisplay.pDisplay.DeleteWindow = fghGetAtom("WM_DELETE_WINDOW");

    /* Create the state and full screen atoms */
    fgDisplay.pDisplay.State           = None;
    fgDisplay.pDisplay.StateFullScreen = None;
    fgDisplay.pDisplay.NetWMPid        = None;
    fgDisplay.pDisplay.ClientMachine   = None;

    fgDisplay.pDisplay.NetWMSupported = fghNetWMSupported();

    if (fgDisplay.pDisplay.NetWMSupported)
    {
      const Atom supported = fghGetAtom("_NET_SUPPORTED");
      const Atom state     = fghGetAtom("_NET_WM_STATE");
      
      /* Check if the state hint is supported. */
      if (fgHintPresent(fgDisplay.pDisplay.RootWindow, supported, state))
      {
        const Atom full_screen = fghGetAtom("_NET_WM_STATE_FULLSCREEN");
        
        fgDisplay.pDisplay.State = state;
        
        /* Check if the window manager supports full screen. */
        /**  Check "_NET_WM_ALLOWED_ACTIONS" on our window instead? **/
        if (fgHintPresent(fgDisplay.pDisplay.RootWindow, supported, full_screen))
        {
          fgDisplay.pDisplay.StateFullScreen = full_screen;
        }
      }

      fgDisplay.pDisplay.NetWMPid = fghGetAtom("_NET_WM_PID");
      fgDisplay.pDisplay.ClientMachine = fghGetAtom("WM_CLIENT_MACHINE");
    }

    /* Get start time */
    fgState.Time = fgSystemTime();
    

    fgState.Initialised = GL_TRUE;

    atexit(fgDeinitialize);

    /* InputDevice uses GlutTimerFunc(), so fgState.Initialised must be TRUE */
    fgInitialiseInputDevices();
}
void fgPlatformInitialize()
{
  fghPlatformInitializeEGL();
  fgState.Initialised = GL_TRUE;
}
Beispiel #4
0
/*
 * A call to this function should initialize all the display stuff...
 */
void fgPlatformInitialize( const char* displayName )
{
    fgDisplay.pDisplay.Display = XOpenDisplay( displayName );

    if( fgDisplay.pDisplay.Display == NULL )
        fgError( "failed to open display '%s'", XDisplayName( displayName ) );

#ifdef EGL_VERSION_1_0
    fghPlatformInitializeEGL();
#else
    if( !glXQueryExtension( fgDisplay.pDisplay.Display, NULL, NULL ) )
        fgError( "OpenGL GLX extension not supported by display '%s'",
            XDisplayName( displayName ) );
#endif

    fgDisplay.pDisplay.Screen = DefaultScreen( fgDisplay.pDisplay.Display );
    fgDisplay.pDisplay.RootWindow = RootWindow(
        fgDisplay.pDisplay.Display,
        fgDisplay.pDisplay.Screen
    );

    fgDisplay.ScreenWidth  = DisplayWidth(
        fgDisplay.pDisplay.Display,
        fgDisplay.pDisplay.Screen
    );
    fgDisplay.ScreenHeight = DisplayHeight(
        fgDisplay.pDisplay.Display,
        fgDisplay.pDisplay.Screen
    );

    fgDisplay.ScreenWidthMM = DisplayWidthMM(
        fgDisplay.pDisplay.Display,
        fgDisplay.pDisplay.Screen
    );
    fgDisplay.ScreenHeightMM = DisplayHeightMM(
        fgDisplay.pDisplay.Display,
        fgDisplay.pDisplay.Screen
    );

    fgDisplay.pDisplay.Connection = ConnectionNumber( fgDisplay.pDisplay.Display );

    /* Create the window deletion atom */
    fgDisplay.pDisplay.DeleteWindow = fghGetAtom("WM_DELETE_WINDOW");

    /* Create the state and full screen atoms */
    fgDisplay.pDisplay.State           = None;
    fgDisplay.pDisplay.StateFullScreen = None;

    if (fghNetWMSupported())
    {
      const Atom supported = fghGetAtom("_NET_SUPPORTED");
      const Atom state     = fghGetAtom("_NET_WM_STATE");
      
      /* Check if the state hint is supported. */
      if (fgHintPresent(fgDisplay.pDisplay.RootWindow, supported, state))
      {
        const Atom full_screen = fghGetAtom("_NET_WM_STATE_FULLSCREEN");
        
        fgDisplay.pDisplay.State = state;
        
        /* Check if the window manager supports full screen. */
        /**  Check "_NET_WM_ALLOWED_ACTIONS" on our window instead? **/
        if (fgHintPresent(fgDisplay.pDisplay.RootWindow, supported, full_screen))
        {
          fgDisplay.pDisplay.StateFullScreen = full_screen;
        }
      }
    }

    /* Get start time */
    fgState.Time = fgSystemTime();
    

    fgState.Initialised = GL_TRUE;

    atexit(fgDeinitialize);

    /* InputDevice uses GlutTimerFunc(), so fgState.Initialised must be TRUE */
    fgInitialiseInputDevices();
}