Oolite 1.91.0.7699-250829-cea269d
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
157
168
169extern int debug;
170
171@interface MyOpenGLView : NSObject
172{
173 GameController *gameController;
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 _gamma;
210 float _fov;
211 BOOL _msaa;
212
213 // Full screen sizes
214 NSMutableArray *screenSizes;
215 int currentSize; //we need an int!
217
218 // Windowed mode
220 SDL_Surface *surface;
221
223
224#if OOLITE_WINDOWS
225
226 BOOL wasFullScreen;
227 BOOL updateContext;
228 BOOL saveSize;
229 BOOL atDesktopResolution;
230 unsigned keyboardMap; // *** FLAGGED for deletion
231 HWND SDL_Window;
232 MONITORINFOEX monitorInfo;
233 RECT lastGoodRect;
234 float _hdrMaxBrightness;
235 float _hdrPaperWhiteBrightness;
236 int _hdrToneMapper;
237
238#endif
239
241
243
245
247
249
251
252 // Mouse mode indicator (for mouse movement model)
254
255 float _mouseWheelDelta;
256}
257
262- (id) init;
263
264- (void) initSplashScreen;
265- (void) endSplashScreen;
266- (void) autoShowMouse;
267
269
270- (void) setStringInput: (enum StringInput) value;
271- (void) allowStringInput: (BOOL) value;
273- (NSString *) typedString;
275- (void) setTypedString:(NSString*) value;
276
277- (NSSize) viewSize;
279- (GLfloat) display_z;
280- (GLfloat) x_offset;
281- (GLfloat) y_offset;
282
284- (void) setGameController:(GameController *) controller;
285
286- (void) noteMouseInteractionModeChangedFrom:(OOMouseInteractionMode)oldMode to:(OOMouseInteractionMode)newMode;
287
288- (void) initialiseGLWithSize:(NSSize) v_size;
289- (void) initialiseGLWithSize:(NSSize) v_size useVideoMode:(BOOL) v_mode;
291#if OOLITE_WINDOWS
292- (BOOL) getCurrentMonitorInfo:(MONITORINFOEX *)mInfo;
293- (MONITORINFOEX) currentMonitorInfo;
294- (void) refreshDarKOrLightMode;
295- (BOOL) isDarkModeOn;
296- (BOOL) atDesktopResolution;
297- (float) hdrMaxBrightness;
298- (void) setHDRMaxBrightness:(float)newMaxBrightness;
299- (float) hdrPaperWhiteBrightness;
300- (void) setHDRPaperWhiteBrightness:(float)newPaperWhiteBrightness;
301- (OOHDRToneMapper) hdrToneMapper;
302- (void) setHDRToneMapper: (OOHDRToneMapper)newToneMapper;
303#endif
305- (void) setSDRToneMapper: (OOSDRToneMapper)newToneMapper;
306- (float) colorSaturation;
307- (void) adjustColorSaturation:(float)colorSaturationAdjustment;
308- (BOOL) hdrOutput;
310
311- (void) grabMouseInsideGameWindow:(BOOL) value;
312
313- (void) stringToClipboard:(NSString *)stringToCopy;
314
315- (void) drawRect:(NSRect)rect;
317- (void) updateScreenWithVideoMode:(BOOL) v_mode;
318- (void) display;
319
320- (BOOL) snapShot:(NSString *)filename;
321#if SNAPSHOTS_PNG_FORMAT
322- (BOOL) pngSaveSurface:(NSString *)fileName withSurface:(SDL_Surface *)surf;
323#endif
324
325- (NSRect) bounds;
326+ (NSMutableDictionary *) getNativeSize;
327
328- (void) setFullScreenMode:(BOOL)fsm;
329- (BOOL) inFullScreenMode;
331- (void) setDisplayMode:(int)mode fullScreen:(BOOL)fsm;
332
334- (void) setScreenSize: (int)sizeIndex;
335- (NSMutableArray *)getScreenSizeArray;
337- (NSSize) modeAsSize: (int)sizeIndex;
338- (void) saveWindowSize: (NSSize) windowSize;
339- (NSSize) loadWindowSize;
341- (int) findDisplayModeForWidth: (unsigned int) d_width Height:(unsigned int) d_height
342 Refresh: (unsigned int)d_refresh;
343- (NSSize) currentScreenSize;
344
346
347- (void) setVirtualJoystick:(double) vmx :(double) vmy;
349
350- (void) clearKeys;
351- (void) clearMouse;
352- (void) clearKey: (int)theKey;
353- (void) resetMouse;
356- (BOOL) isDown: (int) key;
357- (BOOL) isOptDown; // opt == alt key
358- (BOOL) isCtrlDown;
360- (BOOL) isShiftDown;
366- (void) setMouseWheelDelta: (float) newWheelDelta;
367
368// Command-key combinations need special handling. SDL stubs for these mac functions.
372
373- (void) setMouseInDeltaMode: (BOOL) inDelta;
374
375- (void) setGammaValue: (float) value;
376- (float) gammaValue;
377
378- (void) setFov:(float)value fromFraction:(BOOL)fromFraction;
379- (float) fov:(BOOL)inFraction;
380
381- (void) setMsaa:(BOOL)newMsaa;
382- (BOOL) msaa;
383
384// Check current state of shift key rather than relying on last event.
386
388
389#ifndef NDEBUG
390// General image-dumping method.
391- (void) dumpRGBAToFileNamed:(NSString *)name
392 bytes:(uint8_t *)bytes
393 width:(NSUInteger)width
394 height:(NSUInteger)height
395 rowBytes:(NSUInteger)rowBytes;
396- (void) dumpRGBToFileNamed:(NSString *)name
397 bytes:(uint8_t *)bytes
398 width:(NSUInteger)width
399 height:(NSUInteger)height
400 rowBytes:(NSUInteger)rowBytes;
401- (void) dumpGrayToFileNamed:(NSString *)name
402 bytes:(uint8_t *)bytes
403 width:(NSUInteger)width
404 height:(NSUInteger)height
405 rowBytes:(NSUInteger)rowBytes;
406- (void) dumpGrayAlphaToFileNamed:(NSString *)name
407 bytes:(uint8_t *)bytes
408 width:(NSUInteger)width
409 height:(NSUInteger)height
410 rowBytes:(NSUInteger)rowBytes;
411- (void) dumpRGBAToRGBFileNamed:(NSString *)rgbName
412 andGrayFileNamed:(NSString *)grayName
413 bytes:(uint8_t *)bytes
414 width:(NSUInteger)width
415 height:(NSUInteger)height
416 rowBytes:(NSUInteger)rowBytes;
417#endif
418
419@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
void suppressKeysUntilKeyUp()
NSMutableArray * getScreenSizeArray()
BOOL isOutputDisplayHDREnabled()
void resetTypedString()
int keycodetrans[255]
GLfloat display_z
void toggleScreenMode()
void initKeyMappingData()
BOOL mouseInDeltaMode
BOOL allowingStringInput
int loadFullscreenSettings()
float mouseWheelDelta()
NSMutableDictionary * getNativeSize()
NSDictionary * keyMappings_shifted
float _mouseVirtualStickSensitivityFactor
SDL_Surface * surface
float _mouseWheelDelta
NSSize currentWindowSize
void populateFullScreenModelist()
BOOL inFullScreenMode()
NSMutableString * typedString
NSMutableArray * screenSizes
int scancode2Unicode[NUM_KEYS]
float _colorSaturation
NSPoint mouseDragStartPoint
NSPoint virtualJoystickPosition
BOOL isRunningOnPrimaryDisplayDevice()
OOOpenGLMatrixManager * getOpenGLMatrixManager()
NSSize backingViewSize
GLfloat x_offset
float colorSaturation()
NSTimeInterval timeSinceLastMouseWheel
OOOpenGLMatrixManager * matrixManager
NSSize firstScreen
BOOL lastKeyWasShifted()
NSTimeInterval timeIntervalAtLastClick
NSSize currentScreenSize()
int indexOfCurrentSize()
BOOL keys[NUM_KEYS]
OOSDRToneMapper sdrToneMapper()
NSDictionary * keyMappings_normal
GameController * gameController
NSSize loadWindowSize()
GLfloat y_offset
typedef int(ZCALLBACK *close_file_func) OF((voidpf opaque