mirror of
https://github.com/glfw/glfw.git
synced 2024-11-10 00:51:47 +00:00
Formatting pass (no code changes).
This commit is contained in:
parent
a0351391d1
commit
9e4137c0a9
70
lib/enable.c
70
lib/enable.c
@ -39,11 +39,11 @@
|
|||||||
// Enable (show) mouse cursor
|
// Enable (show) mouse cursor
|
||||||
//========================================================================
|
//========================================================================
|
||||||
|
|
||||||
static void enableMouseCursor( void )
|
static void enableMouseCursor(void)
|
||||||
{
|
{
|
||||||
int centerPosX, centerPosY;
|
int centerPosX, centerPosY;
|
||||||
|
|
||||||
if( !_glfwWin.opened || !_glfwWin.mouseLock )
|
if (!_glfwWin.opened || !_glfwWin.mouseLock)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
// Show mouse cursor
|
// Show mouse cursor
|
||||||
@ -52,17 +52,17 @@ static void enableMouseCursor( void )
|
|||||||
centerPosX = _glfwWin.width / 2;
|
centerPosX = _glfwWin.width / 2;
|
||||||
centerPosY = _glfwWin.height / 2;
|
centerPosY = _glfwWin.height / 2;
|
||||||
|
|
||||||
if( centerPosX != _glfwInput.MousePosX || centerPosY != _glfwInput.MousePosY )
|
if (centerPosX != _glfwInput.MousePosX || centerPosY != _glfwInput.MousePosY)
|
||||||
{
|
{
|
||||||
_glfwPlatformSetMouseCursorPos( centerPosX, centerPosY );
|
_glfwPlatformSetMouseCursorPos(centerPosX, centerPosY);
|
||||||
|
|
||||||
_glfwInput.MousePosX = centerPosX;
|
_glfwInput.MousePosX = centerPosX;
|
||||||
_glfwInput.MousePosY = centerPosY;
|
_glfwInput.MousePosY = centerPosY;
|
||||||
|
|
||||||
if( _glfwWin.mousePosCallback )
|
if (_glfwWin.mousePosCallback)
|
||||||
{
|
{
|
||||||
_glfwWin.mousePosCallback( _glfwInput.MousePosX,
|
_glfwWin.mousePosCallback(_glfwInput.MousePosX,
|
||||||
_glfwInput.MousePosY );
|
_glfwInput.MousePosY);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -74,17 +74,17 @@ static void enableMouseCursor( void )
|
|||||||
// Disable (hide) mouse cursor
|
// Disable (hide) mouse cursor
|
||||||
//========================================================================
|
//========================================================================
|
||||||
|
|
||||||
static void disableMouseCursor( void )
|
static void disableMouseCursor(void)
|
||||||
{
|
{
|
||||||
if( !_glfwWin.opened || _glfwWin.mouseLock )
|
if (!_glfwWin.opened || _glfwWin.mouseLock)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
// Hide mouse cursor
|
// Hide mouse cursor
|
||||||
_glfwPlatformHideMouseCursor();
|
_glfwPlatformHideMouseCursor();
|
||||||
|
|
||||||
// Move cursor to the middle of the window
|
// Move cursor to the middle of the window
|
||||||
_glfwPlatformSetMouseCursorPos( _glfwWin.width >> 1,
|
_glfwPlatformSetMouseCursorPos(_glfwWin.width >> 1,
|
||||||
_glfwWin.height >> 1 );
|
_glfwWin.height >> 1);
|
||||||
|
|
||||||
// From now on the mouse is locked
|
// From now on the mouse is locked
|
||||||
_glfwWin.mouseLock = GL_TRUE;
|
_glfwWin.mouseLock = GL_TRUE;
|
||||||
@ -95,7 +95,7 @@ static void disableMouseCursor( void )
|
|||||||
// Enable sticky keys
|
// Enable sticky keys
|
||||||
//========================================================================
|
//========================================================================
|
||||||
|
|
||||||
static void enableStickyKeys( void )
|
static void enableStickyKeys(void)
|
||||||
{
|
{
|
||||||
_glfwInput.StickyKeys = 1;
|
_glfwInput.StickyKeys = 1;
|
||||||
}
|
}
|
||||||
@ -104,17 +104,17 @@ static void enableStickyKeys( void )
|
|||||||
// Disable sticky keys
|
// Disable sticky keys
|
||||||
//========================================================================
|
//========================================================================
|
||||||
|
|
||||||
static void disableStickyKeys( void )
|
static void disableStickyKeys(void)
|
||||||
{
|
{
|
||||||
int i;
|
int i;
|
||||||
|
|
||||||
_glfwInput.StickyKeys = 0;
|
_glfwInput.StickyKeys = 0;
|
||||||
|
|
||||||
// Release all sticky keys
|
// Release all sticky keys
|
||||||
for( i = 0; i <= GLFW_KEY_LAST; i++ )
|
for (i = 0; i <= GLFW_KEY_LAST; i++)
|
||||||
{
|
{
|
||||||
if( _glfwInput.Key[ i ] == 2 )
|
if (_glfwInput.Key[i] == 2)
|
||||||
_glfwInput.Key[ i ] = 0;
|
_glfwInput.Key[i] = 0;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -123,7 +123,7 @@ static void disableStickyKeys( void )
|
|||||||
// Enable sticky mouse buttons
|
// Enable sticky mouse buttons
|
||||||
//========================================================================
|
//========================================================================
|
||||||
|
|
||||||
static void enableStickyMouseButtons( void )
|
static void enableStickyMouseButtons(void)
|
||||||
{
|
{
|
||||||
_glfwInput.StickyMouseButtons = 1;
|
_glfwInput.StickyMouseButtons = 1;
|
||||||
}
|
}
|
||||||
@ -132,17 +132,17 @@ static void enableStickyMouseButtons( void )
|
|||||||
// Disable sticky mouse buttons
|
// Disable sticky mouse buttons
|
||||||
//========================================================================
|
//========================================================================
|
||||||
|
|
||||||
static void disableStickyMouseButtons( void )
|
static void disableStickyMouseButtons(void)
|
||||||
{
|
{
|
||||||
int i;
|
int i;
|
||||||
|
|
||||||
_glfwInput.StickyMouseButtons = 0;
|
_glfwInput.StickyMouseButtons = 0;
|
||||||
|
|
||||||
// Release all sticky mouse buttons
|
// Release all sticky mouse buttons
|
||||||
for( i = 0; i <= GLFW_MOUSE_BUTTON_LAST; i++ )
|
for (i = 0; i <= GLFW_MOUSE_BUTTON_LAST; i++)
|
||||||
{
|
{
|
||||||
if( _glfwInput.MouseButton[ i ] == 2 )
|
if (_glfwInput.MouseButton[i] == 2)
|
||||||
_glfwInput.MouseButton[ i ] = 0;
|
_glfwInput.MouseButton[i] = 0;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -151,9 +151,9 @@ static void disableStickyMouseButtons( void )
|
|||||||
// Enable system keys
|
// Enable system keys
|
||||||
//========================================================================
|
//========================================================================
|
||||||
|
|
||||||
static void enableSystemKeys( void )
|
static void enableSystemKeys(void)
|
||||||
{
|
{
|
||||||
if( !_glfwWin.sysKeysDisabled )
|
if (!_glfwWin.sysKeysDisabled)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
_glfwPlatformEnableSystemKeys();
|
_glfwPlatformEnableSystemKeys();
|
||||||
@ -166,9 +166,9 @@ static void enableSystemKeys( void )
|
|||||||
// Disable system keys
|
// Disable system keys
|
||||||
//========================================================================
|
//========================================================================
|
||||||
|
|
||||||
static void disableSystemKeys( void )
|
static void disableSystemKeys(void)
|
||||||
{
|
{
|
||||||
if( _glfwWin.sysKeysDisabled )
|
if (_glfwWin.sysKeysDisabled)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
_glfwPlatformDisableSystemKeys();
|
_glfwPlatformDisableSystemKeys();
|
||||||
@ -182,7 +182,7 @@ static void disableSystemKeys( void )
|
|||||||
// Enable key repeat
|
// Enable key repeat
|
||||||
//========================================================================
|
//========================================================================
|
||||||
|
|
||||||
static void enableKeyRepeat( void )
|
static void enableKeyRepeat(void)
|
||||||
{
|
{
|
||||||
_glfwInput.KeyRepeat = 1;
|
_glfwInput.KeyRepeat = 1;
|
||||||
}
|
}
|
||||||
@ -191,7 +191,7 @@ static void enableKeyRepeat( void )
|
|||||||
// Disable key repeat
|
// Disable key repeat
|
||||||
//========================================================================
|
//========================================================================
|
||||||
|
|
||||||
static void disableKeyRepeat( void )
|
static void disableKeyRepeat(void)
|
||||||
{
|
{
|
||||||
_glfwInput.KeyRepeat = 0;
|
_glfwInput.KeyRepeat = 0;
|
||||||
}
|
}
|
||||||
@ -201,7 +201,7 @@ static void disableKeyRepeat( void )
|
|||||||
// Enable automatic event polling
|
// Enable automatic event polling
|
||||||
//========================================================================
|
//========================================================================
|
||||||
|
|
||||||
static void enableAutoPollEvents( void )
|
static void enableAutoPollEvents(void)
|
||||||
{
|
{
|
||||||
_glfwWin.autoPollEvents = 1;
|
_glfwWin.autoPollEvents = 1;
|
||||||
}
|
}
|
||||||
@ -210,7 +210,7 @@ static void enableAutoPollEvents( void )
|
|||||||
// Disable automatic event polling
|
// Disable automatic event polling
|
||||||
//========================================================================
|
//========================================================================
|
||||||
|
|
||||||
static void disableAutoPollEvents( void )
|
static void disableAutoPollEvents(void)
|
||||||
{
|
{
|
||||||
_glfwWin.autoPollEvents = 0;
|
_glfwWin.autoPollEvents = 0;
|
||||||
}
|
}
|
||||||
@ -224,12 +224,12 @@ static void disableAutoPollEvents( void )
|
|||||||
// Enable certain GLFW/window/system functions.
|
// Enable certain GLFW/window/system functions.
|
||||||
//========================================================================
|
//========================================================================
|
||||||
|
|
||||||
GLFWAPI void glfwEnable( int token )
|
GLFWAPI void glfwEnable(int token)
|
||||||
{
|
{
|
||||||
if( !_glfwInitialized )
|
if (!_glfwInitialized)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
switch( token )
|
switch (token)
|
||||||
{
|
{
|
||||||
case GLFW_MOUSE_CURSOR:
|
case GLFW_MOUSE_CURSOR:
|
||||||
enableMouseCursor();
|
enableMouseCursor();
|
||||||
@ -259,12 +259,12 @@ GLFWAPI void glfwEnable( int token )
|
|||||||
// Disable certain GLFW/window/system functions.
|
// Disable certain GLFW/window/system functions.
|
||||||
//========================================================================
|
//========================================================================
|
||||||
|
|
||||||
GLFWAPI void glfwDisable( int token )
|
GLFWAPI void glfwDisable(int token)
|
||||||
{
|
{
|
||||||
if( !_glfwInitialized )
|
if (!_glfwInitialized)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
switch( token )
|
switch (token)
|
||||||
{
|
{
|
||||||
case GLFW_MOUSE_CURSOR:
|
case GLFW_MOUSE_CURSOR:
|
||||||
disableMouseCursor();
|
disableMouseCursor();
|
||||||
|
@ -39,39 +39,39 @@
|
|||||||
// Get a list of available video modes
|
// Get a list of available video modes
|
||||||
//========================================================================
|
//========================================================================
|
||||||
|
|
||||||
GLFWAPI int glfwGetVideoModes( GLFWvidmode *list, int maxcount )
|
GLFWAPI int glfwGetVideoModes(GLFWvidmode *list, int maxcount)
|
||||||
{
|
{
|
||||||
int count, i, swap, res1, res2, depth1, depth2;
|
int count, i, swap, res1, res2, depth1, depth2;
|
||||||
GLFWvidmode vm;
|
GLFWvidmode vm;
|
||||||
|
|
||||||
if( !_glfwInitialized || maxcount <= 0 || list == (GLFWvidmode*) 0 )
|
if (!_glfwInitialized || maxcount <= 0 || list == NULL)
|
||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
// Get list of video modes
|
// Get list of video modes
|
||||||
count = _glfwPlatformGetVideoModes( list, maxcount );
|
count = _glfwPlatformGetVideoModes(list, maxcount);
|
||||||
|
|
||||||
// Sort list (bubble sort)
|
// Sort list (bubble sort)
|
||||||
do
|
do
|
||||||
{
|
{
|
||||||
swap = 0;
|
swap = 0;
|
||||||
for( i = 0; i < count-1; ++ i )
|
for (i = 0; i < count - 1; i++)
|
||||||
{
|
{
|
||||||
res1 = list[i].Width*list[i].Height;
|
res1 = list[i].Width*list[i].Height;
|
||||||
depth1 = list[i].RedBits+list[i].GreenBits+list[i].BlueBits;
|
depth1 = list[i].RedBits+list[i].GreenBits+list[i].BlueBits;
|
||||||
res2 = list[i+1].Width*list[i+1].Height;
|
res2 = list[i + 1].Width*list[i + 1].Height;
|
||||||
depth2 = list[i+1].RedBits+list[i+1].GreenBits+
|
depth2 = list[i + 1].RedBits+list[i + 1].GreenBits+
|
||||||
list[i+1].BlueBits;
|
list[i + 1].BlueBits;
|
||||||
|
|
||||||
if( (depth2 < depth1) || ((depth2 == depth1) && (res2 < res1)) )
|
if ((depth2 < depth1) || ((depth2 == depth1) && (res2 < res1)))
|
||||||
{
|
{
|
||||||
vm = list[i];
|
vm = list[i];
|
||||||
list[i] = list[i+1];
|
list[i] = list[i + 1];
|
||||||
list[i+1] = vm;
|
list[i + 1] = vm;
|
||||||
swap = 1;
|
swap = 1;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
while( swap );
|
while (swap);
|
||||||
|
|
||||||
return count;
|
return count;
|
||||||
}
|
}
|
||||||
@ -81,11 +81,11 @@ GLFWAPI int glfwGetVideoModes( GLFWvidmode *list, int maxcount )
|
|||||||
// Get the desktop video mode
|
// Get the desktop video mode
|
||||||
//========================================================================
|
//========================================================================
|
||||||
|
|
||||||
GLFWAPI void glfwGetDesktopMode( GLFWvidmode *mode )
|
GLFWAPI void glfwGetDesktopMode(GLFWvidmode *mode)
|
||||||
{
|
{
|
||||||
if( !_glfwInitialized || mode == (GLFWvidmode*) 0 )
|
if (!_glfwInitialized || mode == NULL)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
_glfwPlatformGetDesktopMode( mode );
|
_glfwPlatformGetDesktopMode(mode);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
80
lib/glext.c
80
lib/glext.c
@ -43,32 +43,32 @@
|
|||||||
// Parses the OpenGL version string and extracts the version number
|
// Parses the OpenGL version string and extracts the version number
|
||||||
//========================================================================
|
//========================================================================
|
||||||
|
|
||||||
void _glfwParseGLVersion( int *major, int *minor, int *rev )
|
void _glfwParseGLVersion(int *major, int *minor, int *rev)
|
||||||
{
|
{
|
||||||
GLuint _major, _minor = 0, _rev = 0;
|
GLuint _major, _minor = 0, _rev = 0;
|
||||||
const GLubyte *version;
|
const GLubyte *version;
|
||||||
const GLubyte *ptr;
|
const GLubyte *ptr;
|
||||||
|
|
||||||
// Get OpenGL version string
|
// Get OpenGL version string
|
||||||
version = glGetString( GL_VERSION );
|
version = glGetString(GL_VERSION);
|
||||||
if( !version )
|
if (!version)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
// Parse string
|
// Parse string
|
||||||
ptr = version;
|
ptr = version;
|
||||||
for( _major = 0; *ptr >= '0' && *ptr <= '9'; ptr ++ )
|
for (_major = 0; *ptr >= '0' && *ptr <= '9'; ptr++)
|
||||||
_major = 10*_major + (*ptr - '0');
|
_major = 10 * _major + (*ptr - '0');
|
||||||
|
|
||||||
if( *ptr == '.' )
|
if (*ptr == '.')
|
||||||
{
|
{
|
||||||
ptr ++;
|
ptr++;
|
||||||
for( _minor = 0; *ptr >= '0' && *ptr <= '9'; ptr ++ )
|
for (_minor = 0; *ptr >= '0' && *ptr <= '9'; ptr++)
|
||||||
_minor = 10*_minor + (*ptr - '0');
|
_minor = 10*_minor + (*ptr - '0');
|
||||||
|
|
||||||
if( *ptr == '.' )
|
if (*ptr == '.')
|
||||||
{
|
{
|
||||||
ptr ++;
|
ptr++;
|
||||||
for( _rev = 0; *ptr >= '0' && *ptr <= '9'; ptr ++ )
|
for (_rev = 0; *ptr >= '0' && *ptr <= '9'; ptr++)
|
||||||
_rev = 10*_rev + (*ptr - '0');
|
_rev = 10*_rev + (*ptr - '0');
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -83,8 +83,8 @@ void _glfwParseGLVersion( int *major, int *minor, int *rev )
|
|||||||
// Check if a string can be found in an OpenGL extension string
|
// Check if a string can be found in an OpenGL extension string
|
||||||
//========================================================================
|
//========================================================================
|
||||||
|
|
||||||
int _glfwStringInExtensionString( const char *string,
|
int _glfwStringInExtensionString(const char *string,
|
||||||
const GLubyte *extensions )
|
const GLubyte *extensions)
|
||||||
{
|
{
|
||||||
const GLubyte *start;
|
const GLubyte *start;
|
||||||
GLubyte *where, *terminator;
|
GLubyte *where, *terminator;
|
||||||
@ -93,16 +93,16 @@ int _glfwStringInExtensionString( const char *string,
|
|||||||
// OpenGL extensions string. Don't be fooled by sub-strings,
|
// OpenGL extensions string. Don't be fooled by sub-strings,
|
||||||
// etc.
|
// etc.
|
||||||
start = extensions;
|
start = extensions;
|
||||||
while( 1 )
|
for (;;)
|
||||||
{
|
{
|
||||||
where = (GLubyte *) strstr( (const char *) start, string );
|
where = (GLubyte *) strstr((const char *) start, string);
|
||||||
if( !where )
|
if (!where)
|
||||||
return GL_FALSE;
|
return GL_FALSE;
|
||||||
|
|
||||||
terminator = where + strlen( string );
|
terminator = where + strlen(string);
|
||||||
if( where == start || *(where - 1) == ' ' )
|
if (where == start || *(where - 1) == ' ')
|
||||||
{
|
{
|
||||||
if( *terminator == ' ' || *terminator == '\0' )
|
if (*terminator == ' ' || *terminator == '\0')
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -122,29 +122,29 @@ int _glfwStringInExtensionString( const char *string,
|
|||||||
// Check if an OpenGL extension is available at runtime
|
// Check if an OpenGL extension is available at runtime
|
||||||
//========================================================================
|
//========================================================================
|
||||||
|
|
||||||
GLFWAPI int glfwExtensionSupported( const char *extension )
|
GLFWAPI int glfwExtensionSupported(const char *extension)
|
||||||
{
|
{
|
||||||
const GLubyte *extensions;
|
const GLubyte *extensions;
|
||||||
GLubyte *where;
|
GLubyte *where;
|
||||||
GLint count;
|
GLint count;
|
||||||
int i;
|
int i;
|
||||||
|
|
||||||
if( !_glfwInitialized || !_glfwWin.opened )
|
if (!_glfwInitialized || !_glfwWin.opened)
|
||||||
return GL_FALSE;
|
return GL_FALSE;
|
||||||
|
|
||||||
// Extension names should not have spaces
|
// Extension names should not have spaces
|
||||||
where = (GLubyte *) strchr( extension, ' ' );
|
where = (GLubyte *) strchr(extension, ' ');
|
||||||
if( where || *extension == '\0' )
|
if (where || *extension == '\0')
|
||||||
return GL_FALSE;
|
return GL_FALSE;
|
||||||
|
|
||||||
if( _glfwWin.glMajor < 3 )
|
if (_glfwWin.glMajor < 3)
|
||||||
{
|
{
|
||||||
// Check if extension is in the old style OpenGL extensions string
|
// Check if extension is in the old style OpenGL extensions string
|
||||||
|
|
||||||
extensions = glGetString( GL_EXTENSIONS );
|
extensions = glGetString(GL_EXTENSIONS);
|
||||||
if( extensions != NULL )
|
if (extensions != NULL)
|
||||||
{
|
{
|
||||||
if( _glfwStringInExtensionString( extension, extensions ) )
|
if (_glfwStringInExtensionString(extension, extensions))
|
||||||
return GL_TRUE;
|
return GL_TRUE;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -152,12 +152,12 @@ GLFWAPI int glfwExtensionSupported( const char *extension )
|
|||||||
{
|
{
|
||||||
// Check if extension is in the modern OpenGL extensions string list
|
// Check if extension is in the modern OpenGL extensions string list
|
||||||
|
|
||||||
glGetIntegerv( GL_NUM_EXTENSIONS, &count );
|
glGetIntegerv(GL_NUM_EXTENSIONS, &count);
|
||||||
|
|
||||||
for( i = 0; i < count; i++ )
|
for (i = 0; i < count; i++)
|
||||||
{
|
{
|
||||||
if( strcmp( (const char*) _glfwWin.GetStringi( GL_EXTENSIONS, i ),
|
if (strcmp((const char*) _glfwWin.GetStringi(GL_EXTENSIONS, i),
|
||||||
extension ) == 0 )
|
extension) == 0)
|
||||||
{
|
{
|
||||||
return GL_TRUE;
|
return GL_TRUE;
|
||||||
}
|
}
|
||||||
@ -165,7 +165,7 @@ GLFWAPI int glfwExtensionSupported( const char *extension )
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Additional platform specific extension checking (e.g. WGL)
|
// Additional platform specific extension checking (e.g. WGL)
|
||||||
if( _glfwPlatformExtensionSupported( extension ) )
|
if (_glfwPlatformExtensionSupported(extension))
|
||||||
return GL_TRUE;
|
return GL_TRUE;
|
||||||
|
|
||||||
return GL_FALSE;
|
return GL_FALSE;
|
||||||
@ -177,12 +177,12 @@ GLFWAPI int glfwExtensionSupported( const char *extension )
|
|||||||
// This function can be used to get access to extended OpenGL functions.
|
// This function can be used to get access to extended OpenGL functions.
|
||||||
//========================================================================
|
//========================================================================
|
||||||
|
|
||||||
GLFWAPI void * glfwGetProcAddress( const char *procname )
|
GLFWAPI void * glfwGetProcAddress(const char *procname)
|
||||||
{
|
{
|
||||||
if( !_glfwInitialized || !_glfwWin.opened )
|
if (!_glfwInitialized || !_glfwWin.opened)
|
||||||
return NULL;
|
return NULL;
|
||||||
|
|
||||||
return _glfwPlatformGetProcAddress( procname );
|
return _glfwPlatformGetProcAddress(procname);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -190,18 +190,18 @@ GLFWAPI void * glfwGetProcAddress( const char *procname )
|
|||||||
// Returns the OpenGL version
|
// Returns the OpenGL version
|
||||||
//========================================================================
|
//========================================================================
|
||||||
|
|
||||||
GLFWAPI void glfwGetGLVersion( int *major, int *minor, int *rev )
|
GLFWAPI void glfwGetGLVersion(int *major, int *minor, int *rev)
|
||||||
{
|
{
|
||||||
if( !_glfwInitialized || !_glfwWin.opened )
|
if (!_glfwInitialized || !_glfwWin.opened)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
if( major != NULL )
|
if (major != NULL)
|
||||||
*major = _glfwWin.glMajor;
|
*major = _glfwWin.glMajor;
|
||||||
|
|
||||||
if( minor != NULL )
|
if (minor != NULL)
|
||||||
*minor = _glfwWin.glMinor;
|
*minor = _glfwWin.glMinor;
|
||||||
|
|
||||||
if( rev != NULL )
|
if (rev != NULL)
|
||||||
*rev = _glfwWin.glRevision;
|
*rev = _glfwWin.glRevision;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
24
lib/init.c
24
lib/init.c
@ -40,13 +40,13 @@
|
|||||||
// Initialize various GLFW state
|
// Initialize various GLFW state
|
||||||
//========================================================================
|
//========================================================================
|
||||||
|
|
||||||
GLFWAPI int glfwInit( void )
|
GLFWAPI int glfwInit(void)
|
||||||
{
|
{
|
||||||
if( _glfwInitialized )
|
if (_glfwInitialized)
|
||||||
return GL_TRUE;
|
return GL_TRUE;
|
||||||
|
|
||||||
memset( &_glfwLibrary, 0, sizeof( _glfwLibrary ) );
|
memset(&_glfwLibrary, 0, sizeof(_glfwLibrary));
|
||||||
memset( &_glfwWin, 0, sizeof( _glfwWin ) );
|
memset(&_glfwWin, 0, sizeof(_glfwWin ));
|
||||||
|
|
||||||
// Window is not yet opened
|
// Window is not yet opened
|
||||||
_glfwWin.opened = GL_FALSE;
|
_glfwWin.opened = GL_FALSE;
|
||||||
@ -58,7 +58,7 @@ GLFWAPI int glfwInit( void )
|
|||||||
_glfwClearWindowHints();
|
_glfwClearWindowHints();
|
||||||
|
|
||||||
// Platform specific initialization
|
// Platform specific initialization
|
||||||
if( !_glfwPlatformInit() )
|
if (!_glfwPlatformInit())
|
||||||
return GL_FALSE;
|
return GL_FALSE;
|
||||||
|
|
||||||
// Form now on, GLFW state is valid
|
// Form now on, GLFW state is valid
|
||||||
@ -72,13 +72,13 @@ GLFWAPI int glfwInit( void )
|
|||||||
// Close window and shut down library
|
// Close window and shut down library
|
||||||
//========================================================================
|
//========================================================================
|
||||||
|
|
||||||
GLFWAPI void glfwTerminate( void )
|
GLFWAPI void glfwTerminate(void)
|
||||||
{
|
{
|
||||||
if( !_glfwInitialized )
|
if (!_glfwInitialized)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
// Platform specific termination
|
// Platform specific termination
|
||||||
if( !_glfwPlatformTerminate() )
|
if (!_glfwPlatformTerminate())
|
||||||
return;
|
return;
|
||||||
|
|
||||||
// GLFW is no longer initialized
|
// GLFW is no longer initialized
|
||||||
@ -90,15 +90,15 @@ GLFWAPI void glfwTerminate( void )
|
|||||||
// Get GLFW version
|
// Get GLFW version
|
||||||
//========================================================================
|
//========================================================================
|
||||||
|
|
||||||
GLFWAPI void glfwGetVersion( int *major, int *minor, int *rev )
|
GLFWAPI void glfwGetVersion(int *major, int *minor, int *rev)
|
||||||
{
|
{
|
||||||
if( major != NULL )
|
if (major != NULL)
|
||||||
*major = GLFW_VERSION_MAJOR;
|
*major = GLFW_VERSION_MAJOR;
|
||||||
|
|
||||||
if( minor != NULL )
|
if (minor != NULL)
|
||||||
*minor = GLFW_VERSION_MINOR;
|
*minor = GLFW_VERSION_MINOR;
|
||||||
|
|
||||||
if( rev != NULL )
|
if (rev != NULL)
|
||||||
*rev = GLFW_VERSION_REVISION;
|
*rev = GLFW_VERSION_REVISION;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
78
lib/input.c
78
lib/input.c
@ -35,23 +35,23 @@
|
|||||||
//
|
//
|
||||||
//========================================================================
|
//========================================================================
|
||||||
|
|
||||||
GLFWAPI int glfwGetKey( int key )
|
GLFWAPI int glfwGetKey(int key)
|
||||||
{
|
{
|
||||||
if( !_glfwInitialized || !_glfwWin.opened )
|
if (!_glfwInitialized || !_glfwWin.opened)
|
||||||
return GLFW_RELEASE;
|
return GLFW_RELEASE;
|
||||||
|
|
||||||
// Is it a valid key?
|
// Is it a valid key?
|
||||||
if( key < 0 || key > GLFW_KEY_LAST )
|
if (key < 0 || key > GLFW_KEY_LAST)
|
||||||
return GLFW_RELEASE;
|
return GLFW_RELEASE;
|
||||||
|
|
||||||
if( _glfwInput.Key[ key ] == GLFW_STICK )
|
if (_glfwInput.Key[key] == GLFW_STICK)
|
||||||
{
|
{
|
||||||
// Sticky mode: release key now
|
// Sticky mode: release key now
|
||||||
_glfwInput.Key[ key ] = GLFW_RELEASE;
|
_glfwInput.Key[key] = GLFW_RELEASE;
|
||||||
return GLFW_PRESS;
|
return GLFW_PRESS;
|
||||||
}
|
}
|
||||||
|
|
||||||
return (int) _glfwInput.Key[ key ];
|
return (int) _glfwInput.Key[key];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -59,23 +59,23 @@ GLFWAPI int glfwGetKey( int key )
|
|||||||
//
|
//
|
||||||
//========================================================================
|
//========================================================================
|
||||||
|
|
||||||
GLFWAPI int glfwGetMouseButton( int button )
|
GLFWAPI int glfwGetMouseButton(int button)
|
||||||
{
|
{
|
||||||
if( !_glfwInitialized || !_glfwWin.opened )
|
if (!_glfwInitialized || !_glfwWin.opened)
|
||||||
return GLFW_RELEASE;
|
return GLFW_RELEASE;
|
||||||
|
|
||||||
// Is it a valid mouse button?
|
// Is it a valid mouse button?
|
||||||
if( button < 0 || button > GLFW_MOUSE_BUTTON_LAST )
|
if (button < 0 || button > GLFW_MOUSE_BUTTON_LAST)
|
||||||
return GLFW_RELEASE;
|
return GLFW_RELEASE;
|
||||||
|
|
||||||
if( _glfwInput.MouseButton[ button ] == GLFW_STICK )
|
if (_glfwInput.MouseButton[button] == GLFW_STICK)
|
||||||
{
|
{
|
||||||
// Sticky mode: release mouse button now
|
// Sticky mode: release mouse button now
|
||||||
_glfwInput.MouseButton[ button ] = GLFW_RELEASE;
|
_glfwInput.MouseButton[button] = GLFW_RELEASE;
|
||||||
return GLFW_PRESS;
|
return GLFW_PRESS;
|
||||||
}
|
}
|
||||||
|
|
||||||
return (int) _glfwInput.MouseButton[ button ];
|
return (int) _glfwInput.MouseButton[button];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -83,16 +83,16 @@ GLFWAPI int glfwGetMouseButton( int button )
|
|||||||
//
|
//
|
||||||
//========================================================================
|
//========================================================================
|
||||||
|
|
||||||
GLFWAPI void glfwGetMousePos( int *xpos, int *ypos )
|
GLFWAPI void glfwGetMousePos(int *xpos, int *ypos)
|
||||||
{
|
{
|
||||||
if( !_glfwInitialized || !_glfwWin.opened )
|
if (!_glfwInitialized || !_glfwWin.opened)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
// Return mouse position
|
// Return mouse position
|
||||||
if( xpos != NULL )
|
if (xpos != NULL)
|
||||||
*xpos = _glfwInput.MousePosX;
|
*xpos = _glfwInput.MousePosX;
|
||||||
|
|
||||||
if( ypos != NULL )
|
if (ypos != NULL)
|
||||||
*ypos = _glfwInput.MousePosY;
|
*ypos = _glfwInput.MousePosY;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -101,13 +101,13 @@ GLFWAPI void glfwGetMousePos( int *xpos, int *ypos )
|
|||||||
//
|
//
|
||||||
//========================================================================
|
//========================================================================
|
||||||
|
|
||||||
GLFWAPI void glfwSetMousePos( int xpos, int ypos )
|
GLFWAPI void glfwSetMousePos(int xpos, int ypos)
|
||||||
{
|
{
|
||||||
if( !_glfwInitialized || !_glfwWin.opened )
|
if (!_glfwInitialized || !_glfwWin.opened)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
// Don't do anything if the mouse position did not change
|
// Don't do anything if the mouse position did not change
|
||||||
if( xpos == _glfwInput.MousePosX && ypos == _glfwInput.MousePosY )
|
if (xpos == _glfwInput.MousePosX && ypos == _glfwInput.MousePosY)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
// Set GLFW mouse position
|
// Set GLFW mouse position
|
||||||
@ -115,11 +115,11 @@ GLFWAPI void glfwSetMousePos( int xpos, int ypos )
|
|||||||
_glfwInput.MousePosY = ypos;
|
_glfwInput.MousePosY = ypos;
|
||||||
|
|
||||||
// If we have a locked mouse, do not change cursor position
|
// If we have a locked mouse, do not change cursor position
|
||||||
if( _glfwWin.mouseLock )
|
if (_glfwWin.mouseLock)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
// Update physical cursor position
|
// Update physical cursor position
|
||||||
_glfwPlatformSetMouseCursorPos( xpos, ypos );
|
_glfwPlatformSetMouseCursorPos(xpos, ypos);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -127,9 +127,9 @@ GLFWAPI void glfwSetMousePos( int xpos, int ypos )
|
|||||||
//
|
//
|
||||||
//========================================================================
|
//========================================================================
|
||||||
|
|
||||||
GLFWAPI int glfwGetMouseWheel( void )
|
GLFWAPI int glfwGetMouseWheel(void)
|
||||||
{
|
{
|
||||||
if( !_glfwInitialized || !_glfwWin.opened )
|
if (!_glfwInitialized || !_glfwWin.opened)
|
||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
// Return mouse wheel position
|
// Return mouse wheel position
|
||||||
@ -141,9 +141,9 @@ GLFWAPI int glfwGetMouseWheel( void )
|
|||||||
//
|
//
|
||||||
//========================================================================
|
//========================================================================
|
||||||
|
|
||||||
GLFWAPI void glfwSetMouseWheel( int pos )
|
GLFWAPI void glfwSetMouseWheel(int pos)
|
||||||
{
|
{
|
||||||
if( !_glfwInitialized || !_glfwWin.opened )
|
if (!_glfwInitialized || !_glfwWin.opened)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
// Set mouse wheel position
|
// Set mouse wheel position
|
||||||
@ -155,9 +155,9 @@ GLFWAPI void glfwSetMouseWheel( int pos )
|
|||||||
// Set callback function for keyboard input
|
// Set callback function for keyboard input
|
||||||
//========================================================================
|
//========================================================================
|
||||||
|
|
||||||
GLFWAPI void glfwSetKeyCallback( GLFWkeyfun cbfun )
|
GLFWAPI void glfwSetKeyCallback(GLFWkeyfun cbfun)
|
||||||
{
|
{
|
||||||
if( !_glfwInitialized || !_glfwWin.opened )
|
if (!_glfwInitialized || !_glfwWin.opened)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
// Set callback function
|
// Set callback function
|
||||||
@ -169,9 +169,9 @@ GLFWAPI void glfwSetKeyCallback( GLFWkeyfun cbfun )
|
|||||||
// Set callback function for character input
|
// Set callback function for character input
|
||||||
//========================================================================
|
//========================================================================
|
||||||
|
|
||||||
GLFWAPI void glfwSetCharCallback( GLFWcharfun cbfun )
|
GLFWAPI void glfwSetCharCallback(GLFWcharfun cbfun)
|
||||||
{
|
{
|
||||||
if( !_glfwInitialized || !_glfwWin.opened )
|
if (!_glfwInitialized || !_glfwWin.opened)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
// Set callback function
|
// Set callback function
|
||||||
@ -183,9 +183,9 @@ GLFWAPI void glfwSetCharCallback( GLFWcharfun cbfun )
|
|||||||
// Set callback function for mouse clicks
|
// Set callback function for mouse clicks
|
||||||
//========================================================================
|
//========================================================================
|
||||||
|
|
||||||
GLFWAPI void glfwSetMouseButtonCallback( GLFWmousebuttonfun cbfun )
|
GLFWAPI void glfwSetMouseButtonCallback(GLFWmousebuttonfun cbfun)
|
||||||
{
|
{
|
||||||
if( !_glfwInitialized || !_glfwWin.opened )
|
if (!_glfwInitialized || !_glfwWin.opened)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
// Set callback function
|
// Set callback function
|
||||||
@ -197,9 +197,9 @@ GLFWAPI void glfwSetMouseButtonCallback( GLFWmousebuttonfun cbfun )
|
|||||||
// Set callback function for mouse moves
|
// Set callback function for mouse moves
|
||||||
//========================================================================
|
//========================================================================
|
||||||
|
|
||||||
GLFWAPI void glfwSetMousePosCallback( GLFWmouseposfun cbfun )
|
GLFWAPI void glfwSetMousePosCallback(GLFWmouseposfun cbfun)
|
||||||
{
|
{
|
||||||
if( !_glfwInitialized || !_glfwWin.opened )
|
if (!_glfwInitialized || !_glfwWin.opened)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
// Set callback function
|
// Set callback function
|
||||||
@ -207,8 +207,8 @@ GLFWAPI void glfwSetMousePosCallback( GLFWmouseposfun cbfun )
|
|||||||
|
|
||||||
// Call the callback function to let the application know the current
|
// Call the callback function to let the application know the current
|
||||||
// mouse position
|
// mouse position
|
||||||
if( cbfun )
|
if (cbfun)
|
||||||
cbfun( _glfwInput.MousePosX, _glfwInput.MousePosY );
|
cbfun(_glfwInput.MousePosX, _glfwInput.MousePosY);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -216,9 +216,9 @@ GLFWAPI void glfwSetMousePosCallback( GLFWmouseposfun cbfun )
|
|||||||
// Set callback function for mouse wheel
|
// Set callback function for mouse wheel
|
||||||
//========================================================================
|
//========================================================================
|
||||||
|
|
||||||
GLFWAPI void glfwSetMouseWheelCallback( GLFWmousewheelfun cbfun )
|
GLFWAPI void glfwSetMouseWheelCallback(GLFWmousewheelfun cbfun)
|
||||||
{
|
{
|
||||||
if( !_glfwInitialized || !_glfwWin.opened )
|
if (!_glfwInitialized || !_glfwWin.opened)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
// Set callback function
|
// Set callback function
|
||||||
@ -226,7 +226,7 @@ GLFWAPI void glfwSetMouseWheelCallback( GLFWmousewheelfun cbfun )
|
|||||||
|
|
||||||
// Call the callback function to let the application know the current
|
// Call the callback function to let the application know the current
|
||||||
// mouse wheel position
|
// mouse wheel position
|
||||||
if( cbfun )
|
if (cbfun)
|
||||||
cbfun( _glfwInput.WheelPos );
|
cbfun(_glfwInput.WheelPos);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -39,12 +39,12 @@
|
|||||||
// Determine joystick capabilities
|
// Determine joystick capabilities
|
||||||
//========================================================================
|
//========================================================================
|
||||||
|
|
||||||
GLFWAPI int glfwGetJoystickParam( int joy, int param )
|
GLFWAPI int glfwGetJoystickParam(int joy, int param)
|
||||||
{
|
{
|
||||||
if( !_glfwInitialized )
|
if (!_glfwInitialized)
|
||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
return _glfwPlatformGetJoystickParam( joy, param );
|
return _glfwPlatformGetJoystickParam(joy, param);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -52,18 +52,18 @@ GLFWAPI int glfwGetJoystickParam( int joy, int param )
|
|||||||
// Get joystick axis positions
|
// Get joystick axis positions
|
||||||
//========================================================================
|
//========================================================================
|
||||||
|
|
||||||
GLFWAPI int glfwGetJoystickPos( int joy, float *pos, int numaxes )
|
GLFWAPI int glfwGetJoystickPos(int joy, float *pos, int numaxes)
|
||||||
{
|
{
|
||||||
int i;
|
int i;
|
||||||
|
|
||||||
if( !_glfwInitialized )
|
if (!_glfwInitialized)
|
||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
// Clear positions
|
// Clear positions
|
||||||
for( i = 0; i < numaxes; i++ )
|
for (i = 0; i < numaxes; i++)
|
||||||
pos[ i ] = 0.0f;
|
pos[i] = 0.0f;
|
||||||
|
|
||||||
return _glfwPlatformGetJoystickPos( joy, pos, numaxes );
|
return _glfwPlatformGetJoystickPos(joy, pos, numaxes);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -71,19 +71,19 @@ GLFWAPI int glfwGetJoystickPos( int joy, float *pos, int numaxes )
|
|||||||
// Get joystick button states
|
// Get joystick button states
|
||||||
//========================================================================
|
//========================================================================
|
||||||
|
|
||||||
GLFWAPI int glfwGetJoystickButtons( int joy,
|
GLFWAPI int glfwGetJoystickButtons(int joy,
|
||||||
unsigned char *buttons,
|
unsigned char *buttons,
|
||||||
int numbuttons )
|
int numbuttons)
|
||||||
{
|
{
|
||||||
int i;
|
int i;
|
||||||
|
|
||||||
if( !_glfwInitialized )
|
if (!_glfwInitialized)
|
||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
// Clear button states
|
// Clear button states
|
||||||
for( i = 0; i < numbuttons; i++ )
|
for (i = 0; i < numbuttons; i++)
|
||||||
buttons[ i ] = GLFW_RELEASE;
|
buttons[i] = GLFW_RELEASE;
|
||||||
|
|
||||||
return _glfwPlatformGetJoystickButtons( joy, buttons, numbuttons );
|
return _glfwPlatformGetJoystickButtons(joy, buttons, numbuttons);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
10
lib/time.c
10
lib/time.c
@ -39,9 +39,9 @@
|
|||||||
// Return timer value in seconds
|
// Return timer value in seconds
|
||||||
//========================================================================
|
//========================================================================
|
||||||
|
|
||||||
GLFWAPI double glfwGetTime( void )
|
GLFWAPI double glfwGetTime(void)
|
||||||
{
|
{
|
||||||
if( !_glfwInitialized )
|
if (!_glfwInitialized)
|
||||||
return 0.0;
|
return 0.0;
|
||||||
|
|
||||||
return _glfwPlatformGetTime();
|
return _glfwPlatformGetTime();
|
||||||
@ -52,11 +52,11 @@ GLFWAPI double glfwGetTime( void )
|
|||||||
// Set timer value in seconds
|
// Set timer value in seconds
|
||||||
//========================================================================
|
//========================================================================
|
||||||
|
|
||||||
GLFWAPI void glfwSetTime( double time )
|
GLFWAPI void glfwSetTime(double time)
|
||||||
{
|
{
|
||||||
if( !_glfwInitialized )
|
if (!_glfwInitialized)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
_glfwPlatformSetTime( time );
|
_glfwPlatformSetTime(time);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
370
lib/window.c
370
lib/window.c
@ -46,9 +46,9 @@ static int Max(int a, int b)
|
|||||||
// Clear all open window hints
|
// Clear all open window hints
|
||||||
//========================================================================
|
//========================================================================
|
||||||
|
|
||||||
void _glfwClearWindowHints( void )
|
void _glfwClearWindowHints(void)
|
||||||
{
|
{
|
||||||
memset( &_glfwLibrary.hints, 0, sizeof( _glfwLibrary.hints ) );
|
memset(&_glfwLibrary.hints, 0, sizeof(_glfwLibrary.hints));
|
||||||
_glfwLibrary.hints.glMajor = 1;
|
_glfwLibrary.hints.glMajor = 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -57,22 +57,22 @@ void _glfwClearWindowHints( void )
|
|||||||
// Handle the input tracking part of window deactivation
|
// Handle the input tracking part of window deactivation
|
||||||
//========================================================================
|
//========================================================================
|
||||||
|
|
||||||
void _glfwInputDeactivation( void )
|
void _glfwInputDeactivation(void)
|
||||||
{
|
{
|
||||||
int i;
|
int i;
|
||||||
|
|
||||||
// Release all keyboard keys
|
// Release all keyboard keys
|
||||||
for( i = 0; i <= GLFW_KEY_LAST; i ++ )
|
for (i = 0; i <= GLFW_KEY_LAST; i++)
|
||||||
{
|
{
|
||||||
if( _glfwInput.Key[ i ] == GLFW_PRESS )
|
if(_glfwInput.Key[i] == GLFW_PRESS)
|
||||||
_glfwInputKey( i, GLFW_RELEASE );
|
_glfwInputKey(i, GLFW_RELEASE);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Release all mouse buttons
|
// Release all mouse buttons
|
||||||
for( i = 0; i <= GLFW_MOUSE_BUTTON_LAST; i ++ )
|
for (i = 0; i <= GLFW_MOUSE_BUTTON_LAST; i++)
|
||||||
{
|
{
|
||||||
if( _glfwInput.MouseButton[ i ] == GLFW_PRESS )
|
if (_glfwInput.MouseButton[i] == GLFW_PRESS)
|
||||||
_glfwInputMouseClick( i, GLFW_RELEASE );
|
_glfwInputMouseClick(i, GLFW_RELEASE);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -81,20 +81,20 @@ void _glfwInputDeactivation( void )
|
|||||||
// Clear all input state
|
// Clear all input state
|
||||||
//========================================================================
|
//========================================================================
|
||||||
|
|
||||||
void _glfwClearInput( void )
|
void _glfwClearInput(void)
|
||||||
{
|
{
|
||||||
int i;
|
int i;
|
||||||
|
|
||||||
// Release all keyboard keys
|
// Release all keyboard keys
|
||||||
for( i = 0; i <= GLFW_KEY_LAST; i ++ )
|
for (i = 0; i <= GLFW_KEY_LAST; i++)
|
||||||
_glfwInput.Key[ i ] = GLFW_RELEASE;
|
_glfwInput.Key[i] = GLFW_RELEASE;
|
||||||
|
|
||||||
// Clear last character
|
// Clear last character
|
||||||
_glfwInput.LastChar = 0;
|
_glfwInput.LastChar = 0;
|
||||||
|
|
||||||
// Release all mouse buttons
|
// Release all mouse buttons
|
||||||
for( i = 0; i <= GLFW_MOUSE_BUTTON_LAST; i ++ )
|
for (i = 0; i <= GLFW_MOUSE_BUTTON_LAST; i++)
|
||||||
_glfwInput.MouseButton[ i ] = GLFW_RELEASE;
|
_glfwInput.MouseButton[i] = GLFW_RELEASE;
|
||||||
|
|
||||||
// Set mouse position to (0,0)
|
// Set mouse position to (0,0)
|
||||||
_glfwInput.MousePosX = 0;
|
_glfwInput.MousePosX = 0;
|
||||||
@ -116,30 +116,30 @@ void _glfwClearInput( void )
|
|||||||
// Register keyboard activity
|
// Register keyboard activity
|
||||||
//========================================================================
|
//========================================================================
|
||||||
|
|
||||||
void _glfwInputKey( int key, int action )
|
void _glfwInputKey(int key, int action)
|
||||||
{
|
{
|
||||||
int keyrepeat = 0;
|
int keyrepeat = 0;
|
||||||
|
|
||||||
if( key < 0 || key > GLFW_KEY_LAST )
|
if (key < 0 || key > GLFW_KEY_LAST)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
// Are we trying to release an already released key?
|
// Are we trying to release an already released key?
|
||||||
if( action == GLFW_RELEASE && _glfwInput.Key[ key ] != GLFW_PRESS )
|
if (action == GLFW_RELEASE && _glfwInput.Key[key] != GLFW_PRESS)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
// Register key action
|
// Register key action
|
||||||
if( action == GLFW_RELEASE && _glfwInput.StickyKeys )
|
if(action == GLFW_RELEASE && _glfwInput.StickyKeys)
|
||||||
_glfwInput.Key[ key ] = GLFW_STICK;
|
_glfwInput.Key[key] = GLFW_STICK;
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
keyrepeat = (_glfwInput.Key[ key ] == GLFW_PRESS) &&
|
keyrepeat = (_glfwInput.Key[key] == GLFW_PRESS) &&
|
||||||
(action == GLFW_PRESS);
|
(action == GLFW_PRESS);
|
||||||
_glfwInput.Key[ key ] = (char) action;
|
_glfwInput.Key[key] = (char) action;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Call user callback function
|
// Call user callback function
|
||||||
if( _glfwWin.keyCallback && (_glfwInput.KeyRepeat || !keyrepeat) )
|
if (_glfwWin.keyCallback && (_glfwInput.KeyRepeat || !keyrepeat) )
|
||||||
_glfwWin.keyCallback( key, action );
|
_glfwWin.keyCallback(key, action);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -147,25 +147,25 @@ void _glfwInputKey( int key, int action )
|
|||||||
// Register (keyboard) character activity
|
// Register (keyboard) character activity
|
||||||
//========================================================================
|
//========================================================================
|
||||||
|
|
||||||
void _glfwInputChar( int character, int action )
|
void _glfwInputChar(int character, int action)
|
||||||
{
|
{
|
||||||
int keyrepeat = 0;
|
int keyrepeat = 0;
|
||||||
|
|
||||||
// Valid Unicode (ISO 10646) character?
|
// Valid Unicode (ISO 10646) character?
|
||||||
if( !( (character >= 32 && character <= 126) || character >= 160 ) )
|
if (!((character >= 32 && character <= 126) || character >= 160))
|
||||||
return;
|
return;
|
||||||
|
|
||||||
// Is this a key repeat?
|
// Is this a key repeat?
|
||||||
if( action == GLFW_PRESS && _glfwInput.LastChar == character )
|
if (action == GLFW_PRESS && _glfwInput.LastChar == character)
|
||||||
keyrepeat = 1;
|
keyrepeat = 1;
|
||||||
|
|
||||||
// Store this character as last character (or clear it, if released)
|
// Store this character as last character (or clear it, if released)
|
||||||
if( action == GLFW_PRESS )
|
if (action == GLFW_PRESS)
|
||||||
_glfwInput.LastChar = character;
|
_glfwInput.LastChar = character;
|
||||||
else
|
else
|
||||||
_glfwInput.LastChar = 0;
|
_glfwInput.LastChar = 0;
|
||||||
|
|
||||||
if( action != GLFW_PRESS )
|
if (action != GLFW_PRESS)
|
||||||
{
|
{
|
||||||
// This intentionally breaks release notifications for Unicode
|
// This intentionally breaks release notifications for Unicode
|
||||||
// characters, partly to see if anyone cares but mostly because it's
|
// characters, partly to see if anyone cares but mostly because it's
|
||||||
@ -183,8 +183,8 @@ void _glfwInputChar( int character, int action )
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if( _glfwWin.charCallback && (_glfwInput.KeyRepeat || !keyrepeat) )
|
if (_glfwWin.charCallback && (_glfwInput.KeyRepeat || !keyrepeat))
|
||||||
_glfwWin.charCallback( character, action );
|
_glfwWin.charCallback(character, action);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -192,19 +192,19 @@ void _glfwInputChar( int character, int action )
|
|||||||
// Register mouse button clicks
|
// Register mouse button clicks
|
||||||
//========================================================================
|
//========================================================================
|
||||||
|
|
||||||
void _glfwInputMouseClick( int button, int action )
|
void _glfwInputMouseClick(int button, int action)
|
||||||
{
|
{
|
||||||
if( button >= 0 && button <= GLFW_MOUSE_BUTTON_LAST )
|
if (button >= 0 && button <= GLFW_MOUSE_BUTTON_LAST)
|
||||||
{
|
{
|
||||||
// Register mouse button action
|
// Register mouse button action
|
||||||
if( action == GLFW_RELEASE && _glfwInput.StickyMouseButtons )
|
if (action == GLFW_RELEASE && _glfwInput.StickyMouseButtons)
|
||||||
_glfwInput.MouseButton[ button ] = GLFW_STICK;
|
_glfwInput.MouseButton[button] = GLFW_STICK;
|
||||||
else
|
else
|
||||||
_glfwInput.MouseButton[ button ] = (char) action;
|
_glfwInput.MouseButton[button] = (char) action;
|
||||||
|
|
||||||
// Call user callback function
|
// Call user callback function
|
||||||
if( _glfwWin.mouseButtonCallback )
|
if (_glfwWin.mouseButtonCallback)
|
||||||
_glfwWin.mouseButtonCallback( button, action );
|
_glfwWin.mouseButtonCallback(button, action);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -214,9 +214,9 @@ void _glfwInputMouseClick( int button, int action )
|
|||||||
// This is based on the manual GLX Visual selection from 2.6
|
// This is based on the manual GLX Visual selection from 2.6
|
||||||
//========================================================================
|
//========================================================================
|
||||||
|
|
||||||
const _GLFWfbconfig *_glfwChooseFBConfig( const _GLFWfbconfig *desired,
|
const _GLFWfbconfig *_glfwChooseFBConfig(const _GLFWfbconfig *desired,
|
||||||
const _GLFWfbconfig *alternatives,
|
const _GLFWfbconfig *alternatives,
|
||||||
unsigned int count )
|
unsigned int count)
|
||||||
{
|
{
|
||||||
unsigned int i;
|
unsigned int i;
|
||||||
unsigned int missing, leastMissing = UINT_MAX;
|
unsigned int missing, leastMissing = UINT_MAX;
|
||||||
@ -228,17 +228,17 @@ const _GLFWfbconfig *_glfwChooseFBConfig( const _GLFWfbconfig *desired,
|
|||||||
|
|
||||||
// Cache some long-winded preferences
|
// Cache some long-winded preferences
|
||||||
|
|
||||||
if( desired->redBits || desired->greenBits || desired->blueBits ||
|
if (desired->redBits || desired->greenBits || desired->blueBits ||
|
||||||
desired->alphaBits )
|
desired->alphaBits)
|
||||||
{
|
{
|
||||||
desiresColor = GL_TRUE;
|
desiresColor = GL_TRUE;
|
||||||
}
|
}
|
||||||
|
|
||||||
for( i = 0; i < count; i++ )
|
for (i = 0; i < count; i++)
|
||||||
{
|
{
|
||||||
current = alternatives + i;
|
current = alternatives + i;
|
||||||
|
|
||||||
if( desired->stereo > 0 && current->stereo == 0 )
|
if (desired->stereo > 0 && current->stereo == 0)
|
||||||
{
|
{
|
||||||
// Stereo is a hard constraint
|
// Stereo is a hard constraint
|
||||||
continue;
|
continue;
|
||||||
@ -248,19 +248,19 @@ const _GLFWfbconfig *_glfwChooseFBConfig( const _GLFWfbconfig *desired,
|
|||||||
{
|
{
|
||||||
missing = 0;
|
missing = 0;
|
||||||
|
|
||||||
if( desired->alphaBits > 0 && current->alphaBits == 0 )
|
if (desired->alphaBits > 0 && current->alphaBits == 0)
|
||||||
missing++;
|
missing++;
|
||||||
|
|
||||||
if( desired->depthBits > 0 && current->depthBits == 0 )
|
if (desired->depthBits > 0 && current->depthBits == 0)
|
||||||
missing++;
|
missing++;
|
||||||
|
|
||||||
if( desired->stencilBits > 0 && current->stencilBits == 0 )
|
if (desired->stencilBits > 0 && current->stencilBits == 0)
|
||||||
missing++;
|
missing++;
|
||||||
|
|
||||||
if( desired->auxBuffers > 0 && current->auxBuffers < desired->auxBuffers )
|
if (desired->auxBuffers > 0 && current->auxBuffers < desired->auxBuffers)
|
||||||
missing += desired->auxBuffers - current->auxBuffers;
|
missing += desired->auxBuffers - current->auxBuffers;
|
||||||
|
|
||||||
if( desired->samples > 0 && current->samples == 0 )
|
if (desired->samples > 0 && current->samples == 0)
|
||||||
{
|
{
|
||||||
// Technically, several multisampling buffers could be
|
// Technically, several multisampling buffers could be
|
||||||
// involved, but that's a lower level implementation detail and
|
// involved, but that's a lower level implementation detail and
|
||||||
@ -276,22 +276,22 @@ const _GLFWfbconfig *_glfwChooseFBConfig( const _GLFWfbconfig *desired,
|
|||||||
{
|
{
|
||||||
colorDiff = 0;
|
colorDiff = 0;
|
||||||
|
|
||||||
if ( desired->redBits > 0 )
|
if (desired->redBits > 0)
|
||||||
{
|
{
|
||||||
colorDiff += ( desired->redBits - current->redBits ) *
|
colorDiff += (desired->redBits - current->redBits) *
|
||||||
( desired->redBits - current->redBits );
|
(desired->redBits - current->redBits);
|
||||||
}
|
}
|
||||||
|
|
||||||
if ( desired->greenBits > 0 )
|
if (desired->greenBits > 0)
|
||||||
{
|
{
|
||||||
colorDiff += ( desired->greenBits - current->greenBits ) *
|
colorDiff += (desired->greenBits - current->greenBits) *
|
||||||
( desired->greenBits - current->greenBits );
|
(desired->greenBits - current->greenBits);
|
||||||
}
|
}
|
||||||
|
|
||||||
if ( desired->blueBits > 0 )
|
if (desired->blueBits > 0)
|
||||||
{
|
{
|
||||||
colorDiff += ( desired->blueBits - current->blueBits ) *
|
colorDiff += (desired->blueBits - current->blueBits) *
|
||||||
( desired->blueBits - current->blueBits );
|
(desired->blueBits - current->blueBits);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -299,80 +299,80 @@ const _GLFWfbconfig *_glfwChooseFBConfig( const _GLFWfbconfig *desired,
|
|||||||
{
|
{
|
||||||
extraDiff = 0;
|
extraDiff = 0;
|
||||||
|
|
||||||
if( desired->alphaBits > 0 )
|
if (desired->alphaBits > 0)
|
||||||
{
|
{
|
||||||
extraDiff += ( desired->alphaBits - current->alphaBits ) *
|
extraDiff += (desired->alphaBits - current->alphaBits) *
|
||||||
( desired->alphaBits - current->alphaBits );
|
(desired->alphaBits - current->alphaBits);
|
||||||
}
|
}
|
||||||
|
|
||||||
if( desired->depthBits > 0 )
|
if (desired->depthBits > 0)
|
||||||
{
|
{
|
||||||
extraDiff += ( desired->depthBits - current->depthBits ) *
|
extraDiff += (desired->depthBits - current->depthBits) *
|
||||||
( desired->depthBits - current->depthBits );
|
(desired->depthBits - current->depthBits);
|
||||||
}
|
}
|
||||||
|
|
||||||
if( desired->stencilBits > 0 )
|
if (desired->stencilBits > 0)
|
||||||
{
|
{
|
||||||
extraDiff += ( desired->stencilBits - current->stencilBits ) *
|
extraDiff += (desired->stencilBits - current->stencilBits) *
|
||||||
( desired->stencilBits - current->stencilBits );
|
(desired->stencilBits - current->stencilBits);
|
||||||
}
|
}
|
||||||
|
|
||||||
if( desired->accumRedBits > 0 )
|
if (desired->accumRedBits > 0)
|
||||||
{
|
{
|
||||||
extraDiff += ( desired->accumRedBits - current->accumRedBits ) *
|
extraDiff += (desired->accumRedBits - current->accumRedBits) *
|
||||||
( desired->accumRedBits - current->accumRedBits );
|
(desired->accumRedBits - current->accumRedBits);
|
||||||
}
|
}
|
||||||
|
|
||||||
if( desired->accumGreenBits > 0 )
|
if (desired->accumGreenBits > 0)
|
||||||
{
|
{
|
||||||
extraDiff += ( desired->accumGreenBits - current->accumGreenBits ) *
|
extraDiff += (desired->accumGreenBits - current->accumGreenBits) *
|
||||||
( desired->accumGreenBits - current->accumGreenBits );
|
(desired->accumGreenBits - current->accumGreenBits);
|
||||||
}
|
}
|
||||||
|
|
||||||
if( desired->accumBlueBits > 0 )
|
if (desired->accumBlueBits > 0)
|
||||||
{
|
{
|
||||||
extraDiff += ( desired->accumBlueBits - current->accumBlueBits ) *
|
extraDiff += (desired->accumBlueBits - current->accumBlueBits) *
|
||||||
( desired->accumBlueBits - current->accumBlueBits );
|
(desired->accumBlueBits - current->accumBlueBits);
|
||||||
}
|
}
|
||||||
|
|
||||||
if( desired->accumAlphaBits > 0 )
|
if (desired->accumAlphaBits > 0)
|
||||||
{
|
{
|
||||||
extraDiff += ( desired->accumAlphaBits - current->accumAlphaBits ) *
|
extraDiff += (desired->accumAlphaBits - current->accumAlphaBits) *
|
||||||
( desired->accumAlphaBits - current->accumAlphaBits );
|
(desired->accumAlphaBits - current->accumAlphaBits);
|
||||||
}
|
}
|
||||||
|
|
||||||
if( desired->samples > 0 )
|
if (desired->samples > 0)
|
||||||
{
|
{
|
||||||
extraDiff += ( desired->samples - current->samples ) *
|
extraDiff += (desired->samples - current->samples) *
|
||||||
( desired->samples - current->samples );
|
(desired->samples - current->samples);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Figure out if the current one is better than the best one found so far
|
// Figure out if the current one is better than the best one found so far
|
||||||
|
|
||||||
if( missing < leastMissing )
|
if (missing < leastMissing)
|
||||||
closest = current;
|
closest = current;
|
||||||
else if( missing == leastMissing )
|
else if (missing == leastMissing)
|
||||||
{
|
{
|
||||||
if( desiresColor )
|
if (desiresColor)
|
||||||
{
|
{
|
||||||
if( ( colorDiff < leastColorDiff ) ||
|
if ((colorDiff < leastColorDiff) ||
|
||||||
( colorDiff == leastColorDiff && extraDiff < leastExtraDiff ) )
|
(colorDiff == leastColorDiff && extraDiff < leastExtraDiff))
|
||||||
{
|
{
|
||||||
closest = current;
|
closest = current;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
if( ( extraDiff < leastExtraDiff ) ||
|
if ((extraDiff < leastExtraDiff) ||
|
||||||
( extraDiff == leastExtraDiff && colorDiff < leastColorDiff ) )
|
(extraDiff == leastExtraDiff && colorDiff < leastColorDiff))
|
||||||
{
|
{
|
||||||
closest = current;
|
closest = current;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if( current == closest )
|
if (current == closest)
|
||||||
{
|
{
|
||||||
leastMissing = missing;
|
leastMissing = missing;
|
||||||
leastColorDiff = colorDiff;
|
leastColorDiff = colorDiff;
|
||||||
@ -392,52 +392,53 @@ const _GLFWfbconfig *_glfwChooseFBConfig( const _GLFWfbconfig *desired,
|
|||||||
// Create the GLFW window and its associated context
|
// Create the GLFW window and its associated context
|
||||||
//========================================================================
|
//========================================================================
|
||||||
|
|
||||||
GLFWAPI int glfwOpenWindow( int width, int height,
|
GLFWAPI int glfwOpenWindow(int width, int height,
|
||||||
int redbits, int greenbits, int bluebits, int alphabits,
|
int redbits, int greenbits, int bluebits,
|
||||||
int depthbits, int stencilbits, int mode )
|
int alphabits, int depthbits, int stencilbits,
|
||||||
|
int mode)
|
||||||
{
|
{
|
||||||
_GLFWfbconfig fbconfig;
|
_GLFWfbconfig fbconfig;
|
||||||
_GLFWwndconfig wndconfig;
|
_GLFWwndconfig wndconfig;
|
||||||
|
|
||||||
if( !_glfwInitialized || _glfwWin.opened )
|
if (!_glfwInitialized || _glfwWin.opened)
|
||||||
return GL_FALSE;
|
return GL_FALSE;
|
||||||
|
|
||||||
// Set up desired framebuffer config
|
// Set up desired framebuffer config
|
||||||
fbconfig.redBits = Max( redbits, 0 );
|
fbconfig.redBits = Max(redbits, 0);
|
||||||
fbconfig.greenBits = Max( greenbits, 0 );
|
fbconfig.greenBits = Max(greenbits, 0);
|
||||||
fbconfig.blueBits = Max( bluebits, 0 );
|
fbconfig.blueBits = Max(bluebits, 0);
|
||||||
fbconfig.alphaBits = Max( alphabits, 0 );
|
fbconfig.alphaBits = Max(alphabits, 0);
|
||||||
fbconfig.depthBits = Max( depthbits, 0 );
|
fbconfig.depthBits = Max(depthbits, 0);
|
||||||
fbconfig.stencilBits = Max( stencilbits, 0 );
|
fbconfig.stencilBits = Max(stencilbits, 0);
|
||||||
fbconfig.accumRedBits = Max( _glfwLibrary.hints.accumRedBits, 0 );
|
fbconfig.accumRedBits = Max(_glfwLibrary.hints.accumRedBits, 0);
|
||||||
fbconfig.accumGreenBits = Max( _glfwLibrary.hints.accumGreenBits, 0 );
|
fbconfig.accumGreenBits = Max(_glfwLibrary.hints.accumGreenBits, 0);
|
||||||
fbconfig.accumBlueBits = Max( _glfwLibrary.hints.accumBlueBits, 0 );
|
fbconfig.accumBlueBits = Max(_glfwLibrary.hints.accumBlueBits, 0);
|
||||||
fbconfig.accumAlphaBits = Max( _glfwLibrary.hints.accumAlphaBits, 0 );
|
fbconfig.accumAlphaBits = Max(_glfwLibrary.hints.accumAlphaBits, 0);
|
||||||
fbconfig.auxBuffers = Max( _glfwLibrary.hints.auxBuffers, 0 );
|
fbconfig.auxBuffers = Max(_glfwLibrary.hints.auxBuffers, 0);
|
||||||
fbconfig.stereo = _glfwLibrary.hints.stereo ? GL_TRUE : GL_FALSE;
|
fbconfig.stereo = _glfwLibrary.hints.stereo ? GL_TRUE : GL_FALSE;
|
||||||
fbconfig.samples = Max( _glfwLibrary.hints.samples, 0 );
|
fbconfig.samples = Max(_glfwLibrary.hints.samples, 0);
|
||||||
|
|
||||||
// Set up desired window config
|
// Set up desired window config
|
||||||
wndconfig.mode = mode;
|
wndconfig.mode = mode;
|
||||||
wndconfig.refreshRate = Max( _glfwLibrary.hints.refreshRate, 0 );
|
wndconfig.refreshRate = Max(_glfwLibrary.hints.refreshRate, 0);
|
||||||
wndconfig.windowNoResize = _glfwLibrary.hints.windowNoResize ? GL_TRUE : GL_FALSE;
|
wndconfig.windowNoResize = _glfwLibrary.hints.windowNoResize ? GL_TRUE : GL_FALSE;
|
||||||
wndconfig.glMajor = Max( _glfwLibrary.hints.glMajor, 1 );
|
wndconfig.glMajor = Max(_glfwLibrary.hints.glMajor, 1);
|
||||||
wndconfig.glMinor = Max( _glfwLibrary.hints.glMinor, 0 );
|
wndconfig.glMinor = Max(_glfwLibrary.hints.glMinor, 0);
|
||||||
wndconfig.glForward = _glfwLibrary.hints.glForward ? GL_TRUE : GL_FALSE;
|
wndconfig.glForward = _glfwLibrary.hints.glForward ? GL_TRUE : GL_FALSE;
|
||||||
wndconfig.glDebug = _glfwLibrary.hints.glDebug ? GL_TRUE : GL_FALSE;
|
wndconfig.glDebug = _glfwLibrary.hints.glDebug ? GL_TRUE : GL_FALSE;
|
||||||
wndconfig.glProfile = _glfwLibrary.hints.glProfile;
|
wndconfig.glProfile = _glfwLibrary.hints.glProfile;
|
||||||
|
|
||||||
if( wndconfig.glMajor == 1 && wndconfig.glMinor > 5 )
|
if (wndconfig.glMajor == 1 && wndconfig.glMinor > 5)
|
||||||
{
|
{
|
||||||
// OpenGL 1.x series ended with version 1.5
|
// OpenGL 1.x series ended with version 1.5
|
||||||
return GL_FALSE;
|
return GL_FALSE;
|
||||||
}
|
}
|
||||||
else if( wndconfig.glMajor == 2 && wndconfig.glMinor > 1 )
|
else if (wndconfig.glMajor == 2 && wndconfig.glMinor > 1)
|
||||||
{
|
{
|
||||||
// OpenGL 2.x series ended with version 2.1
|
// OpenGL 2.x series ended with version 2.1
|
||||||
return GL_FALSE;
|
return GL_FALSE;
|
||||||
}
|
}
|
||||||
else if( wndconfig.glMajor == 3 && wndconfig.glMinor > 3 )
|
else if (wndconfig.glMajor == 3 && wndconfig.glMinor > 3)
|
||||||
{
|
{
|
||||||
// OpenGL 3.x series ended with version 3.3
|
// OpenGL 3.x series ended with version 3.3
|
||||||
return GL_FALSE;
|
return GL_FALSE;
|
||||||
@ -447,14 +448,14 @@ GLFWAPI int glfwOpenWindow( int width, int height,
|
|||||||
// For now, let everything else through
|
// For now, let everything else through
|
||||||
}
|
}
|
||||||
|
|
||||||
if( wndconfig.glProfile &&
|
if (wndconfig.glProfile &&
|
||||||
( wndconfig.glMajor < 3 || ( wndconfig.glMajor == 3 && wndconfig.glMinor < 2 ) ) )
|
(wndconfig.glMajor < 3 || (wndconfig.glMajor == 3 && wndconfig.glMinor < 2)))
|
||||||
{
|
{
|
||||||
// Context profiles are only defined for OpenGL version 3.2 and above
|
// Context profiles are only defined for OpenGL version 3.2 and above
|
||||||
return GL_FALSE;
|
return GL_FALSE;
|
||||||
}
|
}
|
||||||
|
|
||||||
if( wndconfig.glForward && wndconfig.glMajor < 3 )
|
if (wndconfig.glForward && wndconfig.glMajor < 3)
|
||||||
{
|
{
|
||||||
// Forward-compatible contexts are only defined for OpenGL version 3.0 and above
|
// Forward-compatible contexts are only defined for OpenGL version 3.0 and above
|
||||||
return GL_FALSE;
|
return GL_FALSE;
|
||||||
@ -464,7 +465,7 @@ GLFWAPI int glfwOpenWindow( int width, int height,
|
|||||||
_glfwClearWindowHints();
|
_glfwClearWindowHints();
|
||||||
|
|
||||||
// Check input arguments
|
// Check input arguments
|
||||||
if( mode != GLFW_WINDOW && mode != GLFW_FULLSCREEN )
|
if (mode != GLFW_WINDOW && mode != GLFW_FULLSCREEN)
|
||||||
return GL_FALSE;
|
return GL_FALSE;
|
||||||
|
|
||||||
// Clear GLFW window state
|
// Clear GLFW window state
|
||||||
@ -485,17 +486,17 @@ GLFWAPI int glfwOpenWindow( int width, int height,
|
|||||||
_glfwWin.mouseWheelCallback = NULL;
|
_glfwWin.mouseWheelCallback = NULL;
|
||||||
|
|
||||||
// Check width & height
|
// Check width & height
|
||||||
if( width > 0 && height <= 0 )
|
if (width > 0 && height <= 0)
|
||||||
{
|
{
|
||||||
// Set the window aspect ratio to 4:3
|
// Set the window aspect ratio to 4:3
|
||||||
height = (width * 3) / 4;
|
height = (width * 3) / 4;
|
||||||
}
|
}
|
||||||
else if( width <= 0 && height > 0 )
|
else if (width <= 0 && height > 0)
|
||||||
{
|
{
|
||||||
// Set the window aspect ratio to 4:3
|
// Set the window aspect ratio to 4:3
|
||||||
width = (height * 4) / 3;
|
width = (height * 4) / 3;
|
||||||
}
|
}
|
||||||
else if( width <= 0 && height <= 0 )
|
else if (width <= 0 && height <= 0)
|
||||||
{
|
{
|
||||||
// Default window size
|
// Default window size
|
||||||
width = 640;
|
width = 640;
|
||||||
@ -508,7 +509,7 @@ GLFWAPI int glfwOpenWindow( int width, int height,
|
|||||||
_glfwWin.fullscreen = (mode == GLFW_FULLSCREEN ? GL_TRUE : GL_FALSE);
|
_glfwWin.fullscreen = (mode == GLFW_FULLSCREEN ? GL_TRUE : GL_FALSE);
|
||||||
|
|
||||||
// Platform specific window opening routine
|
// Platform specific window opening routine
|
||||||
if( !_glfwPlatformOpenWindow( width, height, &wndconfig, &fbconfig ) )
|
if (!_glfwPlatformOpenWindow(width, height, &wndconfig, &fbconfig))
|
||||||
return GL_FALSE;
|
return GL_FALSE;
|
||||||
|
|
||||||
// Flag that window is now opened
|
// Flag that window is now opened
|
||||||
@ -518,12 +519,12 @@ GLFWAPI int glfwOpenWindow( int width, int height,
|
|||||||
_glfwPlatformRefreshWindowParams();
|
_glfwPlatformRefreshWindowParams();
|
||||||
|
|
||||||
// Get OpenGL version
|
// Get OpenGL version
|
||||||
_glfwParseGLVersion( &_glfwWin.glMajor, &_glfwWin.glMinor,
|
_glfwParseGLVersion(&_glfwWin.glMajor, &_glfwWin.glMinor,
|
||||||
&_glfwWin.glRevision );
|
&_glfwWin.glRevision);
|
||||||
|
|
||||||
if( _glfwWin.glMajor < wndconfig.glMajor ||
|
if (_glfwWin.glMajor < wndconfig.glMajor ||
|
||||||
( _glfwWin.glMajor == wndconfig.glMajor &&
|
(_glfwWin.glMajor == wndconfig.glMajor &&
|
||||||
_glfwWin.glMinor < wndconfig.glMinor ) )
|
_glfwWin.glMinor < wndconfig.glMinor))
|
||||||
{
|
{
|
||||||
_glfwPlatformCloseWindow();
|
_glfwPlatformCloseWindow();
|
||||||
return GL_FALSE;
|
return GL_FALSE;
|
||||||
@ -531,18 +532,18 @@ GLFWAPI int glfwOpenWindow( int width, int height,
|
|||||||
|
|
||||||
// Do we have non-power-of-two textures (added to core in version 2.0)?
|
// Do we have non-power-of-two textures (added to core in version 2.0)?
|
||||||
_glfwWin.has_GL_ARB_texture_non_power_of_two =
|
_glfwWin.has_GL_ARB_texture_non_power_of_two =
|
||||||
( _glfwWin.glMajor >= 2 ) ||
|
(_glfwWin.glMajor >= 2) ||
|
||||||
glfwExtensionSupported( "GL_ARB_texture_non_power_of_two" );
|
glfwExtensionSupported("GL_ARB_texture_non_power_of_two");
|
||||||
|
|
||||||
// Do we have automatic mipmap generation (added to core in version 1.4)?
|
// Do we have automatic mipmap generation (added to core in version 1.4)?
|
||||||
_glfwWin.has_GL_SGIS_generate_mipmap =
|
_glfwWin.has_GL_SGIS_generate_mipmap =
|
||||||
( _glfwWin.glMajor >= 2 ) || ( _glfwWin.glMinor >= 4 ) ||
|
(_glfwWin.glMajor >= 2) || (_glfwWin.glMinor >= 4) ||
|
||||||
glfwExtensionSupported( "GL_SGIS_generate_mipmap" );
|
glfwExtensionSupported("GL_SGIS_generate_mipmap");
|
||||||
|
|
||||||
if( _glfwWin.glMajor > 2 )
|
if (_glfwWin.glMajor > 2)
|
||||||
{
|
{
|
||||||
_glfwWin.GetStringi = (PFNGLGETSTRINGIPROC) glfwGetProcAddress( "glGetStringi" );
|
_glfwWin.GetStringi = (PFNGLGETSTRINGIPROC) glfwGetProcAddress("glGetStringi");
|
||||||
if( !_glfwWin.GetStringi )
|
if (!_glfwWin.GetStringi)
|
||||||
{
|
{
|
||||||
_glfwPlatformCloseWindow();
|
_glfwPlatformCloseWindow();
|
||||||
return GL_FALSE;
|
return GL_FALSE;
|
||||||
@ -550,12 +551,12 @@ GLFWAPI int glfwOpenWindow( int width, int height,
|
|||||||
}
|
}
|
||||||
|
|
||||||
// If full-screen mode was requested, disable mouse cursor
|
// If full-screen mode was requested, disable mouse cursor
|
||||||
if( mode == GLFW_FULLSCREEN )
|
if (mode == GLFW_FULLSCREEN)
|
||||||
glfwDisable( GLFW_MOUSE_CURSOR );
|
glfwDisable(GLFW_MOUSE_CURSOR);
|
||||||
|
|
||||||
// Start by clearing the front buffer to black (avoid ugly desktop
|
// Start by clearing the front buffer to black (avoid ugly desktop
|
||||||
// remains in our OpenGL window)
|
// remains in our OpenGL window)
|
||||||
glClear( GL_COLOR_BUFFER_BIT );
|
glClear(GL_COLOR_BUFFER_BIT);
|
||||||
_glfwPlatformSwapBuffers();
|
_glfwPlatformSwapBuffers();
|
||||||
|
|
||||||
return GL_TRUE;
|
return GL_TRUE;
|
||||||
@ -566,13 +567,12 @@ GLFWAPI int glfwOpenWindow( int width, int height,
|
|||||||
// Set hints for opening the window
|
// Set hints for opening the window
|
||||||
//========================================================================
|
//========================================================================
|
||||||
|
|
||||||
GLFWAPI void glfwOpenWindowHint( int target, int hint )
|
GLFWAPI void glfwOpenWindowHint(int target, int hint)
|
||||||
{
|
{
|
||||||
// Is GLFW initialized?
|
if (!_glfwInitialized)
|
||||||
if( !_glfwInitialized )
|
|
||||||
return;
|
return;
|
||||||
|
|
||||||
switch( target )
|
switch (target)
|
||||||
{
|
{
|
||||||
case GLFW_REFRESH_RATE:
|
case GLFW_REFRESH_RATE:
|
||||||
_glfwLibrary.hints.refreshRate = hint;
|
_glfwLibrary.hints.refreshRate = hint;
|
||||||
@ -626,17 +626,17 @@ GLFWAPI void glfwOpenWindowHint( int target, int hint )
|
|||||||
// Properly kill the window / video display
|
// Properly kill the window / video display
|
||||||
//========================================================================
|
//========================================================================
|
||||||
|
|
||||||
GLFWAPI void glfwCloseWindow( void )
|
GLFWAPI void glfwCloseWindow(void)
|
||||||
{
|
{
|
||||||
if( !_glfwInitialized )
|
if (!_glfwInitialized)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
// Show mouse pointer again (if hidden)
|
// Show mouse pointer again (if hidden)
|
||||||
glfwEnable( GLFW_MOUSE_CURSOR );
|
glfwEnable(GLFW_MOUSE_CURSOR);
|
||||||
|
|
||||||
_glfwPlatformCloseWindow();
|
_glfwPlatformCloseWindow();
|
||||||
|
|
||||||
memset( &_glfwWin, 0, sizeof(_glfwWin) );
|
memset(&_glfwWin, 0, sizeof(_glfwWin));
|
||||||
_glfwWin.opened = GL_FALSE;
|
_glfwWin.opened = GL_FALSE;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -645,13 +645,13 @@ GLFWAPI void glfwCloseWindow( void )
|
|||||||
// Set the window title
|
// Set the window title
|
||||||
//========================================================================
|
//========================================================================
|
||||||
|
|
||||||
GLFWAPI void glfwSetWindowTitle( const char *title )
|
GLFWAPI void glfwSetWindowTitle(const char *title)
|
||||||
{
|
{
|
||||||
if( !_glfwInitialized || !_glfwWin.opened )
|
if (!_glfwInitialized || !_glfwWin.opened)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
// Set window title
|
// Set window title
|
||||||
_glfwPlatformSetWindowTitle( title );
|
_glfwPlatformSetWindowTitle(title);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -659,12 +659,12 @@ GLFWAPI void glfwSetWindowTitle( const char *title )
|
|||||||
// Get the window size
|
// Get the window size
|
||||||
//========================================================================
|
//========================================================================
|
||||||
|
|
||||||
GLFWAPI void glfwGetWindowSize( int *width, int *height )
|
GLFWAPI void glfwGetWindowSize(int *width, int *height)
|
||||||
{
|
{
|
||||||
if( width != NULL )
|
if (width != NULL)
|
||||||
*width = _glfwWin.width;
|
*width = _glfwWin.width;
|
||||||
|
|
||||||
if( height != NULL )
|
if (height != NULL)
|
||||||
*height = _glfwWin.height;
|
*height = _glfwWin.height;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -673,17 +673,17 @@ GLFWAPI void glfwGetWindowSize( int *width, int *height )
|
|||||||
// Set the window size
|
// Set the window size
|
||||||
//========================================================================
|
//========================================================================
|
||||||
|
|
||||||
GLFWAPI void glfwSetWindowSize( int width, int height )
|
GLFWAPI void glfwSetWindowSize(int width, int height)
|
||||||
{
|
{
|
||||||
if( !_glfwInitialized || !_glfwWin.opened || _glfwWin.iconified )
|
if (!_glfwInitialized || !_glfwWin.opened || _glfwWin.iconified)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
// Don't do anything if the window size did not change
|
// Don't do anything if the window size did not change
|
||||||
if( width == _glfwWin.width && height == _glfwWin.height )
|
if (width == _glfwWin.width && height == _glfwWin.height)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
// Change window size
|
// Change window size
|
||||||
_glfwPlatformSetWindowSize( width, height );
|
_glfwPlatformSetWindowSize(width, height);
|
||||||
|
|
||||||
// Refresh window parameters (may have changed due to changed video
|
// Refresh window parameters (may have changed due to changed video
|
||||||
// modes)
|
// modes)
|
||||||
@ -695,16 +695,16 @@ GLFWAPI void glfwSetWindowSize( int width, int height )
|
|||||||
// Set the window position
|
// Set the window position
|
||||||
//========================================================================
|
//========================================================================
|
||||||
|
|
||||||
GLFWAPI void glfwSetWindowPos( int x, int y )
|
GLFWAPI void glfwSetWindowPos(int x, int y)
|
||||||
{
|
{
|
||||||
if( !_glfwInitialized || !_glfwWin.opened || _glfwWin.fullscreen ||
|
if (!_glfwInitialized || !_glfwWin.opened || _glfwWin.fullscreen ||
|
||||||
_glfwWin.iconified )
|
_glfwWin.iconified)
|
||||||
{
|
{
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Set window position
|
// Set window position
|
||||||
_glfwPlatformSetWindowPos( x, y );
|
_glfwPlatformSetWindowPos(x, y);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -712,9 +712,9 @@ GLFWAPI void glfwSetWindowPos( int x, int y )
|
|||||||
// Window iconification
|
// Window iconification
|
||||||
//========================================================================
|
//========================================================================
|
||||||
|
|
||||||
GLFWAPI void glfwIconifyWindow( void )
|
GLFWAPI void glfwIconifyWindow(void)
|
||||||
{
|
{
|
||||||
if( !_glfwInitialized || !_glfwWin.opened || _glfwWin.iconified )
|
if (!_glfwInitialized || !_glfwWin.opened || _glfwWin.iconified)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
// Iconify window
|
// Iconify window
|
||||||
@ -726,9 +726,9 @@ GLFWAPI void glfwIconifyWindow( void )
|
|||||||
// Window un-iconification
|
// Window un-iconification
|
||||||
//========================================================================
|
//========================================================================
|
||||||
|
|
||||||
GLFWAPI void glfwRestoreWindow( void )
|
GLFWAPI void glfwRestoreWindow(void)
|
||||||
{
|
{
|
||||||
if( !_glfwInitialized || !_glfwWin.opened || !_glfwWin.iconified )
|
if (!_glfwInitialized || !_glfwWin.opened || !_glfwWin.iconified)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
// Restore iconified window
|
// Restore iconified window
|
||||||
@ -743,17 +743,17 @@ GLFWAPI void glfwRestoreWindow( void )
|
|||||||
// Swap buffers (double-buffering) and poll any new events
|
// Swap buffers (double-buffering) and poll any new events
|
||||||
//========================================================================
|
//========================================================================
|
||||||
|
|
||||||
GLFWAPI void glfwSwapBuffers( void )
|
GLFWAPI void glfwSwapBuffers(void)
|
||||||
{
|
{
|
||||||
if( !_glfwInitialized || !_glfwWin.opened )
|
if (!_glfwInitialized || !_glfwWin.opened)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
// Update display-buffer
|
// Update display-buffer
|
||||||
if( _glfwWin.opened )
|
if (_glfwWin.opened)
|
||||||
_glfwPlatformSwapBuffers();
|
_glfwPlatformSwapBuffers();
|
||||||
|
|
||||||
// Check for window messages
|
// Check for window messages
|
||||||
if( _glfwWin.autoPollEvents )
|
if (_glfwWin.autoPollEvents)
|
||||||
glfwPollEvents();
|
glfwPollEvents();
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -762,13 +762,13 @@ GLFWAPI void glfwSwapBuffers( void )
|
|||||||
// Set double buffering swap interval (0 = vsync off)
|
// Set double buffering swap interval (0 = vsync off)
|
||||||
//========================================================================
|
//========================================================================
|
||||||
|
|
||||||
GLFWAPI void glfwSwapInterval( int interval )
|
GLFWAPI void glfwSwapInterval(int interval)
|
||||||
{
|
{
|
||||||
if( !_glfwInitialized || !_glfwWin.opened )
|
if (!_glfwInitialized || !_glfwWin.opened)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
// Set double buffering swap interval
|
// Set double buffering swap interval
|
||||||
_glfwPlatformSwapInterval( interval );
|
_glfwPlatformSwapInterval(interval);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -776,21 +776,21 @@ GLFWAPI void glfwSwapInterval( int interval )
|
|||||||
// Get window parameter
|
// Get window parameter
|
||||||
//========================================================================
|
//========================================================================
|
||||||
|
|
||||||
GLFWAPI int glfwGetWindowParam( int param )
|
GLFWAPI int glfwGetWindowParam(int param)
|
||||||
{
|
{
|
||||||
if( !_glfwInitialized )
|
if (!_glfwInitialized)
|
||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
if( !_glfwWin.opened )
|
if (!_glfwWin.opened)
|
||||||
{
|
{
|
||||||
if( param == GLFW_OPENED )
|
if (param == GLFW_OPENED)
|
||||||
return GL_FALSE;
|
return GL_FALSE;
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Window parameters
|
// Window parameters
|
||||||
switch( param )
|
switch (param)
|
||||||
{
|
{
|
||||||
case GLFW_OPENED:
|
case GLFW_OPENED:
|
||||||
return GL_TRUE;
|
return GL_TRUE;
|
||||||
@ -850,9 +850,9 @@ GLFWAPI int glfwGetWindowParam( int param )
|
|||||||
// Set callback function for window size changes
|
// Set callback function for window size changes
|
||||||
//========================================================================
|
//========================================================================
|
||||||
|
|
||||||
GLFWAPI void glfwSetWindowSizeCallback( GLFWwindowsizefun cbfun )
|
GLFWAPI void glfwSetWindowSizeCallback(GLFWwindowsizefun cbfun)
|
||||||
{
|
{
|
||||||
if( !_glfwInitialized || !_glfwWin.opened )
|
if (!_glfwInitialized || !_glfwWin.opened)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
// Set callback function
|
// Set callback function
|
||||||
@ -860,17 +860,17 @@ GLFWAPI void glfwSetWindowSizeCallback( GLFWwindowsizefun cbfun )
|
|||||||
|
|
||||||
// Call the callback function to let the application know the current
|
// Call the callback function to let the application know the current
|
||||||
// window size
|
// window size
|
||||||
if( cbfun )
|
if (cbfun)
|
||||||
cbfun( _glfwWin.width, _glfwWin.height );
|
cbfun(_glfwWin.width, _glfwWin.height);
|
||||||
}
|
}
|
||||||
|
|
||||||
//========================================================================
|
//========================================================================
|
||||||
// Set callback function for window close events
|
// Set callback function for window close events
|
||||||
//========================================================================
|
//========================================================================
|
||||||
|
|
||||||
GLFWAPI void glfwSetWindowCloseCallback( GLFWwindowclosefun cbfun )
|
GLFWAPI void glfwSetWindowCloseCallback(GLFWwindowclosefun cbfun)
|
||||||
{
|
{
|
||||||
if( !_glfwInitialized || !_glfwWin.opened )
|
if (!_glfwInitialized || !_glfwWin.opened)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
// Set callback function
|
// Set callback function
|
||||||
@ -882,9 +882,9 @@ GLFWAPI void glfwSetWindowCloseCallback( GLFWwindowclosefun cbfun )
|
|||||||
// Set callback function for window refresh events
|
// Set callback function for window refresh events
|
||||||
//========================================================================
|
//========================================================================
|
||||||
|
|
||||||
GLFWAPI void glfwSetWindowRefreshCallback( GLFWwindowrefreshfun cbfun )
|
GLFWAPI void glfwSetWindowRefreshCallback(GLFWwindowrefreshfun cbfun)
|
||||||
{
|
{
|
||||||
if( !_glfwInitialized || !_glfwWin.opened )
|
if (!_glfwInitialized || !_glfwWin.opened)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
// Set callback function
|
// Set callback function
|
||||||
@ -896,9 +896,9 @@ GLFWAPI void glfwSetWindowRefreshCallback( GLFWwindowrefreshfun cbfun )
|
|||||||
// Poll for new window and input events
|
// Poll for new window and input events
|
||||||
//========================================================================
|
//========================================================================
|
||||||
|
|
||||||
GLFWAPI void glfwPollEvents( void )
|
GLFWAPI void glfwPollEvents(void)
|
||||||
{
|
{
|
||||||
if( !_glfwInitialized || !_glfwWin.opened )
|
if (!_glfwInitialized || !_glfwWin.opened)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
// Poll for new events
|
// Poll for new events
|
||||||
@ -910,9 +910,9 @@ GLFWAPI void glfwPollEvents( void )
|
|||||||
// Wait for new window and input events
|
// Wait for new window and input events
|
||||||
//========================================================================
|
//========================================================================
|
||||||
|
|
||||||
GLFWAPI void glfwWaitEvents( void )
|
GLFWAPI void glfwWaitEvents(void)
|
||||||
{
|
{
|
||||||
if( !_glfwInitialized || !_glfwWin.opened )
|
if (!_glfwInitialized || !_glfwWin.opened)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
// Poll for new events
|
// Poll for new events
|
||||||
|
Loading…
Reference in New Issue
Block a user