static void fghVisibility( int status )
{
int glut_status = GLUT_VISIBLE;
-
+
freeglut_assert_ready;
freeglut_return_if_fail( fgStructure.Window );
{
int ret = 0;
char buf[ 256 ];
-
+
switch( cursor )
{
case BadAlloc:
if( GLUT_CURSOR_FULL_CROSSHAIR == cursorID )
cursorID = GLUT_CURSOR_CROSSHAIR;
-
+
switch( cursorID )
{
MAP_CURSOR( GLUT_CURSOR_RIGHT_ARROW, XC_right_ptr);
0, 0 );
break;
}
-
+
case GLUT_CURSOR_INHERIT:
break;
MAP_CURSOR( GLUT_CURSOR_CROSSHAIR, IDC_CROSS );
/* MAP_CURSOR( GLUT_CURSOR_NONE, IDC_NO ); */
ZAP_CURSOR( GLUT_CURSOR_NONE, NULL );
-
+
default:
MAP_CURSOR( GLUT_CURSOR_UP_DOWN, IDC_ARROW );
}
{ "glutGetProcAddress", (void *) glutGetProcAddress },
{ "glutMouseWheelFunc", (void *) glutMouseWheelFunc },
{ NULL, NULL }
-};
+};
void *FGAPIENTRY glutGetProcAddress( const char *procName )
glEnd( );
}
-
+
length += schar->Right;
glTranslatef( schar->Right, 0.0, 0.0 );
}
);
schar = font->Characters[ character ];
freeglut_return_val_if_fail( schar, 0 );
-
+
return ( int )( schar->Right + 0.5 );
}
/*
* Following fonts are defined in this file:
- *
+ *
* 1. fgFontFixed8x13 <-misc-fixed-medium-r-normal--13-120-75-75-C-80-iso8859-1>
* 2. fgFontFixed9x15 <-misc-fixed-medium-r-normal--15-140-75-75-C-90-iso8859-1>
* 3. fgFontHelvetica10 <-adobe-helvetica-medium-r-normal--10-100-75-75-p-56-iso8859-1>
/*
* Query the current display settings:
*/
- fgDisplay.DisplayModeValid =
+ fgDisplay.DisplayModeValid =
XF86VidModeGetModeLine(
fgDisplay.Display,
fgDisplay.Screen,
#elif TARGET_HOST_WIN32
/* DEVMODE devMode; */
-
+
/*
* Grab the current desktop settings...
*/
return FALSE;
}
- fgStructure.GameMode = fgCreateWindow(
+ fgStructure.GameMode = fgCreateWindow(
NULL, "FREEGLUT", 0, 0,
fgState.GameModeSize.X, fgState.GameModeSize.Y, GL_TRUE, GL_FALSE
);
/* Move the Pointer to the middle of the fullscreen window */
XWarpPointer(
fgDisplay.Display,
- None,
+ None,
fgDisplay.RootWindow,
0, 0, 0, 0,
fgState.GameModeSize.X/2, fgState.GameModeSize.Y/2
GrabModeAsync, GrabModeAsync,
fgStructure.GameMode->Window.Handle, None, CurrentTime) )
usleep( 100 );
-
+
/*
* Change input focus to the new window. This will exit the application
* if the new window is not viewable yet, see the XGrabPointer loop above.
glVertex3d(0,0,radius);
for (j=slices; j>=0; j--)
- {
+ {
glNormal3d(cost1[j]*r1, sint1[j]*r1, z1 );
glVertex3d(cost1[j]*r1*radius, sint1[j]*r1*radius, z1*radius);
}
double x,y,z;
/* Pre-computed circle */
-
+
double *sint1,*cost1;
double *sint2,*cost2;
circleTable(&sint1,&cost1,-slices );
struct freeglutStrokeFont
{
- const char *name ;
- int num_chars ;
- void *ch ;
- float top ;
- float bottom ;
-};
+ const char *name ;
+ int num_chars ;
+ void *ch ;
+ float top ;
+ float bottom ;
+};
struct freeglutBitmapFont
-{
- const char *name ;
- const int num_chars ;
- const int first ;
- const void *ch ;
-};
+{
+ const char *name ;
+ const int num_chars ;
+ const int first ;
+ const void *ch ;
+};
struct freeglutStrokeFont glutStrokeRoman ;
free( fgState.ProgramName );
fgState.ProgramName = NULL;
}
-
+
#if TARGET_HOST_UNIX_X11
* It returns a bitmask that indicates which of the four values
* were actually found in the string. For each value found,
* the corresponding argument is updated; for each value
- * not found, the corresponding argument is left unchanged.
+ * not found, the corresponding argument is left unchanged.
*/
static int
{
register int Result = 0;
int Sign = 1;
-
+
if (*string == '+')
string++;
else if (*string == '-')
strind = (char *)string;
if (*strind != '+' && *strind != '-' && *strind != 'x') {
tempWidth = ReadInteger(strind, &nextCharacter);
- if (strind == nextCharacter)
+ if (strind == nextCharacter)
return 0;
strind = nextCharacter;
mask |= WidthValue;
{
int interval;
sscanf( fps, "%d", &interval );
-
+
if( interval <= 0 )
fgState.FPSInterval = 5000; /* 5000 millisecond default */
else
/* XXX Update these for each release! */
#define VERSION_MAJOR 2
#define VERSION_MINOR 2
-#define VERSION_PATCH 0
+#define VERSION_PATCH 0
/*
* Freeglut is meant to be available under all Unix/X11 and Win32 platforms.
CB_ButtonBox,
CB_TabletMotion,
CB_TabletButton,
-
+
/* Always make this the LAST one */
TOTAL_CALLBACKS
};
IOHIDEventStruct hidEvent;
(*(joy->hidDev))->getElementValue ( joy->hidDev, buttonCookies[i], &hidEvent );
if ( hidEvent.value )
- *buttons |= 1 << i;
+ *buttons |= 1 << i;
}
}
IOReturn rv;
CFMutableDictionaryRef cfProperties;
-#if 0
+#if 0
/* comment copied from darwin/SDL_sysjoystick.c */
/* Mac OS X currently is not mirroring all USB properties to HID page so need to look at USB device page also
* get dictionary for usb properties: step up two levels and get CF dictionary for USB properties
}
#endif
- rv = IORegistryEntryCreateCFProperties( ioDev /*parent2*/,
+ rv = IORegistryEntryCreateCFProperties( ioDev /*parent2*/,
&cfProperties, kCFAllocatorDefault, kNilOptions);
if (rv != kIOReturnSuccess || !cfProperties) {
fgWarning ( "%s", "error getting device properties");
return;
}
- static_cast<jsJoystick*>(vjs)->parseElement ( (CFDictionaryRef) element );
+ static_cast<jsJoystick*>(vjs)->parseElement ( (CFDictionaryRef) element );
}
/** element enumerator function : pass NULL for top-level*/
assert(CFGetTypeID(element) == CFArrayGetTypeID());
CFRange range = {0, CFArrayGetCount ((CFArrayRef)element)};
- CFArrayApplyFunction((CFArrayRef) element, range,
+ CFArrayApplyFunction((CFArrayRef) element, range,
&fghJoystickElementEnumerator, joy );
}
long type, page, usage;
CFNumberGetValue((CFNumberRef)
- CFDictionaryGetValue ((CFDictionaryRef) element, CFSTR(kIOHIDElementTypeKey)),
+ CFDictionaryGetValue ((CFDictionaryRef) element, CFSTR(kIOHIDElementTypeKey)),
kCFNumberLongType, &type);
switch ( typ e) {
CFNumberGetValue( (CFNumberRef) refUsage, kCFNumberLongType, &usage );
CFNumberGetValue( (CFNumberRef) refPage, kCFNumberLongType, &page );
- if (page == kHIDPage_GenericDesktop) {
+ if (page == kHIDPage_GenericDesktop) {
switch ( usage ) /* look at usage to determine function */
{
case kHIDUsage_GD_X:
default:
break;
- }
+ }
}
static void fghJoystickAddAxisElement ( SFG_Joystick *joy, CFDictionaryRef axis )
int index = joy->num_axes++;
CFNumberGetValue ((CFNumberRef)
- CFDictionaryGetValue ( axis, CFSTR(kIOHIDElementCookieKey) ),
+ CFDictionaryGetValue ( axis, CFSTR(kIOHIDElementCookieKey) ),
kCFNumberLongType, &cookie);
axisCookies[index] = (IOHIDElementCookie) cookie;
CFNumberGetValue ((CFNumberRef)
- CFDictionaryGetValue ( axis, CFSTR(kIOHIDElementMinKey) ),
+ CFDictionaryGetValue ( axis, CFSTR(kIOHIDElementMinKey) ),
kCFNumberLongType, &lmin);
CFNumberGetValue ((CFNumberRef)
- CFDictionaryGetValue ( axis, CFSTR(kIOHIDElementMaxKey) ),
+ CFDictionaryGetValue ( axis, CFSTR(kIOHIDElementMaxKey) ),
kCFNumberLongType, &lmax);
joy->min[index] = lmin;
{
long cookie;
CFNumberGetValue ((CFNumberRef)
- CFDictionaryGetValue ( button, CFSTR(kIOHIDElementCookieKey) ),
+ CFDictionaryGetValue ( button, CFSTR(kIOHIDElementCookieKey) ),
kCFNumberLongType, &cookie);
joy->buttonCookies[num_buttons++] = (IOHIDElementCookie) cookie;
}
/* create device interface */
- rv = IOCreatePlugInInterfaceForService( ioDevices[ joy->id ],
+ rv = IOCreatePlugInInterfaceForService( ioDevices[ joy->id ],
kIOHIDDeviceUserClientTypeID,
kIOCFPlugInInterfaceID,
&plugin, &score );
}
pluginResult = ( *plugin )->QueryInterface(
- plugin,
+ plugin,
CFUUIDGetUUIDBytes(kIOHIDDeviceInterfaceID),
&( LPVOID )joy->hidDev
);
props = getCFProperties( ioDevices[ joy->id ] );
/* recursively enumerate all the bits */
- CFTypeRef topLevelElement =
+ CFTypeRef topLevelElement =
CFDictionaryGetValue( props, CFSTR( kIOHIDElementKey ) );
enumerateElements( topLevelElement );
* Set the correct number of axes for the linux driver
*/
# ifdef JS_NEW
- /* Melchior Franz's fixes for big-endian Linuxes since writing
- * to the upper byte of an uninitialized word doesn't work.
- * 9 April 2003
+ /* Melchior Franz's fixes for big-endian Linuxes since writing
+ * to the upper byte of an uninitialized word doesn't work.
+ * 9 April 2003
*/
- ioctl( joy->fd, JSIOCGAXES, &u );
+ ioctl( joy->fd, JSIOCGAXES, &u );
joy->num_axes = u;
ioctl( joy->fd, JSIOCGBUTTONS, &u );
joy->num_buttons = u;
counter = 0;
do
- {
+ {
fghJoystickRawRead( joy, NULL, joy->center );
counter++;
} while( !joy->error &&
fgSetWindow( window );
- fghReshapeWindowByHandle(
+ fghReshapeWindowByHandle(
window->Window.Handle,
window->State.Width,
window->State.Height
fgSetWindow( window );
- fghReshapeWindowByHandle(
+ fghReshapeWindowByHandle(
window->Window.Handle,
window->State.Width,
window->State.Height
}
#elif TARGET_HOST_WIN32
RedrawWindow(
- window->Window.Handle, NULL, NULL,
+ window->Window.Handle, NULL, NULL,
RDW_NOERASE | RDW_INTERNALPAINT | RDW_INVALIDATE | RDW_UPDATENOW
);
#endif
e->data = w;
}
fgEnumSubWindows( w, fgHavePendingRedisplaysCallback, e );
-}
+}
static int fgHavePendingRedisplays (void)
{
SFG_Enumerator enumerator;
ret |= GLUT_ACTIVE_CTRL;
if( event->xkey.state & Mod1Mask )
ret |= GLUT_ACTIVE_ALT;
-
+
return ret;
}
#endif
*/
if( (Atom) event.xclient.data.l[ 0 ] == fgDisplay.DeleteWindow )
{
- GETWINDOW( xclient );
+ GETWINDOW( xclient );
fgDestroyWindow ( window );
case VisibilityNotify:
{
- GETWINDOW( xvisibility );
+ GETWINDOW( xvisibility );
/*
* XXX INVOKE_WCB() does this check for us.
*/
INVOKE_WCB( *window, WindowStatus, ( GLUT_FULLY_RETAINED ) );
window->State.Visible = GL_TRUE;
break;
-
+
case VisibilityPartiallyObscured:
INVOKE_WCB( *window, WindowStatus,
( GLUT_PARTIALLY_RETAINED ) );
window->State.Visible = GL_TRUE;
break;
-
+
case VisibilityFullyObscured:
INVOKE_WCB( *window, WindowStatus, ( GLUT_FULLY_COVERED ) );
window->State.Visible = GL_FALSE;
*/
GETWINDOW( xbutton );
GETMOUSE( xbutton );
-
+
/*
* An X button (at least in XFree86) is numbered from 1.
* A GLUT button is numbered from 0.
window->ActiveMenu->Window->State.MouseY =
event.xbutton.y_root - window->ActiveMenu->Y;
}
-
+
/* In the menu, invoke the callback and deactivate the menu*/
if( fgCheckActiveMenu( window->ActiveMenu->Window,
window->ActiveMenu ) )
int direction = -1;
if( button % 2 )
direction = 1;
-
+
if( pressed )
INVOKE_WCB( *window, MouseWheel, ( wheel_number,
direction,
INVOKE_WCB( *window, Visibility, ( window->State.Visible ) );
fgSetWindow( current_window );
}
-
+
window = (SFG_Window *)window->Node.Next ;
}
#endif
/*
* Step through the list of windows, seeing if there are any
* that are not menus
- */
+ */
for( window = ( SFG_Window * )fgStructure.Windows.First;
window;
window = ( SFG_Window * )window->Node.Next )
if ( ! ( window->IsMenu ) )
break;
-
+
if( ! window )
fgState.ExecState = GLUT_EXEC_STATE_STOP;
else
break;
#if 0
- case WM_SETFOCUS:
+ case WM_SETFOCUS:
printf("WM_SETFOCUS: %p\n", window );
lRet = DefWindowProc( hWnd, uMsg, wParam, lParam );
break;
- case WM_ACTIVATE:
+ case WM_ACTIVATE:
if (LOWORD(wParam) != WA_INACTIVE)
{
/* glutSetCursor( fgStructure.Window->State.Cursor ); */
* XXX call glutSetCurdsor() instead of defining two macros
* XXX and implementing a nested case in-line.
*/
- case WM_SETCURSOR:
+ case WM_SETCURSOR:
/* Set the cursor AND change it for this window class. */
#define MAP_CURSOR(a,b) \
case a: \
{
window->State.MouseX = LOWORD( lParam );
window->State.MouseY = HIWORD( lParam );
-
+
if ( window->ActiveMenu )
{
window->State.Redisplay = GL_TRUE;
break;
/*
- * Remember the current modifiers state. This is done here in order
+ * Remember the current modifiers state. This is done here in order
* to make sure the VK_DELETE keyboard callback is executed properly.
*/
fgState.Modifiers = fgGetWin32Modifiers( );
POINT mouse_pos;
/*
- * Remember the current modifiers state. This is done here in order
+ * Remember the current modifiers state. This is done here in order
* to make sure the VK_DELETE keyboard callback is executed properly.
*/
fgState.Modifiers = fgGetWin32Modifiers( );
{
BYTE state[ 256 ];
WORD code[ 2 ];
-
+
GetKeyboardState( state );
-
+
if( ToAscii( wParam, 0, state, code, 0 ) == 1 )
wParam=code[ 0 ];
case GLUT_HAS_MOUSE:
/*
- * The Windows can be booted without a mouse.
+ * The Windows can be booted without a mouse.
* It would be nice to have this reported.
*/
return GetSystemMetrics( SM_MOUSEPRESENT );
*/
while( fgStructure.Menus.First )
fgDestroyMenu( ( SFG_Menu * )fgStructure.Menus.First );
-
+
while( fgStructure.Windows.First )
fgDestroyWindow( ( SFG_Window * )fgStructure.Windows.First );
}
pfd.cColorBits = (BYTE) GetDeviceCaps( window->Window.Device, BITSPIXEL );
ppfd = &pfd;
-
+
pixelformat = ChoosePixelFormat( window->Window.Device, ppfd );
if( pixelformat == 0 )
return GL_FALSE;
if ( window )
{
window->Window.Device = GetDC( window->Window.Handle );
- wglMakeCurrent(
- window->Window.Device,
+ wglMakeCurrent(
+ window->Window.Device,
window->Window.Context
);
}
window->Window.VisualInfo = fgChooseVisual( );
fgState.DisplayMode &= ~GLUT_DOUBLE;
}
-
+
/*
* GLUT also checks for multi-sampling, but I don't see that
* anywhere else in FREEGLUT so I won't bother with it for the moment.
&wmHints,
NULL
);
-
+
XSetWMProtocols( fgDisplay.Display, window->Window.Handle,
&fgDisplay.DeleteWindow, 1 );
-
+
XMapWindow( fgDisplay.Display, window->Window.Handle );
}
-
+
#elif TARGET_HOST_WIN32
WNDCLASS wc;
ATOM atom;
freeglut_assert_ready;
-
+
/*
* Grab the window class we have registered on glutInit():
*/
atom = GetClassInfo( fgDisplay.Instance, "FREEGLUT", &wc );
assert( atom != 0 );
-
+
if( gameMode )
{
assert( window->Parent == NULL );
int FGAPIENTRY glutCreateSubWindow( int parentID, int x, int y, int w, int h )
{
int ret = 0;
-
+
if( GL_FALSE == fgStructure.Window->State.IsOffscreen )
{
SFG_Window* window = NULL;
#if TARGET_HOST_UNIX_X11
XTextProperty text;
-
+
text.value = (unsigned char *) title;
text.encoding = XA_STRING;
text.format = 8;
text.nitems = strlen( title );
-
+
XSetWMName(
fgDisplay.Display,
fgStructure.Window->Window.Handle,
&text
);
-
+
XFlush( fgDisplay.Display ); /* XXX Shouldn't need this */
#elif TARGET_HOST_WIN32
#if TARGET_HOST_UNIX_X11
XTextProperty text;
-
+
text.value = (unsigned char *) title;
text.encoding = XA_STRING;
text.format = 8;
#elif TARGET_HOST_WIN32
RECT winRect;
-
+
GetWindowRect( fgStructure.Window->Window.Handle, &winRect );
MoveWindow(
fgStructure.Window->Window.Handle,