mirror of
https://github.com/glfw/glfw.git
synced 2026-09-19 23:43:15 +00:00
Merge branch 'master' into multi-monitor
Conflicts: tests/modes.c
This commit is contained in:
+1
-2
@@ -1,4 +1,3 @@
|
||||
|
||||
include_directories(${GLFW_SOURCE_DIR}/src
|
||||
${GLFW_BINARY_DIR}/src
|
||||
${glfw_INCLUDE_DIRS})
|
||||
@@ -59,5 +58,5 @@ if (BUILD_SHARED_LIBS)
|
||||
target_link_libraries(glfw LINK_INTERFACE_LIBRARIES)
|
||||
endif()
|
||||
|
||||
install(TARGETS glfw DESTINATION lib)
|
||||
install(TARGETS glfw DESTINATION lib${LIB_SUFFIX} )
|
||||
|
||||
|
||||
+1
-3
@@ -51,10 +51,8 @@ void _glfwPlatformMakeContextCurrent(_GLFWwindow* window)
|
||||
// Swap buffers
|
||||
//========================================================================
|
||||
|
||||
void _glfwPlatformSwapBuffers(void)
|
||||
void _glfwPlatformSwapBuffers(_GLFWwindow* window)
|
||||
{
|
||||
_GLFWwindow* window = _glfwLibrary.currentWindow;
|
||||
|
||||
// ARP appears to be unnecessary, but this is future-proof
|
||||
[window->NSGL.context flushBuffer];
|
||||
}
|
||||
|
||||
+7
-14
@@ -59,8 +59,7 @@
|
||||
|
||||
- (BOOL)windowShouldClose:(id)sender
|
||||
{
|
||||
window->closeRequested = GL_TRUE;
|
||||
|
||||
_glfwInputWindowCloseRequest(window);
|
||||
return NO;
|
||||
}
|
||||
|
||||
@@ -127,7 +126,7 @@
|
||||
_GLFWwindow* window;
|
||||
|
||||
for (window = _glfwLibrary.windowListHead; window; window = window->next)
|
||||
window->closeRequested = GL_TRUE;
|
||||
_glfwInputWindowCloseRequest(window);
|
||||
|
||||
return NSTerminateCancel;
|
||||
}
|
||||
@@ -860,15 +859,13 @@ static GLboolean createContext(_GLFWwindow* window,
|
||||
// created
|
||||
//========================================================================
|
||||
|
||||
int _glfwPlatformOpenWindow(_GLFWwindow* window,
|
||||
const _GLFWwndconfig* wndconfig,
|
||||
const _GLFWfbconfig* fbconfig)
|
||||
int _glfwPlatformCreateWindow(_GLFWwindow* window,
|
||||
const _GLFWwndconfig* wndconfig,
|
||||
const _GLFWfbconfig* fbconfig)
|
||||
{
|
||||
if (!initializeAppKit())
|
||||
return GL_FALSE;
|
||||
|
||||
window->resizable = wndconfig->resizable;
|
||||
|
||||
// We can only have one application delegate, but we only allocate it the
|
||||
// first time we create a window to keep all window code in this file
|
||||
if (_glfwLibrary.NS.delegate == nil)
|
||||
@@ -928,14 +925,10 @@ int _glfwPlatformOpenWindow(_GLFWwindow* window,
|
||||
withOptions:nil];
|
||||
}
|
||||
|
||||
glfwMakeContextCurrent(window);
|
||||
|
||||
NSPoint point = [[NSCursor currentCursor] hotSpot];
|
||||
window->cursorPosX = point.x;
|
||||
window->cursorPosY = point.y;
|
||||
|
||||
window->resizable = wndconfig->resizable;
|
||||
|
||||
return GL_TRUE;
|
||||
}
|
||||
|
||||
@@ -944,7 +937,7 @@ int _glfwPlatformOpenWindow(_GLFWwindow* window,
|
||||
// Properly kill the window / video display
|
||||
//========================================================================
|
||||
|
||||
void _glfwPlatformCloseWindow(_GLFWwindow* window)
|
||||
void _glfwPlatformDestroyWindow(_GLFWwindow* window)
|
||||
{
|
||||
[window->NS.object orderOut:nil];
|
||||
|
||||
@@ -1041,7 +1034,7 @@ void _glfwPlatformRestoreWindow(_GLFWwindow* window)
|
||||
// Write back window parameters into GLFW window structure
|
||||
//========================================================================
|
||||
|
||||
void _glfwPlatformRefreshWindowParams(void)
|
||||
void _glfwPlatformRefreshWindowParams(_GLFWwindow* window)
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
@@ -59,8 +59,6 @@ void _glfwSetError(int error, const char* format, ...)
|
||||
char buffer[16384];
|
||||
const char* description;
|
||||
|
||||
// We would use vasprintf here if msvcrt supported it
|
||||
|
||||
if (format)
|
||||
{
|
||||
int count;
|
||||
|
||||
@@ -31,6 +31,7 @@
|
||||
#include "internal.h"
|
||||
|
||||
#include <stdlib.h>
|
||||
#include <malloc.h>
|
||||
|
||||
|
||||
//========================================================================
|
||||
|
||||
+1
-1
@@ -79,7 +79,7 @@ GLFWAPI void glfwTerminate(void)
|
||||
|
||||
// Close all remaining windows
|
||||
while (_glfwLibrary.windowListHead)
|
||||
glfwCloseWindow(_glfwLibrary.windowListHead);
|
||||
glfwDestroyWindow(_glfwLibrary.windowListHead);
|
||||
|
||||
if (!_glfwPlatformTerminate())
|
||||
return;
|
||||
|
||||
-10
@@ -551,16 +551,6 @@ GLFWAPI void glfwSetCursorPosCallback(GLFWcursorposfun cbfun)
|
||||
}
|
||||
|
||||
_glfwLibrary.cursorPosCallback = cbfun;
|
||||
|
||||
// Call the callback function to let the application know the current
|
||||
// cursor position
|
||||
if (cbfun)
|
||||
{
|
||||
_GLFWwindow* window;
|
||||
|
||||
for (window = _glfwLibrary.windowListHead; window; window = window->next)
|
||||
cbfun(window, window->cursorPosX, window->cursorPosY);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
+7
-21
@@ -89,10 +89,10 @@ typedef struct _GLFWmonitor _GLFWmonitor;
|
||||
|
||||
|
||||
//------------------------------------------------------------------------
|
||||
// Window hints, set by glfwOpenWindowHint and consumed by glfwOpenWindow
|
||||
// Window hints, set by glfwWindowHint and consumed by glfwCreateWindow
|
||||
// A bucket of semi-random stuff lumped together for historical reasons
|
||||
// This is used only by the platform independent code and only to store
|
||||
// parameters passed to us by glfwOpenWindowHint
|
||||
// parameters passed to us by glfwWindowHint
|
||||
//------------------------------------------------------------------------
|
||||
struct _GLFWhints
|
||||
{
|
||||
@@ -196,21 +196,6 @@ struct _GLFWwindow
|
||||
char mouseButton[GLFW_MOUSE_BUTTON_LAST + 1];
|
||||
char key[GLFW_KEY_LAST + 1];
|
||||
|
||||
// Framebuffer attributes
|
||||
GLint redBits;
|
||||
GLint greenBits;
|
||||
GLint blueBits;
|
||||
GLint alphaBits;
|
||||
GLint depthBits;
|
||||
GLint stencilBits;
|
||||
GLint accumRedBits;
|
||||
GLint accumGreenBits;
|
||||
GLint accumBlueBits;
|
||||
GLint accumAlphaBits;
|
||||
GLint auxBuffers;
|
||||
GLboolean stereo;
|
||||
GLint samples;
|
||||
|
||||
// OpenGL extensions and context attributes
|
||||
int glMajor, glMinor, glRevision;
|
||||
GLboolean glForward, glDebug;
|
||||
@@ -335,8 +320,8 @@ double _glfwPlatformGetTime(void);
|
||||
void _glfwPlatformSetTime(double time);
|
||||
|
||||
// Window management
|
||||
int _glfwPlatformOpenWindow(_GLFWwindow* window, const _GLFWwndconfig* wndconfig, const _GLFWfbconfig* fbconfig);
|
||||
void _glfwPlatformCloseWindow(_GLFWwindow* window);
|
||||
int _glfwPlatformCreateWindow(_GLFWwindow* window, const _GLFWwndconfig* wndconfig, const _GLFWfbconfig* fbconfig);
|
||||
void _glfwPlatformDestroyWindow(_GLFWwindow* window);
|
||||
void _glfwPlatformSetWindowTitle(_GLFWwindow* window, const char* title);
|
||||
void _glfwPlatformSetWindowSize(_GLFWwindow* window, int width, int height);
|
||||
void _glfwPlatformSetWindowPos(_GLFWwindow* window, int x, int y);
|
||||
@@ -349,9 +334,9 @@ void _glfwPlatformWaitEvents(void);
|
||||
|
||||
// OpenGL context management
|
||||
void _glfwPlatformMakeContextCurrent(_GLFWwindow* window);
|
||||
void _glfwPlatformSwapBuffers(void);
|
||||
void _glfwPlatformSwapBuffers(_GLFWwindow* window);
|
||||
void _glfwPlatformSwapInterval(int interval);
|
||||
void _glfwPlatformRefreshWindowParams(void);
|
||||
void _glfwPlatformRefreshWindowParams(_GLFWwindow* window);
|
||||
int _glfwPlatformExtensionSupported(const char* extension);
|
||||
GLFWglproc _glfwPlatformGetProcAddress(const char* procname);
|
||||
void _glfwPlatformCopyContext(_GLFWwindow* src, _GLFWwindow* dst, unsigned long mask);
|
||||
@@ -377,6 +362,7 @@ void _glfwInputWindowPos(_GLFWwindow* window, int x, int y);
|
||||
void _glfwInputWindowSize(_GLFWwindow* window, int width, int height);
|
||||
void _glfwInputWindowIconify(_GLFWwindow* window, int iconified);
|
||||
void _glfwInputWindowDamage(_GLFWwindow* window);
|
||||
void _glfwInputWindowCloseRequest(_GLFWwindow* window);
|
||||
|
||||
// Input event notification (input.c)
|
||||
void _glfwInputKey(_GLFWwindow* window, int key, int action);
|
||||
|
||||
+18
-43
@@ -244,7 +244,7 @@ const _GLFWfbconfig* _glfwChooseFBConfig(const _GLFWfbconfig* desired,
|
||||
|
||||
//========================================================================
|
||||
// Checks whether the OpenGL part of the window config is sane
|
||||
// It blames glfwOpenWindow because that's the only caller
|
||||
// It blames glfwCreateWindow because that's the only caller
|
||||
//========================================================================
|
||||
|
||||
GLboolean _glfwIsValidContextConfig(_GLFWwndconfig* wndconfig)
|
||||
@@ -253,28 +253,28 @@ GLboolean _glfwIsValidContextConfig(_GLFWwndconfig* wndconfig)
|
||||
{
|
||||
// OpenGL 1.0 is the smallest valid version
|
||||
_glfwSetError(GLFW_INVALID_VALUE,
|
||||
"glfwOpenWindow: Invalid OpenGL version requested");
|
||||
"glfwCreateWindow: Invalid OpenGL version requested");
|
||||
return GL_FALSE;
|
||||
}
|
||||
if (wndconfig->glMajor == 1 && wndconfig->glMinor > 5)
|
||||
{
|
||||
// OpenGL 1.x series ended with version 1.5
|
||||
_glfwSetError(GLFW_INVALID_VALUE,
|
||||
"glfwOpenWindow: Invalid OpenGL version requested");
|
||||
"glfwCreateWindow: Invalid OpenGL version requested");
|
||||
return GL_FALSE;
|
||||
}
|
||||
else if (wndconfig->glMajor == 2 && wndconfig->glMinor > 1)
|
||||
{
|
||||
// OpenGL 2.x series ended with version 2.1
|
||||
_glfwSetError(GLFW_INVALID_VALUE,
|
||||
"glfwOpenWindow: Invalid OpenGL version requested");
|
||||
"glfwCreateWindow: Invalid OpenGL version requested");
|
||||
return GL_FALSE;
|
||||
}
|
||||
else if (wndconfig->glMajor == 3 && wndconfig->glMinor > 3)
|
||||
{
|
||||
// OpenGL 3.x series ended with version 3.3
|
||||
_glfwSetError(GLFW_INVALID_VALUE,
|
||||
"glfwOpenWindow: Invalid OpenGL version requested");
|
||||
"glfwCreateWindow: Invalid OpenGL version requested");
|
||||
return GL_FALSE;
|
||||
}
|
||||
else
|
||||
@@ -292,7 +292,7 @@ GLboolean _glfwIsValidContextConfig(_GLFWwndconfig* wndconfig)
|
||||
// everything 2.x and let the driver report invalid 2.x versions
|
||||
|
||||
_glfwSetError(GLFW_INVALID_VALUE,
|
||||
"glfwOpenWindow: Invalid OpenGL ES 2.x version requested");
|
||||
"glfwCreateWindow: Invalid OpenGL ES 2.x version requested");
|
||||
return GL_FALSE;
|
||||
}
|
||||
}
|
||||
@@ -302,7 +302,7 @@ GLboolean _glfwIsValidContextConfig(_GLFWwndconfig* wndconfig)
|
||||
wndconfig->glProfile != GLFW_OPENGL_COMPAT_PROFILE)
|
||||
{
|
||||
_glfwSetError(GLFW_INVALID_ENUM,
|
||||
"glfwOpenWindow: Invalid OpenGL profile requested");
|
||||
"glfwCreateWindow: Invalid OpenGL profile requested");
|
||||
return GL_FALSE;
|
||||
}
|
||||
|
||||
@@ -313,7 +313,7 @@ GLboolean _glfwIsValidContextConfig(_GLFWwndconfig* wndconfig)
|
||||
// and above
|
||||
|
||||
_glfwSetError(GLFW_INVALID_VALUE,
|
||||
"glfwOpenWindow: Context profiles only exist for "
|
||||
"glfwCreateWindow: Context profiles only exist for "
|
||||
"OpenGL version 3.2 and above");
|
||||
return GL_FALSE;
|
||||
}
|
||||
@@ -323,7 +323,7 @@ GLboolean _glfwIsValidContextConfig(_GLFWwndconfig* wndconfig)
|
||||
{
|
||||
// Forward-compatible contexts are only defined for OpenGL version 3.0 and above
|
||||
_glfwSetError(GLFW_INVALID_VALUE,
|
||||
"glfwOpenWindow: Forward compatibility only exist for "
|
||||
"glfwCreateWindow: Forward compatibility only exist for "
|
||||
"OpenGL version 3.0 and above");
|
||||
return GL_FALSE;
|
||||
}
|
||||
@@ -334,7 +334,7 @@ GLboolean _glfwIsValidContextConfig(_GLFWwndconfig* wndconfig)
|
||||
wndconfig->glRobustness != GLFW_OPENGL_LOSE_CONTEXT_ON_RESET)
|
||||
{
|
||||
_glfwSetError(GLFW_INVALID_VALUE,
|
||||
"glfwOpenWindow: Invalid OpenGL robustness mode requested");
|
||||
"glfwCreateWindow: Invalid OpenGL robustness mode requested");
|
||||
return GL_FALSE;
|
||||
}
|
||||
}
|
||||
@@ -345,7 +345,7 @@ GLboolean _glfwIsValidContextConfig(_GLFWwndconfig* wndconfig)
|
||||
|
||||
//========================================================================
|
||||
// Reads back context properties
|
||||
// It blames glfwOpenWindow because that's the only caller
|
||||
// It blames glfwCreateWindow because that's the only caller
|
||||
//========================================================================
|
||||
|
||||
GLboolean _glfwRefreshContextParams(void)
|
||||
@@ -369,7 +369,7 @@ GLboolean _glfwRefreshContextParams(void)
|
||||
if (!window->GetStringi)
|
||||
{
|
||||
_glfwSetError(GLFW_PLATFORM_ERROR,
|
||||
"glfwOpenWindow: Entry point retrieval is broken");
|
||||
"glfwCreateWindow: Entry point retrieval is broken");
|
||||
return GL_FALSE;
|
||||
}
|
||||
}
|
||||
@@ -406,34 +406,13 @@ GLboolean _glfwRefreshContextParams(void)
|
||||
}
|
||||
}
|
||||
|
||||
glGetIntegerv(GL_RED_BITS, &window->redBits);
|
||||
glGetIntegerv(GL_GREEN_BITS, &window->greenBits);
|
||||
glGetIntegerv(GL_BLUE_BITS, &window->blueBits);
|
||||
|
||||
glGetIntegerv(GL_ALPHA_BITS, &window->alphaBits);
|
||||
glGetIntegerv(GL_DEPTH_BITS, &window->depthBits);
|
||||
glGetIntegerv(GL_STENCIL_BITS, &window->stencilBits);
|
||||
|
||||
glGetIntegerv(GL_ACCUM_RED_BITS, &window->accumRedBits);
|
||||
glGetIntegerv(GL_ACCUM_GREEN_BITS, &window->accumGreenBits);
|
||||
glGetIntegerv(GL_ACCUM_BLUE_BITS, &window->accumBlueBits);
|
||||
glGetIntegerv(GL_ACCUM_ALPHA_BITS, &window->accumAlphaBits);
|
||||
|
||||
glGetIntegerv(GL_AUX_BUFFERS, &window->auxBuffers);
|
||||
glGetBooleanv(GL_STEREO, &window->stereo);
|
||||
|
||||
if (glfwExtensionSupported("GL_ARB_multisample"))
|
||||
glGetIntegerv(GL_SAMPLES_ARB, &window->samples);
|
||||
else
|
||||
window->samples = 0;
|
||||
|
||||
return GL_TRUE;
|
||||
}
|
||||
|
||||
|
||||
//========================================================================
|
||||
// Checks whether the current context fulfils the specified requirements
|
||||
// It blames glfwOpenWindow because that's the only caller
|
||||
// It blames glfwCreateWindow because that's the only caller
|
||||
//========================================================================
|
||||
|
||||
GLboolean _glfwIsValidContext(_GLFWwndconfig* wndconfig)
|
||||
@@ -452,7 +431,7 @@ GLboolean _glfwIsValidContext(_GLFWwndconfig* wndconfig)
|
||||
// {GLX|WGL}_ARB_create_context extension and fail here
|
||||
|
||||
_glfwSetError(GLFW_VERSION_UNAVAILABLE,
|
||||
"glfwOpenWindow: The requested OpenGL version is not available");
|
||||
"glfwCreateWindow: The requested OpenGL version is not available");
|
||||
return GL_FALSE;
|
||||
}
|
||||
|
||||
@@ -541,21 +520,17 @@ GLFWAPI GLFWwindow glfwGetCurrentContext(void)
|
||||
// Swap buffers (double-buffering)
|
||||
//========================================================================
|
||||
|
||||
GLFWAPI void glfwSwapBuffers(void)
|
||||
GLFWAPI void glfwSwapBuffers(GLFWwindow handle)
|
||||
{
|
||||
_GLFWwindow* window = (_GLFWwindow*) handle;
|
||||
|
||||
if (!_glfwInitialized)
|
||||
{
|
||||
_glfwSetError(GLFW_NOT_INITIALIZED, NULL);
|
||||
return;
|
||||
}
|
||||
|
||||
if (!_glfwLibrary.currentWindow)
|
||||
{
|
||||
_glfwSetError(GLFW_NO_CURRENT_CONTEXT, NULL);
|
||||
return;
|
||||
}
|
||||
|
||||
_glfwPlatformSwapBuffers();
|
||||
_glfwPlatformSwapBuffers(window);
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -32,6 +32,7 @@
|
||||
#include <limits.h>
|
||||
#include <string.h>
|
||||
#include <stdlib.h>
|
||||
#include <malloc.h>
|
||||
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
|
||||
@@ -32,6 +32,7 @@
|
||||
|
||||
#include <stdlib.h>
|
||||
#include <limits.h>
|
||||
#include <malloc.h>
|
||||
|
||||
|
||||
//========================================================================
|
||||
|
||||
@@ -31,6 +31,7 @@
|
||||
#include "internal.h"
|
||||
|
||||
#include <stdlib.h>
|
||||
#include <malloc.h>
|
||||
|
||||
#ifdef __BORLANDC__
|
||||
// With the Borland C++ compiler, we want to disable FPU exceptions
|
||||
|
||||
+5
-4
@@ -30,6 +30,9 @@
|
||||
|
||||
#include "internal.h"
|
||||
|
||||
#include <stdlib.h>
|
||||
#include <malloc.h>
|
||||
|
||||
|
||||
//========================================================================
|
||||
// Initialize WGL-specific extensions
|
||||
@@ -505,7 +508,7 @@ int _glfwCreateContext(_GLFWwindow* window,
|
||||
|
||||
void _glfwDestroyContext(_GLFWwindow* window)
|
||||
{
|
||||
// This is duplicated from glfwCloseWindow
|
||||
// This is duplicated from glfwDestroyWindow
|
||||
// TODO: Stop duplicating code
|
||||
if (window == _glfwLibrary.currentWindow)
|
||||
glfwMakeContextCurrent(NULL);
|
||||
@@ -545,10 +548,8 @@ void _glfwPlatformMakeContextCurrent(_GLFWwindow* window)
|
||||
// Swap buffers (double-buffering)
|
||||
//========================================================================
|
||||
|
||||
void _glfwPlatformSwapBuffers(void)
|
||||
void _glfwPlatformSwapBuffers(_GLFWwindow* window)
|
||||
{
|
||||
_GLFWwindow* window = _glfwLibrary.currentWindow;
|
||||
|
||||
SwapBuffers(window->WGL.DC);
|
||||
}
|
||||
|
||||
|
||||
Executable → Regular
+10
-12
@@ -31,6 +31,7 @@
|
||||
#include "internal.h"
|
||||
|
||||
#include <stdlib.h>
|
||||
#include <malloc.h>
|
||||
|
||||
|
||||
//========================================================================
|
||||
@@ -531,8 +532,7 @@ static LRESULT CALLBACK windowProc(HWND hWnd, UINT uMsg,
|
||||
|
||||
case WM_CLOSE:
|
||||
{
|
||||
// Flag this window for closing (handled in glfwPollEvents)
|
||||
window->closeRequested = GL_TRUE;
|
||||
_glfwInputWindowCloseRequest(window);
|
||||
return 0;
|
||||
}
|
||||
|
||||
@@ -895,7 +895,7 @@ static int createWindow(_GLFWwindow* window,
|
||||
if (!wideTitle)
|
||||
{
|
||||
_glfwSetError(GLFW_PLATFORM_ERROR,
|
||||
"glfwOpenWindow: Failed to convert title to wide string");
|
||||
"glfwCreateWindow: Failed to convert title to wide string");
|
||||
return GL_FALSE;
|
||||
}
|
||||
|
||||
@@ -940,7 +940,7 @@ static void destroyWindow(_GLFWwindow* window)
|
||||
{
|
||||
_glfwDestroyContext(window);
|
||||
|
||||
// This is duplicated from glfwCloseWindow
|
||||
// This is duplicated from glfwDestroyWindow
|
||||
// TODO: Stop duplicating code
|
||||
if (window == _glfwLibrary.activeWindow)
|
||||
_glfwLibrary.activeWindow = NULL;
|
||||
@@ -962,14 +962,13 @@ static void destroyWindow(_GLFWwindow* window)
|
||||
// created
|
||||
//========================================================================
|
||||
|
||||
int _glfwPlatformOpenWindow(_GLFWwindow* window,
|
||||
const _GLFWwndconfig* wndconfig,
|
||||
const _GLFWfbconfig* fbconfig)
|
||||
int _glfwPlatformCreateWindow(_GLFWwindow* window,
|
||||
const _GLFWwndconfig* wndconfig,
|
||||
const _GLFWfbconfig* fbconfig)
|
||||
{
|
||||
GLboolean recreateContext = GL_FALSE;
|
||||
|
||||
window->Win32.desiredRefreshRate = wndconfig->refreshRate;
|
||||
window->resizable = wndconfig->resizable;
|
||||
|
||||
if (!_glfwLibrary.Win32.classAtom)
|
||||
{
|
||||
@@ -1092,7 +1091,7 @@ int _glfwPlatformOpenWindow(_GLFWwindow* window,
|
||||
// Properly kill the window / video display
|
||||
//========================================================================
|
||||
|
||||
void _glfwPlatformCloseWindow(_GLFWwindow* window)
|
||||
void _glfwPlatformDestroyWindow(_GLFWwindow* window)
|
||||
{
|
||||
destroyWindow(window);
|
||||
|
||||
@@ -1207,10 +1206,9 @@ void _glfwPlatformRestoreWindow(_GLFWwindow* window)
|
||||
// Write back window parameters into GLFW window structure
|
||||
//========================================================================
|
||||
|
||||
void _glfwPlatformRefreshWindowParams(void)
|
||||
void _glfwPlatformRefreshWindowParams(_GLFWwindow* window)
|
||||
{
|
||||
DEVMODE dm;
|
||||
_GLFWwindow* window = _glfwLibrary.currentWindow;
|
||||
|
||||
ZeroMemory(&dm, sizeof(DEVMODE));
|
||||
dm.dmSize = sizeof(DEVMODE);
|
||||
@@ -1259,7 +1257,7 @@ void _glfwPlatformPollEvents(void)
|
||||
window = _glfwLibrary.windowListHead;
|
||||
while (window)
|
||||
{
|
||||
window->closeRequested = GL_TRUE;
|
||||
_glfwInputWindowCloseRequest(window);
|
||||
window = window->next;
|
||||
}
|
||||
|
||||
|
||||
+47
-112
@@ -32,6 +32,7 @@
|
||||
|
||||
#include <string.h>
|
||||
#include <stdlib.h>
|
||||
#include <malloc.h>
|
||||
|
||||
|
||||
//========================================================================
|
||||
@@ -44,31 +45,6 @@ static int Max(int a, int b)
|
||||
}
|
||||
|
||||
|
||||
//========================================================================
|
||||
// Close all GLFW windows with the closed flag set
|
||||
//========================================================================
|
||||
|
||||
static void closeFlaggedWindows(void)
|
||||
{
|
||||
_GLFWwindow* window;
|
||||
|
||||
for (window = _glfwLibrary.windowListHead; window; )
|
||||
{
|
||||
if (window->closeRequested && _glfwLibrary.windowCloseCallback)
|
||||
window->closeRequested = _glfwLibrary.windowCloseCallback(window);
|
||||
|
||||
if (window->closeRequested)
|
||||
{
|
||||
_GLFWwindow* next = window->next;
|
||||
glfwCloseWindow(window);
|
||||
window = next;
|
||||
}
|
||||
else
|
||||
window = window->next;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
//========================================================================
|
||||
// Clear scroll offsets for all windows
|
||||
//========================================================================
|
||||
@@ -206,6 +182,19 @@ void _glfwInputWindowDamage(_GLFWwindow* window)
|
||||
}
|
||||
|
||||
|
||||
//========================================================================
|
||||
// Register window close request events
|
||||
//========================================================================
|
||||
|
||||
void _glfwInputWindowCloseRequest(_GLFWwindow* window)
|
||||
{
|
||||
if (_glfwLibrary.windowCloseCallback)
|
||||
window->closeRequested = _glfwLibrary.windowCloseCallback(window);
|
||||
else
|
||||
window->closeRequested = GL_TRUE;
|
||||
}
|
||||
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
////// GLFW public API //////
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
@@ -214,13 +203,14 @@ void _glfwInputWindowDamage(_GLFWwindow* window)
|
||||
// Create the GLFW window and its associated context
|
||||
//========================================================================
|
||||
|
||||
GLFWAPI GLFWwindow glfwOpenWindow(int width, int height,
|
||||
int mode, const char* title,
|
||||
GLFWwindow share)
|
||||
GLFWAPI GLFWwindow glfwCreateWindow(int width, int height,
|
||||
int mode, const char* title,
|
||||
GLFWwindow share)
|
||||
{
|
||||
_GLFWfbconfig fbconfig;
|
||||
_GLFWwndconfig wndconfig;
|
||||
_GLFWwindow* window;
|
||||
_GLFWwindow* previous;
|
||||
|
||||
if (!_glfwInitialized)
|
||||
{
|
||||
@@ -266,10 +256,13 @@ GLFWAPI GLFWwindow glfwOpenWindow(int width, int height,
|
||||
if (!_glfwIsValidContextConfig(&wndconfig))
|
||||
return GL_FALSE;
|
||||
|
||||
// Save the currently current context so it can be restored later
|
||||
previous = glfwGetCurrentContext();
|
||||
|
||||
if (mode != GLFW_WINDOWED && mode != GLFW_FULLSCREEN)
|
||||
{
|
||||
_glfwSetError(GLFW_INVALID_ENUM,
|
||||
"glfwOpenWindow: Invalid enum for 'mode' parameter");
|
||||
"glfwCreateWindow: Invalid enum for 'mode' parameter");
|
||||
return GL_FALSE;
|
||||
}
|
||||
|
||||
@@ -295,7 +288,7 @@ GLFWAPI GLFWwindow glfwOpenWindow(int width, int height,
|
||||
if (!window)
|
||||
{
|
||||
_glfwSetError(GLFW_OUT_OF_MEMORY,
|
||||
"glfwOpenWindow: Failed to allocate window structure");
|
||||
"glfwCreateWindow: Failed to allocate window structure");
|
||||
return NULL;
|
||||
}
|
||||
|
||||
@@ -308,33 +301,41 @@ GLFWAPI GLFWwindow glfwOpenWindow(int width, int height,
|
||||
window->width = width;
|
||||
window->height = height;
|
||||
window->mode = mode;
|
||||
window->resizable = wndconfig.resizable;
|
||||
window->cursorMode = GLFW_CURSOR_NORMAL;
|
||||
window->systemKeys = GL_TRUE;
|
||||
|
||||
// Open the actual window and create its context
|
||||
if (!_glfwPlatformOpenWindow(window, &wndconfig, &fbconfig))
|
||||
if (!_glfwPlatformCreateWindow(window, &wndconfig, &fbconfig))
|
||||
{
|
||||
glfwCloseWindow(window);
|
||||
glfwDestroyWindow(window);
|
||||
glfwMakeContextCurrent(previous);
|
||||
return GL_FALSE;
|
||||
}
|
||||
|
||||
// Cache the actual (as opposed to desired) window parameters
|
||||
_glfwPlatformRefreshWindowParams();
|
||||
// Cache the actual (as opposed to requested) window parameters
|
||||
_glfwPlatformRefreshWindowParams(window);
|
||||
|
||||
// Cache the actual (as opposed to requested) context parameters
|
||||
glfwMakeContextCurrent(window);
|
||||
|
||||
if (!_glfwRefreshContextParams())
|
||||
{
|
||||
glfwCloseWindow(window);
|
||||
glfwDestroyWindow(window);
|
||||
glfwMakeContextCurrent(previous);
|
||||
return GL_FALSE;
|
||||
}
|
||||
|
||||
// Verify the context against the requested parameters
|
||||
if (!_glfwIsValidContext(&wndconfig))
|
||||
{
|
||||
glfwCloseWindow(window);
|
||||
glfwDestroyWindow(window);
|
||||
glfwMakeContextCurrent(previous);
|
||||
return GL_FALSE;
|
||||
}
|
||||
|
||||
// Restore the previously current context (or NULL)
|
||||
glfwMakeContextCurrent(previous);
|
||||
|
||||
// The GLFW specification states that fullscreen windows have the cursor
|
||||
// captured by default
|
||||
if (mode == GLFW_FULLSCREEN)
|
||||
@@ -343,45 +344,17 @@ GLFWAPI GLFWwindow glfwOpenWindow(int width, int height,
|
||||
// Clearing the front buffer to black to avoid garbage pixels left over
|
||||
// from previous uses of our bit of VRAM
|
||||
glClear(GL_COLOR_BUFFER_BIT);
|
||||
_glfwPlatformSwapBuffers();
|
||||
_glfwPlatformSwapBuffers(window);
|
||||
|
||||
return window;
|
||||
}
|
||||
|
||||
|
||||
//========================================================================
|
||||
// Returns GL_TRUE if the specified window handle is an actual window
|
||||
// Set hints for creating the window
|
||||
//========================================================================
|
||||
|
||||
GLFWAPI int glfwIsWindow(GLFWwindow handle)
|
||||
{
|
||||
_GLFWwindow* entry;
|
||||
_GLFWwindow* window = (_GLFWwindow*) handle;
|
||||
|
||||
if (!_glfwInitialized)
|
||||
{
|
||||
_glfwSetError(GLFW_NOT_INITIALIZED, NULL);
|
||||
return GL_FALSE;
|
||||
}
|
||||
|
||||
if (window == NULL)
|
||||
return GL_FALSE;
|
||||
|
||||
for (entry = _glfwLibrary.windowListHead; entry; entry = entry->next)
|
||||
{
|
||||
if (entry == window)
|
||||
return GL_TRUE;
|
||||
}
|
||||
|
||||
return GL_FALSE;
|
||||
}
|
||||
|
||||
|
||||
//========================================================================
|
||||
// Set hints for opening the window
|
||||
//========================================================================
|
||||
|
||||
GLFWAPI void glfwOpenWindowHint(int target, int hint)
|
||||
GLFWAPI void glfwWindowHint(int target, int hint)
|
||||
{
|
||||
if (!_glfwInitialized)
|
||||
{
|
||||
@@ -465,7 +438,7 @@ GLFWAPI void glfwOpenWindowHint(int target, int hint)
|
||||
// Properly kill the window / video display
|
||||
//========================================================================
|
||||
|
||||
GLFWAPI void glfwCloseWindow(GLFWwindow handle)
|
||||
GLFWAPI void glfwDestroyWindow(GLFWwindow handle)
|
||||
{
|
||||
_GLFWwindow* window = (_GLFWwindow*) handle;
|
||||
|
||||
@@ -487,7 +460,7 @@ GLFWAPI void glfwCloseWindow(GLFWwindow handle)
|
||||
if (window == _glfwLibrary.activeWindow)
|
||||
_glfwLibrary.activeWindow = NULL;
|
||||
|
||||
_glfwPlatformCloseWindow(window);
|
||||
_glfwPlatformDestroyWindow(window);
|
||||
|
||||
// Unlink window from global linked list
|
||||
{
|
||||
@@ -573,7 +546,7 @@ GLFWAPI void glfwSetWindowSize(GLFWwindow handle, int width, int height)
|
||||
{
|
||||
// Refresh window parameters (may have changed due to changed video
|
||||
// modes)
|
||||
_glfwPlatformRefreshWindowParams();
|
||||
_glfwPlatformRefreshWindowParams(window);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -665,7 +638,7 @@ GLFWAPI void glfwRestoreWindow(GLFWwindow handle)
|
||||
_glfwPlatformRestoreWindow(window);
|
||||
|
||||
if (window->mode == GLFW_FULLSCREEN)
|
||||
_glfwPlatformRefreshWindowParams();
|
||||
_glfwPlatformRefreshWindowParams(window);
|
||||
}
|
||||
|
||||
|
||||
@@ -689,36 +662,12 @@ GLFWAPI int glfwGetWindowParam(GLFWwindow handle, int param)
|
||||
return window == _glfwLibrary.activeWindow;
|
||||
case GLFW_ICONIFIED:
|
||||
return window->iconified;
|
||||
case GLFW_RED_BITS:
|
||||
return window->redBits;
|
||||
case GLFW_GREEN_BITS:
|
||||
return window->greenBits;
|
||||
case GLFW_BLUE_BITS:
|
||||
return window->blueBits;
|
||||
case GLFW_ALPHA_BITS:
|
||||
return window->alphaBits;
|
||||
case GLFW_DEPTH_BITS:
|
||||
return window->depthBits;
|
||||
case GLFW_STENCIL_BITS:
|
||||
return window->stencilBits;
|
||||
case GLFW_ACCUM_RED_BITS:
|
||||
return window->accumRedBits;
|
||||
case GLFW_ACCUM_GREEN_BITS:
|
||||
return window->accumGreenBits;
|
||||
case GLFW_ACCUM_BLUE_BITS:
|
||||
return window->accumBlueBits;
|
||||
case GLFW_ACCUM_ALPHA_BITS:
|
||||
return window->accumAlphaBits;
|
||||
case GLFW_AUX_BUFFERS:
|
||||
return window->auxBuffers;
|
||||
case GLFW_STEREO:
|
||||
return window->stereo;
|
||||
case GLFW_CLOSE_REQUESTED:
|
||||
return window->closeRequested;
|
||||
case GLFW_REFRESH_RATE:
|
||||
return window->refreshRate;
|
||||
case GLFW_WINDOW_RESIZABLE:
|
||||
return window->resizable;
|
||||
case GLFW_FSAA_SAMPLES:
|
||||
return window->samples;
|
||||
case GLFW_OPENGL_VERSION_MAJOR:
|
||||
return window->glMajor;
|
||||
case GLFW_OPENGL_VERSION_MINOR:
|
||||
@@ -789,16 +738,6 @@ GLFWAPI void glfwSetWindowSizeCallback(GLFWwindowsizefun cbfun)
|
||||
}
|
||||
|
||||
_glfwLibrary.windowSizeCallback = cbfun;
|
||||
|
||||
// Call the callback function to let the application know the current
|
||||
// window size
|
||||
if (cbfun)
|
||||
{
|
||||
_GLFWwindow* window;
|
||||
|
||||
for (window = _glfwLibrary.windowListHead; window; window = window->next)
|
||||
cbfun(window, window->width, window->height);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -881,8 +820,6 @@ GLFWAPI void glfwPollEvents(void)
|
||||
clearScrollOffsets();
|
||||
|
||||
_glfwPlatformPollEvents();
|
||||
|
||||
closeFlaggedWindows();
|
||||
}
|
||||
|
||||
|
||||
@@ -901,7 +838,5 @@ GLFWAPI void glfwWaitEvents(void)
|
||||
clearScrollOffsets();
|
||||
|
||||
_glfwPlatformWaitEvents();
|
||||
|
||||
closeFlaggedWindows();
|
||||
}
|
||||
|
||||
|
||||
+1
-1
@@ -83,7 +83,7 @@ void _glfwInitJoysticks(void)
|
||||
{
|
||||
#ifdef _GLFW_USE_LINUX_JOYSTICKS
|
||||
int k, n, fd, joy_count;
|
||||
char* joy_base_name;
|
||||
const char* joy_base_name;
|
||||
char joy_dev_name[20];
|
||||
int driver_version = 0x000800;
|
||||
char ret_data;
|
||||
|
||||
+2
-3
@@ -642,10 +642,9 @@ void _glfwPlatformMakeContextCurrent(_GLFWwindow* window)
|
||||
// Swap OpenGL buffers
|
||||
//========================================================================
|
||||
|
||||
void _glfwPlatformSwapBuffers(void)
|
||||
void _glfwPlatformSwapBuffers(_GLFWwindow* window)
|
||||
{
|
||||
glXSwapBuffers(_glfwLibrary.X11.display,
|
||||
_glfwLibrary.currentWindow->X11.handle);
|
||||
glXSwapBuffers(_glfwLibrary.X11.display, window->X11.handle);
|
||||
}
|
||||
|
||||
|
||||
|
||||
+7
-43
@@ -43,16 +43,6 @@
|
||||
#define Button6 6
|
||||
#define Button7 7
|
||||
|
||||
//========================================================================
|
||||
// Checks whether the event is a MapNotify for the specified window
|
||||
//========================================================================
|
||||
|
||||
static Bool isMapNotify(Display* d, XEvent* e, char* arg)
|
||||
{
|
||||
return (e->type == MapNotify) && (e->xmap.window == (Window)arg);
|
||||
}
|
||||
|
||||
|
||||
//========================================================================
|
||||
// Translates an X Window key to internal coding
|
||||
//========================================================================
|
||||
@@ -94,7 +84,6 @@ static int translateChar(XKeyEvent* event)
|
||||
static GLboolean createWindow(_GLFWwindow* window,
|
||||
const _GLFWwndconfig* wndconfig)
|
||||
{
|
||||
XEvent event;
|
||||
unsigned long wamask;
|
||||
XSetWindowAttributes wa;
|
||||
XVisualInfo* visual = _glfwGetContextVisual(window);
|
||||
@@ -243,8 +232,7 @@ static GLboolean createWindow(_GLFWwindow* window,
|
||||
|
||||
// Make sure the window is mapped before proceeding
|
||||
XMapWindow(_glfwLibrary.X11.display, window->X11.handle);
|
||||
XPeekIfEvent(_glfwLibrary.X11.display, &event, isMapNotify,
|
||||
(char*) window->X11.handle);
|
||||
XFlush(_glfwLibrary.X11.display);
|
||||
|
||||
return GL_TRUE;
|
||||
}
|
||||
@@ -723,7 +711,7 @@ static void processSingleEvent(void)
|
||||
// The window manager was asked to close the window, for example by
|
||||
// the user pressing a 'close' window decoration button
|
||||
|
||||
window->closeRequested = GL_TRUE;
|
||||
_glfwInputWindowCloseRequest(window);
|
||||
}
|
||||
else if (_glfwLibrary.X11.wmPing != None &&
|
||||
(Atom) event.xclient.data.l[0] == _glfwLibrary.X11.wmPing)
|
||||
@@ -888,24 +876,6 @@ static void processSingleEvent(void)
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
////// GLFW internal API //////
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
|
||||
//========================================================================
|
||||
// Processes all pending events
|
||||
//========================================================================
|
||||
|
||||
void _glfwProcessPendingEvents(void)
|
||||
{
|
||||
int i, count = XPending(_glfwLibrary.X11.display);
|
||||
|
||||
for (i = 0; i < count; i++)
|
||||
processSingleEvent();
|
||||
}
|
||||
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
////// GLFW platform API //////
|
||||
//////////////////////////////////////////////////////////////////////////
|
||||
@@ -915,12 +885,11 @@ void _glfwProcessPendingEvents(void)
|
||||
// the OpenGL rendering context is created
|
||||
//========================================================================
|
||||
|
||||
int _glfwPlatformOpenWindow(_GLFWwindow* window,
|
||||
const _GLFWwndconfig* wndconfig,
|
||||
const _GLFWfbconfig* fbconfig)
|
||||
int _glfwPlatformCreateWindow(_GLFWwindow* window,
|
||||
const _GLFWwndconfig* wndconfig,
|
||||
const _GLFWfbconfig* fbconfig)
|
||||
{
|
||||
window->refreshRate = wndconfig->refreshRate;
|
||||
window->resizable = wndconfig->resizable;
|
||||
|
||||
if (!_glfwCreateContext(window, wndconfig, fbconfig))
|
||||
return GL_FALSE;
|
||||
@@ -943,9 +912,6 @@ int _glfwPlatformOpenWindow(_GLFWwindow* window,
|
||||
enterFullscreenMode(window);
|
||||
}
|
||||
|
||||
// Process the window map event and any other that may have arrived
|
||||
_glfwProcessPendingEvents();
|
||||
|
||||
// Retrieve and set initial cursor position
|
||||
{
|
||||
Window cursorWindow, cursorRoot;
|
||||
@@ -974,7 +940,7 @@ int _glfwPlatformOpenWindow(_GLFWwindow* window,
|
||||
// Properly kill the window/video display
|
||||
//========================================================================
|
||||
|
||||
void _glfwPlatformCloseWindow(_GLFWwindow* window)
|
||||
void _glfwPlatformDestroyWindow(_GLFWwindow* window)
|
||||
{
|
||||
if (window->mode == GLFW_FULLSCREEN)
|
||||
leaveFullscreenMode(window);
|
||||
@@ -1138,10 +1104,8 @@ void _glfwPlatformRestoreWindow(_GLFWwindow* window)
|
||||
// Read back framebuffer parameters from the context
|
||||
//========================================================================
|
||||
|
||||
void _glfwPlatformRefreshWindowParams(void)
|
||||
void _glfwPlatformRefreshWindowParams(_GLFWwindow* window)
|
||||
{
|
||||
_GLFWwindow* window = _glfwLibrary.currentWindow;
|
||||
|
||||
// Retrieve refresh rate if possible
|
||||
if (_glfwLibrary.X11.RandR.available)
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user