2010-09-07 11:34:51 -04:00
|
|
|
//========================================================================
|
2016-08-18 17:42:15 -04:00
|
|
|
// GLFW 3.3 - www.glfw.org
|
2010-09-07 11:34:51 -04:00
|
|
|
//------------------------------------------------------------------------
|
|
|
|
// Copyright (c) 2002-2006 Marcus Geelnard
|
2016-11-21 10:23:59 -05:00
|
|
|
// Copyright (c) 2006-2016 Camilla Löwy <elmindreda@glfw.org>
|
2012-08-14 17:34:26 -04:00
|
|
|
// Copyright (c) 2012 Torsten Walluhn <tw@mad-cad.net>
|
2010-09-07 11:34:51 -04: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"
|
|
|
|
|
2016-01-31 11:56:36 -05:00
|
|
|
#include <assert.h>
|
2010-09-08 11:01:39 -04:00
|
|
|
#include <string.h>
|
2010-09-09 12:15:32 -04:00
|
|
|
#include <stdlib.h>
|
2016-02-02 15:11:16 -05:00
|
|
|
#include <float.h>
|
2010-09-07 11:34:51 -04:00
|
|
|
|
|
|
|
|
2010-09-09 14:59:50 -04:00
|
|
|
//////////////////////////////////////////////////////////////////////////
|
2013-01-23 13:47:05 -05:00
|
|
|
////// GLFW event API //////
|
2010-09-09 14:59:50 -04:00
|
|
|
//////////////////////////////////////////////////////////////////////////
|
|
|
|
|
2015-08-23 13:30:04 -04:00
|
|
|
void _glfwInputWindowFocus(_GLFWwindow* window, GLFWbool focused)
|
2010-09-18 20:49:42 -04:00
|
|
|
{
|
2017-01-29 10:17:05 -05:00
|
|
|
if (window->callbacks.focus)
|
|
|
|
window->callbacks.focus((GLFWwindow*) window, focused);
|
2014-04-08 09:50:27 -04:00
|
|
|
|
2017-01-29 10:17:05 -05:00
|
|
|
if (!focused)
|
|
|
|
{
|
|
|
|
int key, button;
|
2014-04-08 09:50:27 -04:00
|
|
|
|
2017-01-29 10:17:05 -05:00
|
|
|
for (key = 0; key <= GLFW_KEY_LAST; key++)
|
2014-04-08 09:50:27 -04:00
|
|
|
{
|
2017-01-29 10:17:05 -05:00
|
|
|
if (window->keys[key] == GLFW_PRESS)
|
2017-01-29 10:18:58 -05:00
|
|
|
{
|
|
|
|
const int scancode = _glfwPlatformGetKeyScancode(key);
|
|
|
|
_glfwInputKey(window, key, scancode, GLFW_RELEASE, 0);
|
|
|
|
}
|
2014-04-08 09:50:27 -04:00
|
|
|
}
|
|
|
|
|
2017-01-29 10:17:05 -05:00
|
|
|
for (button = 0; button <= GLFW_MOUSE_BUTTON_LAST; button++)
|
2012-09-16 06:42:51 -04:00
|
|
|
{
|
2017-01-29 10:17:05 -05:00
|
|
|
if (window->mouseButtons[button] == GLFW_PRESS)
|
|
|
|
_glfwInputMouseClick(window, button, GLFW_RELEASE, 0);
|
2012-09-16 06:42:51 -04:00
|
|
|
}
|
2010-09-18 20:49:42 -04:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2011-10-09 11:10:40 -04:00
|
|
|
void _glfwInputWindowPos(_GLFWwindow* window, int x, int y)
|
|
|
|
{
|
2013-01-15 15:34:26 -05:00
|
|
|
if (window->callbacks.pos)
|
|
|
|
window->callbacks.pos((GLFWwindow*) window, x, y);
|
2011-10-09 11:10:40 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
void _glfwInputWindowSize(_GLFWwindow* window, int width, int height)
|
|
|
|
{
|
2013-01-15 15:34:26 -05:00
|
|
|
if (window->callbacks.size)
|
|
|
|
window->callbacks.size((GLFWwindow*) window, width, height);
|
2011-10-09 11:10:40 -04:00
|
|
|
}
|
|
|
|
|
2015-11-05 02:58:40 -05:00
|
|
|
void _glfwInputWindowIconify(_GLFWwindow* window, GLFWbool iconified)
|
2011-10-09 11:10:40 -04:00
|
|
|
{
|
2013-01-15 15:34:26 -05:00
|
|
|
if (window->callbacks.iconify)
|
|
|
|
window->callbacks.iconify((GLFWwindow*) window, iconified);
|
2011-10-09 11:10:40 -04:00
|
|
|
}
|
|
|
|
|
2016-06-16 07:09:28 -04:00
|
|
|
void _glfwInputWindowMaximize(_GLFWwindow* window, GLFWbool maximized)
|
|
|
|
{
|
|
|
|
if (window->callbacks.maximize)
|
|
|
|
window->callbacks.maximize((GLFWwindow*) window, maximized);
|
|
|
|
}
|
|
|
|
|
2013-06-03 06:51:57 -04:00
|
|
|
void _glfwInputFramebufferSize(_GLFWwindow* window, int width, int height)
|
|
|
|
{
|
|
|
|
if (window->callbacks.fbsize)
|
|
|
|
window->callbacks.fbsize((GLFWwindow*) window, width, height);
|
|
|
|
}
|
|
|
|
|
2011-10-09 15:12:13 -04:00
|
|
|
void _glfwInputWindowDamage(_GLFWwindow* window)
|
|
|
|
{
|
2013-01-15 15:34:26 -05:00
|
|
|
if (window->callbacks.refresh)
|
|
|
|
window->callbacks.refresh((GLFWwindow*) window);
|
2011-10-09 15:12:13 -04:00
|
|
|
}
|
|
|
|
|
2012-08-10 07:31:15 -04:00
|
|
|
void _glfwInputWindowCloseRequest(_GLFWwindow* window)
|
|
|
|
{
|
2016-12-08 08:53:01 -05:00
|
|
|
window->shouldClose = GLFW_TRUE;
|
2013-03-06 17:29:37 -05:00
|
|
|
|
2013-01-15 15:34:26 -05:00
|
|
|
if (window->callbacks.close)
|
2013-03-06 17:29:37 -05:00
|
|
|
window->callbacks.close((GLFWwindow*) window);
|
2012-08-10 07:31:15 -04:00
|
|
|
}
|
|
|
|
|
2016-02-23 06:26:42 -05:00
|
|
|
void _glfwInputWindowMonitorChange(_GLFWwindow* window, _GLFWmonitor* monitor)
|
|
|
|
{
|
|
|
|
window->monitor = monitor;
|
|
|
|
}
|
|
|
|
|
2012-08-10 07:31:15 -04:00
|
|
|
|
2010-09-09 14:59:50 -04:00
|
|
|
//////////////////////////////////////////////////////////////////////////
|
|
|
|
////// GLFW public API //////
|
|
|
|
//////////////////////////////////////////////////////////////////////////
|
2010-09-07 11:34:51 -04:00
|
|
|
|
2013-01-05 15:13:28 -05:00
|
|
|
GLFWAPI GLFWwindow* glfwCreateWindow(int width, int height,
|
|
|
|
const char* title,
|
|
|
|
GLFWmonitor* monitor,
|
|
|
|
GLFWwindow* share)
|
2010-09-07 11:34:51 -04:00
|
|
|
{
|
|
|
|
_GLFWfbconfig fbconfig;
|
2014-03-06 14:05:32 -05:00
|
|
|
_GLFWctxconfig ctxconfig;
|
2010-09-07 11:34:51 -04:00
|
|
|
_GLFWwndconfig wndconfig;
|
2010-09-09 12:15:32 -04:00
|
|
|
_GLFWwindow* window;
|
2012-08-10 09:29:45 -04:00
|
|
|
_GLFWwindow* previous;
|
2010-09-07 11:34:51 -04:00
|
|
|
|
2016-03-02 11:58:05 -05:00
|
|
|
assert(title != NULL);
|
2017-02-23 11:47:41 -05:00
|
|
|
assert(width >= 0);
|
|
|
|
assert(height >= 0);
|
2016-01-31 11:56:36 -05:00
|
|
|
|
2013-02-19 18:28:08 -05:00
|
|
|
_GLFW_REQUIRE_INIT_OR_RETURN(NULL);
|
2010-09-09 15:34:42 -04:00
|
|
|
|
2013-01-04 01:28:12 -05:00
|
|
|
if (width <= 0 || height <= 0)
|
|
|
|
{
|
2016-03-29 04:49:34 -04:00
|
|
|
_glfwInputError(GLFW_INVALID_VALUE,
|
|
|
|
"Invalid window size %ix%i",
|
|
|
|
width, height);
|
|
|
|
|
2013-07-30 08:19:24 -04:00
|
|
|
return NULL;
|
2013-01-04 01:28:12 -05:00
|
|
|
}
|
2010-09-09 12:15:32 -04:00
|
|
|
|
2015-06-07 12:14:07 -04:00
|
|
|
fbconfig = _glfw.hints.framebuffer;
|
|
|
|
ctxconfig = _glfw.hints.context;
|
|
|
|
wndconfig = _glfw.hints.window;
|
|
|
|
|
|
|
|
wndconfig.width = width;
|
|
|
|
wndconfig.height = height;
|
|
|
|
wndconfig.title = title;
|
|
|
|
ctxconfig.share = (_GLFWwindow*) share;
|
2010-09-07 11:34:51 -04:00
|
|
|
|
2015-06-18 08:03:02 -04:00
|
|
|
if (ctxconfig.share)
|
|
|
|
{
|
2016-06-22 08:36:46 -04:00
|
|
|
if (ctxconfig.client == GLFW_NO_API ||
|
|
|
|
ctxconfig.share->context.client == GLFW_NO_API)
|
2015-06-18 08:03:02 -04:00
|
|
|
{
|
|
|
|
_glfwInputError(GLFW_NO_WINDOW_CONTEXT, NULL);
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2014-03-06 14:05:32 -05:00
|
|
|
if (!_glfwIsValidContextConfig(&ctxconfig))
|
2013-07-30 08:19:24 -04:00
|
|
|
return NULL;
|
2010-09-07 11:34:51 -04:00
|
|
|
|
2013-07-04 08:54:07 -04:00
|
|
|
window = calloc(1, sizeof(_GLFWwindow));
|
2013-01-01 19:40:42 -05:00
|
|
|
window->next = _glfw.windowListHead;
|
|
|
|
_glfw.windowListHead = window;
|
2011-03-07 08:30:23 -05:00
|
|
|
|
2015-06-07 12:14:07 -04:00
|
|
|
window->videoMode.width = width;
|
|
|
|
window->videoMode.height = height;
|
|
|
|
window->videoMode.redBits = fbconfig.redBits;
|
|
|
|
window->videoMode.greenBits = fbconfig.greenBits;
|
|
|
|
window->videoMode.blueBits = fbconfig.blueBits;
|
|
|
|
window->videoMode.refreshRate = _glfw.hints.refreshRate;
|
|
|
|
|
2016-03-14 10:17:28 -04:00
|
|
|
window->monitor = (_GLFWmonitor*) monitor;
|
2014-04-08 09:32:34 -04:00
|
|
|
window->resizable = wndconfig.resizable;
|
|
|
|
window->decorated = wndconfig.decorated;
|
|
|
|
window->autoIconify = wndconfig.autoIconify;
|
2014-05-23 08:01:02 -04:00
|
|
|
window->floating = wndconfig.floating;
|
2014-04-08 09:32:34 -04:00
|
|
|
window->cursorMode = GLFW_CURSOR_NORMAL;
|
2010-09-07 11:34:51 -04:00
|
|
|
|
2016-02-23 06:26:42 -05:00
|
|
|
window->minwidth = GLFW_DONT_CARE;
|
|
|
|
window->minheight = GLFW_DONT_CARE;
|
|
|
|
window->maxwidth = GLFW_DONT_CARE;
|
|
|
|
window->maxheight = GLFW_DONT_CARE;
|
|
|
|
window->numer = GLFW_DONT_CARE;
|
|
|
|
window->denom = GLFW_DONT_CARE;
|
|
|
|
|
2013-01-04 01:28:12 -05:00
|
|
|
// Save the currently current context so it can be restored later
|
2017-03-08 07:58:09 -05:00
|
|
|
previous = _glfwPlatformGetTls(&_glfw.context);
|
2016-03-28 07:19:31 -04:00
|
|
|
if (ctxconfig.client != GLFW_NO_API)
|
|
|
|
glfwMakeContextCurrent(NULL);
|
2013-01-04 01:28:12 -05:00
|
|
|
|
2011-03-04 11:49:36 -05:00
|
|
|
// Open the actual window and create its context
|
2014-03-06 14:05:32 -05:00
|
|
|
if (!_glfwPlatformCreateWindow(window, &wndconfig, &ctxconfig, &fbconfig))
|
2010-09-09 12:15:32 -04:00
|
|
|
{
|
2016-03-28 07:19:31 -04:00
|
|
|
glfwMakeContextCurrent((GLFWwindow*) previous);
|
2013-01-05 15:13:28 -05:00
|
|
|
glfwDestroyWindow((GLFWwindow*) window);
|
2013-07-30 08:19:24 -04:00
|
|
|
return NULL;
|
2010-09-09 12:15:32 -04:00
|
|
|
}
|
2010-09-07 11:34:51 -04:00
|
|
|
|
2016-03-28 07:19:31 -04:00
|
|
|
if (ctxconfig.client != GLFW_NO_API)
|
2012-08-02 08:42:24 -04:00
|
|
|
{
|
2016-05-25 08:43:51 -04:00
|
|
|
window->context.makeCurrent(window);
|
2012-08-02 08:42:24 -04:00
|
|
|
|
2015-06-18 08:03:02 -04:00
|
|
|
// Retrieve the actual (as opposed to requested) context attributes
|
|
|
|
if (!_glfwRefreshContextAttribs(&ctxconfig))
|
|
|
|
{
|
2016-03-28 07:19:31 -04:00
|
|
|
glfwMakeContextCurrent((GLFWwindow*) previous);
|
2015-06-18 08:03:02 -04:00
|
|
|
glfwDestroyWindow((GLFWwindow*) window);
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
|
|
|
|
// Restore the previously current context (or NULL)
|
2016-03-28 07:19:31 -04:00
|
|
|
glfwMakeContextCurrent((GLFWwindow*) previous);
|
2010-09-07 11:34:51 -04:00
|
|
|
}
|
|
|
|
|
2016-05-25 08:06:02 -04:00
|
|
|
if (!window->monitor)
|
2014-06-18 11:10:26 -04:00
|
|
|
{
|
|
|
|
if (wndconfig.visible)
|
2014-06-20 07:39:06 -04:00
|
|
|
{
|
2016-02-21 09:42:49 -05:00
|
|
|
_glfwPlatformShowWindow(window);
|
2014-06-20 07:39:06 -04:00
|
|
|
if (wndconfig.focused)
|
2016-02-21 09:42:49 -05:00
|
|
|
_glfwPlatformFocusWindow(window);
|
2014-06-20 07:39:06 -04:00
|
|
|
}
|
2014-06-18 11:10:26 -04:00
|
|
|
}
|
2012-08-21 15:18:09 -04:00
|
|
|
|
2013-01-05 15:13:28 -05:00
|
|
|
return (GLFWwindow*) window;
|
2010-09-09 12:15:32 -04:00
|
|
|
}
|
|
|
|
|
2012-10-21 20:59:05 -04:00
|
|
|
void glfwDefaultWindowHints(void)
|
|
|
|
{
|
2013-02-19 18:28:08 -05:00
|
|
|
_GLFW_REQUIRE_INIT();
|
2012-10-21 20:59:05 -04:00
|
|
|
|
|
|
|
// The default is OpenGL with minimum version 1.0
|
2017-02-14 09:43:31 -05:00
|
|
|
memset(&_glfw.hints.context, 0, sizeof(_glfw.hints.context));
|
2016-03-28 07:19:31 -04:00
|
|
|
_glfw.hints.context.client = GLFW_OPENGL_API;
|
|
|
|
_glfw.hints.context.source = GLFW_NATIVE_CONTEXT_API;
|
|
|
|
_glfw.hints.context.major = 1;
|
|
|
|
_glfw.hints.context.minor = 0;
|
2012-10-21 20:59:05 -04:00
|
|
|
|
2014-06-20 07:39:06 -04:00
|
|
|
// The default is a focused, visible, resizable window with decorations
|
2017-02-14 09:43:31 -05:00
|
|
|
memset(&_glfw.hints.window, 0, sizeof(_glfw.hints.window));
|
2015-08-23 13:30:04 -04:00
|
|
|
_glfw.hints.window.resizable = GLFW_TRUE;
|
|
|
|
_glfw.hints.window.visible = GLFW_TRUE;
|
|
|
|
_glfw.hints.window.decorated = GLFW_TRUE;
|
|
|
|
_glfw.hints.window.focused = GLFW_TRUE;
|
|
|
|
_glfw.hints.window.autoIconify = GLFW_TRUE;
|
2012-10-21 20:59:05 -04:00
|
|
|
|
2014-04-24 13:21:10 -04:00
|
|
|
// The default is 24 bits of color, 24 bits of depth and 8 bits of stencil,
|
|
|
|
// double buffered
|
2017-02-14 09:43:31 -05:00
|
|
|
memset(&_glfw.hints.framebuffer, 0, sizeof(_glfw.hints.framebuffer));
|
2015-06-07 12:14:07 -04:00
|
|
|
_glfw.hints.framebuffer.redBits = 8;
|
|
|
|
_glfw.hints.framebuffer.greenBits = 8;
|
|
|
|
_glfw.hints.framebuffer.blueBits = 8;
|
|
|
|
_glfw.hints.framebuffer.alphaBits = 8;
|
|
|
|
_glfw.hints.framebuffer.depthBits = 24;
|
|
|
|
_glfw.hints.framebuffer.stencilBits = 8;
|
2015-08-23 13:30:04 -04:00
|
|
|
_glfw.hints.framebuffer.doublebuffer = GLFW_TRUE;
|
2015-06-07 12:22:38 -04:00
|
|
|
|
|
|
|
// The default is to select the highest available refresh rate
|
|
|
|
_glfw.hints.refreshRate = GLFW_DONT_CARE;
|
2016-12-06 18:41:54 -05:00
|
|
|
|
|
|
|
// The default is to use full Retina resolution framebuffers
|
|
|
|
_glfw.hints.window.ns.retina = GLFW_TRUE;
|
2012-10-21 20:59:05 -04:00
|
|
|
}
|
|
|
|
|
2016-01-26 21:25:21 -05:00
|
|
|
GLFWAPI void glfwWindowHint(int hint, int value)
|
2010-09-07 11:34:51 -04:00
|
|
|
{
|
2013-02-19 18:28:08 -05:00
|
|
|
_GLFW_REQUIRE_INIT();
|
2010-09-07 11:34:51 -04:00
|
|
|
|
2016-01-26 21:25:21 -05:00
|
|
|
switch (hint)
|
2010-09-07 11:34:51 -04:00
|
|
|
{
|
2010-09-09 13:58:51 -04:00
|
|
|
case GLFW_RED_BITS:
|
2016-01-26 21:25:21 -05:00
|
|
|
_glfw.hints.framebuffer.redBits = value;
|
2010-09-09 13:58:51 -04:00
|
|
|
break;
|
|
|
|
case GLFW_GREEN_BITS:
|
2016-01-26 21:25:21 -05:00
|
|
|
_glfw.hints.framebuffer.greenBits = value;
|
2010-09-09 13:58:51 -04:00
|
|
|
break;
|
|
|
|
case GLFW_BLUE_BITS:
|
2016-01-26 21:25:21 -05:00
|
|
|
_glfw.hints.framebuffer.blueBits = value;
|
2010-09-09 13:58:51 -04:00
|
|
|
break;
|
|
|
|
case GLFW_ALPHA_BITS:
|
2016-01-26 21:25:21 -05:00
|
|
|
_glfw.hints.framebuffer.alphaBits = value;
|
2010-09-09 13:58:51 -04:00
|
|
|
break;
|
|
|
|
case GLFW_DEPTH_BITS:
|
2016-01-26 21:25:21 -05:00
|
|
|
_glfw.hints.framebuffer.depthBits = value;
|
2010-09-09 13:58:51 -04:00
|
|
|
break;
|
|
|
|
case GLFW_STENCIL_BITS:
|
2016-01-26 21:25:21 -05:00
|
|
|
_glfw.hints.framebuffer.stencilBits = value;
|
2010-09-09 13:58:51 -04:00
|
|
|
break;
|
2010-09-07 11:34:51 -04:00
|
|
|
case GLFW_ACCUM_RED_BITS:
|
2016-01-26 21:25:21 -05:00
|
|
|
_glfw.hints.framebuffer.accumRedBits = value;
|
2010-09-07 11:34:51 -04:00
|
|
|
break;
|
|
|
|
case GLFW_ACCUM_GREEN_BITS:
|
2016-01-26 21:25:21 -05:00
|
|
|
_glfw.hints.framebuffer.accumGreenBits = value;
|
2010-09-07 11:34:51 -04:00
|
|
|
break;
|
|
|
|
case GLFW_ACCUM_BLUE_BITS:
|
2016-01-26 21:25:21 -05:00
|
|
|
_glfw.hints.framebuffer.accumBlueBits = value;
|
2010-09-07 11:34:51 -04:00
|
|
|
break;
|
|
|
|
case GLFW_ACCUM_ALPHA_BITS:
|
2016-01-26 21:25:21 -05:00
|
|
|
_glfw.hints.framebuffer.accumAlphaBits = value;
|
2010-09-07 11:34:51 -04:00
|
|
|
break;
|
|
|
|
case GLFW_AUX_BUFFERS:
|
2016-01-26 21:25:21 -05:00
|
|
|
_glfw.hints.framebuffer.auxBuffers = value;
|
2010-09-07 11:34:51 -04:00
|
|
|
break;
|
|
|
|
case GLFW_STEREO:
|
2016-01-26 21:25:21 -05:00
|
|
|
_glfw.hints.framebuffer.stereo = value ? GLFW_TRUE : GLFW_FALSE;
|
2010-09-07 11:34:51 -04:00
|
|
|
break;
|
2014-04-24 13:21:10 -04:00
|
|
|
case GLFW_DOUBLEBUFFER:
|
2016-01-26 21:25:21 -05:00
|
|
|
_glfw.hints.framebuffer.doublebuffer = value ? GLFW_TRUE : GLFW_FALSE;
|
2014-04-24 13:21:10 -04:00
|
|
|
break;
|
2015-06-07 12:22:38 -04:00
|
|
|
case GLFW_SAMPLES:
|
2016-01-26 21:25:21 -05:00
|
|
|
_glfw.hints.framebuffer.samples = value;
|
2015-06-07 12:22:38 -04:00
|
|
|
break;
|
|
|
|
case GLFW_SRGB_CAPABLE:
|
2016-01-26 21:25:21 -05:00
|
|
|
_glfw.hints.framebuffer.sRGB = value ? GLFW_TRUE : GLFW_FALSE;
|
2015-06-07 12:22:38 -04:00
|
|
|
break;
|
2012-08-21 14:28:36 -04:00
|
|
|
case GLFW_RESIZABLE:
|
2016-01-26 21:25:21 -05:00
|
|
|
_glfw.hints.window.resizable = value ? GLFW_TRUE : GLFW_FALSE;
|
2010-09-07 11:34:51 -04:00
|
|
|
break;
|
2013-04-08 09:16:32 -04:00
|
|
|
case GLFW_DECORATED:
|
2016-01-26 21:25:21 -05:00
|
|
|
_glfw.hints.window.decorated = value ? GLFW_TRUE : GLFW_FALSE;
|
2013-04-07 21:07:52 -04:00
|
|
|
break;
|
2014-06-20 07:39:06 -04:00
|
|
|
case GLFW_FOCUSED:
|
2016-01-26 21:25:21 -05:00
|
|
|
_glfw.hints.window.focused = value ? GLFW_TRUE : GLFW_FALSE;
|
2014-06-20 07:39:06 -04:00
|
|
|
break;
|
2014-04-08 09:32:34 -04:00
|
|
|
case GLFW_AUTO_ICONIFY:
|
2016-01-26 21:25:21 -05:00
|
|
|
_glfw.hints.window.autoIconify = value ? GLFW_TRUE : GLFW_FALSE;
|
2014-04-08 09:32:34 -04:00
|
|
|
break;
|
2014-05-23 08:01:02 -04:00
|
|
|
case GLFW_FLOATING:
|
2016-01-26 21:25:21 -05:00
|
|
|
_glfw.hints.window.floating = value ? GLFW_TRUE : GLFW_FALSE;
|
2014-05-23 08:01:02 -04:00
|
|
|
break;
|
2015-10-13 06:50:59 -04:00
|
|
|
case GLFW_MAXIMIZED:
|
2016-04-17 07:44:07 -04:00
|
|
|
_glfw.hints.window.maximized = value ? GLFW_TRUE : GLFW_FALSE;
|
2015-10-13 06:50:59 -04:00
|
|
|
break;
|
2012-08-21 15:18:09 -04:00
|
|
|
case GLFW_VISIBLE:
|
2016-01-26 21:25:21 -05:00
|
|
|
_glfw.hints.window.visible = value ? GLFW_TRUE : GLFW_FALSE;
|
2012-08-21 15:18:09 -04:00
|
|
|
break;
|
2016-12-06 18:41:54 -05:00
|
|
|
case GLFW_COCOA_RETINA_FRAMEBUFFER:
|
|
|
|
_glfw.hints.window.ns.retina = value ? GLFW_TRUE : GLFW_FALSE;
|
|
|
|
break;
|
2017-01-01 13:41:50 -05:00
|
|
|
case GLFW_COCOA_FRAME_AUTOSAVE:
|
|
|
|
_glfw.hints.window.ns.frame = value ? GLFW_TRUE : GLFW_FALSE;
|
|
|
|
break;
|
2017-01-27 06:02:09 -05:00
|
|
|
case GLFW_COCOA_GRAPHICS_SWITCHING:
|
|
|
|
_glfw.hints.context.nsgl.offline = value ? GLFW_TRUE : GLFW_FALSE;
|
|
|
|
break;
|
2017-02-06 09:03:50 -05:00
|
|
|
case GLFW_CENTER_CURSOR:
|
|
|
|
_glfw.hints.window.centerCursor = value ? GLFW_TRUE : GLFW_FALSE;
|
|
|
|
break;
|
2012-09-30 09:32:50 -04:00
|
|
|
case GLFW_CLIENT_API:
|
2016-03-28 07:19:31 -04:00
|
|
|
_glfw.hints.context.client = value;
|
|
|
|
break;
|
|
|
|
case GLFW_CONTEXT_CREATION_API:
|
|
|
|
_glfw.hints.context.source = value;
|
2012-09-30 09:32:50 -04:00
|
|
|
break;
|
2012-12-12 20:22:39 -05:00
|
|
|
case GLFW_CONTEXT_VERSION_MAJOR:
|
2016-01-26 21:25:21 -05:00
|
|
|
_glfw.hints.context.major = value;
|
2010-09-07 11:34:51 -04:00
|
|
|
break;
|
2012-12-12 20:22:39 -05:00
|
|
|
case GLFW_CONTEXT_VERSION_MINOR:
|
2016-01-26 21:25:21 -05:00
|
|
|
_glfw.hints.context.minor = value;
|
2010-09-07 11:34:51 -04:00
|
|
|
break;
|
2012-12-12 20:22:39 -05:00
|
|
|
case GLFW_CONTEXT_ROBUSTNESS:
|
2016-01-26 21:25:21 -05:00
|
|
|
_glfw.hints.context.robustness = value;
|
2012-12-12 20:22:39 -05:00
|
|
|
break;
|
2010-09-07 11:34:51 -04:00
|
|
|
case GLFW_OPENGL_FORWARD_COMPAT:
|
2016-01-26 21:25:21 -05:00
|
|
|
_glfw.hints.context.forward = value ? GLFW_TRUE : GLFW_FALSE;
|
2010-09-07 11:34:51 -04:00
|
|
|
break;
|
|
|
|
case GLFW_OPENGL_DEBUG_CONTEXT:
|
2016-01-26 21:25:21 -05:00
|
|
|
_glfw.hints.context.debug = value ? GLFW_TRUE : GLFW_FALSE;
|
2010-09-07 11:34:51 -04:00
|
|
|
break;
|
2015-08-10 06:46:14 -04:00
|
|
|
case GLFW_CONTEXT_NO_ERROR:
|
2016-01-26 21:25:21 -05:00
|
|
|
_glfw.hints.context.noerror = value ? GLFW_TRUE : GLFW_FALSE;
|
2015-08-10 06:46:14 -04:00
|
|
|
break;
|
2010-09-07 11:34:51 -04:00
|
|
|
case GLFW_OPENGL_PROFILE:
|
2016-01-26 21:25:21 -05:00
|
|
|
_glfw.hints.context.profile = value;
|
2010-09-07 11:34:51 -04:00
|
|
|
break;
|
2014-08-21 13:21:45 -04:00
|
|
|
case GLFW_CONTEXT_RELEASE_BEHAVIOR:
|
2016-01-26 21:25:21 -05:00
|
|
|
_glfw.hints.context.release = value;
|
2014-08-21 13:21:45 -04:00
|
|
|
break;
|
2015-06-07 12:22:38 -04:00
|
|
|
case GLFW_REFRESH_RATE:
|
2016-01-26 21:25:21 -05:00
|
|
|
_glfw.hints.refreshRate = value;
|
2015-06-07 12:22:38 -04:00
|
|
|
break;
|
2010-09-07 11:34:51 -04:00
|
|
|
default:
|
2016-03-29 04:49:34 -04:00
|
|
|
_glfwInputError(GLFW_INVALID_ENUM, "Invalid window hint %i", hint);
|
2010-09-07 11:34:51 -04:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2013-01-05 15:13:28 -05:00
|
|
|
GLFWAPI void glfwDestroyWindow(GLFWwindow* handle)
|
2010-09-07 11:34:51 -04:00
|
|
|
{
|
2011-04-06 14:38:55 -04:00
|
|
|
_GLFWwindow* window = (_GLFWwindow*) handle;
|
|
|
|
|
2013-02-19 18:28:08 -05:00
|
|
|
_GLFW_REQUIRE_INIT();
|
2010-09-07 11:34:51 -04:00
|
|
|
|
2011-03-08 17:14:42 -05:00
|
|
|
// Allow closing of NULL (to match the behavior of free)
|
|
|
|
if (window == NULL)
|
|
|
|
return;
|
|
|
|
|
2012-12-23 10:08:17 -05:00
|
|
|
// Clear all callbacks to avoid exposing a half torn-down window object
|
2013-01-15 15:34:26 -05:00
|
|
|
memset(&window->callbacks, 0, sizeof(window->callbacks));
|
2012-12-23 10:08:17 -05:00
|
|
|
|
2012-10-21 15:57:29 -04:00
|
|
|
// The window's context must not be current on another thread when the
|
|
|
|
// window is destroyed
|
2017-03-08 07:58:09 -05:00
|
|
|
if (window == _glfwPlatformGetTls(&_glfw.context))
|
2016-03-28 07:19:31 -04:00
|
|
|
glfwMakeContextCurrent(NULL);
|
2010-09-07 11:34:51 -04:00
|
|
|
|
2012-08-06 11:56:41 -04:00
|
|
|
_glfwPlatformDestroyWindow(window);
|
2010-09-09 12:15:32 -04:00
|
|
|
|
2010-09-15 20:05:01 -04:00
|
|
|
// Unlink window from global linked list
|
|
|
|
{
|
2013-01-01 19:40:42 -05:00
|
|
|
_GLFWwindow** prev = &_glfw.windowListHead;
|
2010-09-15 20:05:01 -04:00
|
|
|
|
|
|
|
while (*prev != window)
|
|
|
|
prev = &((*prev)->next);
|
2010-09-09 18:06:23 -04:00
|
|
|
|
2010-09-15 20:05:01 -04:00
|
|
|
*prev = window->next;
|
|
|
|
}
|
2010-09-09 18:30:10 -04:00
|
|
|
|
2012-02-07 08:58:58 -05:00
|
|
|
free(window);
|
2010-09-07 11:34:51 -04:00
|
|
|
}
|
|
|
|
|
2013-03-01 07:45:12 -05:00
|
|
|
GLFWAPI int glfwWindowShouldClose(GLFWwindow* handle)
|
|
|
|
{
|
|
|
|
_GLFWwindow* window = (_GLFWwindow*) handle;
|
2016-03-02 11:58:05 -05:00
|
|
|
assert(window != NULL);
|
2016-01-31 11:56:36 -05:00
|
|
|
|
2013-03-01 07:45:12 -05:00
|
|
|
_GLFW_REQUIRE_INIT_OR_RETURN(0);
|
2016-12-08 08:53:01 -05:00
|
|
|
return window->shouldClose;
|
2013-03-01 07:45:12 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
GLFWAPI void glfwSetWindowShouldClose(GLFWwindow* handle, int value)
|
|
|
|
{
|
|
|
|
_GLFWwindow* window = (_GLFWwindow*) handle;
|
2016-03-02 11:58:05 -05:00
|
|
|
assert(window != NULL);
|
2016-01-31 11:56:36 -05:00
|
|
|
|
2013-03-01 07:45:12 -05:00
|
|
|
_GLFW_REQUIRE_INIT();
|
2016-12-08 08:53:01 -05:00
|
|
|
window->shouldClose = value;
|
2013-03-01 07:45:12 -05:00
|
|
|
}
|
|
|
|
|
2013-01-05 15:13:28 -05:00
|
|
|
GLFWAPI void glfwSetWindowTitle(GLFWwindow* handle, const char* title)
|
2010-09-07 11:34:51 -04:00
|
|
|
{
|
2011-04-06 14:38:55 -04:00
|
|
|
_GLFWwindow* window = (_GLFWwindow*) handle;
|
2016-03-02 11:58:05 -05:00
|
|
|
assert(window != NULL);
|
|
|
|
assert(title != NULL);
|
2016-01-31 11:56:36 -05:00
|
|
|
|
2013-02-19 18:28:08 -05:00
|
|
|
_GLFW_REQUIRE_INIT();
|
2010-09-09 12:15:32 -04:00
|
|
|
_glfwPlatformSetWindowTitle(window, title);
|
2010-09-07 11:34:51 -04:00
|
|
|
}
|
|
|
|
|
2016-03-07 08:55:30 -05:00
|
|
|
GLFWAPI void glfwSetWindowIcon(GLFWwindow* handle,
|
|
|
|
int count, const GLFWimage* images)
|
|
|
|
{
|
|
|
|
_GLFWwindow* window = (_GLFWwindow*) handle;
|
|
|
|
assert(window != NULL);
|
|
|
|
assert(count >= 0);
|
|
|
|
assert(count == 0 || images != NULL);
|
|
|
|
|
|
|
|
_GLFW_REQUIRE_INIT();
|
|
|
|
_glfwPlatformSetWindowIcon(window, count, images);
|
|
|
|
}
|
|
|
|
|
2013-01-24 13:30:31 -05:00
|
|
|
GLFWAPI void glfwGetWindowPos(GLFWwindow* handle, int* xpos, int* ypos)
|
|
|
|
{
|
|
|
|
_GLFWwindow* window = (_GLFWwindow*) handle;
|
2016-03-02 11:58:05 -05:00
|
|
|
assert(window != NULL);
|
2014-04-07 09:28:32 -04:00
|
|
|
|
|
|
|
if (xpos)
|
|
|
|
*xpos = 0;
|
|
|
|
if (ypos)
|
|
|
|
*ypos = 0;
|
|
|
|
|
2013-02-19 18:28:08 -05:00
|
|
|
_GLFW_REQUIRE_INIT();
|
2013-01-24 13:30:31 -05:00
|
|
|
_glfwPlatformGetWindowPos(window, xpos, ypos);
|
|
|
|
}
|
|
|
|
|
|
|
|
GLFWAPI void glfwSetWindowPos(GLFWwindow* handle, int xpos, int ypos)
|
|
|
|
{
|
|
|
|
_GLFWwindow* window = (_GLFWwindow*) handle;
|
2016-03-02 11:58:05 -05:00
|
|
|
assert(window != NULL);
|
2013-01-24 13:30:31 -05:00
|
|
|
|
2013-02-19 18:28:08 -05:00
|
|
|
_GLFW_REQUIRE_INIT();
|
2013-01-24 13:30:31 -05:00
|
|
|
|
|
|
|
if (window->monitor)
|
|
|
|
return;
|
|
|
|
|
|
|
|
_glfwPlatformSetWindowPos(window, xpos, ypos);
|
|
|
|
}
|
|
|
|
|
2013-01-05 15:13:28 -05:00
|
|
|
GLFWAPI void glfwGetWindowSize(GLFWwindow* handle, int* width, int* height)
|
2010-09-07 11:34:51 -04:00
|
|
|
{
|
2011-04-06 14:38:55 -04:00
|
|
|
_GLFWwindow* window = (_GLFWwindow*) handle;
|
2016-03-02 11:58:05 -05:00
|
|
|
assert(window != NULL);
|
2014-04-07 09:28:32 -04:00
|
|
|
|
|
|
|
if (width)
|
|
|
|
*width = 0;
|
|
|
|
if (height)
|
|
|
|
*height = 0;
|
|
|
|
|
2013-02-19 18:28:08 -05:00
|
|
|
_GLFW_REQUIRE_INIT();
|
2012-11-25 08:53:33 -05:00
|
|
|
_glfwPlatformGetWindowSize(window, width, height);
|
2010-09-07 11:34:51 -04:00
|
|
|
}
|
|
|
|
|
2013-01-05 15:13:28 -05:00
|
|
|
GLFWAPI void glfwSetWindowSize(GLFWwindow* handle, int width, int height)
|
2010-09-07 11:34:51 -04:00
|
|
|
{
|
2011-04-06 14:38:55 -04:00
|
|
|
_GLFWwindow* window = (_GLFWwindow*) handle;
|
2016-03-02 11:58:05 -05:00
|
|
|
assert(window != NULL);
|
2017-02-23 11:47:41 -05:00
|
|
|
assert(width >= 0);
|
|
|
|
assert(height >= 0);
|
2011-04-06 14:38:55 -04:00
|
|
|
|
2013-02-19 18:28:08 -05:00
|
|
|
_GLFW_REQUIRE_INIT();
|
2010-09-09 15:34:42 -04:00
|
|
|
|
2016-02-23 06:26:42 -05:00
|
|
|
window->videoMode.width = width;
|
|
|
|
window->videoMode.height = height;
|
2013-02-01 02:25:05 -05:00
|
|
|
|
2010-09-09 12:15:32 -04:00
|
|
|
_glfwPlatformSetWindowSize(window, width, height);
|
2010-09-07 11:34:51 -04:00
|
|
|
}
|
|
|
|
|
2014-02-12 20:57:59 -05:00
|
|
|
GLFWAPI void glfwSetWindowSizeLimits(GLFWwindow* handle,
|
|
|
|
int minwidth, int minheight,
|
|
|
|
int maxwidth, int maxheight)
|
|
|
|
{
|
|
|
|
_GLFWwindow* window = (_GLFWwindow*) handle;
|
2016-03-02 11:58:05 -05:00
|
|
|
assert(window != NULL);
|
2014-02-12 20:57:59 -05:00
|
|
|
|
|
|
|
_GLFW_REQUIRE_INIT();
|
|
|
|
|
2016-05-18 17:23:39 -04:00
|
|
|
if (minwidth != GLFW_DONT_CARE && minheight != GLFW_DONT_CARE)
|
2016-05-04 10:28:08 -04:00
|
|
|
{
|
2016-05-18 17:23:39 -04:00
|
|
|
if (minwidth < 0 || minheight < 0)
|
|
|
|
{
|
|
|
|
_glfwInputError(GLFW_INVALID_VALUE,
|
|
|
|
"Invalid window minimum size %ix%i",
|
|
|
|
minwidth, minheight);
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if (maxwidth != GLFW_DONT_CARE && maxheight != GLFW_DONT_CARE)
|
|
|
|
{
|
|
|
|
if (maxwidth < 0 || maxheight < 0 ||
|
|
|
|
maxwidth < minwidth || maxheight < minheight)
|
|
|
|
{
|
|
|
|
_glfwInputError(GLFW_INVALID_VALUE,
|
|
|
|
"Invalid window maximum size %ix%i",
|
|
|
|
maxwidth, maxheight);
|
|
|
|
return;
|
|
|
|
}
|
2016-05-04 10:28:08 -04:00
|
|
|
}
|
|
|
|
|
2016-02-23 06:26:42 -05:00
|
|
|
window->minwidth = minwidth;
|
|
|
|
window->minheight = minheight;
|
|
|
|
window->maxwidth = maxwidth;
|
|
|
|
window->maxheight = maxheight;
|
|
|
|
|
2014-02-12 20:57:59 -05:00
|
|
|
if (window->monitor || !window->resizable)
|
|
|
|
return;
|
|
|
|
|
|
|
|
_glfwPlatformSetWindowSizeLimits(window,
|
|
|
|
minwidth, minheight,
|
|
|
|
maxwidth, maxheight);
|
|
|
|
}
|
|
|
|
|
|
|
|
GLFWAPI void glfwSetWindowAspectRatio(GLFWwindow* handle, int numer, int denom)
|
|
|
|
{
|
|
|
|
_GLFWwindow* window = (_GLFWwindow*) handle;
|
2016-03-02 11:58:05 -05:00
|
|
|
assert(window != NULL);
|
2017-02-23 11:47:41 -05:00
|
|
|
assert(numer != 0);
|
|
|
|
assert(denom != 0);
|
2014-02-12 20:57:59 -05:00
|
|
|
|
|
|
|
_GLFW_REQUIRE_INIT();
|
|
|
|
|
2016-05-18 17:23:39 -04:00
|
|
|
if (numer != GLFW_DONT_CARE && denom != GLFW_DONT_CARE)
|
2016-05-04 10:28:08 -04:00
|
|
|
{
|
2016-05-18 17:23:39 -04:00
|
|
|
if (numer <= 0 || denom <= 0)
|
|
|
|
{
|
|
|
|
_glfwInputError(GLFW_INVALID_VALUE,
|
|
|
|
"Invalid window aspect ratio %i:%i",
|
|
|
|
numer, denom);
|
|
|
|
return;
|
|
|
|
}
|
2016-05-04 10:28:08 -04:00
|
|
|
}
|
|
|
|
|
2016-02-23 06:26:42 -05:00
|
|
|
window->numer = numer;
|
|
|
|
window->denom = denom;
|
|
|
|
|
2014-02-12 20:57:59 -05:00
|
|
|
if (window->monitor || !window->resizable)
|
|
|
|
return;
|
|
|
|
|
|
|
|
_glfwPlatformSetWindowAspectRatio(window, numer, denom);
|
|
|
|
}
|
|
|
|
|
2013-06-03 06:51:57 -04:00
|
|
|
GLFWAPI void glfwGetFramebufferSize(GLFWwindow* handle, int* width, int* height)
|
|
|
|
{
|
|
|
|
_GLFWwindow* window = (_GLFWwindow*) handle;
|
2016-05-03 11:44:46 -04:00
|
|
|
assert(window != NULL);
|
2013-06-03 06:51:57 -04:00
|
|
|
|
2014-04-07 09:28:32 -04:00
|
|
|
if (width)
|
|
|
|
*width = 0;
|
|
|
|
if (height)
|
|
|
|
*height = 0;
|
2013-06-03 06:51:57 -04:00
|
|
|
|
2014-04-07 09:28:32 -04:00
|
|
|
_GLFW_REQUIRE_INIT();
|
2013-06-03 06:51:57 -04:00
|
|
|
_glfwPlatformGetFramebufferSize(window, width, height);
|
|
|
|
}
|
|
|
|
|
2014-03-25 16:30:13 -04:00
|
|
|
GLFWAPI void glfwGetWindowFrameSize(GLFWwindow* handle,
|
|
|
|
int* left, int* top,
|
|
|
|
int* right, int* bottom)
|
|
|
|
{
|
|
|
|
_GLFWwindow* window = (_GLFWwindow*) handle;
|
2016-03-02 11:58:05 -05:00
|
|
|
assert(window != NULL);
|
2014-04-07 09:28:32 -04:00
|
|
|
|
|
|
|
if (left)
|
|
|
|
*left = 0;
|
|
|
|
if (top)
|
|
|
|
*top = 0;
|
|
|
|
if (right)
|
|
|
|
*right = 0;
|
|
|
|
if (bottom)
|
|
|
|
*bottom = 0;
|
|
|
|
|
2014-03-25 16:30:13 -04:00
|
|
|
_GLFW_REQUIRE_INIT();
|
|
|
|
_glfwPlatformGetWindowFrameSize(window, left, top, right, bottom);
|
|
|
|
}
|
|
|
|
|
2013-01-05 15:13:28 -05:00
|
|
|
GLFWAPI void glfwIconifyWindow(GLFWwindow* handle)
|
2010-09-07 11:34:51 -04:00
|
|
|
{
|
2011-04-06 14:38:55 -04:00
|
|
|
_GLFWwindow* window = (_GLFWwindow*) handle;
|
2016-03-02 11:58:05 -05:00
|
|
|
assert(window != NULL);
|
2016-01-31 11:56:36 -05:00
|
|
|
|
2013-02-19 18:28:08 -05:00
|
|
|
_GLFW_REQUIRE_INIT();
|
2010-09-09 12:15:32 -04:00
|
|
|
_glfwPlatformIconifyWindow(window);
|
2010-09-07 11:34:51 -04:00
|
|
|
}
|
|
|
|
|
2013-01-05 15:13:28 -05:00
|
|
|
GLFWAPI void glfwRestoreWindow(GLFWwindow* handle)
|
2012-08-21 14:01:57 -04:00
|
|
|
{
|
2012-09-11 17:51:45 -04:00
|
|
|
_GLFWwindow* window = (_GLFWwindow*) handle;
|
2016-03-02 11:58:05 -05:00
|
|
|
assert(window != NULL);
|
2016-01-31 11:56:36 -05:00
|
|
|
|
2013-02-19 18:28:08 -05:00
|
|
|
_GLFW_REQUIRE_INIT();
|
2012-09-11 17:56:44 -04:00
|
|
|
_glfwPlatformRestoreWindow(window);
|
2012-08-21 14:01:57 -04:00
|
|
|
}
|
|
|
|
|
2015-10-13 06:50:59 -04:00
|
|
|
GLFWAPI void glfwMaximizeWindow(GLFWwindow* handle)
|
|
|
|
{
|
|
|
|
_GLFWwindow* window = (_GLFWwindow*) handle;
|
2016-07-11 10:39:53 -04:00
|
|
|
assert(window != NULL);
|
|
|
|
|
2015-10-13 06:50:59 -04:00
|
|
|
_GLFW_REQUIRE_INIT();
|
2016-06-16 06:52:22 -04:00
|
|
|
|
|
|
|
if (window->monitor)
|
|
|
|
return;
|
|
|
|
|
2015-10-13 06:50:59 -04:00
|
|
|
_glfwPlatformMaximizeWindow(window);
|
|
|
|
}
|
|
|
|
|
2013-01-05 15:13:28 -05:00
|
|
|
GLFWAPI void glfwShowWindow(GLFWwindow* handle)
|
2012-08-21 14:01:57 -04:00
|
|
|
{
|
2012-09-11 17:51:45 -04:00
|
|
|
_GLFWwindow* window = (_GLFWwindow*) handle;
|
2016-03-02 11:58:05 -05:00
|
|
|
assert(window != NULL);
|
2012-09-11 17:51:45 -04:00
|
|
|
|
2013-02-19 18:28:08 -05:00
|
|
|
_GLFW_REQUIRE_INIT();
|
2012-08-21 14:01:57 -04:00
|
|
|
|
2012-09-27 15:37:36 -04:00
|
|
|
if (window->monitor)
|
2012-09-11 17:51:45 -04:00
|
|
|
return;
|
|
|
|
|
2012-09-11 17:56:44 -04:00
|
|
|
_glfwPlatformShowWindow(window);
|
2016-03-15 17:22:14 -04:00
|
|
|
_glfwPlatformFocusWindow(window);
|
2012-08-21 14:01:57 -04:00
|
|
|
}
|
|
|
|
|
2013-01-05 15:13:28 -05:00
|
|
|
GLFWAPI void glfwHideWindow(GLFWwindow* handle)
|
2010-09-07 11:34:51 -04:00
|
|
|
{
|
2011-04-06 14:38:55 -04:00
|
|
|
_GLFWwindow* window = (_GLFWwindow*) handle;
|
2016-03-02 11:58:05 -05:00
|
|
|
assert(window != NULL);
|
2011-04-06 14:38:55 -04:00
|
|
|
|
2013-02-19 18:28:08 -05:00
|
|
|
_GLFW_REQUIRE_INIT();
|
2010-09-09 15:34:42 -04:00
|
|
|
|
2012-09-27 15:37:36 -04:00
|
|
|
if (window->monitor)
|
2010-09-07 11:34:51 -04:00
|
|
|
return;
|
|
|
|
|
2012-09-11 17:56:44 -04:00
|
|
|
_glfwPlatformHideWindow(window);
|
2016-02-21 09:42:49 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
GLFWAPI void glfwFocusWindow(GLFWwindow* handle)
|
|
|
|
{
|
|
|
|
_GLFWwindow* window = (_GLFWwindow*) handle;
|
2016-03-02 11:58:05 -05:00
|
|
|
assert(window != NULL);
|
2016-02-21 09:42:49 -05:00
|
|
|
|
|
|
|
_GLFW_REQUIRE_INIT();
|
|
|
|
|
|
|
|
_glfwPlatformFocusWindow(window);
|
2010-09-07 11:34:51 -04:00
|
|
|
}
|
|
|
|
|
2013-05-27 09:30:32 -04:00
|
|
|
GLFWAPI int glfwGetWindowAttrib(GLFWwindow* handle, int attrib)
|
2010-09-07 11:34:51 -04:00
|
|
|
{
|
2011-04-06 14:38:55 -04:00
|
|
|
_GLFWwindow* window = (_GLFWwindow*) handle;
|
2016-03-02 11:58:05 -05:00
|
|
|
assert(window != NULL);
|
2011-04-06 14:38:55 -04:00
|
|
|
|
2013-02-19 18:28:08 -05:00
|
|
|
_GLFW_REQUIRE_INIT_OR_RETURN(0);
|
2010-09-07 11:34:51 -04:00
|
|
|
|
2013-05-27 09:30:32 -04:00
|
|
|
switch (attrib)
|
2010-09-07 11:34:51 -04:00
|
|
|
{
|
2012-11-22 11:04:44 -05:00
|
|
|
case GLFW_FOCUSED:
|
2014-12-26 06:25:48 -05:00
|
|
|
return _glfwPlatformWindowFocused(window);
|
2010-09-07 11:34:51 -04:00
|
|
|
case GLFW_ICONIFIED:
|
2014-12-26 06:25:48 -05:00
|
|
|
return _glfwPlatformWindowIconified(window);
|
|
|
|
case GLFW_VISIBLE:
|
|
|
|
return _glfwPlatformWindowVisible(window);
|
2015-10-13 06:50:59 -04:00
|
|
|
case GLFW_MAXIMIZED:
|
|
|
|
return _glfwPlatformWindowMaximized(window);
|
2012-08-21 14:28:36 -04:00
|
|
|
case GLFW_RESIZABLE:
|
2011-11-02 11:56:34 -04:00
|
|
|
return window->resizable;
|
2013-04-08 09:16:32 -04:00
|
|
|
case GLFW_DECORATED:
|
|
|
|
return window->decorated;
|
2014-05-23 08:01:02 -04:00
|
|
|
case GLFW_FLOATING:
|
|
|
|
return window->floating;
|
2016-09-29 19:52:22 -04:00
|
|
|
case GLFW_AUTO_ICONIFY:
|
|
|
|
return window->autoIconify;
|
2012-09-30 09:43:26 -04:00
|
|
|
case GLFW_CLIENT_API:
|
2016-03-28 07:19:31 -04:00
|
|
|
return window->context.client;
|
|
|
|
case GLFW_CONTEXT_CREATION_API:
|
|
|
|
return window->context.source;
|
2012-12-12 20:22:39 -05:00
|
|
|
case GLFW_CONTEXT_VERSION_MAJOR:
|
2014-03-06 14:05:32 -05:00
|
|
|
return window->context.major;
|
2012-12-12 20:22:39 -05:00
|
|
|
case GLFW_CONTEXT_VERSION_MINOR:
|
2014-03-06 14:05:32 -05:00
|
|
|
return window->context.minor;
|
2012-12-12 20:22:39 -05:00
|
|
|
case GLFW_CONTEXT_REVISION:
|
2014-03-06 14:05:32 -05:00
|
|
|
return window->context.revision;
|
2012-12-12 20:22:39 -05:00
|
|
|
case GLFW_CONTEXT_ROBUSTNESS:
|
2014-03-06 14:05:32 -05:00
|
|
|
return window->context.robustness;
|
2010-09-07 11:34:51 -04:00
|
|
|
case GLFW_OPENGL_FORWARD_COMPAT:
|
2014-03-06 14:05:32 -05:00
|
|
|
return window->context.forward;
|
2010-09-07 11:34:51 -04:00
|
|
|
case GLFW_OPENGL_DEBUG_CONTEXT:
|
2014-03-06 14:05:32 -05:00
|
|
|
return window->context.debug;
|
2010-09-07 11:34:51 -04:00
|
|
|
case GLFW_OPENGL_PROFILE:
|
2014-03-06 14:05:32 -05:00
|
|
|
return window->context.profile;
|
2014-08-21 13:21:45 -04:00
|
|
|
case GLFW_CONTEXT_RELEASE_BEHAVIOR:
|
|
|
|
return window->context.release;
|
2015-08-10 06:46:14 -04:00
|
|
|
case GLFW_CONTEXT_NO_ERROR:
|
|
|
|
return window->context.noerror;
|
2010-09-07 11:34:51 -04:00
|
|
|
}
|
2011-10-08 17:41:30 -04:00
|
|
|
|
2016-03-29 04:49:34 -04:00
|
|
|
_glfwInputError(GLFW_INVALID_ENUM, "Invalid window attribute %i", attrib);
|
2011-10-08 17:41:30 -04:00
|
|
|
return 0;
|
2010-09-07 11:34:51 -04:00
|
|
|
}
|
|
|
|
|
2016-09-29 19:52:22 -04:00
|
|
|
GLFWAPI void glfwSetWindowAttrib(GLFWwindow* handle, int attrib, int value)
|
|
|
|
{
|
|
|
|
_GLFWwindow* window = (_GLFWwindow*) handle;
|
|
|
|
assert(window != NULL);
|
|
|
|
|
|
|
|
_GLFW_REQUIRE_INIT();
|
|
|
|
|
|
|
|
value = value ? GLFW_TRUE : GLFW_FALSE;
|
|
|
|
|
|
|
|
switch (attrib)
|
|
|
|
{
|
|
|
|
case GLFW_RESIZABLE:
|
|
|
|
if (window->resizable != value)
|
|
|
|
{
|
|
|
|
window->resizable = value;
|
|
|
|
if (!window->monitor)
|
|
|
|
_glfwPlatformSetWindowResizable(window, value);
|
|
|
|
}
|
|
|
|
return;
|
|
|
|
|
|
|
|
case GLFW_DECORATED:
|
|
|
|
if (window->decorated != value)
|
|
|
|
{
|
|
|
|
window->decorated = value;
|
|
|
|
if (!window->monitor)
|
|
|
|
_glfwPlatformSetWindowDecorated(window, value);
|
|
|
|
}
|
|
|
|
return;
|
|
|
|
|
|
|
|
case GLFW_FLOATING:
|
|
|
|
if (window->floating != value)
|
|
|
|
{
|
|
|
|
window->floating = value;
|
|
|
|
if (!window->monitor)
|
|
|
|
_glfwPlatformSetWindowFloating(window, value);
|
|
|
|
}
|
|
|
|
return;
|
|
|
|
|
|
|
|
case GLFW_AUTO_ICONIFY:
|
|
|
|
window->autoIconify = value;
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
_glfwInputError(GLFW_INVALID_ENUM, "Invalid window attribute %i", attrib);
|
|
|
|
}
|
|
|
|
|
2013-01-05 15:13:28 -05:00
|
|
|
GLFWAPI GLFWmonitor* glfwGetWindowMonitor(GLFWwindow* handle)
|
2012-10-02 11:24:18 -04:00
|
|
|
{
|
|
|
|
_GLFWwindow* window = (_GLFWwindow*) handle;
|
2016-03-02 11:58:05 -05:00
|
|
|
assert(window != NULL);
|
2016-01-31 11:56:36 -05:00
|
|
|
|
2013-02-19 18:28:08 -05:00
|
|
|
_GLFW_REQUIRE_INIT_OR_RETURN(NULL);
|
2013-01-05 15:13:28 -05:00
|
|
|
return (GLFWmonitor*) window->monitor;
|
2012-10-02 11:24:18 -04:00
|
|
|
}
|
|
|
|
|
2016-02-23 06:26:42 -05:00
|
|
|
GLFWAPI void glfwSetWindowMonitor(GLFWwindow* wh,
|
|
|
|
GLFWmonitor* mh,
|
|
|
|
int xpos, int ypos,
|
|
|
|
int width, int height,
|
|
|
|
int refreshRate)
|
|
|
|
{
|
|
|
|
_GLFWwindow* window = (_GLFWwindow*) wh;
|
|
|
|
_GLFWmonitor* monitor = (_GLFWmonitor*) mh;
|
2016-05-03 11:44:46 -04:00
|
|
|
assert(window != NULL);
|
2017-02-23 11:47:41 -05:00
|
|
|
assert(width >= 0);
|
|
|
|
assert(height >= 0);
|
2016-02-23 06:26:42 -05:00
|
|
|
|
|
|
|
_GLFW_REQUIRE_INIT();
|
|
|
|
|
2016-05-22 08:25:37 -04:00
|
|
|
if (width <= 0 || height <= 0)
|
|
|
|
{
|
|
|
|
_glfwInputError(GLFW_INVALID_VALUE,
|
|
|
|
"Invalid window size %ix%i",
|
|
|
|
width, height);
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (refreshRate < 0 && refreshRate != GLFW_DONT_CARE)
|
|
|
|
{
|
|
|
|
_glfwInputError(GLFW_INVALID_VALUE,
|
|
|
|
"Invalid refresh rate %i",
|
|
|
|
refreshRate);
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2016-02-23 06:26:42 -05:00
|
|
|
window->videoMode.width = width;
|
|
|
|
window->videoMode.height = height;
|
|
|
|
window->videoMode.refreshRate = refreshRate;
|
|
|
|
|
|
|
|
_glfwPlatformSetWindowMonitor(window, monitor,
|
|
|
|
xpos, ypos, width, height,
|
|
|
|
refreshRate);
|
|
|
|
}
|
|
|
|
|
2013-01-05 15:13:28 -05:00
|
|
|
GLFWAPI void glfwSetWindowUserPointer(GLFWwindow* handle, void* pointer)
|
2010-09-09 16:44:38 -04:00
|
|
|
{
|
2011-04-06 14:38:55 -04:00
|
|
|
_GLFWwindow* window = (_GLFWwindow*) handle;
|
2016-03-02 11:58:05 -05:00
|
|
|
assert(window != NULL);
|
2016-01-31 11:56:36 -05:00
|
|
|
|
2013-02-19 18:28:08 -05:00
|
|
|
_GLFW_REQUIRE_INIT();
|
2010-09-09 16:44:38 -04:00
|
|
|
window->userPointer = pointer;
|
|
|
|
}
|
|
|
|
|
2013-01-05 15:13:28 -05:00
|
|
|
GLFWAPI void* glfwGetWindowUserPointer(GLFWwindow* handle)
|
2010-09-09 16:44:38 -04:00
|
|
|
{
|
2011-04-06 14:38:55 -04:00
|
|
|
_GLFWwindow* window = (_GLFWwindow*) handle;
|
2016-03-02 11:58:05 -05:00
|
|
|
assert(window != NULL);
|
2016-01-31 11:56:36 -05:00
|
|
|
|
2013-02-19 18:28:08 -05:00
|
|
|
_GLFW_REQUIRE_INIT_OR_RETURN(NULL);
|
2010-09-09 16:44:38 -04:00
|
|
|
return window->userPointer;
|
|
|
|
}
|
|
|
|
|
2013-04-08 15:21:21 -04:00
|
|
|
GLFWAPI GLFWwindowposfun glfwSetWindowPosCallback(GLFWwindow* handle,
|
|
|
|
GLFWwindowposfun cbfun)
|
2012-11-30 07:56:42 -05:00
|
|
|
{
|
|
|
|
_GLFWwindow* window = (_GLFWwindow*) handle;
|
2016-03-02 11:58:05 -05:00
|
|
|
assert(window != NULL);
|
2016-01-31 11:56:36 -05:00
|
|
|
|
2013-04-08 15:21:21 -04:00
|
|
|
_GLFW_REQUIRE_INIT_OR_RETURN(NULL);
|
2013-07-30 08:43:01 -04:00
|
|
|
_GLFW_SWAP_POINTERS(window->callbacks.pos, cbfun);
|
|
|
|
return cbfun;
|
2012-11-30 07:56:42 -05:00
|
|
|
}
|
|
|
|
|
2013-04-08 15:21:21 -04:00
|
|
|
GLFWAPI GLFWwindowsizefun glfwSetWindowSizeCallback(GLFWwindow* handle,
|
|
|
|
GLFWwindowsizefun cbfun)
|
2010-09-07 11:34:51 -04:00
|
|
|
{
|
2012-10-28 08:45:11 -04:00
|
|
|
_GLFWwindow* window = (_GLFWwindow*) handle;
|
2016-03-02 11:58:05 -05:00
|
|
|
assert(window != NULL);
|
2016-01-31 11:56:36 -05:00
|
|
|
|
2013-04-08 15:21:21 -04:00
|
|
|
_GLFW_REQUIRE_INIT_OR_RETURN(NULL);
|
2013-07-30 08:43:01 -04:00
|
|
|
_GLFW_SWAP_POINTERS(window->callbacks.size, cbfun);
|
|
|
|
return cbfun;
|
2010-09-07 11:34:51 -04:00
|
|
|
}
|
|
|
|
|
2013-04-08 15:21:21 -04:00
|
|
|
GLFWAPI GLFWwindowclosefun glfwSetWindowCloseCallback(GLFWwindow* handle,
|
|
|
|
GLFWwindowclosefun cbfun)
|
2010-09-07 11:34:51 -04:00
|
|
|
{
|
2012-10-28 08:45:11 -04:00
|
|
|
_GLFWwindow* window = (_GLFWwindow*) handle;
|
2016-03-02 11:58:05 -05:00
|
|
|
assert(window != NULL);
|
2016-01-31 11:56:36 -05:00
|
|
|
|
2013-04-08 15:21:21 -04:00
|
|
|
_GLFW_REQUIRE_INIT_OR_RETURN(NULL);
|
2013-07-30 08:43:01 -04:00
|
|
|
_GLFW_SWAP_POINTERS(window->callbacks.close, cbfun);
|
|
|
|
return cbfun;
|
2010-09-07 11:34:51 -04:00
|
|
|
}
|
|
|
|
|
2013-04-08 15:21:21 -04:00
|
|
|
GLFWAPI GLFWwindowrefreshfun glfwSetWindowRefreshCallback(GLFWwindow* handle,
|
|
|
|
GLFWwindowrefreshfun cbfun)
|
2010-09-07 11:34:51 -04:00
|
|
|
{
|
2012-10-28 08:45:11 -04:00
|
|
|
_GLFWwindow* window = (_GLFWwindow*) handle;
|
2016-03-02 11:58:05 -05:00
|
|
|
assert(window != NULL);
|
2016-01-31 11:56:36 -05:00
|
|
|
|
2013-04-08 15:21:21 -04:00
|
|
|
_GLFW_REQUIRE_INIT_OR_RETURN(NULL);
|
2013-07-30 08:43:01 -04:00
|
|
|
_GLFW_SWAP_POINTERS(window->callbacks.refresh, cbfun);
|
|
|
|
return cbfun;
|
2010-09-07 11:34:51 -04:00
|
|
|
}
|
|
|
|
|
2013-04-08 15:21:21 -04:00
|
|
|
GLFWAPI GLFWwindowfocusfun glfwSetWindowFocusCallback(GLFWwindow* handle,
|
|
|
|
GLFWwindowfocusfun cbfun)
|
2010-09-18 20:49:42 -04:00
|
|
|
{
|
2012-10-28 08:45:11 -04:00
|
|
|
_GLFWwindow* window = (_GLFWwindow*) handle;
|
2016-03-02 11:58:05 -05:00
|
|
|
assert(window != NULL);
|
2016-01-31 11:56:36 -05:00
|
|
|
|
2013-04-08 15:21:21 -04:00
|
|
|
_GLFW_REQUIRE_INIT_OR_RETURN(NULL);
|
2013-07-30 08:43:01 -04:00
|
|
|
_GLFW_SWAP_POINTERS(window->callbacks.focus, cbfun);
|
|
|
|
return cbfun;
|
2010-09-18 20:49:42 -04:00
|
|
|
}
|
|
|
|
|
2013-04-08 15:21:21 -04:00
|
|
|
GLFWAPI GLFWwindowiconifyfun glfwSetWindowIconifyCallback(GLFWwindow* handle,
|
|
|
|
GLFWwindowiconifyfun cbfun)
|
2010-09-19 20:22:35 -04:00
|
|
|
{
|
2012-10-28 08:45:11 -04:00
|
|
|
_GLFWwindow* window = (_GLFWwindow*) handle;
|
2016-03-02 11:58:05 -05:00
|
|
|
assert(window != NULL);
|
2016-01-31 11:56:36 -05:00
|
|
|
|
2013-04-08 15:21:21 -04:00
|
|
|
_GLFW_REQUIRE_INIT_OR_RETURN(NULL);
|
2013-07-30 08:43:01 -04:00
|
|
|
_GLFW_SWAP_POINTERS(window->callbacks.iconify, cbfun);
|
|
|
|
return cbfun;
|
2010-09-19 20:22:35 -04:00
|
|
|
}
|
|
|
|
|
2016-06-16 07:09:28 -04:00
|
|
|
GLFWAPI GLFWwindowmaximizefun glfwSetWindowMaximizeCallback(GLFWwindow* handle,
|
|
|
|
GLFWwindowmaximizefun cbfun)
|
|
|
|
{
|
|
|
|
_GLFWwindow* window = (_GLFWwindow*) handle;
|
|
|
|
assert(window != NULL);
|
|
|
|
|
|
|
|
_GLFW_REQUIRE_INIT_OR_RETURN(NULL);
|
|
|
|
_GLFW_SWAP_POINTERS(window->callbacks.maximize, cbfun);
|
|
|
|
return cbfun;
|
|
|
|
}
|
|
|
|
|
2013-06-03 06:51:57 -04:00
|
|
|
GLFWAPI GLFWframebuffersizefun glfwSetFramebufferSizeCallback(GLFWwindow* handle,
|
|
|
|
GLFWframebuffersizefun cbfun)
|
|
|
|
{
|
|
|
|
_GLFWwindow* window = (_GLFWwindow*) handle;
|
2016-03-02 11:58:05 -05:00
|
|
|
assert(window != NULL);
|
2016-01-31 11:56:36 -05:00
|
|
|
|
2013-06-03 06:51:57 -04:00
|
|
|
_GLFW_REQUIRE_INIT_OR_RETURN(NULL);
|
2013-07-30 08:43:01 -04:00
|
|
|
_GLFW_SWAP_POINTERS(window->callbacks.fbsize, cbfun);
|
|
|
|
return cbfun;
|
2013-06-03 06:51:57 -04:00
|
|
|
}
|
|
|
|
|
2010-09-08 08:45:52 -04:00
|
|
|
GLFWAPI void glfwPollEvents(void)
|
2010-09-07 11:34:51 -04:00
|
|
|
{
|
2013-02-19 18:28:08 -05:00
|
|
|
_GLFW_REQUIRE_INIT();
|
2010-09-07 11:34:51 -04:00
|
|
|
_glfwPlatformPollEvents();
|
|
|
|
}
|
|
|
|
|
2010-09-08 08:45:52 -04:00
|
|
|
GLFWAPI void glfwWaitEvents(void)
|
2010-09-07 11:34:51 -04:00
|
|
|
{
|
2013-02-19 18:28:08 -05:00
|
|
|
_GLFW_REQUIRE_INIT();
|
2014-02-10 12:16:58 -05:00
|
|
|
|
|
|
|
if (!_glfw.windowListHead)
|
|
|
|
return;
|
|
|
|
|
2010-09-07 11:34:51 -04:00
|
|
|
_glfwPlatformWaitEvents();
|
|
|
|
}
|
|
|
|
|
2016-02-02 15:11:16 -05:00
|
|
|
GLFWAPI void glfwWaitEventsTimeout(double timeout)
|
|
|
|
{
|
|
|
|
_GLFW_REQUIRE_INIT();
|
2017-02-23 11:47:41 -05:00
|
|
|
assert(timeout == timeout);
|
|
|
|
assert(timeout >= 0.0);
|
|
|
|
assert(timeout <= DBL_MAX);
|
2016-02-02 15:11:16 -05:00
|
|
|
|
|
|
|
if (timeout != timeout || timeout < 0.0 || timeout > DBL_MAX)
|
|
|
|
{
|
2016-03-29 04:49:34 -04:00
|
|
|
_glfwInputError(GLFW_INVALID_VALUE, "Invalid time %f", timeout);
|
2016-02-02 15:11:16 -05:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
_glfwPlatformWaitEventsTimeout(timeout);
|
|
|
|
}
|
|
|
|
|
2014-02-10 12:16:58 -05:00
|
|
|
GLFWAPI void glfwPostEmptyEvent(void)
|
|
|
|
{
|
|
|
|
_GLFW_REQUIRE_INIT();
|
|
|
|
|
|
|
|
if (!_glfw.windowListHead)
|
|
|
|
return;
|
|
|
|
|
|
|
|
_glfwPlatformPostEmptyEvent();
|
|
|
|
}
|
|
|
|
|