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