mirror of
https://github.com/gwm17/glfw.git
synced 2024-11-26 20:28:49 -05:00
Add suffixes to platform specific helper functions
Also merge win32_tls.h into win32_platform.h.
This commit is contained in:
parent
0a3b5952e0
commit
12b6c56903
|
@ -17,8 +17,7 @@ if (_GLFW_COCOA)
|
|||
set(glfw_SOURCES ${common_SOURCES} cocoa_init.m cocoa_monitor.m
|
||||
cocoa_window.m iokit_joystick.m mach_time.c posix_tls.c)
|
||||
elseif (_GLFW_WIN32)
|
||||
set(glfw_HEADERS ${common_HEADERS} win32_platform.h win32_tls.h
|
||||
winmm_joystick.h)
|
||||
set(glfw_HEADERS ${common_HEADERS} win32_platform.h winmm_joystick.h)
|
||||
set(glfw_SOURCES ${common_SOURCES} win32_init.c win32_monitor.c win32_time.c
|
||||
win32_tls.c win32_window.c winmm_joystick.c)
|
||||
elseif (_GLFW_X11)
|
||||
|
|
|
@ -232,11 +232,14 @@ int _glfwPlatformInit(void)
|
|||
if (!_glfw.ns.unicodeData)
|
||||
return GLFW_FALSE;
|
||||
|
||||
if (!_glfwInitContextAPI())
|
||||
if (!_glfwInitThreadLocalStoragePOSIX())
|
||||
return GLFW_FALSE;
|
||||
|
||||
_glfwInitTimer();
|
||||
_glfwInitJoysticks();
|
||||
if (!_glfwInitNSGL())
|
||||
return GLFW_FALSE;
|
||||
|
||||
_glfwInitTimerNS();
|
||||
_glfwInitJoysticksNS();
|
||||
|
||||
return GLFW_TRUE;
|
||||
}
|
||||
|
@ -270,8 +273,9 @@ void _glfwPlatformTerminate(void)
|
|||
|
||||
free(_glfw.ns.clipboardString);
|
||||
|
||||
_glfwTerminateJoysticks();
|
||||
_glfwTerminateContextAPI();
|
||||
_glfwTerminateNSGL();
|
||||
_glfwTerminateJoysticksNS();
|
||||
_glfwTerminateThreadLocalStoragePOSIX();
|
||||
}
|
||||
|
||||
const char* _glfwPlatformGetVersionString(void)
|
||||
|
|
|
@ -166,7 +166,7 @@ static void endFadeReservation(CGDisplayFadeReservationToken token)
|
|||
|
||||
// Change the current video mode
|
||||
//
|
||||
GLFWbool _glfwSetVideoMode(_GLFWmonitor* monitor, const GLFWvidmode* desired)
|
||||
GLFWbool _glfwSetVideoModeNS(_GLFWmonitor* monitor, const GLFWvidmode* desired)
|
||||
{
|
||||
CFArrayRef modes;
|
||||
CFIndex count, i;
|
||||
|
@ -224,7 +224,7 @@ GLFWbool _glfwSetVideoMode(_GLFWmonitor* monitor, const GLFWvidmode* desired)
|
|||
|
||||
// Restore the previously saved (original) video mode
|
||||
//
|
||||
void _glfwRestoreVideoMode(_GLFWmonitor* monitor)
|
||||
void _glfwRestoreVideoModeNS(_GLFWmonitor* monitor)
|
||||
{
|
||||
if (monitor->ns.previousMode)
|
||||
{
|
||||
|
|
|
@ -120,9 +120,9 @@ typedef struct _GLFWtimeNS
|
|||
} _GLFWtimeNS;
|
||||
|
||||
|
||||
void _glfwInitTimer(void);
|
||||
void _glfwInitTimerNS(void);
|
||||
|
||||
GLFWbool _glfwSetVideoMode(_GLFWmonitor* monitor, const GLFWvidmode* desired);
|
||||
void _glfwRestoreVideoMode(_GLFWmonitor* monitor);
|
||||
GLFWbool _glfwSetVideoModeNS(_GLFWmonitor* monitor, const GLFWvidmode* desired);
|
||||
void _glfwRestoreVideoModeNS(_GLFWmonitor* monitor);
|
||||
|
||||
#endif // _glfw3_cocoa_platform_h_
|
||||
|
|
|
@ -76,7 +76,7 @@ static float transformY(float y)
|
|||
//
|
||||
static GLFWbool enterFullscreenMode(_GLFWwindow* window)
|
||||
{
|
||||
const GLFWbool status = _glfwSetVideoMode(window->monitor, &window->videoMode);
|
||||
const GLFWbool status = _glfwSetVideoModeNS(window->monitor, &window->videoMode);
|
||||
const CGRect bounds = CGDisplayBounds(window->monitor->ns.displayID);
|
||||
const NSRect frame = NSMakeRect(bounds.origin.x,
|
||||
transformY(bounds.origin.y + bounds.size.height),
|
||||
|
@ -91,7 +91,7 @@ static GLFWbool enterFullscreenMode(_GLFWwindow* window)
|
|||
//
|
||||
static void leaveFullscreenMode(_GLFWwindow* window)
|
||||
{
|
||||
_glfwRestoreVideoMode(window->monitor);
|
||||
_glfwRestoreVideoModeNS(window->monitor);
|
||||
}
|
||||
|
||||
// Translates OS X key modifiers into GLFW ones
|
||||
|
@ -262,7 +262,7 @@ static int translateKey(unsigned int key)
|
|||
int i;
|
||||
|
||||
for (i = 0; i < _glfw.monitorCount; i++)
|
||||
_glfwRestoreVideoMode(_glfw.monitors[i]);
|
||||
_glfwRestoreVideoModeNS(_glfw.monitors[i]);
|
||||
}
|
||||
|
||||
@end
|
||||
|
@ -886,7 +886,7 @@ int _glfwPlatformCreateWindow(_GLFWwindow* window,
|
|||
|
||||
if (ctxconfig->api != GLFW_NO_API)
|
||||
{
|
||||
if (!_glfwCreateContext(window, ctxconfig, fbconfig))
|
||||
if (!_glfwCreateContextNSGL(window, ctxconfig, fbconfig))
|
||||
return GLFW_FALSE;
|
||||
}
|
||||
|
||||
|
@ -908,7 +908,7 @@ void _glfwPlatformDestroyWindow(_GLFWwindow* window)
|
|||
leaveFullscreenMode(window);
|
||||
|
||||
if (window->context.api != GLFW_NO_API)
|
||||
_glfwDestroyContext(window);
|
||||
_glfwDestroyContextNSGL(window);
|
||||
|
||||
[window->ns.object setDelegate:nil];
|
||||
[window->ns.delegate release];
|
||||
|
|
|
@ -176,7 +176,7 @@ static GLFWbool chooseFBConfigs(const _GLFWctxconfig* ctxconfig,
|
|||
|
||||
// Initialize EGL
|
||||
//
|
||||
int _glfwInitContextAPI(void)
|
||||
int _glfwInitEGL(void)
|
||||
{
|
||||
int i;
|
||||
const char* sonames[] =
|
||||
|
@ -192,9 +192,6 @@ int _glfwInitContextAPI(void)
|
|||
NULL
|
||||
};
|
||||
|
||||
if (!_glfwCreateContextTLS())
|
||||
return GLFW_FALSE;
|
||||
|
||||
for (i = 0; sonames[i]; i++)
|
||||
{
|
||||
_glfw.egl.handle = _glfw_dlopen(sonames[i]);
|
||||
|
@ -268,7 +265,7 @@ int _glfwInitContextAPI(void)
|
|||
|
||||
// Terminate EGL
|
||||
//
|
||||
void _glfwTerminateContextAPI(void)
|
||||
void _glfwTerminateEGL(void)
|
||||
{
|
||||
if (_glfw.egl.handle)
|
||||
{
|
||||
|
@ -276,8 +273,6 @@ void _glfwTerminateContextAPI(void)
|
|||
_glfw_dlclose(_glfw.egl.handle);
|
||||
_glfw.egl.handle = NULL;
|
||||
}
|
||||
|
||||
_glfwDestroyContextTLS();
|
||||
}
|
||||
|
||||
#define setEGLattrib(attribName, attribValue) \
|
||||
|
@ -289,7 +284,7 @@ void _glfwTerminateContextAPI(void)
|
|||
|
||||
// Create the OpenGL or OpenGL ES context
|
||||
//
|
||||
int _glfwCreateContext(_GLFWwindow* window,
|
||||
int _glfwCreateContextEGL(_GLFWwindow* window,
|
||||
const _GLFWctxconfig* ctxconfig,
|
||||
const _GLFWfbconfig* fbconfig)
|
||||
{
|
||||
|
@ -492,7 +487,7 @@ int _glfwCreateContext(_GLFWwindow* window,
|
|||
|
||||
// Destroy the OpenGL context
|
||||
//
|
||||
void _glfwDestroyContext(_GLFWwindow* window)
|
||||
void _glfwDestroyContextEGL(_GLFWwindow* window)
|
||||
{
|
||||
#if defined(_GLFW_X11)
|
||||
// NOTE: Do not unload libGL.so.1 while the X11 display is still open,
|
||||
|
@ -523,7 +518,7 @@ void _glfwDestroyContext(_GLFWwindow* window)
|
|||
// Returns the Visual and depth of the chosen EGLConfig
|
||||
//
|
||||
#if defined(_GLFW_X11)
|
||||
GLFWbool _glfwChooseVisual(const _GLFWctxconfig* ctxconfig,
|
||||
GLFWbool _glfwChooseVisualEGL(const _GLFWctxconfig* ctxconfig,
|
||||
const _GLFWfbconfig* fbconfig,
|
||||
Visual** visual, int* depth)
|
||||
{
|
||||
|
@ -584,7 +579,7 @@ void _glfwPlatformMakeContextCurrent(_GLFWwindow* window)
|
|||
EGL_NO_CONTEXT);
|
||||
}
|
||||
|
||||
_glfwSetContextTLS(window);
|
||||
_glfwPlatformSetCurrentContext(window);
|
||||
}
|
||||
|
||||
void _glfwPlatformSwapBuffers(_GLFWwindow* window)
|
||||
|
|
|
@ -207,14 +207,14 @@ typedef struct _GLFWlibraryEGL
|
|||
} _GLFWlibraryEGL;
|
||||
|
||||
|
||||
int _glfwInitContextAPI(void);
|
||||
void _glfwTerminateContextAPI(void);
|
||||
int _glfwCreateContext(_GLFWwindow* window,
|
||||
int _glfwInitEGL(void);
|
||||
void _glfwTerminateEGL(void);
|
||||
int _glfwCreateContextEGL(_GLFWwindow* window,
|
||||
const _GLFWctxconfig* ctxconfig,
|
||||
const _GLFWfbconfig* fbconfig);
|
||||
void _glfwDestroyContext(_GLFWwindow* window);
|
||||
void _glfwDestroyContextEGL(_GLFWwindow* window);
|
||||
#if defined(_GLFW_X11)
|
||||
GLFWbool _glfwChooseVisual(const _GLFWctxconfig* ctxconfig,
|
||||
GLFWbool _glfwChooseVisualEGL(const _GLFWctxconfig* ctxconfig,
|
||||
const _GLFWfbconfig* fbconfig,
|
||||
Visual** visual, int* depth);
|
||||
#endif /*_GLFW_X11*/
|
||||
|
|
|
@ -150,7 +150,7 @@ static GLXContext createLegacyContext(_GLFWwindow* window,
|
|||
|
||||
// Initialize GLX
|
||||
//
|
||||
int _glfwInitContextAPI(void)
|
||||
int _glfwInitGLX(void)
|
||||
{
|
||||
int i;
|
||||
const char* sonames[] =
|
||||
|
@ -165,9 +165,6 @@ int _glfwInitContextAPI(void)
|
|||
};
|
||||
|
||||
|
||||
if (!_glfwCreateContextTLS())
|
||||
return GLFW_FALSE;
|
||||
|
||||
for (i = 0; sonames[i]; i++)
|
||||
{
|
||||
_glfw.glx.handle = dlopen(sonames[i], RTLD_LAZY | RTLD_GLOBAL);
|
||||
|
@ -296,7 +293,7 @@ int _glfwInitContextAPI(void)
|
|||
|
||||
// Terminate GLX
|
||||
//
|
||||
void _glfwTerminateContextAPI(void)
|
||||
void _glfwTerminateGLX(void)
|
||||
{
|
||||
// NOTE: This function must not call any X11 functions, as it is called
|
||||
// after XCloseDisplay (see _glfwPlatformTerminate for details)
|
||||
|
@ -306,8 +303,6 @@ void _glfwTerminateContextAPI(void)
|
|||
dlclose(_glfw.glx.handle);
|
||||
_glfw.glx.handle = NULL;
|
||||
}
|
||||
|
||||
_glfwDestroyContextTLS();
|
||||
}
|
||||
|
||||
#define setGLXattrib(attribName, attribValue) \
|
||||
|
@ -319,7 +314,7 @@ void _glfwTerminateContextAPI(void)
|
|||
|
||||
// Create the OpenGL or OpenGL ES context
|
||||
//
|
||||
int _glfwCreateContext(_GLFWwindow* window,
|
||||
int _glfwCreateContextGLX(_GLFWwindow* window,
|
||||
const _GLFWctxconfig* ctxconfig,
|
||||
const _GLFWfbconfig* fbconfig)
|
||||
{
|
||||
|
@ -370,7 +365,7 @@ int _glfwCreateContext(_GLFWwindow* window,
|
|||
}
|
||||
}
|
||||
|
||||
_glfwGrabXErrorHandler();
|
||||
_glfwGrabErrorHandlerX11();
|
||||
|
||||
if (_glfw.glx.ARB_create_context)
|
||||
{
|
||||
|
@ -473,11 +468,11 @@ int _glfwCreateContext(_GLFWwindow* window,
|
|||
else
|
||||
window->context.glx.handle = createLegacyContext(window, native, share);
|
||||
|
||||
_glfwReleaseXErrorHandler();
|
||||
_glfwReleaseErrorHandlerX11();
|
||||
|
||||
if (!window->context.glx.handle)
|
||||
{
|
||||
_glfwInputXError(GLFW_VERSION_UNAVAILABLE, "GLX: Failed to create context");
|
||||
_glfwInputErrorX11(GLFW_VERSION_UNAVAILABLE, "GLX: Failed to create context");
|
||||
return GLFW_FALSE;
|
||||
}
|
||||
|
||||
|
@ -496,7 +491,7 @@ int _glfwCreateContext(_GLFWwindow* window,
|
|||
|
||||
// Destroy the OpenGL context
|
||||
//
|
||||
void _glfwDestroyContext(_GLFWwindow* window)
|
||||
void _glfwDestroyContextGLX(_GLFWwindow* window)
|
||||
{
|
||||
if (window->context.glx.window)
|
||||
{
|
||||
|
@ -513,7 +508,7 @@ void _glfwDestroyContext(_GLFWwindow* window)
|
|||
|
||||
// Returns the Visual and depth of the chosen GLXFBConfig
|
||||
//
|
||||
GLFWbool _glfwChooseVisual(const _GLFWctxconfig* ctxconfig,
|
||||
GLFWbool _glfwChooseVisualGLX(const _GLFWctxconfig* ctxconfig,
|
||||
const _GLFWfbconfig* fbconfig,
|
||||
Visual** visual, int* depth)
|
||||
{
|
||||
|
@ -558,7 +553,7 @@ void _glfwPlatformMakeContextCurrent(_GLFWwindow* window)
|
|||
else
|
||||
glXMakeCurrent(_glfw.x11.display, None, NULL);
|
||||
|
||||
_glfwSetContextTLS(window);
|
||||
_glfwPlatformSetCurrentContext(window);
|
||||
}
|
||||
|
||||
void _glfwPlatformSwapBuffers(_GLFWwindow* window)
|
||||
|
|
|
@ -171,13 +171,13 @@ typedef struct _GLFWlibraryGLX
|
|||
} _GLFWlibraryGLX;
|
||||
|
||||
|
||||
int _glfwInitContextAPI(void);
|
||||
void _glfwTerminateContextAPI(void);
|
||||
int _glfwCreateContext(_GLFWwindow* window,
|
||||
int _glfwInitGLX(void);
|
||||
void _glfwTerminateGLX(void);
|
||||
int _glfwCreateContextGLX(_GLFWwindow* window,
|
||||
const _GLFWctxconfig* ctxconfig,
|
||||
const _GLFWfbconfig* fbconfig);
|
||||
void _glfwDestroyContext(_GLFWwindow* window);
|
||||
GLFWbool _glfwChooseVisual(const _GLFWctxconfig* ctxconfig,
|
||||
void _glfwDestroyContextGLX(_GLFWwindow* window);
|
||||
GLFWbool _glfwChooseVisualGLX(const _GLFWctxconfig* ctxconfig,
|
||||
const _GLFWfbconfig* fbconfig,
|
||||
Visual** visual, int* depth);
|
||||
|
||||
|
|
|
@ -637,6 +637,10 @@ void _glfwPlatformPostEmptyEvent(void);
|
|||
*/
|
||||
void _glfwPlatformMakeContextCurrent(_GLFWwindow* window);
|
||||
|
||||
/*! @ingroup platform
|
||||
*/
|
||||
void _glfwPlatformSetCurrentContext(_GLFWwindow* context);
|
||||
|
||||
/*! @copydoc glfwGetCurrentContext
|
||||
* @ingroup platform
|
||||
*/
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
//========================================================================
|
||||
// GLFW 3.2 IOKit - www.glfw.org
|
||||
// GLFW 3.2 Cocoa - www.glfw.org
|
||||
//------------------------------------------------------------------------
|
||||
// Copyright (c) 2006-2014 Camilla Berglund <elmindreda@elmindreda.org>
|
||||
//
|
||||
|
@ -32,13 +32,12 @@
|
|||
#include <IOKit/hid/IOHIDLib.h>
|
||||
#include <IOKit/hid/IOHIDKeys.h>
|
||||
|
||||
#define _GLFW_PLATFORM_LIBRARY_JOYSTICK_STATE \
|
||||
_GLFWjoystickIOKit iokit_js
|
||||
#define _GLFW_PLATFORM_LIBRARY_JOYSTICK_STATE _GLFWjoystickNS ns_js
|
||||
|
||||
|
||||
// IOKit-specific per-joystick data
|
||||
//
|
||||
typedef struct _GLFWjoydevice
|
||||
typedef struct _GLFWjoydeviceNS
|
||||
{
|
||||
int present;
|
||||
char name[256];
|
||||
|
@ -51,18 +50,18 @@ typedef struct _GLFWjoydevice
|
|||
|
||||
float* axes;
|
||||
unsigned char* buttons;
|
||||
} _GLFWjoydevice;
|
||||
} _GLFWjoydeviceNS;
|
||||
|
||||
// IOKit-specific joystick API data
|
||||
//
|
||||
typedef struct _GLFWjoystickIOKit
|
||||
typedef struct _GLFWjoystickNS
|
||||
{
|
||||
_GLFWjoydevice devices[GLFW_JOYSTICK_LAST + 1];
|
||||
_GLFWjoydeviceNS devices[GLFW_JOYSTICK_LAST + 1];
|
||||
|
||||
IOHIDManagerRef managerRef;
|
||||
} _GLFWjoystickIOKit;
|
||||
} _GLFWjoystickNS;
|
||||
|
||||
void _glfwInitJoysticks(void);
|
||||
void _glfwTerminateJoysticks(void);
|
||||
void _glfwInitJoysticksNS(void);
|
||||
void _glfwTerminateJoysticksNS(void);
|
||||
|
||||
#endif // _glfw3_iokit_joystick_h_
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
//========================================================================
|
||||
// GLFW 3.2 IOKit - www.glfw.org
|
||||
// GLFW 3.2 Cocoa - www.glfw.org
|
||||
//------------------------------------------------------------------------
|
||||
// Copyright (c) 2009-2010 Camilla Berglund <elmindreda@elmindreda.org>
|
||||
// Copyright (c) 2012 Torsten Walluhn <tw@mad-cad.net>
|
||||
|
@ -40,7 +40,7 @@
|
|||
//------------------------------------------------------------------------
|
||||
// Joystick element information
|
||||
//------------------------------------------------------------------------
|
||||
typedef struct
|
||||
typedef struct _GLFWjoyelementNS
|
||||
{
|
||||
IOHIDElementRef elementRef;
|
||||
|
||||
|
@ -50,14 +50,14 @@ typedef struct
|
|||
long minReport;
|
||||
long maxReport;
|
||||
|
||||
} _GLFWjoyelement;
|
||||
} _GLFWjoyelementNS;
|
||||
|
||||
|
||||
static void getElementsCFArrayHandler(const void* value, void* parameter);
|
||||
|
||||
// Adds an element to the specified joystick
|
||||
//
|
||||
static void addJoystickElement(_GLFWjoydevice* joystick,
|
||||
static void addJoystickElement(_GLFWjoydeviceNS* joystick,
|
||||
IOHIDElementRef elementRef)
|
||||
{
|
||||
IOHIDElementType elementType;
|
||||
|
@ -109,7 +109,7 @@ static void addJoystickElement(_GLFWjoydevice* joystick,
|
|||
|
||||
if (elementsArray)
|
||||
{
|
||||
_GLFWjoyelement* element = calloc(1, sizeof(_GLFWjoyelement));
|
||||
_GLFWjoyelementNS* element = calloc(1, sizeof(_GLFWjoyelementNS));
|
||||
|
||||
CFArrayAppendValue(elementsArray, element);
|
||||
|
||||
|
@ -126,14 +126,14 @@ static void getElementsCFArrayHandler(const void* value, void* parameter)
|
|||
{
|
||||
if (CFGetTypeID(value) == IOHIDElementGetTypeID())
|
||||
{
|
||||
addJoystickElement((_GLFWjoydevice*) parameter,
|
||||
addJoystickElement((_GLFWjoydeviceNS*) parameter,
|
||||
(IOHIDElementRef) value);
|
||||
}
|
||||
}
|
||||
|
||||
// Returns the value of the specified element of the specified joystick
|
||||
//
|
||||
static long getElementValue(_GLFWjoydevice* joystick, _GLFWjoyelement* element)
|
||||
static long getElementValue(_GLFWjoydeviceNS* joystick, _GLFWjoyelementNS* element)
|
||||
{
|
||||
IOReturn result = kIOReturnSuccess;
|
||||
IOHIDValueRef valueRef;
|
||||
|
@ -163,7 +163,7 @@ static long getElementValue(_GLFWjoydevice* joystick, _GLFWjoyelement* element)
|
|||
|
||||
// Removes the specified joystick
|
||||
//
|
||||
static void removeJoystick(_GLFWjoydevice* joystick)
|
||||
static void removeJoystick(_GLFWjoydeviceNS* joystick)
|
||||
{
|
||||
int i;
|
||||
|
||||
|
@ -188,7 +188,7 @@ static void removeJoystick(_GLFWjoydevice* joystick)
|
|||
free(joystick->axes);
|
||||
free(joystick->buttons);
|
||||
|
||||
memset(joystick, 0, sizeof(_GLFWjoydevice));
|
||||
memset(joystick, 0, sizeof(_GLFWjoydeviceNS));
|
||||
}
|
||||
|
||||
// Polls for joystick events and updates GLFW state
|
||||
|
@ -201,14 +201,14 @@ static void pollJoystickEvents(void)
|
|||
{
|
||||
CFIndex i;
|
||||
int buttonIndex = 0;
|
||||
_GLFWjoydevice* joystick = _glfw.iokit_js.devices + joy;
|
||||
_GLFWjoydeviceNS* joystick = _glfw.ns_js.devices + joy;
|
||||
|
||||
if (!joystick->present)
|
||||
continue;
|
||||
|
||||
for (i = 0; i < CFArrayGetCount(joystick->buttonElements); i++)
|
||||
{
|
||||
_GLFWjoyelement* button = (_GLFWjoyelement*)
|
||||
_GLFWjoyelementNS* button = (_GLFWjoyelementNS*)
|
||||
CFArrayGetValueAtIndex(joystick->buttonElements, i);
|
||||
|
||||
if (getElementValue(joystick, button))
|
||||
|
@ -219,7 +219,7 @@ static void pollJoystickEvents(void)
|
|||
|
||||
for (i = 0; i < CFArrayGetCount(joystick->axisElements); i++)
|
||||
{
|
||||
_GLFWjoyelement* axis = (_GLFWjoyelement*)
|
||||
_GLFWjoyelementNS* axis = (_GLFWjoyelementNS*)
|
||||
CFArrayGetValueAtIndex(joystick->axisElements, i);
|
||||
|
||||
long value = getElementValue(joystick, axis);
|
||||
|
@ -233,7 +233,7 @@ static void pollJoystickEvents(void)
|
|||
|
||||
for (i = 0; i < CFArrayGetCount(joystick->hatElements); i++)
|
||||
{
|
||||
_GLFWjoyelement* hat = (_GLFWjoyelement*)
|
||||
_GLFWjoyelementNS* hat = (_GLFWjoyelementNS*)
|
||||
CFArrayGetValueAtIndex(joystick->hatElements, i);
|
||||
|
||||
// Bit fields of button presses for each direction, including nil
|
||||
|
@ -261,12 +261,12 @@ static void matchCallback(void* context,
|
|||
void* sender,
|
||||
IOHIDDeviceRef deviceRef)
|
||||
{
|
||||
_GLFWjoydevice* joystick;
|
||||
_GLFWjoydeviceNS* joystick;
|
||||
int joy;
|
||||
|
||||
for (joy = GLFW_JOYSTICK_1; joy <= GLFW_JOYSTICK_LAST; joy++)
|
||||
{
|
||||
joystick = _glfw.iokit_js.devices + joy;
|
||||
joystick = _glfw.ns_js.devices + joy;
|
||||
|
||||
if (!joystick->present)
|
||||
continue;
|
||||
|
@ -277,7 +277,7 @@ static void matchCallback(void* context,
|
|||
|
||||
for (joy = GLFW_JOYSTICK_1; joy <= GLFW_JOYSTICK_LAST; joy++)
|
||||
{
|
||||
joystick = _glfw.iokit_js.devices + joy;
|
||||
joystick = _glfw.ns_js.devices + joy;
|
||||
|
||||
if (!joystick->present)
|
||||
break;
|
||||
|
@ -328,7 +328,7 @@ static void removeCallback(void* context,
|
|||
|
||||
for (joy = GLFW_JOYSTICK_1; joy <= GLFW_JOYSTICK_LAST; joy++)
|
||||
{
|
||||
_GLFWjoydevice* joystick = _glfw.iokit_js.devices + joy;
|
||||
_GLFWjoydeviceNS* joystick = _glfw.ns_js.devices + joy;
|
||||
if (joystick->deviceRef == deviceRef)
|
||||
{
|
||||
removeJoystick(joystick);
|
||||
|
@ -384,11 +384,11 @@ static CFMutableDictionaryRef createMatchingDictionary(long usagePage,
|
|||
|
||||
// Initialize joystick interface
|
||||
//
|
||||
void _glfwInitJoysticks(void)
|
||||
void _glfwInitJoysticksNS(void)
|
||||
{
|
||||
CFMutableArrayRef matchingCFArrayRef;
|
||||
|
||||
_glfw.iokit_js.managerRef = IOHIDManagerCreate(kCFAllocatorDefault,
|
||||
_glfw.ns_js.managerRef = IOHIDManagerCreate(kCFAllocatorDefault,
|
||||
kIOHIDOptionsTypeNone);
|
||||
|
||||
matchingCFArrayRef = CFArrayCreateMutable(kCFAllocatorDefault,
|
||||
|
@ -422,21 +422,21 @@ void _glfwInitJoysticks(void)
|
|||
CFRelease(matchingCFDictRef);
|
||||
}
|
||||
|
||||
IOHIDManagerSetDeviceMatchingMultiple(_glfw.iokit_js.managerRef,
|
||||
IOHIDManagerSetDeviceMatchingMultiple(_glfw.ns_js.managerRef,
|
||||
matchingCFArrayRef);
|
||||
CFRelease(matchingCFArrayRef);
|
||||
}
|
||||
|
||||
IOHIDManagerRegisterDeviceMatchingCallback(_glfw.iokit_js.managerRef,
|
||||
IOHIDManagerRegisterDeviceMatchingCallback(_glfw.ns_js.managerRef,
|
||||
&matchCallback, NULL);
|
||||
IOHIDManagerRegisterDeviceRemovalCallback(_glfw.iokit_js.managerRef,
|
||||
IOHIDManagerRegisterDeviceRemovalCallback(_glfw.ns_js.managerRef,
|
||||
&removeCallback, NULL);
|
||||
|
||||
IOHIDManagerScheduleWithRunLoop(_glfw.iokit_js.managerRef,
|
||||
IOHIDManagerScheduleWithRunLoop(_glfw.ns_js.managerRef,
|
||||
CFRunLoopGetMain(),
|
||||
kCFRunLoopDefaultMode);
|
||||
|
||||
IOHIDManagerOpen(_glfw.iokit_js.managerRef, kIOHIDOptionsTypeNone);
|
||||
IOHIDManagerOpen(_glfw.ns_js.managerRef, kIOHIDOptionsTypeNone);
|
||||
|
||||
// Execute the run loop once in order to register any initially-attached
|
||||
// joysticks
|
||||
|
@ -445,18 +445,18 @@ void _glfwInitJoysticks(void)
|
|||
|
||||
// Close all opened joystick handles
|
||||
//
|
||||
void _glfwTerminateJoysticks(void)
|
||||
void _glfwTerminateJoysticksNS(void)
|
||||
{
|
||||
int joy;
|
||||
|
||||
for (joy = 0; joy <= GLFW_JOYSTICK_LAST; joy++)
|
||||
{
|
||||
_GLFWjoydevice* joystick = _glfw.iokit_js.devices + joy;
|
||||
_GLFWjoydeviceNS* joystick = _glfw.ns_js.devices + joy;
|
||||
removeJoystick(joystick);
|
||||
}
|
||||
|
||||
CFRelease(_glfw.iokit_js.managerRef);
|
||||
_glfw.iokit_js.managerRef = NULL;
|
||||
CFRelease(_glfw.ns_js.managerRef);
|
||||
_glfw.ns_js.managerRef = NULL;
|
||||
}
|
||||
|
||||
|
||||
|
@ -468,12 +468,12 @@ int _glfwPlatformJoystickPresent(int joy)
|
|||
{
|
||||
pollJoystickEvents();
|
||||
|
||||
return _glfw.iokit_js.devices[joy].present;
|
||||
return _glfw.ns_js.devices[joy].present;
|
||||
}
|
||||
|
||||
const float* _glfwPlatformGetJoystickAxes(int joy, int* count)
|
||||
{
|
||||
_GLFWjoydevice* joystick = _glfw.iokit_js.devices + joy;
|
||||
_GLFWjoydeviceNS* joystick = _glfw.ns_js.devices + joy;
|
||||
|
||||
pollJoystickEvents();
|
||||
|
||||
|
@ -486,7 +486,7 @@ const float* _glfwPlatformGetJoystickAxes(int joy, int* count)
|
|||
|
||||
const unsigned char* _glfwPlatformGetJoystickButtons(int joy, int* count)
|
||||
{
|
||||
_GLFWjoydevice* joystick = _glfw.iokit_js.devices + joy;
|
||||
_GLFWjoydeviceNS* joystick = _glfw.ns_js.devices + joy;
|
||||
|
||||
pollJoystickEvents();
|
||||
|
||||
|
@ -502,6 +502,6 @@ const char* _glfwPlatformGetJoystickName(int joy)
|
|||
{
|
||||
pollJoystickEvents();
|
||||
|
||||
return _glfw.iokit_js.devices[joy].name;
|
||||
return _glfw.ns_js.devices[joy].name;
|
||||
}
|
||||
|
||||
|
|
|
@ -173,7 +173,7 @@ static GLFWbool pollJoystickEvents(_GLFWjoystickLinux* js)
|
|||
|
||||
// Initialize joystick interface
|
||||
//
|
||||
int _glfwInitJoysticks(void)
|
||||
int _glfwInitJoysticksLinux(void)
|
||||
{
|
||||
#if defined(__linux__)
|
||||
const char* dirname = "/dev/input";
|
||||
|
@ -244,7 +244,7 @@ int _glfwInitJoysticks(void)
|
|||
|
||||
// Close all opened joystick handles
|
||||
//
|
||||
void _glfwTerminateJoysticks(void)
|
||||
void _glfwTerminateJoysticksLinux(void)
|
||||
{
|
||||
#if defined(__linux__)
|
||||
int i;
|
||||
|
|
|
@ -61,7 +61,7 @@ typedef struct _GLFWjoylistLinux
|
|||
} _GLFWjoylistLinux;
|
||||
|
||||
|
||||
int _glfwInitJoysticks(void);
|
||||
void _glfwTerminateJoysticks(void);
|
||||
int _glfwInitJoysticksLinux(void);
|
||||
void _glfwTerminateJoysticksLinux(void);
|
||||
|
||||
#endif // _glfw3_linux_joystick_h_
|
||||
|
|
|
@ -43,7 +43,7 @@ static uint64_t getRawTime(void)
|
|||
|
||||
// Initialise timer
|
||||
//
|
||||
void _glfwInitTimer(void)
|
||||
void _glfwInitTimerNS(void)
|
||||
{
|
||||
mach_timebase_info_data_t info;
|
||||
mach_timebase_info(&info);
|
||||
|
|
|
@ -179,17 +179,20 @@ int _glfwPlatformInit(void)
|
|||
|
||||
createKeyTables();
|
||||
|
||||
if (!_glfwInitContextAPI())
|
||||
if (!_glfwInitThreadLocalStoragePOSIX())
|
||||
return GLFW_FALSE;
|
||||
|
||||
if (!_glfwInitEGL())
|
||||
return GLFW_FALSE;
|
||||
|
||||
// Need the default conf for when we set a NULL cursor
|
||||
_glfw.mir.default_conf = mir_cursor_configuration_from_name(mir_arrow_cursor_name);
|
||||
|
||||
_glfwInitTimer();
|
||||
_glfwInitJoysticks();
|
||||
_glfwInitTimerPOSIX();
|
||||
_glfwInitJoysticksLinux();
|
||||
|
||||
_glfw.mir.event_queue = calloc(1, sizeof(EventQueue));
|
||||
_glfwInitEventQueue(_glfw.mir.event_queue);
|
||||
_glfwInitEventQueueMir(_glfw.mir.event_queue);
|
||||
|
||||
error = pthread_mutex_init(&_glfw.mir.event_mutex, NULL);
|
||||
if (error)
|
||||
|
@ -205,10 +208,11 @@ int _glfwPlatformInit(void)
|
|||
|
||||
void _glfwPlatformTerminate(void)
|
||||
{
|
||||
_glfwTerminateContextAPI();
|
||||
_glfwTerminateJoysticks();
|
||||
_glfwTerminateEGL();
|
||||
_glfwTerminateJoysticksLinux();
|
||||
_glfwTerminateThreadLocalStoragePOSIX();
|
||||
|
||||
_glfwDeleteEventQueue(_glfw.mir.event_queue);
|
||||
_glfwDeleteEventQueueMir(_glfw.mir.event_queue);
|
||||
|
||||
pthread_mutex_destroy(&_glfw.mir.event_mutex);
|
||||
|
||||
|
|
|
@ -110,7 +110,7 @@ typedef struct _GLFWcursorMir
|
|||
} _GLFWcursorMir;
|
||||
|
||||
|
||||
extern void _glfwInitEventQueue(EventQueue* queue);
|
||||
extern void _glfwDeleteEventQueue(EventQueue* queue);
|
||||
extern void _glfwInitEventQueueMir(EventQueue* queue);
|
||||
extern void _glfwDeleteEventQueueMir(EventQueue* queue);
|
||||
|
||||
#endif // _glfw3_mir_platform_h_
|
||||
|
|
|
@ -310,12 +310,12 @@ static GLFWbool createSurface(_GLFWwindow* window)
|
|||
////// GLFW internal API //////
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
|
||||
void _glfwInitEventQueue(EventQueue* queue)
|
||||
void _glfwInitEventQueueMir(EventQueue* queue)
|
||||
{
|
||||
TAILQ_INIT(&queue->head);
|
||||
}
|
||||
|
||||
void _glfwDeleteEventQueue(EventQueue* queue)
|
||||
void _glfwDeleteEventQueueMir(EventQueue* queue)
|
||||
{
|
||||
if (queue)
|
||||
{
|
||||
|
@ -347,7 +347,7 @@ int _glfwPlatformCreateWindow(_GLFWwindow* window,
|
|||
{
|
||||
if (ctxconfig->api != GLFW_NO_API)
|
||||
{
|
||||
if (!_glfwCreateContext(window, ctxconfig, fbconfig))
|
||||
if (!_glfwCreateContextEGL(window, ctxconfig, fbconfig))
|
||||
return GLFW_FALSE;
|
||||
}
|
||||
|
||||
|
@ -388,7 +388,7 @@ void _glfwPlatformDestroyWindow(_GLFWwindow* window)
|
|||
window->mir.surface = NULL;
|
||||
}
|
||||
|
||||
_glfwDestroyContext(window);
|
||||
_glfwDestroyContextEGL(window);
|
||||
}
|
||||
|
||||
void _glfwPlatformSetWindowTitle(_GLFWwindow* window, const char* title)
|
||||
|
|
|
@ -52,11 +52,11 @@ typedef struct _GLFWlibraryNSGL
|
|||
} _GLFWlibraryNSGL;
|
||||
|
||||
|
||||
int _glfwInitContextAPI(void);
|
||||
void _glfwTerminateContextAPI(void);
|
||||
int _glfwCreateContext(_GLFWwindow* window,
|
||||
int _glfwInitNSGL(void);
|
||||
void _glfwTerminateNSGL(void);
|
||||
int _glfwCreateContextNSGL(_GLFWwindow* window,
|
||||
const _GLFWctxconfig* ctxconfig,
|
||||
const _GLFWfbconfig* fbconfig);
|
||||
void _glfwDestroyContext(_GLFWwindow* window);
|
||||
void _glfwDestroyContextNSGL(_GLFWwindow* window);
|
||||
|
||||
#endif // _glfw3_nsgl_context_h_
|
||||
|
|
|
@ -33,11 +33,8 @@
|
|||
|
||||
// Initialize OpenGL support
|
||||
//
|
||||
int _glfwInitContextAPI(void)
|
||||
int _glfwInitNSGL(void)
|
||||
{
|
||||
if (!_glfwCreateContextTLS())
|
||||
return GLFW_FALSE;
|
||||
|
||||
_glfw.nsgl.framework =
|
||||
CFBundleGetBundleWithIdentifier(CFSTR("com.apple.opengl"));
|
||||
if (_glfw.nsgl.framework == NULL)
|
||||
|
@ -52,14 +49,13 @@ int _glfwInitContextAPI(void)
|
|||
|
||||
// Terminate OpenGL support
|
||||
//
|
||||
void _glfwTerminateContextAPI(void)
|
||||
void _glfwTerminateNSGL(void)
|
||||
{
|
||||
_glfwDestroyContextTLS();
|
||||
}
|
||||
|
||||
// Create the OpenGL context
|
||||
//
|
||||
int _glfwCreateContext(_GLFWwindow* window,
|
||||
int _glfwCreateContextNSGL(_GLFWwindow* window,
|
||||
const _GLFWctxconfig* ctxconfig,
|
||||
const _GLFWfbconfig* fbconfig)
|
||||
{
|
||||
|
@ -225,7 +221,7 @@ int _glfwCreateContext(_GLFWwindow* window,
|
|||
|
||||
// Destroy the OpenGL context
|
||||
//
|
||||
void _glfwDestroyContext(_GLFWwindow* window)
|
||||
void _glfwDestroyContextNSGL(_GLFWwindow* window)
|
||||
{
|
||||
[window->context.nsgl.pixelFormat release];
|
||||
window->context.nsgl.pixelFormat = nil;
|
||||
|
@ -246,7 +242,7 @@ void _glfwPlatformMakeContextCurrent(_GLFWwindow* window)
|
|||
else
|
||||
[NSOpenGLContext clearCurrentContext];
|
||||
|
||||
_glfwSetContextTLS(window);
|
||||
_glfwPlatformSetCurrentContext(window);
|
||||
}
|
||||
|
||||
void _glfwPlatformSwapBuffers(_GLFWwindow* window)
|
||||
|
|
|
@ -59,7 +59,7 @@ static uint64_t getRawTime(void)
|
|||
|
||||
// Initialise timer
|
||||
//
|
||||
void _glfwInitTimer(void)
|
||||
void _glfwInitTimerPOSIX(void)
|
||||
{
|
||||
#if defined(CLOCK_MONOTONIC)
|
||||
struct timespec ts;
|
||||
|
|
|
@ -44,6 +44,6 @@ typedef struct _GLFWtimePOSIX
|
|||
} _GLFWtimePOSIX;
|
||||
|
||||
|
||||
void _glfwInitTimer(void);
|
||||
void _glfwInitTimerPOSIX(void);
|
||||
|
||||
#endif // _glfw3_posix_time_h_
|
||||
|
|
|
@ -32,7 +32,7 @@
|
|||
////// GLFW internal API //////
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
|
||||
GLFWbool _glfwCreateContextTLS(void)
|
||||
GLFWbool _glfwInitThreadLocalStoragePOSIX(void)
|
||||
{
|
||||
if (pthread_key_create(&_glfw.posix_tls.context, NULL) != 0)
|
||||
{
|
||||
|
@ -45,22 +45,22 @@ GLFWbool _glfwCreateContextTLS(void)
|
|||
return GLFW_TRUE;
|
||||
}
|
||||
|
||||
void _glfwDestroyContextTLS(void)
|
||||
void _glfwTerminateThreadLocalStoragePOSIX(void)
|
||||
{
|
||||
if (_glfw.posix_tls.allocated)
|
||||
pthread_key_delete(_glfw.posix_tls.context);
|
||||
}
|
||||
|
||||
void _glfwSetContextTLS(_GLFWwindow* context)
|
||||
{
|
||||
pthread_setspecific(_glfw.posix_tls.context, context);
|
||||
}
|
||||
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
////// GLFW platform API //////
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
|
||||
void _glfwPlatformSetCurrentContext(_GLFWwindow* context)
|
||||
{
|
||||
pthread_setspecific(_glfw.posix_tls.context, context);
|
||||
}
|
||||
|
||||
_GLFWwindow* _glfwPlatformGetCurrentContext(void)
|
||||
{
|
||||
return pthread_getspecific(_glfw.posix_tls.context);
|
||||
|
|
|
@ -43,8 +43,7 @@ typedef struct _GLFWtlsPOSIX
|
|||
} _GLFWtlsPOSIX;
|
||||
|
||||
|
||||
GLFWbool _glfwCreateContextTLS(void);
|
||||
void _glfwDestroyContextTLS(void);
|
||||
void _glfwSetContextTLS(_GLFWwindow* context);
|
||||
GLFWbool _glfwInitThreadLocalStoragePOSIX(void);
|
||||
void _glfwTerminateThreadLocalStoragePOSIX(void);
|
||||
|
||||
#endif // _glfw3_posix_tls_h_
|
||||
|
|
|
@ -287,11 +287,8 @@ static GLFWbool isCompositionEnabled(void)
|
|||
|
||||
// Initialize WGL
|
||||
//
|
||||
int _glfwInitContextAPI(void)
|
||||
int _glfwInitWGL(void)
|
||||
{
|
||||
if (!_glfwCreateContextTLS())
|
||||
return GLFW_FALSE;
|
||||
|
||||
_glfw.wgl.instance = LoadLibraryA("opengl32.dll");
|
||||
if (!_glfw.wgl.instance)
|
||||
{
|
||||
|
@ -315,12 +312,10 @@ int _glfwInitContextAPI(void)
|
|||
|
||||
// Terminate WGL
|
||||
//
|
||||
void _glfwTerminateContextAPI(void)
|
||||
void _glfwTerminateWGL(void)
|
||||
{
|
||||
if (_glfw.wgl.instance)
|
||||
FreeLibrary(_glfw.wgl.instance);
|
||||
|
||||
_glfwDestroyContextTLS();
|
||||
}
|
||||
|
||||
#define setWGLattrib(attribName, attribValue) \
|
||||
|
@ -332,7 +327,7 @@ void _glfwTerminateContextAPI(void)
|
|||
|
||||
// Create the OpenGL or OpenGL ES context
|
||||
//
|
||||
int _glfwCreateContext(_GLFWwindow* window,
|
||||
int _glfwCreateContextWGL(_GLFWwindow* window,
|
||||
const _GLFWctxconfig* ctxconfig,
|
||||
const _GLFWfbconfig* fbconfig)
|
||||
{
|
||||
|
@ -341,6 +336,9 @@ int _glfwCreateContext(_GLFWwindow* window,
|
|||
PIXELFORMATDESCRIPTOR pfd;
|
||||
HGLRC share = NULL;
|
||||
|
||||
if (ctxconfig->api == GLFW_NO_API)
|
||||
return GLFW_TRUE;
|
||||
|
||||
if (ctxconfig->share)
|
||||
share = ctxconfig->share->context.wgl.handle;
|
||||
|
||||
|
@ -483,7 +481,7 @@ int _glfwCreateContext(_GLFWwindow* window,
|
|||
|
||||
// Destroy the OpenGL context
|
||||
//
|
||||
void _glfwDestroyContext(_GLFWwindow* window)
|
||||
void _glfwDestroyContextWGL(_GLFWwindow* window)
|
||||
{
|
||||
if (window->context.wgl.handle)
|
||||
{
|
||||
|
@ -494,7 +492,7 @@ void _glfwDestroyContext(_GLFWwindow* window)
|
|||
|
||||
// Analyzes the specified context for possible recreation
|
||||
//
|
||||
int _glfwAnalyzeContext(_GLFWwindow* window,
|
||||
int _glfwAnalyzeContextWGL(_GLFWwindow* window,
|
||||
const _GLFWctxconfig* ctxconfig,
|
||||
const _GLFWfbconfig* fbconfig)
|
||||
{
|
||||
|
@ -600,7 +598,7 @@ void _glfwPlatformMakeContextCurrent(_GLFWwindow* window)
|
|||
else
|
||||
wglMakeCurrent(NULL, NULL);
|
||||
|
||||
_glfwSetContextTLS(window);
|
||||
_glfwPlatformSetCurrentContext(window);
|
||||
}
|
||||
|
||||
void _glfwPlatformSwapBuffers(_GLFWwindow* window)
|
||||
|
|
|
@ -144,13 +144,13 @@ typedef struct _GLFWlibraryWGL
|
|||
} _GLFWlibraryWGL;
|
||||
|
||||
|
||||
int _glfwInitContextAPI(void);
|
||||
void _glfwTerminateContextAPI(void);
|
||||
int _glfwCreateContext(_GLFWwindow* window,
|
||||
int _glfwInitWGL(void);
|
||||
void _glfwTerminateWGL(void);
|
||||
int _glfwCreateContextWGL(_GLFWwindow* window,
|
||||
const _GLFWctxconfig* ctxconfig,
|
||||
const _GLFWfbconfig* fbconfig);
|
||||
void _glfwDestroyContext(_GLFWwindow* window);
|
||||
int _glfwAnalyzeContext(_GLFWwindow* window,
|
||||
void _glfwDestroyContextWGL(_GLFWwindow* window);
|
||||
int _glfwAnalyzeContextWGL(_GLFWwindow* window,
|
||||
const _GLFWctxconfig* ctxconfig,
|
||||
const _GLFWfbconfig* fbconfig);
|
||||
|
||||
|
|
|
@ -292,7 +292,7 @@ static HWND createHelperWindow(void)
|
|||
|
||||
// Returns a wide string version of the specified UTF-8 string
|
||||
//
|
||||
WCHAR* _glfwCreateWideStringFromUTF8(const char* source)
|
||||
WCHAR* _glfwCreateWideStringFromUTF8Win32(const char* source)
|
||||
{
|
||||
WCHAR* target;
|
||||
int length;
|
||||
|
@ -314,7 +314,7 @@ WCHAR* _glfwCreateWideStringFromUTF8(const char* source)
|
|||
|
||||
// Returns a UTF-8 string version of the specified wide string
|
||||
//
|
||||
char* _glfwCreateUTF8FromWideString(const WCHAR* source)
|
||||
char* _glfwCreateUTF8FromWideStringWin32(const WCHAR* source)
|
||||
{
|
||||
char* target;
|
||||
int length;
|
||||
|
@ -341,6 +341,9 @@ char* _glfwCreateUTF8FromWideString(const WCHAR* source)
|
|||
|
||||
int _glfwPlatformInit(void)
|
||||
{
|
||||
if (!_glfwInitThreadLocalStorageWin32())
|
||||
return GLFW_FALSE;
|
||||
|
||||
// To make SetForegroundWindow work as we want, we need to fiddle
|
||||
// with the FOREGROUNDLOCKTIMEOUT system setting (we do this as early
|
||||
// as possible in the hope of still being the foreground process)
|
||||
|
@ -359,7 +362,7 @@ int _glfwPlatformInit(void)
|
|||
else if (_glfw_SetProcessDPIAware)
|
||||
_glfw_SetProcessDPIAware();
|
||||
|
||||
if (!_glfwRegisterWindowClass())
|
||||
if (!_glfwRegisterWindowClassWin32())
|
||||
return GLFW_FALSE;
|
||||
|
||||
_glfw.win32.helperWindow = createHelperWindow();
|
||||
|
@ -368,18 +371,23 @@ int _glfwPlatformInit(void)
|
|||
|
||||
_glfwPlatformPollEvents();
|
||||
|
||||
if (!_glfwInitContextAPI())
|
||||
#if defined(_GLFW_WGL)
|
||||
if (!_glfwInitWGL())
|
||||
return GLFW_FALSE;
|
||||
#elif defined(_GLFW_EGL)
|
||||
if (!_glfwInitEGL())
|
||||
return GLFW_FALSE;
|
||||
#endif
|
||||
|
||||
_glfwInitTimer();
|
||||
_glfwInitJoysticks();
|
||||
_glfwInitTimerWin32();
|
||||
_glfwInitJoysticksWin32();
|
||||
|
||||
return GLFW_TRUE;
|
||||
}
|
||||
|
||||
void _glfwPlatformTerminate(void)
|
||||
{
|
||||
_glfwUnregisterWindowClass();
|
||||
_glfwUnregisterWindowClassWin32();
|
||||
|
||||
// Restore previous foreground lock timeout system setting
|
||||
SystemParametersInfoW(SPI_SETFOREGROUNDLOCKTIMEOUT, 0,
|
||||
|
@ -388,8 +396,14 @@ void _glfwPlatformTerminate(void)
|
|||
|
||||
free(_glfw.win32.clipboardString);
|
||||
|
||||
_glfwTerminateJoysticks();
|
||||
_glfwTerminateContextAPI();
|
||||
#if defined(_GLFW_WGL)
|
||||
_glfwTerminateWGL();
|
||||
#elif defined(_GLFW_EGL)
|
||||
_glfwTerminateEGL();
|
||||
#endif
|
||||
|
||||
_glfwTerminateJoysticksWin32();
|
||||
_glfwTerminateThreadLocalStorageWin32();
|
||||
|
||||
if (_glfw.win32.helperWindow)
|
||||
DestroyWindow(_glfw.win32.helperWindow);
|
||||
|
|
|
@ -47,7 +47,7 @@
|
|||
|
||||
// Change the current video mode
|
||||
//
|
||||
GLFWbool _glfwSetVideoMode(_GLFWmonitor* monitor, const GLFWvidmode* desired)
|
||||
GLFWbool _glfwSetVideoModeWin32(_GLFWmonitor* monitor, const GLFWvidmode* desired)
|
||||
{
|
||||
GLFWvidmode current;
|
||||
const GLFWvidmode* best;
|
||||
|
@ -86,7 +86,7 @@ GLFWbool _glfwSetVideoMode(_GLFWmonitor* monitor, const GLFWvidmode* desired)
|
|||
|
||||
// Restore the previously saved (original) video mode
|
||||
//
|
||||
void _glfwRestoreVideoMode(_GLFWmonitor* monitor)
|
||||
void _glfwRestoreVideoModeWin32(_GLFWmonitor* monitor)
|
||||
{
|
||||
if (monitor->win32.modeChanged)
|
||||
{
|
||||
|
@ -141,7 +141,7 @@ _GLFWmonitor** _glfwPlatformGetMonitors(int* count)
|
|||
if (!EnumDisplayDevicesW(adapter.DeviceName, displayIndex, &display, 0))
|
||||
break;
|
||||
|
||||
name = _glfwCreateUTF8FromWideString(display.DeviceString);
|
||||
name = _glfwCreateUTF8FromWideStringWin32(display.DeviceString);
|
||||
if (!name)
|
||||
{
|
||||
_glfwInputError(GLFW_PLATFORM_ERROR,
|
||||
|
|
|
@ -140,7 +140,6 @@ typedef HRESULT (WINAPI * DWMFLUSH_T)(VOID);
|
|||
typedef HRESULT (WINAPI * SETPROCESSDPIAWARENESS_T)(PROCESS_DPI_AWARENESS);
|
||||
#define _glfw_SetProcessDPIAwareness _glfw.win32.shcore.SetProcessDPIAwareness
|
||||
|
||||
#include "win32_tls.h"
|
||||
#include "winmm_joystick.h"
|
||||
|
||||
#if defined(_GLFW_WGL)
|
||||
|
@ -158,6 +157,7 @@ typedef HRESULT (WINAPI * SETPROCESSDPIAWARENESS_T)(PROCESS_DPI_AWARENESS);
|
|||
#define _GLFW_PLATFORM_WINDOW_STATE _GLFWwindowWin32 win32
|
||||
#define _GLFW_PLATFORM_LIBRARY_WINDOW_STATE _GLFWlibraryWin32 win32
|
||||
#define _GLFW_PLATFORM_LIBRARY_TIME_STATE _GLFWtimeWin32 win32_time
|
||||
#define _GLFW_PLATFORM_LIBRARY_TLS_STATE _GLFWtlsWin32 win32_tls
|
||||
#define _GLFW_PLATFORM_MONITOR_STATE _GLFWmonitorWin32 win32
|
||||
#define _GLFW_PLATFORM_CURSOR_STATE _GLFWcursorWin32 win32
|
||||
|
||||
|
@ -259,15 +259,28 @@ typedef struct _GLFWtimeWin32
|
|||
} _GLFWtimeWin32;
|
||||
|
||||
|
||||
GLFWbool _glfwRegisterWindowClass(void);
|
||||
void _glfwUnregisterWindowClass(void);
|
||||
// Win32-specific global TLS data
|
||||
//
|
||||
typedef struct _GLFWtlsWin32
|
||||
{
|
||||
GLFWbool allocated;
|
||||
DWORD context;
|
||||
|
||||
WCHAR* _glfwCreateWideStringFromUTF8(const char* source);
|
||||
char* _glfwCreateUTF8FromWideString(const WCHAR* source);
|
||||
} _GLFWtlsWin32;
|
||||
|
||||
void _glfwInitTimer(void);
|
||||
|
||||
GLFWbool _glfwSetVideoMode(_GLFWmonitor* monitor, const GLFWvidmode* desired);
|
||||
void _glfwRestoreVideoMode(_GLFWmonitor* monitor);
|
||||
GLFWbool _glfwRegisterWindowClassWin32(void);
|
||||
void _glfwUnregisterWindowClassWin32(void);
|
||||
|
||||
GLFWbool _glfwInitThreadLocalStorageWin32(void);
|
||||
void _glfwTerminateThreadLocalStorageWin32(void);
|
||||
|
||||
WCHAR* _glfwCreateWideStringFromUTF8Win32(const char* source);
|
||||
char* _glfwCreateUTF8FromWideStringWin32(const WCHAR* source);
|
||||
|
||||
void _glfwInitTimerWin32(void);
|
||||
|
||||
GLFWbool _glfwSetVideoModeWin32(_GLFWmonitor* monitor, const GLFWvidmode* desired);
|
||||
void _glfwRestoreVideoModeWin32(_GLFWmonitor* monitor);
|
||||
|
||||
#endif // _glfw3_win32_platform_h_
|
||||
|
|
|
@ -49,7 +49,7 @@ static unsigned __int64 getRawTime(void)
|
|||
|
||||
// Initialise timer
|
||||
//
|
||||
void _glfwInitTimer(void)
|
||||
void _glfwInitTimerWin32(void)
|
||||
{
|
||||
unsigned __int64 frequency;
|
||||
|
||||
|
|
|
@ -32,7 +32,7 @@
|
|||
////// GLFW internal API //////
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
|
||||
GLFWbool _glfwCreateContextTLS(void)
|
||||
GLFWbool _glfwInitThreadLocalStorageWin32(void)
|
||||
{
|
||||
_glfw.win32_tls.context = TlsAlloc();
|
||||
if (_glfw.win32_tls.context == TLS_OUT_OF_INDEXES)
|
||||
|
@ -46,22 +46,22 @@ GLFWbool _glfwCreateContextTLS(void)
|
|||
return GLFW_TRUE;
|
||||
}
|
||||
|
||||
void _glfwDestroyContextTLS(void)
|
||||
void _glfwTerminateThreadLocalStorageWin32(void)
|
||||
{
|
||||
if (_glfw.win32_tls.allocated)
|
||||
TlsFree(_glfw.win32_tls.context);
|
||||
}
|
||||
|
||||
void _glfwSetContextTLS(_GLFWwindow* context)
|
||||
{
|
||||
TlsSetValue(_glfw.win32_tls.context, context);
|
||||
}
|
||||
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
////// GLFW platform API //////
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
|
||||
void _glfwPlatformSetCurrentContext(_GLFWwindow* context)
|
||||
{
|
||||
TlsSetValue(_glfw.win32_tls.context, context);
|
||||
}
|
||||
|
||||
_GLFWwindow* _glfwPlatformGetCurrentContext(void)
|
||||
{
|
||||
return TlsGetValue(_glfw.win32_tls.context);
|
||||
|
|
|
@ -1,48 +0,0 @@
|
|||
//========================================================================
|
||||
// GLFW 3.2 Win32 - www.glfw.org
|
||||
//------------------------------------------------------------------------
|
||||
// Copyright (c) 2002-2006 Marcus Geelnard
|
||||
// Copyright (c) 2006-2010 Camilla Berglund <elmindreda@elmindreda.org>
|
||||
//
|
||||
// This software is provided 'as-is', without any express or implied
|
||||
// warranty. In no event will the authors be held liable for any damages
|
||||
// arising from the use of this software.
|
||||
//
|
||||
// Permission is granted to anyone to use this software for any purpose,
|
||||
// including commercial applications, and to alter it and redistribute it
|
||||
// freely, subject to the following restrictions:
|
||||
//
|
||||
// 1. The origin of this software must not be misrepresented; you must not
|
||||
// claim that you wrote the original software. If you use this software
|
||||
// in a product, an acknowledgment in the product documentation would
|
||||
// be appreciated but is not required.
|
||||
//
|
||||
// 2. Altered source versions must be plainly marked as such, and must not
|
||||
// be misrepresented as being the original software.
|
||||
//
|
||||
// 3. This notice may not be removed or altered from any source
|
||||
// distribution.
|
||||
//
|
||||
//========================================================================
|
||||
|
||||
#ifndef _glfw3_win32_tls_h_
|
||||
#define _glfw3_win32_tls_h_
|
||||
|
||||
#define _GLFW_PLATFORM_LIBRARY_TLS_STATE _GLFWtlsWin32 win32_tls
|
||||
|
||||
|
||||
// Win32-specific global TLS data
|
||||
//
|
||||
typedef struct _GLFWtlsWin32
|
||||
{
|
||||
GLFWbool allocated;
|
||||
DWORD context;
|
||||
|
||||
} _GLFWtlsWin32;
|
||||
|
||||
|
||||
GLFWbool _glfwCreateContextTLS(void);
|
||||
void _glfwDestroyContextTLS(void);
|
||||
void _glfwSetContextTLS(_GLFWwindow* context);
|
||||
|
||||
#endif // _glfw3_win32_tls_h_
|
|
@ -229,7 +229,7 @@ static GLFWbool enterFullscreenMode(_GLFWwindow* window)
|
|||
GLFWbool status;
|
||||
int xpos, ypos;
|
||||
|
||||
status = _glfwSetVideoMode(window->monitor, &window->videoMode);
|
||||
status = _glfwSetVideoModeWin32(window->monitor, &window->videoMode);
|
||||
|
||||
_glfwPlatformGetVideoMode(window->monitor, &mode);
|
||||
_glfwPlatformGetMonitorPos(window->monitor, &xpos, &ypos);
|
||||
|
@ -244,7 +244,7 @@ static GLFWbool enterFullscreenMode(_GLFWwindow* window)
|
|||
//
|
||||
static void leaveFullscreenMode(_GLFWwindow* window)
|
||||
{
|
||||
_glfwRestoreVideoMode(window->monitor);
|
||||
_glfwRestoreVideoModeWin32(window->monitor);
|
||||
}
|
||||
|
||||
// Window callback function (handles window messages)
|
||||
|
@ -628,7 +628,7 @@ static LRESULT CALLBACK windowProc(HWND hWnd, UINT uMsg,
|
|||
WCHAR* buffer = calloc(length + 1, sizeof(WCHAR));
|
||||
|
||||
DragQueryFileW(drop, i, buffer, length + 1);
|
||||
paths[i] = _glfwCreateUTF8FromWideString(buffer);
|
||||
paths[i] = _glfwCreateUTF8FromWideStringWin32(buffer);
|
||||
|
||||
free(buffer);
|
||||
}
|
||||
|
@ -676,7 +676,7 @@ static int createWindow(_GLFWwindow* window, const _GLFWwndconfig* wndconfig)
|
|||
&fullWidth, &fullHeight);
|
||||
}
|
||||
|
||||
wideTitle = _glfwCreateWideStringFromUTF8(wndconfig->title);
|
||||
wideTitle = _glfwCreateWideStringFromUTF8Win32(wndconfig->title);
|
||||
if (!wideTitle)
|
||||
{
|
||||
_glfwInputError(GLFW_PLATFORM_ERROR,
|
||||
|
@ -751,7 +751,7 @@ static void destroyWindow(_GLFWwindow* window)
|
|||
|
||||
// Registers the GLFW window class
|
||||
//
|
||||
GLFWbool _glfwRegisterWindowClass(void)
|
||||
GLFWbool _glfwRegisterWindowClassWin32(void)
|
||||
{
|
||||
WNDCLASSEXW wc;
|
||||
|
||||
|
@ -788,7 +788,7 @@ GLFWbool _glfwRegisterWindowClass(void)
|
|||
|
||||
// Unregisters the GLFW window class
|
||||
//
|
||||
void _glfwUnregisterWindowClass(void)
|
||||
void _glfwUnregisterWindowClassWin32(void)
|
||||
{
|
||||
UnregisterClassW(_GLFW_WNDCLASSNAME, GetModuleHandleW(NULL));
|
||||
}
|
||||
|
@ -810,11 +810,11 @@ int _glfwPlatformCreateWindow(_GLFWwindow* window,
|
|||
|
||||
if (ctxconfig->api != GLFW_NO_API)
|
||||
{
|
||||
if (!_glfwCreateContext(window, ctxconfig, fbconfig))
|
||||
#if defined(_GLFW_WGL)
|
||||
if (!_glfwCreateContextWGL(window, ctxconfig, fbconfig))
|
||||
return GLFW_FALSE;
|
||||
|
||||
#if defined(_GLFW_WGL)
|
||||
status = _glfwAnalyzeContext(window, ctxconfig, fbconfig);
|
||||
status = _glfwAnalyzeContextWGL(window, ctxconfig, fbconfig);
|
||||
|
||||
if (status == _GLFW_RECREATION_IMPOSSIBLE)
|
||||
return GLFW_FALSE;
|
||||
|
@ -844,16 +844,19 @@ int _glfwPlatformCreateWindow(_GLFWwindow* window,
|
|||
|
||||
// Next destroy the Win32 window and WGL context (without resetting
|
||||
// or destroying the GLFW window object)
|
||||
_glfwDestroyContext(window);
|
||||
_glfwDestroyContextWGL(window);
|
||||
destroyWindow(window);
|
||||
|
||||
// ...and then create them again, this time with better APIs
|
||||
if (!createWindow(window, wndconfig))
|
||||
return GLFW_FALSE;
|
||||
if (!_glfwCreateContext(window, ctxconfig, fbconfig))
|
||||
if (!_glfwCreateContextWGL(window, ctxconfig, fbconfig))
|
||||
return GLFW_FALSE;
|
||||
}
|
||||
#endif // _GLFW_WGL
|
||||
#elif defined(_GLFW_EGL)
|
||||
if (!_glfwCreateContextEGL(window, ctxconfig, fbconfig))
|
||||
return GLFW_FALSE;
|
||||
#endif
|
||||
}
|
||||
|
||||
if (window->monitor)
|
||||
|
@ -872,14 +875,20 @@ void _glfwPlatformDestroyWindow(_GLFWwindow* window)
|
|||
leaveFullscreenMode(window);
|
||||
|
||||
if (window->context.api != GLFW_NO_API)
|
||||
_glfwDestroyContext(window);
|
||||
{
|
||||
#if defined(_GLFW_WGL)
|
||||
_glfwDestroyContextWGL(window);
|
||||
#elif defined(_GLFW_EGL)
|
||||
_glfwDestroyContextEGL(window);
|
||||
#endif
|
||||
}
|
||||
|
||||
destroyWindow(window);
|
||||
}
|
||||
|
||||
void _glfwPlatformSetWindowTitle(_GLFWwindow* window, const char* title)
|
||||
{
|
||||
WCHAR* wideTitle = _glfwCreateWideStringFromUTF8(title);
|
||||
WCHAR* wideTitle = _glfwCreateWideStringFromUTF8Win32(title);
|
||||
if (!wideTitle)
|
||||
{
|
||||
_glfwInputError(GLFW_PLATFORM_ERROR,
|
||||
|
@ -1318,7 +1327,7 @@ void _glfwPlatformSetClipboardString(_GLFWwindow* window, const char* string)
|
|||
HANDLE stringHandle;
|
||||
size_t wideSize;
|
||||
|
||||
wideString = _glfwCreateWideStringFromUTF8(string);
|
||||
wideString = _glfwCreateWideStringFromUTF8Win32(string);
|
||||
if (!wideString)
|
||||
{
|
||||
_glfwInputError(GLFW_PLATFORM_ERROR,
|
||||
|
@ -1379,7 +1388,7 @@ const char* _glfwPlatformGetClipboardString(_GLFWwindow* window)
|
|||
|
||||
free(_glfw.win32.clipboardString);
|
||||
_glfw.win32.clipboardString =
|
||||
_glfwCreateUTF8FromWideString(GlobalLock(stringHandle));
|
||||
_glfwCreateUTF8FromWideStringWin32(GlobalLock(stringHandle));
|
||||
|
||||
GlobalUnlock(stringHandle);
|
||||
CloseClipboard();
|
||||
|
|
|
@ -52,13 +52,13 @@ static float normalizeAxis(DWORD pos, DWORD min, DWORD max)
|
|||
|
||||
// Initialize joystick interface
|
||||
//
|
||||
void _glfwInitJoysticks(void)
|
||||
void _glfwInitJoysticksWin32(void)
|
||||
{
|
||||
}
|
||||
|
||||
// Close all opened joystick handles
|
||||
//
|
||||
void _glfwTerminateJoysticks(void)
|
||||
void _glfwTerminateJoysticksWin32(void)
|
||||
{
|
||||
int i;
|
||||
|
||||
|
@ -170,7 +170,7 @@ const char* _glfwPlatformGetJoystickName(int joy)
|
|||
return NULL;
|
||||
|
||||
free(_glfw.winmm_js[joy].name);
|
||||
_glfw.winmm_js[joy].name = _glfwCreateUTF8FromWideString(jc.szPname);
|
||||
_glfw.winmm_js[joy].name = _glfwCreateUTF8FromWideStringWin32(jc.szPname);
|
||||
|
||||
return _glfw.winmm_js[joy].name;
|
||||
}
|
||||
|
|
|
@ -395,7 +395,7 @@ static void registryHandleGlobal(void* data,
|
|||
}
|
||||
else if (strcmp(interface, "wl_output") == 0)
|
||||
{
|
||||
_glfwAddOutput(name, version);
|
||||
_glfwAddOutputWayland(name, version);
|
||||
}
|
||||
else if (strcmp(interface, "wl_seat") == 0)
|
||||
{
|
||||
|
@ -581,11 +581,14 @@ int _glfwPlatformInit(void)
|
|||
// Sync so we got all initial output events
|
||||
wl_display_roundtrip(_glfw.wl.display);
|
||||
|
||||
if (!_glfwInitContextAPI())
|
||||
if (!_glfwInitThreadLocalStoragePOSIX())
|
||||
return GLFW_FALSE;
|
||||
|
||||
_glfwInitTimer();
|
||||
_glfwInitJoysticks();
|
||||
if (!_glfwInitEGL())
|
||||
return GLFW_FALSE;
|
||||
|
||||
_glfwInitTimerPOSIX();
|
||||
_glfwInitJoysticksLinux();
|
||||
|
||||
if (_glfw.wl.pointer && _glfw.wl.shm)
|
||||
{
|
||||
|
@ -605,8 +608,9 @@ int _glfwPlatformInit(void)
|
|||
|
||||
void _glfwPlatformTerminate(void)
|
||||
{
|
||||
_glfwTerminateContextAPI();
|
||||
_glfwTerminateJoysticks();
|
||||
_glfwTerminateEGL();
|
||||
_glfwTerminateJoysticksLinux();
|
||||
_glfwTerminateThreadLocalStoragePOSIX();
|
||||
|
||||
if (_glfw.wl.cursorTheme)
|
||||
wl_cursor_theme_destroy(_glfw.wl.cursorTheme);
|
||||
|
|
|
@ -111,7 +111,7 @@ static const struct wl_output_listener output_listener = {
|
|||
////// GLFW internal API //////
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
|
||||
void _glfwAddOutput(uint32_t name, uint32_t version)
|
||||
void _glfwAddOutputWayland(uint32_t name, uint32_t version)
|
||||
{
|
||||
_GLFWmonitor *monitor;
|
||||
struct wl_output *output;
|
||||
|
|
|
@ -138,6 +138,6 @@ typedef struct _GLFWcursorWayland
|
|||
} _GLFWcursorWayland;
|
||||
|
||||
|
||||
void _glfwAddOutput(uint32_t name, uint32_t version);
|
||||
void _glfwAddOutputWayland(uint32_t name, uint32_t version);
|
||||
|
||||
#endif // _glfw3_wayland_platform_h_
|
||||
|
|
|
@ -243,7 +243,7 @@ int _glfwPlatformCreateWindow(_GLFWwindow* window,
|
|||
|
||||
if (ctxconfig->api != GLFW_NO_API)
|
||||
{
|
||||
if (!_glfwCreateContext(window, ctxconfig, fbconfig))
|
||||
if (!_glfwCreateContextEGL(window, ctxconfig, fbconfig))
|
||||
return GLFW_FALSE;
|
||||
}
|
||||
|
||||
|
@ -278,7 +278,7 @@ void _glfwPlatformDestroyWindow(_GLFWwindow* window)
|
|||
_glfwInputWindowFocus(window, GLFW_FALSE);
|
||||
}
|
||||
|
||||
_glfwDestroyContext(window);
|
||||
_glfwDestroyContextEGL(window);
|
||||
|
||||
if (window->wl.native)
|
||||
wl_egl_window_destroy(window->wl.native);
|
||||
|
|
|
@ -387,7 +387,7 @@ static void detectEWMH(void)
|
|||
return;
|
||||
|
||||
// Then we look for the _NET_SUPPORTING_WM_CHECK property of the root window
|
||||
if (_glfwGetWindowProperty(_glfw.x11.root,
|
||||
if (_glfwGetWindowPropertyX11(_glfw.x11.root,
|
||||
supportingWmCheck,
|
||||
XA_WINDOW,
|
||||
(unsigned char**) &windowFromRoot) != 1)
|
||||
|
@ -397,11 +397,11 @@ static void detectEWMH(void)
|
|||
return;
|
||||
}
|
||||
|
||||
_glfwGrabXErrorHandler();
|
||||
_glfwGrabErrorHandlerX11();
|
||||
|
||||
// It should be the ID of a child window (of the root)
|
||||
// Then we look for the same property on the child window
|
||||
if (_glfwGetWindowProperty(*windowFromRoot,
|
||||
if (_glfwGetWindowPropertyX11(*windowFromRoot,
|
||||
supportingWmCheck,
|
||||
XA_WINDOW,
|
||||
(unsigned char**) &windowFromChild) != 1)
|
||||
|
@ -412,7 +412,7 @@ static void detectEWMH(void)
|
|||
return;
|
||||
}
|
||||
|
||||
_glfwReleaseXErrorHandler();
|
||||
_glfwReleaseErrorHandlerX11();
|
||||
|
||||
// It should be the ID of that same child window
|
||||
if (*windowFromRoot != *windowFromChild)
|
||||
|
@ -432,7 +432,7 @@ static void detectEWMH(void)
|
|||
|
||||
// Now we need to check the _NET_SUPPORTED property of the root window
|
||||
// It should be a list of supported WM protocol and state atoms
|
||||
atomCount = _glfwGetWindowProperty(_glfw.x11.root,
|
||||
atomCount = _glfwGetWindowPropertyX11(_glfw.x11.root,
|
||||
wmSupported,
|
||||
XA_ATOM,
|
||||
(unsigned char**) &supportedAtoms);
|
||||
|
@ -635,7 +635,7 @@ static Cursor createNULLCursor(void)
|
|||
|
||||
memset(pixels, 0, sizeof(pixels));
|
||||
|
||||
return _glfwCreateCursor(&image, 0, 0);
|
||||
return _glfwCreateCursorX11(&image, 0, 0);
|
||||
}
|
||||
|
||||
// X error handler
|
||||
|
@ -653,7 +653,7 @@ static int errorHandler(Display *display, XErrorEvent* event)
|
|||
|
||||
// Sets the X error handler callback
|
||||
//
|
||||
void _glfwGrabXErrorHandler(void)
|
||||
void _glfwGrabErrorHandlerX11(void)
|
||||
{
|
||||
_glfw.x11.errorCode = Success;
|
||||
XSetErrorHandler(errorHandler);
|
||||
|
@ -661,7 +661,7 @@ void _glfwGrabXErrorHandler(void)
|
|||
|
||||
// Clears the X error handler callback
|
||||
//
|
||||
void _glfwReleaseXErrorHandler(void)
|
||||
void _glfwReleaseErrorHandlerX11(void)
|
||||
{
|
||||
// Synchronize to make sure all commands are processed
|
||||
XSync(_glfw.x11.display, False);
|
||||
|
@ -670,7 +670,7 @@ void _glfwReleaseXErrorHandler(void)
|
|||
|
||||
// Reports the specified error, appending information about the last X error
|
||||
//
|
||||
void _glfwInputXError(int error, const char* message)
|
||||
void _glfwInputErrorX11(int error, const char* message)
|
||||
{
|
||||
char buffer[8192];
|
||||
XGetErrorText(_glfw.x11.display, _glfw.x11.errorCode,
|
||||
|
@ -681,7 +681,7 @@ void _glfwInputXError(int error, const char* message)
|
|||
|
||||
// Creates a native cursor object from the specified image and hotspot
|
||||
//
|
||||
Cursor _glfwCreateCursor(const GLFWimage* image, int xhot, int yhot)
|
||||
Cursor _glfwCreateCursorX11(const GLFWimage* image, int xhot, int yhot)
|
||||
{
|
||||
int i;
|
||||
Cursor cursor;
|
||||
|
@ -768,13 +768,21 @@ int _glfwPlatformInit(void)
|
|||
}
|
||||
}
|
||||
|
||||
if (!_glfwInitContextAPI())
|
||||
if (!_glfwInitThreadLocalStoragePOSIX())
|
||||
return GLFW_FALSE;
|
||||
|
||||
if (!_glfwInitJoysticks())
|
||||
#if defined(_GLFW_GLX)
|
||||
if (!_glfwInitGLX())
|
||||
return GLFW_FALSE;
|
||||
#elif defined(_GLFW_EGL)
|
||||
if (!_glfwInitEGL())
|
||||
return GLFW_FALSE;
|
||||
#endif
|
||||
|
||||
if (!_glfwInitJoysticksLinux())
|
||||
return GLFW_FALSE;
|
||||
|
||||
_glfwInitTimer();
|
||||
_glfwInitTimerPOSIX();
|
||||
|
||||
return GLFW_TRUE;
|
||||
}
|
||||
|
@ -795,6 +803,10 @@ void _glfwPlatformTerminate(void)
|
|||
_glfw.x11.im = NULL;
|
||||
}
|
||||
|
||||
#if defined(_GLFW_EGL)
|
||||
_glfwTerminateEGL();
|
||||
#endif
|
||||
|
||||
if (_glfw.x11.display)
|
||||
{
|
||||
XCloseDisplay(_glfw.x11.display);
|
||||
|
@ -803,8 +815,12 @@ void _glfwPlatformTerminate(void)
|
|||
|
||||
// NOTE: This needs to be done after XCloseDisplay, as libGL registers
|
||||
// cleanup callbacks that get called by it
|
||||
_glfwTerminateContextAPI();
|
||||
_glfwTerminateJoysticks();
|
||||
#if defined(_GLFW_GLX)
|
||||
_glfwTerminateGLX();
|
||||
#endif
|
||||
|
||||
_glfwTerminateJoysticksLinux();
|
||||
_glfwTerminateThreadLocalStoragePOSIX();
|
||||
}
|
||||
|
||||
const char* _glfwPlatformGetVersionString(void)
|
||||
|
|
|
@ -97,7 +97,7 @@ static GLFWvidmode vidmodeFromModeInfo(const XRRModeInfo* mi,
|
|||
|
||||
// Set the current video mode for the specified monitor
|
||||
//
|
||||
GLFWbool _glfwSetVideoMode(_GLFWmonitor* monitor, const GLFWvidmode* desired)
|
||||
GLFWbool _glfwSetVideoModeX11(_GLFWmonitor* monitor, const GLFWvidmode* desired)
|
||||
{
|
||||
if (_glfw.x11.randr.available && !_glfw.x11.randr.monitorBroken)
|
||||
{
|
||||
|
@ -164,7 +164,7 @@ GLFWbool _glfwSetVideoMode(_GLFWmonitor* monitor, const GLFWvidmode* desired)
|
|||
|
||||
// Restore the saved (original) video mode for the specified monitor
|
||||
//
|
||||
void _glfwRestoreVideoMode(_GLFWmonitor* monitor)
|
||||
void _glfwRestoreVideoModeX11(_GLFWmonitor* monitor)
|
||||
{
|
||||
if (_glfw.x11.randr.available && !_glfw.x11.randr.monitorBroken)
|
||||
{
|
||||
|
|
|
@ -253,18 +253,18 @@ typedef struct _GLFWcursorX11
|
|||
} _GLFWcursorX11;
|
||||
|
||||
|
||||
GLFWbool _glfwSetVideoMode(_GLFWmonitor* monitor, const GLFWvidmode* desired);
|
||||
void _glfwRestoreVideoMode(_GLFWmonitor* monitor);
|
||||
GLFWbool _glfwSetVideoModeX11(_GLFWmonitor* monitor, const GLFWvidmode* desired);
|
||||
void _glfwRestoreVideoModeX11(_GLFWmonitor* monitor);
|
||||
|
||||
Cursor _glfwCreateCursor(const GLFWimage* image, int xhot, int yhot);
|
||||
Cursor _glfwCreateCursorX11(const GLFWimage* image, int xhot, int yhot);
|
||||
|
||||
unsigned long _glfwGetWindowProperty(Window window,
|
||||
unsigned long _glfwGetWindowPropertyX11(Window window,
|
||||
Atom property,
|
||||
Atom type,
|
||||
unsigned char** value);
|
||||
|
||||
void _glfwGrabXErrorHandler(void);
|
||||
void _glfwReleaseXErrorHandler(void);
|
||||
void _glfwInputXError(int error, const char* message);
|
||||
void _glfwGrabErrorHandlerX11(void);
|
||||
void _glfwReleaseErrorHandlerX11(void);
|
||||
void _glfwInputErrorX11(int error, const char* message);
|
||||
|
||||
#endif // _glfw3_x11_platform_h_
|
||||
|
|
|
@ -83,7 +83,7 @@ static int getWindowState(_GLFWwindow* window)
|
|||
Window icon;
|
||||
} *state = NULL;
|
||||
|
||||
if (_glfwGetWindowProperty(window->x11.handle,
|
||||
if (_glfwGetWindowPropertyX11(window->x11.handle,
|
||||
_glfw.x11.WM_STATE,
|
||||
_glfw.x11.WM_STATE,
|
||||
(unsigned char**) &state) >= 2)
|
||||
|
@ -272,7 +272,7 @@ static GLFWbool createWindow(_GLFWwindow* window,
|
|||
ExposureMask | FocusChangeMask | VisibilityChangeMask |
|
||||
EnterWindowMask | LeaveWindowMask | PropertyChangeMask;
|
||||
|
||||
_glfwGrabXErrorHandler();
|
||||
_glfwGrabErrorHandlerX11();
|
||||
|
||||
window->x11.handle = XCreateWindow(_glfw.x11.display,
|
||||
_glfw.x11.root,
|
||||
|
@ -285,11 +285,11 @@ static GLFWbool createWindow(_GLFWwindow* window,
|
|||
wamask,
|
||||
&wa);
|
||||
|
||||
_glfwReleaseXErrorHandler();
|
||||
_glfwReleaseErrorHandlerX11();
|
||||
|
||||
if (!window->x11.handle)
|
||||
{
|
||||
_glfwInputXError(GLFW_PLATFORM_ERROR,
|
||||
_glfwInputErrorX11(GLFW_PLATFORM_ERROR,
|
||||
"X11: Failed to create window");
|
||||
return GLFW_FALSE;
|
||||
}
|
||||
|
@ -552,7 +552,7 @@ static Atom writeTargetToProperty(const XSelectionRequestEvent* request)
|
|||
Atom* targets;
|
||||
unsigned long i, count;
|
||||
|
||||
count = _glfwGetWindowProperty(request->requestor,
|
||||
count = _glfwGetWindowPropertyX11(request->requestor,
|
||||
request->property,
|
||||
_glfw.x11.ATOM_PAIR,
|
||||
(unsigned char**) &targets);
|
||||
|
@ -728,7 +728,7 @@ static void enterFullscreenMode(_GLFWwindow* window)
|
|||
|
||||
_glfw.x11.saver.count++;
|
||||
|
||||
_glfwSetVideoMode(window->monitor, &window->videoMode);
|
||||
_glfwSetVideoModeX11(window->monitor, &window->videoMode);
|
||||
|
||||
if (_glfw.x11.NET_WM_BYPASS_COMPOSITOR)
|
||||
{
|
||||
|
@ -793,7 +793,7 @@ static void enterFullscreenMode(_GLFWwindow* window)
|
|||
//
|
||||
static void leaveFullscreenMode(_GLFWwindow* window)
|
||||
{
|
||||
_glfwRestoreVideoMode(window->monitor);
|
||||
_glfwRestoreVideoModeX11(window->monitor);
|
||||
|
||||
_glfw.x11.saver.count--;
|
||||
|
||||
|
@ -1243,7 +1243,7 @@ static void processEvent(XEvent *event)
|
|||
// The converted data from the drag operation has arrived
|
||||
char* data;
|
||||
const int result =
|
||||
_glfwGetWindowProperty(event->xselection.requestor,
|
||||
_glfwGetWindowPropertyX11(event->xselection.requestor,
|
||||
event->xselection.property,
|
||||
event->xselection.target,
|
||||
(unsigned char**) &data);
|
||||
|
@ -1429,7 +1429,7 @@ static void processEvent(XEvent *event)
|
|||
// Retrieve a single window property of the specified type
|
||||
// Inspired by fghGetWindowProperty from freeglut
|
||||
//
|
||||
unsigned long _glfwGetWindowProperty(Window window,
|
||||
unsigned long _glfwGetWindowPropertyX11(Window window,
|
||||
Atom property,
|
||||
Atom type,
|
||||
unsigned char** value)
|
||||
|
@ -1470,16 +1470,26 @@ int _glfwPlatformCreateWindow(_GLFWwindow* window,
|
|||
Visual* visual;
|
||||
int depth;
|
||||
|
||||
if (!_glfwChooseVisual(ctxconfig, fbconfig, &visual, &depth))
|
||||
#if defined(_GLFW_GLX)
|
||||
if (!_glfwChooseVisualGLX(ctxconfig, fbconfig, &visual, &depth))
|
||||
return GLFW_FALSE;
|
||||
#elif defined(_GLFW_EGL)
|
||||
if (!_glfwChooseVisualEGL(ctxconfig, fbconfig, &visual, &depth))
|
||||
return GLFW_FALSE;
|
||||
#endif
|
||||
|
||||
if (!createWindow(window, wndconfig, visual, depth))
|
||||
return GLFW_FALSE;
|
||||
|
||||
if (ctxconfig->api != GLFW_NO_API)
|
||||
{
|
||||
if (!_glfwCreateContext(window, ctxconfig, fbconfig))
|
||||
#if defined(_GLFW_GLX)
|
||||
if (!_glfwCreateContextGLX(window, ctxconfig, fbconfig))
|
||||
return GLFW_FALSE;
|
||||
#elif defined(_GLFW_EGL)
|
||||
if (!_glfwCreateContextEGL(window, ctxconfig, fbconfig))
|
||||
return GLFW_FALSE;
|
||||
#endif
|
||||
}
|
||||
|
||||
if (wndconfig->monitor)
|
||||
|
@ -1503,7 +1513,13 @@ void _glfwPlatformDestroyWindow(_GLFWwindow* window)
|
|||
}
|
||||
|
||||
if (window->context.api != GLFW_NO_API)
|
||||
_glfwDestroyContext(window);
|
||||
{
|
||||
#if defined(_GLFW_GLX)
|
||||
_glfwDestroyContextGLX(window);
|
||||
#elif defined(_GLFW_EGL)
|
||||
_glfwDestroyContextEGL(window);
|
||||
#endif
|
||||
}
|
||||
|
||||
if (window->x11.handle)
|
||||
{
|
||||
|
@ -1610,7 +1626,7 @@ void _glfwPlatformSetWindowSize(_GLFWwindow* window, int width, int height)
|
|||
{
|
||||
if (window->monitor)
|
||||
{
|
||||
_glfwSetVideoMode(window->monitor, &window->videoMode);
|
||||
_glfwSetVideoModeX11(window->monitor, &window->videoMode);
|
||||
|
||||
if (!_glfw.x11.NET_WM_STATE || !_glfw.x11.NET_WM_STATE_FULLSCREEN)
|
||||
{
|
||||
|
@ -1751,7 +1767,7 @@ void _glfwPlatformGetWindowFrameSize(_GLFWwindow* window,
|
|||
}
|
||||
}
|
||||
|
||||
if (_glfwGetWindowProperty(window->x11.handle,
|
||||
if (_glfwGetWindowPropertyX11(window->x11.handle,
|
||||
_glfw.x11.NET_FRAME_EXTENTS,
|
||||
XA_CARDINAL,
|
||||
(unsigned char**) &extents) == 4)
|
||||
|
@ -1971,7 +1987,7 @@ int _glfwPlatformCreateCursor(_GLFWcursor* cursor,
|
|||
const GLFWimage* image,
|
||||
int xhot, int yhot)
|
||||
{
|
||||
cursor->x11.handle = _glfwCreateCursor(image, xhot, yhot);
|
||||
cursor->x11.handle = _glfwCreateCursorX11(image, xhot, yhot);
|
||||
if (!cursor->x11.handle)
|
||||
return GLFW_FALSE;
|
||||
|
||||
|
@ -2066,7 +2082,7 @@ const char* _glfwPlatformGetClipboardString(_GLFWwindow* window)
|
|||
if (event.xselection.property == None)
|
||||
continue;
|
||||
|
||||
if (_glfwGetWindowProperty(event.xselection.requestor,
|
||||
if (_glfwGetWindowPropertyX11(event.xselection.requestor,
|
||||
event.xselection.property,
|
||||
event.xselection.target,
|
||||
(unsigned char**) &data))
|
||||
|
|
Loading…
Reference in New Issue
Block a user