1
0
Fork 0
mirror of https://github.com/gwm17/glfw.git synced 2024-11-22 18:28:52 -05:00

Shallow formatting pass (no code changes).

This commit is contained in:
Camilla Berglund 2010-09-08 04:15:49 +02:00
parent c5af4c4324
commit a0351391d1
6 changed files with 22 additions and 128 deletions

View File

@ -53,13 +53,10 @@ static void BPP2RGB( int bpp, int *r, int *g, int *b )
*r = *g = *b = bpp / 3;
delta = bpp - (*r * 3);
if( delta >= 1 )
{
*g = *g + 1;
}
if( delta == 2 )
{
*r = *r + 1;
}
}
@ -123,19 +120,15 @@ int _glfwGetClosestVideoMode( int screen, int *width, int *height, int *rate )
}
if( bestrate != -1 )
{
*rate = bestrate;
}
}
}
// Free modelist
// Free modelist
XRRFreeScreenConfigInfo( sc );
if( bestsize != -1 )
{
return bestsize;
}
}
#elif defined( _GLFW_HAS_XF86VIDMODE )
XF86VidModeModeInfo **modelist;
@ -175,9 +168,7 @@ int _glfwGetClosestVideoMode( int screen, int *width, int *height, int *rate )
XFree( modelist );
if( bestmode != -1 )
{
return bestmode;
}
}
#endif
@ -251,9 +242,7 @@ void _glfwSetVideoModeMODE( int screen, int mode, int rate )
// Unlock mode switch if necessary
if( _glfwWin.FS.modeChanged )
{
XF86VidModeLockModeSwitch( _glfwLibrary.display, screen, 0 );
}
// Change the video mode to the desired mode
XF86VidModeSwitchToMode( _glfwLibrary.display, screen,
@ -285,7 +274,7 @@ void _glfwSetVideoModeMODE( int screen, int mode, int rate )
void _glfwSetVideoMode( int screen, int *width, int *height, int *rate )
{
int bestmode;
int bestmode;
// Find a best match mode
bestmode = _glfwGetClosestVideoMode( screen, width, height, rate );
@ -379,9 +368,7 @@ int _glfwPlatformGetVideoModes( GLFWvidmode *list, int maxcount )
// Get list of visuals
vislist = XGetVisualInfo( dpy, 0, &dummy, &viscount );
if( vislist == NULL )
{
return 0;
}
rgbarray = (int*) malloc( sizeof(int) * viscount );
rgbcount = 0;
@ -405,10 +392,9 @@ int _glfwPlatformGetVideoModes( GLFWvidmode *list, int maxcount )
for( l = 0; l < rgbcount; l++ )
{
if( depth == rgbarray[ l ] )
{
break;
}
}
if( l >= rgbcount )
{
rgbarray[ rgbcount ] = depth;
@ -454,9 +440,7 @@ int _glfwPlatformGetVideoModes( GLFWvidmode *list, int maxcount )
for( l = 0; l < rescount; l++ )
{
if( width == resarray[ l ].width && height == resarray[ l ].height )
{
break;
}
}
if( l >= rescount )

View File

@ -70,9 +70,7 @@ int _glfwPlatformExtensionSupported( const char *extension )
if( extensions != NULL )
{
if( _glfwStringInExtensionString( extension, extensions ) )
{
return GL_TRUE;
}
}
return GL_FALSE;

View File

@ -31,7 +31,6 @@
#include "internal.h"
//************************************************************************
//**** GLFW internal functions ****
//************************************************************************
@ -155,11 +154,8 @@ static void terminateDisplay( void )
int _glfwPlatformInit( void )
{
// Initialize display
if( !initDisplay() )
{
return GL_FALSE;
}
// Try to load libGL.so if necessary
initLibraries();

View File

@ -74,7 +74,7 @@ struct js_event {
//========================================================================
// _glfwInitJoysticks() - Initialize joystick interface
// Initialize joystick interface
//========================================================================
void _glfwInitJoysticks( void )
@ -89,9 +89,7 @@ void _glfwInitJoysticks( void )
// Start by saying that there are no sticks
for( i = 0; i <= GLFW_JOYSTICK_LAST; ++ i )
{
_glfwJoy[ i ].Present = GL_FALSE;
}
#ifdef _GLFW_USE_LINUX_JOYSTICKS
@ -160,13 +158,10 @@ void _glfwInitJoysticks( void )
// Clear joystick state
for( n = 0; n < _glfwJoy[ joy_count ].NumAxes; ++ n )
{
_glfwJoy[ joy_count ].Axis[ n ] = 0.0f;
}
for( n = 0; n < _glfwJoy[ joy_count ].NumButtons; ++ n )
{
_glfwJoy[ joy_count ].Button[ n ] = GLFW_RELEASE;
}
// The joystick is supported and connected
_glfwJoy[ joy_count ].Present = GL_TRUE;
@ -181,7 +176,7 @@ void _glfwInitJoysticks( void )
//========================================================================
// _glfwTerminateJoysticks() - Close all opened joystick handles
// Close all opened joystick handles
//========================================================================
void _glfwTerminateJoysticks( void )
@ -269,16 +264,13 @@ static void pollJoystickEvents( void )
//************************************************************************
//========================================================================
// _glfwPlatformGetJoystickParam() - Determine joystick capabilities
// Determine joystick capabilities
//========================================================================
int _glfwPlatformGetJoystickParam( int joy, int param )
{
// Is joystick present?
if( !_glfwJoy[ joy ].Present )
{
return 0;
}
switch( param )
{
@ -300,67 +292,53 @@ int _glfwPlatformGetJoystickParam( int joy, int param )
//========================================================================
// _glfwPlatformGetJoystickPos() - Get joystick axis positions
// Get joystick axis positions
//========================================================================
int _glfwPlatformGetJoystickPos( int joy, float *pos, int numaxes )
{
int i;
// Is joystick present?
if( !_glfwJoy[ joy ].Present )
{
return 0;
}
// Update joystick state
pollJoystickEvents();
// Does the joystick support less axes than requested?
if( _glfwJoy[ joy ].NumAxes < numaxes )
{
numaxes = _glfwJoy[ joy ].NumAxes;
}
// Copy axis positions from internal state
for( i = 0; i < numaxes; ++ i )
{
pos[ i ] = _glfwJoy[ joy ].Axis[ i ];
}
return numaxes;
}
//========================================================================
// _glfwPlatformGetJoystickButtons() - Get joystick button states
// Get joystick button states
//========================================================================
int _glfwPlatformGetJoystickButtons( int joy, unsigned char *buttons,
int numbuttons )
int numbuttons )
{
int i;
// Is joystick present?
if( !_glfwJoy[ joy ].Present )
{
return 0;
}
// Update joystick state
pollJoystickEvents();
// Does the joystick support less buttons than requested?
if( _glfwJoy[ joy ].NumButtons < numbuttons )
{
numbuttons = _glfwJoy[ joy ].NumButtons;
}
// Copy button states from internal state
for( i = 0; i < numbuttons; ++ i )
{
buttons[ i ] = _glfwJoy[ joy ].Button[ i ];
}
return numbuttons;
}

View File

@ -873,22 +873,16 @@ long _glfwKeySym2Unicode( KeySym keysym )
/* Also check for directly encoded 24-bit UCS characters */
if( (keysym & 0xff000000) == 0x01000000 )
{
return keysym & 0x00ffffff;
}
/* Binary search in table */
while( max >= min )
{
mid = (min + max) / 2;
if( keysymtab[mid].keysym < keysym )
{
min = mid + 1;
}
else if( keysymtab[mid].keysym > keysym )
{
max = mid - 1;
}
else
{
/* Found it! */

View File

@ -89,9 +89,7 @@ static unsigned long getWindowProperty( Window window,
value );
if( actualType != type )
{
return 0;
}
return itemCount;
}
@ -113,9 +111,7 @@ static Atom getSupportedAtom( Atom* supportedAtoms,
for( i = 0; i < atomCount; i++ )
{
if( supportedAtoms[i] == atom )
{
return atom;
}
}
}
@ -142,9 +138,7 @@ static GLboolean checkForEWMH( void )
"_NET_SUPPORTED",
True );
if( supportingWmCheck == None || wmSupported == None )
{
return GL_FALSE;
}
// Then we look for the _NET_SUPPORTING_WM_CHECK property of the root window
if( getWindowProperty( _glfwWin.root,
@ -332,11 +326,9 @@ static int translateKey( int keycode )
key = key_uc;
// Valid ISO 8859-1 character?
if( (key >= 32 && key <= 126) ||
(key >= 160 && key <= 255) )
{
if( (key >= 32 && key <= 126) || (key >= 160 && key <= 255) )
return (int) key;
}
return GLFW_KEY_UNKNOWN;
}
}
@ -397,12 +389,11 @@ static int getFBConfigAttrib( GLXFBConfig fbconfig, int attrib )
if( _glfwWin.has_GLX_SGIX_fbconfig )
{
_glfwWin.GetFBConfigAttribSGIX( _glfwLibrary.display, fbconfig, attrib, &value );
_glfwWin.GetFBConfigAttribSGIX( _glfwLibrary.display,
fbconfig, attrib, &value );
}
else
{
glXGetFBConfigAttrib( _glfwLibrary.display, fbconfig, attrib, &value );
}
return value;
}
@ -496,13 +487,9 @@ static _GLFWfbconfig *getFBConfigs( unsigned int *found )
result[*found].stereo = getFBConfigAttrib( fbconfigs[i], GLX_STEREO );
if( _glfwWin.has_GLX_ARB_multisample )
{
result[*found].samples = getFBConfigAttrib( fbconfigs[i], GLX_SAMPLES );
}
else
{
result[*found].samples = 0;
}
result[*found].platformID = (GLFWintptr) getFBConfigAttrib( fbconfigs[i], GLX_FBCONFIG_ID );
@ -566,7 +553,8 @@ static int createContext( const _GLFWwndconfig *wndconfig, GLXFBConfigID fbconfi
}
else
{
_glfwWin.visual = glXGetVisualFromFBConfig( _glfwLibrary.display, *fbconfig );
_glfwWin.visual = glXGetVisualFromFBConfig( _glfwLibrary.display,
*fbconfig );
}
if( _glfwWin.visual == NULL )
@ -594,14 +582,10 @@ static int createContext( const _GLFWwndconfig *wndconfig, GLXFBConfigID fbconfi
flags = 0;
if( wndconfig->glForward )
{
flags |= GLX_CONTEXT_FORWARD_COMPATIBLE_BIT_ARB;
}
if( wndconfig->glDebug )
{
flags |= GLX_CONTEXT_DEBUG_BIT_ARB;
}
setGLXattrib( attribs, index, GLX_CONTEXT_FLAGS_ARB, flags );
}
@ -616,13 +600,9 @@ static int createContext( const _GLFWwndconfig *wndconfig, GLXFBConfigID fbconfi
}
if( wndconfig->glProfile == GLFW_OPENGL_CORE_PROFILE )
{
flags = GLX_CONTEXT_CORE_PROFILE_BIT_ARB;
}
else
{
flags = GLX_CONTEXT_COMPATIBILITY_PROFILE_BIT_ARB;
}
setGLXattrib( attribs, index, GLX_CONTEXT_PROFILE_MASK_ARB, flags );
}
@ -796,6 +776,7 @@ static GLboolean createWindow( int width, int height,
wamask,
&wa
);
if( !_glfwWin.window )
{
_glfwPlatformCloseWindow();
@ -847,9 +828,7 @@ static GLboolean createWindow( int width, int height,
// Tells the WM to ping our window and flag us as unresponsive if we
// don't reply within a few seconds
if( _glfwWin.wmPing != None )
{
protocols[count++] = _glfwWin.wmPing;
}
if( count > 0 )
{
@ -994,9 +973,7 @@ static void enterFullscreenMode( void )
}
if( _glfwWin.mouseLock )
{
_glfwPlatformHideMouseCursor();
}
// HACK: Try to get window inside viewport (for virtual displays) by moving
// the mouse cursor to the upper left corner (and then to the center)
@ -1054,9 +1031,7 @@ static void leaveFullscreenMode( void )
}
if( _glfwWin.mouseLock )
{
_glfwPlatformShowMouseCursor();
}
}
//========================================================================
@ -1121,9 +1096,8 @@ static GLboolean processSingleEvent( void )
// Translate and report character input
if( _glfwWin.charCallback )
{
_glfwInputChar( translateChar( &event.xkey ), GLFW_RELEASE );
}
break;
}
@ -1132,17 +1106,11 @@ static GLboolean processSingleEvent( void )
// A mouse button was pressed or a scrolling event occurred
if( event.xbutton.button == Button1 )
{
_glfwInputMouseClick( GLFW_MOUSE_BUTTON_LEFT, GLFW_PRESS );
}
else if( event.xbutton.button == Button2 )
{
_glfwInputMouseClick( GLFW_MOUSE_BUTTON_MIDDLE, GLFW_PRESS );
}
else if( event.xbutton.button == Button3 )
{
_glfwInputMouseClick( GLFW_MOUSE_BUTTON_RIGHT, GLFW_PRESS );
}
// XFree86 3.3.2 and later translates mouse wheel up/down into
// mouse button 4 & 5 presses
@ -1150,17 +1118,13 @@ static GLboolean processSingleEvent( void )
{
_glfwInput.WheelPos++; // To verify: is this up or down?
if( _glfwWin.mouseWheelCallback )
{
_glfwWin.mouseWheelCallback( _glfwInput.WheelPos );
}
}
else if( event.xbutton.button == Button5 )
{
_glfwInput.WheelPos--;
if( _glfwWin.mouseWheelCallback )
{
_glfwWin.mouseWheelCallback( _glfwInput.WheelPos );
}
}
break;
}
@ -1292,9 +1256,7 @@ static GLboolean processSingleEvent( void )
_glfwWin.active = GL_TRUE;
if( _glfwWin.mouseLock )
{
_glfwPlatformHideMouseCursor();
}
break;
}
@ -1307,9 +1269,7 @@ static GLboolean processSingleEvent( void )
_glfwInputDeactivation();
if( _glfwWin.mouseLock )
{
_glfwPlatformShowMouseCursor();
}
break;
}
@ -1319,9 +1279,8 @@ static GLboolean processSingleEvent( void )
// The window's contents was damaged
if( _glfwWin.windowRefreshCallback )
{
_glfwWin.windowRefreshCallback();
}
break;
}
@ -1485,9 +1444,7 @@ int _glfwPlatformOpenWindow( int width, int height,
void _glfwPlatformCloseWindow( void )
{
if( _glfwWin.fullscreen )
{
leaveFullscreenMode();
}
if( _glfwWin.context )
{
@ -1542,7 +1499,7 @@ void _glfwPlatformSetWindowTitle( const char *title )
void _glfwPlatformSetWindowSize( int width, int height )
{
int mode = 0, rate, sizeChanged = GL_FALSE;
int mode = 0, rate, sizeChanged = GL_FALSE;
XSizeHints *sizehints;
rate = _glfwWin.refreshRate;
@ -1582,9 +1539,7 @@ void _glfwPlatformSetWindowSize( int width, int height )
// Set window size (if not already changed)
if( !sizeChanged )
{
XResizeWindow( _glfwLibrary.display, _glfwWin.window, width, height );
}
}
@ -1650,9 +1605,7 @@ void _glfwPlatformSwapBuffers( void )
void _glfwPlatformSwapInterval( int interval )
{
if( _glfwWin.has_GLX_SGI_swap_control )
{
_glfwWin.SwapIntervalSGI( interval );
}
}
@ -1719,13 +1672,9 @@ void _glfwPlatformRefreshWindowParams( void )
// Get FSAA buffer sample count
if( _glfwWin.has_GLX_ARB_multisample )
{
_glfwWin.samples = getFBConfigAttrib( *fbconfig, GLX_SAMPLES );
}
else
{
_glfwWin.samples = 0;
}
// Default to refresh rate unknown (=0 according to GLFW spec)
_glfwWin.refreshRate = 0;
@ -1769,9 +1718,7 @@ void _glfwPlatformPollEvents( void )
while( XPending( _glfwLibrary.display ) )
{
if( processSingleEvent() )
{
closeRequested = GL_TRUE;
}
}
// Did we get mouse movement in fully enabled hidden cursor mode?
@ -1782,13 +1729,10 @@ void _glfwPlatformPollEvents( void )
}
if( closeRequested && _glfwWin.windowCloseCallback )
{
closeRequested = _glfwWin.windowCloseCallback();
}
if( closeRequested )
{
glfwCloseWindow();
}
}