mirror of
https://github.com/gwm17/glfw.git
synced 2024-11-23 10:48:51 -05:00
Merge branch 'master' of github.com:elmindreda/glfw
Conflicts: src/win32_window.c
This commit is contained in:
commit
ca9633247b
2
.gitignore
vendored
2
.gitignore
vendored
|
@ -4,6 +4,7 @@ CMakeCache.txt
|
||||||
Makefile
|
Makefile
|
||||||
cmake_uninstall.cmake
|
cmake_uninstall.cmake
|
||||||
.DS_Store
|
.DS_Store
|
||||||
|
docs/Doxyfile
|
||||||
src/config.h
|
src/config.h
|
||||||
src/libglfw.pc
|
src/libglfw.pc
|
||||||
src/libglfw.so
|
src/libglfw.so
|
||||||
|
@ -32,6 +33,7 @@ tests/peter
|
||||||
tests/reopen
|
tests/reopen
|
||||||
tests/sharing
|
tests/sharing
|
||||||
tests/tearing
|
tests/tearing
|
||||||
|
tests/title
|
||||||
tests/windows
|
tests/windows
|
||||||
tests/*.app
|
tests/*.app
|
||||||
tests/*.exe
|
tests/*.exe
|
||||||
|
|
|
@ -569,7 +569,7 @@ int main( void )
|
||||||
GLFWwindow window;
|
GLFWwindow window;
|
||||||
|
|
||||||
/* Init GLFW */
|
/* Init GLFW */
|
||||||
if( !glfwInit(NULL) )
|
if( !glfwInit() )
|
||||||
{
|
{
|
||||||
fprintf( stderr, "Failed to initialize GLFW\n" );
|
fprintf( stderr, "Failed to initialize GLFW\n" );
|
||||||
exit( EXIT_FAILURE );
|
exit( EXIT_FAILURE );
|
||||||
|
|
|
@ -323,7 +323,7 @@ int main(int argc, char *argv[])
|
||||||
{
|
{
|
||||||
GLFWwindow window;
|
GLFWwindow window;
|
||||||
|
|
||||||
if( !glfwInit(NULL) )
|
if( !glfwInit() )
|
||||||
{
|
{
|
||||||
fprintf( stderr, "Failed to initialize GLFW\n" );
|
fprintf( stderr, "Failed to initialize GLFW\n" );
|
||||||
exit( EXIT_FAILURE );
|
exit( EXIT_FAILURE );
|
||||||
|
|
|
@ -573,7 +573,7 @@ int main(int argc, char** argv)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!glfwInit(NULL))
|
if (!glfwInit())
|
||||||
{
|
{
|
||||||
fprintf(stderr, "ERROR: Unable to initialize GLFW\n");
|
fprintf(stderr, "ERROR: Unable to initialize GLFW\n");
|
||||||
usage();
|
usage();
|
||||||
|
|
|
@ -442,7 +442,7 @@ int main(void)
|
||||||
GLFWwindow window;
|
GLFWwindow window;
|
||||||
|
|
||||||
// Initialise GLFW
|
// Initialise GLFW
|
||||||
if (!glfwInit(NULL))
|
if (!glfwInit())
|
||||||
{
|
{
|
||||||
fprintf(stderr, "Failed to initialize GLFW\n");
|
fprintf(stderr, "Failed to initialize GLFW\n");
|
||||||
exit(EXIT_FAILURE);
|
exit(EXIT_FAILURE);
|
||||||
|
|
|
@ -15,7 +15,7 @@ int main(void)
|
||||||
GLFWwindow window;
|
GLFWwindow window;
|
||||||
|
|
||||||
// Initialise GLFW
|
// Initialise GLFW
|
||||||
if (!glfwInit(NULL))
|
if (!glfwInit())
|
||||||
{
|
{
|
||||||
fprintf(stderr, "Failed to initialize GLFW\n");
|
fprintf(stderr, "Failed to initialize GLFW\n");
|
||||||
exit(EXIT_FAILURE);
|
exit(EXIT_FAILURE);
|
||||||
|
|
|
@ -379,7 +379,7 @@ int main(int argc, char* argv[])
|
||||||
GLFWwindow window;
|
GLFWwindow window;
|
||||||
double t, dt_total, t_old;
|
double t, dt_total, t_old;
|
||||||
|
|
||||||
if (!glfwInit(NULL))
|
if (!glfwInit())
|
||||||
{
|
{
|
||||||
fprintf(stderr, "GLFW initialization failed\n");
|
fprintf(stderr, "GLFW initialization failed\n");
|
||||||
exit(EXIT_FAILURE);
|
exit(EXIT_FAILURE);
|
||||||
|
|
|
@ -478,8 +478,6 @@ typedef void (* GLFWmouseposfun)(GLFWwindow,int,int);
|
||||||
typedef void (* GLFWscrollfun)(GLFWwindow,int,int);
|
typedef void (* GLFWscrollfun)(GLFWwindow,int,int);
|
||||||
typedef void (* GLFWkeyfun)(GLFWwindow,int,int);
|
typedef void (* GLFWkeyfun)(GLFWwindow,int,int);
|
||||||
typedef void (* GLFWcharfun)(GLFWwindow,int);
|
typedef void (* GLFWcharfun)(GLFWwindow,int);
|
||||||
typedef void* (* GLFWmallocfun)(size_t);
|
|
||||||
typedef void (* GLFWfreefun)(void*);
|
|
||||||
|
|
||||||
/* The video mode structure used by glfwGetVideoModes */
|
/* The video mode structure used by glfwGetVideoModes */
|
||||||
typedef struct
|
typedef struct
|
||||||
|
@ -499,20 +497,13 @@ typedef struct
|
||||||
unsigned short blue[GLFW_GAMMA_RAMP_SIZE];
|
unsigned short blue[GLFW_GAMMA_RAMP_SIZE];
|
||||||
} GLFWgammaramp;
|
} GLFWgammaramp;
|
||||||
|
|
||||||
/* Custom memory allocator interface */
|
|
||||||
typedef struct
|
|
||||||
{
|
|
||||||
GLFWmallocfun malloc;
|
|
||||||
GLFWfreefun free;
|
|
||||||
} GLFWallocator;
|
|
||||||
|
|
||||||
|
|
||||||
/*************************************************************************
|
/*************************************************************************
|
||||||
* Prototypes
|
* Prototypes
|
||||||
*************************************************************************/
|
*************************************************************************/
|
||||||
|
|
||||||
/* Initialization, termination and version querying */
|
/* Initialization, termination and version querying */
|
||||||
GLFWAPI int glfwInit(GLFWallocator* allocator);
|
GLFWAPI int glfwInit(void);
|
||||||
GLFWAPI void glfwTerminate(void);
|
GLFWAPI void glfwTerminate(void);
|
||||||
GLFWAPI void glfwGetVersion(int* major, int* minor, int* rev);
|
GLFWAPI void glfwGetVersion(int* major, int* minor, int* rev);
|
||||||
GLFWAPI const char* glfwGetVersionString(void);
|
GLFWAPI const char* glfwGetVersionString(void);
|
||||||
|
|
|
@ -272,7 +272,6 @@ version of GLFW.</p>
|
||||||
<li>Added <code>glfwSetWindowFocusCallback</code> function and <code>GLFWwindowfocusfun</code> type for receiving window focus events</li>
|
<li>Added <code>glfwSetWindowFocusCallback</code> function and <code>GLFWwindowfocusfun</code> type for receiving window focus events</li>
|
||||||
<li>Added <code>glfwSetWindowIconifyCallback</code> function and <code>GLFWwindowiconifyfun</code> type for receiving window iconification events</li>
|
<li>Added <code>glfwSetWindowIconifyCallback</code> function and <code>GLFWwindowiconifyfun</code> type for receiving window iconification events</li>
|
||||||
<li>Added <code>glfwGetCurrentContext</code> function for retrieving the window whose OpenGL context is current</li>
|
<li>Added <code>glfwGetCurrentContext</code> function for retrieving the window whose OpenGL context is current</li>
|
||||||
<li>Added <code>GLFWallocator</code> type and <code>glfwInit</code> parameter for pluggable memory allocator</li>
|
|
||||||
<li>Added <code>glfwCopyContext</code> function for copying OpenGL state categories between contexts</li>
|
<li>Added <code>glfwCopyContext</code> function for copying OpenGL state categories between contexts</li>
|
||||||
<li>Added <code>GLFW_OPENGL_ES2_PROFILE</code> profile for creating OpenGL ES 2.0 contexts using the <code>GLX_EXT_create_context_es2_profile</code> and <code>WGL_EXT_create_context_es2_profile</code> extensions</li>
|
<li>Added <code>GLFW_OPENGL_ES2_PROFILE</code> profile for creating OpenGL ES 2.0 contexts using the <code>GLX_EXT_create_context_es2_profile</code> and <code>WGL_EXT_create_context_es2_profile</code> extensions</li>
|
||||||
<li>Added <code>GLFW_OPENGL_ROBUSTNESS</code> window hint and associated strategy tokens for <code>GL_ARB_robustness</code> support</li>
|
<li>Added <code>GLFW_OPENGL_ROBUSTNESS</code> window hint and associated strategy tokens for <code>GL_ARB_robustness</code> support</li>
|
||||||
|
|
|
@ -152,7 +152,7 @@ static void addJoystickElement(_glfwJoystick* joystick, CFTypeRef refElement)
|
||||||
long number;
|
long number;
|
||||||
CFTypeRef refType;
|
CFTypeRef refType;
|
||||||
|
|
||||||
_glfwJoystickElement* element = (_glfwJoystickElement*) _glfwMalloc(sizeof(_glfwJoystickElement));
|
_glfwJoystickElement* element = (_glfwJoystickElement*) malloc(sizeof(_glfwJoystickElement));
|
||||||
|
|
||||||
CFArrayAppendValue(elementsArray, element);
|
CFArrayAppendValue(elementsArray, element);
|
||||||
|
|
||||||
|
@ -242,7 +242,7 @@ static void removeJoystick(_glfwJoystick* joystick)
|
||||||
{
|
{
|
||||||
_glfwJoystickElement* axes =
|
_glfwJoystickElement* axes =
|
||||||
(_glfwJoystickElement*) CFArrayGetValueAtIndex(joystick->axes, i);
|
(_glfwJoystickElement*) CFArrayGetValueAtIndex(joystick->axes, i);
|
||||||
_glfwFree(axes);
|
free(axes);
|
||||||
}
|
}
|
||||||
CFArrayRemoveAllValues(joystick->axes);
|
CFArrayRemoveAllValues(joystick->axes);
|
||||||
joystick->numAxes = 0;
|
joystick->numAxes = 0;
|
||||||
|
@ -251,7 +251,7 @@ static void removeJoystick(_glfwJoystick* joystick)
|
||||||
{
|
{
|
||||||
_glfwJoystickElement* button =
|
_glfwJoystickElement* button =
|
||||||
(_glfwJoystickElement*) CFArrayGetValueAtIndex(joystick->buttons, i);
|
(_glfwJoystickElement*) CFArrayGetValueAtIndex(joystick->buttons, i);
|
||||||
_glfwFree(button);
|
free(button);
|
||||||
}
|
}
|
||||||
CFArrayRemoveAllValues(joystick->buttons);
|
CFArrayRemoveAllValues(joystick->buttons);
|
||||||
joystick->numButtons = 0;
|
joystick->numButtons = 0;
|
||||||
|
@ -260,7 +260,7 @@ static void removeJoystick(_glfwJoystick* joystick)
|
||||||
{
|
{
|
||||||
_glfwJoystickElement* hat =
|
_glfwJoystickElement* hat =
|
||||||
(_glfwJoystickElement*) CFArrayGetValueAtIndex(joystick->hats, i);
|
(_glfwJoystickElement*) CFArrayGetValueAtIndex(joystick->hats, i);
|
||||||
_glfwFree(hat);
|
free(hat);
|
||||||
}
|
}
|
||||||
CFArrayRemoveAllValues(joystick->hats);
|
CFArrayRemoveAllValues(joystick->hats);
|
||||||
joystick->hats = 0;
|
joystick->hats = 0;
|
||||||
|
|
44
src/init.c
44
src/init.c
|
@ -35,30 +35,6 @@
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
|
|
||||||
|
|
||||||
//////////////////////////////////////////////////////////////////////////
|
|
||||||
////// GLFW internal API //////
|
|
||||||
//////////////////////////////////////////////////////////////////////////
|
|
||||||
|
|
||||||
//========================================================================
|
|
||||||
// Allocate memory using the allocator
|
|
||||||
//========================================================================
|
|
||||||
|
|
||||||
void* _glfwMalloc(size_t size)
|
|
||||||
{
|
|
||||||
return _glfwLibrary.allocator.malloc(size);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
//========================================================================
|
|
||||||
// Free memory using the allocator
|
|
||||||
//========================================================================
|
|
||||||
|
|
||||||
void _glfwFree(void* ptr)
|
|
||||||
{
|
|
||||||
_glfwLibrary.allocator.free(ptr);
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
//////////////////////////////////////////////////////////////////////////
|
//////////////////////////////////////////////////////////////////////////
|
||||||
////// GLFW public API //////
|
////// GLFW public API //////
|
||||||
//////////////////////////////////////////////////////////////////////////
|
//////////////////////////////////////////////////////////////////////////
|
||||||
|
@ -67,31 +43,13 @@ void _glfwFree(void* ptr)
|
||||||
// Initialize various GLFW state
|
// Initialize various GLFW state
|
||||||
//========================================================================
|
//========================================================================
|
||||||
|
|
||||||
GLFWAPI int glfwInit(GLFWallocator* allocator)
|
GLFWAPI int glfwInit(void)
|
||||||
{
|
{
|
||||||
if (_glfwInitialized)
|
if (_glfwInitialized)
|
||||||
return GL_TRUE;
|
return GL_TRUE;
|
||||||
|
|
||||||
memset(&_glfwLibrary, 0, sizeof(_glfwLibrary));
|
memset(&_glfwLibrary, 0, sizeof(_glfwLibrary));
|
||||||
|
|
||||||
if (allocator)
|
|
||||||
{
|
|
||||||
// Verify that the specified model is complete
|
|
||||||
if (!allocator->malloc || !allocator->free)
|
|
||||||
{
|
|
||||||
_glfwSetError(GLFW_INVALID_VALUE, NULL);
|
|
||||||
return GL_FALSE;
|
|
||||||
}
|
|
||||||
|
|
||||||
_glfwLibrary.allocator = *allocator;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
// Use the libc malloc and free
|
|
||||||
_glfwLibrary.allocator.malloc = malloc;
|
|
||||||
_glfwLibrary.allocator.free = free;
|
|
||||||
}
|
|
||||||
|
|
||||||
// Not all window hints have zero as their default value, so this
|
// Not all window hints have zero as their default value, so this
|
||||||
// needs to be here despite the memset above
|
// needs to be here despite the memset above
|
||||||
_glfwSetDefaultWindowHints();
|
_glfwSetDefaultWindowHints();
|
||||||
|
|
|
@ -37,9 +37,9 @@
|
||||||
//========================================================================
|
//========================================================================
|
||||||
|
|
||||||
#if defined(_init_c_)
|
#if defined(_init_c_)
|
||||||
#define GLFWGLOBAL
|
#define GLFWGLOBAL
|
||||||
#else
|
#else
|
||||||
#define GLFWGLOBAL extern
|
#define GLFWGLOBAL extern
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
|
||||||
|
@ -66,13 +66,13 @@
|
||||||
#include "../support/GL/glext.h"
|
#include "../support/GL/glext.h"
|
||||||
|
|
||||||
#if defined(_GLFW_COCOA_NSGL)
|
#if defined(_GLFW_COCOA_NSGL)
|
||||||
#include "cocoa_platform.h"
|
#include "cocoa_platform.h"
|
||||||
#elif defined(_GLFW_WIN32_WGL)
|
#elif defined(_GLFW_WIN32_WGL)
|
||||||
#include "win32_platform.h"
|
#include "win32_platform.h"
|
||||||
#elif defined(_GLFW_X11_GLX)
|
#elif defined(_GLFW_X11_GLX)
|
||||||
#include "x11_platform.h"
|
#include "x11_platform.h"
|
||||||
#else
|
#else
|
||||||
#error "No supported platform selected"
|
#error "No supported platform selected"
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
typedef struct _GLFWhints _GLFWhints;
|
typedef struct _GLFWhints _GLFWhints;
|
||||||
|
@ -241,8 +241,6 @@ struct _GLFWlibrary
|
||||||
GLFWkeyfun keyCallback;
|
GLFWkeyfun keyCallback;
|
||||||
GLFWcharfun charCallback;
|
GLFWcharfun charCallback;
|
||||||
|
|
||||||
GLFWallocator allocator;
|
|
||||||
|
|
||||||
GLFWgammaramp currentRamp;
|
GLFWgammaramp currentRamp;
|
||||||
GLFWgammaramp originalRamp;
|
GLFWgammaramp originalRamp;
|
||||||
int originalRampSize;
|
int originalRampSize;
|
||||||
|
@ -325,10 +323,6 @@ void _glfwPlatformCopyContext(_GLFWwindow* src, _GLFWwindow* dst, unsigned long
|
||||||
// Prototypes for platform independent internal functions
|
// Prototypes for platform independent internal functions
|
||||||
//========================================================================
|
//========================================================================
|
||||||
|
|
||||||
// Memory management (init.c)
|
|
||||||
void* _glfwMalloc(size_t size);
|
|
||||||
void _glfwFree(void* ptr);
|
|
||||||
|
|
||||||
// Fullscren management (fullscreen.c)
|
// Fullscren management (fullscreen.c)
|
||||||
void _glfwSplitBPP(int bpp, int* red, int* green, int* blue);
|
void _glfwSplitBPP(int bpp, int* red, int* green, int* blue);
|
||||||
|
|
||||||
|
|
|
@ -148,11 +148,11 @@ WCHAR* _glfwCreateWideStringFromUTF8(const char* source)
|
||||||
if (!length)
|
if (!length)
|
||||||
return NULL;
|
return NULL;
|
||||||
|
|
||||||
target = (WCHAR*) _glfwMalloc(sizeof(WCHAR) * (length + 1));
|
target = (WCHAR*) malloc(sizeof(WCHAR) * (length + 1));
|
||||||
|
|
||||||
if (!MultiByteToWideChar(CP_UTF8, 0, source, -1, target, length + 1))
|
if (!MultiByteToWideChar(CP_UTF8, 0, source, -1, target, length + 1))
|
||||||
{
|
{
|
||||||
_glfwFree(target);
|
free(target);
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -173,11 +173,11 @@ char* _glfwCreateUTF8FromWideString(const WCHAR* source)
|
||||||
if (!length)
|
if (!length)
|
||||||
return NULL;
|
return NULL;
|
||||||
|
|
||||||
target = (char*) _glfwMalloc(length + 1);
|
target = (char*) malloc(length + 1);
|
||||||
|
|
||||||
if (!WideCharToMultiByte(CP_UTF8, 0, source, -1, target, length + 1, NULL, NULL))
|
if (!WideCharToMultiByte(CP_UTF8, 0, source, -1, target, length + 1, NULL, NULL))
|
||||||
{
|
{
|
||||||
_glfwFree(target);
|
free(target);
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -195,7 +195,7 @@ static _GLFWfbconfig* getFBConfigs(_GLFWwindow* window, unsigned int* found)
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
result = (_GLFWfbconfig*) _glfwMalloc(sizeof(_GLFWfbconfig) * count);
|
result = (_GLFWfbconfig*) malloc(sizeof(_GLFWfbconfig) * count);
|
||||||
if (!result)
|
if (!result)
|
||||||
{
|
{
|
||||||
_glfwSetError(GLFW_OUT_OF_MEMORY,
|
_glfwSetError(GLFW_OUT_OF_MEMORY,
|
||||||
|
@ -1257,13 +1257,13 @@ static int choosePixelFormat(_GLFWwindow* window, const _GLFWfbconfig* fbconfig)
|
||||||
closest = _glfwChooseFBConfig(fbconfig, fbconfigs, fbcount);
|
closest = _glfwChooseFBConfig(fbconfig, fbconfigs, fbcount);
|
||||||
if (!closest)
|
if (!closest)
|
||||||
{
|
{
|
||||||
_glfwFree(fbconfigs);
|
free(fbconfigs);
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
pixelFormat = (int) closest->platformID;
|
pixelFormat = (int) closest->platformID;
|
||||||
|
|
||||||
_glfwFree(fbconfigs);
|
free(fbconfigs);
|
||||||
fbconfigs = NULL;
|
fbconfigs = NULL;
|
||||||
closest = NULL;
|
closest = NULL;
|
||||||
|
|
||||||
|
@ -1358,7 +1358,7 @@ static int createWindow(_GLFWwindow* window,
|
||||||
return GL_FALSE;
|
return GL_FALSE;
|
||||||
}
|
}
|
||||||
|
|
||||||
_glfwFree(wideTitle);
|
free(wideTitle);
|
||||||
|
|
||||||
window->WGL.DC = GetDC(window->Win32.handle);
|
window->WGL.DC = GetDC(window->Win32.handle);
|
||||||
if (!window->WGL.DC)
|
if (!window->WGL.DC)
|
||||||
|
@ -1589,7 +1589,7 @@ void _glfwPlatformSetWindowTitle(_GLFWwindow* window, const char* title)
|
||||||
|
|
||||||
SetWindowText(window->Win32.handle, wideTitle);
|
SetWindowText(window->Win32.handle, wideTitle);
|
||||||
|
|
||||||
_glfwFree(wideTitle);
|
free(wideTitle);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -291,7 +291,7 @@ GLFWAPI GLFWwindow glfwOpenWindow(int width, int height,
|
||||||
height = 480;
|
height = 480;
|
||||||
}
|
}
|
||||||
|
|
||||||
window = (_GLFWwindow*) _glfwMalloc(sizeof(_GLFWwindow));
|
window = (_GLFWwindow*) malloc(sizeof(_GLFWwindow));
|
||||||
if (!window)
|
if (!window)
|
||||||
{
|
{
|
||||||
_glfwSetError(GLFW_OUT_OF_MEMORY,
|
_glfwSetError(GLFW_OUT_OF_MEMORY,
|
||||||
|
@ -492,7 +492,7 @@ GLFWAPI void glfwCloseWindow(GLFWwindow handle)
|
||||||
*prev = window->next;
|
*prev = window->next;
|
||||||
}
|
}
|
||||||
|
|
||||||
_glfwFree(window);
|
free(window);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -339,7 +339,7 @@ int _glfwPlatformGetVideoModes(GLFWvidmode* list, int maxcount)
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
rgbarray = (int*) _glfwMalloc(sizeof(int) * viscount);
|
rgbarray = (int*) malloc(sizeof(int) * viscount);
|
||||||
rgbcount = 0;
|
rgbcount = 0;
|
||||||
|
|
||||||
// Build RGB array
|
// Build RGB array
|
||||||
|
@ -387,7 +387,7 @@ int _glfwPlatformGetVideoModes(GLFWvidmode* list, int maxcount)
|
||||||
sc = XRRGetScreenInfo(_glfwLibrary.X11.display, _glfwLibrary.X11.root);
|
sc = XRRGetScreenInfo(_glfwLibrary.X11.display, _glfwLibrary.X11.root);
|
||||||
sizelist = XRRConfigSizes(sc, &sizecount);
|
sizelist = XRRConfigSizes(sc, &sizecount);
|
||||||
|
|
||||||
resarray = (struct _glfwResolution*) _glfwMalloc(sizeof(struct _glfwResolution) * sizecount);
|
resarray = (struct _glfwResolution*) malloc(sizeof(struct _glfwResolution) * sizecount);
|
||||||
|
|
||||||
for (k = 0; k < sizecount; k++)
|
for (k = 0; k < sizecount; k++)
|
||||||
{
|
{
|
||||||
|
@ -407,7 +407,7 @@ int _glfwPlatformGetVideoModes(GLFWvidmode* list, int maxcount)
|
||||||
|
|
||||||
XF86VidModeGetAllModeLines(_glfwLibrary.X11.display, screen, &modecount, &modelist);
|
XF86VidModeGetAllModeLines(_glfwLibrary.X11.display, screen, &modecount, &modelist);
|
||||||
|
|
||||||
resarray = (struct _glfwResolution*) _glfwMalloc(sizeof(struct _glfwResolution) * modecount);
|
resarray = (struct _glfwResolution*) malloc(sizeof(struct _glfwResolution) * modecount);
|
||||||
|
|
||||||
for (k = 0; k < modecount; k++)
|
for (k = 0; k < modecount; k++)
|
||||||
{
|
{
|
||||||
|
@ -436,7 +436,7 @@ int _glfwPlatformGetVideoModes(GLFWvidmode* list, int maxcount)
|
||||||
if (!resarray)
|
if (!resarray)
|
||||||
{
|
{
|
||||||
rescount = 1;
|
rescount = 1;
|
||||||
resarray = (struct _glfwResolution*) _glfwMalloc(sizeof(struct _glfwResolution) * rescount);
|
resarray = (struct _glfwResolution*) malloc(sizeof(struct _glfwResolution) * rescount);
|
||||||
|
|
||||||
resarray[0].width = DisplayWidth(_glfwLibrary.X11.display, screen);
|
resarray[0].width = DisplayWidth(_glfwLibrary.X11.display, screen);
|
||||||
resarray[0].height = DisplayHeight(_glfwLibrary.X11.display, screen);
|
resarray[0].height = DisplayHeight(_glfwLibrary.X11.display, screen);
|
||||||
|
@ -459,8 +459,8 @@ int _glfwPlatformGetVideoModes(GLFWvidmode* list, int maxcount)
|
||||||
|
|
||||||
XFree(vislist);
|
XFree(vislist);
|
||||||
|
|
||||||
_glfwFree(resarray);
|
free(resarray);
|
||||||
_glfwFree(rgbarray);
|
free(rgbarray);
|
||||||
|
|
||||||
return count;
|
return count;
|
||||||
}
|
}
|
||||||
|
|
|
@ -316,7 +316,7 @@ static _GLFWfbconfig* getFBConfigs(_GLFWwindow* window, unsigned int* found)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
result = (_GLFWfbconfig*) _glfwMalloc(sizeof(_GLFWfbconfig) * count);
|
result = (_GLFWfbconfig*) malloc(sizeof(_GLFWfbconfig) * count);
|
||||||
if (!result)
|
if (!result)
|
||||||
{
|
{
|
||||||
_glfwSetError(GLFW_OUT_OF_MEMORY,
|
_glfwSetError(GLFW_OUT_OF_MEMORY,
|
||||||
|
@ -1415,12 +1415,12 @@ int _glfwPlatformOpenWindow(_GLFWwindow* window,
|
||||||
result = _glfwChooseFBConfig(fbconfig, fbconfigs, fbcount);
|
result = _glfwChooseFBConfig(fbconfig, fbconfigs, fbcount);
|
||||||
if (!result)
|
if (!result)
|
||||||
{
|
{
|
||||||
_glfwFree(fbconfigs);
|
free(fbconfigs);
|
||||||
return GL_FALSE;
|
return GL_FALSE;
|
||||||
}
|
}
|
||||||
|
|
||||||
closest = *result;
|
closest = *result;
|
||||||
_glfwFree(fbconfigs);
|
free(fbconfigs);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!createContext(window, wndconfig, (GLXFBConfigID) closest.platformID))
|
if (!createContext(window, wndconfig, (GLXFBConfigID) closest.platformID))
|
||||||
|
|
|
@ -59,7 +59,7 @@ int main(void)
|
||||||
{
|
{
|
||||||
GLFWwindow window;
|
GLFWwindow window;
|
||||||
|
|
||||||
if (!glfwInit(NULL))
|
if (!glfwInit())
|
||||||
{
|
{
|
||||||
fprintf(stderr, "Failed to initialize GLFW: %s\n", glfwErrorString(glfwGetError()));
|
fprintf(stderr, "Failed to initialize GLFW: %s\n", glfwErrorString(glfwGetError()));
|
||||||
exit(EXIT_FAILURE);
|
exit(EXIT_FAILURE);
|
||||||
|
|
|
@ -69,7 +69,7 @@ int main(void)
|
||||||
int i, width, height;
|
int i, width, height;
|
||||||
GLFWwindow window;
|
GLFWwindow window;
|
||||||
|
|
||||||
if (!glfwInit(NULL))
|
if (!glfwInit())
|
||||||
{
|
{
|
||||||
fprintf(stderr, "Failed to initialize GLFW: %s\n", glfwErrorString(glfwGetError()));
|
fprintf(stderr, "Failed to initialize GLFW: %s\n", glfwErrorString(glfwGetError()));
|
||||||
exit(EXIT_FAILURE);
|
exit(EXIT_FAILURE);
|
||||||
|
|
|
@ -59,7 +59,7 @@ int main(void)
|
||||||
exit(EXIT_FAILURE);
|
exit(EXIT_FAILURE);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!glfwInit(NULL))
|
if (!glfwInit())
|
||||||
{
|
{
|
||||||
fprintf(stderr, "Failed to initialize GLFW\n");
|
fprintf(stderr, "Failed to initialize GLFW\n");
|
||||||
exit(EXIT_FAILURE);
|
exit(EXIT_FAILURE);
|
||||||
|
|
|
@ -330,7 +330,7 @@ int main(void)
|
||||||
|
|
||||||
setlocale(LC_ALL, "");
|
setlocale(LC_ALL, "");
|
||||||
|
|
||||||
if (!glfwInit(NULL))
|
if (!glfwInit())
|
||||||
{
|
{
|
||||||
fprintf(stderr, "Failed to initialize GLFW: %s\n", glfwErrorString(glfwGetError()));
|
fprintf(stderr, "Failed to initialize GLFW: %s\n", glfwErrorString(glfwGetError()));
|
||||||
exit(EXIT_FAILURE);
|
exit(EXIT_FAILURE);
|
||||||
|
|
|
@ -81,7 +81,7 @@ int main(int argc, char** argv)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!glfwInit(NULL))
|
if (!glfwInit())
|
||||||
{
|
{
|
||||||
fprintf(stderr, "Failed to initialize GLFW: %s\n", glfwErrorString(glfwGetError()));
|
fprintf(stderr, "Failed to initialize GLFW: %s\n", glfwErrorString(glfwGetError()));
|
||||||
exit(EXIT_FAILURE);
|
exit(EXIT_FAILURE);
|
||||||
|
|
|
@ -75,7 +75,7 @@ int main(void)
|
||||||
{
|
{
|
||||||
GLFWwindow window;
|
GLFWwindow window;
|
||||||
|
|
||||||
if (!glfwInit(NULL))
|
if (!glfwInit())
|
||||||
{
|
{
|
||||||
fprintf(stderr, "Failed to initialize GLFW: %s\n", glfwErrorString(glfwGetError()));
|
fprintf(stderr, "Failed to initialize GLFW: %s\n", glfwErrorString(glfwGetError()));
|
||||||
exit(EXIT_FAILURE);
|
exit(EXIT_FAILURE);
|
||||||
|
|
|
@ -35,11 +35,20 @@
|
||||||
|
|
||||||
#include "getopt.h"
|
#include "getopt.h"
|
||||||
|
|
||||||
|
#define STEP_SIZE 0.1f
|
||||||
|
|
||||||
static GLfloat gamma = 1.0f;
|
static GLfloat gamma = 1.0f;
|
||||||
|
|
||||||
static void usage(void)
|
static void usage(void)
|
||||||
{
|
{
|
||||||
printf("Usage: gammatest [-h] [-f]\n");
|
printf("Usage: gamma [-h] [-f]\n");
|
||||||
|
}
|
||||||
|
|
||||||
|
static void set_gamma(float value)
|
||||||
|
{
|
||||||
|
gamma = value;
|
||||||
|
printf("Gamma: %f\n", gamma);
|
||||||
|
glfwSetGamma(gamma);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void key_callback(GLFWwindow window, int key, int action)
|
static void key_callback(GLFWwindow window, int key, int action)
|
||||||
|
@ -50,21 +59,27 @@ static void key_callback(GLFWwindow window, int key, int action)
|
||||||
switch (key)
|
switch (key)
|
||||||
{
|
{
|
||||||
case GLFW_KEY_ESCAPE:
|
case GLFW_KEY_ESCAPE:
|
||||||
|
{
|
||||||
glfwCloseWindow(window);
|
glfwCloseWindow(window);
|
||||||
break;
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
case GLFW_KEY_KP_ADD:
|
case GLFW_KEY_KP_ADD:
|
||||||
case GLFW_KEY_Q:
|
case GLFW_KEY_Q:
|
||||||
gamma += 0.1f;
|
{
|
||||||
printf("Gamma: %f\n", gamma);
|
set_gamma(gamma + STEP_SIZE);
|
||||||
glfwSetGamma(gamma);
|
|
||||||
break;
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
case GLFW_KEY_KP_SUBTRACT:
|
case GLFW_KEY_KP_SUBTRACT:
|
||||||
case GLFW_KEY_W:
|
case GLFW_KEY_W:
|
||||||
gamma -= 0.1f;
|
{
|
||||||
printf("Gamma: %f\n", gamma);
|
if (gamma - STEP_SIZE > 0.f)
|
||||||
glfwSetGamma(gamma);
|
set_gamma(gamma - STEP_SIZE);
|
||||||
|
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
static void size_callback(GLFWwindow window, int width, int height)
|
static void size_callback(GLFWwindow window, int width, int height)
|
||||||
|
@ -96,7 +111,7 @@ int main(int argc, char** argv)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!glfwInit(NULL))
|
if (!glfwInit())
|
||||||
{
|
{
|
||||||
fprintf(stderr, "Failed to initialize GLFW: %s\n", glfwErrorString(glfwGetError()));
|
fprintf(stderr, "Failed to initialize GLFW: %s\n", glfwErrorString(glfwGetError()));
|
||||||
exit(EXIT_FAILURE);
|
exit(EXIT_FAILURE);
|
||||||
|
@ -124,7 +139,7 @@ int main(int argc, char** argv)
|
||||||
exit(EXIT_FAILURE);
|
exit(EXIT_FAILURE);
|
||||||
}
|
}
|
||||||
|
|
||||||
printf("Gamma: %f\n", gamma);
|
set_gamma(1.f);
|
||||||
|
|
||||||
glfwSwapInterval(1);
|
glfwSwapInterval(1);
|
||||||
glfwSetKeyCallback(key_callback);
|
glfwSetKeyCallback(key_callback);
|
||||||
|
|
|
@ -51,7 +51,7 @@
|
||||||
|
|
||||||
static void usage(void)
|
static void usage(void)
|
||||||
{
|
{
|
||||||
printf("Usage: version [-h] [-m MAJOR] [-n MINOR] [-d] [-l] [-f] [-p PROFILE] [-r STRATEGY]\n");
|
printf("Usage: glfwinfo [-h] [-m MAJOR] [-n MINOR] [-d] [-l] [-f] [-p PROFILE] [-r STRATEGY]\n");
|
||||||
printf("available profiles: " PROFILE_NAME_CORE " " PROFILE_NAME_COMPAT " " PROFILE_NAME_ES2 "\n");
|
printf("available profiles: " PROFILE_NAME_CORE " " PROFILE_NAME_COMPAT " " PROFILE_NAME_ES2 "\n");
|
||||||
printf("available strategies: " STRATEGY_NAME_NONE " " STRATEGY_NAME_LOSE "\n");
|
printf("available strategies: " STRATEGY_NAME_NONE " " STRATEGY_NAME_LOSE "\n");
|
||||||
}
|
}
|
||||||
|
@ -183,7 +183,7 @@ int main(int argc, char** argv)
|
||||||
|
|
||||||
glfwSetErrorCallback(error_callback);
|
glfwSetErrorCallback(error_callback);
|
||||||
|
|
||||||
if (!glfwInit(NULL))
|
if (!glfwInit())
|
||||||
{
|
{
|
||||||
fprintf(stderr, "Failed to initialize GLFW: %s\n", glfwErrorString(glfwGetError()));
|
fprintf(stderr, "Failed to initialize GLFW: %s\n", glfwErrorString(glfwGetError()));
|
||||||
exit(EXIT_FAILURE);
|
exit(EXIT_FAILURE);
|
||||||
|
|
|
@ -90,7 +90,7 @@ int main(int argc, char** argv)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!glfwInit(NULL))
|
if (!glfwInit())
|
||||||
{
|
{
|
||||||
fprintf(stderr, "Failed to initialize GLFW: %s\n", glfwErrorString(glfwGetError()));
|
fprintf(stderr, "Failed to initialize GLFW: %s\n", glfwErrorString(glfwGetError()));
|
||||||
exit(EXIT_FAILURE);
|
exit(EXIT_FAILURE);
|
||||||
|
|
|
@ -94,7 +94,7 @@ int main(void)
|
||||||
double update;
|
double update;
|
||||||
|
|
||||||
/* Initialise GLFW */
|
/* Initialise GLFW */
|
||||||
if (!glfwInit(NULL))
|
if (!glfwInit())
|
||||||
{
|
{
|
||||||
fprintf(stderr, "Failed to initialize GLFW: %s\n", glfwErrorString(glfwGetError()));
|
fprintf(stderr, "Failed to initialize GLFW: %s\n", glfwErrorString(glfwGetError()));
|
||||||
exit(EXIT_FAILURE);
|
exit(EXIT_FAILURE);
|
||||||
|
|
|
@ -21,7 +21,7 @@ int main(void)
|
||||||
GLFWvidmode dtmode, modes[400];
|
GLFWvidmode dtmode, modes[400];
|
||||||
int modecount, i;
|
int modecount, i;
|
||||||
|
|
||||||
if (!glfwInit(NULL))
|
if (!glfwInit())
|
||||||
{
|
{
|
||||||
fprintf(stderr, "Failed to initialize GLFW: %s\n", glfwErrorString(glfwGetError()));
|
fprintf(stderr, "Failed to initialize GLFW: %s\n", glfwErrorString(glfwGetError()));
|
||||||
exit(EXIT_FAILURE);
|
exit(EXIT_FAILURE);
|
||||||
|
|
|
@ -111,7 +111,7 @@ static GLboolean open_window(void)
|
||||||
|
|
||||||
int main(void)
|
int main(void)
|
||||||
{
|
{
|
||||||
if (!glfwInit(NULL))
|
if (!glfwInit())
|
||||||
{
|
{
|
||||||
fprintf(stderr, "Failed to initialize GLFW: %s\n", glfwErrorString(glfwGetError()));
|
fprintf(stderr, "Failed to initialize GLFW: %s\n", glfwErrorString(glfwGetError()));
|
||||||
exit(EXIT_FAILURE);
|
exit(EXIT_FAILURE);
|
||||||
|
|
|
@ -84,7 +84,7 @@ static GLboolean open_window(int width, int height, int mode)
|
||||||
{
|
{
|
||||||
double base;
|
double base;
|
||||||
|
|
||||||
if (!glfwInit(NULL))
|
if (!glfwInit())
|
||||||
{
|
{
|
||||||
fprintf(stderr, "Failed to initialize GLFW: %s\n", glfwErrorString(glfwGetError()));
|
fprintf(stderr, "Failed to initialize GLFW: %s\n", glfwErrorString(glfwGetError()));
|
||||||
return GL_FALSE;
|
return GL_FALSE;
|
||||||
|
|
|
@ -92,8 +92,6 @@ static void draw_quad(GLuint texture)
|
||||||
glBindTexture(GL_TEXTURE_2D, texture);
|
glBindTexture(GL_TEXTURE_2D, texture);
|
||||||
glTexEnvi(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_MODULATE);
|
glTexEnvi(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_MODULATE);
|
||||||
|
|
||||||
glColor3f(0.6f, 0.f, 0.6f);
|
|
||||||
|
|
||||||
glBegin(GL_QUADS);
|
glBegin(GL_QUADS);
|
||||||
|
|
||||||
glTexCoord2f(0.f, 0.f);
|
glTexCoord2f(0.f, 0.f);
|
||||||
|
@ -117,7 +115,7 @@ int main(int argc, char** argv)
|
||||||
GLuint texture;
|
GLuint texture;
|
||||||
int x, y;
|
int x, y;
|
||||||
|
|
||||||
if (!glfwInit(NULL))
|
if (!glfwInit())
|
||||||
{
|
{
|
||||||
fprintf(stderr, "Failed to initialize GLFW: %s\n", glfwErrorString(glfwGetError()));
|
fprintf(stderr, "Failed to initialize GLFW: %s\n", glfwErrorString(glfwGetError()));
|
||||||
exit(EXIT_FAILURE);
|
exit(EXIT_FAILURE);
|
||||||
|
@ -142,6 +140,11 @@ int main(int argc, char** argv)
|
||||||
exit(EXIT_FAILURE);
|
exit(EXIT_FAILURE);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Set drawing color for the first context and copy it to the second
|
||||||
|
glfwMakeContextCurrent(windows[0]);
|
||||||
|
glColor3f(0.6f, 0.f, 0.6f);
|
||||||
|
glfwCopyContext(windows[0], windows[1], GL_CURRENT_BIT);
|
||||||
|
|
||||||
// Put the second window to the right of the first one
|
// Put the second window to the right of the first one
|
||||||
glfwGetWindowPos(windows[0], &x, &y);
|
glfwGetWindowPos(windows[0], &x, &y);
|
||||||
glfwSetWindowPos(windows[1], x + WIDTH + 50, y);
|
glfwSetWindowPos(windows[1], x + WIDTH + 50, y);
|
||||||
|
|
|
@ -44,7 +44,7 @@ int main(void)
|
||||||
float position;
|
float position;
|
||||||
GLFWwindow window;
|
GLFWwindow window;
|
||||||
|
|
||||||
if (!glfwInit(NULL))
|
if (!glfwInit())
|
||||||
{
|
{
|
||||||
fprintf(stderr, "Failed to initialize GLFW: %s\n", glfwErrorString(glfwGetError()));
|
fprintf(stderr, "Failed to initialize GLFW: %s\n", glfwErrorString(glfwGetError()));
|
||||||
exit(EXIT_FAILURE);
|
exit(EXIT_FAILURE);
|
||||||
|
|
|
@ -41,7 +41,7 @@ int main(void)
|
||||||
{
|
{
|
||||||
GLFWwindow window;
|
GLFWwindow window;
|
||||||
|
|
||||||
if (!glfwInit(NULL))
|
if (!glfwInit())
|
||||||
{
|
{
|
||||||
fprintf(stderr, "Failed to initialize GLFW: %s\n", glfwErrorString(glfwGetError()));
|
fprintf(stderr, "Failed to initialize GLFW: %s\n", glfwErrorString(glfwGetError()));
|
||||||
exit(EXIT_FAILURE);
|
exit(EXIT_FAILURE);
|
||||||
|
|
|
@ -46,7 +46,7 @@ int main(void)
|
||||||
GLboolean running = GL_TRUE;
|
GLboolean running = GL_TRUE;
|
||||||
GLFWwindow windows[4];
|
GLFWwindow windows[4];
|
||||||
|
|
||||||
if (!glfwInit(NULL))
|
if (!glfwInit())
|
||||||
{
|
{
|
||||||
fprintf(stderr, "Failed to initialize GLFW: %s\n",
|
fprintf(stderr, "Failed to initialize GLFW: %s\n",
|
||||||
glfwErrorString(glfwGetError()));
|
glfwErrorString(glfwGetError()));
|
||||||
|
|
Loading…
Reference in New Issue
Block a user