window.c
Go to the documentation of this file.
00001 //========================================================================
00002 // GLFW 3.1 - www.glfw.org
00003 //------------------------------------------------------------------------
00004 // Copyright (c) 2002-2006 Marcus Geelnard
00005 // Copyright (c) 2006-2010 Camilla Berglund <elmindreda@elmindreda.org>
00006 // Copyright (c) 2012 Torsten Walluhn <tw@mad-cad.net>
00007 //
00008 // This software is provided 'as-is', without any express or implied
00009 // warranty. In no event will the authors be held liable for any damages
00010 // arising from the use of this software.
00011 //
00012 // Permission is granted to anyone to use this software for any purpose,
00013 // including commercial applications, and to alter it and redistribute it
00014 // freely, subject to the following restrictions:
00015 //
00016 // 1. The origin of this software must not be misrepresented; you must not
00017 //    claim that you wrote the original software. If you use this software
00018 //    in a product, an acknowledgment in the product documentation would
00019 //    be appreciated but is not required.
00020 //
00021 // 2. Altered source versions must be plainly marked as such, and must not
00022 //    be misrepresented as being the original software.
00023 //
00024 // 3. This notice may not be removed or altered from any source
00025 //    distribution.
00026 //
00027 //========================================================================
00028 
00029 #include "internal.h"
00030 
00031 #include <string.h>
00032 #include <stdlib.h>
00033 
00034 
00038 
00039 void _glfwInputWindowFocus(_GLFWwindow* window, GLboolean focused)
00040 {
00041     if (focused)
00042     {
00043         _glfw.cursorWindow = window;
00044 
00045         if (window->callbacks.focus)
00046             window->callbacks.focus((GLFWwindow*) window, focused);
00047     }
00048     else
00049     {
00050         int i;
00051 
00052         _glfw.cursorWindow = NULL;
00053 
00054         if (window->callbacks.focus)
00055             window->callbacks.focus((GLFWwindow*) window, focused);
00056 
00057         // Release all pressed keyboard keys
00058         for (i = 0;  i <= GLFW_KEY_LAST;  i++)
00059         {
00060             if (window->keys[i] == GLFW_PRESS)
00061                 _glfwInputKey(window, i, 0, GLFW_RELEASE, 0);
00062         }
00063 
00064         // Release all pressed mouse buttons
00065         for (i = 0;  i <= GLFW_MOUSE_BUTTON_LAST;  i++)
00066         {
00067             if (window->mouseButtons[i] == GLFW_PRESS)
00068                 _glfwInputMouseClick(window, i, GLFW_RELEASE, 0);
00069         }
00070     }
00071 }
00072 
00073 void _glfwInputWindowPos(_GLFWwindow* window, int x, int y)
00074 {
00075     if (window->callbacks.pos)
00076         window->callbacks.pos((GLFWwindow*) window, x, y);
00077 }
00078 
00079 void _glfwInputWindowSize(_GLFWwindow* window, int width, int height)
00080 {
00081     if (window->callbacks.size)
00082         window->callbacks.size((GLFWwindow*) window, width, height);
00083 }
00084 
00085 void _glfwInputWindowIconify(_GLFWwindow* window, int iconified)
00086 {
00087     if (window->callbacks.iconify)
00088         window->callbacks.iconify((GLFWwindow*) window, iconified);
00089 }
00090 
00091 void _glfwInputFramebufferSize(_GLFWwindow* window, int width, int height)
00092 {
00093     if (window->callbacks.fbsize)
00094         window->callbacks.fbsize((GLFWwindow*) window, width, height);
00095 }
00096 
00097 void _glfwInputWindowDamage(_GLFWwindow* window)
00098 {
00099     if (window->callbacks.refresh)
00100         window->callbacks.refresh((GLFWwindow*) window);
00101 }
00102 
00103 void _glfwInputWindowCloseRequest(_GLFWwindow* window)
00104 {
00105     window->closed = GL_TRUE;
00106 
00107     if (window->callbacks.close)
00108         window->callbacks.close((GLFWwindow*) window);
00109 }
00110 
00111 
00115 
00116 GLFWAPI GLFWwindow* glfwCreateWindow(int width, int height,
00117                                      const char* title,
00118                                      GLFWmonitor* monitor,
00119                                      GLFWwindow* share)
00120 {
00121     _GLFWfbconfig fbconfig;
00122     _GLFWctxconfig ctxconfig;
00123     _GLFWwndconfig wndconfig;
00124     _GLFWwindow* window;
00125     _GLFWwindow* previous;
00126 
00127     _GLFW_REQUIRE_INIT_OR_RETURN(NULL);
00128 
00129     if (width <= 0 || height <= 0)
00130     {
00131         _glfwInputError(GLFW_INVALID_VALUE, "Invalid window size");
00132         return NULL;
00133     }
00134 
00135     fbconfig  = _glfw.hints.framebuffer;
00136     ctxconfig = _glfw.hints.context;
00137     wndconfig = _glfw.hints.window;
00138 
00139     wndconfig.width   = width;
00140     wndconfig.height  = height;
00141     wndconfig.title   = title;
00142     wndconfig.monitor = (_GLFWmonitor*) monitor;
00143     ctxconfig.share   = (_GLFWwindow*) share;
00144 
00145     if (wndconfig.monitor)
00146     {
00147         wndconfig.resizable = GL_TRUE;
00148         wndconfig.visible   = GL_TRUE;
00149         wndconfig.focused   = GL_TRUE;
00150     }
00151 
00152     // Check the OpenGL bits of the window config
00153     if (!_glfwIsValidContextConfig(&ctxconfig))
00154         return NULL;
00155 
00156     window = calloc(1, sizeof(_GLFWwindow));
00157     window->next = _glfw.windowListHead;
00158     _glfw.windowListHead = window;
00159 
00160     window->videoMode.width       = width;
00161     window->videoMode.height      = height;
00162     window->videoMode.redBits     = fbconfig.redBits;
00163     window->videoMode.greenBits   = fbconfig.greenBits;
00164     window->videoMode.blueBits    = fbconfig.blueBits;
00165     window->videoMode.refreshRate = _glfw.hints.refreshRate;
00166 
00167     window->monitor     = wndconfig.monitor;
00168     window->resizable   = wndconfig.resizable;
00169     window->decorated   = wndconfig.decorated;
00170     window->autoIconify = wndconfig.autoIconify;
00171     window->floating    = wndconfig.floating;
00172     window->cursorMode  = GLFW_CURSOR_NORMAL;
00173 
00174     // Save the currently current context so it can be restored later
00175     previous = _glfwPlatformGetCurrentContext();
00176 
00177     // Open the actual window and create its context
00178     if (!_glfwPlatformCreateWindow(window, &wndconfig, &ctxconfig, &fbconfig))
00179     {
00180         glfwDestroyWindow((GLFWwindow*) window);
00181         _glfwPlatformMakeContextCurrent(previous);
00182         return NULL;
00183     }
00184 
00185     _glfwPlatformMakeContextCurrent(window);
00186 
00187     // Retrieve the actual (as opposed to requested) context attributes
00188     if (!_glfwRefreshContextAttribs(&ctxconfig))
00189     {
00190         glfwDestroyWindow((GLFWwindow*) window);
00191         _glfwPlatformMakeContextCurrent(previous);
00192         return NULL;
00193     }
00194 
00195     // Verify the context against the requested parameters
00196     if (!_glfwIsValidContext(&ctxconfig))
00197     {
00198         glfwDestroyWindow((GLFWwindow*) window);
00199         _glfwPlatformMakeContextCurrent(previous);
00200         return NULL;
00201     }
00202 
00203     // Clearing the front buffer to black to avoid garbage pixels left over
00204     // from previous uses of our bit of VRAM
00205     window->Clear(GL_COLOR_BUFFER_BIT);
00206     _glfwPlatformSwapBuffers(window);
00207 
00208     // Restore the previously current context (or NULL)
00209     _glfwPlatformMakeContextCurrent(previous);
00210 
00211     if (wndconfig.monitor)
00212     {
00213         int width, height;
00214         _glfwPlatformGetWindowSize(window, &width, &height);
00215 
00216         window->cursorPosX = width / 2;
00217         window->cursorPosY = height / 2;
00218 
00219         _glfwPlatformSetCursorPos(window, window->cursorPosX, window->cursorPosY);
00220     }
00221     else
00222     {
00223         if (wndconfig.visible)
00224         {
00225             if (wndconfig.focused)
00226                 _glfwPlatformShowWindow(window);
00227             else
00228                 _glfwPlatformUnhideWindow(window);
00229         }
00230     }
00231 
00232     return (GLFWwindow*) window;
00233 }
00234 
00235 void glfwDefaultWindowHints(void)
00236 {
00237     _GLFW_REQUIRE_INIT();
00238 
00239     memset(&_glfw.hints, 0, sizeof(_glfw.hints));
00240 
00241     // The default is OpenGL with minimum version 1.0
00242     _glfw.hints.context.api   = GLFW_OPENGL_API;
00243     _glfw.hints.context.major = 1;
00244     _glfw.hints.context.minor = 0;
00245 
00246     // The default is a focused, visible, resizable window with decorations
00247     _glfw.hints.window.resizable   = GL_TRUE;
00248     _glfw.hints.window.visible     = GL_TRUE;
00249     _glfw.hints.window.decorated   = GL_TRUE;
00250     _glfw.hints.window.focused     = GL_TRUE;
00251     _glfw.hints.window.autoIconify = GL_TRUE;
00252 
00253     // The default is 24 bits of color, 24 bits of depth and 8 bits of stencil,
00254     // double buffered
00255     _glfw.hints.framebuffer.redBits      = 8;
00256     _glfw.hints.framebuffer.greenBits    = 8;
00257     _glfw.hints.framebuffer.blueBits     = 8;
00258     _glfw.hints.framebuffer.alphaBits    = 8;
00259     _glfw.hints.framebuffer.depthBits    = 24;
00260     _glfw.hints.framebuffer.stencilBits  = 8;
00261     _glfw.hints.framebuffer.doublebuffer = GL_TRUE;
00262 
00263     // The default is to select the highest available refresh rate
00264     _glfw.hints.refreshRate = GLFW_DONT_CARE;
00265 }
00266 
00267 GLFWAPI void glfwWindowHint(int target, int hint)
00268 {
00269     _GLFW_REQUIRE_INIT();
00270 
00271     switch (target)
00272     {
00273         case GLFW_RED_BITS:
00274             _glfw.hints.framebuffer.redBits = hint;
00275             break;
00276         case GLFW_GREEN_BITS:
00277             _glfw.hints.framebuffer.greenBits = hint;
00278             break;
00279         case GLFW_BLUE_BITS:
00280             _glfw.hints.framebuffer.blueBits = hint;
00281             break;
00282         case GLFW_ALPHA_BITS:
00283             _glfw.hints.framebuffer.alphaBits = hint;
00284             break;
00285         case GLFW_DEPTH_BITS:
00286             _glfw.hints.framebuffer.depthBits = hint;
00287             break;
00288         case GLFW_STENCIL_BITS:
00289             _glfw.hints.framebuffer.stencilBits = hint;
00290             break;
00291         case GLFW_ACCUM_RED_BITS:
00292             _glfw.hints.framebuffer.accumRedBits = hint;
00293             break;
00294         case GLFW_ACCUM_GREEN_BITS:
00295             _glfw.hints.framebuffer.accumGreenBits = hint;
00296             break;
00297         case GLFW_ACCUM_BLUE_BITS:
00298             _glfw.hints.framebuffer.accumBlueBits = hint;
00299             break;
00300         case GLFW_ACCUM_ALPHA_BITS:
00301             _glfw.hints.framebuffer.accumAlphaBits = hint;
00302             break;
00303         case GLFW_AUX_BUFFERS:
00304             _glfw.hints.framebuffer.auxBuffers = hint;
00305             break;
00306         case GLFW_STEREO:
00307             _glfw.hints.framebuffer.stereo = hint ? GL_TRUE : GL_FALSE;
00308             break;
00309         case GLFW_DOUBLEBUFFER:
00310             _glfw.hints.framebuffer.doublebuffer = hint ? GL_TRUE : GL_FALSE;
00311             break;
00312         case GLFW_SAMPLES:
00313             _glfw.hints.framebuffer.samples = hint;
00314             break;
00315         case GLFW_SRGB_CAPABLE:
00316             _glfw.hints.framebuffer.sRGB = hint ? GL_TRUE : GL_FALSE;
00317             break;
00318         case GLFW_RESIZABLE:
00319             _glfw.hints.window.resizable = hint ? GL_TRUE : GL_FALSE;
00320             break;
00321         case GLFW_DECORATED:
00322             _glfw.hints.window.decorated = hint ? GL_TRUE : GL_FALSE;
00323             break;
00324         case GLFW_FOCUSED:
00325             _glfw.hints.window.focused = hint ? GL_TRUE : GL_FALSE;
00326             break;
00327         case GLFW_AUTO_ICONIFY:
00328             _glfw.hints.window.autoIconify = hint ? GL_TRUE : GL_FALSE;
00329             break;
00330         case GLFW_FLOATING:
00331             _glfw.hints.window.floating = hint ? GL_TRUE : GL_FALSE;
00332             break;
00333         case GLFW_VISIBLE:
00334             _glfw.hints.window.visible = hint ? GL_TRUE : GL_FALSE;
00335             break;
00336         case GLFW_CLIENT_API:
00337             _glfw.hints.context.api = hint;
00338             break;
00339         case GLFW_CONTEXT_VERSION_MAJOR:
00340             _glfw.hints.context.major = hint;
00341             break;
00342         case GLFW_CONTEXT_VERSION_MINOR:
00343             _glfw.hints.context.minor = hint;
00344             break;
00345         case GLFW_CONTEXT_ROBUSTNESS:
00346             _glfw.hints.context.robustness = hint;
00347             break;
00348         case GLFW_OPENGL_FORWARD_COMPAT:
00349             _glfw.hints.context.forward = hint ? GL_TRUE : GL_FALSE;
00350             break;
00351         case GLFW_OPENGL_DEBUG_CONTEXT:
00352             _glfw.hints.context.debug = hint ? GL_TRUE : GL_FALSE;
00353             break;
00354         case GLFW_OPENGL_PROFILE:
00355             _glfw.hints.context.profile = hint;
00356             break;
00357         case GLFW_CONTEXT_RELEASE_BEHAVIOR:
00358             _glfw.hints.context.release = hint;
00359             break;
00360         case GLFW_REFRESH_RATE:
00361             _glfw.hints.refreshRate = hint;
00362             break;
00363         default:
00364             _glfwInputError(GLFW_INVALID_ENUM, "Invalid window hint");
00365             break;
00366     }
00367 }
00368 
00369 GLFWAPI void glfwDestroyWindow(GLFWwindow* handle)
00370 {
00371     _GLFWwindow* window = (_GLFWwindow*) handle;
00372 
00373     _GLFW_REQUIRE_INIT();
00374 
00375     // Allow closing of NULL (to match the behavior of free)
00376     if (window == NULL)
00377         return;
00378 
00379     // Clear all callbacks to avoid exposing a half torn-down window object
00380     memset(&window->callbacks, 0, sizeof(window->callbacks));
00381 
00382     // The window's context must not be current on another thread when the
00383     // window is destroyed
00384     if (window == _glfwPlatformGetCurrentContext())
00385         _glfwPlatformMakeContextCurrent(NULL);
00386 
00387     // Clear the focused window pointer if this is the focused window
00388     if (_glfw.cursorWindow == window)
00389         _glfw.cursorWindow = NULL;
00390 
00391     _glfwPlatformDestroyWindow(window);
00392 
00393     // Unlink window from global linked list
00394     {
00395         _GLFWwindow** prev = &_glfw.windowListHead;
00396 
00397         while (*prev != window)
00398             prev = &((*prev)->next);
00399 
00400         *prev = window->next;
00401     }
00402 
00403     free(window);
00404 }
00405 
00406 GLFWAPI int glfwWindowShouldClose(GLFWwindow* handle)
00407 {
00408     _GLFWwindow* window = (_GLFWwindow*) handle;
00409     _GLFW_REQUIRE_INIT_OR_RETURN(0);
00410     return window->closed;
00411 }
00412 
00413 GLFWAPI void glfwSetWindowShouldClose(GLFWwindow* handle, int value)
00414 {
00415     _GLFWwindow* window = (_GLFWwindow*) handle;
00416     _GLFW_REQUIRE_INIT();
00417     window->closed = value;
00418 }
00419 
00420 GLFWAPI void glfwSetWindowTitle(GLFWwindow* handle, const char* title)
00421 {
00422     _GLFWwindow* window = (_GLFWwindow*) handle;
00423     _GLFW_REQUIRE_INIT();
00424     _glfwPlatformSetWindowTitle(window, title);
00425 }
00426 
00427 GLFWAPI void glfwGetWindowPos(GLFWwindow* handle, int* xpos, int* ypos)
00428 {
00429     _GLFWwindow* window = (_GLFWwindow*) handle;
00430 
00431     if (xpos)
00432         *xpos = 0;
00433     if (ypos)
00434         *ypos = 0;
00435 
00436     _GLFW_REQUIRE_INIT();
00437     _glfwPlatformGetWindowPos(window, xpos, ypos);
00438 }
00439 
00440 GLFWAPI void glfwSetWindowPos(GLFWwindow* handle, int xpos, int ypos)
00441 {
00442     _GLFWwindow* window = (_GLFWwindow*) handle;
00443 
00444     _GLFW_REQUIRE_INIT();
00445 
00446     if (window->monitor)
00447     {
00448         _glfwInputError(GLFW_INVALID_VALUE,
00449                         "Full screen windows cannot be moved");
00450         return;
00451     }
00452 
00453     _glfwPlatformSetWindowPos(window, xpos, ypos);
00454 }
00455 
00456 GLFWAPI void glfwGetWindowSize(GLFWwindow* handle, int* width, int* height)
00457 {
00458     _GLFWwindow* window = (_GLFWwindow*) handle;
00459 
00460     if (width)
00461         *width = 0;
00462     if (height)
00463         *height = 0;
00464 
00465     _GLFW_REQUIRE_INIT();
00466     _glfwPlatformGetWindowSize(window, width, height);
00467 }
00468 
00469 GLFWAPI void glfwSetWindowSize(GLFWwindow* handle, int width, int height)
00470 {
00471     _GLFWwindow* window = (_GLFWwindow*) handle;
00472 
00473     _GLFW_REQUIRE_INIT();
00474 
00475     if (window->monitor)
00476     {
00477         window->videoMode.width  = width;
00478         window->videoMode.height = height;
00479     }
00480 
00481     _glfwPlatformSetWindowSize(window, width, height);
00482 }
00483 
00484 GLFWAPI void glfwGetFramebufferSize(GLFWwindow* handle, int* width, int* height)
00485 {
00486     _GLFWwindow* window = (_GLFWwindow*) handle;
00487 
00488     if (width)
00489         *width = 0;
00490     if (height)
00491         *height = 0;
00492 
00493     _GLFW_REQUIRE_INIT();
00494     _glfwPlatformGetFramebufferSize(window, width, height);
00495 }
00496 
00497 GLFWAPI void glfwGetWindowFrameSize(GLFWwindow* handle,
00498                                     int* left, int* top,
00499                                     int* right, int* bottom)
00500 {
00501     _GLFWwindow* window = (_GLFWwindow*) handle;
00502 
00503     if (left)
00504         *left = 0;
00505     if (top)
00506         *top = 0;
00507     if (right)
00508         *right = 0;
00509     if (bottom)
00510         *bottom = 0;
00511 
00512     _GLFW_REQUIRE_INIT();
00513     _glfwPlatformGetWindowFrameSize(window, left, top, right, bottom);
00514 }
00515 
00516 GLFWAPI void glfwIconifyWindow(GLFWwindow* handle)
00517 {
00518     _GLFWwindow* window = (_GLFWwindow*) handle;
00519     _GLFW_REQUIRE_INIT();
00520     _glfwPlatformIconifyWindow(window);
00521 }
00522 
00523 GLFWAPI void glfwRestoreWindow(GLFWwindow* handle)
00524 {
00525     _GLFWwindow* window = (_GLFWwindow*) handle;
00526     _GLFW_REQUIRE_INIT();
00527     _glfwPlatformRestoreWindow(window);
00528 }
00529 
00530 GLFWAPI void glfwShowWindow(GLFWwindow* handle)
00531 {
00532     _GLFWwindow* window = (_GLFWwindow*) handle;
00533 
00534     _GLFW_REQUIRE_INIT();
00535 
00536     if (window->monitor)
00537         return;
00538 
00539     _glfwPlatformShowWindow(window);
00540 }
00541 
00542 GLFWAPI void glfwHideWindow(GLFWwindow* handle)
00543 {
00544     _GLFWwindow* window = (_GLFWwindow*) handle;
00545 
00546     _GLFW_REQUIRE_INIT();
00547 
00548     if (window->monitor)
00549         return;
00550 
00551     _glfwPlatformHideWindow(window);
00552 }
00553 
00554 GLFWAPI int glfwGetWindowAttrib(GLFWwindow* handle, int attrib)
00555 {
00556     _GLFWwindow* window = (_GLFWwindow*) handle;
00557 
00558     _GLFW_REQUIRE_INIT_OR_RETURN(0);
00559 
00560     switch (attrib)
00561     {
00562         case GLFW_FOCUSED:
00563             return _glfwPlatformWindowFocused(window);
00564         case GLFW_ICONIFIED:
00565             return _glfwPlatformWindowIconified(window);
00566         case GLFW_VISIBLE:
00567             return _glfwPlatformWindowVisible(window);
00568         case GLFW_RESIZABLE:
00569             return window->resizable;
00570         case GLFW_DECORATED:
00571             return window->decorated;
00572         case GLFW_FLOATING:
00573             return window->floating;
00574         case GLFW_CLIENT_API:
00575             return window->context.api;
00576         case GLFW_CONTEXT_VERSION_MAJOR:
00577             return window->context.major;
00578         case GLFW_CONTEXT_VERSION_MINOR:
00579             return window->context.minor;
00580         case GLFW_CONTEXT_REVISION:
00581             return window->context.revision;
00582         case GLFW_CONTEXT_ROBUSTNESS:
00583             return window->context.robustness;
00584         case GLFW_OPENGL_FORWARD_COMPAT:
00585             return window->context.forward;
00586         case GLFW_OPENGL_DEBUG_CONTEXT:
00587             return window->context.debug;
00588         case GLFW_OPENGL_PROFILE:
00589             return window->context.profile;
00590         case GLFW_CONTEXT_RELEASE_BEHAVIOR:
00591             return window->context.release;
00592     }
00593 
00594     _glfwInputError(GLFW_INVALID_ENUM, "Invalid window attribute");
00595     return 0;
00596 }
00597 
00598 GLFWAPI GLFWmonitor* glfwGetWindowMonitor(GLFWwindow* handle)
00599 {
00600     _GLFWwindow* window = (_GLFWwindow*) handle;
00601     _GLFW_REQUIRE_INIT_OR_RETURN(NULL);
00602     return (GLFWmonitor*) window->monitor;
00603 }
00604 
00605 GLFWAPI void glfwSetWindowUserPointer(GLFWwindow* handle, void* pointer)
00606 {
00607     _GLFWwindow* window = (_GLFWwindow*) handle;
00608     _GLFW_REQUIRE_INIT();
00609     window->userPointer = pointer;
00610 }
00611 
00612 GLFWAPI void* glfwGetWindowUserPointer(GLFWwindow* handle)
00613 {
00614     _GLFWwindow* window = (_GLFWwindow*) handle;
00615     _GLFW_REQUIRE_INIT_OR_RETURN(NULL);
00616     return window->userPointer;
00617 }
00618 
00619 GLFWAPI GLFWwindowposfun glfwSetWindowPosCallback(GLFWwindow* handle,
00620                                                   GLFWwindowposfun cbfun)
00621 {
00622     _GLFWwindow* window = (_GLFWwindow*) handle;
00623     _GLFW_REQUIRE_INIT_OR_RETURN(NULL);
00624     _GLFW_SWAP_POINTERS(window->callbacks.pos, cbfun);
00625     return cbfun;
00626 }
00627 
00628 GLFWAPI GLFWwindowsizefun glfwSetWindowSizeCallback(GLFWwindow* handle,
00629                                                     GLFWwindowsizefun cbfun)
00630 {
00631     _GLFWwindow* window = (_GLFWwindow*) handle;
00632     _GLFW_REQUIRE_INIT_OR_RETURN(NULL);
00633     _GLFW_SWAP_POINTERS(window->callbacks.size, cbfun);
00634     return cbfun;
00635 }
00636 
00637 GLFWAPI GLFWwindowclosefun glfwSetWindowCloseCallback(GLFWwindow* handle,
00638                                                       GLFWwindowclosefun cbfun)
00639 {
00640     _GLFWwindow* window = (_GLFWwindow*) handle;
00641     _GLFW_REQUIRE_INIT_OR_RETURN(NULL);
00642     _GLFW_SWAP_POINTERS(window->callbacks.close, cbfun);
00643     return cbfun;
00644 }
00645 
00646 GLFWAPI GLFWwindowrefreshfun glfwSetWindowRefreshCallback(GLFWwindow* handle,
00647                                                           GLFWwindowrefreshfun cbfun)
00648 {
00649     _GLFWwindow* window = (_GLFWwindow*) handle;
00650     _GLFW_REQUIRE_INIT_OR_RETURN(NULL);
00651     _GLFW_SWAP_POINTERS(window->callbacks.refresh, cbfun);
00652     return cbfun;
00653 }
00654 
00655 GLFWAPI GLFWwindowfocusfun glfwSetWindowFocusCallback(GLFWwindow* handle,
00656                                                       GLFWwindowfocusfun cbfun)
00657 {
00658     _GLFWwindow* window = (_GLFWwindow*) handle;
00659     _GLFW_REQUIRE_INIT_OR_RETURN(NULL);
00660     _GLFW_SWAP_POINTERS(window->callbacks.focus, cbfun);
00661     return cbfun;
00662 }
00663 
00664 GLFWAPI GLFWwindowiconifyfun glfwSetWindowIconifyCallback(GLFWwindow* handle,
00665                                                           GLFWwindowiconifyfun cbfun)
00666 {
00667     _GLFWwindow* window = (_GLFWwindow*) handle;
00668     _GLFW_REQUIRE_INIT_OR_RETURN(NULL);
00669     _GLFW_SWAP_POINTERS(window->callbacks.iconify, cbfun);
00670     return cbfun;
00671 }
00672 
00673 GLFWAPI GLFWframebuffersizefun glfwSetFramebufferSizeCallback(GLFWwindow* handle,
00674                                                               GLFWframebuffersizefun cbfun)
00675 {
00676     _GLFWwindow* window = (_GLFWwindow*) handle;
00677     _GLFW_REQUIRE_INIT_OR_RETURN(NULL);
00678     _GLFW_SWAP_POINTERS(window->callbacks.fbsize, cbfun);
00679     return cbfun;
00680 }
00681 
00682 GLFWAPI void glfwPollEvents(void)
00683 {
00684     _GLFW_REQUIRE_INIT();
00685     _glfwPlatformPollEvents();
00686 }
00687 
00688 GLFWAPI void glfwWaitEvents(void)
00689 {
00690     _GLFW_REQUIRE_INIT();
00691 
00692     if (!_glfw.windowListHead)
00693         return;
00694 
00695     _glfwPlatformWaitEvents();
00696 }
00697 
00698 GLFWAPI void glfwPostEmptyEvent(void)
00699 {
00700     _GLFW_REQUIRE_INIT();
00701 
00702     if (!_glfw.windowListHead)
00703         return;
00704 
00705     _glfwPlatformPostEmptyEvent();
00706 }
00707 


librealsense
Author(s): Sergey Dorodnicov , Mark Horn , Reagan Lopez
autogenerated on Tue Jun 25 2019 19:54:39