Oolite 1.91.0.7645-241119-222d325
Loading...
Searching...
No Matches
MyOpenGLView.h
Go to the documentation of this file.
1/*
2
3MyOpenGLView.h
4
5Oolite
6Copyright (C) 2004-2013 Giles C Williams and contributors
7
8This program is free software; you can redistribute it and/or
9modify it under the terms of the GNU General Public License
10as published by the Free Software Foundation; either version 2
11of the License, or (at your option) any later version.
12
13This program is distributed in the hope that it will be useful,
14but WITHOUT ANY WARRANTY; without even the implied warranty of
15MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16GNU General Public License for more details.
17
18You should have received a copy of the GNU General Public License
19along with this program; if not, write to the Free Software
20Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
21MA 02110-1301, USA.
22
23*/
24
25#import "OOCocoa.h"
26#import "OOOpenGL.h"
29
30
31#include <SDL.h>
32
33#define WINDOW_SIZE_DEFAULT_WIDTH 1280
34#define WINDOW_SIZE_DEFAULT_HEIGHT 720
35
36#define MIN_FOV_DEG 30.0f
37#define MAX_FOV_DEG 80.0f
38#define MIN_FOV (tan((MIN_FOV_DEG / 2) * M_PI / 180.0f))
39#define MAX_FOV (tan((MAX_FOV_DEG / 2) * M_PI / 180.0f))
40
41#define MIN_HDR_MAXBRIGHTNESS 400.0
42#define MAX_HDR_MAXBRIGHTNESS 1000.0
43
44#define MIN_HDR_PAPERWHITE 80.0f
45#define MAX_HDR_PAPERWHITE 280.0f
46
47#define MAX_COLOR_SATURATION 2.0f
48
49#define MOUSEX_MAXIMUM 0.6
50#define MOUSEY_MAXIMUM 0.6
51
52#define MAX_CLEAR_DEPTH 10000000000.0
53// 10 000 000 km.
54#define INTERMEDIATE_CLEAR_DEPTH 100.0
55// 100 m.
56
57
58#define NUM_KEYS 327
59#define MOUSE_DOUBLE_CLICK_INTERVAL 0.40
60#define OOMOUSEWHEEL_EVENTS_DELAY_INTERVAL 0.05
61#define OOMOUSEWHEEL_DELTA 120 // Same as Windows WHEEL_DELTA
62
63#define SNAPSHOTS_PNG_FORMAT 1
64#define SNAPSHOTHDR_EXTENSION_EXR @".exr"
65#define SNAPSHOTHDR_EXTENSION_HDR @".hdr"
66#define SNAPSHOTHDR_EXTENSION_DEFAULT SNAPSHOTHDR_EXTENSION_EXR
67
68@class Entity, GameController, OpenGLSprite;
69
126
133
141
148
149extern int debug;
150
151@interface MyOpenGLView : NSObject
152{
154 BOOL keys[NUM_KEYS];
155 int scancode2Unicode[NUM_KEYS];
156 NSDictionary *keyMappings_normal;
157 NSDictionary *keyMappings_shifted;
158
159 BOOL suppressKeys; // DJS
160
164
165 int keycodetrans[255];
166
169
171
172 NSTimeInterval timeIntervalAtLastClick;
174 BOOL doubleClick;
175
176 NSMutableString *typedString;
177
179
181
182 NSSize viewSize;
183 GLfloat display_z;
184 GLfloat x_offset, y_offset;
185
187 NSRect bounds;
188
189 float _gamma;
190 float _fov;
191 BOOL _msaa;
192
193 // Full screen sizes
194 NSMutableArray *screenSizes;
195 int currentSize; //we need an int!
197
198 // Windowed mode
200 SDL_Surface *surface;
201
203
204#if OOLITE_WINDOWS
205
206 BOOL wasFullScreen;
207 BOOL updateContext;
208 BOOL saveSize;
209 BOOL atDesktopResolution;
210 unsigned keyboardMap; // *** FLAGGED for deletion
211 HWND SDL_Window;
212 MONITORINFOEX monitorInfo;
213 RECT lastGoodRect;
214 float _hdrMaxBrightness;
215 float _hdrPaperWhiteBrightness;
216
217#endif
218
220
222
224
226
228
229 // Mouse mode indicator (for mouse movement model)
231
233}
234
239- (id) init;
240
241- (void) initSplashScreen;
242- (void) endSplashScreen;
243- (void) autoShowMouse;
244
245- (void) initKeyMappingData;
246
247- (void) setStringInput: (enum StringInput) value;
248- (void) allowStringInput: (BOOL) value;
249- (enum StringInput) allowingStringInput;
250- (NSString *) typedString;
251- (void) resetTypedString;
252- (void) setTypedString:(NSString*) value;
253
254- (NSSize) viewSize;
255- (NSSize) backingViewSize;
256- (GLfloat) display_z;
257- (GLfloat) x_offset;
258- (GLfloat) y_offset;
259
260- (GameController *) gameController;
261- (void) setGameController:(GameController *) controller;
262
263- (void) noteMouseInteractionModeChangedFrom:(OOMouseInteractionMode)oldMode to:(OOMouseInteractionMode)newMode;
264
265- (void) initialiseGLWithSize:(NSSize) v_size;
266- (void) initialiseGLWithSize:(NSSize) v_size useVideoMode:(BOOL) v_mode;
267- (BOOL) isRunningOnPrimaryDisplayDevice;
268#if OOLITE_WINDOWS
269- (BOOL) getCurrentMonitorInfo:(MONITORINFOEX *)mInfo;
270- (MONITORINFOEX) currentMonitorInfo;
271- (void) refreshDarKOrLightMode;
272- (BOOL) isDarkModeOn;
273- (BOOL) atDesktopResolution;
274- (float) hdrMaxBrightness;
275- (void) setHDRMaxBrightness:(float)newMaxBrightness;
276- (float) hdrPaperWhiteBrightness;
277- (void) setHDRPaperWhiteBrightness:(float)newPaperWhiteBrightness;
278#endif
279- (float) colorSaturation;
280- (void) adjustColorSaturation:(float)colorSaturationAdjustment;
281- (BOOL) hdrOutput;
282- (BOOL) isOutputDisplayHDREnabled;
283
284- (void) grabMouseInsideGameWindow:(BOOL) value;
285
286- (void) stringToClipboard:(NSString *)stringToCopy;
287
288- (void) drawRect:(NSRect)rect;
289- (void) updateScreen;
290- (void) updateScreenWithVideoMode:(BOOL) v_mode;
291- (void) display;
292
293- (BOOL) snapShot:(NSString *)filename;
294#if SNAPSHOTS_PNG_FORMAT
295- (BOOL) pngSaveSurface:(NSString *)fileName withSurface:(SDL_Surface *)surf;
296#endif
297
298- (NSRect) bounds;
299+ (NSMutableDictionary *) getNativeSize;
300
301- (void) setFullScreenMode:(BOOL)fsm;
302- (BOOL) inFullScreenMode;
303- (void) toggleScreenMode;
304- (void) setDisplayMode:(int)mode fullScreen:(BOOL)fsm;
305
306- (int) indexOfCurrentSize;
307- (void) setScreenSize: (int)sizeIndex;
308- (NSMutableArray *)getScreenSizeArray;
309- (void) populateFullScreenModelist;
310- (NSSize) modeAsSize: (int)sizeIndex;
311- (void) saveWindowSize: (NSSize) windowSize;
312- (NSSize) loadWindowSize;
313- (int) loadFullscreenSettings;
314- (int) findDisplayModeForWidth: (unsigned int) d_width Height:(unsigned int) d_height
315 Refresh: (unsigned int)d_refresh;
316- (NSSize) currentScreenSize;
317
318- (void) pollControls;
319
320- (void) setVirtualJoystick:(double) vmx :(double) vmy;
321- (NSPoint) virtualJoystickPosition;
322
323- (void) clearKeys;
324- (void) clearMouse;
325- (void) clearKey: (int)theKey;
326- (void) resetMouse;
327- (BOOL) isAlphabetKeyDown;
328- (void) suppressKeysUntilKeyUp; // DJS
329- (BOOL) isDown: (int) key;
330- (BOOL) isOptDown; // opt == alt key
331- (BOOL) isCtrlDown;
332- (BOOL) isCommandDown;
333- (BOOL) isShiftDown;
334- (BOOL) isCapsLockOn;
335- (BOOL) lastKeyWasShifted;
336- (int) numKeys;
337- (int) mouseWheelState;
338- (float) mouseWheelDelta;
339- (void) setMouseWheelDelta: (float) newWheelDelta;
340
341// Command-key combinations need special handling. SDL stubs for these mac functions.
342- (BOOL) isCommandQDown;
343- (BOOL) isCommandFDown;
344- (void) clearCommandF;
345
346- (void) setMouseInDeltaMode: (BOOL) inDelta;
347
348- (void) setGammaValue: (float) value;
349- (float) gammaValue;
350
351- (void) setFov:(float)value fromFraction:(BOOL)fromFraction;
352- (float) fov:(BOOL)inFraction;
353
354- (void) setMsaa:(BOOL)newMsaa;
355- (BOOL) msaa;
356
357// Check current state of shift key rather than relying on last event.
358+ (BOOL)pollShiftKey;
359
360- (OOOpenGLMatrixManager *) getOpenGLMatrixManager;
361
362#ifndef NDEBUG
363// General image-dumping method.
364- (void) dumpRGBAToFileNamed:(NSString *)name
365 bytes:(uint8_t *)bytes
366 width:(NSUInteger)width
367 height:(NSUInteger)height
368 rowBytes:(NSUInteger)rowBytes;
369- (void) dumpRGBToFileNamed:(NSString *)name
370 bytes:(uint8_t *)bytes
371 width:(NSUInteger)width
372 height:(NSUInteger)height
373 rowBytes:(NSUInteger)rowBytes;
374- (void) dumpGrayToFileNamed:(NSString *)name
375 bytes:(uint8_t *)bytes
376 width:(NSUInteger)width
377 height:(NSUInteger)height
378 rowBytes:(NSUInteger)rowBytes;
379- (void) dumpGrayAlphaToFileNamed:(NSString *)name
380 bytes:(uint8_t *)bytes
381 width:(NSUInteger)width
382 height:(NSUInteger)height
383 rowBytes:(NSUInteger)rowBytes;
384- (void) dumpRGBAToRGBFileNamed:(NSString *)rgbName
385 andGrayFileNamed:(NSString *)grayName
386 bytes:(uint8_t *)bytes
387 width:(NSUInteger)width
388 height:(NSUInteger)height
389 rowBytes:(NSUInteger)rowBytes;
390#endif
391
392@end
MouseWheelStatus
@ gvMouseWheelDown
@ gvMouseWheelNeutral
@ gvMouseWheelUp
GameViewKeys
@ gvNumberKey4
@ gvNumberPadKeyDivide
@ gvNumberPadKeyMultiply
@ gvNumberKey9
@ gvNumberKey5
@ gvMouseLeftButton
@ gvNumberPadKeyPeriod
@ gvFunctionKey2
@ gvBackspaceKey
@ gvInsertKey
@ gvNumberPadKeyPlus
@ gvNumberPadKey9
@ gvNumberPadKey1
@ gvFunctionKey10
@ gvFunctionKey5
@ gvDeleteKey
@ gvNumberKey2
@ gvArrowKeyDown
@ gvNumberPadKey2
@ gvFunctionKey9
@ gvNumberPadKey3
@ gvFunctionKey4
@ gvEndKey
@ gvNumberKey0
@ gvNumberKey7
@ gvMouseDoubleClick
@ gvHomeKey
@ gvNumberPadKeyEquals
@ gvNumberPadKey6
@ gvNumberPadKeyEnter
@ gvNumberPadKey5
@ gvNumberPadKey4
@ gvNumberKey8
@ gvNumberKey3
@ gvNumberKey6
@ gvPauseKey
@ gvNumberPadKeyMinus
@ gvNumberPadKey7
@ gvPrintScreenKey
@ gvFunctionKey11
@ gvFunctionKey8
@ gvNumberKey1
@ gvPageDownKey
@ gvNumberPadKey8
@ gvFunctionKey3
@ gvArrowKeyUp
@ gvArrowKeyRight
@ gvFunctionKey6
@ gvArrowKeyLeft
@ gvFunctionKey7
@ gvPageUpKey
@ gvNumberPadKey0
@ gvFunctionKey1
int debug
StringInput
@ gvStringInputAlpha
@ gvStringInputNo
@ gvStringInputLoadSave
@ gvStringInputAll
OOMouseInteractionMode
KeyboardType
@ gvKeyboardUS
@ gvKeyboardUK
@ gvKeyboardAuto
BOOL m_glContextInitialized
BOOL showSplashScreen
BOOL isAlphabetKeyDown
int keycodetrans[255]
GLfloat display_z
BOOL mouseInDeltaMode
BOOL allowingStringInput
NSDictionary * keyMappings_shifted
float _mouseVirtualStickSensitivityFactor
SDL_Surface * surface
float _mouseWheelDelta
NSSize currentWindowSize
NSMutableString * typedString
NSMutableArray * screenSizes
int scancode2Unicode[NUM_KEYS]
float _colorSaturation
NSPoint mouseDragStartPoint
NSPoint virtualJoystickPosition
GLfloat x_offset
NSTimeInterval timeSinceLastMouseWheel
OOOpenGLMatrixManager * matrixManager
NSSize firstScreen
NSTimeInterval timeIntervalAtLastClick
BOOL keys[NUM_KEYS]
NSDictionary * keyMappings_normal
GameController * gameController
GLfloat y_offset
typedef int(ZCALLBACK *close_file_func) OF((voidpf opaque