-
Notifications
You must be signed in to change notification settings - Fork 31
/
Copy pathinternal.h
executable file
·266 lines (222 loc) · 9.55 KB
/
internal.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
//========================================================================
// GLFW - An OpenGL framework
// Platform: Any
// API version: 2.7
// WWW: http://www.glfw.org/
//------------------------------------------------------------------------
// Copyright (c) 2002-2006 Marcus Geelnard
// Copyright (c) 2006-2010 Camilla Berglund <[email protected]>
//
// 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')
//========================================================================
#if defined( _init_c_ )
#define GLFWGLOBAL
#else
#define GLFWGLOBAL extern
#endif
//========================================================================
// Input handling definitions
//========================================================================
// Internal key and button state/action definitions
#define GLFW_STICK 2
//========================================================================
// System independent include files
//========================================================================
#include <stdlib.h>
#include <string.h>
#include <stdio.h>
//------------------------------------------------------------------------
// Window opening hints (set by glfwOpenWindowHint)
// A bucket of semi-random stuff bunched together for historical reasons
// This is used only by the platform independent code and only to store
// parameters passed to us by glfwOpenWindowHint
//------------------------------------------------------------------------
typedef struct {
int refreshRate;
int accumRedBits;
int accumGreenBits;
int accumBlueBits;
int accumAlphaBits;
int auxBuffers;
int stereo;
int windowNoResize;
int samples;
int glMajor;
int glMinor;
int glForward;
int glDebug;
int glProfile;
} _GLFWhints;
//------------------------------------------------------------------------
// Platform specific definitions goes in platform.h (which also includes
// glfw.h)
//------------------------------------------------------------------------
#include "platform.h"
//------------------------------------------------------------------------
// 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
//------------------------------------------------------------------------
typedef struct {
int mode;
int refreshRate;
int windowNoResize;
int glMajor;
int glMinor;
int glForward;
int glDebug;
int glProfile;
} _GLFWwndconfig;
//------------------------------------------------------------------------
// 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
//------------------------------------------------------------------------
typedef struct {
int redBits;
int greenBits;
int blueBits;
int alphaBits;
int depthBits;
int stencilBits;
int accumRedBits;
int accumGreenBits;
int accumBlueBits;
int accumAlphaBits;
int auxBuffers;
int stereo;
int samples;
GLFWintptr platformID;
} _GLFWfbconfig;
//========================================================================
// System independent global variables (GLFW internals)
//========================================================================
// Flag indicating if GLFW has been initialized
#if defined( _init_c_ )
int _glfwInitialized = 0;
#else
GLFWGLOBAL int _glfwInitialized;
#endif
//------------------------------------------------------------------------
// Abstract data stream (for image I/O)
//------------------------------------------------------------------------
typedef struct {
FILE* file;
void* data;
long position;
long size;
} _GLFWstream;
//========================================================================
// Prototypes for platform specific implementation functions
//========================================================================
// Init/terminate
int _glfwPlatformInit( void );
int _glfwPlatformTerminate( void );
// Enable/Disable
void _glfwPlatformEnableSystemKeys( void );
void _glfwPlatformDisableSystemKeys( void );
// Fullscreen
int _glfwPlatformGetVideoModes( GLFWvidmode *list, int maxcount );
void _glfwPlatformGetDesktopMode( GLFWvidmode *mode );
// OpenGL extensions
int _glfwPlatformExtensionSupported( const char *extension );
void * _glfwPlatformGetProcAddress( const char *procname );
// Joystick
int _glfwPlatformGetJoystickParam( int joy, int param );
int _glfwPlatformGetJoystickPos( int joy, float *pos, int numaxes );
int _glfwPlatformGetJoystickButtons( int joy, unsigned char *buttons, int numbuttons );
// Threads
GLFWthread _glfwPlatformCreateThread( GLFWthreadfun fun, void *arg );
void _glfwPlatformDestroyThread( GLFWthread ID );
int _glfwPlatformWaitThread( GLFWthread ID, int waitmode );
GLFWthread _glfwPlatformGetThreadID( void );
GLFWmutex _glfwPlatformCreateMutex( void );
void _glfwPlatformDestroyMutex( GLFWmutex mutex );
void _glfwPlatformLockMutex( GLFWmutex mutex );
void _glfwPlatformUnlockMutex( GLFWmutex mutex );
GLFWcond _glfwPlatformCreateCond( void );
void _glfwPlatformDestroyCond( GLFWcond cond );
void _glfwPlatformWaitCond( GLFWcond cond, GLFWmutex mutex, double timeout );
void _glfwPlatformSignalCond( GLFWcond cond );
void _glfwPlatformBroadcastCond( GLFWcond cond );
int _glfwPlatformGetNumberOfProcessors( void );
// Time
double _glfwPlatformGetTime( void );
void _glfwPlatformSetTime( double time );
void _glfwPlatformSleep( double time );
// Window management
int _glfwPlatformOpenWindow( int width, int height, const _GLFWwndconfig *wndconfig, const _GLFWfbconfig *fbconfig );
void _glfwPlatformCloseWindow( void );
void _glfwPlatformSetWindowTitle( const char *title );
void _glfwPlatformSetWindowSize( int width, int height );
void _glfwPlatformSetWindowPos( int x, int y );
void _glfwPlatformIconifyWindow( void );
void _glfwPlatformRestoreWindow( void );
void _glfwPlatformSwapBuffers( void );
void _glfwPlatformSwapInterval( int interval );
void _glfwPlatformRefreshWindowParams( void );
void _glfwPlatformPollEvents( void );
void _glfwPlatformWaitEvents( void );
void _glfwPlatformHideMouseCursor( void );
void _glfwPlatformShowMouseCursor( void );
void _glfwPlatformSetMouseCursorPos( int x, int y );
//========================================================================
// Prototypes for platform independent internal functions
//========================================================================
// Window management (window.c)
void _glfwClearWindowHints( void );
// Input handling (window.c)
void _glfwClearInput( void );
void _glfwInputDeactivation( void );
void _glfwInputKey( int key, int action );
void _glfwInputChar( int character, int action );
void _glfwInputMouseClick( int button, int action );
// Threads (thread.c)
_GLFWthread * _glfwGetThreadPointer( int ID );
void _glfwAppendThread( _GLFWthread * t );
void _glfwRemoveThread( _GLFWthread * t );
// OpenGL extensions (glext.c)
void _glfwParseGLVersion( int *major, int *minor, int *rev );
int _glfwStringInExtensionString( const char *string, const GLubyte *extensions );
void _glfwRefreshContextParams( void );
// Abstracted data streams (stream.c)
int _glfwOpenFileStream( _GLFWstream *stream, const char *name, const char *mode );
int _glfwOpenBufferStream( _GLFWstream *stream, void *data, long size );
long _glfwReadStream( _GLFWstream *stream, void *data, long size );
long _glfwTellStream( _GLFWstream *stream );
int _glfwSeekStream( _GLFWstream *stream, long offset, int whence );
void _glfwCloseStream( _GLFWstream *stream );
// Targa image I/O (tga.c)
int _glfwReadTGA( _GLFWstream *s, GLFWimage *img, int flags );
// Framebuffer configs
const _GLFWfbconfig *_glfwChooseFBConfig( const _GLFWfbconfig *desired,
const _GLFWfbconfig *alternatives,
unsigned int count );
#endif // _internal_h_