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#pragma once
25
26#import "OOFoundation.h"
28#import "OOOpenGL.h"
30
31#include <SDL3/SDL_video.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#define NUM_KEYS 327
58#define MOUSE_DOUBLE_CLICK_INTERVAL 0.40
59#define OOMOUSEWHEEL_EVENTS_DELAY_INTERVAL 0.05
60#define OOMOUSEWHEEL_DELTA 120 // Same as Windows WHEEL_DELTA
61
62#define SNAPSHOTS_PNG_FORMAT 1
63#define SNAPSHOTHDR_EXTENSION_EXR @".exr"
64#define SNAPSHOTHDR_EXTENSION_HDR @".hdr"
65#define SNAPSHOTHDR_EXTENSION_DEFAULT SNAPSHOTHDR_EXTENSION_EXR
66
67@class Entity, GameController, OpenGLSprite;
68
124
130
137
143
151
161
162extern int debug;
163
164@interface MyOpenGLView : NSObject {
166 BOOL keys[NUM_KEYS];
167 int scancode2Unicode[NUM_KEYS];
168 NSDictionary* keyMappings_normal;
169 NSDictionary* keyMappings_shifted;
170
171 BOOL suppressKeys; // DJS
172
176
177 int keycodetrans[255];
178
180
182
186
187 NSMutableString* typedString;
188
190
192
193 NSSize viewSize;
194 GLfloat display_z;
195 GLfloat x_offset, y_offset;
196
198 NSRect bounds;
199
200 float _fov;
201 BOOL _msaa;
202
203 // Full screen sizes
204 NSMutableArray* screenSizes;
205 int currentSize; // we need an int!
207
208 // Windowed mode
210
212 SDL_Window* window;
213 SDL_GLContext glContext;
216
217#if OOLITE_WINDOWS
218
219 BOOL saveSize;
220 BOOL atDesktopResolution;
221 unsigned keyboardMap; // *** FLAGGED for deletion
222 HWND windowHandle;
223 RECT lastGoodRect;
224 float _hdrMaxBrightness;
225 float _hdrPaperWhiteBrightness;
226 int _hdrToneMapper;
227
228#endif
229
231
233
235
237
239
241
242 // Mouse mode indicator (for mouse movement model)
244
246}
247
252- (id)init;
253
254- (NSString*)getWindowCaption;
255- (void)createWindowWithSize:(NSSize)size;
256- (void)initSplashScreen;
257- (void)endSplashScreen;
258
259- (NSSize)viewSize;
260- (NSSize)backingViewSize;
261- (GLfloat)display_z;
262- (GLfloat)x_offset;
263- (GLfloat)y_offset;
264
266- (void)setGameController:(GameController*)controller;
267
268- (void)initialiseGLWithSize:(NSSize)v_size;
269- (void)updateGLSize:(NSSize)size;
271- (void)getDisplayDimensions:(unsigned*)width height:(unsigned*)height;
272#if OOLITE_WINDOWS
273- (BOOL)atDesktopResolution;
274- (float)hdrMaxBrightness;
275- (void)setHDRMaxBrightness:(float)newMaxBrightness;
276- (float)hdrPaperWhiteBrightness;
277- (void)setHDRPaperWhiteBrightness:(float)newPaperWhiteBrightness;
278- (OOHDRToneMapper)hdrToneMapper;
279- (void)setHDRToneMapper:(OOHDRToneMapper)newToneMapper;
280#endif
282- (void)setSDRToneMapper:(OOSDRToneMapper)newToneMapper;
283- (float)colorSaturation;
284- (void)adjustColorSaturation:(float)colorSaturationAdjustment;
285- (BOOL)hdrOutput;
287
288- (void)grabMouseInsideGameWindow:(BOOL)value;
289
290- (void)stringToClipboard:(NSString*)stringToCopy;
291
292- (void)updateScreen;
293
294- (BOOL)snapShot:(NSString*)filename;
295
296- (SDL_DisplayID)getDisplayId;
297- (NSMutableDictionary*)getNativeSize;
298
299- (void)setFullScreenMode:(BOOL)fsm;
300- (BOOL)inFullScreenMode;
302- (void)setDisplayMode:(int)mode fullScreen:(BOOL)fsm;
303
304- (void)setScreenSize:(int)sizeIndex;
305- (NSMutableArray*)getScreenSizeArray;
307- (NSSize)modeAsSize:(int)sizeIndex;
308- (void)saveWindowSize:(NSSize)windowSize;
309- (NSSize)loadWindowSize;
311- (int)findDisplayModeForWidth:(unsigned int)d_width Height:(unsigned int)d_height
312 Refresh:(unsigned int)d_refresh;
313- (NSSize)currentScreenSize;
314- (NSDictionary*)currentScreenMode;
315
316// Command-key combinations need special handling. SDL stubs for these mac functions.
317
318- (void)setFov:(float)value fromFraction:(BOOL)fromFraction;
319- (float)fov:(BOOL)inFraction;
320
321- (void)setMsaa:(BOOL)newMsaa;
322- (BOOL)msaa;
323
324// Check current state of shift key rather than relying on last event.
325+ (BOOL)pollShiftKey;
326
328
329#ifndef NDEBUG
330// General image-dumping method.
331- (void)dumpRGBAToFileNamed:(NSString*)name
332 bytes:(uint8_t*)bytes
333 width:(NSUInteger)width
334 height:(NSUInteger)height
335 rowBytes:(NSUInteger)rowBytes;
336- (void)dumpRGBToFileNamed:(NSString*)name
337 bytes:(uint8_t*)bytes
338 width:(NSUInteger)width
339 height:(NSUInteger)height
340 rowBytes:(NSUInteger)rowBytes;
341- (void)dumpGrayToFileNamed:(NSString*)name
342 bytes:(uint8_t*)bytes
343 width:(NSUInteger)width
344 height:(NSUInteger)height
345 rowBytes:(NSUInteger)rowBytes;
346- (void)dumpGrayAlphaToFileNamed:(NSString*)name
347 bytes:(uint8_t*)bytes
348 width:(NSUInteger)width
349 height:(NSUInteger)height
350 rowBytes:(NSUInteger)rowBytes;
351- (void)dumpRGBAToRGBFileNamed:(NSString*)rgbName
352 andGrayFileNamed:(NSString*)grayName
353 bytes:(uint8_t*)bytes
354 width:(NSUInteger)width
355 height:(NSUInteger)height
356 rowBytes:(NSUInteger)rowBytes;
357#endif
358
359@end
360
361#import "MyOpenGLView+Input.h"
362#include <SDL3/SDL_events.h>
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
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
int debug
KeyboardType
@ gvKeyboardUS
@ gvKeyboardUK
@ gvKeyboardAuto
StringInput
@ gvStringInputAlpha
@ gvStringInputNo
@ gvStringInputLoadSave
@ gvStringInputAll
BOOL showSplashScreen
int bitsPerColorComponent
NSMutableArray * getScreenSizeArray()
NSDictionary * keyMappings_shifted
BOOL isAlphabetKeyDown
BOOL isOutputDisplayHDREnabled()
NSDictionary * currentScreenMode()
GLfloat display_z
void toggleScreenMode()
int scancode2Unicode[NUM_KEYS]
NSSize backingViewSize()
BOOL mouseInDeltaMode
enum StringInput allowingStringInput
int loadFullscreenSettings()
NSMutableString * typedString
NSMutableDictionary * getNativeSize()
SDL_Window * window
float _mouseVirtualStickSensitivityFactor
float _mouseWheelDelta
NSSize currentWindowSize
void populateFullScreenModelist()
BOOL inFullScreenMode()
NSMutableArray * screenSizes
int keycodetrans[255]
float _colorSaturation
NSPoint mouseDragStartPoint
OOOpenGLMatrixManager * matrixManager
NSPoint virtualJoystickPosition
BOOL keys[NUM_KEYS]
BOOL isRunningOnPrimaryDisplayDevice()
NSDictionary * keyMappings_normal
OOOpenGLMatrixManager * getOpenGLMatrixManager()
GLfloat x_offset
float colorSaturation()
NSTimeInterval timeSinceLastMouseWheel
NSSize firstScreen
NSTimeInterval timeIntervalAtLastClick
NSSize currentScreenSize()
OOSDRToneMapper sdrToneMapper()
SDL_DisplayID getDisplayId()
SDL_GLContext glContext
GameController * gameController
NSSize loadWindowSize()
GLfloat y_offset
typedef int(ZCALLBACK *close_file_func) OF((voidpf opaque