Oolite 1.91.0.7644-241112-7f5034b
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 MOUSEVIRTUALSTICKSENSITIVITYFACTOR 0.95f
50#define MOUSEX_MAXIMUM 0.6
51#define MOUSEY_MAXIMUM 0.6
52
53#define MAX_CLEAR_DEPTH 10000000000.0
54// 10 000 000 km.
55#define INTERMEDIATE_CLEAR_DEPTH 100.0
56// 100 m.
57
58
59#define NUM_KEYS 327
60#define MOUSE_DOUBLE_CLICK_INTERVAL 0.40
61#define OOMOUSEWHEEL_EVENTS_DELAY_INTERVAL 0.05
62#define OOMOUSEWHEEL_DELTA 120 // Same as Windows WHEEL_DELTA
63
64#define SNAPSHOTS_PNG_FORMAT 1
65#define SNAPSHOTHDR_EXTENSION_EXR @".exr"
66#define SNAPSHOTHDR_EXTENSION_HDR @".hdr"
67#define SNAPSHOTHDR_EXTENSION_DEFAULT SNAPSHOTHDR_EXTENSION_EXR
68
69@class Entity, GameController, OpenGLSprite;
70
127
134
142
149
150extern int debug;
151
152@interface MyOpenGLView : NSObject
153{
155 BOOL keys[NUM_KEYS];
156 int scancode2Unicode[NUM_KEYS];
157 NSDictionary *keyMappings_normal;
158 NSDictionary *keyMappings_shifted;
159
160 BOOL suppressKeys; // DJS
161
165
166 int keycodetrans[255];
167
170
172
173 NSTimeInterval timeIntervalAtLastClick;
175 BOOL doubleClick;
176
177 NSMutableString *typedString;
178
180
181 NSSize viewSize;
182 GLfloat display_z;
183 GLfloat x_offset, y_offset;
184
186 NSRect bounds;
187
188 float _gamma;
189 float _fov;
190 BOOL _msaa;
191
192 // Full screen sizes
193 NSMutableArray *screenSizes;
194 int currentSize; //we need an int!
196
197 // Windowed mode
199 SDL_Surface *surface;
200
202
203#if OOLITE_WINDOWS
204
205 BOOL wasFullScreen;
206 BOOL updateContext;
207 BOOL saveSize;
208 BOOL atDesktopResolution;
209 unsigned keyboardMap; // *** FLAGGED for deletion
210 HWND SDL_Window;
211 MONITORINFOEX monitorInfo;
212 RECT lastGoodRect;
213 float _hdrMaxBrightness;
214 float _hdrPaperWhiteBrightness;
215
216#endif
217
219
221
223
225
227
228 // Mouse mode indicator (for mouse movement model)
230
232}
233
238- (id) init;
239
240- (void) initSplashScreen;
241- (void) endSplashScreen;
242- (void) autoShowMouse;
243
244- (void) initKeyMappingData;
245
246- (void) setStringInput: (enum StringInput) value;
247- (void) allowStringInput: (BOOL) value;
248- (enum StringInput) allowingStringInput;
249- (NSString *) typedString;
250- (void) resetTypedString;
251- (void) setTypedString:(NSString*) value;
252
253- (NSSize) viewSize;
254- (NSSize) backingViewSize;
255- (GLfloat) display_z;
256- (GLfloat) x_offset;
257- (GLfloat) y_offset;
258
259- (GameController *) gameController;
260- (void) setGameController:(GameController *) controller;
261
262- (void) noteMouseInteractionModeChangedFrom:(OOMouseInteractionMode)oldMode to:(OOMouseInteractionMode)newMode;
263
264- (void) initialiseGLWithSize:(NSSize) v_size;
265- (void) initialiseGLWithSize:(NSSize) v_size useVideoMode:(BOOL) v_mode;
266- (BOOL) isRunningOnPrimaryDisplayDevice;
267#if OOLITE_WINDOWS
268- (BOOL) getCurrentMonitorInfo:(MONITORINFOEX *)mInfo;
269- (MONITORINFOEX) currentMonitorInfo;
270- (void) refreshDarKOrLightMode;
271- (BOOL) isDarkModeOn;
272- (BOOL) atDesktopResolution;
273- (float) hdrMaxBrightness;
274- (void) setHDRMaxBrightness:(float)newMaxBrightness;
275- (float) hdrPaperWhiteBrightness;
276- (void) setHDRPaperWhiteBrightness:(float)newPaperWhiteBrightness;
277#endif
278- (float) colorSaturation;
279- (void) adjustColorSaturation:(float)colorSaturationAdjustment;
280- (BOOL) hdrOutput;
281- (BOOL) isOutputDisplayHDREnabled;
282
283- (void) grabMouseInsideGameWindow:(BOOL) value;
284
285- (void) stringToClipboard:(NSString *)stringToCopy;
286
287- (void) drawRect:(NSRect)rect;
288- (void) updateScreen;
289- (void) updateScreenWithVideoMode:(BOOL) v_mode;
290- (void) display;
291
292- (BOOL) snapShot:(NSString *)filename;
293#if SNAPSHOTS_PNG_FORMAT
294- (BOOL) pngSaveSurface:(NSString *)fileName withSurface:(SDL_Surface *)surf;
295#endif
296
297- (NSRect) bounds;
298+ (NSMutableDictionary *) getNativeSize;
299
300- (void) setFullScreenMode:(BOOL)fsm;
301- (BOOL) inFullScreenMode;
302- (void) toggleScreenMode;
303- (void) setDisplayMode:(int)mode fullScreen:(BOOL)fsm;
304
305- (int) indexOfCurrentSize;
306- (void) setScreenSize: (int)sizeIndex;
307- (NSMutableArray *)getScreenSizeArray;
308- (void) populateFullScreenModelist;
309- (NSSize) modeAsSize: (int)sizeIndex;
310- (void) saveWindowSize: (NSSize) windowSize;
311- (NSSize) loadWindowSize;
312- (int) loadFullscreenSettings;
313- (int) findDisplayModeForWidth: (unsigned int) d_width Height:(unsigned int) d_height
314 Refresh: (unsigned int)d_refresh;
315- (NSSize) currentScreenSize;
316
317- (void) pollControls;
318
319- (void) setVirtualJoystick:(double) vmx :(double) vmy;
320- (NSPoint) virtualJoystickPosition;
321
322- (void) clearKeys;
323- (void) clearMouse;
324- (void) clearKey: (int)theKey;
325- (void) resetMouse;
326- (BOOL) isAlphabetKeyDown;
327- (void) suppressKeysUntilKeyUp; // DJS
328- (BOOL) isDown: (int) key;
329- (BOOL) isOptDown; // opt == alt key
330- (BOOL) isCtrlDown;
331- (BOOL) isCommandDown;
332- (BOOL) isShiftDown;
333- (BOOL) isCapsLockOn;
334- (BOOL) lastKeyWasShifted;
335- (int) numKeys;
336- (int) mouseWheelState;
337- (float) mouseWheelDelta;
338- (void) setMouseWheelDelta: (float) newWheelDelta;
339
340// Command-key combinations need special handling. SDL stubs for these mac functions.
341- (BOOL) isCommandQDown;
342- (BOOL) isCommandFDown;
343- (void) clearCommandF;
344
345- (void) setMouseInDeltaMode: (BOOL) inDelta;
346
347- (void) setGammaValue: (float) value;
348- (float) gammaValue;
349
350- (void) setFov:(float)value fromFraction:(BOOL)fromFraction;
351- (float) fov:(BOOL)inFraction;
352
353- (void) setMsaa:(BOOL)newMsaa;
354- (BOOL) msaa;
355
356// Check current state of shift key rather than relying on last event.
357+ (BOOL)pollShiftKey;
358
359- (OOOpenGLMatrixManager *) getOpenGLMatrixManager;
360
361#ifndef NDEBUG
362// General image-dumping method.
363- (void) dumpRGBAToFileNamed:(NSString *)name
364 bytes:(uint8_t *)bytes
365 width:(NSUInteger)width
366 height:(NSUInteger)height
367 rowBytes:(NSUInteger)rowBytes;
368- (void) dumpRGBToFileNamed:(NSString *)name
369 bytes:(uint8_t *)bytes
370 width:(NSUInteger)width
371 height:(NSUInteger)height
372 rowBytes:(NSUInteger)rowBytes;
373- (void) dumpGrayToFileNamed:(NSString *)name
374 bytes:(uint8_t *)bytes
375 width:(NSUInteger)width
376 height:(NSUInteger)height
377 rowBytes:(NSUInteger)rowBytes;
378- (void) dumpGrayAlphaToFileNamed:(NSString *)name
379 bytes:(uint8_t *)bytes
380 width:(NSUInteger)width
381 height:(NSUInteger)height
382 rowBytes:(NSUInteger)rowBytes;
383- (void) dumpRGBAToRGBFileNamed:(NSString *)rgbName
384 andGrayFileNamed:(NSString *)grayName
385 bytes:(uint8_t *)bytes
386 width:(NSUInteger)width
387 height:(NSUInteger)height
388 rowBytes:(NSUInteger)rowBytes;
389#endif
390
391@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
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