2010-09-07 15:34:51 +00:00
|
|
|
//========================================================================
|
2011-03-06 00:46:39 +00:00
|
|
|
// GLFW - An OpenGL library
|
2010-09-07 15:34:51 +00:00
|
|
|
// Platform: Any
|
2010-09-07 15:41:26 +00:00
|
|
|
// API version: 3.0
|
2010-09-07 15:34:51 +00:00
|
|
|
// WWW: http://www.glfw.org/
|
|
|
|
//------------------------------------------------------------------------
|
|
|
|
// Copyright (c) 2002-2006 Marcus Geelnard
|
|
|
|
// Copyright (c) 2006-2010 Camilla Berglund <elmindreda@elmindreda.org>
|
2012-08-14 21:34:26 +00:00
|
|
|
// Copyright (c) 2012 Torsten Walluhn <tw@mad-cad.net>
|
2010-09-07 15:34:51 +00:00
|
|
|
//
|
|
|
|
// This software is provided 'as-is', without any express or implied
|
|
|
|
// warranty. In no event will the authors be held liable for any damages
|
|
|
|
// arising from the use of this software.
|
|
|
|
//
|
|
|
|
// Permission is granted to anyone to use this software for any purpose,
|
|
|
|
// including commercial applications, and to alter it and redistribute it
|
|
|
|
// freely, subject to the following restrictions:
|
|
|
|
//
|
|
|
|
// 1. The origin of this software must not be misrepresented; you must not
|
|
|
|
// claim that you wrote the original software. If you use this software
|
|
|
|
// in a product, an acknowledgment in the product documentation would
|
|
|
|
// be appreciated but is not required.
|
|
|
|
//
|
|
|
|
// 2. Altered source versions must be plainly marked as such, and must not
|
|
|
|
// be misrepresented as being the original software.
|
|
|
|
//
|
|
|
|
// 3. This notice may not be removed or altered from any source
|
|
|
|
// distribution.
|
|
|
|
//
|
|
|
|
//========================================================================
|
|
|
|
|
|
|
|
#include "internal.h"
|
|
|
|
|
2010-09-08 15:01:39 +00:00
|
|
|
#include <string.h>
|
2010-09-09 16:15:32 +00:00
|
|
|
#include <stdlib.h>
|
2012-09-12 19:18:37 +00:00
|
|
|
#if defined(_MSC_VER)
|
2012-09-09 12:22:14 +00:00
|
|
|
#include <malloc.h>
|
2012-08-14 21:34:26 +00:00
|
|
|
#endif
|
2010-09-07 15:34:51 +00:00
|
|
|
|
|
|
|
|
2010-09-09 18:59:50 +00:00
|
|
|
// Return the maxiumum of the specified values
|
2013-02-04 12:22:10 +00:00
|
|
|
//
|
2010-09-07 15:34:51 +00:00
|
|
|
static int Max(int a, int b)
|
|
|
|
{
|
|
|
|
return (a > b) ? a : b;
|
|
|
|
}
|
|
|
|
|
2010-09-13 23:43:31 +00:00
|
|
|
|
2010-09-09 18:59:50 +00:00
|
|
|
//////////////////////////////////////////////////////////////////////////
|
2013-01-23 18:47:05 +00:00
|
|
|
////// GLFW event API //////
|
2010-09-09 18:59:50 +00:00
|
|
|
//////////////////////////////////////////////////////////////////////////
|
|
|
|
|
2012-11-22 16:04:44 +00:00
|
|
|
void _glfwInputWindowFocus(_GLFWwindow* window, GLboolean focused)
|
2010-09-19 00:49:42 +00:00
|
|
|
{
|
2012-11-22 16:04:44 +00:00
|
|
|
if (focused)
|
2010-09-19 00:49:42 +00:00
|
|
|
{
|
2013-01-02 00:40:42 +00:00
|
|
|
if (_glfw.focusedWindow != window)
|
2010-09-19 00:49:42 +00:00
|
|
|
{
|
2013-01-02 00:40:42 +00:00
|
|
|
_glfw.focusedWindow = window;
|
2012-09-16 10:42:51 +00:00
|
|
|
|
2013-01-15 20:34:26 +00:00
|
|
|
if (window->callbacks.focus)
|
|
|
|
window->callbacks.focus((GLFWwindow*) window, focused);
|
2010-09-19 00:49:42 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2013-01-02 00:40:42 +00:00
|
|
|
if (_glfw.focusedWindow == window)
|
2012-09-16 10:42:51 +00:00
|
|
|
{
|
2010-09-19 00:49:42 +00:00
|
|
|
int i;
|
|
|
|
|
2013-04-16 14:06:28 +00:00
|
|
|
_glfw.focusedWindow = NULL;
|
|
|
|
|
|
|
|
if (window->callbacks.focus)
|
|
|
|
window->callbacks.focus((GLFWwindow*) window, focused);
|
|
|
|
|
2010-09-19 00:49:42 +00:00
|
|
|
// Release all pressed keyboard keys
|
|
|
|
for (i = 0; i <= GLFW_KEY_LAST; i++)
|
|
|
|
{
|
|
|
|
if (window->key[i] == GLFW_PRESS)
|
2013-05-30 15:19:12 +00:00
|
|
|
_glfwInputKey(window, i, 0, GLFW_RELEASE, 0);
|
2010-09-19 00:49:42 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
// Release all pressed mouse buttons
|
|
|
|
for (i = 0; i <= GLFW_MOUSE_BUTTON_LAST; i++)
|
|
|
|
{
|
|
|
|
if (window->mouseButton[i] == GLFW_PRESS)
|
2012-12-09 18:19:00 +00:00
|
|
|
_glfwInputMouseClick(window, i, GLFW_RELEASE, 0);
|
2010-09-19 00:49:42 +00:00
|
|
|
}
|
2012-09-16 10:42:51 +00:00
|
|
|
}
|
2010-09-19 00:49:42 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2011-10-09 15:10:40 +00:00
|
|
|
void _glfwInputWindowPos(_GLFWwindow* window, int x, int y)
|
|
|
|
{
|
2013-01-15 20:34:26 +00:00
|
|
|
if (window->callbacks.pos)
|
|
|
|
window->callbacks.pos((GLFWwindow*) window, x, y);
|
2011-10-09 15:10:40 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void _glfwInputWindowSize(_GLFWwindow* window, int width, int height)
|
|
|
|
{
|
2013-01-15 20:34:26 +00:00
|
|
|
if (window->callbacks.size)
|
|
|
|
window->callbacks.size((GLFWwindow*) window, width, height);
|
2011-10-09 15:10:40 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void _glfwInputWindowIconify(_GLFWwindow* window, int iconified)
|
|
|
|
{
|
|
|
|
if (window->iconified == iconified)
|
|
|
|
return;
|
|
|
|
|
|
|
|
window->iconified = iconified;
|
|
|
|
|
2013-01-15 20:34:26 +00:00
|
|
|
if (window->callbacks.iconify)
|
|
|
|
window->callbacks.iconify((GLFWwindow*) window, iconified);
|
2011-10-09 15:10:40 +00:00
|
|
|
}
|
|
|
|
|
2013-06-03 10:51:57 +00:00
|
|
|
void _glfwInputFramebufferSize(_GLFWwindow* window, int width, int height)
|
|
|
|
{
|
|
|
|
if (window->callbacks.fbsize)
|
|
|
|
window->callbacks.fbsize((GLFWwindow*) window, width, height);
|
|
|
|
}
|
|
|
|
|
2012-08-21 19:18:09 +00:00
|
|
|
void _glfwInputWindowVisibility(_GLFWwindow* window, int visible)
|
|
|
|
{
|
|
|
|
window->visible = visible;
|
|
|
|
}
|
|
|
|
|
2011-10-09 19:12:13 +00:00
|
|
|
void _glfwInputWindowDamage(_GLFWwindow* window)
|
|
|
|
{
|
2013-01-15 20:34:26 +00:00
|
|
|
if (window->callbacks.refresh)
|
|
|
|
window->callbacks.refresh((GLFWwindow*) window);
|
2011-10-09 19:12:13 +00:00
|
|
|
}
|
|
|
|
|
2012-08-10 11:31:15 +00:00
|
|
|
void _glfwInputWindowCloseRequest(_GLFWwindow* window)
|
|
|
|
{
|
2013-04-08 01:07:52 +00:00
|
|
|
window->closed = GL_TRUE;
|
2013-03-06 22:29:37 +00:00
|
|
|
|
2013-01-15 20:34:26 +00:00
|
|
|
if (window->callbacks.close)
|
2013-03-06 22:29:37 +00:00
|
|
|
window->callbacks.close((GLFWwindow*) window);
|
2012-08-10 11:31:15 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
|
2010-09-09 18:59:50 +00:00
|
|
|
//////////////////////////////////////////////////////////////////////////
|
|
|
|
////// GLFW public API //////
|
|
|
|
//////////////////////////////////////////////////////////////////////////
|
2010-09-07 15:34:51 +00:00
|
|
|
|
2013-01-05 20:13:28 +00:00
|
|
|
GLFWAPI GLFWwindow* glfwCreateWindow(int width, int height,
|
|
|
|
const char* title,
|
|
|
|
GLFWmonitor* monitor,
|
|
|
|
GLFWwindow* share)
|
2010-09-07 15:34:51 +00:00
|
|
|
{
|
|
|
|
_GLFWfbconfig fbconfig;
|
|
|
|
_GLFWwndconfig wndconfig;
|
2010-09-09 16:15:32 +00:00
|
|
|
_GLFWwindow* window;
|
2012-08-10 13:29:45 +00:00
|
|
|
_GLFWwindow* previous;
|
2010-09-07 15:34:51 +00:00
|
|
|
|
2013-02-19 23:28:08 +00:00
|
|
|
_GLFW_REQUIRE_INIT_OR_RETURN(NULL);
|
2010-09-09 19:34:42 +00:00
|
|
|
|
2013-01-04 06:28:12 +00:00
|
|
|
if (width <= 0 || height <= 0)
|
|
|
|
{
|
|
|
|
_glfwInputError(GLFW_INVALID_VALUE, "Invalid window size");
|
2013-07-30 12:19:24 +00:00
|
|
|
return NULL;
|
2013-01-04 06:28:12 +00:00
|
|
|
}
|
2010-09-09 16:15:32 +00:00
|
|
|
|
2010-09-07 15:34:51 +00:00
|
|
|
// Set up desired framebuffer config
|
2013-01-02 00:40:42 +00:00
|
|
|
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;
|
2010-09-07 15:34:51 +00:00
|
|
|
|
|
|
|
// Set up desired window config
|
2012-11-25 13:53:33 +00:00
|
|
|
wndconfig.width = width;
|
|
|
|
wndconfig.height = height;
|
2012-12-31 01:06:19 +00:00
|
|
|
wndconfig.title = title;
|
2013-01-02 00:40:42 +00:00
|
|
|
wndconfig.resizable = _glfw.hints.resizable ? GL_TRUE : GL_FALSE;
|
|
|
|
wndconfig.visible = _glfw.hints.visible ? GL_TRUE : GL_FALSE;
|
2013-04-08 13:16:32 +00:00
|
|
|
wndconfig.decorated = _glfw.hints.decorated ? GL_TRUE : GL_FALSE;
|
2013-01-02 00:40:42 +00:00
|
|
|
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;
|
2012-12-31 01:06:19 +00:00
|
|
|
wndconfig.monitor = (_GLFWmonitor*) monitor;
|
|
|
|
wndconfig.share = (_GLFWwindow*) share;
|
2010-09-07 15:34:51 +00:00
|
|
|
|
2011-03-04 14:00:19 +00:00
|
|
|
// Check the OpenGL bits of the window config
|
2011-03-07 13:55:11 +00:00
|
|
|
if (!_glfwIsValidContextConfig(&wndconfig))
|
2013-07-30 12:19:24 +00:00
|
|
|
return NULL;
|
2010-09-07 15:34:51 +00:00
|
|
|
|
2013-07-04 12:54:07 +00:00
|
|
|
window = calloc(1, sizeof(_GLFWwindow));
|
2013-01-02 00:40:42 +00:00
|
|
|
window->next = _glfw.windowListHead;
|
|
|
|
_glfw.windowListHead = window;
|
2011-03-07 13:30:23 +00:00
|
|
|
|
2013-01-17 19:18:17 +00:00
|
|
|
if (wndconfig.monitor)
|
2013-01-02 16:29:24 +00:00
|
|
|
{
|
2013-01-31 07:36:06 +00:00
|
|
|
wndconfig.resizable = GL_TRUE;
|
|
|
|
wndconfig.visible = GL_TRUE;
|
2013-01-17 19:18:17 +00:00
|
|
|
|
2013-05-30 18:42:50 +00:00
|
|
|
// Set up desired video mode
|
|
|
|
window->videoMode.width = width;
|
|
|
|
window->videoMode.height = height;
|
|
|
|
window->videoMode.redBits = Max(_glfw.hints.redBits, 0);
|
|
|
|
window->videoMode.greenBits = Max(_glfw.hints.greenBits, 0);
|
|
|
|
window->videoMode.blueBits = Max(_glfw.hints.blueBits, 0);
|
|
|
|
window->videoMode.refreshRate = Max(_glfw.hints.refreshRate, 0);
|
2013-01-02 16:29:24 +00:00
|
|
|
}
|
2013-01-31 07:36:06 +00:00
|
|
|
|
2013-04-08 01:07:52 +00:00
|
|
|
window->monitor = wndconfig.monitor;
|
|
|
|
window->resizable = wndconfig.resizable;
|
2013-04-08 13:16:32 +00:00
|
|
|
window->decorated = wndconfig.decorated;
|
2013-04-08 01:07:52 +00:00
|
|
|
window->cursorMode = GLFW_CURSOR_NORMAL;
|
2010-09-07 15:34:51 +00:00
|
|
|
|
2013-01-04 06:28:12 +00:00
|
|
|
// Save the currently current context so it can be restored later
|
2013-01-05 20:13:28 +00:00
|
|
|
previous = (_GLFWwindow*) glfwGetCurrentContext();
|
2013-01-04 06:28:12 +00:00
|
|
|
|
2011-03-04 16:49:36 +00:00
|
|
|
// Open the actual window and create its context
|
2012-08-06 15:56:41 +00:00
|
|
|
if (!_glfwPlatformCreateWindow(window, &wndconfig, &fbconfig))
|
2010-09-09 16:15:32 +00:00
|
|
|
{
|
2013-01-05 20:13:28 +00:00
|
|
|
glfwDestroyWindow((GLFWwindow*) window);
|
|
|
|
glfwMakeContextCurrent((GLFWwindow*) previous);
|
2013-07-30 12:19:24 +00:00
|
|
|
return NULL;
|
2010-09-09 16:15:32 +00:00
|
|
|
}
|
2010-09-07 15:34:51 +00:00
|
|
|
|
2013-01-05 20:13:28 +00:00
|
|
|
glfwMakeContextCurrent((GLFWwindow*) window);
|
2012-09-23 12:08:36 +00:00
|
|
|
|
2013-05-27 13:30:32 +00:00
|
|
|
// Retrieve the actual (as opposed to requested) context attributes
|
|
|
|
if (!_glfwRefreshContextAttribs())
|
2012-08-02 12:42:24 +00:00
|
|
|
{
|
2013-01-05 20:13:28 +00:00
|
|
|
glfwDestroyWindow((GLFWwindow*) window);
|
|
|
|
glfwMakeContextCurrent((GLFWwindow*) previous);
|
2013-07-30 12:19:24 +00:00
|
|
|
return NULL;
|
2012-08-02 12:42:24 +00:00
|
|
|
}
|
|
|
|
|
2012-08-03 13:21:49 +00:00
|
|
|
// Verify the context against the requested parameters
|
2012-08-02 12:42:24 +00:00
|
|
|
if (!_glfwIsValidContext(&wndconfig))
|
2010-09-07 15:34:51 +00:00
|
|
|
{
|
2013-01-05 20:13:28 +00:00
|
|
|
glfwDestroyWindow((GLFWwindow*) window);
|
|
|
|
glfwMakeContextCurrent((GLFWwindow*) previous);
|
2013-07-30 12:19:24 +00:00
|
|
|
return NULL;
|
2010-09-07 15:34:51 +00:00
|
|
|
}
|
|
|
|
|
2012-09-23 12:08:36 +00:00
|
|
|
// 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(window);
|
|
|
|
|
2012-08-10 13:29:45 +00:00
|
|
|
// Restore the previously current context (or NULL)
|
2013-01-05 20:13:28 +00:00
|
|
|
glfwMakeContextCurrent((GLFWwindow*) previous);
|
2012-08-10 13:29:45 +00:00
|
|
|
|
2012-09-27 19:37:36 +00:00
|
|
|
if (wndconfig.monitor == NULL && wndconfig.visible)
|
2013-01-05 20:13:28 +00:00
|
|
|
glfwShowWindow((GLFWwindow*) window);
|
2012-08-21 19:18:09 +00:00
|
|
|
|
2013-01-05 20:13:28 +00:00
|
|
|
return (GLFWwindow*) window;
|
2010-09-09 16:15:32 +00:00
|
|
|
}
|
|
|
|
|
2012-10-22 00:59:05 +00:00
|
|
|
void glfwDefaultWindowHints(void)
|
|
|
|
{
|
2013-02-19 23:28:08 +00:00
|
|
|
_GLFW_REQUIRE_INIT();
|
2012-10-22 00:59:05 +00:00
|
|
|
|
2013-01-02 00:40:42 +00:00
|
|
|
memset(&_glfw.hints, 0, sizeof(_glfw.hints));
|
2012-10-22 00:59:05 +00:00
|
|
|
|
|
|
|
// The default is OpenGL with minimum version 1.0
|
2013-01-02 00:40:42 +00:00
|
|
|
_glfw.hints.clientAPI = GLFW_OPENGL_API;
|
|
|
|
_glfw.hints.glMajor = 1;
|
|
|
|
_glfw.hints.glMinor = 0;
|
2012-10-22 00:59:05 +00:00
|
|
|
|
2013-04-08 13:16:32 +00:00
|
|
|
// The default is a visible, resizable window with decorations
|
2013-01-02 00:40:42 +00:00
|
|
|
_glfw.hints.resizable = GL_TRUE;
|
|
|
|
_glfw.hints.visible = GL_TRUE;
|
2013-04-08 13:16:32 +00:00
|
|
|
_glfw.hints.decorated = GL_TRUE;
|
2012-10-22 00:59:05 +00:00
|
|
|
|
|
|
|
// The default is 24 bits of color, 24 bits of depth and 8 bits of stencil
|
2013-01-02 00:40:42 +00:00
|
|
|
_glfw.hints.redBits = 8;
|
|
|
|
_glfw.hints.greenBits = 8;
|
|
|
|
_glfw.hints.blueBits = 8;
|
2013-06-17 15:42:22 +00:00
|
|
|
_glfw.hints.alphaBits = 8;
|
2013-01-02 00:40:42 +00:00
|
|
|
_glfw.hints.depthBits = 24;
|
|
|
|
_glfw.hints.stencilBits = 8;
|
2012-10-22 00:59:05 +00:00
|
|
|
}
|
|
|
|
|
2012-08-06 15:56:41 +00:00
|
|
|
GLFWAPI void glfwWindowHint(int target, int hint)
|
2010-09-07 15:34:51 +00:00
|
|
|
{
|
2013-02-19 23:28:08 +00:00
|
|
|
_GLFW_REQUIRE_INIT();
|
2010-09-07 15:34:51 +00:00
|
|
|
|
2010-09-08 12:45:52 +00:00
|
|
|
switch (target)
|
2010-09-07 15:34:51 +00:00
|
|
|
{
|
2010-09-09 17:58:51 +00:00
|
|
|
case GLFW_RED_BITS:
|
2013-01-02 00:40:42 +00:00
|
|
|
_glfw.hints.redBits = hint;
|
2010-09-09 17:58:51 +00:00
|
|
|
break;
|
|
|
|
case GLFW_GREEN_BITS:
|
2013-01-02 00:40:42 +00:00
|
|
|
_glfw.hints.greenBits = hint;
|
2010-09-09 17:58:51 +00:00
|
|
|
break;
|
|
|
|
case GLFW_BLUE_BITS:
|
2013-01-02 00:40:42 +00:00
|
|
|
_glfw.hints.blueBits = hint;
|
2010-09-09 17:58:51 +00:00
|
|
|
break;
|
|
|
|
case GLFW_ALPHA_BITS:
|
2013-01-02 00:40:42 +00:00
|
|
|
_glfw.hints.alphaBits = hint;
|
2010-09-09 17:58:51 +00:00
|
|
|
break;
|
|
|
|
case GLFW_DEPTH_BITS:
|
2013-01-02 00:40:42 +00:00
|
|
|
_glfw.hints.depthBits = hint;
|
2010-09-09 17:58:51 +00:00
|
|
|
break;
|
|
|
|
case GLFW_STENCIL_BITS:
|
2013-01-02 00:40:42 +00:00
|
|
|
_glfw.hints.stencilBits = hint;
|
2010-09-09 17:58:51 +00:00
|
|
|
break;
|
2010-09-07 15:34:51 +00:00
|
|
|
case GLFW_ACCUM_RED_BITS:
|
2013-01-02 00:40:42 +00:00
|
|
|
_glfw.hints.accumRedBits = hint;
|
2010-09-07 15:34:51 +00:00
|
|
|
break;
|
|
|
|
case GLFW_ACCUM_GREEN_BITS:
|
2013-01-02 00:40:42 +00:00
|
|
|
_glfw.hints.accumGreenBits = hint;
|
2010-09-07 15:34:51 +00:00
|
|
|
break;
|
|
|
|
case GLFW_ACCUM_BLUE_BITS:
|
2013-01-02 00:40:42 +00:00
|
|
|
_glfw.hints.accumBlueBits = hint;
|
2010-09-07 15:34:51 +00:00
|
|
|
break;
|
|
|
|
case GLFW_ACCUM_ALPHA_BITS:
|
2013-01-02 00:40:42 +00:00
|
|
|
_glfw.hints.accumAlphaBits = hint;
|
2010-09-07 15:34:51 +00:00
|
|
|
break;
|
|
|
|
case GLFW_AUX_BUFFERS:
|
2013-01-02 00:40:42 +00:00
|
|
|
_glfw.hints.auxBuffers = hint;
|
2010-09-07 15:34:51 +00:00
|
|
|
break;
|
|
|
|
case GLFW_STEREO:
|
2013-01-02 00:40:42 +00:00
|
|
|
_glfw.hints.stereo = hint;
|
2010-09-07 15:34:51 +00:00
|
|
|
break;
|
2013-05-30 18:42:50 +00:00
|
|
|
case GLFW_REFRESH_RATE:
|
|
|
|
_glfw.hints.refreshRate = hint;
|
|
|
|
break;
|
2012-08-21 18:28:36 +00:00
|
|
|
case GLFW_RESIZABLE:
|
2013-01-02 00:40:42 +00:00
|
|
|
_glfw.hints.resizable = hint;
|
2010-09-07 15:34:51 +00:00
|
|
|
break;
|
2013-04-08 13:16:32 +00:00
|
|
|
case GLFW_DECORATED:
|
|
|
|
_glfw.hints.decorated = hint;
|
2013-04-08 01:07:52 +00:00
|
|
|
break;
|
2012-08-21 19:18:09 +00:00
|
|
|
case GLFW_VISIBLE:
|
2013-01-02 00:40:42 +00:00
|
|
|
_glfw.hints.visible = hint;
|
2012-08-21 19:18:09 +00:00
|
|
|
break;
|
2012-12-31 18:45:13 +00:00
|
|
|
case GLFW_SAMPLES:
|
2013-01-02 00:40:42 +00:00
|
|
|
_glfw.hints.samples = hint;
|
2010-09-07 15:34:51 +00:00
|
|
|
break;
|
2012-12-02 15:10:00 +00:00
|
|
|
case GLFW_SRGB_CAPABLE:
|
2013-01-02 00:40:42 +00:00
|
|
|
_glfw.hints.sRGB = hint;
|
2012-12-02 15:10:00 +00:00
|
|
|
break;
|
2012-09-30 13:32:50 +00:00
|
|
|
case GLFW_CLIENT_API:
|
2013-01-02 00:40:42 +00:00
|
|
|
_glfw.hints.clientAPI = hint;
|
2012-09-30 13:32:50 +00:00
|
|
|
break;
|
2012-12-13 01:22:39 +00:00
|
|
|
case GLFW_CONTEXT_VERSION_MAJOR:
|
2013-01-02 00:40:42 +00:00
|
|
|
_glfw.hints.glMajor = hint;
|
2010-09-07 15:34:51 +00:00
|
|
|
break;
|
2012-12-13 01:22:39 +00:00
|
|
|
case GLFW_CONTEXT_VERSION_MINOR:
|
2013-01-02 00:40:42 +00:00
|
|
|
_glfw.hints.glMinor = hint;
|
2010-09-07 15:34:51 +00:00
|
|
|
break;
|
2012-12-13 01:22:39 +00:00
|
|
|
case GLFW_CONTEXT_ROBUSTNESS:
|
2013-01-02 00:40:42 +00:00
|
|
|
_glfw.hints.glRobustness = hint;
|
2012-12-13 01:22:39 +00:00
|
|
|
break;
|
2010-09-07 15:34:51 +00:00
|
|
|
case GLFW_OPENGL_FORWARD_COMPAT:
|
2013-01-02 00:40:42 +00:00
|
|
|
_glfw.hints.glForward = hint;
|
2010-09-07 15:34:51 +00:00
|
|
|
break;
|
|
|
|
case GLFW_OPENGL_DEBUG_CONTEXT:
|
2013-01-02 00:40:42 +00:00
|
|
|
_glfw.hints.glDebug = hint;
|
2010-09-07 15:34:51 +00:00
|
|
|
break;
|
|
|
|
case GLFW_OPENGL_PROFILE:
|
2013-01-02 00:40:42 +00:00
|
|
|
_glfw.hints.glProfile = hint;
|
2010-09-07 15:34:51 +00:00
|
|
|
break;
|
|
|
|
default:
|
2012-12-31 20:05:28 +00:00
|
|
|
_glfwInputError(GLFW_INVALID_ENUM, NULL);
|
2010-09-07 15:34:51 +00:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2013-01-05 20:13:28 +00:00
|
|
|
GLFWAPI void glfwDestroyWindow(GLFWwindow* handle)
|
2010-09-07 15:34:51 +00:00
|
|
|
{
|
2011-04-06 18:38:55 +00:00
|
|
|
_GLFWwindow* window = (_GLFWwindow*) handle;
|
|
|
|
|
2013-02-19 23:28:08 +00:00
|
|
|
_GLFW_REQUIRE_INIT();
|
2010-09-07 15:34:51 +00:00
|
|
|
|
2011-03-08 22:14:42 +00:00
|
|
|
// Allow closing of NULL (to match the behavior of free)
|
|
|
|
if (window == NULL)
|
|
|
|
return;
|
|
|
|
|
2012-12-23 15:08:17 +00:00
|
|
|
// Clear all callbacks to avoid exposing a half torn-down window object
|
2013-01-15 20:34:26 +00:00
|
|
|
memset(&window->callbacks, 0, sizeof(window->callbacks));
|
2012-12-23 15:08:17 +00:00
|
|
|
|
2012-10-21 19:57:29 +00:00
|
|
|
// The window's context must not be current on another thread when the
|
|
|
|
// window is destroyed
|
2012-08-12 12:13:18 +00:00
|
|
|
if (window == _glfwPlatformGetCurrentContext())
|
|
|
|
_glfwPlatformMakeContextCurrent(NULL);
|
2010-09-07 15:34:51 +00:00
|
|
|
|
2012-11-22 16:04:44 +00:00
|
|
|
// Clear the focused window pointer if this is the focused window
|
2013-01-02 00:40:42 +00:00
|
|
|
if (window == _glfw.focusedWindow)
|
|
|
|
_glfw.focusedWindow = NULL;
|
2010-09-11 13:14:57 +00:00
|
|
|
|
2012-08-06 15:56:41 +00:00
|
|
|
_glfwPlatformDestroyWindow(window);
|
2010-09-09 16:15:32 +00:00
|
|
|
|
2010-09-16 00:05:01 +00:00
|
|
|
// Unlink window from global linked list
|
|
|
|
{
|
2013-01-02 00:40:42 +00:00
|
|
|
_GLFWwindow** prev = &_glfw.windowListHead;
|
2010-09-16 00:05:01 +00:00
|
|
|
|
|
|
|
while (*prev != window)
|
|
|
|
prev = &((*prev)->next);
|
2010-09-09 22:06:23 +00:00
|
|
|
|
2010-09-16 00:05:01 +00:00
|
|
|
*prev = window->next;
|
|
|
|
}
|
2010-09-09 22:30:10 +00:00
|
|
|
|
2012-02-07 13:58:58 +00:00
|
|
|
free(window);
|
2010-09-07 15:34:51 +00:00
|
|
|
}
|
|
|
|
|
2013-03-01 12:45:12 +00:00
|
|
|
GLFWAPI int glfwWindowShouldClose(GLFWwindow* handle)
|
|
|
|
{
|
|
|
|
_GLFWwindow* window = (_GLFWwindow*) handle;
|
|
|
|
_GLFW_REQUIRE_INIT_OR_RETURN(0);
|
|
|
|
return window->closed;
|
|
|
|
}
|
|
|
|
|
|
|
|
GLFWAPI void glfwSetWindowShouldClose(GLFWwindow* handle, int value)
|
|
|
|
{
|
|
|
|
_GLFWwindow* window = (_GLFWwindow*) handle;
|
|
|
|
_GLFW_REQUIRE_INIT();
|
|
|
|
window->closed = value;
|
|
|
|
}
|
|
|
|
|
2013-01-05 20:13:28 +00:00
|
|
|
GLFWAPI void glfwSetWindowTitle(GLFWwindow* handle, const char* title)
|
2010-09-07 15:34:51 +00:00
|
|
|
{
|
2011-04-06 18:38:55 +00:00
|
|
|
_GLFWwindow* window = (_GLFWwindow*) handle;
|
2013-02-19 23:28:08 +00:00
|
|
|
_GLFW_REQUIRE_INIT();
|
2010-09-09 16:15:32 +00:00
|
|
|
_glfwPlatformSetWindowTitle(window, title);
|
2010-09-07 15:34:51 +00:00
|
|
|
}
|
|
|
|
|
2013-01-24 18:30:31 +00:00
|
|
|
GLFWAPI void glfwGetWindowPos(GLFWwindow* handle, int* xpos, int* ypos)
|
|
|
|
{
|
|
|
|
_GLFWwindow* window = (_GLFWwindow*) handle;
|
2013-02-19 23:28:08 +00:00
|
|
|
_GLFW_REQUIRE_INIT();
|
2013-01-24 18:30:31 +00:00
|
|
|
_glfwPlatformGetWindowPos(window, xpos, ypos);
|
|
|
|
}
|
|
|
|
|
|
|
|
GLFWAPI void glfwSetWindowPos(GLFWwindow* handle, int xpos, int ypos)
|
|
|
|
{
|
|
|
|
_GLFWwindow* window = (_GLFWwindow*) handle;
|
|
|
|
|
2013-02-19 23:28:08 +00:00
|
|
|
_GLFW_REQUIRE_INIT();
|
2013-01-24 18:30:31 +00:00
|
|
|
|
|
|
|
if (window->monitor)
|
|
|
|
{
|
|
|
|
_glfwInputError(GLFW_INVALID_VALUE,
|
|
|
|
"Fullscreen windows cannot be positioned");
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
_glfwPlatformSetWindowPos(window, xpos, ypos);
|
|
|
|
}
|
|
|
|
|
2013-01-05 20:13:28 +00:00
|
|
|
GLFWAPI void glfwGetWindowSize(GLFWwindow* handle, int* width, int* height)
|
2010-09-07 15:34:51 +00:00
|
|
|
{
|
2011-04-06 18:38:55 +00:00
|
|
|
_GLFWwindow* window = (_GLFWwindow*) handle;
|
2013-02-19 23:28:08 +00:00
|
|
|
_GLFW_REQUIRE_INIT();
|
2012-11-25 13:53:33 +00:00
|
|
|
_glfwPlatformGetWindowSize(window, width, height);
|
2010-09-07 15:34:51 +00:00
|
|
|
}
|
|
|
|
|
2013-01-05 20:13:28 +00:00
|
|
|
GLFWAPI void glfwSetWindowSize(GLFWwindow* handle, int width, int height)
|
2010-09-07 15:34:51 +00:00
|
|
|
{
|
2011-04-06 18:38:55 +00:00
|
|
|
_GLFWwindow* window = (_GLFWwindow*) handle;
|
|
|
|
|
2013-02-19 23:28:08 +00:00
|
|
|
_GLFW_REQUIRE_INIT();
|
2010-09-09 19:34:42 +00:00
|
|
|
|
|
|
|
if (window->iconified)
|
2010-09-07 15:34:51 +00:00
|
|
|
return;
|
|
|
|
|
2013-02-01 07:25:05 +00:00
|
|
|
if (window->monitor)
|
|
|
|
{
|
|
|
|
window->videoMode.width = width;
|
|
|
|
window->videoMode.height = height;
|
|
|
|
}
|
|
|
|
|
2010-09-09 16:15:32 +00:00
|
|
|
_glfwPlatformSetWindowSize(window, width, height);
|
2010-09-07 15:34:51 +00:00
|
|
|
}
|
|
|
|
|
2013-06-03 10:51:57 +00:00
|
|
|
GLFWAPI void glfwGetFramebufferSize(GLFWwindow* handle, int* width, int* height)
|
|
|
|
{
|
|
|
|
_GLFWwindow* window = (_GLFWwindow*) handle;
|
|
|
|
|
|
|
|
_GLFW_REQUIRE_INIT();
|
|
|
|
|
|
|
|
_glfwPlatformGetFramebufferSize(window, width, height);
|
|
|
|
}
|
|
|
|
|
2013-01-05 20:13:28 +00:00
|
|
|
GLFWAPI void glfwIconifyWindow(GLFWwindow* handle)
|
2010-09-07 15:34:51 +00:00
|
|
|
{
|
2011-04-06 18:38:55 +00:00
|
|
|
_GLFWwindow* window = (_GLFWwindow*) handle;
|
|
|
|
|
2013-02-19 23:28:08 +00:00
|
|
|
_GLFW_REQUIRE_INIT();
|
2010-09-09 19:34:42 +00:00
|
|
|
|
|
|
|
if (window->iconified)
|
2010-09-07 15:34:51 +00:00
|
|
|
return;
|
|
|
|
|
2010-09-09 16:15:32 +00:00
|
|
|
_glfwPlatformIconifyWindow(window);
|
2010-09-07 15:34:51 +00:00
|
|
|
}
|
|
|
|
|
2013-01-05 20:13:28 +00:00
|
|
|
GLFWAPI void glfwRestoreWindow(GLFWwindow* handle)
|
2012-08-21 18:01:57 +00:00
|
|
|
{
|
2012-09-11 21:51:45 +00:00
|
|
|
_GLFWwindow* window = (_GLFWwindow*) handle;
|
|
|
|
|
2013-02-19 23:28:08 +00:00
|
|
|
_GLFW_REQUIRE_INIT();
|
2012-08-21 18:01:57 +00:00
|
|
|
|
2012-09-11 21:56:44 +00:00
|
|
|
if (!window->iconified)
|
2012-09-11 21:51:45 +00:00
|
|
|
return;
|
|
|
|
|
2012-09-11 21:56:44 +00:00
|
|
|
_glfwPlatformRestoreWindow(window);
|
2012-08-21 18:01:57 +00:00
|
|
|
}
|
|
|
|
|
2013-01-05 20:13:28 +00:00
|
|
|
GLFWAPI void glfwShowWindow(GLFWwindow* handle)
|
2012-08-21 18:01:57 +00:00
|
|
|
{
|
2012-09-11 21:51:45 +00:00
|
|
|
_GLFWwindow* window = (_GLFWwindow*) handle;
|
|
|
|
|
2013-02-19 23:28:08 +00:00
|
|
|
_GLFW_REQUIRE_INIT();
|
2012-08-21 18:01:57 +00:00
|
|
|
|
2012-09-27 19:37:36 +00:00
|
|
|
if (window->monitor)
|
2012-09-11 21:51:45 +00:00
|
|
|
return;
|
|
|
|
|
2012-09-11 21:56:44 +00:00
|
|
|
_glfwPlatformShowWindow(window);
|
2012-08-21 18:01:57 +00:00
|
|
|
}
|
|
|
|
|
2013-01-05 20:13:28 +00:00
|
|
|
GLFWAPI void glfwHideWindow(GLFWwindow* handle)
|
2010-09-07 15:34:51 +00:00
|
|
|
{
|
2011-04-06 18:38:55 +00:00
|
|
|
_GLFWwindow* window = (_GLFWwindow*) handle;
|
|
|
|
|
2013-02-19 23:28:08 +00:00
|
|
|
_GLFW_REQUIRE_INIT();
|
2010-09-09 19:34:42 +00:00
|
|
|
|
2012-09-27 19:37:36 +00:00
|
|
|
if (window->monitor)
|
2010-09-07 15:34:51 +00:00
|
|
|
return;
|
|
|
|
|
2012-09-11 21:56:44 +00:00
|
|
|
_glfwPlatformHideWindow(window);
|
2010-09-07 15:34:51 +00:00
|
|
|
}
|
|
|
|
|
2013-05-27 13:30:32 +00:00
|
|
|
GLFWAPI int glfwGetWindowAttrib(GLFWwindow* handle, int attrib)
|
2010-09-07 15:34:51 +00:00
|
|
|
{
|
2011-04-06 18:38:55 +00:00
|
|
|
_GLFWwindow* window = (_GLFWwindow*) handle;
|
|
|
|
|
2013-02-19 23:28:08 +00:00
|
|
|
_GLFW_REQUIRE_INIT_OR_RETURN(0);
|
2010-09-07 15:34:51 +00:00
|
|
|
|
2013-05-27 13:30:32 +00:00
|
|
|
switch (attrib)
|
2010-09-07 15:34:51 +00:00
|
|
|
{
|
2012-11-22 16:04:44 +00:00
|
|
|
case GLFW_FOCUSED:
|
2013-01-02 00:40:42 +00:00
|
|
|
return window == _glfw.focusedWindow;
|
2010-09-07 15:34:51 +00:00
|
|
|
case GLFW_ICONIFIED:
|
2010-09-09 16:15:32 +00:00
|
|
|
return window->iconified;
|
2012-08-21 18:28:36 +00:00
|
|
|
case GLFW_RESIZABLE:
|
2011-11-02 15:56:34 +00:00
|
|
|
return window->resizable;
|
2013-04-08 13:16:32 +00:00
|
|
|
case GLFW_DECORATED:
|
|
|
|
return window->decorated;
|
2012-08-21 19:57:13 +00:00
|
|
|
case GLFW_VISIBLE:
|
|
|
|
return window->visible;
|
2012-09-30 13:43:26 +00:00
|
|
|
case GLFW_CLIENT_API:
|
|
|
|
return window->clientAPI;
|
2012-12-13 01:22:39 +00:00
|
|
|
case GLFW_CONTEXT_VERSION_MAJOR:
|
2010-09-09 16:15:32 +00:00
|
|
|
return window->glMajor;
|
2012-12-13 01:22:39 +00:00
|
|
|
case GLFW_CONTEXT_VERSION_MINOR:
|
2010-09-09 16:15:32 +00:00
|
|
|
return window->glMinor;
|
2012-12-13 01:22:39 +00:00
|
|
|
case GLFW_CONTEXT_REVISION:
|
2011-05-21 15:16:32 +00:00
|
|
|
return window->glRevision;
|
2012-12-13 01:22:39 +00:00
|
|
|
case GLFW_CONTEXT_ROBUSTNESS:
|
|
|
|
return window->glRobustness;
|
2010-09-07 15:34:51 +00:00
|
|
|
case GLFW_OPENGL_FORWARD_COMPAT:
|
2010-09-09 16:15:32 +00:00
|
|
|
return window->glForward;
|
2010-09-07 15:34:51 +00:00
|
|
|
case GLFW_OPENGL_DEBUG_CONTEXT:
|
2010-09-09 16:15:32 +00:00
|
|
|
return window->glDebug;
|
2010-09-07 15:34:51 +00:00
|
|
|
case GLFW_OPENGL_PROFILE:
|
2010-09-09 16:15:32 +00:00
|
|
|
return window->glProfile;
|
2010-09-07 15:34:51 +00:00
|
|
|
}
|
2011-10-08 21:41:30 +00:00
|
|
|
|
2012-12-31 20:05:28 +00:00
|
|
|
_glfwInputError(GLFW_INVALID_ENUM, NULL);
|
2011-10-08 21:41:30 +00:00
|
|
|
return 0;
|
2010-09-07 15:34:51 +00:00
|
|
|
}
|
|
|
|
|
2013-01-05 20:13:28 +00:00
|
|
|
GLFWAPI GLFWmonitor* glfwGetWindowMonitor(GLFWwindow* handle)
|
2012-10-02 15:24:18 +00:00
|
|
|
{
|
|
|
|
_GLFWwindow* window = (_GLFWwindow*) handle;
|
2013-02-19 23:28:08 +00:00
|
|
|
_GLFW_REQUIRE_INIT_OR_RETURN(NULL);
|
2013-01-05 20:13:28 +00:00
|
|
|
return (GLFWmonitor*) window->monitor;
|
2012-10-02 15:24:18 +00:00
|
|
|
}
|
|
|
|
|
2013-01-05 20:13:28 +00:00
|
|
|
GLFWAPI void glfwSetWindowUserPointer(GLFWwindow* handle, void* pointer)
|
2010-09-09 20:44:38 +00:00
|
|
|
{
|
2011-04-06 18:38:55 +00:00
|
|
|
_GLFWwindow* window = (_GLFWwindow*) handle;
|
2013-02-19 23:28:08 +00:00
|
|
|
_GLFW_REQUIRE_INIT();
|
2010-09-09 20:44:38 +00:00
|
|
|
window->userPointer = pointer;
|
|
|
|
}
|
|
|
|
|
2013-01-05 20:13:28 +00:00
|
|
|
GLFWAPI void* glfwGetWindowUserPointer(GLFWwindow* handle)
|
2010-09-09 20:44:38 +00:00
|
|
|
{
|
2011-04-06 18:38:55 +00:00
|
|
|
_GLFWwindow* window = (_GLFWwindow*) handle;
|
2013-02-19 23:28:08 +00:00
|
|
|
_GLFW_REQUIRE_INIT_OR_RETURN(NULL);
|
2010-09-09 20:44:38 +00:00
|
|
|
return window->userPointer;
|
|
|
|
}
|
|
|
|
|
2013-04-08 19:21:21 +00:00
|
|
|
GLFWAPI GLFWwindowposfun glfwSetWindowPosCallback(GLFWwindow* handle,
|
|
|
|
GLFWwindowposfun cbfun)
|
2012-11-30 12:56:42 +00:00
|
|
|
{
|
|
|
|
_GLFWwindow* window = (_GLFWwindow*) handle;
|
2013-04-08 19:21:21 +00:00
|
|
|
GLFWwindowposfun previous;
|
|
|
|
|
|
|
|
_GLFW_REQUIRE_INIT_OR_RETURN(NULL);
|
|
|
|
|
|
|
|
previous = window->callbacks.pos;
|
2013-01-15 20:34:26 +00:00
|
|
|
window->callbacks.pos = cbfun;
|
2013-04-08 19:21:21 +00:00
|
|
|
return previous;
|
2012-11-30 12:56:42 +00:00
|
|
|
}
|
|
|
|
|
2013-04-08 19:21:21 +00:00
|
|
|
GLFWAPI GLFWwindowsizefun glfwSetWindowSizeCallback(GLFWwindow* handle,
|
|
|
|
GLFWwindowsizefun cbfun)
|
2010-09-07 15:34:51 +00:00
|
|
|
{
|
2012-10-28 12:45:11 +00:00
|
|
|
_GLFWwindow* window = (_GLFWwindow*) handle;
|
2013-04-08 19:21:21 +00:00
|
|
|
GLFWwindowsizefun previous;
|
|
|
|
|
|
|
|
_GLFW_REQUIRE_INIT_OR_RETURN(NULL);
|
|
|
|
|
|
|
|
previous = window->callbacks.size;
|
2013-01-15 20:34:26 +00:00
|
|
|
window->callbacks.size = cbfun;
|
2013-04-08 19:21:21 +00:00
|
|
|
return previous;
|
2010-09-07 15:34:51 +00:00
|
|
|
}
|
|
|
|
|
2013-04-08 19:21:21 +00:00
|
|
|
GLFWAPI GLFWwindowclosefun glfwSetWindowCloseCallback(GLFWwindow* handle,
|
|
|
|
GLFWwindowclosefun cbfun)
|
2010-09-07 15:34:51 +00:00
|
|
|
{
|
2012-10-28 12:45:11 +00:00
|
|
|
_GLFWwindow* window = (_GLFWwindow*) handle;
|
2013-04-08 19:21:21 +00:00
|
|
|
GLFWwindowclosefun previous;
|
|
|
|
|
|
|
|
_GLFW_REQUIRE_INIT_OR_RETURN(NULL);
|
|
|
|
|
|
|
|
previous = window->callbacks.close;
|
2013-01-15 20:34:26 +00:00
|
|
|
window->callbacks.close = cbfun;
|
2013-04-08 19:21:21 +00:00
|
|
|
return previous;
|
2010-09-07 15:34:51 +00:00
|
|
|
}
|
|
|
|
|
2013-04-08 19:21:21 +00:00
|
|
|
GLFWAPI GLFWwindowrefreshfun glfwSetWindowRefreshCallback(GLFWwindow* handle,
|
|
|
|
GLFWwindowrefreshfun cbfun)
|
2010-09-07 15:34:51 +00:00
|
|
|
{
|
2012-10-28 12:45:11 +00:00
|
|
|
_GLFWwindow* window = (_GLFWwindow*) handle;
|
2013-04-08 19:21:21 +00:00
|
|
|
GLFWwindowrefreshfun previous;
|
|
|
|
|
|
|
|
_GLFW_REQUIRE_INIT_OR_RETURN(NULL);
|
|
|
|
|
|
|
|
previous = window->callbacks.refresh;
|
2013-01-15 20:34:26 +00:00
|
|
|
window->callbacks.refresh = cbfun;
|
2013-04-08 19:21:21 +00:00
|
|
|
return previous;
|
2010-09-07 15:34:51 +00:00
|
|
|
}
|
|
|
|
|
2013-04-08 19:21:21 +00:00
|
|
|
GLFWAPI GLFWwindowfocusfun glfwSetWindowFocusCallback(GLFWwindow* handle,
|
|
|
|
GLFWwindowfocusfun cbfun)
|
2010-09-19 00:49:42 +00:00
|
|
|
{
|
2012-10-28 12:45:11 +00:00
|
|
|
_GLFWwindow* window = (_GLFWwindow*) handle;
|
2013-04-08 19:21:21 +00:00
|
|
|
GLFWwindowfocusfun previous;
|
|
|
|
|
|
|
|
_GLFW_REQUIRE_INIT_OR_RETURN(NULL);
|
|
|
|
|
|
|
|
previous = window->callbacks.focus;
|
2013-01-15 20:34:26 +00:00
|
|
|
window->callbacks.focus = cbfun;
|
2013-04-08 19:21:21 +00:00
|
|
|
return previous;
|
2010-09-19 00:49:42 +00:00
|
|
|
}
|
|
|
|
|
2013-04-08 19:21:21 +00:00
|
|
|
GLFWAPI GLFWwindowiconifyfun glfwSetWindowIconifyCallback(GLFWwindow* handle,
|
|
|
|
GLFWwindowiconifyfun cbfun)
|
2010-09-20 00:22:35 +00:00
|
|
|
{
|
2012-10-28 12:45:11 +00:00
|
|
|
_GLFWwindow* window = (_GLFWwindow*) handle;
|
2013-04-08 19:21:21 +00:00
|
|
|
GLFWwindowiconifyfun previous;
|
|
|
|
|
|
|
|
_GLFW_REQUIRE_INIT_OR_RETURN(NULL);
|
|
|
|
|
|
|
|
previous = window->callbacks.iconify;
|
2013-01-15 20:34:26 +00:00
|
|
|
window->callbacks.iconify = cbfun;
|
2013-04-08 19:21:21 +00:00
|
|
|
return previous;
|
2010-09-20 00:22:35 +00:00
|
|
|
}
|
|
|
|
|
2013-06-03 10:51:57 +00:00
|
|
|
GLFWAPI GLFWframebuffersizefun glfwSetFramebufferSizeCallback(GLFWwindow* handle,
|
|
|
|
GLFWframebuffersizefun cbfun)
|
|
|
|
{
|
|
|
|
_GLFWwindow* window = (_GLFWwindow*) handle;
|
|
|
|
GLFWframebuffersizefun previous;
|
|
|
|
|
|
|
|
_GLFW_REQUIRE_INIT_OR_RETURN(NULL);
|
|
|
|
|
|
|
|
previous = window->callbacks.fbsize;
|
|
|
|
window->callbacks.fbsize = cbfun;
|
|
|
|
return previous;
|
|
|
|
}
|
|
|
|
|
2010-09-08 12:45:52 +00:00
|
|
|
GLFWAPI void glfwPollEvents(void)
|
2010-09-07 15:34:51 +00:00
|
|
|
{
|
2013-02-19 23:28:08 +00:00
|
|
|
_GLFW_REQUIRE_INIT();
|
2010-09-07 15:34:51 +00:00
|
|
|
_glfwPlatformPollEvents();
|
|
|
|
}
|
|
|
|
|
2010-09-08 12:45:52 +00:00
|
|
|
GLFWAPI void glfwWaitEvents(void)
|
2010-09-07 15:34:51 +00:00
|
|
|
{
|
2013-02-19 23:28:08 +00:00
|
|
|
_GLFW_REQUIRE_INIT();
|
2010-09-07 15:34:51 +00:00
|
|
|
_glfwPlatformWaitEvents();
|
|
|
|
}
|
|
|
|
|