Oolite 1.91.0.7646-241128-10e222e
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#define MAX_CLEAR_DEPTH 10000000000.0
32// 10 000 000 km.
33#define INTERMEDIATE_CLEAR_DEPTH 100.0
34// 100 m.
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 NUM_KEYS 327
42#define MOUSE_DOUBLE_CLICK_INTERVAL 0.40
43#define OOMOUSEWHEEL_EVENTS_DELAY_INTERVAL 0.05
44#define OOMOUSEWHEEL_DELTA 1.0
45
47
105
112
120
121extern int debug;
122
123@interface MyOpenGLView: NSOpenGLView
124{
125@private
127
128 BOOL keys[NUM_KEYS];
129 int scancode2Unicode[NUM_KEYS];
130 NSDictionary *keyMappings_normal;
131 NSDictionary *keyMappings_shifted;
132
133 BOOL suppressKeys; // DJS
134
140 BOOL f12;
141
142 int keycodetrans[255];
143
145
149
150 NSMutableString *typedString;
151
154
155 NSSize viewSize;
157 GLfloat display_z;
159
160 float _fov;
161
164
166
167}
168
169
170- (void) initKeyMappingData;
171- (void) setStringInput: (enum StringInput) value;
172- (void) allowStringInput: (BOOL) value;
173- (enum StringInput) allowingStringInput;
174- (NSString *) typedString;
175- (void) resetTypedString;
176- (void) setTypedString:(NSString*) value;
177
178- (NSSize) viewSize;
179- (NSSize) backingViewSize;
180- (GLfloat) display_z;
181- (GLfloat) x_offset;
182- (GLfloat) y_offset;
183
184- (GameController *) gameController;
185- (void) setGameController:(GameController *) controller;
186
187- (void) noteMouseInteractionModeChangedFrom:(OOMouseInteractionMode)oldMode to:(OOMouseInteractionMode)newMode;
188
189- (void) initialiseGLWithSize:(NSSize) v_size;
190
191- (NSData *)pixelFormatAttributes;
192
193- (void) drawRect:(NSRect)rect;
194- (void) updateScreen;
195- (void) pollControls;
196
197- (void) stringToClipboard:(NSString *)stringToCopy;
198
199- (BOOL) snapShot:(NSString *)filename;
200
201- (void)mouseDown:(NSEvent *)theEvent;
202- (void)mouseUp:(NSEvent *)theEvent;
203- (void)resetMouse;
204
205- (void) setVirtualJoystick:(double) vmx :(double) vmy;
206- (NSPoint) virtualJoystickPosition;
207
208- (void) clearKeys;
209- (void) clearMouse;
210- (void) clearKey: (int)theKey;
211- (BOOL) isAlphabetKeyDown;
212- (void) suppressKeysUntilKeyUp; // DJS
213- (BOOL) isDown: (int) key;
214- (BOOL) isOptDown;
215- (BOOL) isCtrlDown;
216- (BOOL) isCommandDown;
217- (BOOL) isShiftDown;
218- (BOOL) isCapsLockOn;
219- (BOOL) lastKeyWasShifted;
220- (int) numKeys;
221- (int) mouseWheelState;
222- (float) mouseWheelDelta;
223- (void) setMouseWheelDelta: (float) newWheelDelta;
224
225// Command-key combinations need special handling.
226- (BOOL) isCommandQDown;
227- (BOOL) isCommandFDown;
228- (void) clearCommandF;
229
230// Check current state of shift key rather than relying on last event.
231+ (BOOL)pollShiftKey;
232
233- (OOOpenGLMatrixManager *) getOpenGLMatrixManager;
234
235#ifndef NDEBUG
236// General image-dumping methods.
237- (void) dumpRGBAToFileNamed:(NSString *)name
238 bytes:(uint8_t *)bytes
239 width:(NSUInteger)width
240 height:(NSUInteger)height
241 rowBytes:(NSUInteger)rowBytes;
242
243- (void) dumpRGBToFileNamed:(NSString *)name
244 bytes:(uint8_t *)bytes
245 width:(NSUInteger)width
246 height:(NSUInteger)height
247 rowBytes:(NSUInteger)rowBytes;
248
249- (void) dumpGrayToFileNamed:(NSString *)name
250 bytes:(uint8_t *)bytes
251 width:(NSUInteger)width
252 height:(NSUInteger)height
253 rowBytes:(NSUInteger)rowBytes;
254
255- (void) dumpGrayAlphaToFileNamed:(NSString *)name
256 bytes:(uint8_t *)bytes
257 width:(NSUInteger)width
258 height:(NSUInteger)height
259 rowBytes:(NSUInteger)rowBytes;
260
261// Split alpha into separate file.
262- (void) dumpRGBAToRGBFileNamed:(NSString *)rgbName
263 andGrayFileNamed:(NSString *)grayName
264 bytes:(uint8_t *)bytes
265 width:(NSUInteger)width
266 height:(NSUInteger)height
267 rowBytes:(NSUInteger)rowBytes;
268#endif
269
270// no-ops to allow gamma value to be easily saved/restored
271- (void) setGammaValue: (float) value;
272- (float) gammaValue;
273
274- (void) setFov:(float)value fromFraction:(BOOL)fromFraction;
275- (float) fov:(BOOL)inFraction;
276
277@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
BOOL m_glContextInitialized
BOOL isAlphabetKeyDown
int keycodetrans[255]
GLfloat display_z
BOOL allowingStringInput
NSDictionary * keyMappings_shifted
float _mouseWheelDelta
NSMutableString * typedString
int scancode2Unicode[NUM_KEYS]
NSTimeInterval timeIntervalAtLastMouseWheel
NSData * _pixelFormatAttributes
NSPoint virtualJoystickPosition
NSSize backingViewSize
GLfloat x_offset
OOOpenGLMatrixManager * matrixManager
NSTimeInterval timeIntervalAtLastClick
BOOL keys[NUM_KEYS]
NSDictionary * keyMappings_normal
GameController * gameController
GLfloat y_offset
typedef int(ZCALLBACK *close_file_func) OF((voidpf opaque