1
0
Fork 0
mirror of https://github.com/gwm17/glfw.git synced 2024-11-23 02:38:52 -05:00
This commit is contained in:
Camilla Berglund 2016-05-25 14:43:51 +02:00
parent 797ee8d8e3
commit bda031f4ac
13 changed files with 98 additions and 111 deletions

View File

@ -1066,7 +1066,7 @@ void _glfwPlatformDestroyWindow(_GLFWwindow* window)
releaseMonitor(window); releaseMonitor(window);
if (window->context.client != GLFW_NO_API) if (window->context.client != GLFW_NO_API)
window->context.destroyContext(window); window->context.destroy(window);
[window->ns.object setDelegate:nil]; [window->ns.object setDelegate:nil];
[window->ns.delegate release]; [window->ns.delegate release];

View File

@ -576,11 +576,11 @@ GLFWAPI void glfwMakeContextCurrent(GLFWwindow* handle)
if (previous) if (previous)
{ {
if (!window || window->context.source != previous->context.source) if (!window || window->context.source != previous->context.source)
previous->context.makeContextCurrent(NULL); previous->context.makeCurrent(NULL);
} }
if (window) if (window)
window->context.makeContextCurrent(window); window->context.makeCurrent(window);
} }
GLFWAPI GLFWwindow* glfwGetCurrentContext(void) GLFWAPI GLFWwindow* glfwGetCurrentContext(void)

View File

@ -613,12 +613,12 @@ GLFWbool _glfwCreateContextEGL(_GLFWwindow* window,
} }
} }
window->context.makeContextCurrent = makeContextCurrent; window->context.makeCurrent = makeContextCurrent;
window->context.swapBuffers = swapBuffers; window->context.swapBuffers = swapBuffers;
window->context.swapInterval = swapInterval; window->context.swapInterval = swapInterval;
window->context.extensionSupported = extensionSupported; window->context.extensionSupported = extensionSupported;
window->context.getProcAddress = getProcAddress; window->context.getProcAddress = getProcAddress;
window->context.destroyContext = destroyContext; window->context.destroy = destroyContext;
return GLFW_TRUE; return GLFW_TRUE;
} }

View File

@ -572,12 +572,12 @@ GLFWbool _glfwCreateContextGLX(_GLFWwindow* window,
return GLFW_FALSE; return GLFW_FALSE;
} }
window->context.makeContextCurrent = makeContextCurrent; window->context.makeCurrent = makeContextCurrent;
window->context.swapBuffers = swapBuffers; window->context.swapBuffers = swapBuffers;
window->context.swapInterval = swapInterval; window->context.swapInterval = swapInterval;
window->context.extensionSupported = extensionSupported; window->context.extensionSupported = extensionSupported;
window->context.getProcAddress = getProcAddress; window->context.getProcAddress = getProcAddress;
window->context.destroyContext = destroyContext; window->context.destroy = destroyContext;
return GLFW_TRUE; return GLFW_TRUE;
} }

View File

@ -35,76 +35,6 @@
#define _GLFW_STICK 3 #define _GLFW_STICK 3
// Sets the cursor mode for the specified window
//
static void setCursorMode(_GLFWwindow* window, int mode)
{
if (mode != GLFW_CURSOR_NORMAL &&
mode != GLFW_CURSOR_HIDDEN &&
mode != GLFW_CURSOR_DISABLED)
{
_glfwInputError(GLFW_INVALID_ENUM, "Invalid cursor mode %i", mode);
return;
}
if (window->cursorMode == mode)
return;
_glfwPlatformGetCursorPos(window,
&window->virtualCursorPosX,
&window->virtualCursorPosY);
if (_glfw.cursorWindow == window)
_glfwPlatformSetCursorMode(window, mode);
window->cursorMode = mode;
}
// Set sticky keys mode for the specified window
//
static void setStickyKeys(_GLFWwindow* window, int enabled)
{
if (window->stickyKeys == enabled)
return;
if (!enabled)
{
int i;
// Release all sticky keys
for (i = 0; i <= GLFW_KEY_LAST; i++)
{
if (window->keys[i] == _GLFW_STICK)
window->keys[i] = GLFW_RELEASE;
}
}
window->stickyKeys = enabled;
}
// Set sticky mouse buttons mode for the specified window
//
static void setStickyMouseButtons(_GLFWwindow* window, int enabled)
{
if (window->stickyMouseButtons == enabled)
return;
if (!enabled)
{
int i;
// Release all sticky mouse buttons
for (i = 0; i <= GLFW_MOUSE_BUTTON_LAST; i++)
{
if (window->mouseButtons[i] == _GLFW_STICK)
window->mouseButtons[i] = GLFW_RELEASE;
}
}
window->stickyMouseButtons = enabled;
}
////////////////////////////////////////////////////////////////////////// //////////////////////////////////////////////////////////////////////////
////// GLFW event API ////// ////// GLFW event API //////
////////////////////////////////////////////////////////////////////////// //////////////////////////////////////////////////////////////////////////
@ -170,16 +100,16 @@ void _glfwInputMouseClick(_GLFWwindow* window, int button, int action, int mods)
window->callbacks.mouseButton((GLFWwindow*) window, button, action, mods); window->callbacks.mouseButton((GLFWwindow*) window, button, action, mods);
} }
void _glfwInputCursorPos(_GLFWwindow* window, double x, double y) void _glfwInputCursorPos(_GLFWwindow* window, double xpos, double ypos)
{ {
if (window->virtualCursorPosX == x && window->virtualCursorPosY == y) if (window->virtualCursorPosX == xpos && window->virtualCursorPosY == ypos)
return; return;
window->virtualCursorPosX = x; window->virtualCursorPosX = xpos;
window->virtualCursorPosY = y; window->virtualCursorPosY = ypos;
if (window->callbacks.cursorPos) if (window->callbacks.cursorPos)
window->callbacks.cursorPos((GLFWwindow*) window, x, y); window->callbacks.cursorPos((GLFWwindow*) window, xpos, ypos);
} }
void _glfwInputCursorEnter(_GLFWwindow* window, GLFWbool entered) void _glfwInputCursorEnter(_GLFWwindow* window, GLFWbool entered)
@ -248,18 +178,75 @@ GLFWAPI void glfwSetInputMode(GLFWwindow* handle, int mode, int value)
switch (mode) switch (mode)
{ {
case GLFW_CURSOR: case GLFW_CURSOR:
setCursorMode(window, value); {
break; if (value != GLFW_CURSOR_NORMAL &&
value != GLFW_CURSOR_HIDDEN &&
value != GLFW_CURSOR_DISABLED)
{
_glfwInputError(GLFW_INVALID_ENUM,
"Invalid cursor mode %i",
value);
return;
}
if (window->cursorMode == value)
return;
_glfwPlatformGetCursorPos(window,
&window->virtualCursorPosX,
&window->virtualCursorPosY);
if (_glfw.cursorWindow == window)
_glfwPlatformSetCursorMode(window, value);
window->cursorMode = value;
return;
}
case GLFW_STICKY_KEYS: case GLFW_STICKY_KEYS:
setStickyKeys(window, value ? GLFW_TRUE : GLFW_FALSE); {
break; if (window->stickyKeys == value)
return;
if (!value)
{
int i;
// Release all sticky keys
for (i = 0; i <= GLFW_KEY_LAST; i++)
{
if (window->keys[i] == _GLFW_STICK)
window->keys[i] = GLFW_RELEASE;
}
}
window->stickyKeys = value ? GLFW_TRUE : GLFW_FALSE;
return;
}
case GLFW_STICKY_MOUSE_BUTTONS: case GLFW_STICKY_MOUSE_BUTTONS:
setStickyMouseButtons(window, value ? GLFW_TRUE : GLFW_FALSE); {
break; if (window->stickyMouseButtons == value)
default: return;
_glfwInputError(GLFW_INVALID_ENUM, "Invalid input mode %i", mode);
break; if (!value)
{
int i;
// Release all sticky mouse buttons
for (i = 0; i <= GLFW_MOUSE_BUTTON_LAST; i++)
{
if (window->mouseButtons[i] == _GLFW_STICK)
window->mouseButtons[i] = GLFW_RELEASE;
}
}
window->stickyMouseButtons = value ? GLFW_TRUE : GLFW_FALSE;
return;
}
} }
_glfwInputError(GLFW_INVALID_ENUM, "Invalid input mode %i", mode);
} }
GLFWAPI const char* glfwGetKeyName(int key, int scancode) GLFWAPI const char* glfwGetKeyName(int key, int scancode)

View File

@ -324,12 +324,12 @@ struct _GLFWcontext
PFNGLGETINTEGERVPROC GetIntegerv; PFNGLGETINTEGERVPROC GetIntegerv;
PFNGLGETSTRINGPROC GetString; PFNGLGETSTRINGPROC GetString;
_GLFWmakecontextcurrentfun makeContextCurrent; _GLFWmakecontextcurrentfun makeCurrent;
_GLFWswapbuffersfun swapBuffers; _GLFWswapbuffersfun swapBuffers;
_GLFWswapintervalfun swapInterval; _GLFWswapintervalfun swapInterval;
_GLFWextensionsupportedfun extensionSupported; _GLFWextensionsupportedfun extensionSupported;
_GLFWgetprocaddressfun getProcAddress; _GLFWgetprocaddressfun getProcAddress;
_GLFWdestroycontextfun destroyContext; _GLFWdestroycontextfun destroy;
// This is defined in the context API's context.h // This is defined in the context API's context.h
_GLFW_PLATFORM_CONTEXT_STATE; _GLFW_PLATFORM_CONTEXT_STATE;
@ -881,11 +881,11 @@ void _glfwInputChar(_GLFWwindow* window, unsigned int codepoint, int mods, GLFWb
/*! @brief Notifies shared code of a scroll event. /*! @brief Notifies shared code of a scroll event.
* @param[in] window The window that received the event. * @param[in] window The window that received the event.
* @param[in] x The scroll offset along the x-axis. * @param[in] xoffset The scroll offset along the x-axis.
* @param[in] y The scroll offset along the y-axis. * @param[in] yoffset The scroll offset along the y-axis.
* @ingroup event * @ingroup event
*/ */
void _glfwInputScroll(_GLFWwindow* window, double x, double y); void _glfwInputScroll(_GLFWwindow* window, double xoffset, double yoffset);
/*! @brief Notifies shared code of a mouse button click event. /*! @brief Notifies shared code of a mouse button click event.
* @param[in] window The window that received the event. * @param[in] window The window that received the event.
@ -897,13 +897,13 @@ void _glfwInputMouseClick(_GLFWwindow* window, int button, int action, int mods)
/*! @brief Notifies shared code of a cursor motion event. /*! @brief Notifies shared code of a cursor motion event.
* @param[in] window The window that received the event. * @param[in] window The window that received the event.
* @param[in] x The new x-coordinate of the cursor, relative to the left edge * @param[in] xpos The new x-coordinate of the cursor, relative to the left
* of the client area of the window. * edge of the client area of the window.
* @param[in] y The new y-coordinate of the cursor, relative to the top edge * @param[in] ypos The new y-coordinate of the cursor, relative to the top edge
* of the client area of the window. * of the client area of the window.
* @ingroup event * @ingroup event
*/ */
void _glfwInputCursorPos(_GLFWwindow* window, double x, double y); void _glfwInputCursorPos(_GLFWwindow* window, double xpos, double ypos);
/*! @brief Notifies shared code of a cursor enter/leave event. /*! @brief Notifies shared code of a cursor enter/leave event.
* @param[in] window The window that received the event. * @param[in] window The window that received the event.

View File

@ -395,7 +395,7 @@ void _glfwPlatformDestroyWindow(_GLFWwindow* window)
} }
if (window->context.client != GLFW_NO_API) if (window->context.client != GLFW_NO_API)
window->context.destroyContext(window); window->context.destroy(window);
} }
void _glfwPlatformSetWindowTitle(_GLFWwindow* window, const char* title) void _glfwPlatformSetWindowTitle(_GLFWwindow* window, const char* title)

View File

@ -274,12 +274,12 @@ GLFWbool _glfwCreateContextNSGL(_GLFWwindow* window,
[window->context.nsgl.object setView:window->ns.view]; [window->context.nsgl.object setView:window->ns.view];
window->context.makeContextCurrent = makeContextCurrent; window->context.makeCurrent = makeContextCurrent;
window->context.swapBuffers = swapBuffers; window->context.swapBuffers = swapBuffers;
window->context.swapInterval = swapInterval; window->context.swapInterval = swapInterval;
window->context.extensionSupported = extensionSupported; window->context.extensionSupported = extensionSupported;
window->context.getProcAddress = getProcAddress; window->context.getProcAddress = getProcAddress;
window->context.destroyContext = destroyContext; window->context.destroy = destroyContext;
return GLFW_TRUE; return GLFW_TRUE;
} }

View File

@ -576,12 +576,12 @@ GLFWbool _glfwCreateContextWGL(_GLFWwindow* window,
} }
} }
window->context.makeContextCurrent = makeContextCurrent; window->context.makeCurrent = makeContextCurrent;
window->context.swapBuffers = swapBuffers; window->context.swapBuffers = swapBuffers;
window->context.swapInterval = swapInterval; window->context.swapInterval = swapInterval;
window->context.extensionSupported = extensionSupported; window->context.extensionSupported = extensionSupported;
window->context.getProcAddress = getProcAddress; window->context.getProcAddress = getProcAddress;
window->context.destroyContext = destroyContext; window->context.destroy = destroyContext;
return GLFW_TRUE; return GLFW_TRUE;
} }

View File

@ -1029,11 +1029,11 @@ int _glfwPlatformCreateWindow(_GLFWwindow* window,
// First we clear the current context (the one we just created) // First we clear the current context (the one we just created)
// This is usually done by glfwDestroyWindow, but as we're not doing // This is usually done by glfwDestroyWindow, but as we're not doing
// full GLFW window destruction, it's duplicated here // full GLFW window destruction, it's duplicated here
window->context.makeContextCurrent(NULL); window->context.makeCurrent(NULL);
// Next destroy the Win32 window and WGL context (without resetting // Next destroy the Win32 window and WGL context (without resetting
// or destroying the GLFW window object) // or destroying the GLFW window object)
window->context.destroyContext(window); window->context.destroy(window);
destroyWindow(window); destroyWindow(window);
// ...and then create them again, this time with better APIs // ...and then create them again, this time with better APIs
@ -1069,7 +1069,7 @@ void _glfwPlatformDestroyWindow(_GLFWwindow* window)
releaseMonitor(window); releaseMonitor(window);
if (window->context.client != GLFW_NO_API) if (window->context.client != GLFW_NO_API)
window->context.destroyContext(window); window->context.destroy(window);
destroyWindow(window); destroyWindow(window);

View File

@ -205,7 +205,7 @@ GLFWAPI GLFWwindow* glfwCreateWindow(int width, int height,
if (ctxconfig.client != GLFW_NO_API) if (ctxconfig.client != GLFW_NO_API)
{ {
window->context.makeContextCurrent(window); window->context.makeCurrent(window);
// Retrieve the actual (as opposed to requested) context attributes // Retrieve the actual (as opposed to requested) context attributes
if (!_glfwRefreshContextAttribs(&ctxconfig)) if (!_glfwRefreshContextAttribs(&ctxconfig))

View File

@ -436,7 +436,7 @@ void _glfwPlatformDestroyWindow(_GLFWwindow* window)
} }
if (window->context.client != GLFW_NO_API) if (window->context.client != GLFW_NO_API)
window->context.destroyContext(window); window->context.destroy(window);
if (window->wl.native) if (window->wl.native)
wl_egl_window_destroy(window->wl.native); wl_egl_window_destroy(window->wl.native);

View File

@ -1548,7 +1548,7 @@ void _glfwPlatformDestroyWindow(_GLFWwindow* window)
} }
if (window->context.client != GLFW_NO_API) if (window->context.client != GLFW_NO_API)
window->context.destroyContext(window); window->context.destroy(window);
if (window->x11.handle) if (window->x11.handle)
{ {