int fgPlatformGlutGet ( GLenum eWhat ) { switch (eWhat) { /* One full-screen window only */ case GLUT_WINDOW_X: case GLUT_WINDOW_Y: case GLUT_WINDOW_BORDER_WIDTH: case GLUT_WINDOW_HEADER_HEIGHT: return 0; case GLUT_WINDOW_WIDTH: case GLUT_WINDOW_HEIGHT: { if ( fgStructure.CurrentWindow == NULL || *fgStructure.CurrentWindow->Window.Handle == NULL ) return 0; int32_t width = ANativeWindow_getWidth(*fgStructure.CurrentWindow->Window.Handle); int32_t height = ANativeWindow_getHeight(*fgStructure.CurrentWindow->Window.Handle); switch ( eWhat ) { case GLUT_WINDOW_WIDTH: return width; case GLUT_WINDOW_HEIGHT: return height; } } case GLUT_WINDOW_COLORMAP_SIZE: /* 0 for RGBA/non-indexed mode */ /* Under Android and GLES more generally, no indexed-mode */ return 0; default: return fghPlatformGlutGetEGL(eWhat); } return -1; }
int fgPlatformGlutGet ( GLenum eWhat ) { switch( eWhat ) { /* * Those calls are somewhat similiar, as they use XGetWindowAttributes() * function */ case GLUT_WINDOW_X: case GLUT_WINDOW_Y: case GLUT_WINDOW_BORDER_WIDTH: case GLUT_WINDOW_HEADER_HEIGHT: { int x, y; Window w; if( fgStructure.CurrentWindow == NULL ) return 0; XTranslateCoordinates( fgDisplay.pDisplay.Display, fgStructure.CurrentWindow->Window.Handle, fgDisplay.pDisplay.RootWindow, 0, 0, &x, &y, &w); switch ( eWhat ) { case GLUT_WINDOW_X: return x; case GLUT_WINDOW_Y: return y; } if ( w == 0 ) return 0; XTranslateCoordinates( fgDisplay.pDisplay.Display, fgStructure.CurrentWindow->Window.Handle, w, 0, 0, &x, &y, &w); switch ( eWhat ) { case GLUT_WINDOW_BORDER_WIDTH: return x; case GLUT_WINDOW_HEADER_HEIGHT: return y; } } case GLUT_WINDOW_WIDTH: case GLUT_WINDOW_HEIGHT: { XWindowAttributes winAttributes; if( fgStructure.CurrentWindow == NULL ) return 0; XGetWindowAttributes( fgDisplay.pDisplay.Display, fgStructure.CurrentWindow->Window.Handle, &winAttributes ); switch ( eWhat ) { case GLUT_WINDOW_WIDTH: return winAttributes.width ; case GLUT_WINDOW_HEIGHT: return winAttributes.height ; } } /* Colormap size is handled in a bit different way than all the rest */ case GLUT_WINDOW_COLORMAP_SIZE: if( #ifndef EGL_VERSION_1_0 fgPlatformGetConfig( GLX_RGBA ) || #endif fgStructure.CurrentWindow == NULL) { /* * We've got a RGBA visual, so there is no colormap at all. * The other possibility is that we have no current window set. */ return 0; } else { XVisualInfo * visualInfo; int result; #ifdef EGL_VERSION_1_0 EGLint vid = 0; XVisualInfo visualTemplate; int num_visuals; if (!eglGetConfigAttrib(fgDisplay.pDisplay.egl.Display, fgStructure.CurrentWindow->Window.pContext.egl.Config, EGL_NATIVE_VISUAL_ID, &vid)) fgError("eglGetConfigAttrib(EGL_NATIVE_VISUAL_ID) failed"); visualTemplate.visualid = vid; visualInfo = XGetVisualInfo(fgDisplay.pDisplay.Display, VisualIDMask, &visualTemplate, &num_visuals); #else { const GLXFBConfig fbconfig = fgStructure.CurrentWindow->Window.pContext.FBConfig; visualInfo = glXGetVisualFromFBConfig( fgDisplay.pDisplay.Display, fbconfig ); } #endif result = visualInfo->visual->map_entries; XFree(visualInfo); return result; } default: #ifdef EGL_VERSION_1_0 return fghPlatformGlutGetEGL(eWhat); #else return fghPlatformGlutGetGLX(eWhat); #endif } }
int fgPlatformGlutGet ( GLenum eWhat ) { switch( eWhat ) { /* * Those calls are pointless under Wayland, so inform the user */ case GLUT_WINDOW_X: case GLUT_WINDOW_Y: { if( fgStructure.CurrentWindow == NULL ) { return 0; } else { fgWarning( "glutGet(): GLUT_WINDOW_X/Y properties " "unsupported under Wayland" ); return -1; } } /* * TODO : support this correctly once we will start drawing * client-side decorations */ case GLUT_WINDOW_BORDER_WIDTH: case GLUT_WINDOW_HEADER_HEIGHT: { if( fgStructure.CurrentWindow == NULL || fgStructure.CurrentWindow->Parent ) /* can't get widths/heights if no current window * and child windows don't have borders */ return 0; return 0; } case GLUT_WINDOW_WIDTH: case GLUT_WINDOW_HEIGHT: { if( fgStructure.CurrentWindow == NULL ) return 0; switch ( eWhat ) { case GLUT_WINDOW_WIDTH: return fgStructure.CurrentWindow->State.Width; case GLUT_WINDOW_HEIGHT: return fgStructure.CurrentWindow->State.Height; } } /* Colormap size is handled in a bit different way than all the rest */ case GLUT_WINDOW_COLORMAP_SIZE: { if( fgStructure.CurrentWindow == NULL ) { return 0; } else { int result = 0; if ( ! eglGetConfigAttrib( fgDisplay.pDisplay.egl.Display, fgStructure.CurrentWindow->Window.pContext.egl.Config, EGL_BUFFER_SIZE, &result ) ) fgError( "eglGetConfigAttrib(EGL_BUFFER_SIZE) failed" ); return result; } } default: return fghPlatformGlutGetEGL( eWhat ); } }