1
0
Fork 0
mirror of https://github.com/gwm17/glfw.git synced 2024-11-27 04:28:52 -05:00
glfw/src/internal.h

366 lines
13 KiB
C
Raw Normal View History

2010-09-07 11:34:51 -04:00
//========================================================================
// GLFW - An OpenGL library
2010-09-07 11:34:51 -04:00
// Platform: Any
2010-09-07 11:41:26 -04:00
// API version: 3.0
2010-09-07 11:34:51 -04:00
// WWW: http://www.glfw.org/
//------------------------------------------------------------------------
// Copyright (c) 2002-2006 Marcus Geelnard
// Copyright (c) 2006-2010 Camilla Berglund <elmindreda@elmindreda.org>
//
// 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.
//
//========================================================================
#ifndef _internal_h_
#define _internal_h_
//========================================================================
// GLFWGLOBAL is a macro that places all global variables in the init.c
// module (all other modules reference global variables as 'extern')
//========================================================================
2010-09-08 11:30:21 -04:00
#if defined(_init_c_)
2010-09-07 11:34:51 -04:00
#define GLFWGLOBAL
#else
#define GLFWGLOBAL extern
#endif
//========================================================================
// Input handling definitions
//========================================================================
// Internal key and button state/action definitions
#define GLFW_STICK 2
2010-09-09 12:15:32 -04:00
//------------------------------------------------------------------------
// Platform specific definitions goes in platform.h (which also includes
// glfw.h)
//------------------------------------------------------------------------
#include "config.h"
2010-11-17 08:52:47 -05:00
2011-07-26 09:16:34 -04:00
#include "../include/GL/glfw3.h"
2011-09-22 08:15:07 -04:00
// This path may need to be changed if you build GLFW using your own setup
// We ship and use our own copy of glext.h since GLFW uses fairly new
// extensions and not all operating systems come with an up-to-date version
2011-09-06 11:32:41 -04:00
#include "../support/GL/glext.h"
2010-09-09 12:15:32 -04:00
2011-07-26 09:16:34 -04:00
#if defined(_GLFW_COCOA_NSGL)
#include "cocoa_platform.h"
#elif defined(_GLFW_WIN32_WGL)
#include "win32_platform.h"
#elif defined(_GLFW_X11_GLX)
#include "x11_platform.h"
#else
#error "No supported platform selected"
#endif
2010-09-09 12:15:32 -04:00
2010-10-04 12:17:53 -04:00
typedef struct _GLFWhints _GLFWhints;
typedef struct _GLFWwndconfig _GLFWwndconfig;
typedef struct _GLFWfbconfig _GLFWfbconfig;
typedef struct _GLFWwindow _GLFWwindow;
typedef struct _GLFWlibrary _GLFWlibrary;
2010-09-07 11:34:51 -04:00
//------------------------------------------------------------------------
2010-09-09 14:18:10 -04:00
// Window hints, set by glfwOpenWindowHint and consumed by glfwOpenWindow
// A bucket of semi-random stuff lumped together for historical reasons
2010-09-07 11:34:51 -04:00
// This is used only by the platform independent code and only to store
// parameters passed to us by glfwOpenWindowHint
//------------------------------------------------------------------------
2010-10-04 12:17:53 -04:00
struct _GLFWhints
2010-09-09 14:18:10 -04:00
{
int redBits;
int greenBits;
int blueBits;
int alphaBits;
int depthBits;
int stencilBits;
2010-09-07 11:34:51 -04:00
int refreshRate;
int accumRedBits;
int accumGreenBits;
int accumBlueBits;
int accumAlphaBits;
int auxBuffers;
2010-10-25 06:36:14 -04:00
GLboolean stereo;
GLboolean resizable;
2010-09-07 11:34:51 -04:00
int samples;
int glMajor;
int glMinor;
2010-10-25 06:36:14 -04:00
GLboolean glForward;
GLboolean glDebug;
2010-09-07 11:34:51 -04:00
int glProfile;
2011-03-07 14:51:34 -05:00
int glRobustness;
2010-10-04 12:17:53 -04:00
};
2010-09-07 11:34:51 -04:00
//------------------------------------------------------------------------
// Parameters relating to the creation of the context and window but not
// directly related to the properties of the framebuffer
// This is used to pass window and context creation parameters from the
// platform independent code to the platform specific code
//------------------------------------------------------------------------
2010-10-04 12:17:53 -04:00
struct _GLFWwndconfig
2010-09-09 14:18:10 -04:00
{
2010-10-04 12:17:53 -04:00
int mode;
const char* title;
int refreshRate;
GLboolean resizable;
2010-10-04 12:17:53 -04:00
int glMajor;
int glMinor;
2010-10-25 06:36:14 -04:00
GLboolean glForward;
GLboolean glDebug;
2010-10-04 12:17:53 -04:00
int glProfile;
2011-03-07 14:51:34 -05:00
int glRobustness;
2010-10-04 12:17:53 -04:00
_GLFWwindow* share;
};
2010-09-07 11:34:51 -04:00
//------------------------------------------------------------------------
// Framebuffer configuration descriptor, i.e. buffers and their sizes
// Also a platform specific ID used to map back to the actual backend APIs
// This is used to pass framebuffer parameters from the platform independent
// code to the platform specific code, and also to enumerate and select
// available framebuffer configurations
//------------------------------------------------------------------------
2010-10-04 12:17:53 -04:00
struct _GLFWfbconfig
2010-09-09 14:18:10 -04:00
{
2010-09-07 11:34:51 -04:00
int redBits;
int greenBits;
int blueBits;
int alphaBits;
int depthBits;
int stencilBits;
int accumRedBits;
int accumGreenBits;
int accumBlueBits;
int accumAlphaBits;
int auxBuffers;
2010-10-25 06:36:14 -04:00
GLboolean stereo;
2010-09-07 11:34:51 -04:00
int samples;
GLFWintptr platformID;
2010-10-04 12:17:53 -04:00
};
2010-09-07 11:34:51 -04:00
2010-09-09 12:15:32 -04:00
//------------------------------------------------------------------------
// Window structure
//------------------------------------------------------------------------
2010-10-04 12:17:53 -04:00
struct _GLFWwindow
2010-09-09 14:18:10 -04:00
{
2010-09-09 18:06:23 -04:00
struct _GLFWwindow* next;
2010-09-09 14:18:10 -04:00
// Window settings and state
GLboolean iconified; // GL_TRUE if this window is iconified
2010-09-16 00:02:44 -04:00
GLboolean closeRequested; // GL_TRUE if this window should be closed
2010-09-09 14:18:10 -04:00
int width, height;
2010-09-13 21:53:22 -04:00
int positionX, positionY;
2010-09-09 14:18:10 -04:00
int mode; // GLFW_WINDOW or GLFW_FULLSCREEN
GLboolean resizable; // GL_TRUE if user may resize this window
2010-09-09 14:18:10 -04:00
int refreshRate; // monitor refresh rate
2010-09-09 16:44:38 -04:00
void* userPointer;
2010-09-09 12:15:32 -04:00
2010-09-09 14:18:10 -04:00
// Window input state
2010-09-09 12:15:32 -04:00
GLboolean stickyKeys;
GLboolean stickyMouseButtons;
GLboolean keyRepeat;
GLboolean sysKeysDisabled; // system keys disabled flag
int cursorPosX, cursorPosY;
int cursorMode;
int scrollX, scrollY;
2010-09-09 12:15:32 -04:00
char mouseButton[GLFW_MOUSE_BUTTON_LAST + 1];
char key[GLFW_KEY_LAST + 1];
// Framebuffer attributes
int redBits;
int greenBits;
int blueBits;
int alphaBits;
int depthBits;
int stencilBits;
int accumRedBits;
int accumGreenBits;
int accumBlueBits;
int accumAlphaBits;
int auxBuffers;
GLboolean stereo;
int samples;
// OpenGL extensions and context attributes
2010-09-09 14:18:10 -04:00
GLboolean accelerated; // GL_TRUE if OpenGL context is "accelerated"
2010-09-09 12:15:32 -04:00
int glMajor, glMinor, glRevision;
2010-10-25 06:36:14 -04:00
GLboolean glForward, glDebug;
int glProfile;
2011-03-07 14:51:34 -05:00
int glRobustness;
2010-09-09 12:15:32 -04:00
PFNGLGETSTRINGIPROC GetStringi;
// These are defined in the current port's platform.h
2010-09-09 12:15:32 -04:00
_GLFW_PLATFORM_WINDOW_STATE;
_GLFW_PLATFORM_CONTEXT_STATE;
2010-10-04 12:17:53 -04:00
};
2010-09-09 12:15:32 -04:00
//------------------------------------------------------------------------
// Library global data
//------------------------------------------------------------------------
2010-10-04 12:17:53 -04:00
struct _GLFWlibrary
2010-09-09 14:18:10 -04:00
{
_GLFWhints hints;
2010-09-09 18:06:23 -04:00
_GLFWwindow* windowListHead;
_GLFWwindow* currentWindow;
_GLFWwindow* activeWindow;
2010-10-24 12:28:55 -04:00
GLFWwindowsizefun windowSizeCallback;
GLFWwindowclosefun windowCloseCallback;
GLFWwindowrefreshfun windowRefreshCallback;
GLFWwindowfocusfun windowFocusCallback;
GLFWwindowiconifyfun windowIconifyCallback;
GLFWmousebuttonfun mouseButtonCallback;
GLFWmouseposfun mousePosCallback;
GLFWscrollfun scrollCallback;
GLFWkeyfun keyCallback;
GLFWcharfun charCallback;
GLFWthreadmodel threading;
GLFWallocator allocator;
GLFWgammaramp currentRamp;
GLFWgammaramp originalRamp;
int originalRampSize;
2010-09-09 12:15:32 -04:00
// This is defined in the current port's platform.h
2010-09-09 12:15:32 -04:00
_GLFW_PLATFORM_LIBRARY_STATE;
2010-10-04 12:17:53 -04:00
};
2010-09-09 12:15:32 -04:00
2010-09-07 11:34:51 -04:00
//========================================================================
// System independent global variables (GLFW internals)
//========================================================================
// Flag indicating if GLFW has been initialized
2010-09-08 11:30:21 -04:00
#if defined(_init_c_)
2010-09-09 14:18:10 -04:00
GLboolean _glfwInitialized = GL_FALSE;
2010-09-07 11:34:51 -04:00
#else
2010-09-09 14:18:10 -04:00
GLFWGLOBAL GLboolean _glfwInitialized;
2010-09-07 11:34:51 -04:00
#endif
2010-09-09 12:15:32 -04:00
GLFWGLOBAL _GLFWlibrary _glfwLibrary;
2010-09-07 11:34:51 -04:00
//========================================================================
// Prototypes for platform specific implementation functions
//========================================================================
// Init/terminate
2010-09-08 11:30:21 -04:00
int _glfwPlatformInit(void);
int _glfwPlatformTerminate(void);
2010-09-13 12:05:59 -04:00
const char* _glfwPlatformGetVersionString(void);
2010-09-07 11:34:51 -04:00
// Enable/Disable
2010-09-09 12:15:32 -04:00
void _glfwPlatformEnableSystemKeys(_GLFWwindow* window);
void _glfwPlatformDisableSystemKeys(_GLFWwindow* window);
2010-09-07 11:34:51 -04:00
// Fullscreen
2010-09-08 11:30:21 -04:00
int _glfwPlatformGetVideoModes(GLFWvidmode* list, int maxcount);
void _glfwPlatformGetDesktopMode(GLFWvidmode* mode);
2010-09-07 11:34:51 -04:00
// Gamma ramp
2010-10-13 16:42:31 -04:00
void _glfwPlatformGetGammaRamp(GLFWgammaramp* ramp);
void _glfwPlatformSetGammaRamp(const GLFWgammaramp* ramp);
2010-09-07 11:34:51 -04:00
// Joystick
2010-09-08 11:30:21 -04:00
int _glfwPlatformGetJoystickParam(int joy, int param);
int _glfwPlatformGetJoystickPos(int joy, float* pos, int numaxes);
int _glfwPlatformGetJoystickButtons(int joy, unsigned char* buttons, int numbuttons);
2010-09-07 11:34:51 -04:00
// Time
2010-09-08 11:30:21 -04:00
double _glfwPlatformGetTime(void);
void _glfwPlatformSetTime(double time);
2010-09-07 11:34:51 -04:00
// Window management
int _glfwPlatformOpenWindow(_GLFWwindow* window, const _GLFWwndconfig* wndconfig, const _GLFWfbconfig* fbconfig);
2010-09-09 12:15:32 -04:00
void _glfwPlatformCloseWindow(_GLFWwindow* window);
void _glfwPlatformSetWindowTitle(_GLFWwindow* window, const char* title);
void _glfwPlatformSetWindowSize(_GLFWwindow* window, int width, int height);
void _glfwPlatformSetWindowPos(_GLFWwindow* window, int x, int y);
void _glfwPlatformIconifyWindow(_GLFWwindow* window);
void _glfwPlatformRestoreWindow(_GLFWwindow* window);
void _glfwPlatformSetMouseCursorPos(_GLFWwindow* window, int x, int y);
void _glfwPlatformSetCursorMode(_GLFWwindow* window, int mode);
2010-09-09 12:15:32 -04:00
// Event management
void _glfwPlatformPollEvents(void);
void _glfwPlatformWaitEvents(void);
// OpenGL context management
void _glfwPlatformMakeContextCurrent(_GLFWwindow* window);
2010-09-08 11:30:21 -04:00
void _glfwPlatformSwapBuffers(void);
void _glfwPlatformSwapInterval(int interval);
void _glfwPlatformRefreshWindowParams(void);
2010-09-09 12:15:32 -04:00
int _glfwPlatformExtensionSupported(const char* extension);
void* _glfwPlatformGetProcAddress(const char* procname);
void _glfwPlatformCopyContext(_GLFWwindow* src, _GLFWwindow* dst, unsigned long mask);
2010-09-07 11:34:51 -04:00
//========================================================================
// Prototypes for platform independent internal functions
//========================================================================
// Memory management (init.c)
void* _glfwMalloc(size_t size);
void _glfwFree(void* ptr);
// Fullscren management (fullscreen.c)
void _glfwSplitBPP(int bpp, int* red, int* green, int* blue);
// Error handling (error.c)
2010-11-23 11:45:23 -05:00
void _glfwSetError(int error, const char* description);
2010-09-13 12:05:59 -04:00
2010-09-07 11:34:51 -04:00
// Window management (window.c)
void _glfwSetDefaultWindowHints(void);
2010-09-07 11:34:51 -04:00
2012-01-31 09:27:15 -05:00
// Window event notification (window.c)
void _glfwInputWindowFocus(_GLFWwindow* window, GLboolean activated);
void _glfwInputWindowPos(_GLFWwindow* window, int x, int y);
void _glfwInputWindowSize(_GLFWwindow* window, int width, int height);
void _glfwInputWindowIconify(_GLFWwindow* window, int iconified);
void _glfwInputWindowDamage(_GLFWwindow* window);
2012-01-31 09:27:15 -05:00
// Input event notification (input.c)
2010-09-09 12:15:32 -04:00
void _glfwInputKey(_GLFWwindow* window, int key, int action);
void _glfwInputChar(_GLFWwindow* window, int character);
2010-09-26 20:16:17 -04:00
void _glfwInputScroll(_GLFWwindow* window, int x, int y);
2010-09-09 12:15:32 -04:00
void _glfwInputMouseClick(_GLFWwindow* window, int button, int action);
void _glfwInputCursorMotion(_GLFWwindow* window, int x, int y);
2010-09-07 11:34:51 -04:00
// OpenGL context helpers (opengl.c)
2010-09-08 11:30:21 -04:00
int _glfwStringInExtensionString(const char* string, const GLubyte* extensions);
const _GLFWfbconfig* _glfwChooseFBConfig(const _GLFWfbconfig* desired,
const _GLFWfbconfig* alternatives,
unsigned int count);
2011-03-07 08:55:11 -05:00
GLboolean _glfwIsValidContextConfig(_GLFWwndconfig* wndconfig);
GLboolean _glfwIsValidContext(_GLFWwindow* window, _GLFWwndconfig* wndconfig);
2010-09-07 11:34:51 -04:00
#endif // _internal_h_