1
0
Fork 0
mirror of https://github.com/gwm17/glfw.git synced 2024-11-26 20:28:49 -05:00

Renamed global struct and substructs.

Renamed _glfwLibrary to _glfw and made all substructs lower-case, making
global variable names easier to read and type.  Partially inspired by the
internal naming conventions of glwt.
This commit is contained in:
Camilla Berglund 2013-01-02 01:40:42 +01:00
parent 45459d5a34
commit b72a97d531
39 changed files with 1017 additions and 1054 deletions

View File

@ -74,9 +74,9 @@ const char* _glfwPlatformGetClipboardString(_GLFWwindow* window)
return NULL;
}
free(_glfwLibrary.NS.clipboardString);
_glfwLibrary.NS.clipboardString = strdup([object UTF8String]);
free(_glfw.ns.clipboardString);
_glfw.ns.clipboardString = strdup([object UTF8String]);
return _glfwLibrary.NS.clipboardString;
return _glfw.ns.clipboardString;
}

View File

@ -52,7 +52,7 @@ void _glfwPlatformGetGammaRamp(GLFWgammaramp* ramp)
CGGammaValue blue[GLFW_GAMMA_RAMP_SIZE];
// For now, don't support anything that is not GLFW_GAMMA_RAMP_SIZE
if (_glfwLibrary.originalRampSize != GLFW_GAMMA_RAMP_SIZE)
if (_glfw.originalRampSize != GLFW_GAMMA_RAMP_SIZE)
return;
CGGetDisplayTransferByTable(CGMainDisplayID(), GLFW_GAMMA_RAMP_SIZE, red, green, blue,
@ -80,7 +80,7 @@ void _glfwPlatformSetGammaRamp(const GLFWgammaramp* ramp)
CGGammaValue blue[GLFW_GAMMA_RAMP_SIZE];
// For now, don't support anything that is not GLFW_GAMMA_RAMP_SIZE
if (_glfwLibrary.originalRampSize != GLFW_GAMMA_RAMP_SIZE)
if (_glfw.originalRampSize != GLFW_GAMMA_RAMP_SIZE)
return;
// Convert to float & take the difference of the original gamma and

View File

@ -79,11 +79,11 @@ static void changeToResourcesDirectory(void)
int _glfwPlatformInit(void)
{
_glfwLibrary.NS.autoreleasePool = [[NSAutoreleasePool alloc] init];
_glfw.ns.autoreleasePool = [[NSAutoreleasePool alloc] init];
_glfwLibrary.NSGL.framework =
_glfw.nsgl.framework =
CFBundleGetBundleWithIdentifier(CFSTR("com.apple.opengl"));
if (_glfwLibrary.NSGL.framework == NULL)
if (_glfw.nsgl.framework == NULL)
{
_glfwInputError(GLFW_PLATFORM_ERROR,
"NSGL: Failed to locate OpenGL framework");
@ -93,9 +93,9 @@ int _glfwPlatformInit(void)
changeToResourcesDirectory();
// Save the original gamma ramp
_glfwLibrary.originalRampSize = CGDisplayGammaTableCapacity(CGMainDisplayID());
_glfwPlatformGetGammaRamp(&_glfwLibrary.originalRamp);
_glfwLibrary.currentRamp = _glfwLibrary.originalRamp;
_glfw.originalRampSize = CGDisplayGammaTableCapacity(CGMainDisplayID());
_glfwPlatformGetGammaRamp(&_glfw.originalRamp);
_glfw.currentRamp = _glfw.originalRamp;
_glfwInitTimer();
@ -104,12 +104,11 @@ int _glfwPlatformInit(void)
if (!_glfwInitOpenGL())
return GL_FALSE;
_glfwLibrary.NS.eventSource = CGEventSourceCreate(kCGEventSourceStateHIDSystemState);
if (!_glfwLibrary.NS.eventSource)
_glfw.ns.eventSource = CGEventSourceCreate(kCGEventSourceStateHIDSystemState);
if (!_glfw.ns.eventSource)
return GL_FALSE;
CGEventSourceSetLocalEventsSuppressionInterval(_glfwLibrary.NS.eventSource,
0.0);
CGEventSourceSetLocalEventsSuppressionInterval(_glfw.ns.eventSource, 0.0);
return GL_TRUE;
}
@ -123,22 +122,22 @@ void _glfwPlatformTerminate(void)
{
// TODO: Probably other cleanup
if (_glfwLibrary.NS.eventSource)
if (_glfw.ns.eventSource)
{
CFRelease(_glfwLibrary.NS.eventSource);
_glfwLibrary.NS.eventSource = NULL;
CFRelease(_glfw.ns.eventSource);
_glfw.ns.eventSource = NULL;
}
// Restore the original gamma ramp
if (_glfwLibrary.rampChanged)
_glfwPlatformSetGammaRamp(&_glfwLibrary.originalRamp);
if (_glfw.rampChanged)
_glfwPlatformSetGammaRamp(&_glfw.originalRamp);
[NSApp setDelegate:nil];
[_glfwLibrary.NS.delegate release];
_glfwLibrary.NS.delegate = nil;
[_glfw.ns.delegate release];
_glfw.ns.delegate = nil;
[_glfwLibrary.NS.autoreleasePool release];
_glfwLibrary.NS.autoreleasePool = nil;
[_glfw.ns.autoreleasePool release];
_glfw.ns.autoreleasePool = nil;
_glfwTerminateJoysticks();

View File

@ -190,7 +190,7 @@ GLboolean _glfwSetVideoMode(int* width, int* height, int* bpp)
return GL_FALSE;
}
_glfwLibrary.NS.previousMode = CGDisplayCopyDisplayMode(CGMainDisplayID());
_glfw.ns.previousMode = CGDisplayCopyDisplayMode(CGMainDisplayID());
CGDisplayCapture(CGMainDisplayID());
CGDisplaySetDisplayMode(CGMainDisplayID(), bestMode, NULL);
@ -206,10 +206,7 @@ GLboolean _glfwSetVideoMode(int* width, int* height, int* bpp)
void _glfwRestoreVideoMode(void)
{
CGDisplaySetDisplayMode(CGMainDisplayID(),
_glfwLibrary.NS.previousMode,
NULL);
CGDisplaySetDisplayMode(CGMainDisplayID(), _glfw.ns.previousMode, NULL);
CGDisplayRelease(CGMainDisplayID());
}
@ -256,7 +253,7 @@ _GLFWmonitor** _glfwPlatformGetMonitors(int* count)
size.width, size.height,
bounds.origin.x, bounds.origin.y);
monitors[found]->NS.displayID = displays[i];
monitors[found]->ns.displayID = displays[i];
found++;
}
@ -286,7 +283,7 @@ GLFWvidmode* _glfwPlatformGetVideoModes(_GLFWmonitor* monitor, int* found)
CFIndex count, i;
GLFWvidmode* result;
modes = CGDisplayCopyAllDisplayModes(monitor->NS.displayID, NULL);
modes = CGDisplayCopyAllDisplayModes(monitor->ns.displayID, NULL);
count = CFArrayGetCount(modes);
result = (GLFWvidmode*) malloc(sizeof(GLFWvidmode) * count);
@ -317,7 +314,7 @@ void _glfwPlatformGetVideoMode(_GLFWmonitor* monitor, GLFWvidmode *mode)
{
CGDisplayModeRef displayMode;
displayMode = CGDisplayCopyDisplayMode(monitor->NS.displayID);
displayMode = CGDisplayCopyDisplayMode(monitor->ns.displayID);
*mode = vidmodeFromCGDisplayMode(displayMode);
CGDisplayModeRelease(displayMode);
}

View File

@ -51,7 +51,7 @@ GLFWAPI id glfwGetCocoaWindow(GLFWwindow handle)
return 0;
}
return window->NS.object;
return window->ns.object;
}
@ -69,6 +69,6 @@ GLFWAPI id glfwGetNSGLContext(GLFWwindow handle)
return NULL;
}
return window->NSGL.context;
return window->nsgl.context;
}

View File

@ -46,9 +46,9 @@ typedef void* id;
#error "No supported context creation API selected"
#endif
#define _GLFW_PLATFORM_WINDOW_STATE _GLFWwindowNS NS
#define _GLFW_PLATFORM_LIBRARY_WINDOW_STATE _GLFWlibraryNS NS
#define _GLFW_PLATFORM_MONITOR_STATE _GLFWmonitorNS NS
#define _GLFW_PLATFORM_WINDOW_STATE _GLFWwindowNS ns
#define _GLFW_PLATFORM_LIBRARY_WINDOW_STATE _GLFWlibraryNS ns
#define _GLFW_PLATFORM_MONITOR_STATE _GLFWmonitorNS ns
//========================================================================

View File

@ -55,8 +55,8 @@ void _glfwInitTimer(void)
mach_timebase_info_data_t info;
mach_timebase_info(&info);
_glfwLibrary.NS.timer.resolution = (double) info.numer / (info.denom * 1.0e9);
_glfwLibrary.NS.timer.base = getRawTime();
_glfw.ns.timer.resolution = (double) info.numer / (info.denom * 1.0e9);
_glfw.ns.timer.base = getRawTime();
}
@ -70,8 +70,8 @@ void _glfwInitTimer(void)
double _glfwPlatformGetTime(void)
{
return (double) (getRawTime() - _glfwLibrary.NS.timer.base) *
_glfwLibrary.NS.timer.resolution;
return (double) (getRawTime() - _glfw.ns.timer.base) *
_glfw.ns.timer.resolution;
}
@ -81,7 +81,7 @@ double _glfwPlatformGetTime(void)
void _glfwPlatformSetTime(double time)
{
_glfwLibrary.NS.timer.base = getRawTime() -
(uint64_t) (time / _glfwLibrary.NS.timer.resolution);
_glfw.ns.timer.base = getRawTime() -
(uint64_t) (time / _glfw.ns.timer.resolution);
}

View File

@ -65,20 +65,20 @@
- (void)windowDidResize:(NSNotification *)notification
{
[window->NSGL.context update];
[window->nsgl.context update];
NSRect contentRect =
[window->NS.object contentRectForFrameRect:[window->NS.object frame]];
[window->ns.object contentRectForFrameRect:[window->ns.object frame]];
_glfwInputWindowSize(window, contentRect.size.width, contentRect.size.height);
}
- (void)windowDidMove:(NSNotification *)notification
{
[window->NSGL.context update];
[window->nsgl.context update];
NSRect contentRect =
[window->NS.object contentRectForFrameRect:[window->NS.object frame]];
[window->ns.object contentRectForFrameRect:[window->ns.object frame]];
CGPoint mainScreenOrigin = CGDisplayBounds(CGMainDisplayID()).origin;
double mainScreenHeight = CGDisplayBounds(CGMainDisplayID()).size.height;
@ -125,7 +125,7 @@
{
_GLFWwindow* window;
for (window = _glfwLibrary.windowListHead; window; window = window->next)
for (window = _glfw.windowListHead; window; window = window->next)
_glfwInputWindowCloseRequest(window);
return NSTerminateCancel;
@ -135,7 +135,7 @@
{
_GLFWwindow* window;
for (window = _glfwLibrary.windowListHead; window; window = window->next)
for (window = _glfw.windowListHead; window; window = window->next)
_glfwInputWindowVisibility(window, GL_FALSE);
}
@ -143,9 +143,9 @@
{
_GLFWwindow* window;
for (window = _glfwLibrary.windowListHead; window; window = window->next)
for (window = _glfw.windowListHead; window; window = window->next)
{
if ([window->NS.object isVisible])
if ([window->ns.object isVisible])
_glfwInputWindowVisibility(window, GL_TRUE);
}
}
@ -474,12 +474,12 @@ static int convertMacKeyCode(unsigned int macKeyCode)
unsigned int newModifierFlags =
[event modifierFlags] | NSDeviceIndependentModifierFlagsMask;
if (newModifierFlags > window->NS.modifierFlags)
if (newModifierFlags > window->ns.modifierFlags)
mode = GLFW_PRESS;
else
mode = GLFW_RELEASE;
window->NS.modifierFlags = newModifierFlags;
window->ns.modifierFlags = newModifierFlags;
key = convertMacKeyCode([event keyCode]);
if (key != -1)
@ -684,28 +684,28 @@ static GLboolean createWindow(_GLFWwindow* window,
styleMask |= NSResizableWindowMask;
}
window->NS.object = [[NSWindow alloc]
window->ns.object = [[NSWindow alloc]
initWithContentRect:NSMakeRect(wndconfig->positionX, wndconfig->positionY, window->width, window->height)
styleMask:styleMask
backing:NSBackingStoreBuffered
defer:NO];
if (window->NS.object == nil)
if (window->ns.object == nil)
{
_glfwInputError(GLFW_PLATFORM_ERROR, "Cocoa: Failed to create window");
return GL_FALSE;
}
window->NS.view = [[GLFWContentView alloc] initWithGlfwWindow:window];
window->ns.view = [[GLFWContentView alloc] initWithGlfwWindow:window];
[window->NS.object setTitle:[NSString stringWithUTF8String:wndconfig->title]];
[window->NS.object setContentView:window->NS.view];
[window->NS.object setDelegate:window->NS.delegate];
[window->NS.object setAcceptsMouseMovedEvents:YES];
[window->NS.object center];
[window->ns.object setTitle:[NSString stringWithUTF8String:wndconfig->title]];
[window->ns.object setContentView:window->ns.view];
[window->ns.object setDelegate:window->ns.delegate];
[window->ns.object setAcceptsMouseMovedEvents:YES];
[window->ns.object center];
if ([window->NS.object respondsToSelector:@selector(setRestorable:)])
[window->NS.object setRestorable:NO];
if ([window->ns.object respondsToSelector:@selector(setRestorable:)])
[window->ns.object setRestorable:NO];
return GL_TRUE;
}
@ -729,21 +729,21 @@ int _glfwPlatformCreateWindow(_GLFWwindow* window,
// There can only be one application delegate, but we allocate it the
// first time a window is created to keep all window code in this file
if (_glfwLibrary.NS.delegate == nil)
if (_glfw.ns.delegate == nil)
{
_glfwLibrary.NS.delegate = [[GLFWApplicationDelegate alloc] init];
if (_glfwLibrary.NS.delegate == nil)
_glfw.ns.delegate = [[GLFWApplicationDelegate alloc] init];
if (_glfw.ns.delegate == nil)
{
_glfwInputError(GLFW_PLATFORM_ERROR,
"Cocoa: Failed to create application delegate");
return GL_FALSE;
}
[NSApp setDelegate:_glfwLibrary.NS.delegate];
[NSApp setDelegate:_glfw.ns.delegate];
}
window->NS.delegate = [[GLFWWindowDelegate alloc] initWithGlfwWindow:window];
if (window->NS.delegate == nil)
window->ns.delegate = [[GLFWWindowDelegate alloc] initWithGlfwWindow:window];
if (window->ns.delegate == nil)
{
_glfwInputError(GLFW_PLATFORM_ERROR,
"Cocoa: Failed to create window delegate");
@ -766,7 +766,7 @@ int _glfwPlatformCreateWindow(_GLFWwindow* window,
if (!_glfwCreateContext(window, wndconfig, fbconfig))
return GL_FALSE;
[window->NSGL.context setView:[window->NS.object contentView]];
[window->nsgl.context setView:[window->ns.object contentView]];
if (wndconfig->monitor)
{
@ -776,7 +776,7 @@ int _glfwPlatformCreateWindow(_GLFWwindow* window,
return GL_FALSE;
_glfwPlatformShowWindow(window);
[[window->NS.object contentView] enterFullScreenMode:[NSScreen mainScreen]
[[window->ns.object contentView] enterFullScreenMode:[NSScreen mainScreen]
withOptions:nil];
}
@ -794,26 +794,26 @@ int _glfwPlatformCreateWindow(_GLFWwindow* window,
void _glfwPlatformDestroyWindow(_GLFWwindow* window)
{
[window->NS.object orderOut:nil];
[window->ns.object orderOut:nil];
if (window->monitor)
{
[[window->NS.object contentView] exitFullScreenModeWithOptions:nil];
[[window->ns.object contentView] exitFullScreenModeWithOptions:nil];
_glfwRestoreVideoMode();
}
_glfwDestroyContext(window);
[window->NS.object setDelegate:nil];
[window->NS.delegate release];
window->NS.delegate = nil;
[window->ns.object setDelegate:nil];
[window->ns.delegate release];
window->ns.delegate = nil;
[window->NS.view release];
window->NS.view = nil;
[window->ns.view release];
window->ns.view = nil;
[window->NS.object close];
window->NS.object = nil;
[window->ns.object close];
window->ns.object = nil;
// TODO: Probably more cleanup
}
@ -825,7 +825,7 @@ void _glfwPlatformDestroyWindow(_GLFWwindow* window)
void _glfwPlatformSetWindowTitle(_GLFWwindow* window, const char *title)
{
[window->NS.object setTitle:[NSString stringWithUTF8String:title]];
[window->ns.object setTitle:[NSString stringWithUTF8String:title]];
}
@ -835,7 +835,7 @@ void _glfwPlatformSetWindowTitle(_GLFWwindow* window, const char *title)
void _glfwPlatformSetWindowSize(_GLFWwindow* window, int width, int height)
{
[window->NS.object setContentSize:NSMakeSize(width, height)];
[window->ns.object setContentSize:NSMakeSize(width, height)];
}
@ -845,7 +845,7 @@ void _glfwPlatformSetWindowSize(_GLFWwindow* window, int width, int height)
void _glfwPlatformIconifyWindow(_GLFWwindow* window)
{
[window->NS.object miniaturize:nil];
[window->ns.object miniaturize:nil];
}
@ -855,7 +855,7 @@ void _glfwPlatformIconifyWindow(_GLFWwindow* window)
void _glfwPlatformRestoreWindow(_GLFWwindow* window)
{
[window->NS.object deminiaturize:nil];
[window->ns.object deminiaturize:nil];
}
@ -865,7 +865,7 @@ void _glfwPlatformRestoreWindow(_GLFWwindow* window)
void _glfwPlatformShowWindow(_GLFWwindow* window)
{
[window->NS.object makeKeyAndOrderFront:nil];
[window->ns.object makeKeyAndOrderFront:nil];
_glfwInputWindowVisibility(window, GL_TRUE);
}
@ -876,7 +876,7 @@ void _glfwPlatformShowWindow(_GLFWwindow* window)
void _glfwPlatformHideWindow(_GLFWwindow* window)
{
[window->NS.object orderOut:nil];
[window->ns.object orderOut:nil];
_glfwInputWindowVisibility(window, GL_FALSE);
}
@ -899,8 +899,8 @@ void _glfwPlatformPollEvents(void)
[NSApp sendEvent:event];
}
[_glfwLibrary.NS.autoreleasePool drain];
_glfwLibrary.NS.autoreleasePool = [[NSAutoreleasePool alloc] init];
[_glfw.ns.autoreleasePool drain];
_glfw.ns.autoreleasePool = [[NSAutoreleasePool alloc] init];
}
@ -937,7 +937,7 @@ void _glfwPlatformSetCursorPos(_GLFWwindow* window, int x, int y)
else
{
NSPoint localPoint = NSMakePoint(x, window->height - y - 1);
NSPoint globalPoint = [window->NS.object convertBaseToScreen:localPoint];
NSPoint globalPoint = [window->ns.object convertBaseToScreen:localPoint];
CGPoint mainScreenOrigin = CGDisplayBounds(CGMainDisplayID()).origin;
double mainScreenHeight = CGDisplayBounds(CGMainDisplayID()).size.height;
CGPoint targetPoint = CGPointMake(globalPoint.x - mainScreenOrigin.x,

View File

@ -59,7 +59,7 @@ static _GLFW_TLS _GLFWwindow* _glfwCurrentWindow = NULL;
static int getConfigAttrib(EGLConfig config, int attrib)
{
int value;
eglGetConfigAttrib(_glfwLibrary.EGL.display, config, attrib, &value);
eglGetConfigAttrib(_glfw.egl.display, config, attrib, &value);
return value;
}
@ -78,7 +78,7 @@ static _GLFWfbconfig* getFBConfigs(_GLFWwindow* window,
*found = 0;
eglGetConfigs(_glfwLibrary.EGL.display, NULL, 0, &count);
eglGetConfigs(_glfw.egl.display, NULL, 0, &count);
configs = (EGLConfig*) malloc(sizeof(EGLConfig) * count);
if (!configs)
@ -87,7 +87,7 @@ static _GLFWfbconfig* getFBConfigs(_GLFWwindow* window,
return NULL;
}
eglGetConfigs(_glfwLibrary.EGL.display, configs, count, &count);
eglGetConfigs(_glfw.egl.display, configs, count, &count);
if (!count)
{
free(configs);
@ -190,7 +190,7 @@ static int createContext(_GLFWwindow* window,
EGLContext share = NULL;
if (wndconfig->share)
share = wndconfig->share->EGL.context;
share = wndconfig->share->egl.context;
// Retrieve the previously selected EGLConfig
{
@ -199,7 +199,7 @@ static int createContext(_GLFWwindow* window,
setEGLattrib(EGL_CONFIG_ID, fbconfigID);
setEGLattrib(EGL_NONE, EGL_NONE);
eglChooseConfig(_glfwLibrary.EGL.display, attribs, &config, 1, &count);
eglChooseConfig(_glfw.egl.display, attribs, &config, 1, &count);
if (!count)
{
_glfwInputError(GLFW_PLATFORM_ERROR,
@ -215,10 +215,10 @@ static int createContext(_GLFWwindow* window,
EGLint redBits, greenBits, blueBits, alphaBits, visualID = 0;
XVisualInfo info;
eglGetConfigAttrib(_glfwLibrary.EGL.display, config,
eglGetConfigAttrib(_glfw.egl.display, config,
EGL_NATIVE_VISUAL_ID, &visualID);
info.screen = _glfwLibrary.X11.screen;
info.screen = _glfw.x11.screen;
mask = VisualScreenMask;
if (visualID)
@ -232,23 +232,23 @@ static int createContext(_GLFWwindow* window,
// some EGL drivers don't implement the EGL_NATIVE_VISUAL_ID
// attribute, so attempt to find the closest match.
eglGetConfigAttrib(_glfwLibrary.EGL.display, config,
eglGetConfigAttrib(_glfw.egl.display, config,
EGL_RED_SIZE, &redBits);
eglGetConfigAttrib(_glfwLibrary.EGL.display, config,
eglGetConfigAttrib(_glfw.egl.display, config,
EGL_GREEN_SIZE, &greenBits);
eglGetConfigAttrib(_glfwLibrary.EGL.display, config,
eglGetConfigAttrib(_glfw.egl.display, config,
EGL_BLUE_SIZE, &blueBits);
eglGetConfigAttrib(_glfwLibrary.EGL.display, config,
eglGetConfigAttrib(_glfw.egl.display, config,
EGL_ALPHA_SIZE, &alphaBits);
info.depth = redBits + greenBits + blueBits + alphaBits;
mask |= VisualDepthMask;
}
window->EGL.visual = XGetVisualInfo(_glfwLibrary.X11.display,
window->egl.visual = XGetVisualInfo(_glfw.x11.display,
mask, &info, &count);
if (window->EGL.visual == NULL)
if (window->egl.visual == NULL)
{
_glfwInputError(GLFW_PLATFORM_ERROR,
"EGL: Failed to retrieve visual for EGLConfig");
@ -275,7 +275,7 @@ static int createContext(_GLFWwindow* window,
}
}
if (_glfwLibrary.EGL.KHR_create_context)
if (_glfw.egl.KHR_create_context)
{
int index = 0, mask = 0, flags = 0, strategy = 0;
@ -330,10 +330,10 @@ static int createContext(_GLFWwindow* window,
setEGLattrib(EGL_NONE, EGL_NONE);
}
window->EGL.context = eglCreateContext(_glfwLibrary.EGL.display,
window->egl.context = eglCreateContext(_glfw.egl.display,
config, share, attribs);
if (window->EGL.context == EGL_NO_CONTEXT)
if (window->egl.context == EGL_NO_CONTEXT)
{
// TODO: Handle all the various error codes here
@ -341,7 +341,7 @@ static int createContext(_GLFWwindow* window,
return GL_FALSE;
}
window->EGL.config = config;
window->egl.config = config;
return GL_TRUE;
}
@ -372,35 +372,35 @@ int _glfwInitOpenGL(void)
for (i = 0; libEGL_names[i] != NULL; i++)
{
_glfwLibrary.EGL.libEGL = dlopen(libEGL_names[i], RTLD_LAZY | RTLD_GLOBAL);
if (_glfwLibrary.EGL.libEGL)
_glfw.egl.libEGL = dlopen(libEGL_names[i], RTLD_LAZY | RTLD_GLOBAL);
if (_glfw.egl.libEGL)
break;
}
if (!_glfwLibrary.EGL.libEGL)
if (!_glfw.egl.libEGL)
{
_glfwInputError(GLFW_PLATFORM_ERROR, "EGL: Failed to find libEGL");
return GL_FALSE;
}
#endif
_glfwLibrary.EGL.display = eglGetDisplay(_GLFW_EGL_NATIVE_DISPLAY);
if (_glfwLibrary.EGL.display == EGL_NO_DISPLAY)
_glfw.egl.display = eglGetDisplay(_GLFW_EGL_NATIVE_DISPLAY);
if (_glfw.egl.display == EGL_NO_DISPLAY)
{
_glfwInputError(GLFW_API_UNAVAILABLE, "EGL: Failed to get EGL display");
return GL_FALSE;
}
if (!eglInitialize(_glfwLibrary.EGL.display,
&_glfwLibrary.EGL.majorVersion,
&_glfwLibrary.EGL.minorVersion))
if (!eglInitialize(_glfw.egl.display,
&_glfw.egl.versionMajor,
&_glfw.egl.versionMinor))
{
_glfwInputError(GLFW_API_UNAVAILABLE, "EGL: Failed to initialize EGL");
return GL_FALSE;
}
if (_glfwPlatformExtensionSupported("EGL_KHR_create_context"))
_glfwLibrary.EGL.KHR_create_context = GL_TRUE;
_glfw.egl.KHR_create_context = GL_TRUE;
return GL_TRUE;
}
@ -413,14 +413,14 @@ int _glfwInitOpenGL(void)
void _glfwTerminateOpenGL(void)
{
#ifdef _GLFW_DLOPEN_LIBEGL
if (_glfwLibrary.EGL.libEGL != NULL)
if (_glfw.egl.libEGL != NULL)
{
dlclose(_glfwLibrary.EGL.libEGL);
_glfwLibrary.EGL.libEGL = NULL;
dlclose(_glfw.egl.libEGL);
_glfw.egl.libEGL = NULL;
}
#endif
eglTerminate(_glfwLibrary.EGL.display);
eglTerminate(_glfw.egl.display);
}
@ -472,22 +472,22 @@ int _glfwCreateContext(_GLFWwindow* window,
void _glfwDestroyContext(_GLFWwindow* window)
{
if (window->EGL.visual)
if (window->egl.visual)
{
XFree(window->EGL.visual);
window->EGL.visual = NULL;
XFree(window->egl.visual);
window->egl.visual = NULL;
}
if (window->EGL.surface)
if (window->egl.surface)
{
eglDestroySurface(_glfwLibrary.EGL.display, window->EGL.surface);
window->EGL.surface = EGL_NO_SURFACE;
eglDestroySurface(_glfw.egl.display, window->egl.surface);
window->egl.surface = EGL_NO_SURFACE;
}
if (window->EGL.context)
if (window->egl.context)
{
eglDestroyContext(_glfwLibrary.EGL.display, window->EGL.context);
window->EGL.context = EGL_NO_CONTEXT;
eglDestroyContext(_glfw.egl.display, window->egl.context);
window->egl.context = EGL_NO_CONTEXT;
}
}
@ -516,27 +516,27 @@ void _glfwPlatformMakeContextCurrent(_GLFWwindow* window)
{
if (window)
{
if (window->EGL.surface == EGL_NO_SURFACE)
if (window->egl.surface == EGL_NO_SURFACE)
{
window->EGL.surface = eglCreateWindowSurface(_glfwLibrary.EGL.display,
window->EGL.config,
window->egl.surface = eglCreateWindowSurface(_glfw.egl.display,
window->egl.config,
_GLFW_EGL_NATIVE_WINDOW,
NULL);
if (window->EGL.surface == EGL_NO_SURFACE)
if (window->egl.surface == EGL_NO_SURFACE)
{
_glfwInputError(GLFW_PLATFORM_ERROR,
"EGL: Failed to create window surface");
}
}
eglMakeCurrent(_glfwLibrary.EGL.display,
window->EGL.surface,
window->EGL.surface,
window->EGL.context);
eglMakeCurrent(_glfw.egl.display,
window->egl.surface,
window->egl.surface,
window->egl.context);
}
else
{
eglMakeCurrent(_glfwLibrary.EGL.display,
eglMakeCurrent(_glfw.egl.display,
EGL_NO_SURFACE, EGL_NO_SURFACE, EGL_NO_CONTEXT);
}
@ -560,7 +560,7 @@ _GLFWwindow* _glfwPlatformGetCurrentContext(void)
void _glfwPlatformSwapBuffers(_GLFWwindow* window)
{
eglSwapBuffers(_glfwLibrary.EGL.display, window->EGL.surface);
eglSwapBuffers(_glfw.egl.display, window->egl.surface);
}
@ -570,7 +570,7 @@ void _glfwPlatformSwapBuffers(_GLFWwindow* window)
void _glfwPlatformSwapInterval(int interval)
{
eglSwapInterval(_glfwLibrary.EGL.display, interval);
eglSwapInterval(_glfw.egl.display, interval);
}
@ -582,7 +582,7 @@ int _glfwPlatformExtensionSupported(const char* extension)
{
const char* extensions;
extensions = eglQueryString(_glfwLibrary.EGL.display, EGL_EXTENSIONS);
extensions = eglQueryString(_glfw.egl.display, EGL_EXTENSIONS);
if (extensions != NULL)
{
if (_glfwStringInExtensionString(extension, (unsigned char*) extensions))

View File

@ -48,14 +48,14 @@
#if defined(_GLFW_HAS_EGLGETPROCADDRESS)
#define _glfw_eglGetProcAddress(x) eglGetProcAddress(x)
#elif defined(_GLFW_HAS_DLOPEN)
#define _glfw_eglGetProcAddress(x) dlsym(_glfwLibrary.EGL.libEGL, x)
#define _glfw_eglGetProcAddress(x) dlsym(_glfw.egl.libEGL, x)
#define _GLFW_DLOPEN_LIBEGL
#else
#error "No OpenGL entry point retrieval mechanism was enabled"
#endif
#define _GLFW_PLATFORM_CONTEXT_STATE _GLFWcontextEGL EGL
#define _GLFW_PLATFORM_LIBRARY_OPENGL_STATE _GLFWlibraryEGL EGL
#define _GLFW_PLATFORM_CONTEXT_STATE _GLFWcontextEGL egl
#define _GLFW_PLATFORM_LIBRARY_OPENGL_STATE _GLFWlibraryEGL egl
//========================================================================
@ -83,7 +83,7 @@ typedef struct _GLFWcontextEGL
typedef struct _GLFWlibraryEGL
{
EGLDisplay display;
EGLint majorVersion, minorVersion;
EGLint versionMajor, versionMinor;
GLboolean KHR_create_context;

View File

@ -95,7 +95,7 @@ GLFWAPI void glfwGetGammaRamp(GLFWgammaramp* ramp)
return;
}
*ramp = _glfwLibrary.currentRamp;
*ramp = _glfw.currentRamp;
}
@ -112,7 +112,7 @@ GLFWAPI void glfwSetGammaRamp(const GLFWgammaramp* ramp)
}
_glfwPlatformSetGammaRamp(ramp);
_glfwLibrary.currentRamp = *ramp;
_glfwLibrary.rampChanged = GL_TRUE;
_glfw.currentRamp = *ramp;
_glfw.rampChanged = GL_TRUE;
}

View File

@ -74,13 +74,13 @@ static int getFBConfigAttrib(_GLFWwindow* window, GLXFBConfig fbconfig, int attr
{
int value;
if (_glfwLibrary.GLX.SGIX_fbconfig)
if (_glfw.glx.SGIX_fbconfig)
{
_glfwLibrary.GLX.GetFBConfigAttribSGIX(_glfwLibrary.X11.display,
_glfw.glx.GetFBConfigAttribSGIX(_glfw.x11.display,
fbconfig, attrib, &value);
}
else
glXGetFBConfigAttrib(_glfwLibrary.X11.display, fbconfig, attrib, &value);
glXGetFBConfigAttrib(_glfw.x11.display, fbconfig, attrib, &value);
return value;
}
@ -100,9 +100,9 @@ static _GLFWfbconfig* getFBConfigs(_GLFWwindow* window, unsigned int* found)
*found = 0;
if (_glfwLibrary.GLX.majorVersion == 1 && _glfwLibrary.GLX.minorVersion < 3)
if (_glfw.glx.versionMajor == 1 && _glfw.glx.versionMinor < 3)
{
if (!_glfwLibrary.GLX.SGIX_fbconfig)
if (!_glfw.glx.SGIX_fbconfig)
{
_glfwInputError(GLFW_API_UNAVAILABLE,
"GLX: GLXFBConfig support not found");
@ -110,7 +110,7 @@ static _GLFWfbconfig* getFBConfigs(_GLFWwindow* window, unsigned int* found)
}
}
vendor = glXGetClientString(_glfwLibrary.X11.display, GLX_VENDOR);
vendor = glXGetClientString(_glfw.x11.display, GLX_VENDOR);
if (strcmp(vendor, "Chromium") == 0)
{
@ -119,10 +119,10 @@ static _GLFWfbconfig* getFBConfigs(_GLFWwindow* window, unsigned int* found)
trustWindowBit = GL_FALSE;
}
if (_glfwLibrary.GLX.SGIX_fbconfig)
if (_glfw.glx.SGIX_fbconfig)
{
fbconfigs = _glfwLibrary.GLX.ChooseFBConfigSGIX(_glfwLibrary.X11.display,
_glfwLibrary.X11.screen,
fbconfigs = _glfw.glx.ChooseFBConfigSGIX(_glfw.x11.display,
_glfw.x11.screen,
NULL,
&count);
if (!count)
@ -134,9 +134,7 @@ static _GLFWfbconfig* getFBConfigs(_GLFWwindow* window, unsigned int* found)
}
else
{
fbconfigs = glXGetFBConfigs(_glfwLibrary.X11.display,
_glfwLibrary.X11.screen,
&count);
fbconfigs = glXGetFBConfigs(_glfw.x11.display, _glfw.x11.screen, &count);
if (!count)
{
_glfwInputError(GLFW_API_UNAVAILABLE,
@ -196,12 +194,12 @@ static _GLFWfbconfig* getFBConfigs(_GLFWwindow* window, unsigned int* found)
f->auxBuffers = getFBConfigAttrib(window, fbconfigs[i], GLX_AUX_BUFFERS);
f->stereo = getFBConfigAttrib(window, fbconfigs[i], GLX_STEREO);
if (_glfwLibrary.GLX.ARB_multisample)
if (_glfw.glx.ARB_multisample)
f->samples = getFBConfigAttrib(window, fbconfigs[i], GLX_SAMPLES);
else
f->samples = 0;
if (_glfwLibrary.GLX.ARB_framebuffer_sRGB)
if (_glfw.glx.ARB_framebuffer_sRGB)
f->sRGB = getFBConfigAttrib(window, fbconfigs[i], GLX_FRAMEBUFFER_SRGB_CAPABLE_ARB);
else
f->sRGB = GL_FALSE;
@ -238,10 +236,10 @@ static void createLegacyContext(_GLFWwindow* window,
GLXFBConfig fbconfig,
GLXContext share)
{
if (_glfwLibrary.GLX.SGIX_fbconfig)
if (_glfw.glx.SGIX_fbconfig)
{
window->GLX.context =
_glfwLibrary.GLX.CreateContextWithConfigSGIX(_glfwLibrary.X11.display,
window->glx.context =
_glfw.glx.CreateContextWithConfigSGIX(_glfw.x11.display,
fbconfig,
GLX_RGBA_TYPE,
share,
@ -249,7 +247,7 @@ static void createLegacyContext(_GLFWwindow* window,
}
else
{
window->GLX.context = glXCreateNewContext(_glfwLibrary.X11.display,
window->glx.context = glXCreateNewContext(_glfw.x11.display,
fbconfig,
GLX_RGBA_TYPE,
share,
@ -275,7 +273,7 @@ static int createContext(_GLFWwindow* window,
GLXContext share = NULL;
if (wndconfig->share)
share = wndconfig->share->GLX.context;
share = wndconfig->share->glx.context;
// Retrieve the previously selected GLXFBConfig
{
@ -284,18 +282,17 @@ static int createContext(_GLFWwindow* window,
setGLXattrib(GLX_FBCONFIG_ID, (int) fbconfigID);
setGLXattrib(None, None);
if (_glfwLibrary.GLX.SGIX_fbconfig)
if (_glfw.glx.SGIX_fbconfig)
{
fbconfig =
_glfwLibrary.GLX.ChooseFBConfigSGIX(_glfwLibrary.X11.display,
_glfwLibrary.X11.screen,
fbconfig = _glfw.glx.ChooseFBConfigSGIX(_glfw.x11.display,
_glfw.x11.screen,
attribs,
&dummy);
}
else
{
fbconfig = glXChooseFBConfig(_glfwLibrary.X11.display,
_glfwLibrary.X11.screen,
fbconfig = glXChooseFBConfig(_glfw.x11.display,
_glfw.x11.screen,
attribs,
&dummy);
}
@ -309,19 +306,18 @@ static int createContext(_GLFWwindow* window,
}
// Retrieve the corresponding visual
if (_glfwLibrary.GLX.SGIX_fbconfig)
if (_glfw.glx.SGIX_fbconfig)
{
window->GLX.visual =
_glfwLibrary.GLX.GetVisualFromFBConfigSGIX(_glfwLibrary.X11.display,
*fbconfig);
window->glx.visual =
_glfw.glx.GetVisualFromFBConfigSGIX(_glfw.x11.display, *fbconfig);
}
else
{
window->GLX.visual = glXGetVisualFromFBConfig(_glfwLibrary.X11.display,
window->glx.visual = glXGetVisualFromFBConfig(_glfw.x11.display,
*fbconfig);
}
if (window->GLX.visual == NULL)
if (window->glx.visual == NULL)
{
XFree(fbconfig);
@ -332,9 +328,9 @@ static int createContext(_GLFWwindow* window,
if (wndconfig->clientAPI == GLFW_OPENGL_ES_API)
{
if (!_glfwLibrary.GLX.ARB_create_context ||
!_glfwLibrary.GLX.ARB_create_context_profile ||
!_glfwLibrary.GLX.EXT_create_context_es2_profile)
if (!_glfw.glx.ARB_create_context ||
!_glfw.glx.ARB_create_context_profile ||
!_glfw.glx.EXT_create_context_es2_profile)
{
_glfwInputError(GLFW_VERSION_UNAVAILABLE,
"GLX: OpenGL ES requested but "
@ -345,7 +341,7 @@ static int createContext(_GLFWwindow* window,
if (wndconfig->glForward)
{
if (!_glfwLibrary.GLX.ARB_create_context)
if (!_glfw.glx.ARB_create_context)
{
_glfwInputError(GLFW_VERSION_UNAVAILABLE,
"GLX: Forward compatibility requested but "
@ -356,8 +352,8 @@ static int createContext(_GLFWwindow* window,
if (wndconfig->glProfile)
{
if (!_glfwLibrary.GLX.ARB_create_context ||
!_glfwLibrary.GLX.ARB_create_context_profile)
if (!_glfw.glx.ARB_create_context ||
!_glfw.glx.ARB_create_context_profile)
{
_glfwInputError(GLFW_VERSION_UNAVAILABLE,
"GLX: An OpenGL profile requested but "
@ -366,7 +362,7 @@ static int createContext(_GLFWwindow* window,
}
}
if (_glfwLibrary.GLX.ARB_create_context)
if (_glfw.glx.ARB_create_context)
{
int index = 0, mask = 0, flags = 0, strategy = 0;
@ -391,7 +387,7 @@ static int createContext(_GLFWwindow* window,
if (wndconfig->glRobustness != GLFW_NO_ROBUSTNESS)
{
if (_glfwLibrary.GLX.ARB_create_context_robustness)
if (_glfw.glx.ARB_create_context_robustness)
{
if (wndconfig->glRobustness == GLFW_NO_RESET_NOTIFICATION)
strategy = GLX_NO_RESET_NOTIFICATION_ARB;
@ -430,8 +426,8 @@ static int createContext(_GLFWwindow* window,
_glfwErrorCode = Success;
XSetErrorHandler(errorHandler);
window->GLX.context =
_glfwLibrary.GLX.CreateContextAttribsARB(_glfwLibrary.X11.display,
window->glx.context =
_glfw.glx.CreateContextAttribsARB(_glfw.x11.display,
*fbconfig,
share,
True,
@ -440,12 +436,12 @@ static int createContext(_GLFWwindow* window,
// We are done, so unset the error handler again (see above)
XSetErrorHandler(NULL);
if (window->GLX.context == NULL)
if (window->glx.context == NULL)
{
// HACK: This is a fallback for the broken Mesa implementation of
// GLX_ARB_create_context_profile, which fails default 1.0 context
// creation with a GLXBadProfileARB error in violation of the spec
if (_glfwErrorCode == _glfwLibrary.GLX.errorBase + GLXBadProfileARB &&
if (_glfwErrorCode == _glfw.glx.errorBase + GLXBadProfileARB &&
wndconfig->clientAPI == GLFW_OPENGL_API &&
wndconfig->glProfile == GLFW_OPENGL_NO_PROFILE &&
wndconfig->glForward == GL_FALSE)
@ -459,7 +455,7 @@ static int createContext(_GLFWwindow* window,
XFree(fbconfig);
if (window->GLX.context == NULL)
if (window->glx.context == NULL)
{
_glfwInputError(GLFW_PLATFORM_ERROR, "GLX: Failed to create context");
return GL_FALSE;
@ -494,12 +490,12 @@ int _glfwInitOpenGL(void)
for (i = 0; libGL_names[i] != NULL; i++)
{
_glfwLibrary.GLX.libGL = dlopen(libGL_names[i], RTLD_LAZY | RTLD_GLOBAL);
if (_glfwLibrary.GLX.libGL)
_glfw.glx.libGL = dlopen(libGL_names[i], RTLD_LAZY | RTLD_GLOBAL);
if (_glfw.glx.libGL)
break;
}
if (!_glfwLibrary.GLX.libGL)
if (!_glfw.glx.libGL)
{
_glfwInputError(GLFW_PLATFORM_ERROR, "GLX: Failed to find libGL");
return GL_FALSE;
@ -507,17 +503,17 @@ int _glfwInitOpenGL(void)
#endif
// Check if GLX is supported on this display
if (!glXQueryExtension(_glfwLibrary.X11.display,
&_glfwLibrary.GLX.errorBase,
&_glfwLibrary.GLX.eventBase))
if (!glXQueryExtension(_glfw.x11.display,
&_glfw.glx.errorBase,
&_glfw.glx.eventBase))
{
_glfwInputError(GLFW_API_UNAVAILABLE, "GLX: GLX support not found");
return GL_FALSE;
}
if (!glXQueryVersion(_glfwLibrary.X11.display,
&_glfwLibrary.GLX.majorVersion,
&_glfwLibrary.GLX.minorVersion))
if (!glXQueryVersion(_glfw.x11.display,
&_glfw.glx.versionMajor,
&_glfw.glx.versionMinor))
{
_glfwInputError(GLFW_API_UNAVAILABLE,
"GLX: Failed to query GLX version");
@ -526,74 +522,74 @@ int _glfwInitOpenGL(void)
if (_glfwPlatformExtensionSupported("GLX_EXT_swap_control"))
{
_glfwLibrary.GLX.SwapIntervalEXT = (PFNGLXSWAPINTERVALEXTPROC)
_glfw.glx.SwapIntervalEXT = (PFNGLXSWAPINTERVALEXTPROC)
_glfwPlatformGetProcAddress("glXSwapIntervalEXT");
if (_glfwLibrary.GLX.SwapIntervalEXT)
_glfwLibrary.GLX.EXT_swap_control = GL_TRUE;
if (_glfw.glx.SwapIntervalEXT)
_glfw.glx.EXT_swap_control = GL_TRUE;
}
if (_glfwPlatformExtensionSupported("GLX_SGI_swap_control"))
{
_glfwLibrary.GLX.SwapIntervalSGI = (PFNGLXSWAPINTERVALSGIPROC)
_glfw.glx.SwapIntervalSGI = (PFNGLXSWAPINTERVALSGIPROC)
_glfwPlatformGetProcAddress("glXSwapIntervalSGI");
if (_glfwLibrary.GLX.SwapIntervalSGI)
_glfwLibrary.GLX.SGI_swap_control = GL_TRUE;
if (_glfw.glx.SwapIntervalSGI)
_glfw.glx.SGI_swap_control = GL_TRUE;
}
if (_glfwPlatformExtensionSupported("GLX_MESA_swap_control"))
{
_glfwLibrary.GLX.SwapIntervalMESA = (PFNGLXSWAPINTERVALMESAPROC)
_glfw.glx.SwapIntervalMESA = (PFNGLXSWAPINTERVALMESAPROC)
_glfwPlatformGetProcAddress("glXSwapIntervalMESA");
if (_glfwLibrary.GLX.SwapIntervalMESA)
_glfwLibrary.GLX.MESA_swap_control = GL_TRUE;
if (_glfw.glx.SwapIntervalMESA)
_glfw.glx.MESA_swap_control = GL_TRUE;
}
if (_glfwPlatformExtensionSupported("GLX_SGIX_fbconfig"))
{
_glfwLibrary.GLX.GetFBConfigAttribSGIX = (PFNGLXGETFBCONFIGATTRIBSGIXPROC)
_glfw.glx.GetFBConfigAttribSGIX = (PFNGLXGETFBCONFIGATTRIBSGIXPROC)
_glfwPlatformGetProcAddress("glXGetFBConfigAttribSGIX");
_glfwLibrary.GLX.ChooseFBConfigSGIX = (PFNGLXCHOOSEFBCONFIGSGIXPROC)
_glfw.glx.ChooseFBConfigSGIX = (PFNGLXCHOOSEFBCONFIGSGIXPROC)
_glfwPlatformGetProcAddress("glXChooseFBConfigSGIX");
_glfwLibrary.GLX.CreateContextWithConfigSGIX = (PFNGLXCREATECONTEXTWITHCONFIGSGIXPROC)
_glfw.glx.CreateContextWithConfigSGIX = (PFNGLXCREATECONTEXTWITHCONFIGSGIXPROC)
_glfwPlatformGetProcAddress("glXCreateContextWithConfigSGIX");
_glfwLibrary.GLX.GetVisualFromFBConfigSGIX = (PFNGLXGETVISUALFROMFBCONFIGSGIXPROC)
_glfw.glx.GetVisualFromFBConfigSGIX = (PFNGLXGETVISUALFROMFBCONFIGSGIXPROC)
_glfwPlatformGetProcAddress("glXGetVisualFromFBConfigSGIX");
if (_glfwLibrary.GLX.GetFBConfigAttribSGIX &&
_glfwLibrary.GLX.ChooseFBConfigSGIX &&
_glfwLibrary.GLX.CreateContextWithConfigSGIX &&
_glfwLibrary.GLX.GetVisualFromFBConfigSGIX)
if (_glfw.glx.GetFBConfigAttribSGIX &&
_glfw.glx.ChooseFBConfigSGIX &&
_glfw.glx.CreateContextWithConfigSGIX &&
_glfw.glx.GetVisualFromFBConfigSGIX)
{
_glfwLibrary.GLX.SGIX_fbconfig = GL_TRUE;
_glfw.glx.SGIX_fbconfig = GL_TRUE;
}
}
if (_glfwPlatformExtensionSupported("GLX_ARB_multisample"))
_glfwLibrary.GLX.ARB_multisample = GL_TRUE;
_glfw.glx.ARB_multisample = GL_TRUE;
if (_glfwPlatformExtensionSupported("GLX_ARB_framebuffer_sRGB"))
_glfwLibrary.GLX.ARB_framebuffer_sRGB = GL_TRUE;
_glfw.glx.ARB_framebuffer_sRGB = GL_TRUE;
if (_glfwPlatformExtensionSupported("GLX_ARB_create_context"))
{
_glfwLibrary.GLX.CreateContextAttribsARB = (PFNGLXCREATECONTEXTATTRIBSARBPROC)
_glfw.glx.CreateContextAttribsARB = (PFNGLXCREATECONTEXTATTRIBSARBPROC)
_glfwPlatformGetProcAddress("glXCreateContextAttribsARB");
if (_glfwLibrary.GLX.CreateContextAttribsARB)
_glfwLibrary.GLX.ARB_create_context = GL_TRUE;
if (_glfw.glx.CreateContextAttribsARB)
_glfw.glx.ARB_create_context = GL_TRUE;
}
if (_glfwPlatformExtensionSupported("GLX_ARB_create_context_robustness"))
_glfwLibrary.GLX.ARB_create_context_robustness = GL_TRUE;
_glfw.glx.ARB_create_context_robustness = GL_TRUE;
if (_glfwPlatformExtensionSupported("GLX_ARB_create_context_profile"))
_glfwLibrary.GLX.ARB_create_context_profile = GL_TRUE;
_glfw.glx.ARB_create_context_profile = GL_TRUE;
if (_glfwPlatformExtensionSupported("GLX_EXT_create_context_es2_profile"))
_glfwLibrary.GLX.EXT_create_context_es2_profile = GL_TRUE;
_glfw.glx.EXT_create_context_es2_profile = GL_TRUE;
return GL_TRUE;
}
@ -607,10 +603,10 @@ void _glfwTerminateOpenGL(void)
{
// Unload libGL.so if necessary
#ifdef _GLFW_DLOPEN_LIBGL
if (_glfwLibrary.GLX.libGL != NULL)
if (_glfw.glx.libGL != NULL)
{
dlclose(_glfwLibrary.GLX.libGL);
_glfwLibrary.GLX.libGL = NULL;
dlclose(_glfw.glx.libGL);
_glfw.glx.libGL = NULL;
}
#endif
}
@ -660,16 +656,16 @@ int _glfwCreateContext(_GLFWwindow* window,
void _glfwDestroyContext(_GLFWwindow* window)
{
if (window->GLX.visual)
if (window->glx.visual)
{
XFree(window->GLX.visual);
window->GLX.visual = NULL;
XFree(window->glx.visual);
window->glx.visual = NULL;
}
if (window->GLX.context)
if (window->glx.context)
{
glXDestroyContext(_glfwLibrary.X11.display, window->GLX.context);
window->GLX.context = NULL;
glXDestroyContext(_glfw.x11.display, window->glx.context);
window->glx.context = NULL;
}
}
@ -686,12 +682,12 @@ void _glfwPlatformMakeContextCurrent(_GLFWwindow* window)
{
if (window)
{
glXMakeCurrent(_glfwLibrary.X11.display,
window->X11.handle,
window->GLX.context);
glXMakeCurrent(_glfw.x11.display,
window->x11.handle,
window->glx.context);
}
else
glXMakeCurrent(_glfwLibrary.X11.display, None, NULL);
glXMakeCurrent(_glfw.x11.display, None, NULL);
_glfwCurrentWindow = window;
}
@ -713,7 +709,7 @@ _GLFWwindow* _glfwPlatformGetCurrentContext(void)
void _glfwPlatformSwapBuffers(_GLFWwindow* window)
{
glXSwapBuffers(_glfwLibrary.X11.display, window->X11.handle);
glXSwapBuffers(_glfw.x11.display, window->x11.handle);
}
@ -725,18 +721,18 @@ void _glfwPlatformSwapInterval(int interval)
{
_GLFWwindow* window = _glfwCurrentWindow;
if (_glfwLibrary.GLX.EXT_swap_control)
if (_glfw.glx.EXT_swap_control)
{
_glfwLibrary.GLX.SwapIntervalEXT(_glfwLibrary.X11.display,
window->X11.handle,
_glfw.glx.SwapIntervalEXT(_glfw.x11.display,
window->x11.handle,
interval);
}
else if (_glfwLibrary.GLX.MESA_swap_control)
_glfwLibrary.GLX.SwapIntervalMESA(interval);
else if (_glfwLibrary.GLX.SGI_swap_control)
else if (_glfw.glx.MESA_swap_control)
_glfw.glx.SwapIntervalMESA(interval);
else if (_glfw.glx.SGI_swap_control)
{
if (interval > 0)
_glfwLibrary.GLX.SwapIntervalSGI(interval);
_glfw.glx.SwapIntervalSGI(interval);
}
}
@ -750,8 +746,8 @@ int _glfwPlatformExtensionSupported(const char* extension)
const GLubyte* extensions;
// Get list of GLX extensions
extensions = (const GLubyte*) glXQueryExtensionsString(_glfwLibrary.X11.display,
_glfwLibrary.X11.screen);
extensions = (const GLubyte*) glXQueryExtensionsString(_glfw.x11.display,
_glfw.x11.screen);
if (extensions != NULL)
{
if (_glfwStringInExtensionString(extension, extensions))

View File

@ -54,14 +54,14 @@
#elif defined(_GLFW_HAS_GLXGETPROCADDRESSEXT)
#define _glfw_glXGetProcAddress(x) glXGetProcAddressEXT(x)
#elif defined(_GLFW_HAS_DLOPEN)
#define _glfw_glXGetProcAddress(x) dlsym(_glfwLibrary.GLX.libGL, x)
#define _glfw_glXGetProcAddress(x) dlsym(_glfw.glx.libGL, x)
#define _GLFW_DLOPEN_LIBGL
#else
#error "No OpenGL entry point retrieval mechanism was enabled"
#endif
#define _GLFW_PLATFORM_CONTEXT_STATE _GLFWcontextGLX GLX
#define _GLFW_PLATFORM_LIBRARY_OPENGL_STATE _GLFWlibraryGLX GLX
#define _GLFW_PLATFORM_CONTEXT_STATE _GLFWcontextGLX glx
#define _GLFW_PLATFORM_LIBRARY_OPENGL_STATE _GLFWlibraryGLX glx
#ifndef GLX_MESA_swap_control
typedef int (*PFNGLXSWAPINTERVALMESAPROC)(int);
@ -89,7 +89,7 @@ typedef struct _GLFWcontextGLX
typedef struct _GLFWlibraryGLX
{
// Server-side GLX version
int majorVersion, minorVersion;
int versionMajor, versionMinor;
int eventBase;
int errorBase;

View File

@ -47,13 +47,13 @@ GLboolean _glfwInitialized = GL_FALSE;
// This should only be touched after a call to glfwInit that has not been
// followed by a call to glfwTerminate
//------------------------------------------------------------------------
_GLFWlibrary _glfwLibrary;
_GLFWlibrary _glfw;
//------------------------------------------------------------------------
// The current error callback
// This is outside of _glfwLibrary so it can be initialized and usable
// before glfwInit is called, which lets that function report errors
// This is outside of _glfw so it can be initialized and usable before
// glfwInit is called, which lets that function report errors
//------------------------------------------------------------------------
static GLFWerrorfun _glfwErrorCallback = NULL;
@ -142,7 +142,7 @@ GLFWAPI int glfwInit(void)
if (_glfwInitialized)
return GL_TRUE;
memset(&_glfwLibrary, 0, sizeof(_glfwLibrary));
memset(&_glfw, 0, sizeof(_glfw));
if (!_glfwPlatformInit())
{
@ -150,8 +150,8 @@ GLFWAPI int glfwInit(void)
return GL_FALSE;
}
_glfwLibrary.monitors = _glfwPlatformGetMonitors(&_glfwLibrary.monitorCount);
if (!_glfwLibrary.monitors)
_glfw.monitors = _glfwPlatformGetMonitors(&_glfw.monitorCount);
if (!_glfw.monitors)
{
_glfwPlatformTerminate();
return GL_FALSE;
@ -176,8 +176,8 @@ GLFWAPI void glfwTerminate(void)
return;
// Close all remaining windows
while (_glfwLibrary.windowListHead)
glfwDestroyWindow(_glfwLibrary.windowListHead);
while (_glfw.windowListHead)
glfwDestroyWindow(_glfw.windowListHead);
_glfwDestroyMonitors();

View File

@ -406,7 +406,7 @@ GLFWAPI void glfwSetCursorPos(GLFWwindow handle, int xpos, int ypos)
return;
}
if (_glfwLibrary.focusedWindow != window)
if (_glfw.focusedWindow != window)
return;
// Don't do anything if the cursor position did not change

View File

@ -275,7 +275,7 @@ struct _GLFWlibrary
// These are exported from and documented in init.c
//------------------------------------------------------------------------
extern GLboolean _glfwInitialized;
extern _GLFWlibrary _glfwLibrary;
extern _GLFWlibrary _glfw;
//========================================================================

View File

@ -132,12 +132,12 @@ void _glfwInputMonitorChange(void)
for (i = 0; i < monitorCount; i++)
{
for (j = 0; j < _glfwLibrary.monitorCount; j++)
for (j = 0; j < _glfw.monitorCount; j++)
{
if (_glfwLibrary.monitors[j] == NULL)
if (_glfw.monitors[j] == NULL)
continue;
if (strcmp(monitors[i]->name, _glfwLibrary.monitors[j]->name) == 0)
if (strcmp(monitors[i]->name, _glfw.monitors[j]->name) == 0)
{
// This monitor was connected before, so re-use the existing
// monitor object to preserve its address and user pointer
@ -145,40 +145,40 @@ void _glfwInputMonitorChange(void)
// TODO: Transfer monitor properties
_glfwDestroyMonitor(monitors[i]);
monitors[i] = _glfwLibrary.monitors[j];
_glfwLibrary.monitors[j] = NULL;
monitors[i] = _glfw.monitors[j];
_glfw.monitors[j] = NULL;
break;
}
}
if (j == _glfwLibrary.monitorCount)
if (j == _glfw.monitorCount)
{
// This monitor was not connected before
_glfwLibrary.monitorCallback(monitors[i], GLFW_CONNECTED);
_glfw.monitorCallback(monitors[i], GLFW_CONNECTED);
}
}
for (i = 0; i < _glfwLibrary.monitorCount; i++)
for (i = 0; i < _glfw.monitorCount; i++)
{
_GLFWwindow* window;
if (_glfwLibrary.monitors[i] == NULL)
if (_glfw.monitors[i] == NULL)
continue;
// This monitor is no longer connected
_glfwLibrary.monitorCallback(_glfwLibrary.monitors[i], GLFW_DISCONNECTED);
_glfw.monitorCallback(_glfw.monitors[i], GLFW_DISCONNECTED);
for (window = _glfwLibrary.windowListHead; window; window = window->next)
for (window = _glfw.windowListHead; window; window = window->next)
{
if (window->monitor == _glfwLibrary.monitors[i])
if (window->monitor == _glfw.monitors[i])
window->monitor = NULL;
}
}
_glfwDestroyMonitors();
_glfwLibrary.monitors = monitors;
_glfwLibrary.monitorCount = monitorCount;
_glfw.monitors = monitors;
_glfw.monitorCount = monitorCount;
}
@ -190,12 +190,12 @@ void _glfwDestroyMonitors(void)
{
int i;
for (i = 0; i < _glfwLibrary.monitorCount; i++)
_glfwDestroyMonitor(_glfwLibrary.monitors[i]);
for (i = 0; i < _glfw.monitorCount; i++)
_glfwDestroyMonitor(_glfw.monitors[i]);
free(_glfwLibrary.monitors);
_glfwLibrary.monitors = NULL;
_glfwLibrary.monitorCount = 0;
free(_glfw.monitors);
_glfw.monitors = NULL;
_glfw.monitorCount = 0;
}
@ -294,8 +294,8 @@ GLFWAPI const GLFWmonitor* glfwGetMonitors(int* count)
return NULL;
}
*count = _glfwLibrary.monitorCount;
return (GLFWmonitor*) _glfwLibrary.monitors;
*count = _glfw.monitorCount;
return (GLFWmonitor*) _glfw.monitors;
}
@ -314,11 +314,11 @@ GLFWAPI GLFWmonitor glfwGetPrimaryMonitor(void)
return NULL;
}
for (i = 0; i < _glfwLibrary.monitorCount; i++)
for (i = 0; i < _glfw.monitorCount; i++)
{
if (_glfwLibrary.monitors[i]->primary)
if (_glfw.monitors[i]->primary)
{
handle = _glfwLibrary.monitors[i];
handle = _glfw.monitors[i];
break;
}
}
@ -409,7 +409,7 @@ GLFWAPI void glfwSetMonitorCallback(GLFWmonitorfun cbfun)
return;
}
_glfwLibrary.monitorCallback = cbfun;
_glfw.monitorCallback = cbfun;
}

View File

@ -201,9 +201,9 @@ int _glfwCreateContext(_GLFWwindow* window,
#undef ADD_ATTR
#undef ADD_ATTR2
window->NSGL.pixelFormat =
window->nsgl.pixelFormat =
[[NSOpenGLPixelFormat alloc] initWithAttributes:attributes];
if (window->NSGL.pixelFormat == nil)
if (window->nsgl.pixelFormat == nil)
{
_glfwInputError(GLFW_PLATFORM_ERROR,
"NSOpenGL: Failed to create OpenGL pixel format");
@ -213,12 +213,12 @@ int _glfwCreateContext(_GLFWwindow* window,
NSOpenGLContext* share = NULL;
if (wndconfig->share)
share = wndconfig->share->NSGL.context;
share = wndconfig->share->nsgl.context;
window->NSGL.context =
[[NSOpenGLContext alloc] initWithFormat:window->NSGL.pixelFormat
window->nsgl.context =
[[NSOpenGLContext alloc] initWithFormat:window->nsgl.pixelFormat
shareContext:share];
if (window->NSGL.context == nil)
if (window->nsgl.context == nil)
{
_glfwInputError(GLFW_PLATFORM_ERROR,
"NSOpenGL: Failed to create OpenGL context");
@ -235,11 +235,11 @@ int _glfwCreateContext(_GLFWwindow* window,
void _glfwDestroyContext(_GLFWwindow* window)
{
[window->NSGL.pixelFormat release];
window->NSGL.pixelFormat = nil;
[window->nsgl.pixelFormat release];
window->nsgl.pixelFormat = nil;
[window->NSGL.context release];
window->NSGL.context = nil;
[window->nsgl.context release];
window->nsgl.context = nil;
}
@ -254,7 +254,7 @@ void _glfwDestroyContext(_GLFWwindow* window)
void _glfwPlatformMakeContextCurrent(_GLFWwindow* window)
{
if (window)
[window->NSGL.context makeCurrentContext];
[window->nsgl.context makeCurrentContext];
else
[NSOpenGLContext clearCurrentContext];
@ -279,7 +279,7 @@ _GLFWwindow* _glfwPlatformGetCurrentContext(void)
void _glfwPlatformSwapBuffers(_GLFWwindow* window)
{
// ARP appears to be unnecessary, but this is future-proof
[window->NSGL.context flushBuffer];
[window->nsgl.context flushBuffer];
}
@ -292,7 +292,7 @@ void _glfwPlatformSwapInterval(int interval)
_GLFWwindow* window = _glfwPlatformGetCurrentContext();
GLint sync = interval;
[window->NSGL.context setValues:&sync forParameter:NSOpenGLCPSwapInterval];
[window->nsgl.context setValues:&sync forParameter:NSOpenGLCPSwapInterval];
}
@ -317,7 +317,7 @@ GLFWglproc _glfwPlatformGetProcAddress(const char* procname)
procname,
kCFStringEncodingASCII);
GLFWglproc symbol = CFBundleGetFunctionPointerForName(_glfwLibrary.NSGL.framework,
GLFWglproc symbol = CFBundleGetFunctionPointerForName(_glfw.nsgl.framework,
symbolName);
CFRelease(symbolName);

View File

@ -31,8 +31,8 @@
#define _nsgl_platform_h_
#define _GLFW_PLATFORM_CONTEXT_STATE _GLFWcontextNSGL NSGL
#define _GLFW_PLATFORM_LIBRARY_OPENGL_STATE _GLFWlibraryNSGL NSGL
#define _GLFW_PLATFORM_CONTEXT_STATE _GLFWcontextNSGL nsgl
#define _GLFW_PLATFORM_LIBRARY_OPENGL_STATE _GLFWlibraryNSGL nsgl
//========================================================================

View File

@ -63,83 +63,83 @@ static _GLFW_TLS _GLFWwindow* _glfwCurrentWindow = NULL;
static void initWGLExtensions(_GLFWwindow* window)
{
// This needs to include every function pointer loaded below
window->WGL.SwapIntervalEXT = NULL;
window->WGL.GetPixelFormatAttribivARB = NULL;
window->WGL.GetExtensionsStringARB = NULL;
window->WGL.GetExtensionsStringEXT = NULL;
window->WGL.CreateContextAttribsARB = NULL;
window->wgl.SwapIntervalEXT = NULL;
window->wgl.GetPixelFormatAttribivARB = NULL;
window->wgl.GetExtensionsStringARB = NULL;
window->wgl.GetExtensionsStringEXT = NULL;
window->wgl.CreateContextAttribsARB = NULL;
// This needs to include every extension used below except for
// WGL_ARB_extensions_string and WGL_EXT_extensions_string
window->WGL.ARB_multisample = GL_FALSE;
window->WGL.ARB_framebuffer_sRGB = GL_FALSE;
window->WGL.ARB_create_context = GL_FALSE;
window->WGL.ARB_create_context_profile = GL_FALSE;
window->WGL.EXT_create_context_es2_profile = GL_FALSE;
window->WGL.ARB_create_context_robustness = GL_FALSE;
window->WGL.EXT_swap_control = GL_FALSE;
window->WGL.ARB_pixel_format = GL_FALSE;
window->wgl.ARB_multisample = GL_FALSE;
window->wgl.ARB_framebuffer_sRGB = GL_FALSE;
window->wgl.ARB_create_context = GL_FALSE;
window->wgl.ARB_create_context_profile = GL_FALSE;
window->wgl.EXT_create_context_es2_profile = GL_FALSE;
window->wgl.ARB_create_context_robustness = GL_FALSE;
window->wgl.EXT_swap_control = GL_FALSE;
window->wgl.ARB_pixel_format = GL_FALSE;
window->WGL.GetExtensionsStringEXT = (PFNWGLGETEXTENSIONSSTRINGEXTPROC)
window->wgl.GetExtensionsStringEXT = (PFNWGLGETEXTENSIONSSTRINGEXTPROC)
wglGetProcAddress("wglGetExtensionsStringEXT");
if (!window->WGL.GetExtensionsStringEXT)
if (!window->wgl.GetExtensionsStringEXT)
{
window->WGL.GetExtensionsStringARB = (PFNWGLGETEXTENSIONSSTRINGARBPROC)
window->wgl.GetExtensionsStringARB = (PFNWGLGETEXTENSIONSSTRINGARBPROC)
wglGetProcAddress("wglGetExtensionsStringARB");
if (!window->WGL.GetExtensionsStringARB)
if (!window->wgl.GetExtensionsStringARB)
return;
}
if (_glfwPlatformExtensionSupported("WGL_ARB_multisample"))
window->WGL.ARB_multisample = GL_TRUE;
window->wgl.ARB_multisample = GL_TRUE;
if (_glfwPlatformExtensionSupported("WGL_ARB_framebuffer_sRGB"))
window->WGL.ARB_framebuffer_sRGB = GL_TRUE;
window->wgl.ARB_framebuffer_sRGB = GL_TRUE;
if (_glfwPlatformExtensionSupported("WGL_ARB_create_context"))
{
window->WGL.CreateContextAttribsARB = (PFNWGLCREATECONTEXTATTRIBSARBPROC)
window->wgl.CreateContextAttribsARB = (PFNWGLCREATECONTEXTATTRIBSARBPROC)
wglGetProcAddress("wglCreateContextAttribsARB");
if (window->WGL.CreateContextAttribsARB)
window->WGL.ARB_create_context = GL_TRUE;
if (window->wgl.CreateContextAttribsARB)
window->wgl.ARB_create_context = GL_TRUE;
}
if (window->WGL.ARB_create_context)
if (window->wgl.ARB_create_context)
{
if (_glfwPlatformExtensionSupported("WGL_ARB_create_context_profile"))
window->WGL.ARB_create_context_profile = GL_TRUE;
window->wgl.ARB_create_context_profile = GL_TRUE;
}
if (window->WGL.ARB_create_context &&
window->WGL.ARB_create_context_profile)
if (window->wgl.ARB_create_context &&
window->wgl.ARB_create_context_profile)
{
if (_glfwPlatformExtensionSupported("WGL_EXT_create_context_es2_profile"))
window->WGL.EXT_create_context_es2_profile = GL_TRUE;
window->wgl.EXT_create_context_es2_profile = GL_TRUE;
}
if (window->WGL.ARB_create_context)
if (window->wgl.ARB_create_context)
{
if (_glfwPlatformExtensionSupported("WGL_ARB_create_context_robustness"))
window->WGL.ARB_create_context_robustness = GL_TRUE;
window->wgl.ARB_create_context_robustness = GL_TRUE;
}
if (_glfwPlatformExtensionSupported("WGL_EXT_swap_control"))
{
window->WGL.SwapIntervalEXT = (PFNWGLSWAPINTERVALEXTPROC)
window->wgl.SwapIntervalEXT = (PFNWGLSWAPINTERVALEXTPROC)
wglGetProcAddress("wglSwapIntervalEXT");
if (window->WGL.SwapIntervalEXT)
window->WGL.EXT_swap_control = GL_TRUE;
if (window->wgl.SwapIntervalEXT)
window->wgl.EXT_swap_control = GL_TRUE;
}
if (_glfwPlatformExtensionSupported("WGL_ARB_pixel_format"))
{
window->WGL.GetPixelFormatAttribivARB = (PFNWGLGETPIXELFORMATATTRIBIVARBPROC)
window->wgl.GetPixelFormatAttribivARB = (PFNWGLGETPIXELFORMATATTRIBIVARBPROC)
wglGetProcAddress("wglGetPixelFormatAttribivARB");
if (window->WGL.GetPixelFormatAttribivARB)
window->WGL.ARB_pixel_format = GL_TRUE;
if (window->wgl.GetPixelFormatAttribivARB)
window->wgl.ARB_pixel_format = GL_TRUE;
}
}
@ -153,7 +153,7 @@ static int getPixelFormatAttrib(_GLFWwindow* window, int pixelFormat, int attrib
{
int value = 0;
if (!window->WGL.GetPixelFormatAttribivARB(window->WGL.DC,
if (!window->wgl.GetPixelFormatAttribivARB(window->wgl.dc,
pixelFormat,
0, 1, &attrib, &value))
{
@ -177,7 +177,7 @@ static _GLFWfbconfig* getFBConfigs(_GLFWwindow* window, unsigned int* found)
*found = 0;
if (window->WGL.ARB_pixel_format)
if (window->wgl.ARB_pixel_format)
{
available = getPixelFormatAttrib(window,
1,
@ -185,7 +185,7 @@ static _GLFWfbconfig* getFBConfigs(_GLFWwindow* window, unsigned int* found)
}
else
{
available = DescribePixelFormat(window->WGL.DC,
available = DescribePixelFormat(window->wgl.dc,
1,
sizeof(PIXELFORMATDESCRIPTOR),
NULL);
@ -208,7 +208,7 @@ static _GLFWfbconfig* getFBConfigs(_GLFWwindow* window, unsigned int* found)
{
_GLFWfbconfig* f = fbconfigs + *found;
if (window->WGL.ARB_pixel_format)
if (window->wgl.ARB_pixel_format)
{
// Get pixel format attributes through WGL_ARB_pixel_format
if (!getPixelFormatAttrib(window, i, WGL_SUPPORT_OPENGL_ARB) ||
@ -246,12 +246,12 @@ static _GLFWfbconfig* getFBConfigs(_GLFWwindow* window, unsigned int* found)
f->auxBuffers = getPixelFormatAttrib(window, i, WGL_AUX_BUFFERS_ARB);
f->stereo = getPixelFormatAttrib(window, i, WGL_STEREO_ARB);
if (window->WGL.ARB_multisample)
if (window->wgl.ARB_multisample)
f->samples = getPixelFormatAttrib(window, i, WGL_SAMPLES_ARB);
else
f->samples = 0;
if (window->WGL.ARB_framebuffer_sRGB)
if (window->wgl.ARB_framebuffer_sRGB)
f->sRGB = getPixelFormatAttrib(window, i, WGL_FRAMEBUFFER_SRGB_CAPABLE_ARB);
else
f->sRGB = GL_FALSE;
@ -260,7 +260,7 @@ static _GLFWfbconfig* getFBConfigs(_GLFWwindow* window, unsigned int* found)
{
// Get pixel format attributes through old-fashioned PFDs
if (!DescribePixelFormat(window->WGL.DC,
if (!DescribePixelFormat(window->wgl.dc,
i,
sizeof(PIXELFORMATDESCRIPTOR),
&pfd))
@ -342,9 +342,9 @@ static GLboolean createContext(_GLFWwindow* window,
HGLRC share = NULL;
if (wndconfig->share)
share = wndconfig->share->WGL.context;
share = wndconfig->share->wgl.context;
if (!DescribePixelFormat(window->WGL.DC, pixelFormat, sizeof(pfd), &pfd))
if (!DescribePixelFormat(window->wgl.dc, pixelFormat, sizeof(pfd), &pfd))
{
_glfwInputError(GLFW_PLATFORM_ERROR,
"Win32: Failed to retrieve PFD for selected pixel "
@ -352,14 +352,14 @@ static GLboolean createContext(_GLFWwindow* window,
return GL_FALSE;
}
if (!SetPixelFormat(window->WGL.DC, pixelFormat, &pfd))
if (!SetPixelFormat(window->wgl.dc, pixelFormat, &pfd))
{
_glfwInputError(GLFW_PLATFORM_ERROR,
"Win32: Failed to set selected pixel format");
return GL_FALSE;
}
if (window->WGL.ARB_create_context)
if (window->wgl.ARB_create_context)
{
int index = 0, mask = 0, flags = 0, strategy = 0;
@ -384,7 +384,7 @@ static GLboolean createContext(_GLFWwindow* window,
if (wndconfig->glRobustness)
{
if (window->WGL.ARB_create_context_robustness)
if (window->wgl.ARB_create_context_robustness)
{
if (wndconfig->glRobustness == GLFW_NO_RESET_NOTIFICATION)
strategy = WGL_NO_RESET_NOTIFICATION_ARB;
@ -412,10 +412,10 @@ static GLboolean createContext(_GLFWwindow* window,
setWGLattrib(0, 0);
window->WGL.context = window->WGL.CreateContextAttribsARB(window->WGL.DC,
window->wgl.context = window->wgl.CreateContextAttribsARB(window->wgl.dc,
share,
attribs);
if (!window->WGL.context)
if (!window->wgl.context)
{
_glfwInputError(GLFW_VERSION_UNAVAILABLE,
"WGL: Failed to create OpenGL context");
@ -424,8 +424,8 @@ static GLboolean createContext(_GLFWwindow* window,
}
else
{
window->WGL.context = wglCreateContext(window->WGL.DC);
if (!window->WGL.context)
window->wgl.context = wglCreateContext(window->wgl.dc);
if (!window->wgl.context)
{
_glfwInputError(GLFW_PLATFORM_ERROR,
"WGL: Failed to create OpenGL context");
@ -434,7 +434,7 @@ static GLboolean createContext(_GLFWwindow* window,
if (share)
{
if (!wglShareLists(share, window->WGL.context))
if (!wglShareLists(share, window->wgl.context))
{
_glfwInputError(GLFW_PLATFORM_ERROR,
"WGL: Failed to enable sharing with specified "
@ -467,8 +467,8 @@ int _glfwCreateContext(_GLFWwindow* window,
{
_GLFWfbconfig closest;
window->WGL.DC = GetDC(window->Win32.handle);
if (!window->WGL.DC)
window->wgl.dc = GetDC(window->win32.handle);
if (!window->wgl.dc)
{
_glfwInputError(GLFW_PLATFORM_ERROR,
"Win32: Failed to retrieve DC for window");
@ -509,16 +509,16 @@ int _glfwCreateContext(_GLFWwindow* window,
void _glfwDestroyContext(_GLFWwindow* window)
{
if (window->WGL.context)
if (window->wgl.context)
{
wglDeleteContext(window->WGL.context);
window->WGL.context = NULL;
wglDeleteContext(window->wgl.context);
window->wgl.context = NULL;
}
if (window->WGL.DC)
if (window->wgl.dc)
{
ReleaseDC(window->Win32.handle, window->WGL.DC);
window->WGL.DC = NULL;
ReleaseDC(window->win32.handle, window->wgl.dc);
window->wgl.dc = NULL;
}
}
@ -537,7 +537,7 @@ int _glfwAnalyzeContext(const _GLFWwindow* window,
{
if (wndconfig->glForward)
{
if (!window->WGL.ARB_create_context)
if (!window->wgl.ARB_create_context)
{
_glfwInputError(GLFW_VERSION_UNAVAILABLE,
"WGL: A forward compatible OpenGL context "
@ -551,7 +551,7 @@ int _glfwAnalyzeContext(const _GLFWwindow* window,
if (wndconfig->glProfile)
{
if (!window->WGL.ARB_create_context_profile)
if (!window->wgl.ARB_create_context_profile)
{
_glfwInputError(GLFW_VERSION_UNAVAILABLE,
"WGL: OpenGL profile requested but "
@ -564,9 +564,9 @@ int _glfwAnalyzeContext(const _GLFWwindow* window,
}
else
{
if (!window->WGL.ARB_create_context ||
!window->WGL.ARB_create_context_profile ||
!window->WGL.EXT_create_context_es2_profile)
if (!window->wgl.ARB_create_context ||
!window->wgl.ARB_create_context_profile ||
!window->wgl.EXT_create_context_es2_profile)
{
_glfwInputError(GLFW_VERSION_UNAVAILABLE,
"WGL: OpenGL ES requested but "
@ -579,13 +579,13 @@ int _glfwAnalyzeContext(const _GLFWwindow* window,
if (wndconfig->glMajor != 1 || wndconfig->glMinor != 0)
{
if (window->WGL.ARB_create_context)
if (window->wgl.ARB_create_context)
required = GL_TRUE;
}
if (wndconfig->glDebug)
{
if (window->WGL.ARB_create_context)
if (window->wgl.ARB_create_context)
required = GL_TRUE;
}
@ -594,7 +594,7 @@ int _glfwAnalyzeContext(const _GLFWwindow* window,
// We want FSAA, but can we get it?
// FSAA is not a hard constraint, so otherwise we just don't care
if (window->WGL.ARB_multisample && window->WGL.ARB_pixel_format)
if (window->wgl.ARB_multisample && window->wgl.ARB_pixel_format)
{
// We appear to have both the extension and the means to ask for it
required = GL_TRUE;
@ -619,7 +619,7 @@ int _glfwAnalyzeContext(const _GLFWwindow* window,
void _glfwPlatformMakeContextCurrent(_GLFWwindow* window)
{
if (window)
wglMakeCurrent(window->WGL.DC, window->WGL.context);
wglMakeCurrent(window->wgl.dc, window->wgl.context);
else
wglMakeCurrent(NULL, NULL);
@ -643,7 +643,7 @@ _GLFWwindow* _glfwPlatformGetCurrentContext(void)
void _glfwPlatformSwapBuffers(_GLFWwindow* window)
{
SwapBuffers(window->WGL.DC);
SwapBuffers(window->wgl.dc);
}
@ -655,8 +655,8 @@ void _glfwPlatformSwapInterval(int interval)
{
_GLFWwindow* window = _glfwCurrentWindow;
if (window->WGL.EXT_swap_control)
window->WGL.SwapIntervalEXT(interval);
if (window->wgl.EXT_swap_control)
window->wgl.SwapIntervalEXT(interval);
}
@ -670,9 +670,9 @@ int _glfwPlatformExtensionSupported(const char* extension)
_GLFWwindow* window = _glfwCurrentWindow;
if (window->WGL.GetExtensionsStringEXT != NULL)
if (window->wgl.GetExtensionsStringEXT != NULL)
{
extensions = (GLubyte*) window->WGL.GetExtensionsStringEXT();
extensions = (GLubyte*) window->wgl.GetExtensionsStringEXT();
if (extensions != NULL)
{
if (_glfwStringInExtensionString(extension, extensions))
@ -680,9 +680,9 @@ int _glfwPlatformExtensionSupported(const char* extension)
}
}
if (window->WGL.GetExtensionsStringARB != NULL)
if (window->wgl.GetExtensionsStringARB != NULL)
{
extensions = (GLubyte*) window->WGL.GetExtensionsStringARB(window->WGL.DC);
extensions = (GLubyte*) window->wgl.GetExtensionsStringARB(window->wgl.dc);
if (extensions != NULL)
{
if (_glfwStringInExtensionString(extension, extensions))

View File

@ -37,8 +37,8 @@
#include "../support/GL/wglext.h"
#define _GLFW_PLATFORM_CONTEXT_STATE _GLFWcontextWGL WGL
#define _GLFW_PLATFORM_LIBRARY_OPENGL_STATE _GLFWlibraryWGL WGL
#define _GLFW_PLATFORM_CONTEXT_STATE _GLFWcontextWGL wgl
#define _GLFW_PLATFORM_LIBRARY_OPENGL_STATE _GLFWlibraryWGL wgl
//========================================================================
@ -51,7 +51,7 @@
typedef struct _GLFWcontextWGL
{
// Platform specific window resources
HDC DC; // Private GDI device context
HDC dc; // Private GDI device context
HGLRC context; // Permanent rendering context
// Platform specific extensions (context specific)

View File

@ -73,7 +73,7 @@ void _glfwPlatformSetClipboardString(_GLFWwindow* window, const char* string)
memcpy(GlobalLock(stringHandle), wideString, wideSize);
GlobalUnlock(stringHandle);
if (!OpenClipboard(window->Win32.handle))
if (!OpenClipboard(window->win32.handle))
{
GlobalFree(stringHandle);
free(wideString);
@ -104,7 +104,7 @@ const char* _glfwPlatformGetClipboardString(_GLFWwindow* window)
return NULL;
}
if (!OpenClipboard(window->Win32.handle))
if (!OpenClipboard(window->win32.handle))
{
_glfwInputError(GLFW_PLATFORM_ERROR, "Win32: Failed to open clipboard");
return NULL;
@ -120,20 +120,20 @@ const char* _glfwPlatformGetClipboardString(_GLFWwindow* window)
return NULL;
}
free(_glfwLibrary.Win32.clipboardString);
_glfwLibrary.Win32.clipboardString =
free(_glfw.win32.clipboardString);
_glfw.win32.clipboardString =
_glfwCreateUTF8FromWideString(GlobalLock(stringHandle));
GlobalUnlock(stringHandle);
CloseClipboard();
if (!_glfwLibrary.Win32.clipboardString)
if (!_glfw.win32.clipboardString)
{
_glfwInputError(GLFW_PLATFORM_ERROR,
"Win32: Failed to convert wide string to UTF-8");
return NULL;
}
return _glfwLibrary.Win32.clipboardString;
return _glfw.win32.clipboardString;
}

View File

@ -60,23 +60,23 @@ static GLboolean initLibraries(void)
#ifndef _GLFW_NO_DLOAD_WINMM
// winmm.dll (for joystick and timer support)
_glfwLibrary.Win32.winmm.instance = LoadLibrary(L"winmm.dll");
if (!_glfwLibrary.Win32.winmm.instance)
_glfw.win32.winmm.instance = LoadLibrary(L"winmm.dll");
if (!_glfw.win32.winmm.instance)
return GL_FALSE;
_glfwLibrary.Win32.winmm.joyGetDevCaps = (JOYGETDEVCAPS_T)
GetProcAddress(_glfwLibrary.Win32.winmm.instance, "joyGetDevCapsW");
_glfwLibrary.Win32.winmm.joyGetPos = (JOYGETPOS_T)
GetProcAddress(_glfwLibrary.Win32.winmm.instance, "joyGetPos");
_glfwLibrary.Win32.winmm.joyGetPosEx = (JOYGETPOSEX_T)
GetProcAddress(_glfwLibrary.Win32.winmm.instance, "joyGetPosEx");
_glfwLibrary.Win32.winmm.timeGetTime = (TIMEGETTIME_T)
GetProcAddress(_glfwLibrary.Win32.winmm.instance, "timeGetTime");
_glfw.win32.winmm.joyGetDevCaps = (JOYGETDEVCAPS_T)
GetProcAddress(_glfw.win32.winmm.instance, "joyGetDevCapsW");
_glfw.win32.winmm.joyGetPos = (JOYGETPOS_T)
GetProcAddress(_glfw.win32.winmm.instance, "joyGetPos");
_glfw.win32.winmm.joyGetPosEx = (JOYGETPOSEX_T)
GetProcAddress(_glfw.win32.winmm.instance, "joyGetPosEx");
_glfw.win32.winmm.timeGetTime = (TIMEGETTIME_T)
GetProcAddress(_glfw.win32.winmm.instance, "timeGetTime");
if (!_glfwLibrary.Win32.winmm.joyGetDevCaps ||
!_glfwLibrary.Win32.winmm.joyGetPos ||
!_glfwLibrary.Win32.winmm.joyGetPosEx ||
!_glfwLibrary.Win32.winmm.timeGetTime)
if (!_glfw.win32.winmm.joyGetDevCaps ||
!_glfw.win32.winmm.joyGetPos ||
!_glfw.win32.winmm.joyGetPosEx ||
!_glfw.win32.winmm.timeGetTime)
{
return GL_FALSE;
}
@ -93,10 +93,10 @@ static GLboolean initLibraries(void)
static void freeLibraries(void)
{
#ifndef _GLFW_NO_DLOAD_WINMM
if (_glfwLibrary.Win32.winmm.instance != NULL)
if (_glfw.win32.winmm.instance != NULL)
{
FreeLibrary(_glfwLibrary.Win32.winmm.instance);
_glfwLibrary.Win32.winmm.instance = NULL;
FreeLibrary(_glfw.win32.winmm.instance);
_glfw.win32.winmm.instance = NULL;
}
#endif // _GLFW_NO_DLOAD_WINMM
}
@ -170,7 +170,7 @@ int _glfwPlatformInit(void)
// with the FOREGROUNDLOCKTIMEOUT system setting (we do this as early
// as possible in the hope of still being the foreground process)
SystemParametersInfo(SPI_GETFOREGROUNDLOCKTIMEOUT, 0,
&_glfwLibrary.Win32.foregroundLockTimeout, 0);
&_glfw.win32.foregroundLockTimeout, 0);
SystemParametersInfo(SPI_SETFOREGROUNDLOCKTIMEOUT, 0, UIntToPtr(0),
SPIF_SENDCHANGE);
@ -183,12 +183,12 @@ int _glfwPlatformInit(void)
_control87(MCW_EM, MCW_EM);
#endif
_glfwLibrary.Win32.instance = GetModuleHandle(NULL);
_glfw.win32.instance = GetModuleHandle(NULL);
// Save the original gamma ramp
_glfwLibrary.originalRampSize = 256;
_glfwPlatformGetGammaRamp(&_glfwLibrary.originalRamp);
_glfwLibrary.currentRamp = _glfwLibrary.originalRamp;
_glfw.originalRampSize = 256;
_glfwPlatformGetGammaRamp(&_glfw.originalRamp);
_glfw.currentRamp = _glfw.originalRamp;
_glfwInitTimer();
@ -203,13 +203,13 @@ int _glfwPlatformInit(void)
void _glfwPlatformTerminate(void)
{
// Restore the original gamma ramp
if (_glfwLibrary.rampChanged)
_glfwPlatformSetGammaRamp(&_glfwLibrary.originalRamp);
if (_glfw.rampChanged)
_glfwPlatformSetGammaRamp(&_glfw.originalRamp);
if (_glfwLibrary.Win32.classAtom)
if (_glfw.win32.classAtom)
{
UnregisterClass(_GLFW_WNDCLASSNAME, _glfwLibrary.Win32.instance);
_glfwLibrary.Win32.classAtom = 0;
UnregisterClass(_GLFW_WNDCLASSNAME, _glfw.win32.instance);
_glfw.win32.classAtom = 0;
}
// TODO: Remove keyboard hook
@ -218,7 +218,7 @@ void _glfwPlatformTerminate(void)
// Restore previous FOREGROUNDLOCKTIMEOUT system setting
SystemParametersInfo(SPI_SETFOREGROUNDLOCKTIMEOUT, 0,
UIntToPtr(_glfwLibrary.Win32.foregroundLockTimeout),
UIntToPtr(_glfw.win32.foregroundLockTimeout),
SPIF_SENDCHANGE);
}

View File

@ -235,9 +235,9 @@ const char* _glfwPlatformGetJoystickName(int joy)
_glfw_joyGetDevCaps(i, &jc, sizeof(JOYCAPS));
free(_glfwLibrary.Win32.joyNames[i]);
_glfwLibrary.Win32.joyNames[i] = _glfwCreateUTF8FromWideString(jc.szPname);
free(_glfw.win32.joyNames[i]);
_glfw.win32.joyNames[i] = _glfwCreateUTF8FromWideString(jc.szPname);
return _glfwLibrary.Win32.joyNames[i];
return _glfw.win32.joyNames[i];
}

View File

@ -243,7 +243,7 @@ _GLFWmonitor** _glfwPlatformGetMonitors(int* count)
return NULL;
}
monitors[found]->Win32.name = _wcsdup(adapter.DeviceName);
monitors[found]->win32.name = _wcsdup(adapter.DeviceName);
found++;
}
@ -258,7 +258,7 @@ _GLFWmonitor** _glfwPlatformGetMonitors(int* count)
void _glfwPlatformDestroyMonitor(_GLFWmonitor* monitor)
{
free(monitor->Win32.name);
free(monitor->win32.name);
}
@ -282,7 +282,7 @@ GLFWvidmode* _glfwPlatformGetVideoModes(_GLFWmonitor* monitor, int* found)
ZeroMemory(&dm, sizeof(DEVMODE));
dm.dmSize = sizeof(DEVMODE);
if (!EnumDisplaySettings(monitor->Win32.name, modeIndex, &dm))
if (!EnumDisplaySettings(monitor->win32.name, modeIndex, &dm))
break;
modeIndex++;
@ -352,7 +352,7 @@ void _glfwPlatformGetVideoMode(_GLFWmonitor* monitor, GLFWvidmode* mode)
ZeroMemory(&dm, sizeof(DEVMODE));
dm.dmSize = sizeof(DEVMODE);
EnumDisplaySettings(monitor->Win32.name, ENUM_REGISTRY_SETTINGS, &dm);
EnumDisplaySettings(monitor->win32.name, ENUM_REGISTRY_SETTINGS, &dm);
mode->width = dm.dmPelsWidth;
mode->height = dm.dmPelsHeight;

View File

@ -1,4 +1,4 @@
//========================================================================
_glfw
// GLFW - An OpenGL library
// Platform: Win32/WGL
// API version: 3.0
@ -51,7 +51,7 @@ GLFWAPI HWND glfwGetWin32Window(GLFWwindow handle)
return NULL;
}
return window->Win32.handle;
return window->win32.handle;
}

View File

@ -89,10 +89,10 @@ typedef DWORD (WINAPI * TIMEGETTIME_T) (void);
// winmm.dll shortcuts
#ifndef _GLFW_NO_DLOAD_WINMM
#define _glfw_joyGetDevCaps _glfwLibrary.Win32.winmm.joyGetDevCaps
#define _glfw_joyGetPos _glfwLibrary.Win32.winmm.joyGetPos
#define _glfw_joyGetPosEx _glfwLibrary.Win32.winmm.joyGetPosEx
#define _glfw_timeGetTime _glfwLibrary.Win32.winmm.timeGetTime
#define _glfw_joyGetDevCaps _glfw.win32.winmm.joyGetDevCaps
#define _glfw_joyGetPos _glfw.win32.winmm.joyGetPos
#define _glfw_joyGetPosEx _glfw.win32.winmm.joyGetPosEx
#define _glfw_timeGetTime _glfw.win32.winmm.timeGetTime
#else
#define _glfw_joyGetDevCaps joyGetDevCaps
#define _glfw_joyGetPos joyGetPos
@ -113,16 +113,16 @@ typedef DWORD (WINAPI * TIMEGETTIME_T) (void);
#if defined(_GLFW_WGL)
#include "wgl_platform.h"
#elif defined(_GLFW_EGL)
#define _GLFW_EGL_NATIVE_WINDOW window->Win32.handle
#define _GLFW_EGL_NATIVE_WINDOW window->win32.handle
#define _GLFW_EGL_NATIVE_DISPLAY NULL
#include "egl_platform.h"
#else
#error "No supported context creation API selected"
#endif
#define _GLFW_PLATFORM_WINDOW_STATE _GLFWwindowWin32 Win32
#define _GLFW_PLATFORM_LIBRARY_WINDOW_STATE _GLFWlibraryWin32 Win32
#define _GLFW_PLATFORM_MONITOR_STATE _GLFWmonitorWin32 Win32
#define _GLFW_PLATFORM_WINDOW_STATE _GLFWwindowWin32 win32
#define _GLFW_PLATFORM_LIBRARY_WINDOW_STATE _GLFWlibraryWin32 win32
#define _GLFW_PLATFORM_MONITOR_STATE _GLFWmonitorWin32 win32
//========================================================================

View File

@ -45,15 +45,15 @@ void _glfwInitTimer(void)
if (QueryPerformanceFrequency((LARGE_INTEGER*) &freq))
{
_glfwLibrary.Win32.timer.hasPC = GL_TRUE;
_glfwLibrary.Win32.timer.resolution = 1.0 / (double) freq;
QueryPerformanceCounter((LARGE_INTEGER*) &_glfwLibrary.Win32.timer.t0_64);
_glfw.win32.timer.hasPC = GL_TRUE;
_glfw.win32.timer.resolution = 1.0 / (double) freq;
QueryPerformanceCounter((LARGE_INTEGER*) &_glfw.win32.timer.t0_64);
}
else
{
_glfwLibrary.Win32.timer.hasPC = GL_FALSE;
_glfwLibrary.Win32.timer.resolution = 0.001; // winmm resolution is 1 ms
_glfwLibrary.Win32.timer.t0_32 = _glfw_timeGetTime();
_glfw.win32.timer.hasPC = GL_FALSE;
_glfw.win32.timer.resolution = 0.001; // winmm resolution is 1 ms
_glfw.win32.timer.t0_32 = _glfw_timeGetTime();
}
}
@ -71,15 +71,15 @@ double _glfwPlatformGetTime(void)
double t;
__int64 t_64;
if (_glfwLibrary.Win32.timer.hasPC)
if (_glfw.win32.timer.hasPC)
{
QueryPerformanceCounter((LARGE_INTEGER*) &t_64);
t = (double)(t_64 - _glfwLibrary.Win32.timer.t0_64);
t = (double)(t_64 - _glfw.win32.timer.t0_64);
}
else
t = (double)(_glfw_timeGetTime() - _glfwLibrary.Win32.timer.t0_32);
t = (double)(_glfw_timeGetTime() - _glfw.win32.timer.t0_32);
return t * _glfwLibrary.Win32.timer.resolution;
return t * _glfw.win32.timer.resolution;
}
@ -91,12 +91,12 @@ void _glfwPlatformSetTime(double t)
{
__int64 t_64;
if (_glfwLibrary.Win32.timer.hasPC)
if (_glfw.win32.timer.hasPC)
{
QueryPerformanceCounter((LARGE_INTEGER*) &t_64);
_glfwLibrary.Win32.timer.t0_64 = t_64 - (__int64) (t / _glfwLibrary.Win32.timer.resolution);
_glfw.win32.timer.t0_64 = t_64 - (__int64) (t / _glfw.win32.timer.resolution);
}
else
_glfwLibrary.Win32.timer.t0_32 = _glfw_timeGetTime() - (int)(t * 1000.0);
_glfw.win32.timer.t0_32 = _glfw_timeGetTime() - (int)(t * 1000.0);
}

View File

@ -55,11 +55,11 @@ static void captureCursor(_GLFWwindow* window)
ShowCursor(FALSE);
// Clip cursor to the window
if (GetWindowRect(window->Win32.handle, &ClipWindowRect))
if (GetWindowRect(window->win32.handle, &ClipWindowRect))
ClipCursor(&ClipWindowRect);
// Capture cursor to user window
SetCapture(window->Win32.handle);
SetCapture(window->win32.handle);
}
@ -340,7 +340,7 @@ static LRESULT CALLBACK windowProc(HWND hWnd, UINT uMsg,
focused = FALSE;
}
if (!focused && _glfwLibrary.focusedWindow == window)
if (!focused && _glfw.focusedWindow == window)
{
// The window was defocused (or iconified, see above)
@ -356,14 +356,14 @@ static LRESULT CALLBACK windowProc(HWND hWnd, UINT uMsg,
_glfwPlatformIconifyWindow(window);
}
if (_glfwLibrary.Win32.monitor.modeChanged)
if (_glfw.win32.monitor.modeChanged)
{
_glfwRestoreVideoMode();
_glfwLibrary.Win32.monitor.modeChanged = GL_FALSE;
_glfw.win32.monitor.modeChanged = GL_FALSE;
}
}
}
else if (focused && _glfwLibrary.focusedWindow != window)
else if (focused && _glfw.focusedWindow != window)
{
// The window was focused
@ -372,14 +372,14 @@ static LRESULT CALLBACK windowProc(HWND hWnd, UINT uMsg,
if (window->monitor)
{
if (!_glfwLibrary.Win32.monitor.modeChanged)
if (!_glfw.win32.monitor.modeChanged)
{
_glfwSetVideoMode(&_glfwLibrary.Win32.monitor.width,
&_glfwLibrary.Win32.monitor.height,
&_glfwLibrary.Win32.monitor.bitsPerPixel,
_glfwSetVideoMode(&_glfw.win32.monitor.width,
&_glfw.win32.monitor.height,
&_glfw.win32.monitor.bitsPerPixel,
GL_TRUE);
_glfwLibrary.Win32.monitor.modeChanged = GL_TRUE;
_glfw.win32.monitor.modeChanged = GL_TRUE;
}
}
}
@ -535,18 +535,18 @@ static LRESULT CALLBACK windowProc(HWND hWnd, UINT uMsg,
newCursorX = GET_X_LPARAM(lParam);
newCursorY = GET_Y_LPARAM(lParam);
if (newCursorX != window->Win32.oldCursorX ||
newCursorY != window->Win32.oldCursorY)
if (newCursorX != window->win32.oldCursorX ||
newCursorY != window->win32.oldCursorY)
{
int x, y;
if (window->cursorMode == GLFW_CURSOR_CAPTURED)
{
if (_glfwLibrary.focusedWindow != window)
if (_glfw.focusedWindow != window)
return 0;
x = newCursorX - window->Win32.oldCursorX;
y = newCursorY - window->Win32.oldCursorY;
x = newCursorX - window->win32.oldCursorX;
y = newCursorY - window->win32.oldCursorY;
}
else
{
@ -554,23 +554,23 @@ static LRESULT CALLBACK windowProc(HWND hWnd, UINT uMsg,
y = newCursorY;
}
window->Win32.oldCursorX = newCursorX;
window->Win32.oldCursorY = newCursorY;
window->Win32.cursorCentered = GL_FALSE;
window->win32.oldCursorX = newCursorX;
window->win32.oldCursorY = newCursorY;
window->win32.cursorCentered = GL_FALSE;
_glfwInputCursorMotion(window, x, y);
}
if (!window->Win32.cursorInside)
if (!window->win32.cursorInside)
{
TRACKMOUSEEVENT tme;
ZeroMemory(&tme, sizeof(tme));
tme.cbSize = sizeof(tme);
tme.dwFlags = TME_LEAVE;
tme.hwndTrack = window->Win32.handle;
tme.hwndTrack = window->win32.handle;
TrackMouseEvent(&tme);
window->Win32.cursorInside = GL_TRUE;
window->win32.cursorInside = GL_TRUE;
_glfwInputCursorEnter(window, GL_TRUE);
}
@ -579,7 +579,7 @@ static LRESULT CALLBACK windowProc(HWND hWnd, UINT uMsg,
case WM_MOUSELEAVE:
{
window->Win32.cursorInside = GL_FALSE;
window->win32.cursorInside = GL_FALSE;
_glfwInputCursorEnter(window, GL_FALSE);
return 0;
}
@ -604,7 +604,7 @@ static LRESULT CALLBACK windowProc(HWND hWnd, UINT uMsg,
if (window->cursorMode == GLFW_CURSOR_CAPTURED)
{
RECT ClipWindowRect;
if (GetWindowRect(window->Win32.handle, &ClipWindowRect))
if (GetWindowRect(window->win32.handle, &ClipWindowRect))
ClipCursor(&ClipWindowRect);
}
@ -618,7 +618,7 @@ static LRESULT CALLBACK windowProc(HWND hWnd, UINT uMsg,
if (window->cursorMode == GLFW_CURSOR_CAPTURED)
{
RECT ClipWindowRect;
if (GetWindowRect(window->Win32.handle, &ClipWindowRect))
if (GetWindowRect(window->win32.handle, &ClipWindowRect))
ClipCursor(&ClipWindowRect);
}
@ -673,7 +673,7 @@ static void getFullWindowSize(_GLFWwindow* window,
rect.bottom = (long) clientHeight - 1;
// Adjust according to window styles
AdjustWindowRectEx(&rect, window->Win32.dwStyle, FALSE, window->Win32.dwExStyle);
AdjustWindowRectEx(&rect, window->win32.dwStyle, FALSE, window->win32.dwExStyle);
// Calculate width and height of full window
*fullWidth = rect.right - rect.left + 1;
@ -695,14 +695,14 @@ static ATOM registerWindowClass(void)
wc.lpfnWndProc = (WNDPROC) windowProc; // Message handler
wc.cbClsExtra = 0; // No extra class data
wc.cbWndExtra = sizeof(void*) + sizeof(int); // Make room for one pointer
wc.hInstance = _glfwLibrary.Win32.instance; // Set instance
wc.hInstance = _glfw.win32.instance; // Set instance
wc.hCursor = LoadCursor(NULL, IDC_ARROW); // Load arrow pointer
wc.hbrBackground = NULL; // No background
wc.lpszMenuName = NULL; // No menu
wc.lpszClassName = _GLFW_WNDCLASSNAME; // Set class name
// Load user-provided icon if available
wc.hIcon = LoadIcon(_glfwLibrary.Win32.instance, L"GLFW_ICON");
wc.hIcon = LoadIcon(_glfw.win32.instance, L"GLFW_ICON");
if (!wc.hIcon)
{
// Load default icon
@ -747,9 +747,9 @@ static int createWindow(_GLFWwindow* window,
// (SetForegroundWindow doesn't work properly under
// Win98/ME/2K/.NET/+)
/*
if (_glfwLibrary.Sys.WinVer != _GLFW_WIN_95 &&
_glfwLibrary.Sys.WinVer != _GLFW_WIN_NT4 &&
_glfwLibrary.Sys.WinVer != _GLFW_WIN_XP)
if (_glfw.Sys.WinVer != _GLFW_WIN_95 &&
_glfw.Sys.WinVer != _GLFW_WIN_NT4 &&
_glfw.Sys.WinVer != _GLFW_WIN_XP)
{
dwStyle |= WS_MINIMIZE;
}
@ -767,8 +767,8 @@ static int createWindow(_GLFWwindow* window,
}
// Remember window styles (used by getFullWindowSize)
window->Win32.dwStyle = dwStyle;
window->Win32.dwExStyle = dwExStyle;
window->win32.dwStyle = dwStyle;
window->win32.dwExStyle = dwExStyle;
// Adjust window size for frame and title bar
getFullWindowSize(window, window->width, window->height, &fullWidth, &fullHeight);
@ -798,19 +798,19 @@ static int createWindow(_GLFWwindow* window,
return GL_FALSE;
}
window->Win32.handle = CreateWindowEx(window->Win32.dwExStyle,
window->win32.handle = CreateWindowEx(window->win32.dwExStyle,
_GLFW_WNDCLASSNAME,
wideTitle,
window->Win32.dwStyle,
window->win32.dwStyle,
positionX, positionY,
fullWidth, // Decorated window width
fullHeight, // Decorated window height
NULL, // No parent window
NULL, // No menu
_glfwLibrary.Win32.instance,
_glfw.win32.instance,
window); // Pass GLFW window to WM_CREATE
if (!window->Win32.handle)
if (!window->win32.handle)
{
_glfwInputError(GLFW_PLATFORM_ERROR, "Win32: Failed to create window");
return GL_FALSE;
@ -820,9 +820,9 @@ static int createWindow(_GLFWwindow* window,
// Initialize cursor position data
GetCursorPos(&pos);
ScreenToClient(window->Win32.handle, &pos);
window->Win32.oldCursorX = window->cursorPosX = pos.x;
window->Win32.oldCursorY = window->cursorPosY = pos.y;
ScreenToClient(window->win32.handle, &pos);
window->win32.oldCursorX = window->cursorPosX = pos.x;
window->win32.oldCursorY = window->cursorPosY = pos.y;
if (!_glfwCreateContext(window, wndconfig, fbconfig))
return GL_FALSE;
@ -841,13 +841,13 @@ static void destroyWindow(_GLFWwindow* window)
// This is duplicated from glfwDestroyWindow
// TODO: Stop duplicating code
if (window == _glfwLibrary.focusedWindow)
_glfwLibrary.focusedWindow = NULL;
if (window == _glfw.focusedWindow)
_glfw.focusedWindow = NULL;
if (window->Win32.handle)
if (window->win32.handle)
{
DestroyWindow(window->Win32.handle);
window->Win32.handle = NULL;
DestroyWindow(window->win32.handle);
window->win32.handle = NULL;
}
}
@ -867,10 +867,10 @@ int _glfwPlatformCreateWindow(_GLFWwindow* window,
{
int status;
if (!_glfwLibrary.Win32.classAtom)
if (!_glfw.win32.classAtom)
{
_glfwLibrary.Win32.classAtom = registerWindowClass();
if (!_glfwLibrary.Win32.classAtom)
_glfw.win32.classAtom = registerWindowClass();
if (!_glfw.win32.classAtom)
return GL_FALSE;
}
@ -880,16 +880,16 @@ int _glfwPlatformCreateWindow(_GLFWwindow* window,
if (bpp < 15 || bpp >= 24)
bpp = 32;
_glfwLibrary.Win32.monitor.width = window->width;
_glfwLibrary.Win32.monitor.height = window->height;
_glfwLibrary.Win32.monitor.bitsPerPixel = bpp;
_glfw.win32.monitor.width = window->width;
_glfw.win32.monitor.height = window->height;
_glfw.win32.monitor.bitsPerPixel = bpp;
_glfwSetVideoMode(&_glfwLibrary.Win32.monitor.width,
&_glfwLibrary.Win32.monitor.height,
&_glfwLibrary.Win32.monitor.bitsPerPixel,
_glfwSetVideoMode(&_glfw.win32.monitor.width,
&_glfw.win32.monitor.height,
&_glfw.win32.monitor.bitsPerPixel,
GL_FALSE);
_glfwLibrary.Win32.monitor.modeChanged = GL_TRUE;
_glfw.win32.monitor.modeChanged = GL_TRUE;
}
if (!createWindow(window, wndconfig, fbconfig))
@ -935,7 +935,7 @@ int _glfwPlatformCreateWindow(_GLFWwindow* window,
{
// Place the window above all topmost windows
_glfwPlatformShowWindow(window);
SetWindowPos(window->Win32.handle, HWND_TOPMOST, 0,0,0,0,
SetWindowPos(window->win32.handle, HWND_TOPMOST, 0,0,0,0,
SWP_NOMOVE | SWP_NOSIZE);
}
@ -953,10 +953,10 @@ void _glfwPlatformDestroyWindow(_GLFWwindow* window)
if (window->monitor)
{
if (_glfwLibrary.Win32.monitor.modeChanged)
if (_glfw.win32.monitor.modeChanged)
{
_glfwRestoreVideoMode();
_glfwLibrary.Win32.monitor.modeChanged = GL_FALSE;
_glfw.win32.monitor.modeChanged = GL_FALSE;
}
}
}
@ -976,7 +976,7 @@ void _glfwPlatformSetWindowTitle(_GLFWwindow* window, const char* title)
return;
}
SetWindowText(window->Win32.handle, wideTitle);
SetWindowText(window->win32.handle, wideTitle);
free(wideTitle);
}
@ -998,7 +998,7 @@ void _glfwPlatformSetWindowSize(_GLFWwindow* window, int width, int height)
// the window before switch modes to avoid exposing whatever is
// underneath
SetWindowPos(window->Win32.handle, HWND_TOP, 0, 0, width, height,
SetWindowPos(window->win32.handle, HWND_TOP, 0, 0, width, height,
SWP_NOOWNERZORDER | SWP_NOMOVE | SWP_NOZORDER);
sizeChanged = GL_TRUE;
}
@ -1015,7 +1015,7 @@ void _glfwPlatformSetWindowSize(_GLFWwindow* window, int width, int height)
// Set window size (if we haven't already)
if (!sizeChanged)
{
SetWindowPos(window->Win32.handle, HWND_TOP, 0, 0, width, height,
SetWindowPos(window->win32.handle, HWND_TOP, 0, 0, width, height,
SWP_NOOWNERZORDER | SWP_NOMOVE | SWP_NOZORDER);
}
}
@ -1027,7 +1027,7 @@ void _glfwPlatformSetWindowSize(_GLFWwindow* window, int width, int height)
void _glfwPlatformIconifyWindow(_GLFWwindow* window)
{
ShowWindow(window->Win32.handle, SW_MINIMIZE);
ShowWindow(window->win32.handle, SW_MINIMIZE);
}
@ -1037,7 +1037,7 @@ void _glfwPlatformIconifyWindow(_GLFWwindow* window)
void _glfwPlatformRestoreWindow(_GLFWwindow* window)
{
ShowWindow(window->Win32.handle, SW_RESTORE);
ShowWindow(window->win32.handle, SW_RESTORE);
}
@ -1047,10 +1047,10 @@ void _glfwPlatformRestoreWindow(_GLFWwindow* window)
void _glfwPlatformShowWindow(_GLFWwindow* window)
{
ShowWindow(window->Win32.handle, SW_SHOWNORMAL);
BringWindowToTop(window->Win32.handle);
SetForegroundWindow(window->Win32.handle);
SetFocus(window->Win32.handle);
ShowWindow(window->win32.handle, SW_SHOWNORMAL);
BringWindowToTop(window->win32.handle);
SetForegroundWindow(window->win32.handle);
SetFocus(window->win32.handle);
}
@ -1060,7 +1060,7 @@ void _glfwPlatformShowWindow(_GLFWwindow* window)
void _glfwPlatformHideWindow(_GLFWwindow* window)
{
ShowWindow(window->Win32.handle, SW_HIDE);
ShowWindow(window->win32.handle, SW_HIDE);
}
@ -1073,17 +1073,17 @@ void _glfwPlatformPollEvents(void)
MSG msg;
_GLFWwindow* window;
window = _glfwLibrary.focusedWindow;
window = _glfw.focusedWindow;
if (window)
{
window->Win32.cursorCentered = GL_FALSE;
window->Win32.oldCursorX = window->width / 2;
window->Win32.oldCursorY = window->height / 2;
window->win32.cursorCentered = GL_FALSE;
window->win32.oldCursorX = window->width / 2;
window->win32.oldCursorY = window->height / 2;
}
else
{
//window->Win32.oldCursorX = window->cursorPosX;
//window->Win32.oldCursorY = window->cursorPosY;
//window->win32.oldCursorX = window->cursorPosX;
//window->win32.oldCursorY = window->cursorPosY;
}
while (PeekMessage(&msg, NULL, 0, 0, PM_REMOVE))
@ -1092,7 +1092,7 @@ void _glfwPlatformPollEvents(void)
{
// Treat WM_QUIT as a close on all windows
window = _glfwLibrary.windowListHead;
window = _glfw.windowListHead;
while (window)
{
_glfwInputWindowCloseRequest(window);
@ -1109,7 +1109,7 @@ void _glfwPlatformPollEvents(void)
// LSHIFT/RSHIFT fixup (keys tend to "stick" without this fix)
// This is the only async event handling in GLFW, but it solves some
// nasty problems.
window = _glfwLibrary.focusedWindow;
window = _glfw.focusedWindow;
if (window)
{
int lshift_down, rshift_down;
@ -1128,16 +1128,16 @@ void _glfwPlatformPollEvents(void)
}
// Did the cursor move in an focused window that has captured the cursor
window = _glfwLibrary.focusedWindow;
window = _glfw.focusedWindow;
if (window)
{
if (window->cursorMode == GLFW_CURSOR_CAPTURED &&
!window->Win32.cursorCentered)
!window->win32.cursorCentered)
{
_glfwPlatformSetCursorPos(window,
window->width / 2,
window->height / 2);
window->Win32.cursorCentered = GL_TRUE;
window->win32.cursorCentered = GL_TRUE;
}
}
}
@ -1166,7 +1166,7 @@ void _glfwPlatformSetCursorPos(_GLFWwindow* window, int x, int y)
// Convert client coordinates to screen coordinates
pos.x = x;
pos.y = y;
ClientToScreen(window->Win32.handle, &pos);
ClientToScreen(window->win32.handle, &pos);
SetCursorPos(pos.x, pos.y);
}

View File

@ -56,7 +56,7 @@ static void clearScrollOffsets(void)
{
_GLFWwindow* window;
for (window = _glfwLibrary.windowListHead; window; window = window->next)
for (window = _glfw.windowListHead; window; window = window->next)
{
window->scrollX = 0;
window->scrollY = 0;
@ -76,9 +76,9 @@ void _glfwInputWindowFocus(_GLFWwindow* window, GLboolean focused)
{
if (focused)
{
if (_glfwLibrary.focusedWindow != window)
if (_glfw.focusedWindow != window)
{
_glfwLibrary.focusedWindow = window;
_glfw.focusedWindow = window;
if (window->windowFocusCallback)
window->windowFocusCallback(window, focused);
@ -86,7 +86,7 @@ void _glfwInputWindowFocus(_GLFWwindow* window, GLboolean focused)
}
else
{
if (_glfwLibrary.focusedWindow == window)
if (_glfw.focusedWindow == window)
{
int i;
@ -104,7 +104,7 @@ void _glfwInputWindowFocus(_GLFWwindow* window, GLboolean focused)
_glfwInputMouseClick(window, i, GLFW_RELEASE);
}
_glfwLibrary.focusedWindow = NULL;
_glfw.focusedWindow = NULL;
if (window->windowFocusCallback)
window->windowFocusCallback(window, focused);
@ -225,34 +225,34 @@ GLFWAPI GLFWwindow glfwCreateWindow(int width, int height,
// window hints should be cleared after each call even if it fails
// Set up desired framebuffer config
fbconfig.redBits = Max(_glfwLibrary.hints.redBits, 0);
fbconfig.greenBits = Max(_glfwLibrary.hints.greenBits, 0);
fbconfig.blueBits = Max(_glfwLibrary.hints.blueBits, 0);
fbconfig.alphaBits = Max(_glfwLibrary.hints.alphaBits, 0);
fbconfig.depthBits = Max(_glfwLibrary.hints.depthBits, 0);
fbconfig.stencilBits = Max(_glfwLibrary.hints.stencilBits, 0);
fbconfig.accumRedBits = Max(_glfwLibrary.hints.accumRedBits, 0);
fbconfig.accumGreenBits = Max(_glfwLibrary.hints.accumGreenBits, 0);
fbconfig.accumBlueBits = Max(_glfwLibrary.hints.accumBlueBits, 0);
fbconfig.accumAlphaBits = Max(_glfwLibrary.hints.accumAlphaBits, 0);
fbconfig.auxBuffers = Max(_glfwLibrary.hints.auxBuffers, 0);
fbconfig.stereo = _glfwLibrary.hints.stereo ? GL_TRUE : GL_FALSE;
fbconfig.samples = Max(_glfwLibrary.hints.samples, 0);
fbconfig.sRGB = _glfwLibrary.hints.sRGB ? GL_TRUE : GL_FALSE;
fbconfig.redBits = Max(_glfw.hints.redBits, 0);
fbconfig.greenBits = Max(_glfw.hints.greenBits, 0);
fbconfig.blueBits = Max(_glfw.hints.blueBits, 0);
fbconfig.alphaBits = Max(_glfw.hints.alphaBits, 0);
fbconfig.depthBits = Max(_glfw.hints.depthBits, 0);
fbconfig.stencilBits = Max(_glfw.hints.stencilBits, 0);
fbconfig.accumRedBits = Max(_glfw.hints.accumRedBits, 0);
fbconfig.accumGreenBits = Max(_glfw.hints.accumGreenBits, 0);
fbconfig.accumBlueBits = Max(_glfw.hints.accumBlueBits, 0);
fbconfig.accumAlphaBits = Max(_glfw.hints.accumAlphaBits, 0);
fbconfig.auxBuffers = Max(_glfw.hints.auxBuffers, 0);
fbconfig.stereo = _glfw.hints.stereo ? GL_TRUE : GL_FALSE;
fbconfig.samples = Max(_glfw.hints.samples, 0);
fbconfig.sRGB = _glfw.hints.sRGB ? GL_TRUE : GL_FALSE;
// Set up desired window config
wndconfig.title = title;
wndconfig.resizable = _glfwLibrary.hints.resizable ? GL_TRUE : GL_FALSE;
wndconfig.visible = _glfwLibrary.hints.visible ? GL_TRUE : GL_FALSE;
wndconfig.positionX = _glfwLibrary.hints.positionX;
wndconfig.positionY = _glfwLibrary.hints.positionY;
wndconfig.clientAPI = _glfwLibrary.hints.clientAPI;
wndconfig.glMajor = _glfwLibrary.hints.glMajor;
wndconfig.glMinor = _glfwLibrary.hints.glMinor;
wndconfig.glForward = _glfwLibrary.hints.glForward ? GL_TRUE : GL_FALSE;
wndconfig.glDebug = _glfwLibrary.hints.glDebug ? GL_TRUE : GL_FALSE;
wndconfig.glProfile = _glfwLibrary.hints.glProfile;
wndconfig.glRobustness = _glfwLibrary.hints.glRobustness;
wndconfig.resizable = _glfw.hints.resizable ? GL_TRUE : GL_FALSE;
wndconfig.visible = _glfw.hints.visible ? GL_TRUE : GL_FALSE;
wndconfig.positionX = _glfw.hints.positionX;
wndconfig.positionY = _glfw.hints.positionY;
wndconfig.clientAPI = _glfw.hints.clientAPI;
wndconfig.glMajor = _glfw.hints.glMajor;
wndconfig.glMinor = _glfw.hints.glMinor;
wndconfig.glForward = _glfw.hints.glForward ? GL_TRUE : GL_FALSE;
wndconfig.glDebug = _glfw.hints.glDebug ? GL_TRUE : GL_FALSE;
wndconfig.glProfile = _glfw.hints.glProfile;
wndconfig.glRobustness = _glfw.hints.glRobustness;
wndconfig.monitor = (_GLFWmonitor*) monitor;
wndconfig.share = (_GLFWwindow*) share;
@ -276,8 +276,8 @@ GLFWAPI GLFWwindow glfwCreateWindow(int width, int height,
return NULL;
}
window->next = _glfwLibrary.windowListHead;
_glfwLibrary.windowListHead = window;
window->next = _glfw.windowListHead;
_glfw.windowListHead = window;
// Remember window settings
window->width = width;
@ -344,27 +344,27 @@ void glfwDefaultWindowHints(void)
return;
}
memset(&_glfwLibrary.hints, 0, sizeof(_glfwLibrary.hints));
memset(&_glfw.hints, 0, sizeof(_glfw.hints));
// The default is OpenGL with minimum version 1.0
_glfwLibrary.hints.clientAPI = GLFW_OPENGL_API;
_glfwLibrary.hints.glMajor = 1;
_glfwLibrary.hints.glMinor = 0;
_glfw.hints.clientAPI = GLFW_OPENGL_API;
_glfw.hints.glMajor = 1;
_glfw.hints.glMinor = 0;
// The default is to show the window and allow window resizing
_glfwLibrary.hints.resizable = GL_TRUE;
_glfwLibrary.hints.visible = GL_TRUE;
_glfw.hints.resizable = GL_TRUE;
_glfw.hints.visible = GL_TRUE;
// The default window position is the upper left corner of the screen
_glfwLibrary.hints.positionX = 0;
_glfwLibrary.hints.positionY = 0;
_glfw.hints.positionX = 0;
_glfw.hints.positionY = 0;
// The default is 24 bits of color, 24 bits of depth and 8 bits of stencil
_glfwLibrary.hints.redBits = 8;
_glfwLibrary.hints.greenBits = 8;
_glfwLibrary.hints.blueBits = 8;
_glfwLibrary.hints.depthBits = 24;
_glfwLibrary.hints.stencilBits = 8;
_glfw.hints.redBits = 8;
_glfw.hints.greenBits = 8;
_glfw.hints.blueBits = 8;
_glfw.hints.depthBits = 24;
_glfw.hints.stencilBits = 8;
}
@ -383,79 +383,79 @@ GLFWAPI void glfwWindowHint(int target, int hint)
switch (target)
{
case GLFW_RED_BITS:
_glfwLibrary.hints.redBits = hint;
_glfw.hints.redBits = hint;
break;
case GLFW_GREEN_BITS:
_glfwLibrary.hints.greenBits = hint;
_glfw.hints.greenBits = hint;
break;
case GLFW_BLUE_BITS:
_glfwLibrary.hints.blueBits = hint;
_glfw.hints.blueBits = hint;
break;
case GLFW_ALPHA_BITS:
_glfwLibrary.hints.alphaBits = hint;
_glfw.hints.alphaBits = hint;
break;
case GLFW_DEPTH_BITS:
_glfwLibrary.hints.depthBits = hint;
_glfw.hints.depthBits = hint;
break;
case GLFW_STENCIL_BITS:
_glfwLibrary.hints.stencilBits = hint;
_glfw.hints.stencilBits = hint;
break;
case GLFW_ACCUM_RED_BITS:
_glfwLibrary.hints.accumRedBits = hint;
_glfw.hints.accumRedBits = hint;
break;
case GLFW_ACCUM_GREEN_BITS:
_glfwLibrary.hints.accumGreenBits = hint;
_glfw.hints.accumGreenBits = hint;
break;
case GLFW_ACCUM_BLUE_BITS:
_glfwLibrary.hints.accumBlueBits = hint;
_glfw.hints.accumBlueBits = hint;
break;
case GLFW_ACCUM_ALPHA_BITS:
_glfwLibrary.hints.accumAlphaBits = hint;
_glfw.hints.accumAlphaBits = hint;
break;
case GLFW_AUX_BUFFERS:
_glfwLibrary.hints.auxBuffers = hint;
_glfw.hints.auxBuffers = hint;
break;
case GLFW_STEREO:
_glfwLibrary.hints.stereo = hint;
_glfw.hints.stereo = hint;
break;
case GLFW_RESIZABLE:
_glfwLibrary.hints.resizable = hint;
_glfw.hints.resizable = hint;
break;
case GLFW_VISIBLE:
_glfwLibrary.hints.visible = hint;
_glfw.hints.visible = hint;
break;
case GLFW_POSITION_X:
_glfwLibrary.hints.positionX = hint;
_glfw.hints.positionX = hint;
break;
case GLFW_POSITION_Y:
_glfwLibrary.hints.positionY = hint;
_glfw.hints.positionY = hint;
break;
case GLFW_SAMPLES:
_glfwLibrary.hints.samples = hint;
_glfw.hints.samples = hint;
break;
case GLFW_SRGB_CAPABLE:
_glfwLibrary.hints.sRGB = hint;
_glfw.hints.sRGB = hint;
break;
case GLFW_CLIENT_API:
_glfwLibrary.hints.clientAPI = hint;
_glfw.hints.clientAPI = hint;
break;
case GLFW_CONTEXT_VERSION_MAJOR:
_glfwLibrary.hints.glMajor = hint;
_glfw.hints.glMajor = hint;
break;
case GLFW_CONTEXT_VERSION_MINOR:
_glfwLibrary.hints.glMinor = hint;
_glfw.hints.glMinor = hint;
break;
case GLFW_CONTEXT_ROBUSTNESS:
_glfwLibrary.hints.glRobustness = hint;
_glfw.hints.glRobustness = hint;
break;
case GLFW_OPENGL_FORWARD_COMPAT:
_glfwLibrary.hints.glForward = hint;
_glfw.hints.glForward = hint;
break;
case GLFW_OPENGL_DEBUG_CONTEXT:
_glfwLibrary.hints.glDebug = hint;
_glfw.hints.glDebug = hint;
break;
case GLFW_OPENGL_PROFILE:
_glfwLibrary.hints.glProfile = hint;
_glfw.hints.glProfile = hint;
break;
default:
_glfwInputError(GLFW_INVALID_ENUM, NULL);
@ -502,14 +502,14 @@ GLFWAPI void glfwDestroyWindow(GLFWwindow handle)
_glfwPlatformMakeContextCurrent(NULL);
// Clear the focused window pointer if this is the focused window
if (window == _glfwLibrary.focusedWindow)
_glfwLibrary.focusedWindow = NULL;
if (window == _glfw.focusedWindow)
_glfw.focusedWindow = NULL;
_glfwPlatformDestroyWindow(window);
// Unlink window from global linked list
{
_GLFWwindow** prev = &_glfwLibrary.windowListHead;
_GLFWwindow** prev = &_glfw.windowListHead;
while (*prev != window)
prev = &((*prev)->next);
@ -690,7 +690,7 @@ GLFWAPI int glfwGetWindowParam(GLFWwindow handle, int param)
switch (param)
{
case GLFW_FOCUSED:
return window == _glfwLibrary.focusedWindow;
return window == _glfw.focusedWindow;
case GLFW_ICONIFIED:
return window->iconified;
case GLFW_SHOULD_CLOSE:

View File

@ -53,7 +53,7 @@ GLboolean _glfwReadSelection(XSelectionEvent* request)
if (request->property == None)
return GL_FALSE;
XGetWindowProperty(_glfwLibrary.X11.display,
XGetWindowProperty(_glfw.x11.display,
request->requestor,
request->property,
0, LONG_MAX,
@ -68,8 +68,8 @@ GLboolean _glfwReadSelection(XSelectionEvent* request)
if (actualType == None)
return GL_FALSE;
free(_glfwLibrary.X11.selection.string);
_glfwLibrary.X11.selection.string = strdup(data);
free(_glfw.x11.selection.string);
_glfw.x11.selection.string = strdup(data);
XFree(data);
return GL_TRUE;
@ -86,19 +86,19 @@ Atom _glfwWriteSelection(XSelectionRequestEvent* request)
Atom property = request->property;
if (property == None)
property = _glfwLibrary.X11.selection.property;
property = _glfw.x11.selection.property;
if (request->target == _glfwLibrary.X11.selection.targets)
if (request->target == _glfw.x11.selection.targets)
{
// The list of supported targets was requested
XChangeProperty(_glfwLibrary.X11.display,
XChangeProperty(_glfw.x11.display,
request->requestor,
property,
XA_ATOM,
32,
PropModeReplace,
(unsigned char*) _glfwLibrary.X11.selection.formats,
(unsigned char*) _glfw.x11.selection.formats,
_GLFW_CLIPBOARD_FORMAT_COUNT);
return property;
@ -106,18 +106,18 @@ Atom _glfwWriteSelection(XSelectionRequestEvent* request)
for (i = 0; i < _GLFW_CLIPBOARD_FORMAT_COUNT; i++)
{
if (request->target == _glfwLibrary.X11.selection.formats[i])
if (request->target == _glfw.x11.selection.formats[i])
{
// The requested target is one we support
XChangeProperty(_glfwLibrary.X11.display,
XChangeProperty(_glfw.x11.display,
request->requestor,
property,
request->target,
8,
PropModeReplace,
(unsigned char*) _glfwLibrary.X11.selection.string,
strlen(_glfwLibrary.X11.selection.string));
(unsigned char*) _glfw.x11.selection.string,
strlen(_glfw.x11.selection.string));
return property;
}
@ -138,13 +138,13 @@ Atom _glfwWriteSelection(XSelectionRequestEvent* request)
void _glfwPlatformSetClipboardString(_GLFWwindow* window, const char* string)
{
// Store the new string in preparation for a selection request event
free(_glfwLibrary.X11.selection.string);
_glfwLibrary.X11.selection.string = strdup(string);
free(_glfw.x11.selection.string);
_glfw.x11.selection.string = strdup(string);
// Set the specified window as owner of the selection
XSetSelectionOwner(_glfwLibrary.X11.display,
_glfwLibrary.X11.selection.atom,
window->X11.handle, CurrentTime);
XSetSelectionOwner(_glfw.x11.display,
_glfw.x11.selection.atom,
window->x11.handle, CurrentTime);
}
@ -156,36 +156,35 @@ const char* _glfwPlatformGetClipboardString(_GLFWwindow* window)
{
int i;
_glfwLibrary.X11.selection.status = _GLFW_CONVERSION_INACTIVE;
_glfw.x11.selection.status = _GLFW_CONVERSION_INACTIVE;
for (i = 0; i < _GLFW_CLIPBOARD_FORMAT_COUNT; i++)
{
// Request conversion to the selected format
_glfwLibrary.X11.selection.target =
_glfwLibrary.X11.selection.formats[i];
_glfw.x11.selection.target = _glfw.x11.selection.formats[i];
XConvertSelection(_glfwLibrary.X11.display,
_glfwLibrary.X11.selection.atom,
_glfwLibrary.X11.selection.target,
_glfwLibrary.X11.selection.property,
window->X11.handle, CurrentTime);
XConvertSelection(_glfw.x11.display,
_glfw.x11.selection.atom,
_glfw.x11.selection.target,
_glfw.x11.selection.property,
window->x11.handle, CurrentTime);
// Process the resulting SelectionNotify event
XSync(_glfwLibrary.X11.display, False);
while (_glfwLibrary.X11.selection.status == _GLFW_CONVERSION_INACTIVE)
XSync(_glfw.x11.display, False);
while (_glfw.x11.selection.status == _GLFW_CONVERSION_INACTIVE)
_glfwPlatformWaitEvents();
if (_glfwLibrary.X11.selection.status == _GLFW_CONVERSION_SUCCEEDED)
if (_glfw.x11.selection.status == _GLFW_CONVERSION_SUCCEEDED)
break;
}
if (_glfwLibrary.X11.selection.status == _GLFW_CONVERSION_FAILED)
if (_glfw.x11.selection.status == _GLFW_CONVERSION_FAILED)
{
_glfwInputError(GLFW_FORMAT_UNAVAILABLE,
"X11: Failed to convert selection to string");
return NULL;
}
return _glfwLibrary.X11.selection.string;
return _glfw.x11.selection.string;
}

View File

@ -45,25 +45,25 @@ void _glfwInitGammaRamp(void)
{
#ifdef _GLFW_HAS_XRANDR
// RandR gamma support is only available with version 1.2 and above
if (_glfwLibrary.X11.RandR.available &&
(_glfwLibrary.X11.RandR.majorVersion > 1 ||
(_glfwLibrary.X11.RandR.majorVersion == 1 &&
_glfwLibrary.X11.RandR.minorVersion >= 2)))
if (_glfw.x11.randr.available &&
(_glfw.x11.randr.versionMajor > 1 ||
(_glfw.x11.randr.versionMajor == 1 &&
_glfw.x11.randr.versionMinor >= 2)))
{
// FIXME: Assumes that all monitors have the same size gamma tables
// This is reasonable as I suspect the that if they did differ, it
// would imply that setting the gamma size to an arbitary size is
// possible as well.
XRRScreenResources* rr = XRRGetScreenResources(_glfwLibrary.X11.display,
_glfwLibrary.X11.root);
XRRScreenResources* rr = XRRGetScreenResources(_glfw.x11.display,
_glfw.x11.root);
_glfwLibrary.originalRampSize = XRRGetCrtcGammaSize(_glfwLibrary.X11.display,
_glfw.originalRampSize = XRRGetCrtcGammaSize(_glfw.x11.display,
rr->crtcs[0]);
if (_glfwLibrary.originalRampSize == 0)
if (_glfw.originalRampSize == 0)
{
// This is probably older Nvidia RandR with broken gamma support
// Flag it as useless and try Xf86VidMode below, if available
_glfwLibrary.X11.RandR.gammaBroken = GL_TRUE;
_glfw.x11.randr.gammaBroken = GL_TRUE;
}
XRRFreeScreenResources(rr);
@ -71,21 +71,20 @@ void _glfwInitGammaRamp(void)
#endif /*_GLFW_HAS_XRANDR*/
#if defined(_GLFW_HAS_XF86VIDMODE)
if (_glfwLibrary.X11.VidMode.available &&
!_glfwLibrary.originalRampSize)
if (_glfw.x11.vidmode.available && !_glfw.originalRampSize)
{
// Get the gamma size using XF86VidMode
XF86VidModeGetGammaRampSize(_glfwLibrary.X11.display,
_glfwLibrary.X11.screen,
&_glfwLibrary.originalRampSize);
XF86VidModeGetGammaRampSize(_glfw.x11.display,
_glfw.x11.screen,
&_glfw.originalRampSize);
}
#endif /*_GLFW_HAS_XF86VIDMODE*/
if (_glfwLibrary.originalRampSize)
if (_glfw.originalRampSize)
{
// Save the original gamma ramp
_glfwPlatformGetGammaRamp(&_glfwLibrary.originalRamp);
_glfwLibrary.currentRamp = _glfwLibrary.originalRamp;
_glfwPlatformGetGammaRamp(&_glfw.originalRamp);
_glfw.currentRamp = _glfw.originalRamp;
}
}
@ -96,8 +95,8 @@ void _glfwInitGammaRamp(void)
void _glfwTerminateGammaRamp(void)
{
if (_glfwLibrary.originalRampSize && _glfwLibrary.rampChanged)
_glfwPlatformSetGammaRamp(&_glfwLibrary.originalRamp);
if (_glfw.originalRampSize && _glfw.rampChanged)
_glfwPlatformSetGammaRamp(&_glfw.originalRamp);
}
@ -112,7 +111,7 @@ void _glfwTerminateGammaRamp(void)
void _glfwPlatformGetGammaRamp(GLFWgammaramp* ramp)
{
// For now, don't support anything that is not GLFW_GAMMA_RAMP_SIZE
if (_glfwLibrary.originalRampSize != GLFW_GAMMA_RAMP_SIZE)
if (_glfw.originalRampSize != GLFW_GAMMA_RAMP_SIZE)
{
_glfwInputError(GLFW_PLATFORM_ERROR,
"X11: Failed to get gamma ramp due to size "
@ -120,16 +119,15 @@ void _glfwPlatformGetGammaRamp(GLFWgammaramp* ramp)
return;
}
if (_glfwLibrary.X11.RandR.available &&
!_glfwLibrary.X11.RandR.gammaBroken)
if (_glfw.x11.randr.available && !_glfw.x11.randr.gammaBroken)
{
#if defined (_GLFW_HAS_XRANDR)
size_t size = GLFW_GAMMA_RAMP_SIZE * sizeof(unsigned short);
XRRScreenResources* rr = XRRGetScreenResources(_glfwLibrary.X11.display,
_glfwLibrary.X11.root);
XRRScreenResources* rr = XRRGetScreenResources(_glfw.x11.display,
_glfw.x11.root);
XRRCrtcGamma* gamma = XRRGetCrtcGamma(_glfwLibrary.X11.display,
XRRCrtcGamma* gamma = XRRGetCrtcGamma(_glfw.x11.display,
rr->crtcs[0]);
// TODO: Handle case of original ramp size having a size other than 256
@ -142,11 +140,11 @@ void _glfwPlatformGetGammaRamp(GLFWgammaramp* ramp)
XRRFreeScreenResources(rr);
#endif /*_GLFW_HAS_XRANDR*/
}
else if (_glfwLibrary.X11.VidMode.available)
else if (_glfw.x11.vidmode.available)
{
#if defined (_GLFW_HAS_XF86VIDMODE)
XF86VidModeGetGammaRamp(_glfwLibrary.X11.display,
_glfwLibrary.X11.screen,
XF86VidModeGetGammaRamp(_glfw.x11.display,
_glfw.x11.screen,
GLFW_GAMMA_RAMP_SIZE,
ramp->red,
ramp->green,
@ -163,7 +161,7 @@ void _glfwPlatformGetGammaRamp(GLFWgammaramp* ramp)
void _glfwPlatformSetGammaRamp(const GLFWgammaramp* ramp)
{
// For now, don't support anything that is not GLFW_GAMMA_RAMP_SIZE
if (_glfwLibrary.originalRampSize != GLFW_GAMMA_RAMP_SIZE)
if (_glfw.originalRampSize != GLFW_GAMMA_RAMP_SIZE)
{
_glfwInputError(GLFW_PLATFORM_ERROR,
"X11: Failed to set gamma ramp due to size "
@ -171,15 +169,14 @@ void _glfwPlatformSetGammaRamp(const GLFWgammaramp* ramp)
return;
}
if (_glfwLibrary.X11.RandR.available &&
!_glfwLibrary.X11.RandR.gammaBroken)
if (_glfw.x11.randr.available && !_glfw.x11.randr.gammaBroken)
{
#if defined (_GLFW_HAS_XRANDR)
int i;
size_t size = GLFW_GAMMA_RAMP_SIZE * sizeof(unsigned short);
XRRScreenResources* rr = XRRGetScreenResources(_glfwLibrary.X11.display,
_glfwLibrary.X11.root);
XRRScreenResources* rr = XRRGetScreenResources(_glfw.x11.display,
_glfw.x11.root);
// Update gamma per monitor
for (i = 0; i < rr->ncrtc; i++)
@ -190,18 +187,18 @@ void _glfwPlatformSetGammaRamp(const GLFWgammaramp* ramp)
memcpy(gamma->green, ramp->green, size);
memcpy(gamma->blue, ramp->blue, size);
XRRSetCrtcGamma(_glfwLibrary.X11.display, rr->crtcs[i], gamma);
XRRSetCrtcGamma(_glfw.x11.display, rr->crtcs[i], gamma);
XRRFreeGamma(gamma);
}
XRRFreeScreenResources(rr);
#endif /*_GLFW_HAS_XRANDR*/
}
else if (_glfwLibrary.X11.VidMode.available)
else if (_glfw.x11.vidmode.available)
{
#if defined (_GLFW_HAS_XF86VIDMODE)
XF86VidModeSetGammaRamp(_glfwLibrary.X11.display,
_glfwLibrary.X11.screen,
XF86VidModeSetGammaRamp(_glfw.x11.display,
_glfw.x11.screen,
GLFW_GAMMA_RAMP_SIZE,
(unsigned short*) ramp->red,
(unsigned short*) ramp->green,

View File

@ -52,9 +52,9 @@ static int keyCodeToGLFWKeyCode(int keyCode)
// since the returned key code should correspond to a physical
// location.
#if defined(_GLFW_HAS_XKB)
keySym = XkbKeycodeToKeysym(_glfwLibrary.X11.display, keyCode, 1, 0);
keySym = XkbKeycodeToKeysym(_glfw.x11.display, keyCode, 1, 0);
#else
keySym = XKeycodeToKeysym(_glfwLibrary.X11.display, keyCode, 1);
keySym = XKeycodeToKeysym(_glfw.x11.display, keyCode, 1);
#endif
switch (keySym)
{
@ -79,9 +79,9 @@ static int keyCodeToGLFWKeyCode(int keyCode)
// should not be layout dependent (i.e. US layout and international
// layouts should give the same result).
#if defined(_GLFW_HAS_XKB)
keySym = XkbKeycodeToKeysym(_glfwLibrary.X11.display, keyCode, 0, 0);
keySym = XkbKeycodeToKeysym(_glfw.x11.display, keyCode, 0, 0);
#else
keySym = XKeycodeToKeysym(_glfwLibrary.X11.display, keyCode, 0);
keySym = XKeycodeToKeysym(_glfw.x11.display, keyCode, 0);
#endif
switch (keySym)
@ -234,19 +234,19 @@ static void updateKeyCodeLUT(void)
// Clear the LUT
for (keyCode = 0; keyCode < 256; keyCode++)
_glfwLibrary.X11.keyCodeLUT[keyCode] = -1;
_glfw.x11.keyCodeLUT[keyCode] = -1;
#if defined(_GLFW_HAS_XKB)
// If the Xkb extension is available, use it to determine physical key
// locations independently of the current keyboard layout
if (_glfwLibrary.X11.Xkb.available)
if (_glfw.x11.xkb.available)
{
int i, keyCodeGLFW;
char name[XkbKeyNameLength + 1];
XkbDescPtr descr;
// Get keyboard description
descr = XkbGetKeyboard(_glfwLibrary.X11.display,
descr = XkbGetKeyboard(_glfw.x11.display,
XkbAllComponentsMask,
XkbUseCoreKbd);
@ -315,7 +315,7 @@ static void updateKeyCodeLUT(void)
// Update the key code LUT
if ((keyCode >= 0) && (keyCode < 256))
_glfwLibrary.X11.keyCodeLUT[keyCode] = keyCodeGLFW;
_glfw.x11.keyCodeLUT[keyCode] = keyCodeGLFW;
}
// Free the keyboard description
@ -327,11 +327,8 @@ static void updateKeyCodeLUT(void)
// lookups
for (keyCode = 0; keyCode < 256; keyCode++)
{
if (_glfwLibrary.X11.keyCodeLUT[keyCode] < 0)
{
_glfwLibrary.X11.keyCodeLUT[keyCode] =
keyCodeToGLFWKeyCode(keyCode);
}
if (_glfw.x11.keyCodeLUT[keyCode] < 0)
_glfw.x11.keyCodeLUT[keyCode] = keyCodeToGLFWKeyCode(keyCode);
}
}
@ -350,7 +347,7 @@ static unsigned long getWindowProperty(Window window,
int actualFormat;
unsigned long itemCount, bytesAfter;
XGetWindowProperty(_glfwLibrary.X11.display,
XGetWindowProperty(_glfw.x11.display,
window,
property,
0,
@ -378,7 +375,7 @@ static Atom getSupportedAtom(Atom* supportedAtoms,
unsigned long atomCount,
const char* atomName)
{
Atom atom = XInternAtom(_glfwLibrary.X11.display, atomName, True);
Atom atom = XInternAtom(_glfw.x11.display, atomName, True);
if (atom != None)
{
unsigned long i;
@ -405,14 +402,14 @@ static void initEWMH(void)
// First we need a couple of atoms, which should already be there
Atom supportingWmCheck =
XInternAtom(_glfwLibrary.X11.display, "_NET_SUPPORTING_WM_CHECK", True);
XInternAtom(_glfw.x11.display, "_NET_SUPPORTING_WM_CHECK", True);
Atom wmSupported =
XInternAtom(_glfwLibrary.X11.display, "_NET_SUPPORTED", True);
XInternAtom(_glfw.x11.display, "_NET_SUPPORTED", True);
if (supportingWmCheck == None || wmSupported == None)
return;
// Then we look for the _NET_SUPPORTING_WM_CHECK property of the root window
if (getWindowProperty(_glfwLibrary.X11.root,
if (getWindowProperty(_glfw.x11.root,
supportingWmCheck,
XA_WINDOW,
(unsigned char**) &windowFromRoot) != 1)
@ -451,34 +448,34 @@ static void initEWMH(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 = getWindowProperty(_glfwLibrary.X11.root,
atomCount = getWindowProperty(_glfw.x11.root,
wmSupported,
XA_ATOM,
(unsigned char**) &supportedAtoms);
// See which of the atoms we support that are supported by the WM
_glfwLibrary.X11.wmState =
_glfw.x11.wmState =
getSupportedAtom(supportedAtoms, atomCount, "_NET_WM_STATE");
_glfwLibrary.X11.wmStateFullscreen =
_glfw.x11.wmStateFullscreen =
getSupportedAtom(supportedAtoms, atomCount, "_NET_WM_STATE_FULLSCREEN");
_glfwLibrary.X11.wmName =
_glfw.x11.wmName =
getSupportedAtom(supportedAtoms, atomCount, "_NET_WM_NAME");
_glfwLibrary.X11.wmIconName =
_glfw.x11.wmIconName =
getSupportedAtom(supportedAtoms, atomCount, "_NET_WM_ICON_NAME");
_glfwLibrary.X11.wmPing =
_glfw.x11.wmPing =
getSupportedAtom(supportedAtoms, atomCount, "_NET_WM_PING");
_glfwLibrary.X11.wmActiveWindow =
_glfw.x11.wmActiveWindow =
getSupportedAtom(supportedAtoms, atomCount, "_NET_ACTIVE_WINDOW");
XFree(supportedAtoms);
_glfwLibrary.X11.hasEWMH = GL_TRUE;
_glfw.x11.hasEWMH = GL_TRUE;
}
@ -488,8 +485,8 @@ static void initEWMH(void)
static GLboolean initDisplay(void)
{
_glfwLibrary.X11.display = XOpenDisplay(NULL);
if (!_glfwLibrary.X11.display)
_glfw.x11.display = XOpenDisplay(NULL);
if (!_glfw.x11.display)
{
_glfwInputError(GLFW_API_UNAVAILABLE, "X11: Failed to open X display");
return GL_FALSE;
@ -497,32 +494,31 @@ static GLboolean initDisplay(void)
// As the API currently doesn't understand multiple display devices, we hard-code
// this choice and hope for the best
_glfwLibrary.X11.screen = DefaultScreen(_glfwLibrary.X11.display);
_glfwLibrary.X11.root = RootWindow(_glfwLibrary.X11.display,
_glfwLibrary.X11.screen);
_glfw.x11.screen = DefaultScreen(_glfw.x11.display);
_glfw.x11.root = RootWindow(_glfw.x11.display, _glfw.x11.screen);
// Check for XF86VidMode extension
#ifdef _GLFW_HAS_XF86VIDMODE
_glfwLibrary.X11.VidMode.available =
XF86VidModeQueryExtension(_glfwLibrary.X11.display,
&_glfwLibrary.X11.VidMode.eventBase,
&_glfwLibrary.X11.VidMode.errorBase);
_glfw.x11.vidmode.available =
XF86VidModeQueryExtension(_glfw.x11.display,
&_glfw.x11.vidmode.eventBase,
&_glfw.x11.vidmode.errorBase);
#else
_glfwLibrary.X11.VidMode.available = GL_FALSE;
_glfw.x11.vidmode.available = GL_FALSE;
#endif /*_GLFW_HAS_XF86VIDMODE*/
// Check for XRandR extension
#ifdef _GLFW_HAS_XRANDR
_glfwLibrary.X11.RandR.available =
XRRQueryExtension(_glfwLibrary.X11.display,
&_glfwLibrary.X11.RandR.eventBase,
&_glfwLibrary.X11.RandR.errorBase);
_glfw.x11.randr.available =
XRRQueryExtension(_glfw.x11.display,
&_glfw.x11.randr.eventBase,
&_glfw.x11.randr.errorBase);
if (_glfwLibrary.X11.RandR.available)
if (_glfw.x11.randr.available)
{
if (!XRRQueryVersion(_glfwLibrary.X11.display,
&_glfwLibrary.X11.RandR.majorVersion,
&_glfwLibrary.X11.RandR.minorVersion))
if (!XRRQueryVersion(_glfw.x11.display,
&_glfw.x11.randr.versionMajor,
&_glfw.x11.randr.versionMinor))
{
_glfwInputError(GLFW_PLATFORM_ERROR,
"X11: Failed to query RandR version");
@ -530,22 +526,22 @@ static GLboolean initDisplay(void)
}
}
#else
_glfwLibrary.X11.RandR.available = GL_FALSE;
_glfw.x11.randr.available = GL_FALSE;
#endif /*_GLFW_HAS_XRANDR*/
// Check if Xkb is supported on this display
#if defined(_GLFW_HAS_XKB)
_glfwLibrary.X11.Xkb.majorVersion = 1;
_glfwLibrary.X11.Xkb.minorVersion = 0;
_glfwLibrary.X11.Xkb.available =
XkbQueryExtension(_glfwLibrary.X11.display,
&_glfwLibrary.X11.Xkb.majorOpcode,
&_glfwLibrary.X11.Xkb.eventBase,
&_glfwLibrary.X11.Xkb.errorBase,
&_glfwLibrary.X11.Xkb.majorVersion,
&_glfwLibrary.X11.Xkb.minorVersion);
_glfw.x11.xkb.versionMajor = 1;
_glfw.x11.xkb.versionMinor = 0;
_glfw.x11.xkb.available =
XkbQueryExtension(_glfw.x11.display,
&_glfw.x11.xkb.majorOpcode,
&_glfw.x11.xkb.eventBase,
&_glfw.x11.xkb.errorBase,
&_glfw.x11.xkb.versionMajor,
&_glfw.x11.xkb.versionMinor);
#else
_glfwLibrary.X11.Xkb.available = GL_FALSE;
_glfw.x11.xkb.available = GL_FALSE;
#endif /* _GLFW_HAS_XKB */
// Update the key code LUT
@ -554,22 +550,22 @@ static GLboolean initDisplay(void)
updateKeyCodeLUT();
// Find or create selection property atom
_glfwLibrary.X11.selection.property =
XInternAtom(_glfwLibrary.X11.display, "GLFW_SELECTION", False);
_glfw.x11.selection.property =
XInternAtom(_glfw.x11.display, "GLFW_SELECTION", False);
// Find or create clipboard atom
_glfwLibrary.X11.selection.atom =
XInternAtom(_glfwLibrary.X11.display, "CLIPBOARD", False);
_glfw.x11.selection.atom =
XInternAtom(_glfw.x11.display, "CLIPBOARD", False);
// Find or create selection target atoms
_glfwLibrary.X11.selection.formats[_GLFW_CLIPBOARD_FORMAT_UTF8] =
XInternAtom(_glfwLibrary.X11.display, "UTF8_STRING", False);
_glfwLibrary.X11.selection.formats[_GLFW_CLIPBOARD_FORMAT_COMPOUND] =
XInternAtom(_glfwLibrary.X11.display, "COMPOUND_STRING", False);
_glfwLibrary.X11.selection.formats[_GLFW_CLIPBOARD_FORMAT_STRING] =
_glfw.x11.selection.formats[_GLFW_CLIPBOARD_FORMAT_UTF8] =
XInternAtom(_glfw.x11.display, "UTF8_STRING", False);
_glfw.x11.selection.formats[_GLFW_CLIPBOARD_FORMAT_COMPOUND] =
XInternAtom(_glfw.x11.display, "COMPOUND_STRING", False);
_glfw.x11.selection.formats[_GLFW_CLIPBOARD_FORMAT_STRING] =
XA_STRING;
_glfwLibrary.X11.selection.targets = XInternAtom(_glfwLibrary.X11.display,
_glfw.x11.selection.targets = XInternAtom(_glfw.x11.display,
"TARGETS",
False);
@ -591,20 +587,18 @@ static Cursor createNULLCursor(void)
// TODO: Add error checks
cursormask = XCreatePixmap(_glfwLibrary.X11.display,
_glfwLibrary.X11.root,
1, 1, 1);
cursormask = XCreatePixmap(_glfw.x11.display, _glfw.x11.root, 1, 1, 1);
xgc.function = GXclear;
gc = XCreateGC(_glfwLibrary.X11.display, cursormask, GCFunction, &xgc);
XFillRectangle(_glfwLibrary.X11.display, cursormask, gc, 0, 0, 1, 1);
gc = XCreateGC(_glfw.x11.display, cursormask, GCFunction, &xgc);
XFillRectangle(_glfw.x11.display, cursormask, gc, 0, 0, 1, 1);
col.pixel = 0;
col.red = 0;
col.flags = 4;
cursor = XCreatePixmapCursor(_glfwLibrary.X11.display,
cursor = XCreatePixmapCursor(_glfw.x11.display,
cursormask, cursormask,
&col, &col, 0, 0);
XFreePixmap(_glfwLibrary.X11.display, cursormask);
XFreeGC(_glfwLibrary.X11.display, gc);
XFreePixmap(_glfw.x11.display, cursormask);
XFreeGC(_glfw.x11.display, gc);
return cursor;
}
@ -616,10 +610,10 @@ static Cursor createNULLCursor(void)
static void terminateDisplay(void)
{
if (_glfwLibrary.X11.display)
if (_glfw.x11.display)
{
XCloseDisplay(_glfwLibrary.X11.display);
_glfwLibrary.X11.display = NULL;
XCloseDisplay(_glfw.x11.display);
_glfw.x11.display = NULL;
}
}
@ -646,7 +640,7 @@ int _glfwPlatformInit(void)
initEWMH();
_glfwLibrary.X11.cursor = createNULLCursor();
_glfw.x11.cursor = createNULLCursor();
if (!_glfwInitJoysticks())
return GL_FALSE;
@ -664,10 +658,10 @@ int _glfwPlatformInit(void)
void _glfwPlatformTerminate(void)
{
if (_glfwLibrary.X11.cursor)
if (_glfw.x11.cursor)
{
XFreeCursor(_glfwLibrary.X11.display, _glfwLibrary.X11.cursor);
_glfwLibrary.X11.cursor = (Cursor) 0;
XFreeCursor(_glfw.x11.display, _glfw.x11.cursor);
_glfw.x11.cursor = (Cursor) 0;
}
_glfwTerminateGammaRamp();
@ -679,8 +673,8 @@ void _glfwPlatformTerminate(void)
terminateDisplay();
// Free clipboard memory
if (_glfwLibrary.X11.selection.string)
free(_glfwLibrary.X11.selection.string);
if (_glfw.x11.selection.string)
free(_glfw.x11.selection.string);
}

View File

@ -60,7 +60,7 @@ static int openJoystickDevice(int joy, const char* path)
if (fd == -1)
return GL_FALSE;
_glfwLibrary.X11.joystick[joy].fd = fd;
_glfw.x11.joystick[joy].fd = fd;
// Verify that the joystick driver version is at least 1.0
ioctl(fd, JSIOCGVERSION, &version);
@ -74,17 +74,16 @@ static int openJoystickDevice(int joy, const char* path)
if (ioctl(fd, JSIOCGNAME(sizeof(name)), name) < 0)
strncpy(name, "Unknown", sizeof(name));
_glfwLibrary.X11.joystick[joy].name = strdup(name);
_glfw.x11.joystick[joy].name = strdup(name);
ioctl(fd, JSIOCGAXES, &numAxes);
_glfwLibrary.X11.joystick[joy].numAxes = (int) numAxes;
_glfw.x11.joystick[joy].numAxes = (int) numAxes;
ioctl(fd, JSIOCGBUTTONS, &numButtons);
_glfwLibrary.X11.joystick[joy].numButtons = (int) numButtons;
_glfw.x11.joystick[joy].numButtons = (int) numButtons;
_glfwLibrary.X11.joystick[joy].axis =
(float*) malloc(sizeof(float) * numAxes);
if (_glfwLibrary.X11.joystick[joy].axis == NULL)
_glfw.x11.joystick[joy].axis = (float*) malloc(sizeof(float) * numAxes);
if (_glfw.x11.joystick[joy].axis == NULL)
{
close(fd);
@ -92,18 +91,17 @@ static int openJoystickDevice(int joy, const char* path)
return GL_FALSE;
}
_glfwLibrary.X11.joystick[joy].button =
(unsigned char*) malloc(sizeof(char) * numButtons);
if (_glfwLibrary.X11.joystick[joy].button == NULL)
_glfw.x11.joystick[joy].button = (unsigned char*) malloc(numButtons);
if (_glfw.x11.joystick[joy].button == NULL)
{
free(_glfwLibrary.X11.joystick[joy].axis);
free(_glfw.x11.joystick[joy].axis);
close(fd);
_glfwInputError(GLFW_OUT_OF_MEMORY, NULL);
return GL_FALSE;
}
_glfwLibrary.X11.joystick[joy].present = GL_TRUE;
_glfw.x11.joystick[joy].present = GL_TRUE;
#endif // __linux__
return GL_TRUE;
@ -123,17 +121,17 @@ static void pollJoystickEvents(void)
for (i = 0; i <= GLFW_JOYSTICK_LAST; i++)
{
if (!_glfwLibrary.X11.joystick[i].present)
if (!_glfw.x11.joystick[i].present)
continue;
// Read all queued events (non-blocking)
for (;;)
{
errno = 0;
result = read(_glfwLibrary.X11.joystick[i].fd, &e, sizeof(e));
result = read(_glfw.x11.joystick[i].fd, &e, sizeof(e));
if (errno == ENODEV)
_glfwLibrary.X11.joystick[i].present = GL_FALSE;
_glfw.x11.joystick[i].present = GL_FALSE;
if (result == -1)
break;
@ -144,21 +142,21 @@ static void pollJoystickEvents(void)
switch (e.type)
{
case JS_EVENT_AXIS:
_glfwLibrary.X11.joystick[i].axis[e.number] =
_glfw.x11.joystick[i].axis[e.number] =
(float) e.value / 32767.0f;
// We need to change the sign for the Y axes, so that
// positive = up/forward, according to the GLFW spec.
if (e.number & 1)
{
_glfwLibrary.X11.joystick[i].axis[e.number] =
-_glfwLibrary.X11.joystick[i].axis[e.number];
_glfw.x11.joystick[i].axis[e.number] =
-_glfw.x11.joystick[i].axis[e.number];
}
break;
case JS_EVENT_BUTTON:
_glfwLibrary.X11.joystick[i].button[e.number] =
_glfw.x11.joystick[i].button[e.number] =
e.value ? GLFW_PRESS : GLFW_RELEASE;
break;
@ -239,14 +237,14 @@ void _glfwTerminateJoysticks(void)
for (i = 0; i <= GLFW_JOYSTICK_LAST; i++)
{
if (_glfwLibrary.X11.joystick[i].present)
if (_glfw.x11.joystick[i].present)
{
close(_glfwLibrary.X11.joystick[i].fd);
free(_glfwLibrary.X11.joystick[i].axis);
free(_glfwLibrary.X11.joystick[i].button);
free(_glfwLibrary.X11.joystick[i].name);
close(_glfw.x11.joystick[i].fd);
free(_glfw.x11.joystick[i].axis);
free(_glfw.x11.joystick[i].button);
free(_glfw.x11.joystick[i].name);
_glfwLibrary.X11.joystick[i].present = GL_FALSE;
_glfw.x11.joystick[i].present = GL_FALSE;
}
}
#endif // __linux__
@ -265,7 +263,7 @@ int _glfwPlatformGetJoystickParam(int joy, int param)
{
pollJoystickEvents();
if (!_glfwLibrary.X11.joystick[joy].present)
if (!_glfw.x11.joystick[joy].present)
return 0;
switch (param)
@ -274,10 +272,10 @@ int _glfwPlatformGetJoystickParam(int joy, int param)
return GL_TRUE;
case GLFW_AXES:
return _glfwLibrary.X11.joystick[joy].numAxes;
return _glfw.x11.joystick[joy].numAxes;
case GLFW_BUTTONS:
return _glfwLibrary.X11.joystick[joy].numButtons;
return _glfw.x11.joystick[joy].numButtons;
default:
_glfwInputError(GLFW_INVALID_ENUM, NULL);
@ -297,14 +295,14 @@ int _glfwPlatformGetJoystickAxes(int joy, float* axes, int numAxes)
pollJoystickEvents();
if (!_glfwLibrary.X11.joystick[joy].present)
if (!_glfw.x11.joystick[joy].present)
return 0;
if (_glfwLibrary.X11.joystick[joy].numAxes < numAxes)
numAxes = _glfwLibrary.X11.joystick[joy].numAxes;
if (_glfw.x11.joystick[joy].numAxes < numAxes)
numAxes = _glfw.x11.joystick[joy].numAxes;
for (i = 0; i < numAxes; i++)
axes[i] = _glfwLibrary.X11.joystick[joy].axis[i];
axes[i] = _glfw.x11.joystick[joy].axis[i];
return numAxes;
}
@ -321,14 +319,14 @@ int _glfwPlatformGetJoystickButtons(int joy, unsigned char* buttons,
pollJoystickEvents();
if (!_glfwLibrary.X11.joystick[joy].present)
if (!_glfw.x11.joystick[joy].present)
return 0;
if (_glfwLibrary.X11.joystick[joy].numButtons < numButtons)
numButtons = _glfwLibrary.X11.joystick[joy].numButtons;
if (_glfw.x11.joystick[joy].numButtons < numButtons)
numButtons = _glfw.x11.joystick[joy].numButtons;
for (i = 0; i < numButtons; i++)
buttons[i] = _glfwLibrary.X11.joystick[joy].button[i];
buttons[i] = _glfw.x11.joystick[joy].button[i];
return numButtons;
}
@ -340,9 +338,9 @@ int _glfwPlatformGetJoystickButtons(int joy, unsigned char* buttons,
const char* _glfwPlatformGetJoystickName(int joy)
{
if (!_glfwLibrary.X11.joystick[joy].present)
if (!_glfw.x11.joystick[joy].present)
return NULL;
return _glfwLibrary.X11.joystick[joy].name;
return _glfw.x11.joystick[joy].name;
}

View File

@ -47,14 +47,14 @@ int _glfwGetClosestVideoMode(int* width, int* height)
{
int i, match, bestmatch;
if (_glfwLibrary.X11.RandR.available)
if (_glfw.x11.randr.available)
{
#if defined(_GLFW_HAS_XRANDR)
int sizecount, bestsize;
XRRScreenConfiguration* sc;
XRRScreenSize* sizelist;
sc = XRRGetScreenInfo(_glfwLibrary.X11.display, _glfwLibrary.X11.root);
sc = XRRGetScreenInfo(_glfw.x11.display, _glfw.x11.root);
sizelist = XRRConfigSizes(sc, &sizecount);
@ -89,8 +89,8 @@ int _glfwGetClosestVideoMode(int* width, int* height)
}
// Default: Simply use the screen resolution
*width = DisplayWidth(_glfwLibrary.X11.display, _glfwLibrary.X11.screen);
*height = DisplayHeight(_glfwLibrary.X11.display, _glfwLibrary.X11.screen);
*width = DisplayWidth(_glfw.x11.display, _glfw.x11.screen);
*height = DisplayHeight(_glfw.x11.display, _glfw.x11.screen);
return 0;
}
@ -102,28 +102,28 @@ int _glfwGetClosestVideoMode(int* width, int* height)
void _glfwSetVideoModeMODE(int mode)
{
if (_glfwLibrary.X11.RandR.available)
if (_glfw.x11.randr.available)
{
#if defined(_GLFW_HAS_XRANDR)
XRRScreenConfiguration* sc;
Window root;
root = _glfwLibrary.X11.root;
sc = XRRGetScreenInfo(_glfwLibrary.X11.display, root);
root = _glfw.x11.root;
sc = XRRGetScreenInfo(_glfw.x11.display, root);
// Remember old size and flag that we have changed the mode
if (!_glfwLibrary.X11.FS.modeChanged)
if (!_glfw.x11.fs.modeChanged)
{
_glfwLibrary.X11.FS.oldSizeID = XRRConfigCurrentConfiguration(sc, &_glfwLibrary.X11.FS.oldRotation);
_glfwLibrary.X11.FS.oldWidth = DisplayWidth(_glfwLibrary.X11.display,
_glfwLibrary.X11.screen);
_glfwLibrary.X11.FS.oldHeight = DisplayHeight(_glfwLibrary.X11.display,
_glfwLibrary.X11.screen);
_glfw.x11.fs.oldSizeID = XRRConfigCurrentConfiguration(sc, &_glfw.x11.fs.oldRotation);
_glfw.x11.fs.oldWidth = DisplayWidth(_glfw.x11.display,
_glfw.x11.screen);
_glfw.x11.fs.oldHeight = DisplayHeight(_glfw.x11.display,
_glfw.x11.screen);
_glfwLibrary.X11.FS.modeChanged = GL_TRUE;
_glfw.x11.fs.modeChanged = GL_TRUE;
}
XRRSetScreenConfig(_glfwLibrary.X11.display,
XRRSetScreenConfig(_glfw.x11.display,
sc,
root,
mode,
@ -158,23 +158,22 @@ void _glfwSetVideoMode(int* width, int* height)
void _glfwRestoreVideoMode(void)
{
if (_glfwLibrary.X11.FS.modeChanged)
if (_glfw.x11.fs.modeChanged)
{
if (_glfwLibrary.X11.RandR.available)
if (_glfw.x11.randr.available)
{
#if defined(_GLFW_HAS_XRANDR)
XRRScreenConfiguration* sc;
if (_glfwLibrary.X11.RandR.available)
if (_glfw.x11.randr.available)
{
sc = XRRGetScreenInfo(_glfwLibrary.X11.display,
_glfwLibrary.X11.root);
sc = XRRGetScreenInfo(_glfw.x11.display, _glfw.x11.root);
XRRSetScreenConfig(_glfwLibrary.X11.display,
XRRSetScreenConfig(_glfw.x11.display,
sc,
_glfwLibrary.X11.root,
_glfwLibrary.X11.FS.oldSizeID,
_glfwLibrary.X11.FS.oldRotation,
_glfw.x11.root,
_glfw.x11.fs.oldSizeID,
_glfw.x11.fs.oldRotation,
CurrentTime);
XRRFreeScreenConfigInfo(sc);
@ -182,7 +181,7 @@ void _glfwRestoreVideoMode(void)
#endif /*_GLFW_HAS_XRANDR*/
}
_glfwLibrary.X11.FS.modeChanged = GL_FALSE;
_glfw.x11.fs.modeChanged = GL_FALSE;
}
}
@ -201,18 +200,16 @@ _GLFWmonitor** _glfwPlatformGetMonitors(int* count)
int found = 0;
_GLFWmonitor** monitors = NULL;
if (_glfwLibrary.X11.RandR.available)
if (_glfw.x11.randr.available)
{
#if defined (_GLFW_HAS_XRANDR)
int i;
RROutput primary;
XRRScreenResources* sr;
sr = XRRGetScreenResources(_glfwLibrary.X11.display,
_glfwLibrary.X11.root);
sr = XRRGetScreenResources(_glfw.x11.display, _glfw.x11.root);
primary = XRRGetOutputPrimary(_glfwLibrary.X11.display,
_glfwLibrary.X11.root);
primary = XRRGetOutputPrimary(_glfw.x11.display, _glfw.x11.root);
monitors = (_GLFWmonitor**) calloc(sr->noutput, sizeof(_GLFWmonitor*));
if (!monitors)
@ -229,7 +226,7 @@ _GLFWmonitor** _glfwPlatformGetMonitors(int* count)
XRRCrtcInfo* ci;
int physicalWidth, physicalHeight;
oi = XRRGetOutputInfo(_glfwLibrary.X11.display, sr, sr->outputs[i]);
oi = XRRGetOutputInfo(_glfw.x11.display, sr, sr->outputs[i]);
if (oi->connection != RR_Connected)
{
XRRFreeOutputInfo(oi);
@ -243,13 +240,13 @@ _GLFWmonitor** _glfwPlatformGetMonitors(int* count)
}
else
{
physicalWidth = DisplayWidthMM(_glfwLibrary.X11.display,
_glfwLibrary.X11.screen);
physicalHeight = DisplayHeightMM(_glfwLibrary.X11.display,
_glfwLibrary.X11.screen);
physicalWidth = DisplayWidthMM(_glfw.x11.display,
_glfw.x11.screen);
physicalHeight = DisplayHeightMM(_glfw.x11.display,
_glfw.x11.screen);
}
ci = XRRGetCrtcInfo(_glfwLibrary.X11.display, sr, oi->crtc);
ci = XRRGetCrtcInfo(_glfw.x11.display, sr, oi->crtc);
monitors[found] = _glfwCreateMonitor(oi->name,
sr->outputs[i] == primary,
@ -265,7 +262,7 @@ _GLFWmonitor** _glfwPlatformGetMonitors(int* count)
}
// This is retained until the monitor object is destroyed
monitors[found]->X11.output = oi;
monitors[found]->x11.output = oi;
found++;
}
#endif /*_GLFW_HAS_XRANDR*/
@ -282,10 +279,10 @@ _GLFWmonitor** _glfwPlatformGetMonitors(int* count)
void _glfwPlatformDestroyMonitor(_GLFWmonitor* monitor)
{
if (_glfwLibrary.X11.RandR.available)
if (_glfw.x11.randr.available)
{
#if defined (_GLFW_HAS_XRANDR)
XRRFreeOutputInfo(monitor->X11.output);
XRRFreeOutputInfo(monitor->x11.output);
#endif /*_GLFW_HAS_XRANDR*/
}
}
@ -300,21 +297,20 @@ GLFWvidmode* _glfwPlatformGetVideoModes(_GLFWmonitor* monitor, int* found)
GLFWvidmode* result;
int depth, r, g, b;
depth = DefaultDepth(_glfwLibrary.X11.display, _glfwLibrary.X11.screen);
depth = DefaultDepth(_glfw.x11.display, _glfw.x11.screen);
_glfwSplitBPP(depth, &r, &g, &b);
*found = 0;
// Build array of available resolutions
if (_glfwLibrary.X11.RandR.available)
if (_glfw.x11.randr.available)
{
#if defined(_GLFW_HAS_XRANDR)
XRRScreenResources* sr;
int i, j, count = monitor->X11.output->nmode;
int i, j, count = monitor->x11.output->nmode;
sr = XRRGetScreenResources(_glfwLibrary.X11.display,
_glfwLibrary.X11.root);
sr = XRRGetScreenResources(_glfw.x11.display, _glfw.x11.root);
result = (GLFWvidmode*) malloc(sizeof(GLFWvidmode) * count);
if (!result)
@ -329,7 +325,7 @@ GLFWvidmode* _glfwPlatformGetVideoModes(_GLFWmonitor* monitor, int* found)
for (j = 0; j < sr->nmode; j++)
{
if (sr->modes[j].id == monitor->X11.output->modes[i])
if (sr->modes[j].id == monitor->x11.output->modes[i])
break;
}
@ -377,10 +373,8 @@ GLFWvidmode* _glfwPlatformGetVideoModes(_GLFWmonitor* monitor, int* found)
return NULL;
}
result[0].width = DisplayWidth(_glfwLibrary.X11.display,
_glfwLibrary.X11.screen);
result[0].height = DisplayHeight(_glfwLibrary.X11.display,
_glfwLibrary.X11.screen);
result[0].width = DisplayWidth(_glfw.x11.display, _glfw.x11.screen);
result[0].height = DisplayHeight(_glfw.x11.display, _glfw.x11.screen);
result[0].redBits = r;
result[0].greenBits = g;
result[0].blueBits = b;
@ -396,14 +390,13 @@ GLFWvidmode* _glfwPlatformGetVideoModes(_GLFWmonitor* monitor, int* found)
void _glfwPlatformGetVideoMode(_GLFWmonitor* monitor, GLFWvidmode* mode)
{
if (_glfwLibrary.X11.RandR.available)
if (_glfw.x11.randr.available)
{
#if defined (_GLFW_HAS_XRANDR)
XRRScreenResources* sr;
XRRCrtcInfo* ci;
sr = XRRGetScreenResources(_glfwLibrary.X11.display,
_glfwLibrary.X11.root);
sr = XRRGetScreenResources(_glfw.x11.display, _glfw.x11.root);
if (!sr)
{
_glfwInputError(GLFW_PLATFORM_ERROR,
@ -411,8 +404,7 @@ void _glfwPlatformGetVideoMode(_GLFWmonitor* monitor, GLFWvidmode* mode)
return;
}
ci = XRRGetCrtcInfo(_glfwLibrary.X11.display,
sr, monitor->X11.output->crtc);
ci = XRRGetCrtcInfo(_glfw.x11.display, sr, monitor->x11.output->crtc);
if (!ci)
{
XRRFreeScreenResources(sr);
@ -431,14 +423,11 @@ void _glfwPlatformGetVideoMode(_GLFWmonitor* monitor, GLFWvidmode* mode)
}
else
{
mode->width = DisplayWidth(_glfwLibrary.X11.display,
_glfwLibrary.X11.screen);
mode->height = DisplayHeight(_glfwLibrary.X11.display,
_glfwLibrary.X11.screen);
mode->width = DisplayWidth(_glfw.x11.display, _glfw.x11.screen);
mode->height = DisplayHeight(_glfw.x11.display, _glfw.x11.screen);
}
_glfwSplitBPP(DefaultDepth(_glfwLibrary.X11.display,
_glfwLibrary.X11.screen),
_glfwSplitBPP(DefaultDepth(_glfw.x11.display, _glfw.x11.screen),
&mode->redBits, &mode->greenBits, &mode->blueBits);
}

View File

@ -43,7 +43,7 @@
GLFWAPI Display* glfwGetX11Display(void)
{
return _glfwLibrary.X11.display;
return _glfw.x11.display;
}
@ -61,7 +61,7 @@ GLFWAPI Window glfwGetX11Window(GLFWwindow handle)
return 0;
}
return window->X11.handle;
return window->x11.handle;
}
@ -79,6 +79,6 @@ GLFWAPI GLXContext glfwGetGLXContext(GLFWwindow handle)
return NULL;
}
return window->GLX.context;
return window->glx.context;
}

View File

@ -54,20 +54,20 @@
#endif
#if defined(_GLFW_GLX)
#define _GLFW_X11_CONTEXT_VISUAL window->GLX.visual
#define _GLFW_X11_CONTEXT_VISUAL window->glx.visual
#include "glx_platform.h"
#elif defined(_GLFW_EGL)
#define _GLFW_X11_CONTEXT_VISUAL window->EGL.visual
#define _GLFW_EGL_NATIVE_WINDOW window->X11.handle
#define _GLFW_EGL_NATIVE_DISPLAY _glfwLibrary.X11.display
#define _GLFW_X11_CONTEXT_VISUAL window->egl.visual
#define _GLFW_EGL_NATIVE_WINDOW window->x11.handle
#define _GLFW_EGL_NATIVE_DISPLAY _glfw.x11.display
#include "egl_platform.h"
#else
#error "No supported context creation API selected"
#endif
#define _GLFW_PLATFORM_WINDOW_STATE _GLFWwindowX11 X11
#define _GLFW_PLATFORM_LIBRARY_WINDOW_STATE _GLFWlibraryX11 X11
#define _GLFW_PLATFORM_MONITOR_STATE _GLFWmonitorX11 X11
#define _GLFW_PLATFORM_WINDOW_STATE _GLFWwindowX11 x11
#define _GLFW_PLATFORM_LIBRARY_WINDOW_STATE _GLFWlibraryX11 x11
#define _GLFW_PLATFORM_MONITOR_STATE _GLFWmonitorX11 x11
// Clipboard format atom indices
#define _GLFW_CLIPBOARD_FORMAT_UTF8 0
@ -141,25 +141,25 @@ typedef struct _GLFWlibraryX11
GLboolean available;
int eventBase;
int errorBase;
} VidMode;
} vidmode;
struct {
GLboolean available;
int eventBase;
int errorBase;
int majorVersion;
int minorVersion;
int versionMajor;
int versionMinor;
GLboolean gammaBroken;
} RandR;
} randr;
struct {
GLboolean available;
int majorOpcode;
int eventBase;
int errorBase;
int majorVersion;
int minorVersion;
} Xkb;
int versionMajor;
int versionMinor;
} xkb;
// Key code LUT (mapping X11 key codes to GLFW key codes)
int keyCodeLUT[256];
@ -185,7 +185,7 @@ typedef struct _GLFWlibraryX11
#if defined(_GLFW_HAS_XF86VIDMODE)
XF86VidModeModeInfo oldMode;
#endif /*_GLFW_HAS_XF86VIDMODE*/
} FS;
} fs;
// Timer data
struct {

View File

@ -41,7 +41,7 @@
static uint64_t getRawTime(void)
{
#if defined(CLOCK_MONOTONIC)
if (_glfwLibrary.X11.timer.monotonic)
if (_glfw.x11.timer.monotonic)
{
struct timespec ts;
@ -70,16 +70,16 @@ void _glfwInitTimer(void)
if (clock_gettime(CLOCK_MONOTONIC, &ts) == 0)
{
_glfwLibrary.X11.timer.monotonic = GL_TRUE;
_glfwLibrary.X11.timer.resolution = 1e-9;
_glfw.x11.timer.monotonic = GL_TRUE;
_glfw.x11.timer.resolution = 1e-9;
}
else
#endif
{
_glfwLibrary.X11.timer.resolution = 1e-6;
_glfw.x11.timer.resolution = 1e-6;
}
_glfwLibrary.X11.timer.base = getRawTime();
_glfw.x11.timer.base = getRawTime();
}
@ -93,8 +93,8 @@ void _glfwInitTimer(void)
double _glfwPlatformGetTime(void)
{
return (double) (getRawTime() - _glfwLibrary.X11.timer.base) *
_glfwLibrary.X11.timer.resolution;
return (double) (getRawTime() - _glfw.x11.timer.base) *
_glfw.x11.timer.resolution;
}
@ -104,7 +104,7 @@ double _glfwPlatformGetTime(void)
void _glfwPlatformSetTime(double time)
{
_glfwLibrary.X11.timer.base = getRawTime() -
(uint64_t) (time / _glfwLibrary.X11.timer.resolution);
_glfw.x11.timer.base = getRawTime() -
(uint64_t) (time / _glfw.x11.timer.resolution);
}

View File

@ -54,7 +54,7 @@ static int translateKey(int keycode)
{
// Use the pre-filled LUT (see updateKeyCodeLUT() in x11_init.c)
if ((keycode >= 0) && (keycode < 256))
return _glfwLibrary.X11.keyCodeLUT[keycode];
return _glfw.x11.keyCodeLUT[keycode];
else
return -1;
}
@ -91,8 +91,8 @@ static GLboolean createWindow(_GLFWwindow* window,
// Create one based on the visual used by the current context
// TODO: Decouple this from context creation
window->X11.colormap = XCreateColormap(_glfwLibrary.X11.display,
_glfwLibrary.X11.root,
window->x11.colormap = XCreateColormap(_glfw.x11.display,
_glfw.x11.root,
visual->visual,
AllocNone);
@ -100,7 +100,7 @@ static GLboolean createWindow(_GLFWwindow* window,
{
wamask = CWBorderPixel | CWColormap | CWEventMask;
wa.colormap = window->X11.colormap;
wa.colormap = window->x11.colormap;
wa.border_pixel = 0;
wa.event_mask = StructureNotifyMask | KeyPressMask | KeyReleaseMask |
PointerMotionMask | ButtonPressMask | ButtonReleaseMask |
@ -112,13 +112,13 @@ static GLboolean createWindow(_GLFWwindow* window,
// The /only/ reason for setting the background pixel here is that
// otherwise our window won't get any decorations on systems using
// certain versions of Compiz on Intel hardware
wa.background_pixel = BlackPixel(_glfwLibrary.X11.display,
_glfwLibrary.X11.screen);
wa.background_pixel = BlackPixel(_glfw.x11.display,
_glfw.x11.screen);
wamask |= CWBackPixel;
}
window->X11.handle = XCreateWindow(_glfwLibrary.X11.display,
_glfwLibrary.X11.root,
window->x11.handle = XCreateWindow(_glfw.x11.display,
_glfw.x11.root,
wndconfig->positionX, wndconfig->positionY,
window->width, window->height,
0, // Border width
@ -128,7 +128,7 @@ static GLboolean createWindow(_GLFWwindow* window,
wamask,
&wa);
if (!window->X11.handle)
if (!window->x11.handle)
{
// TODO: Handle all the various error codes here and translate them
// to GLFW errors
@ -139,12 +139,12 @@ static GLboolean createWindow(_GLFWwindow* window,
// Request a window position to be set once the window is shown
// (see _glfwPlatformShowWindow)
window->X11.windowPosSet = GL_FALSE;
window->X11.positionX = wndconfig->positionX;
window->X11.positionY = wndconfig->positionY;
window->x11.windowPosSet = GL_FALSE;
window->x11.positionX = wndconfig->positionX;
window->x11.positionY = wndconfig->positionY;
}
if (window->monitor && !_glfwLibrary.X11.hasEWMH)
if (window->monitor && !_glfw.x11.hasEWMH)
{
// This is the butcher's way of removing window decorations
// Setting the override-redirect attribute on a window makes the window
@ -156,16 +156,16 @@ static GLboolean createWindow(_GLFWwindow* window,
XSetWindowAttributes attributes;
attributes.override_redirect = True;
XChangeWindowAttributes(_glfwLibrary.X11.display,
window->X11.handle,
XChangeWindowAttributes(_glfw.x11.display,
window->x11.handle,
CWOverrideRedirect,
&attributes);
window->X11.overrideRedirect = GL_TRUE;
window->x11.overrideRedirect = GL_TRUE;
}
// Find or create the protocol atom for window close notifications
_glfwLibrary.X11.wmDeleteWindow = XInternAtom(_glfwLibrary.X11.display,
_glfw.x11.wmDeleteWindow = XInternAtom(_glfw.x11.display,
"WM_DELETE_WINDOW",
False);
@ -176,18 +176,18 @@ static GLboolean createWindow(_GLFWwindow* window,
// The WM_DELETE_WINDOW ICCCM protocol
// Basic window close notification protocol
if (_glfwLibrary.X11.wmDeleteWindow != None)
protocols[count++] = _glfwLibrary.X11.wmDeleteWindow;
if (_glfw.x11.wmDeleteWindow != None)
protocols[count++] = _glfw.x11.wmDeleteWindow;
// The _NET_WM_PING EWMH protocol
// Tells the WM to ping the GLFW window and flag the application as
// unresponsive if the WM doesn't get a reply within a few seconds
if (_glfwLibrary.X11.wmPing != None)
protocols[count++] = _glfwLibrary.X11.wmPing;
if (_glfw.x11.wmPing != None)
protocols[count++] = _glfw.x11.wmPing;
if (count > 0)
{
XSetWMProtocols(_glfwLibrary.X11.display, window->X11.handle,
XSetWMProtocols(_glfw.x11.display, window->x11.handle,
protocols, count);
}
}
@ -205,7 +205,7 @@ static GLboolean createWindow(_GLFWwindow* window,
hints->flags = StateHint;
hints->initial_state = NormalState;
XSetWMHints(_glfwLibrary.X11.display, window->X11.handle, hints);
XSetWMHints(_glfw.x11.display, window->x11.handle, hints);
XFree(hints);
}
@ -235,7 +235,7 @@ static GLboolean createWindow(_GLFWwindow* window,
hints->min_height = hints->max_height = window->height;
}
XSetWMNormalHints(_glfwLibrary.X11.display, window->X11.handle, hints);
XSetWMNormalHints(_glfw.x11.display, window->x11.handle, hints);
XFree(hints);
}
@ -254,18 +254,16 @@ static void hideCursor(_GLFWwindow* window)
// Un-grab cursor (in windowed mode only; in fullscreen mode we still
// want the cursor grabbed in order to confine the cursor to the window
// area)
if (window->X11.cursorGrabbed && window->monitor == NULL)
if (window->x11.cursorGrabbed && window->monitor == NULL)
{
XUngrabPointer(_glfwLibrary.X11.display, CurrentTime);
window->X11.cursorGrabbed = GL_FALSE;
XUngrabPointer(_glfw.x11.display, CurrentTime);
window->x11.cursorGrabbed = GL_FALSE;
}
if (!window->X11.cursorHidden)
if (!window->x11.cursorHidden)
{
XDefineCursor(_glfwLibrary.X11.display,
window->X11.handle,
_glfwLibrary.X11.cursor);
window->X11.cursorHidden = GL_TRUE;
XDefineCursor(_glfw.x11.display, window->x11.handle, _glfw.x11.cursor);
window->x11.cursorHidden = GL_TRUE;
}
}
@ -278,16 +276,16 @@ static void captureCursor(_GLFWwindow* window)
{
hideCursor(window);
if (!window->X11.cursorGrabbed)
if (!window->x11.cursorGrabbed)
{
if (XGrabPointer(_glfwLibrary.X11.display, window->X11.handle, True,
if (XGrabPointer(_glfw.x11.display, window->x11.handle, True,
ButtonPressMask | ButtonReleaseMask |
PointerMotionMask, GrabModeAsync, GrabModeAsync,
window->X11.handle, None, CurrentTime) ==
window->x11.handle, None, CurrentTime) ==
GrabSuccess)
{
window->X11.cursorGrabbed = GL_TRUE;
window->X11.cursorCentered = GL_FALSE;
window->x11.cursorGrabbed = GL_TRUE;
window->x11.cursorCentered = GL_FALSE;
}
}
}
@ -302,17 +300,17 @@ static void showCursor(_GLFWwindow* window)
// Un-grab cursor (in windowed mode only; in fullscreen mode we still
// want the cursor grabbed in order to confine the cursor to the window
// area)
if (window->X11.cursorGrabbed && window->monitor == NULL)
if (window->x11.cursorGrabbed && window->monitor == NULL)
{
XUngrabPointer(_glfwLibrary.X11.display, CurrentTime);
window->X11.cursorGrabbed = GL_FALSE;
XUngrabPointer(_glfw.x11.display, CurrentTime);
window->x11.cursorGrabbed = GL_FALSE;
}
// Show cursor
if (window->X11.cursorHidden)
if (window->x11.cursorHidden)
{
XUndefineCursor(_glfwLibrary.X11.display, window->X11.handle);
window->X11.cursorHidden = GL_FALSE;
XUndefineCursor(_glfw.x11.display, window->x11.handle);
window->x11.cursorHidden = GL_FALSE;
}
}
@ -323,29 +321,29 @@ static void showCursor(_GLFWwindow* window)
static void enterFullscreenMode(_GLFWwindow* window)
{
if (!_glfwLibrary.X11.saver.changed)
if (!_glfw.x11.saver.changed)
{
// Remember old screen saver settings
XGetScreenSaver(_glfwLibrary.X11.display,
&_glfwLibrary.X11.saver.timeout,
&_glfwLibrary.X11.saver.interval,
&_glfwLibrary.X11.saver.blanking,
&_glfwLibrary.X11.saver.exposure);
XGetScreenSaver(_glfw.x11.display,
&_glfw.x11.saver.timeout,
&_glfw.x11.saver.interval,
&_glfw.x11.saver.blanking,
&_glfw.x11.saver.exposure);
// Disable screen saver
XSetScreenSaver(_glfwLibrary.X11.display, 0, 0, DontPreferBlanking,
XSetScreenSaver(_glfw.x11.display, 0, 0, DontPreferBlanking,
DefaultExposures);
_glfwLibrary.X11.saver.changed = GL_TRUE;
_glfw.x11.saver.changed = GL_TRUE;
}
_glfwSetVideoMode(&window->width, &window->height);
if (_glfwLibrary.X11.hasEWMH &&
_glfwLibrary.X11.wmState != None &&
_glfwLibrary.X11.wmStateFullscreen != None)
if (_glfw.x11.hasEWMH &&
_glfw.x11.wmState != None &&
_glfw.x11.wmStateFullscreen != None)
{
if (_glfwLibrary.X11.wmActiveWindow != None)
if (_glfw.x11.wmActiveWindow != None)
{
// Ask the window manager to raise and focus the GLFW window
// Only focused windows with the _NET_WM_STATE_FULLSCREEN state end
@ -355,14 +353,14 @@ static void enterFullscreenMode(_GLFWwindow* window)
memset(&event, 0, sizeof(event));
event.type = ClientMessage;
event.xclient.window = window->X11.handle;
event.xclient.window = window->x11.handle;
event.xclient.format = 32; // Data is 32-bit longs
event.xclient.message_type = _glfwLibrary.X11.wmActiveWindow;
event.xclient.message_type = _glfw.x11.wmActiveWindow;
event.xclient.data.l[0] = 1; // Sender is a normal application
event.xclient.data.l[1] = 0; // We don't really know the timestamp
XSendEvent(_glfwLibrary.X11.display,
_glfwLibrary.X11.root,
XSendEvent(_glfw.x11.display,
_glfw.x11.root,
False,
SubstructureNotifyMask | SubstructureRedirectMask,
&event);
@ -376,38 +374,38 @@ static void enterFullscreenMode(_GLFWwindow* window)
memset(&event, 0, sizeof(event));
event.type = ClientMessage;
event.xclient.window = window->X11.handle;
event.xclient.window = window->x11.handle;
event.xclient.format = 32; // Data is 32-bit longs
event.xclient.message_type = _glfwLibrary.X11.wmState;
event.xclient.message_type = _glfw.x11.wmState;
event.xclient.data.l[0] = _NET_WM_STATE_ADD;
event.xclient.data.l[1] = _glfwLibrary.X11.wmStateFullscreen;
event.xclient.data.l[1] = _glfw.x11.wmStateFullscreen;
event.xclient.data.l[2] = 0; // No secondary property
event.xclient.data.l[3] = 1; // Sender is a normal application
XSendEvent(_glfwLibrary.X11.display,
_glfwLibrary.X11.root,
XSendEvent(_glfw.x11.display,
_glfw.x11.root,
False,
SubstructureNotifyMask | SubstructureRedirectMask,
&event);
}
else if (window->X11.overrideRedirect)
else if (window->x11.overrideRedirect)
{
// In override-redirect mode we have divorced ourselves from the
// window manager, so we need to do everything manually
XRaiseWindow(_glfwLibrary.X11.display, window->X11.handle);
XSetInputFocus(_glfwLibrary.X11.display, window->X11.handle,
XRaiseWindow(_glfw.x11.display, window->x11.handle);
XSetInputFocus(_glfw.x11.display, window->x11.handle,
RevertToParent, CurrentTime);
XMoveWindow(_glfwLibrary.X11.display, window->X11.handle, 0, 0);
XResizeWindow(_glfwLibrary.X11.display, window->X11.handle,
XMoveWindow(_glfw.x11.display, window->x11.handle, 0, 0);
XResizeWindow(_glfw.x11.display, window->x11.handle,
window->width, window->height);
}
// HACK: Try to get window inside viewport (for virtual displays) by moving
// the cursor to the upper left corner (and then to the center)
// This hack should be harmless on saner systems as well
XWarpPointer(_glfwLibrary.X11.display, None, window->X11.handle, 0,0,0,0, 0,0);
XWarpPointer(_glfwLibrary.X11.display, None, window->X11.handle, 0,0,0,0,
XWarpPointer(_glfw.x11.display, None, window->x11.handle, 0,0,0,0, 0,0);
XWarpPointer(_glfw.x11.display, None, window->x11.handle, 0,0,0,0,
window->width / 2, window->height / 2);
}
@ -420,21 +418,21 @@ static void leaveFullscreenMode(_GLFWwindow* window)
{
_glfwRestoreVideoMode();
if (_glfwLibrary.X11.saver.changed)
if (_glfw.x11.saver.changed)
{
// Restore old screen saver settings
XSetScreenSaver(_glfwLibrary.X11.display,
_glfwLibrary.X11.saver.timeout,
_glfwLibrary.X11.saver.interval,
_glfwLibrary.X11.saver.blanking,
_glfwLibrary.X11.saver.exposure);
XSetScreenSaver(_glfw.x11.display,
_glfw.x11.saver.timeout,
_glfw.x11.saver.interval,
_glfw.x11.saver.blanking,
_glfw.x11.saver.exposure);
_glfwLibrary.X11.saver.changed = GL_FALSE;
_glfw.x11.saver.changed = GL_FALSE;
}
if (_glfwLibrary.X11.hasEWMH &&
_glfwLibrary.X11.wmState != None &&
_glfwLibrary.X11.wmStateFullscreen != None)
if (_glfw.x11.hasEWMH &&
_glfw.x11.wmState != None &&
_glfw.x11.wmStateFullscreen != None)
{
// Ask the window manager to make the GLFW window a normal window
// Normal windows usually have frames and other decorations
@ -443,16 +441,16 @@ static void leaveFullscreenMode(_GLFWwindow* window)
memset(&event, 0, sizeof(event));
event.type = ClientMessage;
event.xclient.window = window->X11.handle;
event.xclient.window = window->x11.handle;
event.xclient.format = 32; // Data is 32-bit longs
event.xclient.message_type = _glfwLibrary.X11.wmState;
event.xclient.message_type = _glfw.x11.wmState;
event.xclient.data.l[0] = _NET_WM_STATE_REMOVE;
event.xclient.data.l[1] = _glfwLibrary.X11.wmStateFullscreen;
event.xclient.data.l[1] = _glfw.x11.wmStateFullscreen;
event.xclient.data.l[2] = 0; // No secondary property
event.xclient.data.l[3] = 1; // Sender is a normal application
XSendEvent(_glfwLibrary.X11.display,
_glfwLibrary.X11.root,
XSendEvent(_glfw.x11.display,
_glfw.x11.root,
False,
SubstructureNotifyMask | SubstructureRedirectMask,
&event);
@ -468,9 +466,9 @@ static _GLFWwindow* findWindow(Window handle)
{
_GLFWwindow* window;
for (window = _glfwLibrary.windowListHead; window; window = window->next)
for (window = _glfw.windowListHead; window; window = window->next)
{
if (window->X11.handle == handle)
if (window->x11.handle == handle)
return window;
}
@ -511,10 +509,10 @@ static void processEvent(XEvent *event)
// will get KeyRelease/KeyPress pairs with similar or identical
// time stamps. User selected key repeat filtering is handled in
// _glfwInputKey/_glfwInputChar.
if (XEventsQueued(_glfwLibrary.X11.display, QueuedAfterReading))
if (XEventsQueued(_glfw.x11.display, QueuedAfterReading))
{
XEvent nextEvent;
XPeekEvent(_glfwLibrary.X11.display, &nextEvent);
XPeekEvent(_glfw.x11.display, &nextEvent);
if (nextEvent.type == KeyPress &&
nextEvent.xkey.window == event->xkey.window &&
@ -629,8 +627,8 @@ static void processEvent(XEvent *event)
if (window == NULL)
return;
if (event->xmotion.x != window->X11.cursorPosX ||
event->xmotion.y != window->X11.cursorPosY)
if (event->xmotion.x != window->x11.cursorPosX ||
event->xmotion.y != window->x11.cursorPosY)
{
// The cursor was moved by something other than GLFW
@ -638,11 +636,11 @@ static void processEvent(XEvent *event)
if (window->cursorMode == GLFW_CURSOR_CAPTURED)
{
if (_glfwLibrary.focusedWindow != window)
if (_glfw.focusedWindow != window)
break;
x = event->xmotion.x - window->X11.cursorPosX;
y = event->xmotion.y - window->X11.cursorPosY;
x = event->xmotion.x - window->x11.cursorPosX;
y = event->xmotion.y - window->x11.cursorPosY;
}
else
{
@ -650,9 +648,9 @@ static void processEvent(XEvent *event)
y = event->xmotion.y;
}
window->X11.cursorPosX = event->xmotion.x;
window->X11.cursorPosY = event->xmotion.y;
window->X11.cursorCentered = GL_FALSE;
window->x11.cursorPosX = event->xmotion.x;
window->x11.cursorPosY = event->xmotion.y;
window->x11.cursorCentered = GL_FALSE;
_glfwInputCursorMotion(window, x, y);
}
@ -685,21 +683,21 @@ static void processEvent(XEvent *event)
if (window == NULL)
return;
if ((Atom) event->xclient.data.l[0] == _glfwLibrary.X11.wmDeleteWindow)
if ((Atom) event->xclient.data.l[0] == _glfw.x11.wmDeleteWindow)
{
// The window manager was asked to close the window, for example by
// the user pressing a 'close' window decoration button
_glfwInputWindowCloseRequest(window);
}
else if (_glfwLibrary.X11.wmPing != None &&
(Atom) event->xclient.data.l[0] == _glfwLibrary.X11.wmPing)
else if (_glfw.x11.wmPing != None &&
(Atom) event->xclient.data.l[0] == _glfw.x11.wmPing)
{
// The window manager is pinging the application to ensure it's
// still responding to events
event->xclient.window = _glfwLibrary.X11.root;
XSendEvent(_glfwLibrary.X11.display,
event->xclient.window = _glfw.x11.root;
XSendEvent(_glfw.x11.display,
event->xclient.window,
False,
SubstructureNotifyMask | SubstructureRedirectMask,
@ -778,8 +776,8 @@ static void processEvent(XEvent *event)
{
// The ownership of the selection was lost
free(_glfwLibrary.X11.selection.string);
_glfwLibrary.X11.selection.string = NULL;
free(_glfw.x11.selection.string);
_glfw.x11.selection.string = NULL;
break;
}
@ -790,9 +788,9 @@ static void processEvent(XEvent *event)
XSelectionEvent* request = &event->xselection;
if (_glfwReadSelection(request))
_glfwLibrary.X11.selection.status = _GLFW_CONVERSION_SUCCEEDED;
_glfw.x11.selection.status = _GLFW_CONVERSION_SUCCEEDED;
else
_glfwLibrary.X11.selection.status = _GLFW_CONVERSION_FAILED;
_glfw.x11.selection.status = _GLFW_CONVERSION_FAILED;
break;
}
@ -814,7 +812,7 @@ static void processEvent(XEvent *event)
response.xselection.target = request->target;
response.xselection.time = request->time;
XSendEvent(_glfwLibrary.X11.display,
XSendEvent(_glfw.x11.display,
request->requestor,
False, 0, &response);
break;
@ -826,7 +824,7 @@ static void processEvent(XEvent *event)
default:
{
#if defined(_GLFW_HAS_XRANDR)
switch (event->type - _glfwLibrary.X11.RandR.eventBase)
switch (event->type - _glfw.x11.randr.eventBase)
{
case RRScreenChangeNotify:
{
@ -862,10 +860,10 @@ int _glfwPlatformCreateWindow(_GLFWwindow* window,
#if defined(_GLFW_HAS_XRANDR)
// Request screen change notifications
if (_glfwLibrary.X11.RandR.available)
if (_glfw.x11.randr.available)
{
XRRSelectInput(_glfwLibrary.X11.display,
window->X11.handle,
XRRSelectInput(_glfw.x11.display,
window->x11.handle,
RRScreenChangeNotifyMask);
}
#endif /*_GLFW_HAS_XRANDR*/
@ -882,8 +880,8 @@ int _glfwPlatformCreateWindow(_GLFWwindow* window,
int windowX, windowY, rootX, rootY;
unsigned int mask;
XQueryPointer(_glfwLibrary.X11.display,
window->X11.handle,
XQueryPointer(_glfw.x11.display,
window->x11.handle,
&cursorRoot,
&cursorWindow,
&rootX, &rootY,
@ -911,17 +909,17 @@ void _glfwPlatformDestroyWindow(_GLFWwindow* window)
_glfwDestroyContext(window);
if (window->X11.handle)
if (window->x11.handle)
{
XUnmapWindow(_glfwLibrary.X11.display, window->X11.handle);
XDestroyWindow(_glfwLibrary.X11.display, window->X11.handle);
window->X11.handle = (Window) 0;
XUnmapWindow(_glfw.x11.display, window->x11.handle);
XDestroyWindow(_glfw.x11.display, window->x11.handle);
window->x11.handle = (Window) 0;
}
if (window->X11.colormap)
if (window->x11.colormap)
{
XFreeColormap(_glfwLibrary.X11.display, window->X11.colormap);
window->X11.colormap = (Colormap) 0;
XFreeColormap(_glfw.x11.display, window->x11.colormap);
window->x11.colormap = (Colormap) 0;
}
}
@ -932,36 +930,36 @@ void _glfwPlatformDestroyWindow(_GLFWwindow* window)
void _glfwPlatformSetWindowTitle(_GLFWwindow* window, const char* title)
{
Atom type = XInternAtom(_glfwLibrary.X11.display, "UTF8_STRING", False);
Atom type = XInternAtom(_glfw.x11.display, "UTF8_STRING", False);
#if defined(X_HAVE_UTF8_STRING)
Xutf8SetWMProperties(_glfwLibrary.X11.display,
window->X11.handle,
Xutf8SetWMProperties(_glfw.x11.display,
window->x11.handle,
title, title,
NULL, 0,
NULL, NULL, NULL);
#else
// This may be a slightly better fallback than using XStoreName and
// XSetIconName, which always store their arguments using STRING
XmbSetWMProperties(_glfwLibrary.X11.display,
window->X11.handle,
XmbSetWMProperties(_glfw.x11.display,
window->x11.handle,
title, title,
NULL, 0,
NULL, NULL, NULL);
#endif
if (_glfwLibrary.X11.wmName != None)
if (_glfw.x11.wmName != None)
{
XChangeProperty(_glfwLibrary.X11.display, window->X11.handle,
_glfwLibrary.X11.wmName, type, 8,
XChangeProperty(_glfw.x11.display, window->x11.handle,
_glfw.x11.wmName, type, 8,
PropModeReplace,
(unsigned char*) title, strlen(title));
}
if (_glfwLibrary.X11.wmIconName != None)
if (_glfw.x11.wmIconName != None)
{
XChangeProperty(_glfwLibrary.X11.display, window->X11.handle,
_glfwLibrary.X11.wmIconName, type, 8,
XChangeProperty(_glfw.x11.display, window->x11.handle,
_glfw.x11.wmIconName, type, 8,
PropModeReplace,
(unsigned char*) title, strlen(title));
}
@ -992,7 +990,7 @@ void _glfwPlatformSetWindowSize(_GLFWwindow* window, int width, int height)
hints->min_width = hints->max_width = width;
hints->min_height = hints->max_height = height;
XSetWMNormalHints(_glfwLibrary.X11.display, window->X11.handle, hints);
XSetWMNormalHints(_glfw.x11.display, window->x11.handle, hints);
XFree(hints);
}
@ -1001,9 +999,7 @@ void _glfwPlatformSetWindowSize(_GLFWwindow* window, int width, int height)
// Change window size before changing fullscreen mode?
if (width > window->width)
{
XResizeWindow(_glfwLibrary.X11.display,
window->X11.handle,
width, height);
XResizeWindow(_glfw.x11.display, window->x11.handle, width, height);
sizeChanged = GL_TRUE;
}
@ -1012,7 +1008,7 @@ void _glfwPlatformSetWindowSize(_GLFWwindow* window, int width, int height)
// Set window size (if not already changed)
if (!sizeChanged)
XResizeWindow(_glfwLibrary.X11.display, window->X11.handle, width, height);
XResizeWindow(_glfw.x11.display, window->x11.handle, width, height);
}
@ -1022,16 +1018,14 @@ void _glfwPlatformSetWindowSize(_GLFWwindow* window, int width, int height)
void _glfwPlatformIconifyWindow(_GLFWwindow* window)
{
if (window->X11.overrideRedirect)
if (window->x11.overrideRedirect)
{
// Override-redirect windows cannot be iconified or restored, as those
// tasks are performed by the window manager
return;
}
XIconifyWindow(_glfwLibrary.X11.display,
window->X11.handle,
_glfwLibrary.X11.screen);
XIconifyWindow(_glfw.x11.display, window->x11.handle, _glfw.x11.screen);
}
@ -1041,14 +1035,14 @@ void _glfwPlatformIconifyWindow(_GLFWwindow* window)
void _glfwPlatformRestoreWindow(_GLFWwindow* window)
{
if (window->X11.overrideRedirect)
if (window->x11.overrideRedirect)
{
// Override-redirect windows cannot be iconified or restored, as those
// tasks are performed by the window manager
return;
}
XMapWindow(_glfwLibrary.X11.display, window->X11.handle);
XMapWindow(_glfw.x11.display, window->x11.handle);
}
@ -1058,16 +1052,16 @@ void _glfwPlatformRestoreWindow(_GLFWwindow* window)
void _glfwPlatformShowWindow(_GLFWwindow* window)
{
XMapRaised(_glfwLibrary.X11.display, window->X11.handle);
XFlush(_glfwLibrary.X11.display);
XMapRaised(_glfw.x11.display, window->x11.handle);
XFlush(_glfw.x11.display);
// Set the window position the first time the window is shown
// Note: XMoveWindow has no effect before the window has been mapped.
if (!window->X11.windowPosSet)
if (!window->x11.windowPosSet)
{
XMoveWindow(_glfwLibrary.X11.display, window->X11.handle,
window->X11.positionX, window->X11.positionY);
window->X11.windowPosSet = GL_TRUE;
XMoveWindow(_glfw.x11.display, window->x11.handle,
window->x11.positionX, window->x11.positionY);
window->x11.windowPosSet = GL_TRUE;
}
}
@ -1078,8 +1072,8 @@ void _glfwPlatformShowWindow(_GLFWwindow* window)
void _glfwPlatformHideWindow(_GLFWwindow* window)
{
XUnmapWindow(_glfwLibrary.X11.display, window->X11.handle);
XFlush(_glfwLibrary.X11.display);
XUnmapWindow(_glfw.x11.display, window->x11.handle);
XFlush(_glfw.x11.display);
}
@ -1091,8 +1085,8 @@ void _glfwPlatformPollEvents(void)
{
XEvent event;
while (XCheckMaskEvent(_glfwLibrary.X11.display, ~0, &event) ||
XCheckTypedEvent(_glfwLibrary.X11.display, ClientMessage, &event))
while (XCheckMaskEvent(_glfw.x11.display, ~0, &event) ||
XCheckTypedEvent(_glfw.x11.display, ClientMessage, &event))
{
processEvent(&event);
}
@ -1101,21 +1095,21 @@ void _glfwPlatformPollEvents(void)
// captured the cursor (because then it needs to be re-centered)
_GLFWwindow* window;
window = _glfwLibrary.focusedWindow;
window = _glfw.focusedWindow;
if (window)
{
if (window->cursorMode == GLFW_CURSOR_CAPTURED &&
!window->X11.cursorCentered)
!window->x11.cursorCentered)
{
_glfwPlatformSetCursorPos(window,
window->width / 2,
window->height / 2);
window->X11.cursorCentered = GL_TRUE;
window->x11.cursorCentered = GL_TRUE;
// NOTE: This is a temporary fix. It works as long as you use
// offsets accumulated over the course of a frame, instead of
// performing the necessary actions per callback call.
XFlush( _glfwLibrary.X11.display );
XFlush(_glfw.x11.display);
}
}
}
@ -1130,12 +1124,12 @@ void _glfwPlatformWaitEvents(void)
int fd;
fd_set fds;
fd = ConnectionNumber(_glfwLibrary.X11.display);
fd = ConnectionNumber(_glfw.x11.display);
FD_ZERO(&fds);
FD_SET(fd, &fds);
XFlush(_glfwLibrary.X11.display);
XFlush(_glfw.x11.display);
if (select(fd + 1, &fds, NULL, NULL, NULL) > 0)
_glfwPlatformPollEvents();
@ -1149,10 +1143,10 @@ void _glfwPlatformWaitEvents(void)
void _glfwPlatformSetCursorPos(_GLFWwindow* window, int x, int y)
{
// Store the new position so it can be recognized later
window->X11.cursorPosX = x;
window->X11.cursorPosY = y;
window->x11.cursorPosX = x;
window->x11.cursorPosY = y;
XWarpPointer(_glfwLibrary.X11.display, None, window->X11.handle, 0,0,0,0, x, y);
XWarpPointer(_glfw.x11.display, None, window->x11.handle, 0,0,0,0, x, y);
}