X-Git-Url: http://git.mutantstargoat.com/user/nuclear/?a=blobdiff_plain;f=src%2Fmswin%2Ffreeglut_state_mswin.c;h=1f9966b7eed4777c44a850e6c71c1f1b44b4a29e;hb=ef90e5c72102f31823452430eb0b704dd3a44113;hp=d3ba24d86c4f76b8129ed85770142d90b5103638;hpb=e837701fc740ce27feb9342c1bbbf1945ab19331;p=freeglut diff --git a/src/mswin/freeglut_state_mswin.c b/src/mswin/freeglut_state_mswin.c index d3ba24d..1f9966b 100644 --- a/src/mswin/freeglut_state_mswin.c +++ b/src/mswin/freeglut_state_mswin.c @@ -26,9 +26,20 @@ */ #include -#include "freeglut_internal_mswin.h" +#include "../Common/freeglut_internal.h" +extern GLboolean fgSetupPixelFormat( SFG_Window* window, GLboolean checkOnly, + unsigned char layer_type ); + +/* + * Helper functions for getting client area from the window rect + * and the window rect from the client area given the style of the window + * (or a valid window pointer from which the style can be queried). + */ +extern RECT fghGetClientArea( const SFG_Window *window, BOOL wantPosOutside ); +extern void fghGetBorderWidth(const DWORD windowStyle, int* xBorderWidth, int* yBorderWidth); + /* The following include file is available from SGI but is not standard: * #include @@ -218,7 +229,7 @@ int fgPlatformGlutGet ( GLenum eWhat ) case GLUT_WINDOW_FORMAT_ID: #if !defined(_WIN32_WCE) if( fgStructure.CurrentWindow != NULL ) - return GetPixelFormat( fgStructure.CurrentWindow->Window.Device ); + return GetPixelFormat( fgStructure.CurrentWindow->Window.pContext.Device ); #endif /* defined(_WIN32_WCE) */ return 0; @@ -229,3 +240,99 @@ int fgPlatformGlutGet ( GLenum eWhat ) return -1; } + + +int fgPlatformGlutDeviceGet ( GLenum eWhat ) +{ + switch( eWhat ) + { + case GLUT_HAS_KEYBOARD: + /* + * Win32 is assumed a keyboard, and this cannot be queried, + * except for WindowsCE. + * + * X11 has a core keyboard by definition, although it can + * be present as a virtual/dummy keyboard. For now, there + * is no reliable way to tell if a real keyboard is present. + */ +#if defined(_WIN32_CE) + return ( GetKeyboardStatus() & KBDI_KEYBOARD_PRESENT ) ? 1 : 0; +# if FREEGLUT_LIB_PRAGMAS +# pragma comment (lib,"Kbdui.lib") +# endif + +#else + return 1; +#endif + + case GLUT_HAS_MOUSE: + /* + * MS Windows can be booted without a mouse. + */ + return GetSystemMetrics( SM_MOUSEPRESENT ); + + case GLUT_NUM_MOUSE_BUTTONS: +# if defined(_WIN32_WCE) + return 1; +# else + return GetSystemMetrics( SM_CMOUSEBUTTONS ); +# endif + + default: + fgWarning( "glutDeviceGet(): missing enum handle %d", eWhat ); + break; + } + + /* And now -- the failure. */ + return -1; +} + + +int fgPlatformGlutLayerGet( GLenum eWhat ) +{ + /* + * This is easy as layers are not implemented ;-) + * + * XXX Can we merge the UNIX/X11 and WIN32 sections? Or + * XXX is overlay support planned? + */ + switch( eWhat ) + { + + case GLUT_OVERLAY_POSSIBLE: +/* return fgSetupPixelFormat( fgStructure.CurrentWindow, GL_TRUE, + PFD_OVERLAY_PLANE ); */ + return 0 ; + + case GLUT_LAYER_IN_USE: + return GLUT_NORMAL; + + case GLUT_HAS_OVERLAY: + return 0; + + case GLUT_TRANSPARENT_INDEX: + /* + * Return just anything, which is always defined as zero + * + * XXX HUH? + */ + return 0; + + case GLUT_NORMAL_DAMAGED: + /* XXX Actually I do not know. Maybe. */ + return 0; + + case GLUT_OVERLAY_DAMAGED: + return -1; + + default: + fgWarning( "glutLayerGet(): missing enum handle %d", eWhat ); + break; + } + + /* And fail. That's good. Programs do love failing. */ + return -1; +} + + +