Oolite
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 <SDL3/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 25000.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
157
168
169extern int debug;
170
171@interface MyOpenGLView : NSObject
172{
174 BOOL keys[NUM_KEYS];
175 int scancode2Unicode[NUM_KEYS];
176 NSDictionary *keyMappings_normal;
177 NSDictionary *keyMappings_shifted;
178
179 BOOL suppressKeys; // DJS
180
184
185 int keycodetrans[255];
186
189
191
192 NSTimeInterval timeIntervalAtLastClick;
194 BOOL doubleClick;
195
196 NSMutableString *typedString;
197
199
201
202 NSSize viewSize;
203 GLfloat display_z;
204 GLfloat x_offset, y_offset;
205
207 NSRect bounds;
208
209 float _fov;
210 BOOL _msaa;
211
212 // Full screen sizes
213 NSMutableArray *screenSizes;
214 int currentSize; //we need an int!
216
217 // Windowed mode
219
221 SDL_Window *splashWindow;
222 SDL_Window *window;
223 SDL_GLContext glContext;
226
227#if OOLITE_WINDOWS
228
229 BOOL wasFullScreen;
230 BOOL updateContext;
231 BOOL saveSize;
232 BOOL atDesktopResolution;
233 unsigned keyboardMap; // *** FLAGGED for deletion
234 HWND windowHandle;
235 MONITORINFOEX monitorInfo;
236 RECT lastGoodRect;
237 float _hdrMaxBrightness;
238 float _hdrPaperWhiteBrightness;
239 int _hdrToneMapper;
240
241#endif
242
244
246
248
250
252
254
255 // Mouse mode indicator (for mouse movement model)
257
259}
260
265- (id) init;
266
267- (NSString*) getWindowCaption;
268- (void) createWindowWithSize: (NSSize) size;
269- (void) initSplashScreen;
270- (void) endSplashScreen;
271- (void) autoShowMouse;
272
273- (void) initKeyMappingData;
274
275- (void) setStringInput: (enum StringInput) value;
276- (void) allowStringInput: (BOOL) value;
277- (enum StringInput) allowingStringInput;
278- (NSString *) typedString;
279- (void) resetTypedString;
280- (void) setTypedString:(NSString*) value;
281
282- (NSSize) viewSize;
283- (NSSize) backingViewSize;
284- (GLfloat) display_z;
285- (GLfloat) x_offset;
286- (GLfloat) y_offset;
287
288- (GameController *) gameController;
289- (void) setGameController:(GameController *) controller;
290
291- (void) noteMouseInteractionModeChangedFrom:(OOMouseInteractionMode)oldMode to:(OOMouseInteractionMode)newMode;
292
293- (void) initialiseGLWithSize:(NSSize) v_size;
294- (void) initialiseGLWithSize:(NSSize) v_size useVideoMode:(BOOL) v_mode;
295- (BOOL) isRunningOnPrimaryDisplayDevice;
296#if OOLITE_WINDOWS
297- (BOOL) getCurrentMonitorInfo:(MONITORINFOEX *)mInfo;
298- (MONITORINFOEX) currentMonitorInfo;
299- (void) refreshDarKOrLightMode;
300- (BOOL) isDarkModeOn;
301- (BOOL) atDesktopResolution;
302- (float) hdrMaxBrightness;
303- (void) setHDRMaxBrightness:(float)newMaxBrightness;
304- (float) hdrPaperWhiteBrightness;
305- (void) setHDRPaperWhiteBrightness:(float)newPaperWhiteBrightness;
306- (OOHDRToneMapper) hdrToneMapper;
307- (void) setHDRToneMapper: (OOHDRToneMapper)newToneMapper;
308#endif
309- (OOSDRToneMapper) sdrToneMapper;
310- (void) setSDRToneMapper: (OOSDRToneMapper)newToneMapper;
311- (float) colorSaturation;
312- (void) adjustColorSaturation:(float)colorSaturationAdjustment;
313- (BOOL) hdrOutput;
314- (BOOL) isOutputDisplayHDREnabled;
315
316- (void) grabMouseInsideGameWindow:(BOOL) value;
317
318- (void) stringToClipboard:(NSString *)stringToCopy;
319
320- (void) drawRect:(NSRect)rect;
321- (void) updateScreen;
322- (void) updateScreenWithVideoMode:(BOOL) v_mode;
323- (void) display;
324
325- (BOOL) snapShot:(NSString *)filename;
326
327- (NSRect) bounds;
328- (SDL_DisplayID) getDisplayId;
329- (NSMutableDictionary *) getNativeSize;
330
331- (void) setFullScreenMode:(BOOL)fsm;
332- (BOOL) inFullScreenMode;
333- (void) toggleScreenMode;
334- (void) setDisplayMode:(int)mode fullScreen:(BOOL)fsm;
335
336- (int) indexOfCurrentSize;
337- (void) setScreenSize: (int)sizeIndex;
338- (NSMutableArray *)getScreenSizeArray;
339- (void) populateFullScreenModelist;
340- (NSSize) modeAsSize: (int)sizeIndex;
341- (void) saveWindowSize: (NSSize) windowSize;
342- (NSSize) loadWindowSize;
343- (int) loadFullscreenSettings;
344- (int) findDisplayModeForWidth: (unsigned int) d_width Height:(unsigned int) d_height
345 Refresh: (unsigned int)d_refresh;
346- (NSSize) currentScreenSize;
347- (NSDictionary*) currentScreenMode;
348
349- (void) pollControls;
350
351- (void) setVirtualJoystick:(double) vmx :(double) vmy;
352- (NSPoint) virtualJoystickPosition;
353
354- (void) clearKeys;
355- (void) clearMouse;
356- (void) clearKey: (int)theKey;
357- (void) resetMouse;
358- (BOOL) isAlphabetKeyDown;
359- (void) suppressKeysUntilKeyUp; // DJS
360- (BOOL) isDown: (int) key;
361- (BOOL) isOptDown; // opt == alt key
362- (BOOL) isCtrlDown;
363- (BOOL) isCommandDown;
364- (BOOL) isShiftDown;
365- (BOOL) isCapsLockOn;
366- (BOOL) lastKeyWasShifted;
367- (int) numKeys;
368- (int) mouseWheelState;
369- (float) mouseWheelDelta;
370- (void) setMouseWheelDelta: (float) newWheelDelta;
371
372// Command-key combinations need special handling. SDL stubs for these mac functions.
373- (BOOL) isCommandQDown;
374- (BOOL) isCommandFDown;
375- (void) clearCommandF;
376
377- (void) setMouseInDeltaMode: (BOOL) inDelta;
378
379- (void) setFov:(float)value fromFraction:(BOOL)fromFraction;
380- (float) fov:(BOOL)inFraction;
381
382- (void) setMsaa:(BOOL)newMsaa;
383- (BOOL) msaa;
384
385// Check current state of shift key rather than relying on last event.
386+ (BOOL)pollShiftKey;
387
388- (OOOpenGLMatrixManager *) getOpenGLMatrixManager;
389
390#ifndef NDEBUG
391// General image-dumping method.
392- (void) dumpRGBAToFileNamed:(NSString *)name
393 bytes:(uint8_t *)bytes
394 width:(NSUInteger)width
395 height:(NSUInteger)height
396 rowBytes:(NSUInteger)rowBytes;
397- (void) dumpRGBToFileNamed:(NSString *)name
398 bytes:(uint8_t *)bytes
399 width:(NSUInteger)width
400 height:(NSUInteger)height
401 rowBytes:(NSUInteger)rowBytes;
402- (void) dumpGrayToFileNamed:(NSString *)name
403 bytes:(uint8_t *)bytes
404 width:(NSUInteger)width
405 height:(NSUInteger)height
406 rowBytes:(NSUInteger)rowBytes;
407- (void) dumpGrayAlphaToFileNamed:(NSString *)name
408 bytes:(uint8_t *)bytes
409 width:(NSUInteger)width
410 height:(NSUInteger)height
411 rowBytes:(NSUInteger)rowBytes;
412- (void) dumpRGBAToRGBFileNamed:(NSString *)rgbName
413 andGrayFileNamed:(NSString *)grayName
414 bytes:(uint8_t *)bytes
415 width:(NSUInteger)width
416 height:(NSUInteger)height
417 rowBytes:(NSUInteger)rowBytes;
418#endif
419
420@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
OOHDRToneMapper
@ OOHDR_TONEMAPPER_REINHARD
@ OOHDR_TONEMAPPER_NONE
@ OOHDR_TONEMAPPER_DICE
@ OOHDR_TONEMAPPER_UCHIMURA
@ OOHDR_TONEMAPPER_ACES_APPROX
OOSDRToneMapper
@ OOSDR_TONEMAPPER_UCHIMURA
@ OOSDR_TONEMAPPER_AgX
@ OOSDR_TONEMAPPER_HEJLDAWSON
@ OOSDR_TONEMAPPER_UC2
@ OOSDR_TONEMAPPER_ACES
@ OOSDR_TONEMAPPER_REINHARD
@ OOSDR_TONEMAPPER_NONE
KeyboardType
@ gvKeyboardUS
@ gvKeyboardUK
@ gvKeyboardAuto
StringInput
BOOL m_glContextInitialized
BOOL showSplashScreen
SDL_Window * splashWindow
int bitsPerColorComponent
BOOL isAlphabetKeyDown
int keycodetrans[255]
GLfloat display_z
BOOL mouseInDeltaMode
enum StringInput allowingStringInput
SDL_Window * window
NSDictionary * keyMappings_shifted
float _mouseVirtualStickSensitivityFactor
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
SDL_GLContext glContext
GameController * gameController
GLfloat y_offset
typedef int(ZCALLBACK *close_file_func) OF((voidpf opaque