FGAPI void FGAPIENTRY glutInitContextFuncUcall( void (* callback)( void* ), void* user_data );
FGAPI void FGAPIENTRY glutAppStatusFuncUcall( void (* callback)( int, void* ), void* user_data );
-/*
+/*
* Continued "hack" from GLUT applied to Ucall functions.
* For more info, see bottom of freeglut_std.h
*/
in OpenGLUT. It may also be useful to see which
parameters control what behavior in the OpenGLUT
objects.
-
+
Spinning wireframe and solid-shaded shapes are
displayed. Some parameters can be adjusted.
-
+
Keys:
- <tt>Esc </tt> Quit
- <tt>q Q </tt> Quit
\author Portions Copyright (C) 2004, the OpenGLUT project contributors. <br>
OpenGLUT branched from freeglut in February, 2004.
-
+
\image html openglut_shapes.png OpenGLUT Geometric Shapes Demonstration
\include demos/shapes/shapes.c
*/
}
/*
- * OpenGL 2+ shader mode needs some function and macro definitions,
+ * OpenGL 2+ shader mode needs some function and macro definitions,
* avoiding a dependency on additional libraries like GLEW or the
* GL/glext.h header
*/
GLint attrib = gl_GetAttribLocation(program, name);
if (attrib == -1)
{
- fprintf(stderr, "Warning: Could not bind attrib %s\n", name);
+ fprintf(stderr, "Warning: Could not bind attrib %s\n", name);
}
- checkError ("getAttribOrUniformLocation");
+ checkError ("getAttribOrUniformLocation");
return attrib;
}
else
GLint uniform = gl_GetUniformLocation(program, name);
if (uniform == -1)
{
- fprintf(stderr, "Warning: Could not bind uniform %s\n", name);
+ fprintf(stderr, "Warning: Could not bind uniform %s\n", name);
}
- checkError ("getAttribOrUniformLocation");
+ checkError ("getAttribOrUniformLocation");
return uniform;
}
}
GLuint program;
-GLint attribute_fg_coord = -1, attribute_fg_normal = -1;
+GLint attribute_fg_coord = -1, attribute_fg_normal = -1;
GLint uniform_m = -1, uniform_p = -1, uniform_m_3x3_inv_transp = -1;
GLint shaderReady = 0; /* Set to 1 when all initialization went well, to -1 when shader somehow unusable. */
case '.':
case '>': stacks++; break;
- case '9':
+ case '9':
case '(': if( depth > -1 ) depth--; break;
- case '0':
+ case '0':
case ')': ++depth; break;
case 'P':
/* What supports variadic macros based off Wikipedia article on it (GCC-like must support C99 or higher to use variadic macros) */
#if (((defined(__GNUC__) && (__GNUC__ >= 3)) || \
- (defined(__clang__))) && \
- (defined(__STDC_VERSION__) && (__STDC_VERSION__ >= 199901L))) || \
- (defined(_MSC_VER) && (_MSC_VER >= 1400)) || \
- (defined(__BORLANDC__) && (__BORLANDC__ >= 0x570)) || \
- (defined(__SUNPRO_C) && (__SUNPRO_C >= 0x530))
+ (defined(__clang__))) && \
+ (defined(__STDC_VERSION__) && (__STDC_VERSION__ >= 199901L))) || \
+ (defined(_MSC_VER) && (_MSC_VER >= 1400)) || \
+ (defined(__BORLANDC__) && (__BORLANDC__ >= 0x570)) || \
+ (defined(__SUNPRO_C) && (__SUNPRO_C >= 0x530))
#define FG_COMPILER_SUPPORTS_VA_ARGS 1
#else
#define FG_COMPILER_SUPPORTS_VA_ARGS 0
*
* This took a while to figure out, so be sure try to understand what is happening so that you can ensure that whatever you
* change won't break other areas.
- *
+ *
* If you are just adding a new callback/changing it's argument count, just go to the bottom of the file.
*
* This whole file exists purely for the sake of preventing the need to implement additional parsing logic for each callback
* then the GCC macro, so maybe it's good to stay as is.
*
* Onto the different "versions" of macros:
- *
- * The first is for any compiler that supports C99 by default. It requires each callback to have a specific argument count
- * passthrough macro. The only reason there are specific count macros is so that (see paraghraph below) don't need have their own
- * set of callback macros. Ideally, there would only be ZERO and ONE_OR_MORE. This works by having callback-specific macros call a
- * specific handler macro to return user data (ZERO) or return one or more arguments along with userData (ONE_OR_MORE) where, with
+ *
+ * The first is for any compiler that supports C99 by default. It requires each callback to have a specific argument count
+ * passthrough macro. The only reason there are specific count macros is so that (see paraghraph below) don't need have their own
+ * set of callback macros. Ideally, there would only be ZERO and ONE_OR_MORE. This works by having callback-specific macros call a
+ * specific handler macro to return user data (ZERO) or return one or more arguments along with userData (ONE_OR_MORE) where, with
* variadic macros, it just reuses the arguments.
*
- * The last macro set is for the poor individual who has to use a compiler that doesn't support C99 by default, or may not support
- * it at all. Stuff like MSVC6... It works by having a specific-count macro that "extracts" each argument to have them reused without
+ * The last macro set is for the poor individual who has to use a compiler that doesn't support C99 by default, or may not support
+ * it at all. Stuff like MSVC6... It works by having a specific-count macro that "extracts" each argument to have them reused without
* the parathesis.
*
- * There is a 3rd macro set that only worked on GCC/Clang, and thus was removed (last seen in revision e9676fc of the GIT mirror.
+ * There is a 3rd macro set that only worked on GCC/Clang, and thus was removed (last seen in revision e9676fc of the GIT mirror.
* Not sure at this time what the SVN number is.) as it's a non-standard functionality.
*/
/*
* EXPAND_WCB() is used as:
- *
+ *
* EXPAND_WCB( cbname )(( arg_list, userData ))
- *
+ *
* ... where {(arg_list)} is the parameter list and userData is user
* provided data.
*
#define EXPAND_WCB(cbname) EXPAND_WCB_SUB_ ## cbname
-/*
+/*
* Freeglut callbacks type definitions macros
*
* Every time a callback is updated in fg_internal.h is updated, this needs updated
}
#define IMPLEMENT_CURRENT_WINDOW_CALLBACK_FUNC_2NAME_GLUT(a,b) \
- IMPLEMENT_CURRENT_WINDOW_CALLBACK_FUNC_2NAME_GLUT_UCALL(a,b) \
- IMPLEMENT_CALLBACK_FUNC_2NAME_GLUT_BASE(a,b)
+ IMPLEMENT_CURRENT_WINDOW_CALLBACK_FUNC_2NAME_GLUT_UCALL(a,b) \
+ IMPLEMENT_CALLBACK_FUNC_2NAME_GLUT_BASE(a,b)
/*
* Combine _glut and _cb macros:
IMPLEMENT_CURRENT_WINDOW_CALLBACK_FUNC_2NAME_GLUT(a,b)
#define IMPLEMENT_GLUT_CALLBACK_FUNC_ARG0(a) \
- IMPLEMENT_CALLBACK_FUNC_CB_ARG0(a,a) \
- IMPLEMENT_CALLBACK_FUNC_2NAME_GLUT_BASE(a,a)
+ IMPLEMENT_CALLBACK_FUNC_CB_ARG0(a,a) \
+ IMPLEMENT_CALLBACK_FUNC_2NAME_GLUT_BASE(a,a)
#define IMPLEMENT_GLUT_CALLBACK_FUNC_ARG0_2NAME(a,b) \
- IMPLEMENT_CALLBACK_FUNC_CB_ARG0(a,b) \
- IMPLEMENT_CALLBACK_FUNC_2NAME_GLUT_BASE(a,b)
+ IMPLEMENT_CALLBACK_FUNC_CB_ARG0(a,b) \
+ IMPLEMENT_CALLBACK_FUNC_2NAME_GLUT_BASE(a,b)
#define IMPLEMENT_CURRENT_WINDOW_CALLBACK_FUNC_ARG1(a) \
IMPLEMENT_CALLBACK_FUNC_CB_ARG1(a,a) \
IMPLEMENT_CURRENT_WINDOW_CALLBACK_FUNC_2NAME_GLUT(a,a)
#define IMPLEMENT_GLUT_CALLBACK_FUNC_ARG1(a) \
- IMPLEMENT_CALLBACK_FUNC_CB_ARG1(a,a) \
- IMPLEMENT_CALLBACK_FUNC_2NAME_GLUT_BASE(a,a)
+ IMPLEMENT_CALLBACK_FUNC_CB_ARG1(a,a) \
+ IMPLEMENT_CALLBACK_FUNC_2NAME_GLUT_BASE(a,a)
#define IMPLEMENT_CURRENT_WINDOW_CALLBACK_FUNC_ARG2(a) \
IMPLEMENT_CALLBACK_FUNC_CB_ARG2(a,a) \
IMPLEMENT_CURRENT_WINDOW_CALLBACK_FUNC_2NAME_GLUT(a,b)
#define IMPLEMENT_GLUT_CALLBACK_FUNC_ARG2(a) \
- IMPLEMENT_CALLBACK_FUNC_CB_ARG2(a,a) \
- IMPLEMENT_CALLBACK_FUNC_2NAME_GLUT_BASE(a,a)
+ IMPLEMENT_CALLBACK_FUNC_CB_ARG2(a,a) \
+ IMPLEMENT_CALLBACK_FUNC_2NAME_GLUT_BASE(a,a)
#define IMPLEMENT_GLUT_CALLBACK_FUNC_ARG2_2NAME(a,b) \
- IMPLEMENT_CALLBACK_FUNC_CB_ARG2(a,b) \
- IMPLEMENT_CALLBACK_FUNC_2NAME_GLUT_BASE(a,b)
+ IMPLEMENT_CALLBACK_FUNC_CB_ARG2(a,b) \
+ IMPLEMENT_CALLBACK_FUNC_2NAME_GLUT_BASE(a,b)
#define IMPLEMENT_CURRENT_WINDOW_CALLBACK_FUNC_ARG3(a) \
IMPLEMENT_CALLBACK_FUNC_CB_ARG3(a,a) \
IMPLEMENT_CURRENT_WINDOW_CALLBACK_FUNC_2NAME_GLUT(a,a)
#define IMPLEMENT_GLUT_CALLBACK_FUNC_ARG3(a) \
- IMPLEMENT_CALLBACK_FUNC_CB_ARG3(a,a) \
- IMPLEMENT_CALLBACK_FUNC_2NAME_GLUT_BASE(a,a)
+ IMPLEMENT_CALLBACK_FUNC_CB_ARG3(a,a) \
+ IMPLEMENT_CALLBACK_FUNC_2NAME_GLUT_BASE(a,a)
#define IMPLEMENT_GLUT_CALLBACK_FUNC_ARG3_2NAME(a,b) \
- IMPLEMENT_CALLBACK_FUNC_CB_ARG3(a,b) \
- IMPLEMENT_CALLBACK_FUNC_2NAME_GLUT_BASE(a,b)
+ IMPLEMENT_CALLBACK_FUNC_CB_ARG3(a,b) \
+ IMPLEMENT_CALLBACK_FUNC_2NAME_GLUT_BASE(a,b)
#define IMPLEMENT_CURRENT_WINDOW_CALLBACK_FUNC_ARG4(a) \
IMPLEMENT_CALLBACK_FUNC_CB_ARG4(a,a) \
{
FREEGLUT_EXIT_IF_NOT_INITIALISED ( "glutPostRedisplay" );
if ( ! fgStructure.CurrentWindow )
- {
+ {
fgError ( " ERROR: Function <%s> called"
" with no current window defined.", "glutPostRedisplay" ) ;
- }
+ }
fgStructure.CurrentWindow->State.WorkMask |= GLUT_DISPLAY_WORK;
}
*/
/*
- * This file has been automatically generated by the
+ * This file has been automatically generated by the
* genfonts utility.
*
* The legal status of this file is a bit vague. The font glyphs
*
* Copyright (c) 1999-2000 by Pawel W. Olszta
* Written by Pawel W. Olszta, <olszta@sourceforge.net>
- *
+ *
* Permission is hereby granted, free of charge, to any person obtaining a
* copy of this software and associated documentation files (the "Software"),
* to deal in the Software without restriction, including without limitation
/*
* The following bitmapped fonts are defined in this file:
- *
+ *
* 1. fgFontFixed8x13
* -misc-fixed-medium-r-normal--13-120-75-75-C-80-iso8859-1
* 2. fgFontFixed9x15
{
const char *dial_device=NULL;
dial_device = getenv ( "GLUT_DIALS_SERIAL" );
- fgPlatformRegisterDialDevice ( dial_device );
+ fgPlatformRegisterDialDevice ( dial_device );
if ( !dial_device ) return;
if ( !( dialbox_port = serial_open ( dial_device ) ) ) return;
/* -- GLOBAL TYPE DEFINITIONS ---------------------------------------------- */
-/*
+/*
* Freeglut callbacks type definitions
*
* If anything here is modified or added, update fg_callback_macros.h functions.
int NumActiveJoysticks; /* Number of active joysticks (callback defined and positive pollrate) -- if zero, don't poll joysticks */
GLboolean InputDevsInitialised; /* Only initialize if application calls for them */
- int MouseWheelTicks; /* Number of ticks the mouse wheel has turned */
+ int MouseWheelTicks; /* Number of ticks the mouse wheel has turned */
int AuxiliaryBufferNumber;/* Number of auxiliary buffers */
int SampleNumber; /* Number of samples per pixel */
typedef struct tagSFG_Display SFG_Display;
struct tagSFG_Display
{
- SFG_PlatformDisplay pDisplay;
+ SFG_PlatformDisplay pDisplay;
int ScreenWidth; /* The screen's width in pixels */
int ScreenHeight; /* The screen's height in pixels */
SFG_WindowHandleType Handle; /* The window's handle */
SFG_WindowContextType Context; /* The window's OpenGL/WGL context */
- SFG_PlatformContext pContext; /* The window's FBConfig (X11) or device context (Windows) */
+ SFG_PlatformContext pContext; /* The window's FBConfig (X11) or device context (Windows) */
int DoubleBuffered; /* Treat the window as double-buffered */
int DesiredZOrder; /* desired window Z Order position */
fgDesiredVisibility DesiredVisibility;/* desired visibility (hidden, iconic, shown/normal) */
- SFG_PlatformWindowState pWState; /* Window width/height (X11) or rectangle/style (Windows) from before a resize, and other stuff only needed on specific platforms */
+ SFG_PlatformWindowState pWState; /* Window width/height (X11) or rectangle/style (Windows) from before a resize, and other stuff only needed on specific platforms */
long JoystickPollRate; /* The joystick polling rate */
fg_time_t JoystickLastPoll; /* When the last poll happened */
(((window).CallBacks[WCB_ ## cbname]) = (SFG_Proc)(func)); \
(((window).CallbackDatas[WCB_ ## cbname]) = (udata)); \
} \
- else if( FETCH_USER_DATA_WCB( window, cbname ) != udata ) \
- { \
- (((window).CallbackDatas[WCB_ ## cbname]) = (udata)); \
- } \
+ else if( FETCH_USER_DATA_WCB( window, cbname ) != udata ) \
+ { \
+ (((window).CallbackDatas[WCB_ ## cbname]) = (udata)); \
+ } \
} while( 0 )
/*
/*
* FETCH_USER_DATA_WCB() is used as:
- *
+ *
* FETCH_USER_DATA_WCB( window, cbname );
*
* ...where {window} is the freeglut window,
/*
* EXPAND_WCB() is used as:
- *
+ *
* EXPAND_WCB( cbname )(( arg_list, userData ))
- *
+ *
* ... where {(arg_list)} is the parameter list and userData is user
* provided data.
*
*
* callback( arg_list, userData );
*
- * ...where userData is added to the arg_list, but the parentheses
+ * ...where userData is added to the arg_list, but the parentheses
* are REQUIRED in the {arg_list}.
*
* NOTE that it does a sanity-check and also sets the
FGCB ## cbname ## UC func = (FGCB ## cbname ## UC)(FETCH_WCB( window, cbname )); \
FGCBUserData userData = FETCH_USER_DATA_WCB( window, cbname ); \
fgSetWindow( &window ); \
- func EXPAND_WCB( cbname )(( arg_list, userData )); \
+ func EXPAND_WCB( cbname )(( arg_list, userData )); \
} \
} while( 0 )
typedef struct tagSFG_Joystick SFG_Joystick;
struct tagSFG_Joystick
{
- SFG_PlatformJoystick pJoystick;
+ SFG_PlatformJoystick pJoystick;
int id;
GLboolean error;
static GLvoid fghGetVMaxExtent( SFG_Window* window, int* x, int* y )
{
if( fgStructure.GameModeWindow )
- fgPlatformGetGameModeVMaxExtent ( window, x, y );
+ fgPlatformGetGameModeVMaxExtent ( window, x, y );
else
{
*x = fgDisplay.ScreenWidth;
{
/* The menu object creation code resides in fg_structure.c */
FREEGLUT_EXIT_IF_NOT_INITIALISED ( "glutCreateMenuUcall" );
- if (fgState.ActiveMenus)
- {
- fgError( "Menu manipulation not allowed while menus in use." );
- }
+ if (fgState.ActiveMenus)
+ {
+ fgError( "Menu manipulation not allowed while menus in use." );
+ }
return fgCreateMenu( callback, userData )->ID;
}
void fgSpaceballClose(void)
{
- fgPlatformSpaceballClose();
+ fgPlatformSpaceballClose();
}
int fgHasSpaceball(void)
int fgHasSpaceball(void)
{
- return 0;
+ return 0;
}
int fgSpaceballNumButtons(void)
{
- return 0;
+ return 0;
}
void fgSpaceballSetWindow(SFG_Window *window)
case GLUT_NUM_DIALS:
if ( fgState.InputDevsInitialised ) return 8;
return 0;
-
+
case GLUT_NUM_BUTTON_BOX_BUTTONS:
return 0;
return fgState.KeyRepeat;
default:
- return fgPlatformGlutDeviceGet ( eWhat );
+ return fgPlatformGlutDeviceGet ( eWhat );
}
}
fgError( "Out of memory. Could not create window." );
}
- fgPlatformCreateWindow ( window );
+ fgPlatformCreateWindow ( window );
fghClearCallBacks( window );
SET_WCB( *window, Reshape, fghDefaultReshape, NULL);
SET_WCB( *window, Destroy, destroy, destroyData );
}
- /*
- * Similarly, clear all work set for the window, none of this has to be executed anymore
- */
- window->State.WorkMask = 0;
+ /*
+ * Similarly, clear all work set for the window, none of this has to be executed anymore
+ */
+ window->State.WorkMask = 0;
}
/*
HDC context = CreateDC(fgDisplay.pDisplay.DisplayName,0,0,0);
if( context )
{
- fgDisplay.ScreenWidth = GetDeviceCaps( context, HORZRES );
- fgDisplay.ScreenHeight = GetDeviceCaps( context, VERTRES );
- fgDisplay.ScreenWidthMM = GetDeviceCaps( context, HORZSIZE );
- fgDisplay.ScreenHeightMM = GetDeviceCaps( context, VERTSIZE );
- DeleteDC(context);
+ fgDisplay.ScreenWidth = GetDeviceCaps( context, HORZRES );
+ fgDisplay.ScreenHeight = GetDeviceCaps( context, VERTRES );
+ fgDisplay.ScreenWidthMM = GetDeviceCaps( context, HORZSIZE );
+ fgDisplay.ScreenHeightMM = GetDeviceCaps( context, VERTSIZE );
+ DeleteDC(context);
}
else
- fgWarning("fgPlatformInitialize: "
- "CreateDC failed, Screen size info may be incorrect\n"
+ fgWarning("fgPlatformInitialize: "
+ "CreateDC failed, Screen size info may be incorrect\n"
"This is quite likely caused by a bad '-display' parameter");
-
+
}
/* Set the timer granularity to 1 ms */
timeBeginPeriod ( 1 );
void fgPlatformDeinitialiseInputDevices ( void )
{
#if !defined(_WIN32_WCE)
- fghCloseInputDevices ();
+ fghCloseInputDevices ();
#endif /* !defined(_WIN32_WCE) */
fgState.JoysticksInitialised = GL_FALSE;
fgState.InputDevsInitialised = GL_FALSE;
void fgPlatformDestroyContext ( SFG_PlatformDisplay pDisplay, SFG_WindowContextType MContext )
{
- /* Do nothing -- this is required for X11 */
+ /* Do nothing -- this is required for X11 */
}
/* -- PLATFORM-SPECIFIC INTERFACE FUNCTION -------------------------------------------------- */
/* window that got focus was not one of the active menus. That means we'll
* close the active menu's unless the window that got focus was their parent */
menu = fgGetActiveMenu();
-
+
if (newFocusWnd != menu->ParentWindow->Window.Handle)
{
/* focus shifted to another window than the menu's parent, close menus */
int FGAPIENTRY __glutCreateMenuUcallWithExit(void(*callback)(int, void*), void(__cdecl *exit_function)(int), void* user_data)
{
- __glutExitFunc = exit_function;
- return glutCreateMenuUcall(callback, user_data);
+ __glutExitFunc = exit_function;
+ return glutCreateMenuUcall(callback, user_data);
}
* fg_spaceball_mswin.c
*
* Spaceball support for Windows
- *
+ *
* Copyright (c) 2012 Stephen J. Baker. All Rights Reserved.
* Written by Evan Felix <karcaw at gmail.com>
* Creation date: Sat Feb 4, 2012
/*
* Modified by Jinrong Xie <stonexjr at gmail.com> 12/24/2014
* for Space Navigator support on Windows.
- * This code is enhanced by at least supporting 3Dconnexion's
+ * This code is enhanced by at least supporting 3Dconnexion's
* six degree of freedom navigator.
*/
#include "../fg_internal.h"
enum {
- SPNAV_EVENT_ANY,
+ SPNAV_EVENT_ANY,
SPNAV_EVENT_MOTION_TRANSLATION,
SPNAV_EVENT_MOTION_ROTATION,
SPNAV_EVENT_BUTTON /* includes both press and release */
void fgPlatformInitializeSpaceball(void)
{
- HWND hwnd;
- sball_initialized = 1;
- if (!fgStructure.CurrentWindow)
- {
- sball_initialized = 0;
- return;
- }
- hwnd = fgStructure.CurrentWindow->Window.Handle;
-
- {
- BOOL ok;
- UINT cbSize = sizeof(__fgSpaceball);
- __fgSpaceball.hwndTarget = hwnd;
- ok = RegisterRawInputDevices(&__fgSpaceball, 1, cbSize);
-
- if (!ok){
- __fgSpaceball.hwndTarget = NULL;
- sball_initialized = 0;
- }
- }
+ HWND hwnd;
+ sball_initialized = 1;
+ if (!fgStructure.CurrentWindow)
+ {
+ sball_initialized = 0;
+ return;
+ }
+ hwnd = fgStructure.CurrentWindow->Window.Handle;
+
+ {
+ BOOL ok;
+ UINT cbSize = sizeof(__fgSpaceball);
+ __fgSpaceball.hwndTarget = hwnd;
+ ok = RegisterRawInputDevices(&__fgSpaceball, 1, cbSize);
+
+ if (!ok){
+ __fgSpaceball.hwndTarget = NULL;
+ sball_initialized = 0;
+ }
+ }
}
void fgPlatformSpaceballClose(void)
{
- return;
+ return;
}
int fgPlatformHasSpaceball(void)
{
- return __fgSpaceball.hwndTarget ? 1 : 0;
+ return __fgSpaceball.hwndTarget ? 1 : 0;
}
int fgPlatformSpaceballNumButtons(void)
{
- return 0;
+ return 0;
}
void fgPlatformSpaceballSetWindow(SFG_Window *window)
{
- return;
+ return;
}
int fgIsSpaceballWinEvent(HWND hwnd, WPARAM wParam, LPARAM lParam)
{
- return 0;
+ return 0;
}
void fgSpaceballHandleWinEvent(HWND hwnd, WPARAM wParam, LPARAM lParam)
{
- #define LOGITECH_VENDOR_ID 0x46d
- HRAWINPUT hRawInput = (HRAWINPUT)lParam;
- UINT inputCode = (UINT)wParam;
- UINT size;
- BYTE *rawInputBuffer;
- PRAWINPUT pRawInput;
- UINT res;
- RID_DEVICE_INFO sRidDeviceInfo;
-
- if (!sball_initialized)
- {
- fgPlatformInitializeSpaceball();
- if (!sball_initialized)
- {
- return;
- }
- }
-
- res = GetRawInputData(hRawInput, RID_INPUT, NULL, &size, sizeof(RAWINPUTHEADER));
- if (res == -1)
- return;
-
- rawInputBuffer = malloc(size * sizeof *rawInputBuffer);
- pRawInput = (PRAWINPUT)rawInputBuffer;
-
- res = GetRawInputData(hRawInput, RID_INPUT, pRawInput, &size, sizeof(RAWINPUTHEADER));
- if (res == -1)
- return;
- if (pRawInput->header.dwType != RIM_TYPEHID)
- return;
-
- sRidDeviceInfo.cbSize = sizeof(RID_DEVICE_INFO);
- size = sizeof(RID_DEVICE_INFO);
- res = GetRawInputDeviceInfo(pRawInput->header.hDevice, RIDI_DEVICEINFO, &sRidDeviceInfo, &size);
- if (res == -1)
- return;
- {
- SFG_Window* window = fgWindowByHandle(hwnd);
- if ((window == NULL))
- return;
-
- if (sRidDeviceInfo.hid.dwVendorId == LOGITECH_VENDOR_ID)
- {
- // Motion data comes in two parts: motion type and
- // displacement/rotation along three axis.
- // Orientation is a right handed coordinate system with
- // X goes right, Y goes up and Z goes towards viewer, e.g.
- // the one used in OpenGL
- if (pRawInput->data.hid.bRawData[0] ==
- SPNAV_EVENT_MOTION_TRANSLATION)
- { // Translation vector
- short* pnData = (short*)(&pRawInput->data.hid.bRawData[1]);
- short X = pnData[0];
- short Y = -pnData[2];
- short Z = pnData[1];
- INVOKE_WCB(*window, SpaceMotion, (X, Y, Z));
- }
- else if (pRawInput->data.hid.bRawData[0] ==
- SPNAV_EVENT_MOTION_ROTATION)
- { // Axis aligned rotation vector
- short* pnData = (short*)(&pRawInput->data.hid.bRawData[1]);
- short rX = pnData[0];
- short rY = -pnData[2];
- short rZ = pnData[1];
- INVOKE_WCB(*window, SpaceRotation, (rX, rY, rZ));
- }
- else if (pRawInput->data.hid.bRawData[0] ==
- SPNAV_EVENT_BUTTON)
- { // State of the keys
- unsigned long dwKeystate = *(unsigned long*)(&pRawInput->data.hid.bRawData[1]);
- unsigned int state = GLUT_UP;
- if (FETCH_WCB(*window, SpaceButton))
- {
- int i;
- for (i = 0; i < 32; i++)
- {
- unsigned long stateBefore = __fgSpaceKeystate&(1 << i);
- unsigned long stateNow = dwKeystate&(1 << i);
-
- if (stateBefore && !stateNow)
- INVOKE_WCB(*window, SpaceButton, (stateBefore, GLUT_UP));
- if (!stateBefore && stateNow)
- INVOKE_WCB(*window, SpaceButton, (stateNow, GLUT_DOWN));
-
- }
- }
- __fgSpaceKeystate = dwKeystate;
- }
- }
- }
+ #define LOGITECH_VENDOR_ID 0x46d
+ HRAWINPUT hRawInput = (HRAWINPUT)lParam;
+ UINT inputCode = (UINT)wParam;
+ UINT size;
+ BYTE *rawInputBuffer;
+ PRAWINPUT pRawInput;
+ UINT res;
+ RID_DEVICE_INFO sRidDeviceInfo;
+
+ if (!sball_initialized)
+ {
+ fgPlatformInitializeSpaceball();
+ if (!sball_initialized)
+ {
+ return;
+ }
+ }
+
+ res = GetRawInputData(hRawInput, RID_INPUT, NULL, &size, sizeof(RAWINPUTHEADER));
+ if (res == -1)
+ return;
+
+ rawInputBuffer = malloc(size * sizeof *rawInputBuffer);
+ pRawInput = (PRAWINPUT)rawInputBuffer;
+
+ res = GetRawInputData(hRawInput, RID_INPUT, pRawInput, &size, sizeof(RAWINPUTHEADER));
+ if (res == -1)
+ return;
+ if (pRawInput->header.dwType != RIM_TYPEHID)
+ return;
+
+ sRidDeviceInfo.cbSize = sizeof(RID_DEVICE_INFO);
+ size = sizeof(RID_DEVICE_INFO);
+ res = GetRawInputDeviceInfo(pRawInput->header.hDevice, RIDI_DEVICEINFO, &sRidDeviceInfo, &size);
+ if (res == -1)
+ return;
+ {
+ SFG_Window* window = fgWindowByHandle(hwnd);
+ if ((window == NULL))
+ return;
+
+ if (sRidDeviceInfo.hid.dwVendorId == LOGITECH_VENDOR_ID)
+ {
+ // Motion data comes in two parts: motion type and
+ // displacement/rotation along three axis.
+ // Orientation is a right handed coordinate system with
+ // X goes right, Y goes up and Z goes towards viewer, e.g.
+ // the one used in OpenGL
+ if (pRawInput->data.hid.bRawData[0] ==
+ SPNAV_EVENT_MOTION_TRANSLATION)
+ { // Translation vector
+ short* pnData = (short*)(&pRawInput->data.hid.bRawData[1]);
+ short X = pnData[0];
+ short Y = -pnData[2];
+ short Z = pnData[1];
+ INVOKE_WCB(*window, SpaceMotion, (X, Y, Z));
+ }
+ else if (pRawInput->data.hid.bRawData[0] ==
+ SPNAV_EVENT_MOTION_ROTATION)
+ { // Axis aligned rotation vector
+ short* pnData = (short*)(&pRawInput->data.hid.bRawData[1]);
+ short rX = pnData[0];
+ short rY = -pnData[2];
+ short rZ = pnData[1];
+ INVOKE_WCB(*window, SpaceRotation, (rX, rY, rZ));
+ }
+ else if (pRawInput->data.hid.bRawData[0] ==
+ SPNAV_EVENT_BUTTON)
+ { // State of the keys
+ unsigned long dwKeystate = *(unsigned long*)(&pRawInput->data.hid.bRawData[1]);
+ unsigned int state = GLUT_UP;
+ if (FETCH_WCB(*window, SpaceButton))
+ {
+ int i;
+ for (i = 0; i < 32; i++)
+ {
+ unsigned long stateBefore = __fgSpaceKeystate&(1 << i);
+ unsigned long stateNow = dwKeystate&(1 << i);
+
+ if (stateBefore && !stateNow)
+ INVOKE_WCB(*window, SpaceButton, (stateBefore, GLUT_UP));
+ if (!stateBefore && stateNow)
+ INVOKE_WCB(*window, SpaceButton, (stateNow, GLUT_DOWN));
+
+ }
+ }
+ __fgSpaceKeystate = dwKeystate;
+ }
+ }
+ }
}
#endif
\ No newline at end of file
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).
HDC hdc = fgStructure.CurrentWindow->Window.pContext.Device;
int iPixelFormat = GetPixelFormat( hdc );
DescribePixelFormat(hdc, iPixelFormat, sizeof(PIXELFORMATDESCRIPTOR), &pfd);
-
+
returnValue = pfd.cColorBits;
if (pfd.iPixelType==PFD_TYPE_RGBA)
returnValue += pfd.cAlphaBits;
GetWindowRect( fgStructure.CurrentWindow->Window.Handle, &winRect);
#else
ClientToScreen(fgStructure.CurrentWindow->Window.Handle, &topLeft);
-
+
if (fgStructure.CurrentWindow->Parent)
/* For child window, we should return relative to upper-left
* of parent's client area.
*/
borderWidth = ((winRect.right-winRect.left)-(clientRect.right-clientRect.left))/2;
captionHeight = (winRect.bottom-winRect.top)-(clientRect.bottom-clientRect.top)-borderWidth; /* include top border in caption height */
-
+
switch( eWhat )
{
case GLUT_WINDOW_BORDER_WIDTH:
break;
}
- return -1;
+ return -1;
}
ppfd->dwLayerMask = 0;
ppfd->dwVisibleMask = 0;
ppfd->dwDamageMask = 0;
-
+
ppfd->cColorBits = (BYTE) GetDeviceCaps( hdc, BITSPIXEL );
}
/* windows hack for multismapling/sRGB */
if ( ( fgState.DisplayMode & GLUT_MULTISAMPLE ) ||
( fgState.DisplayMode & GLUT_SRGB ) )
- {
+ {
HGLRC rc, rc_before=wglGetCurrentContext();
HWND hWnd;
HDC hDC, hDC_before=wglGetCurrentDC();
windowRect.left = clientRect->left;
windowRect.top = clientRect->top;
}
-
+
/* done, copy windowRect to output */
CopyRect(clientRect,&windowRect);
}
POINT topLeftClient = {0,0};
freeglut_return_if_fail((window && window->Window.Handle));
-
+
/* Get size of client rect */
GetClientRect(window->Window.Handle, clientRect);
if (posIsOutside)
} m_proc_t;
static BOOL CALLBACK m_proc(HMONITOR mon,
- HDC hdc,
- LPRECT rect,
- LPARAM data)
+ HDC hdc,
+ LPRECT rect,
+ LPARAM data)
{
m_proc_t *dp=(m_proc_t *)data;
MONITORINFOEX info;
return TRUE;
}
-/*
+/*
* this function returns the origin of the screen identified by
* fgDisplay.pDisplay.DisplayName, and 0 otherwise.
* This is used in fgOpenWindow to open the gamemode window on the screen
/* Enable multitouch: additional flag TWF_FINETOUCH, TWF_WANTPALM */
#ifdef WM_TOUCH
- if (fghRegisterTouchWindow == (pRegisterTouchWindow)0xDEADBEEF)
- fghRegisterTouchWindow = (pRegisterTouchWindow)GetProcAddress(GetModuleHandle("user32"),"RegisterTouchWindow");
- if (fghRegisterTouchWindow)
+ if (fghRegisterTouchWindow == (pRegisterTouchWindow)0xDEADBEEF)
+ fghRegisterTouchWindow = (pRegisterTouchWindow)GetProcAddress(GetModuleHandle("user32"),"RegisterTouchWindow");
+ if (fghRegisterTouchWindow)
fghRegisterTouchWindow( window->Window.Handle, TWF_FINETOUCH | TWF_WANTPALM );
#endif