Oolite 1.91.0.7646-241128-10e222e
Loading...
Searching...
No Matches
MyOpenGLView Class Reference

#include <MyOpenGLView.h>

+ Inheritance diagram for MyOpenGLView:
+ Collaboration diagram for MyOpenGLView:

Instance Methods

(void) - initKeyMappingData
 
(void) - setStringInput:
 
(void) - allowStringInput:
 
(enum StringInput- allowingStringInput
 
(NSString *) - typedString
 
(void) - resetTypedString
 
(void) - setTypedString:
 
(NSSize) - viewSize
 
(NSSize) - backingViewSize
 
(GLfloat) - display_z
 
(GLfloat) - x_offset
 
(GLfloat) - y_offset
 
(GameController *) - gameController
 
(void) - setGameController:
 
(void) - noteMouseInteractionModeChangedFrom:to:
 
(void) - initialiseGLWithSize:
 
(NSData *) - pixelFormatAttributes
 
(void) - drawRect:
 
(void) - updateScreen
 
(void) - pollControls
 
(void) - stringToClipboard:
 
(BOOL) - snapShot:
 
(void) - mouseDown:
 
(void) - mouseUp:
 
(void) - resetMouse
 
(void) - setVirtualJoystick:vmx:
 
(NSPoint) - virtualJoystickPosition
 
(void) - clearKeys
 
(void) - clearMouse
 
(void) - clearKey:
 
(BOOL) - isAlphabetKeyDown
 
(void) - suppressKeysUntilKeyUp
 
(BOOL) - isDown:
 
(BOOL) - isOptDown
 
(BOOL) - isCtrlDown
 
(BOOL) - isCommandDown
 
(BOOL) - isShiftDown
 
(BOOL) - isCapsLockOn
 
(BOOL) - lastKeyWasShifted
 
(int- numKeys
 
(int- mouseWheelState
 
(float) - mouseWheelDelta
 
(void) - setMouseWheelDelta:
 
(BOOL) - isCommandQDown
 
(BOOL) - isCommandFDown
 
(void) - clearCommandF
 
(OOOpenGLMatrixManager *) - getOpenGLMatrixManager
 
(void) - dumpRGBAToFileNamed:bytes:width:height:rowBytes:
 
(void) - dumpRGBToFileNamed:bytes:width:height:rowBytes:
 
(void) - dumpGrayToFileNamed:bytes:width:height:rowBytes:
 
(void) - dumpGrayAlphaToFileNamed:bytes:width:height:rowBytes:
 
(void) - dumpRGBAToRGBFileNamed:andGrayFileNamed:bytes:width:height:rowBytes:
 
(void) - setGammaValue:
 
(float) - gammaValue
 
(void) - setFov:fromFraction:
 
(float) - fov:
 
(id) - init
 
(void) - initSplashScreen
 
(void) - endSplashScreen
 
(void) - autoShowMouse
 
(void) - initKeyMappingData
 
(void) - setStringInput:
 
(void) - allowStringInput:
 
(enum StringInput- allowingStringInput
 
(NSString *) - typedString
 
(void) - resetTypedString
 
(void) - setTypedString:
 
(NSSize) - viewSize
 
(NSSize) - backingViewSize
 
(GLfloat) - display_z
 
(GLfloat) - x_offset
 
(GLfloat) - y_offset
 
(GameController *) - gameController
 
(void) - setGameController:
 
(void) - noteMouseInteractionModeChangedFrom:to:
 
(void) - initialiseGLWithSize:
 
(void) - initialiseGLWithSize:useVideoMode:
 
(BOOL) - isRunningOnPrimaryDisplayDevice
 
(float) - colorSaturation
 
(void) - adjustColorSaturation:
 
(BOOL) - hdrOutput
 
(BOOL) - isOutputDisplayHDREnabled
 
(void) - grabMouseInsideGameWindow:
 
(void) - stringToClipboard:
 
(void) - drawRect:
 
(void) - updateScreen
 
(void) - updateScreenWithVideoMode:
 
(void) - display
 
(BOOL) - snapShot:
 
(BOOL) - pngSaveSurface:withSurface:
 
(NSRect) - bounds
 
(void) - setFullScreenMode:
 
(BOOL) - inFullScreenMode
 
(void) - toggleScreenMode
 
(void) - setDisplayMode:fullScreen:
 
(int- indexOfCurrentSize
 
(void) - setScreenSize:
 
(NSMutableArray *) - getScreenSizeArray
 
(void) - populateFullScreenModelist
 
(NSSize) - modeAsSize:
 
(void) - saveWindowSize:
 
(NSSize) - loadWindowSize
 
(int- loadFullscreenSettings
 
(int- findDisplayModeForWidth:Height:Refresh:
 
(NSSize) - currentScreenSize
 
(void) - pollControls
 
(void) - setVirtualJoystick:vmx:
 
(NSPoint) - virtualJoystickPosition
 
(void) - clearKeys
 
(void) - clearMouse
 
(void) - clearKey:
 
(void) - resetMouse
 
(BOOL) - isAlphabetKeyDown
 
(void) - suppressKeysUntilKeyUp
 
(BOOL) - isDown:
 
(BOOL) - isOptDown
 
(BOOL) - isCtrlDown
 
(BOOL) - isCommandDown
 
(BOOL) - isShiftDown
 
(BOOL) - isCapsLockOn
 
(BOOL) - lastKeyWasShifted
 
(int- numKeys
 
(int- mouseWheelState
 
(float) - mouseWheelDelta
 
(void) - setMouseWheelDelta:
 
(BOOL) - isCommandQDown
 
(BOOL) - isCommandFDown
 
(void) - clearCommandF
 
(void) - setMouseInDeltaMode:
 
(void) - setGammaValue:
 
(float) - gammaValue
 
(void) - setFov:fromFraction:
 
(float) - fov:
 
(void) - setMsaa:
 
(BOOL) - msaa
 
(OOOpenGLMatrixManager *) - getOpenGLMatrixManager
 
(void) - dumpRGBAToFileNamed:bytes:width:height:rowBytes:
 
(void) - dumpRGBToFileNamed:bytes:width:height:rowBytes:
 
(void) - dumpGrayToFileNamed:bytes:width:height:rowBytes:
 
(void) - dumpGrayAlphaToFileNamed:bytes:width:height:rowBytes:
 
(void) - dumpRGBAToRGBFileNamed:andGrayFileNamed:bytes:width:height:rowBytes:
 
(id) - initWithFrame: [implementation]
 
(void) - dealloc [implementation]
 
(void) - noteMovedToBadDisplay [implementation]
 
(void) - update [implementation]
 
(BOOL) - acceptsFirstResponder [implementation]
 
(void) - keyUp: [implementation]
 
(void) - keyDown: [implementation]
 
(void) - flagsChanged: [implementation]
 
(void) - mouseMoved: [implementation]
 
(void) - mouseDragged: [implementation]
 
(void) - scrollWheel: [implementation]
 
(void) - otherMouseDragged: [implementation]
 
(void) - rightMouseDown: [implementation]
 
(void) - rightMouseUp: [implementation]
 
(void) - touchesEndedWithEvent: [implementation]
 
(void) - recenterVirtualJoystick [implementation]
 
(int- translateKeyCode: [implementation]
 
(void) - createSurface [implementation]
 
(void) - resetSDLKeyModifiers [implementation]
 
(void) - setWindowBorderless: [implementation]
 
(void) - handleStringInput:keyID: [implementation]
 
(BOOL) - isCommandModifierKeyDown [implementation]
 

Class Methods

(BOOL) + pollShiftKey
 
(NSMutableDictionary *) + getNativeSize
 
(BOOL) + pollShiftKey
 
(static void) + GetDesiredCursorState [implementation]
 
(static void) + ApplyCursorState [implementation]
 
(static void) + UnapplyCursorState [implementation]
 

Protected Attributes

NSPoint mouseDragStartPoint
 
BOOL mouseWarped
 
NSTimeInterval timeSinceLastMouseWheel
 
float _mouseVirtualStickSensitivityFactor
 
double squareX
 
double squareY
 
NSRect bounds
 
float _gamma
 
BOOL _msaa
 
NSMutableArray * screenSizes
 
int currentSize
 
BOOL fullScreen
 
NSSize currentWindowSize
 
SDL_Surface * surface
 
BOOL showSplashScreen
 
float _colorSaturation
 
BOOL _hdrOutput
 
BOOL grabMouseStatus
 
NSSize firstScreen
 
BOOL mouseInDeltaMode
 

Private Attributes

GameControllergameController
 
BOOL keys [NUM_KEYS]
 
int scancode2Unicode [NUM_KEYS]
 
NSDictionary * keyMappings_normal
 
NSDictionary * keyMappings_shifted
 
BOOL suppressKeys
 
BOOL opt
 
BOOL ctrl
 
BOOL command
 
BOOL shift
 
BOOL capsLockOn
 
BOOL lastKeyShifted
 
BOOL allowingStringInput
 
BOOL isAlphabetKeyDown
 
BOOL commandQ
 
BOOL commandF
 
BOOL f12
 
int keycodetrans [255]
 
BOOL m_glContextInitialized
 
NSTimeInterval timeIntervalAtLastClick
 
NSTimeInterval timeIntervalAtLastMouseWheel
 
BOOL doubleClick
 
NSMutableString * typedString
 
NSPoint virtualJoystickPosition
 
float _mouseWheelDelta
 
NSSize viewSize
 
NSSize backingViewSize
 
GLfloat display_z
 
GLfloat x_offset
 
GLfloat y_offset
 
float _fov
 
int _virtualScreen
 
NSData * _pixelFormatAttributes
 
OOOpenGLMatrixManagermatrixManager
 

Detailed Description

Definition at line 123 of file MyOpenGLView.h.

Method Documentation

◆ acceptsFirstResponder

- (BOOL) acceptsFirstResponder
implementation

Definition at line 50 of file MyOpenGLView.m.

548{
549 return YES;
550}

◆ adjustColorSaturation:

- (void) adjustColorSaturation: (float) colorSaturationAdjustment

Definition at line 50 of file MyOpenGLView.m.

1599 :(float)colorSaturationAdjustment;
1600{
1601 _colorSaturation += colorSaturationAdjustment;
1603}
#define MAX_COLOR_SATURATION
float _colorSaturation

Referenced by GlobalSetColorSaturation().

+ Here is the caller graph for this function:

◆ allowingStringInput [1/2]

- (enum StringInput) allowingStringInput

◆ allowingStringInput [2/2]

- (enum StringInput) allowingStringInput

◆ allowStringInput: [1/2]

- (void) allowStringInput: (BOOL) value

Definition at line 50 of file MyOpenGLView.m.

194 :(BOOL)value
195{
196 if (value)
197 {
199 }
200 else
201 {
203 }
204}
@ gvStringInputAlpha
@ gvStringInputNo
BOOL allowingStringInput

◆ allowStringInput: [2/2]

- (void) allowStringInput: (BOOL) value

◆ ApplyCursorState

+ (static void) ApplyCursorState (OOMouseInteractionMode) mode
implementation

Definition at line 1341 of file MyOpenGLView.m.

1342{
1343 BOOL hidden, obscured;
1344 GetDesiredCursorState(mode, &hidden, &obscured);
1345 if (hidden) [NSCursor hide];
1346 if (obscured) [NSCursor setHiddenUntilMouseMoves:YES];
1347}
static void GetDesiredCursorState(OOMouseInteractionMode mode, BOOL *outHidden, BOOL *outObscured)
const char int mode
Definition ioapi.h:133

References GetDesiredCursorState().

+ Here is the call graph for this function:

◆ autoShowMouse

- (void) autoShowMouse

Definition at line 50 of file MyOpenGLView.m.

564{
565 //don't touch the 'please wait...' cursor.
566 if (fullScreen)
567 {
568 if (SDL_ShowCursor(SDL_QUERY) == SDL_ENABLE)
569 SDL_ShowCursor(SDL_DISABLE);
570 }
571 else
572 {
573 if (SDL_ShowCursor(SDL_QUERY) == SDL_DISABLE)
574 SDL_ShowCursor(SDL_ENABLE);
575 }
576}

◆ backingViewSize [1/2]

- (NSSize) backingViewSize

◆ backingViewSize [2/2]

- (NSSize) backingViewSize

◆ bounds

- (NSRect) bounds

◆ clearCommandF [1/2]

- (void) clearCommandF

Definition at line 50 of file MyOpenGLView.m.

1137{
1138 commandF = NO;
1139}

◆ clearCommandF [2/2]

- (void) clearCommandF

◆ clearKey: [1/2]

- (void) clearKey: (int) theKey

Definition at line 50 of file MyOpenGLView.m.

1015 : (int)theKey
1016{
1017 if (theKey >= 0 && theKey < [self numKeys])
1018 {
1019 keys[theKey] = NO;
1020 }
1021}
BOOL keys[NUM_KEYS]
typedef int(ZCALLBACK *close_file_func) OF((voidpf opaque

◆ clearKey: [2/2]

- (void) clearKey: (int) theKey

◆ clearKeys [1/2]

- (void) clearKeys

Definition at line 50 of file MyOpenGLView.m.

999{
1000 int i;
1001 lastKeyShifted = NO;
1002 for (i = 0; i < [self numKeys]; i++)
1003 keys[i] = NO;
1004}

◆ clearKeys [2/2]

- (void) clearKeys

◆ clearMouse [1/2]

- (void) clearMouse

Definition at line 50 of file MyOpenGLView.m.

1008{
1009 keys[gvMouseDoubleClick] = NO;
1010 keys[gvMouseLeftButton] = NO;
1011 doubleClick = NO;
1012}

◆ clearMouse [2/2]

- (void) clearMouse

◆ colorSaturation

- (float) colorSaturation

Definition at line 50 of file MyOpenGLView.m.

1594{
1595 return _colorSaturation;
1596}

Referenced by GlobalSetColorSaturation().

+ Here is the caller graph for this function:

◆ createSurface

- (void) createSurface
implementation

Definition at line 50 of file MyOpenGLView.m.

122{
123 // Changing these flags can trigger texture bugs.
124 const int videoModeFlags = SDL_HWSURFACE | SDL_OPENGL | SDL_RESIZABLE;
125
127 {
128#if OOLITE_WINDOWS
129 // Pre setVideoMode adjustments.
130 NSSize tmp = currentWindowSize;
131 ShowWindow(SDL_Window,SW_SHOWMINIMIZED);
132 updateContext = NO; //don't update the (splash screen) window yet!
133
134 // Initialise the SDL surface. (need custom SDL.dll)
135 surface = SDL_SetVideoMode(firstScreen.width, firstScreen.height, 32, videoModeFlags);
136
137 // Post setVideoMode adjustments.
139#else
140 // Changing the flags can trigger texture bugs.
141 surface = SDL_SetVideoMode(8, 8, 32, videoModeFlags);
142#endif
143 if (!surface) {
144 return;
145 }
146 }
147 else
148 {
149#if OOLITE_WINDOWS
150 updateContext = YES;
151#endif
152 surface = SDL_SetVideoMode(firstScreen.width, firstScreen.height, 32, videoModeFlags);
153 if (!surface) {
154 return;
155 }
156 // blank the surface / go to fullscreen
157 [self initialiseGLWithSize: firstScreen];
158 }
159
160 _gamma = 1.0f;
161 if (SDL_SetGamma(_gamma, _gamma, _gamma) < 0 )
162 {
163 char * errStr = SDL_GetError();
164 OOLogWARN(@"gamma.set.failed", @"Could not set gamma: %s", errStr);
165 // CIM: this doesn't seem to necessarily be fatal. Gamma settings
166 // mostly work on mine despite this function failing.
167 // exit(1);
168 }
169 SDL_EnableUNICODE(1);
170}
#define OOLogWARN(class, format,...)
Definition OOLogging.h:113
BOOL showSplashScreen
SDL_Surface * surface
NSSize currentWindowSize
NSSize firstScreen

◆ currentScreenSize

- (NSSize) currentScreenSize

Definition at line 50 of file MyOpenGLView.m.

2863{
2864 NSDictionary *mode=[screenSizes objectAtIndex: currentSize];
2865
2866 if(mode)
2867 {
2868 return NSMakeSize([[mode objectForKey: kOODisplayWidth] intValue],
2869 [[mode objectForKey: kOODisplayHeight] intValue]);
2870 }
2871 OOLog(@"display.mode.unknown", @"%@", @"Screen size unknown!");
2873}
#define kOODisplayHeight
#define kOODisplayWidth
#define OOLog(class, format,...)
Definition OOLogging.h:88
#define WINDOW_SIZE_DEFAULT_HEIGHT
#define WINDOW_SIZE_DEFAULT_WIDTH

◆ dealloc

- (void) dealloc
implementation

Definition at line 50 of file MyOpenGLView.m.

174{
178
180 [keyMappings_normal release];
182 [keyMappings_shifted release];
183
184 [super dealloc];
185}
#define DESTROY(x)
Definition OOCocoa.h:77
NSDictionary * keyMappings_shifted
NSMutableString * typedString
NSData * _pixelFormatAttributes
OOOpenGLMatrixManager * matrixManager
NSDictionary * keyMappings_normal

◆ display

- (void) display

Definition at line 50 of file MyOpenGLView.m.

758{
759 [self updateScreen];
760}

◆ display_z [1/2]

- (GLfloat) display_z

◆ display_z [2/2]

- (GLfloat) display_z

◆ drawRect: [1/2]

- (void) drawRect: (NSRect) rect

Definition at line 50 of file MyOpenGLView.m.

293 :(NSRect)rect
294{
295 if ((viewSize.width != [self frame].size.width)||(viewSize.height != [self frame].size.height)) // resized
296 {
298 viewSize = [self frame].size;
299 }
300
301 if (!m_glContextInitialized) [self initialiseGLWithSize:viewSize];
302
303 // do all the drawing!
304 if (UNIVERSE != nil) [UNIVERSE drawUniverse];
305 else
306 {
307 // not set up yet, draw a black screen
308 OOGL(glClearColor(0.0, 0.0, 0.0, 0.0));
309 OOGL(glClear(GL_COLOR_BUFFER_BIT));
310 }
311
312 [[self openGLContext] flushBuffer];
313}
#define OOGL(statement)
Definition OOOpenGL.h:251
return nil
#define UNIVERSE
Definition Universe.h:840
BOOL m_glContextInitialized

◆ drawRect: [2/2]

- (void) drawRect: (NSRect) rect

◆ dumpGrayAlphaToFileNamed:bytes:width:height:rowBytes: [1/2]

- (void) dumpGrayAlphaToFileNamed: (NSString *) name
bytes: (uint8_t *) bytes
width: (NSUInteger) width
height: (NSUInteger) height
rowBytes: (NSUInteger) rowBytes 

Definition at line 50 of file MyOpenGLView.m.

1245 :(NSString *)name
1246 bytes:(uint8_t *)bytes
1247 width:(NSUInteger)width
1248 height:(NSUInteger)height
1249 rowBytes:(NSUInteger)rowBytes
1250{
1251 if (name == nil || bytes == NULL || width == 0 || height == 0 || rowBytes < width * 2) return;
1252
1253 NSBitmapImageRep *bitmap = [[NSBitmapImageRep alloc] initWithBitmapDataPlanes:&bytes
1254 pixelsWide:width
1255 pixelsHigh:height
1256 bitsPerSample:8
1257 samplesPerPixel:2
1258 hasAlpha:YES
1259 isPlanar:NO
1260 colorSpaceName:NSCalibratedWhiteColorSpace
1261 bytesPerRow:rowBytes
1262 bitsPerPixel:16];
1263
1264 if (bitmap != nil)
1265 {
1266 [bitmap autorelease];
1267
1268 NSString *filepath = [[[[[NSBundle mainBundle] bundlePath] stringByDeletingLastPathComponent] stringByAppendingPathComponent:name] stringByAppendingPathExtension:@"png"];
1269 [[bitmap representationUsingType:NSPNGFileType properties:[NSDictionary dictionary]] writeToFile:filepath atomically:YES];
1270 }
1271}

Referenced by OODumpPixMap().

+ Here is the caller graph for this function:

◆ dumpGrayAlphaToFileNamed:bytes:width:height:rowBytes: [2/2]

- (void) dumpGrayAlphaToFileNamed: (NSString *) name
bytes: (uint8_t *) bytes
width: (NSUInteger) width
height: (NSUInteger) height
rowBytes: (NSUInteger) rowBytes 

◆ dumpGrayToFileNamed:bytes:width:height:rowBytes: [1/2]

- (void) dumpGrayToFileNamed: (NSString *) name
bytes: (uint8_t *) bytes
width: (NSUInteger) width
height: (NSUInteger) height
rowBytes: (NSUInteger) rowBytes 

Definition at line 50 of file MyOpenGLView.m.

1216 :(NSString *)name
1217 bytes:(uint8_t *)bytes
1218 width:(NSUInteger)width
1219 height:(NSUInteger)height
1220 rowBytes:(NSUInteger)rowBytes
1221{
1222 if (name == nil || bytes == NULL || width == 0 || height == 0 || rowBytes < width) return;
1223
1224 NSBitmapImageRep *bitmap = [[NSBitmapImageRep alloc] initWithBitmapDataPlanes:&bytes
1225 pixelsWide:width
1226 pixelsHigh:height
1227 bitsPerSample:8
1228 samplesPerPixel:1
1229 hasAlpha:NO
1230 isPlanar:NO
1231 colorSpaceName:NSCalibratedWhiteColorSpace
1232 bytesPerRow:rowBytes
1233 bitsPerPixel:8];
1234
1235 if (bitmap != nil)
1236 {
1237 [bitmap autorelease];
1238
1239 NSString *filepath = [[[[[NSBundle mainBundle] bundlePath] stringByDeletingLastPathComponent] stringByAppendingPathComponent:name] stringByAppendingPathExtension:@"png"];
1240 [[bitmap representationUsingType:NSPNGFileType properties:[NSDictionary dictionary]] writeToFile:filepath atomically:YES];
1241 }
1242}

Referenced by OODumpPixMap().

+ Here is the caller graph for this function:

◆ dumpGrayToFileNamed:bytes:width:height:rowBytes: [2/2]

- (void) dumpGrayToFileNamed: (NSString *) name
bytes: (uint8_t *) bytes
width: (NSUInteger) width
height: (NSUInteger) height
rowBytes: (NSUInteger) rowBytes 

◆ dumpRGBAToFileNamed:bytes:width:height:rowBytes: [1/2]

- (void) dumpRGBAToFileNamed: (NSString *) name
bytes: (uint8_t *) bytes
width: (NSUInteger) width
height: (NSUInteger) height
rowBytes: (NSUInteger) rowBytes 

Definition at line 50 of file MyOpenGLView.m.

1159 :(NSString *)name
1160 bytes:(uint8_t *)bytes
1161 width:(NSUInteger)width
1162 height:(NSUInteger)height
1163 rowBytes:(NSUInteger)rowBytes
1164{
1165 if (name == nil || bytes == NULL || width == 0 || height == 0 || rowBytes < width * 4) return;
1166
1167 NSBitmapImageRep *bitmap = [[NSBitmapImageRep alloc] initWithBitmapDataPlanes:&bytes
1168 pixelsWide:width
1169 pixelsHigh:height
1170 bitsPerSample:8
1171 samplesPerPixel:4
1172 hasAlpha:YES
1173 isPlanar:NO
1174 colorSpaceName:NSCalibratedRGBColorSpace
1175 bytesPerRow:rowBytes
1176 bitsPerPixel:32];
1177
1178 if (bitmap != nil)
1179 {
1180 [bitmap autorelease];
1181
1182 NSString *filepath = [[[[[NSBundle mainBundle] bundlePath] stringByDeletingLastPathComponent] stringByAppendingPathComponent:name] stringByAppendingPathExtension:@"png"];
1183 [[bitmap representationUsingType:NSPNGFileType properties:[NSDictionary dictionary]] writeToFile:filepath atomically:YES];
1184 }
1185}

◆ dumpRGBAToFileNamed:bytes:width:height:rowBytes: [2/2]

- (void) dumpRGBAToFileNamed: (NSString *) name
bytes: (uint8_t *) bytes
width: (NSUInteger) width
height: (NSUInteger) height
rowBytes: (NSUInteger) rowBytes 

◆ dumpRGBAToRGBFileNamed:andGrayFileNamed:bytes:width:height:rowBytes: [1/2]

- (void) dumpRGBAToRGBFileNamed: (NSString *) rgbName
andGrayFileNamed: (NSString *) grayName
bytes: (uint8_t *) bytes
width: (NSUInteger) width
height: (NSUInteger) height
rowBytes: (NSUInteger) rowBytes 

Definition at line 50 of file MyOpenGLView.m.

1274 :(NSString *)rgbName
1275 andGrayFileNamed:(NSString *)grayName
1276 bytes:(uint8_t *)bytes
1277 width:(NSUInteger)width
1278 height:(NSUInteger)height
1279 rowBytes:(NSUInteger)rowBytes
1280{
1281 if ((rgbName == nil && grayName == nil) || bytes == NULL || width == 0 || height == 0 || rowBytes < width * 4) return;
1282
1283 uint8_t *rgbBytes, *rgbPx, *grayBytes, *grayPx, *srcPx;
1284 NSUInteger x, y;
1285 BOOL trivalAlpha = YES;
1286
1287 rgbPx = rgbBytes = malloc(width * height * 3);
1288 if (rgbBytes == NULL) return;
1289
1290 grayPx = grayBytes = malloc(width * height);
1291 if (grayBytes == NULL)
1292 {
1293 free(rgbBytes);
1294 return;
1295 }
1296
1297 for (y = 0; y < height; y++)
1298 {
1299 srcPx = bytes + rowBytes * y;
1300
1301 for (x = 0; x < width; x++)
1302 {
1303 *rgbPx++ = *srcPx++;
1304 *rgbPx++ = *srcPx++;
1305 *rgbPx++ = *srcPx++;
1306 trivalAlpha = trivalAlpha && ((*srcPx == 0xFF) || (*srcPx == 0x00)); // Look for any "interesting" pixels in alpha.
1307 *grayPx++ = *srcPx++;
1308 }
1309 }
1310
1311 [self dumpRGBToFileNamed:rgbName
1312 bytes:rgbBytes
1313 width:width
1314 height:height
1315 rowBytes:width * 3];
1316 free(rgbBytes);
1317
1318 if (!trivalAlpha)
1319 {
1320 [self dumpGrayToFileNamed:grayName
1321 bytes:grayBytes
1322 width:width
1323 height:height
1324 rowBytes:width];
1325 }
1326 free(grayBytes);
1327}
float y
float x

Referenced by OODumpPixMap().

+ Here is the caller graph for this function:

◆ dumpRGBAToRGBFileNamed:andGrayFileNamed:bytes:width:height:rowBytes: [2/2]

- (void) dumpRGBAToRGBFileNamed: (NSString *) rgbName
andGrayFileNamed: (NSString *) grayName
bytes: (uint8_t *) bytes
width: (NSUInteger) width
height: (NSUInteger) height
rowBytes: (NSUInteger) rowBytes 

◆ dumpRGBToFileNamed:bytes:width:height:rowBytes: [1/2]

- (void) dumpRGBToFileNamed: (NSString *) name
bytes: (uint8_t *) bytes
width: (NSUInteger) width
height: (NSUInteger) height
rowBytes: (NSUInteger) rowBytes 

Definition at line 50 of file MyOpenGLView.m.

1187 :(NSString *)name
1188 bytes:(uint8_t *)bytes
1189 width:(NSUInteger)width
1190 height:(NSUInteger)height
1191 rowBytes:(NSUInteger)rowBytes
1192{
1193 if (name == nil || bytes == NULL || width == 0 || height == 0 || rowBytes < width * 3) return;
1194
1195 NSBitmapImageRep *bitmap = [[NSBitmapImageRep alloc] initWithBitmapDataPlanes:&bytes
1196 pixelsWide:width
1197 pixelsHigh:height
1198 bitsPerSample:8
1199 samplesPerPixel:3
1200 hasAlpha:NO
1201 isPlanar:NO
1202 colorSpaceName:NSCalibratedRGBColorSpace
1203 bytesPerRow:rowBytes
1204 bitsPerPixel:24];
1205
1206 if (bitmap != nil)
1207 {
1208 [bitmap autorelease];
1209
1210 NSString *filepath = [[[[[NSBundle mainBundle] bundlePath] stringByDeletingLastPathComponent] stringByAppendingPathComponent:name] stringByAppendingPathExtension:@"png"];
1211 [[bitmap representationUsingType:NSPNGFileType properties:[NSDictionary dictionary]] writeToFile:filepath atomically:YES];
1212 }
1213}

◆ dumpRGBToFileNamed:bytes:width:height:rowBytes: [2/2]

- (void) dumpRGBToFileNamed: (NSString *) name
bytes: (uint8_t *) bytes
width: (NSUInteger) width
height: (NSUInteger) height
rowBytes: (NSUInteger) rowBytes 

◆ endSplashScreen

- (void) endSplashScreen

Definition at line 50 of file MyOpenGLView.m.

449{
450#if OOLITE_WINDOWS
451 if ([self hdrOutput] && ![self isOutputDisplayHDREnabled])
452 {
453 if (MessageBox(NULL, "No primary display in HDR mode was detected.\n\n"
454 "If you continue, graphics will not be rendered as intended.\n"
455 "Click OK to launch anyway, or Cancel to exit.", "oolite.exe - HDR requested",
456 MB_OKCANCEL | MB_ICONWARNING) == IDCANCEL)
457 {
458 exit (1);
459 }
460 }
461#endif // OOLITE_WINDOWS
462
463 if (!showSplashScreen) return;
464
465#if OOLITE_WINDOWS
466
467 wasFullScreen = !fullScreen;
468 updateContext = YES;
469 ShowWindow(SDL_Window,SW_RESTORE);
470 [self initialiseGLWithSize: firstScreen];
471
472#else
473
474 int videoModeFlags = SDL_HWSURFACE | SDL_OPENGL;
475
476 videoModeFlags |= (fullScreen) ? SDL_FULLSCREEN : SDL_RESIZABLE;
477 surface = SDL_SetVideoMode(firstScreen.width, firstScreen.height, 32, videoModeFlags);
478
479 if (!surface && fullScreen == YES)
480 {
481 [self setFullScreenMode: NO];
482 videoModeFlags &= ~SDL_FULLSCREEN;
483 videoModeFlags |= SDL_RESIZABLE;
484 surface = SDL_SetVideoMode(currentWindowSize.width, currentWindowSize.height, 32, videoModeFlags);
485 }
486
487 SDL_putenv ("SDL_VIDEO_WINDOW_POS=none"); //stop linux from auto centering on resize
488
489 /* MKW 2011.11.11
490 * Eat all SDL events to gobble up any resize events while the
491 * splash-screen was visible. They affected the main window after 1.74.
492 * TODO: should really process SDL events while showing the splash-screen
493
494 int numEvents = 0;
495 */
496 SDL_Event dummyEvent;
497 while (SDL_PollEvent(&dummyEvent))
498 {
499 /* Do nothing; the below is for development info
500 numEvents++;
501 OOLog(@"display.splash", @"Suppressed splash-screen event %d: %d ", numEvents, dummyEvent.type);
502 */
503 }
504
505
506#endif
507
508 [self updateScreen];
509 [self autoShowMouse];
510}
BOOL isOutputDisplayHDREnabled()

◆ findDisplayModeForWidth:Height:Refresh:

- (int) findDisplayModeForWidth: (unsigned int) d_width
Height: (unsigned int) d_height
Refresh: (unsigned int) d_refresh 

Definition at line 50 of file MyOpenGLView.m.

2835 :(unsigned int) d_width Height:(unsigned int) d_height Refresh:(unsigned int) d_refresh
2836{
2837 int i, modeCount;
2838 NSDictionary *mode;
2839 unsigned int modeWidth, modeHeight, modeRefresh;
2840
2841 modeCount = [screenSizes count];
2842
2843 for (i = 0; i < modeCount; i++)
2844 {
2845 mode = [screenSizes objectAtIndex: i];
2846 modeWidth = [[mode objectForKey: kOODisplayWidth] intValue];
2847 modeHeight = [[mode objectForKey: kOODisplayHeight] intValue];
2848 modeRefresh = [[mode objectForKey: kOODisplayRefreshRate] intValue];
2849 if ((modeWidth == d_width)&&(modeHeight == d_height)&&(modeRefresh == d_refresh))
2850 {
2851 OOLog(@"display.mode.found", @"Found mode %@", mode);
2852 return i;
2853 }
2854 }
2855
2856 OOLog(@"display.mode.found.failed", @"Failed to find mode: width=%d height=%d refresh=%d", d_width, d_height, d_refresh);
2857 OOLog(@"display.mode.found.failed.list", @"Contents of list: %@", screenSizes);
2858 return 0;
2859}
NSMutableArray * screenSizes

◆ flagsChanged:

- (void) flagsChanged: (NSEvent *) theEvent
implementation

Definition at line 50 of file MyOpenGLView.m.

743 :(NSEvent *)theEvent
744{
745 NSUInteger flags = [theEvent modifierFlags];
746 opt = (flags & NSAlternateKeyMask) ? YES : NO;
747 ctrl = (flags & NSControlKeyMask) ? YES : NO;
748 command = (flags & NSCommandKeyMask) ? YES : NO;
749 shift = ( flags & NSShiftKeyMask ) ? YES : NO;
750 if ([theEvent keyCode] == 0x39) // 57 = key code for caps lock
751 {
752 capsLockOn = (flags & NSAlphaShiftKeyMask) ? YES : NO;
753 }
754}

◆ fov: [1/2]

- (float) fov: (BOOL) inFraction

Definition at line 1350 of file MyOpenGLView.m.

1376 :(BOOL)inFraction
1377{
1378 return inFraction ? _fov : 2 * atanf(_fov) * 180.0f / M_PI;
1379}
#define M_PI
Definition OOMaths.h:73

References GetDesiredCursorState().

Referenced by HeadUpDisplay::drawScannerGrid.

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ fov: [2/2]

- (float) fov: (BOOL) inFraction

◆ gameController [1/2]

- (GameController *) gameController

◆ gameController [2/2]

- (GameController *) gameController

◆ gammaValue [1/2]

- (float) gammaValue

Definition at line 1350 of file MyOpenGLView.m.

1365{
1366 return 1.0;
1367}

◆ gammaValue [2/2]

- (float) gammaValue

◆ GetDesiredCursorState

+ (static void) GetDesiredCursorState (OOMouseInteractionMode) mode
(BOOL *) outHidden
(BOOL *) outObscured 
implementation

Definition at line 1332 of file MyOpenGLView.m.

1333{
1334 NSCParameterAssert(outHidden != NULL && outObscured != NULL);
1335
1337 *outObscured = (mode == MOUSE_MODE_FLIGHT_NO_MOUSE_CONTROL);
1338}
@ MOUSE_MODE_FLIGHT_WITH_MOUSE_CONTROL
@ MOUSE_MODE_FLIGHT_NO_MOUSE_CONTROL

References MOUSE_MODE_FLIGHT_NO_MOUSE_CONTROL, and MOUSE_MODE_FLIGHT_WITH_MOUSE_CONTROL.

◆ getNativeSize

+ (NSMutableDictionary *) getNativeSize

Definition at line 50 of file MyOpenGLView.m.

88{
89 NSMutableDictionary *mode=[[NSMutableDictionary alloc] init];
90 int nativeDisplayWidth = 1024;
91 int nativeDisplayHeight = 768;
92
93#if OOLITE_LINUX
94 SDL_SysWMinfo dpyInfo;
95 SDL_VERSION(&dpyInfo.version);
96 if(SDL_GetWMInfo(&dpyInfo))
97 {
98 nativeDisplayWidth = DisplayWidth(dpyInfo.info.x11.display, 0);
99 nativeDisplayHeight = DisplayHeight(dpyInfo.info.x11.display, 0);
100 OOLog(@"display.mode.list.native", @"X11 native resolution detected: %d x %d", nativeDisplayWidth, nativeDisplayHeight);
101 }
102 else
103 {
104 OOLog(@"display.mode.list.native.failed", @"%@", @"SDL_GetWMInfo failed, defaulting to 1024x768 for native size");
105 }
106#elif OOLITE_WINDOWS
107 nativeDisplayWidth = GetSystemMetrics(SM_CXSCREEN);
108 nativeDisplayHeight = GetSystemMetrics(SM_CYSCREEN);
109 OOLog(@"display.mode.list.native", @"Windows native resolution detected: %d x %d", nativeDisplayWidth, nativeDisplayHeight);
110#else
111 OOLog(@"display.mode.list.native.unknown", @"Unknown architecture, defaulting to 1024x768");
112#endif
113 [mode setValue: [NSNumber numberWithInt: nativeDisplayWidth] forKey:kOODisplayWidth];
114 [mode setValue: [NSNumber numberWithInt: nativeDisplayHeight] forKey: kOODisplayHeight];
115 [mode setValue: [NSNumber numberWithInt: 0] forKey: kOODisplayRefreshRate];
116
117 return [mode autorelease];
118}

◆ getOpenGLMatrixManager [1/2]

- (OOOpenGLMatrixManager *) getOpenGLMatrixManager

Definition at line 50 of file MyOpenGLView.m.

1153{
1154 return matrixManager;
1155}

◆ getOpenGLMatrixManager [2/2]

- (OOOpenGLMatrixManager *) getOpenGLMatrixManager

◆ getScreenSizeArray

- (NSMutableArray *) getScreenSizeArray

◆ grabMouseInsideGameWindow:

- (void) grabMouseInsideGameWindow: (BOOL) value

Definition at line 50 of file MyOpenGLView.m.

1322 :(BOOL) value
1323{
1324 // do nothing
1325}

◆ handleStringInput:keyID:

- (void) handleStringInput: (SDL_KeyboardEvent *) kbd_event
keyID: (Uint16) key_id 
implementation

Provided by category MyOpenGLView(OOPrivate).

Definition at line 50 of file MyOpenGLView.m.

2670 : (SDL_KeyboardEvent *) kbd_event keyID:(Uint16)key_id;
2671{
2672 SDLKey key=kbd_event->keysym.sym;
2673
2674 // Del, Backspace
2675 if((key == SDLK_BACKSPACE || key == SDLK_DELETE) && [typedString length] > 0)
2676 {
2677 // delete
2678 [typedString deleteCharactersInRange:NSMakeRange([typedString length]-1, 1)];
2679 }
2680
2682
2683 // TODO: a more flexible mechanism for max. string length ?
2684 if([typedString length] < 40)
2685 {
2688 {
2689 // inputAlpha - limited input for planet find screen
2690 if(key >= SDLK_a && key <= SDLK_z)
2691 {
2693 [typedString appendFormat:@"%c", key];
2694 // if in inputAlpha, keep in lower case.
2695 }
2696 }
2697 else
2698 {
2699 //Uint16 unicode = kbd_event->keysym.unicode;
2700 // printable range
2701 if (key_id >= 32 && key_id <= 255) // 126
2702 {
2703 if ((char)key_id != '/' || allowingStringInput == gvStringInputAll)
2704 {
2706 [typedString appendFormat:@"%c", key_id];
2707 }
2708 }
2709 }
2710 }
2711}
@ gvStringInputAll
BOOL isAlphabetKeyDown

◆ hdrOutput

- (BOOL) hdrOutput

Definition at line 50 of file MyOpenGLView.m.

1347{
1348 return NO;
1349}

◆ indexOfCurrentSize

- (int) indexOfCurrentSize

◆ inFullScreenMode

- (BOOL) inFullScreenMode

Definition at line 50 of file MyOpenGLView.m.

672{
673 return fullScreen;
674}

◆ initialiseGLWithSize: [1/2]

- (void) initialiseGLWithSize: (NSSize) v_size

Definition at line 50 of file MyOpenGLView.m.

358 :(NSSize)v_size
359{
360 viewSize = v_size;
361 if (viewSize.width/viewSize.height > 4.0/3.0) {
362 display_z = 480.0 * viewSize.width/viewSize.height;
363 x_offset = 240.0 * viewSize.width/viewSize.height;
364 y_offset = 240.0;
365 } else {
366 display_z = 640.0;
367 x_offset = 320.0;
368 y_offset = 320.0 * viewSize.height/viewSize.width;
369 }
370
371 if ([self respondsToSelector:@selector(convertSizeToBacking:)])
372 {
373 // High resolution mode support.
374 backingViewSize = [self convertSizeToBacking:viewSize];
375 }
376 else
377 {
379 }
380
381 [self openGLContext]; // Force lazy setup if needed.
382 [[self gameController] setUpBasicOpenGLStateWithSize:v_size];
383 [[self openGLContext] flushBuffer];
384
386}
GLfloat display_z
NSSize backingViewSize
GLfloat x_offset
GLfloat y_offset

◆ initialiseGLWithSize: [2/2]

- (void) initialiseGLWithSize: (NSSize) v_size

◆ initialiseGLWithSize:useVideoMode:

- (void) initialiseGLWithSize: (NSSize) v_size
useVideoMode: (BOOL) v_mode 

Definition at line 50 of file MyOpenGLView.m.

1366 :(NSSize) v_size useVideoMode:(BOOL) v_mode
1367{
1368#if OOLITE_LINUX
1369 NSSize oldViewSize = viewSize;
1370#endif
1371 viewSize = v_size;
1372 OOLog(@"display.initGL", @"Requested a new surface of %d x %d, %@.", (int)viewSize.width, (int)viewSize.height,(fullScreen ? @"fullscreen" : @"windowed"));
1373 SDL_GL_SwapBuffers(); // clear the buffer before resize
1374
1375#if OOLITE_WINDOWS
1376 if (!updateContext) return;
1377
1378 DEVMODE settings;
1379 settings.dmSize = sizeof(DEVMODE);
1380 settings.dmDriverExtra = 0;
1381 EnumDisplaySettings(0, ENUM_CURRENT_SETTINGS, &settings);
1382
1383 WINDOWPLACEMENT windowPlacement;
1384 windowPlacement.length = sizeof(WINDOWPLACEMENT);
1385 GetWindowPlacement(SDL_Window, &windowPlacement);
1386
1387 static BOOL lastWindowPlacementMaximized = NO;
1388 if (fullScreen && (windowPlacement.showCmd == SW_SHOWMAXIMIZED))
1389 {
1390 if (!wasFullScreen)
1391 {
1392 lastWindowPlacementMaximized = YES;
1393 }
1394 }
1395
1396 if (lastWindowPlacementMaximized)
1397 {
1398 windowPlacement.showCmd = SW_SHOWMAXIMIZED;
1399 }
1400
1401 // are we attempting to go to a different screen resolution? Note: this also takes care of secondary monitor situations because
1402 // by design the only resolution available for fullscreen on a secondary display device is its native one - Nikos 20150605
1403 BOOL changingResolution = [self isRunningOnPrimaryDisplayDevice] &&
1404 ((fullScreen && (settings.dmPelsWidth != viewSize.width || settings.dmPelsHeight != viewSize.height)) ||
1405 (wasFullScreen && (settings.dmPelsWidth != [[[screenSizes objectAtIndex:0] objectForKey: kOODisplayWidth] intValue]
1406 || settings.dmPelsHeight != [[[screenSizes objectAtIndex:0] objectForKey: kOODisplayHeight] intValue])));
1407
1408 RECT wDC;
1409
1410 if (fullScreen)
1411 {
1412 /*NOTE: If we ever decide to change the default behaviour of launching
1413 always on primary monitor to launching on the monitor the program was
1414 started on, all that needs to be done is comment out the line below, as
1415 well as the identical one in the else branch further down.
1416 Nikos 20141222
1417 */
1418 [self getCurrentMonitorInfo: &monitorInfo];
1419
1420 settings.dmPelsWidth = viewSize.width;
1421 settings.dmPelsHeight = viewSize.height;
1422 settings.dmFields = DM_PELSWIDTH | DM_PELSHEIGHT;
1423
1424 // just before going fullscreen, save the location of the current window. It
1425 // may be needed in case of potential attempts to move our fullscreen window
1426 // in a maximized state (yes, in Windows this is entirely possible).
1427 if(lastWindowPlacementMaximized)
1428 {
1429 CopyRect(&lastGoodRect, &windowPlacement.rcNormalPosition);
1430 // if maximized, switch to normal placement before going full screen
1431 windowPlacement.showCmd = SW_SHOWNORMAL;
1432 SetWindowPlacement(SDL_Window, &windowPlacement);
1433 }
1434 else GetWindowRect(SDL_Window, &lastGoodRect);
1435
1436 // ok, can go fullscreen now
1437 SetForegroundWindow(SDL_Window);
1438 if (changingResolution)
1439 {
1440 if (ChangeDisplaySettingsEx(monitorInfo.szDevice, &settings, NULL, CDS_FULLSCREEN, NULL) != DISP_CHANGE_SUCCESSFUL)
1441 {
1443 OOLogERR(@"displayMode.change.error", @"Could not switch to requested display mode.");
1444 return;
1445 }
1446 atDesktopResolution = settings.dmPelsWidth == [[[screenSizes objectAtIndex:0] objectForKey: kOODisplayWidth] intValue]
1447 && settings.dmPelsHeight == [[[screenSizes objectAtIndex:0] objectForKey: kOODisplayHeight] intValue];
1448 }
1449
1450 MoveWindow(SDL_Window, monitorInfo.rcMonitor.left, monitorInfo.rcMonitor.top, (int)viewSize.width, (int)viewSize.height, TRUE);
1451 if(!wasFullScreen)
1452 {
1453 [self setWindowBorderless:YES];
1454 }
1455 }
1456
1457 else if ( wasFullScreen )
1458 {
1459 if (changingResolution)
1460 {
1461 // restore original desktop resolution
1462 if (ChangeDisplaySettingsEx(NULL, NULL, NULL, 0, NULL) == DISP_CHANGE_SUCCESSFUL)
1463 {
1464 atDesktopResolution = YES;
1465 }
1466 }
1467
1468 /*NOTE: If we ever decide to change the default behaviour of launching
1469 always on primary monitor to launching on the monitor the program was
1470 started on, we need to comment out the line below.
1471 For now, this line is needed for correct positioning of our window in case
1472 we return from a non-native resolution fullscreen and has to come after the
1473 display settings have been reverted.
1474 Nikos 20141222
1475 */
1476 [self getCurrentMonitorInfo: &monitorInfo];
1477
1478 if (lastWindowPlacementMaximized) CopyRect(&windowPlacement.rcNormalPosition, &lastGoodRect);
1479 SetWindowPlacement(SDL_Window, &windowPlacement);
1480 if (!lastWindowPlacementMaximized)
1481 {
1482 MoveWindow(SDL_Window, (monitorInfo.rcMonitor.right - monitorInfo.rcMonitor.left - (int)viewSize.width)/2 +
1483 monitorInfo.rcMonitor.left,
1484 (monitorInfo.rcMonitor.bottom - monitorInfo.rcMonitor.top - (int)viewSize.height)/2 +
1485 monitorInfo.rcMonitor.top,
1486 (int)viewSize.width, (int)viewSize.height, TRUE);
1487 }
1488
1489 [self setWindowBorderless:NO];
1490
1491 lastWindowPlacementMaximized = NO;
1492 ShowWindow(SDL_Window,SW_SHOW);
1493 }
1494
1495 // stop saveWindowSize from reacting to caption & frame if necessary
1496 saveSize = !wasFullScreen;
1497
1498 GetClientRect(SDL_Window, &wDC);
1499
1500 if (!fullScreen && (bounds.size.width != wDC.right - wDC.left
1501 || bounds.size.height != wDC.bottom - wDC.top))
1502 {
1503 // Resize the game window if needed. When we ask for a W x H
1504 // window, we intend that the client area be W x H. The actual
1505 // window itself must become big enough to accomodate an area
1506 // of such size.
1507 if (wasFullScreen) // this is true when switching from full screen or when starting in windowed mode
1508 //after the splash screen has ended
1509 {
1510 RECT desiredClientRect;
1511 GetWindowRect(SDL_Window, &desiredClientRect);
1512 AdjustWindowRect(&desiredClientRect, WS_CAPTION | WS_THICKFRAME, FALSE);
1513 SetWindowPos(SDL_Window, NULL, desiredClientRect.left, desiredClientRect.top,
1514 desiredClientRect.right - desiredClientRect.left,
1515 desiredClientRect.bottom - desiredClientRect.top, 0);
1516 }
1517 GetClientRect(SDL_Window, &wDC);
1518 viewSize.width = wDC.right - wDC.left;
1519 viewSize.height = wDC.bottom - wDC.top;
1520 }
1521
1522 // Reset bounds and viewSize to current values
1523 bounds.size.width = viewSize.width = wDC.right - wDC.left;
1524 bounds.size.height = viewSize.height = wDC.bottom - wDC.top;
1525
1526 if (fullScreen) // bounds on fullscreen coincide with client area, since we are borderless
1527 {
1528 bounds.origin.x = monitorInfo.rcMonitor.left;
1529 bounds.origin.y = monitorInfo.rcMonitor.top;
1530 }
1531 wasFullScreen=fullScreen;
1532
1533#else //OOLITE_LINUX
1534
1535 int videoModeFlags = SDL_HWSURFACE | SDL_OPENGL;
1536
1537 if (v_mode == NO)
1538 videoModeFlags |= SDL_NOFRAME;
1539 if (fullScreen == YES)
1540 {
1541 videoModeFlags |= SDL_FULLSCREEN;
1542 }
1543 else
1544 {
1545 videoModeFlags |= SDL_RESIZABLE;
1546 }
1547 surface = SDL_SetVideoMode((int)viewSize.width, (int)viewSize.height, 32, videoModeFlags);
1548
1549 if (!surface && fullScreen == YES)
1550 {
1551 [self setFullScreenMode: NO];
1552 viewSize = oldViewSize;
1553 videoModeFlags &= ~SDL_FULLSCREEN;
1554 videoModeFlags |= SDL_RESIZABLE;
1555 surface = SDL_SetVideoMode((int)viewSize.width, (int)viewSize.height, 32, videoModeFlags);
1556 }
1557
1558 if (!surface)
1559 {
1560 // we should always have a valid surface, but in case we don't
1561 OOLogERR(@"display.mode.error",@"Unable to change display mode: %s",SDL_GetError());
1562 exit(1);
1563 }
1564
1565 bounds.size.width = surface->w;
1566 bounds.size.height = surface->h;
1567
1568#endif
1569 OOLog(@"display.initGL", @"Created a new surface of %d x %d, %@.", (int)viewSize.width, (int)viewSize.height,(fullScreen ? @"fullscreen" : @"windowed"));
1570
1571 if (viewSize.width/viewSize.height > 4.0/3.0) {
1572 display_z = 480.0 * bounds.size.width/bounds.size.height;
1573 x_offset = 240.0 * bounds.size.width/bounds.size.height;
1574 y_offset = 240.0;
1575 } else {
1576 display_z = 640.0;
1577 x_offset = 320.0;
1578 y_offset = 320.0 * bounds.size.height/bounds.size.width;
1579 }
1580
1581 if (surface != 0) SDL_FreeSurface(surface);
1582
1583 [self autoShowMouse];
1584
1585 [[self gameController] setUpBasicOpenGLStateWithSize:viewSize];
1586 SDL_GL_SwapBuffers();
1587 squareX = 0.0f;
1588
1590}
#define OOLogERR(class, format,...)
Definition OOLogging.h:112

◆ initKeyMappingData [1/2]

- (void) initKeyMappingData

Definition at line 50 of file MyOpenGLView.m.

159{
160 NSUserDefaults *prefs = [NSUserDefaults standardUserDefaults];
161 NSDictionary *kmap = [NSDictionary dictionaryWithDictionary:[ResourceManager dictionaryFromFilesNamed:@"keymappings_mac.plist" inFolder:@"Config" mergeMode:MERGE_BASIC cache:NO]];
162 // get the stored keyboard code from preferences
163 NSString *kbd = [prefs oo_stringForKey:@"keyboard-code" defaultValue:@"default"];
164 NSDictionary *subset = [kmap objectForKey:kbd];
165
166 [keyMappings_normal release];
167 keyMappings_normal = [[subset objectForKey:@"mapping_normal"] copy];
168 [keyMappings_shifted release];
169 keyMappings_shifted = [[subset objectForKey:@"mapping_shifted"] copy];
170}
NSDictionary * dictionaryFromFilesNamed:inFolder:mergeMode:cache:(NSString *fileName,[inFolder] NSString *folderName,[mergeMode] OOResourceMergeMode mergeMode,[cache] BOOL useCache)

◆ initKeyMappingData [2/2]

- (void) initKeyMappingData

◆ initSplashScreen

- (void) initSplashScreen

Definition at line 50 of file MyOpenGLView.m.

805{
806 if (!showSplashScreen) return;
807
808 //too early for OOTexture!
809 SDL_Surface *image=NULL;
810 SDL_Rect dest;
811
812 NSString *imagesDir = [[[NSBundle mainBundle] resourcePath] stringByAppendingPathComponent:@"Images"];
813
814 image = SDL_LoadBMP([[imagesDir stringByAppendingPathComponent:@"splash.bmp"] UTF8String]);
815
816 if (image == NULL)
817 {
818 SDL_FreeSurface(image);
819 OOLogWARN(@"sdl.gameStart", @"%@", @"image 'splash.bmp' not found!");
820 [self endSplashScreen];
821 return;
822 }
823
824 dest.x = 0;
825 dest.y = 0;
826 dest.w = image->w;
827 dest.h = image->h;
828
829 #if OOLITE_WINDOWS
830
831 dest.x = (GetSystemMetrics(SM_CXSCREEN)- dest.w)/2;
832 dest.y = (GetSystemMetrics(SM_CYSCREEN)-dest.h)/2;
833 SetWindowLong(SDL_Window,GWL_STYLE,GetWindowLong(SDL_Window,GWL_STYLE) & ~WS_CAPTION & ~WS_THICKFRAME);
834 ShowWindow(SDL_Window,SW_RESTORE);
835 MoveWindow(SDL_Window,dest.x,dest.y,dest.w,dest.h,TRUE);
836
837 #else
838
839 /* MKW 2011.11.11
840 * According to Marc using the NOFRAME flag causes trouble under Ubuntu 8.04.
841 *
842 * The current Ubuntu LTS is 10.04, which doesn't seem to have that problem.
843 * 12.04 LTS is going to be released soon, also without apparent problems.
844 * Changed to SDL_NOFRAME, throwing caution to the wind - Kaks 2012.03.23
845 * Took SDL_NOFRAME out, since it still causes strange problems here - cim 2012.04.09
846 */
847 surface = SDL_SetVideoMode(dest.w, dest.h, 32, SDL_HWSURFACE | SDL_OPENGL);
848
849 #endif
850
852
853 glViewport( 0, 0, dest.w, dest.h);
854
855 glEnable( GL_TEXTURE_2D );
856 glClearColor( 0.0f, 0.0f, 0.0f, 0.0f );
857 glClear( GL_COLOR_BUFFER_BIT );
858
859 [matrixManager resetProjection];
860 [matrixManager orthoLeft: 0.0f right: dest.w bottom: dest.h top: 0.0 near: -1.0 far: 1.0];
861 [matrixManager syncProjection];
862
863 [matrixManager resetModelView];
864 [matrixManager syncModelView];
865
866 GLuint texture;
867 GLenum texture_format;
868 GLint nOfColors;
869
870 // get the number of channels in the SDL image
871 nOfColors = image->format->BytesPerPixel;
872 if (nOfColors == 4) // contains an alpha channel
873 {
874 if (image->format->Rmask == 0x000000ff)
875 texture_format = GL_RGBA;
876 else
877 texture_format = GL_BGRA;
878 }
879 else if (nOfColors == 3) // no alpha channel
880 {
881 if (image->format->Rmask == 0x000000ff)
882 texture_format = GL_RGB;
883 else
884 texture_format = GL_BGR;
885 } else {
886 SDL_FreeSurface(image);
887 OOLog(@"Sdl.GameStart", @"%@", @"----- Encoding error within image 'splash.bmp'");
888 [self endSplashScreen];
889 return;
890 }
891
892 glGenTextures( 1, &texture );
893 glBindTexture( GL_TEXTURE_2D, texture );
894
895 // Set the texture's stretching properties
896 glTexParameteri( GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR );
897 glTexParameteri( GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR );
898
899 // Set the texture image data with the information from SDL_Surface
900 glTexImage2D( GL_TEXTURE_2D, 0, nOfColors, image->w, image->h, 0,
901 texture_format, GL_UNSIGNED_BYTE, image->pixels );
902
903 glBindTexture( GL_TEXTURE_2D, texture );
904 glBegin( GL_QUADS );
905
906 glTexCoord2i( 0, 0 );
907 glVertex2i( 0, 0 );
908 glTexCoord2i( 1, 0 );
909 glVertex2i( dest.w, 0 );
910 glTexCoord2i( 1, 1 );
911 glVertex2i( dest.w, dest.h );
912 glTexCoord2i( 0, 1 );
913 glVertex2i( 0, dest.h );
914
915 glEnd();
916
917 SDL_GL_SwapBuffers();
918 [matrixManager resetModelView];
919 [matrixManager syncModelView];
920
921 if ( image ) {
922 SDL_FreeSurface( image );
923 }
924 glDeleteTextures(1, &texture);
925
926 glDisable( GL_TEXTURE_2D );
928}
@ OPENGL_STATE_OVERLAY
Definition OOOpenGL.h:126
#define OOVerifyOpenGLState()
Definition OOOpenGL.h:136
#define OOSetOpenGLState(STATE)
Definition OOOpenGL.h:135

◆ initWithFrame:

- (id) initWithFrame: (NSRect) frameRect
implementation

Definition at line 50 of file MyOpenGLView.m.

81 :(NSRect)frameRect
82{
83#ifndef NDEBUG
84 if (NSZombieEnabled)
85 {
86 OOLog(@"debug.zombieEnabled", @"*** ZOMBIES WILL EAT YOUR BRAIN ***");
87 }
88#endif
89
90 // Pixel Format Attributes for the View-based (non-FullScreen) NSOpenGLContext
91 NSOpenGLPixelFormatAttribute attrs[] =
92 {
93 // Specify that we want a windowed OpenGL context.
94 // Must be first or we'll hit an assert in the legacy fullscreen controller.
95 NSOpenGLPFAWindow,
96
97 // We may be on a multi-display system (and each screen may be driven by a different renderer), so we need to specify which screen we want to take over.
98 // For this demo, we'll specify the main screen.
99 NSOpenGLPFAScreenMask, CGDisplayIDToOpenGLDisplayMask(kCGDirectMainDisplay),
100
101 // Specifying "NoRecovery" gives us a context that cannot fall back to the software renderer.
102 // This makes the View-based context a compatible with the fullscreen context, enabling us to use the "shareContext"
103 // feature to share textures, display lists, and other OpenGL objects between the two.
104 NSOpenGLPFANoRecovery,
105
106 // Attributes Common to FullScreen and non-FullScreen
107 NSOpenGLPFACompliant,
108
109 NSOpenGLPFAColorSize, 32,
110 NSOpenGLPFADepthSize, 32,
111 NSOpenGLPFADoubleBuffer,
112 NSOpenGLPFAAccelerated,
113#if FSAA
114 // Need a preference or other sane way to activate this
115 NSOpenGLPFAMultisample,
116 NSOpenGLPFASampleBuffers, 1,
117 NSOpenGLPFASamples,4,
118#endif
119 0
120 };
121
122 // Create our non-FullScreen pixel format.
123 NSOpenGLPixelFormat *pixelFormat = [[[NSOpenGLPixelFormat alloc] initWithAttributes:attrs] autorelease];
124
125 if ((self = [super initWithFrame:frameRect pixelFormat:pixelFormat]))
126 {
127 if ([self respondsToSelector:@selector(setAcceptsTouchEvents:)])
128 {
129 [self setAcceptsTouchEvents:YES];
130 }
131
132 if ([self respondsToSelector:@selector(setWantsBestResolutionOpenGLSurface:)])
133 {
134 // Enable high resolution on Retina displays.
135 [self setWantsBestResolutionOpenGLSurface:YES];
136 }
137
138 matrixManager = [[OOOpenGLMatrixManager alloc] init];
139 _pixelFormatAttributes = [[NSData alloc] initWithBytes:attrs length:sizeof attrs];
140 virtualJoystickPosition = NSMakePoint(0.0,0.0);
141
142 typedString = [[NSMutableString alloc] initWithString:@""];
145
146 timeIntervalAtLastClick = [NSDate timeIntervalSinceReferenceDate];
147
148 _virtualScreen = [[self openGLContext] currentVirtualScreen];
149 }
150
151 // preload the printscreen key into our translation array because SDLK_PRINTSCREEN isn't available
153 [self initKeyMappingData];
154
155 return self;
156}
@ gvPrintScreenKey
int scancode2Unicode[NUM_KEYS]
NSPoint virtualJoystickPosition
NSTimeInterval timeIntervalAtLastClick

◆ isAlphabetKeyDown [1/2]

- (BOOL) isAlphabetKeyDown

◆ isAlphabetKeyDown [2/2]

- (BOOL) isAlphabetKeyDown

◆ isCapsLockOn [1/2]

- (BOOL) isCapsLockOn

Definition at line 50 of file MyOpenGLView.m.

1084{
1085 return capsLockOn;
1086}

◆ isCapsLockOn [2/2]

- (BOOL) isCapsLockOn

◆ isCommandDown [1/2]

- (BOOL) isCommandDown

Definition at line 50 of file MyOpenGLView.m.

1072{
1073 return command;
1074}

◆ isCommandDown [2/2]

- (BOOL) isCommandDown

◆ isCommandFDown [1/2]

- (BOOL) isCommandFDown

Definition at line 50 of file MyOpenGLView.m.

1131{
1132 return commandF;
1133}

◆ isCommandFDown [2/2]

- (BOOL) isCommandFDown

◆ isCommandModifierKeyDown

- (BOOL) isCommandModifierKeyDown
implementation

Provided by category MyOpenGLView(OOLoadSaveExtensions).

Definition at line 1003 of file PlayerEntityLoadSave.m.

1355{
1356 return [self isCtrlDown];
1357}

◆ isCommandQDown [1/2]

- (BOOL) isCommandQDown

Definition at line 50 of file MyOpenGLView.m.

1125{
1126 return commandQ;
1127}

◆ isCommandQDown [2/2]

- (BOOL) isCommandQDown

◆ isCtrlDown [1/2]

- (BOOL) isCtrlDown

Definition at line 50 of file MyOpenGLView.m.

1066{
1067 return ctrl;
1068}

◆ isCtrlDown [2/2]

- (BOOL) isCtrlDown

◆ isDown: [1/2]

- (BOOL) isDown: (int) key

Definition at line 50 of file MyOpenGLView.m.

1047 : (int) key
1048{
1049 if( suppressKeys )
1050 return NO;
1051 if ( key < 0 )
1052 return NO;
1053 if ( key >= [self numKeys] )
1054 return NO;
1055 return keys[key];
1056}

◆ isDown: [2/2]

- (BOOL) isDown: (int) key

◆ isOptDown [1/2]

- (BOOL) isOptDown

Definition at line 50 of file MyOpenGLView.m.

1060{
1061 return opt;
1062}

◆ isOptDown [2/2]

- (BOOL) isOptDown

◆ isOutputDisplayHDREnabled

- (BOOL) isOutputDisplayHDREnabled

Definition at line 50 of file MyOpenGLView.m.

1353{
1354 return NO;
1355}

◆ isRunningOnPrimaryDisplayDevice

- (BOOL) isRunningOnPrimaryDisplayDevice

Definition at line 50 of file MyOpenGLView.m.

1317{
1318 return YES;
1319}

◆ isShiftDown [1/2]

- (BOOL) isShiftDown

Definition at line 50 of file MyOpenGLView.m.

1078{
1079 return shift;
1080}

◆ isShiftDown [2/2]

- (BOOL) isShiftDown

◆ keyDown:

- (void) keyDown: (NSEvent *) theEvent
implementation

Definition at line 50 of file MyOpenGLView.m.

616 :(NSEvent *)theEvent
617{
618 NSString *stringValue = nil;
619 int key;
620 int keycode;
621
622 stringValue = [theEvent charactersIgnoringModifiers];
623
624 /* Bug: exception when pressing accent key.
625 Analysis: Dead keys (accents and similar) return an empty string.
626 Fix: reject zero-length strings. This is the Wrong Thing - we should
627 really be using KeyTranslate()/UCKeyTranslate() to find out what the
628 string would be if you pressed the key and then space.
629 -- Ahruman 20070714
630 */
631 //if ([stringValue length] < 1) return;
632
633 keycode = [theEvent keyCode] & 255;
634
635 if ([stringValue length] < 1)
636 {
637 if (!shift)
638 {
639 NSString *keyNormal = [keyMappings_normal objectForKey:[NSString stringWithFormat:@"%d", keycode]];
640 if (keyNormal) stringValue = [NSString stringWithFormat:@"%c", [keyNormal integerValue]];
641 }
642 else
643 {
644 NSString *keyShifted = [keyMappings_shifted objectForKey:[NSString stringWithFormat:@"%d", keycode]];
645 if (keyShifted) stringValue = [NSString stringWithFormat:@"%c", [keyShifted integerValue]];
646 }
647 // if we still have a zero-length string, return at this point
648 if ([stringValue length] < 1) return;
649 }
650
651 key = [stringValue characterAtIndex:0];
652 key = [self translateKeyCode:key];
653
654 OOLog(kOOLogKeyDown, @"Key down: stringValue = \"%@\", keyCode = %d, key = %u", stringValue, keycode, key);
655
656 // Special handling of command keys used in full-screen mode.
657 if ([theEvent modifierFlags] & NSCommandKeyMask)
658 {
659 switch (key)
660 {
661 case 'q':
662 commandQ = YES;
663 break;
664
665 case 'f':
666 commandF = YES;
667 break;
668 }
669
670 return;
671 }
672
673 keycodetrans[keycode] = key; // record the character we got for pressing the hardware at key location 'keycode'
674
675 /* HACK: treat f12 as alias to cmd-F for compatibility with helpful forum
676 advice etc.
677 */
678 if (key == NSF12FunctionKey)
679 {
680 if (!f12)
681 {
682 f12 = YES;
683 [gameController performSelector:@selector(toggleFullScreenAction:) withObject:nil afterDelay:0.0];
684 }
685
686 return;
687 };
688
689 if ((key >= 0)&&(key < [self numKeys])&&(!keys[key]))
690 {
691 keys[key] = YES;
692
694 {
695 if ((key == gvDeleteKey || key == gvBackspaceKey) && [typedString length] > 0)
696 {
697 // delete
698 [typedString deleteCharactersInRange:NSMakeRange([typedString length] - 1, 1)];
699 }
700
703
704 // limited input for planet find screen
706 {
707 if (isalpha(key))
708 {
709 isAlphabetKeyDown = YES;
710 // convert to lower case
711 [typedString appendFormat:@"%c", tolower(key)];
712 }
713 }
714
715 // full input for load-save screen or 'all' input
717 {
718 // except '/' for loadsave
719 if (isprint(key) && key != '/')
720 {
721 isAlphabetKeyDown = YES;
722 [typedString appendFormat:@"%c", key];
723 }
724 else if (key == '/' && allowingStringInput == gvStringInputAll)
725 {
726 isAlphabetKeyDown = YES;
727 [typedString appendFormat:@"%c", key];
728 }
729 }
730
731 }
732 }
733 else
734 {
735 if (key > [self numKeys])
736 {
737 OOLog(kOOLogKeyCodeOutOfRange, @"Translated key: %d out of range", key);
738 }
739 }
740}
static NSString * kOOLogKeyCodeOutOfRange
static NSString * kOOLogKeyDown
@ gvBackspaceKey
@ gvDeleteKey
@ gvStringInputLoadSave
int keycodetrans[255]

Referenced by OoliteApp::sendEvent:.

+ Here is the caller graph for this function:

◆ keyUp:

- (void) keyUp: (NSEvent *) theEvent
implementation

Definition at line 50 of file MyOpenGLView.m.

553 :(NSEvent *)theEvent
554{
555 NSString *stringValue = nil;
556 int key;
557 int keycode;
558
559 stringValue = [theEvent charactersIgnoringModifiers];
560
561 /* Bug: exception when releasing accent key.
562 Analysis: Dead keys (accents and similar) return an empty string.
563 Fix: reject zero-length strings. This is the Wrong Thing - we should
564 really be using KeyTranslate()/UCKeyTranslate() to find out what the
565 string would be if you pressed the key and then space.
566 -- Ahruman 20070714
567 */
568 if ([stringValue length] < 1) return;
569
570 suppressKeys = NO;
571
572 keycode = [theEvent keyCode] & 255;
573 key = keycodetrans[keycode]; // retrieve the character we got for pressing the hardware at key location 'keycode'
574
575 OOLog(kOOLogKeyUp, @"Key up: stringValue = \"%@\", keyCode = %d, key = %u", stringValue, keycode, key);
576
577 // Special handling of command keys used in full-screen mode.
578 if ([theEvent modifierFlags] & NSCommandKeyMask)
579 {
580 switch (key)
581 {
582 case 'q':
583 commandQ = NO;
584 break;
585
586 case 'f':
587 commandF = NO;
588 break;
589 }
590 // Pass through to allow clearing of normal key as well.
591 }
592
593 /* HACK: treat f12 as alias to cmd-F for compatibility with helpful forum
594 advice etc.
595 */
596 if (key == NSF12FunctionKey)
597 {
598 commandF = NO;
599 f12 = NO;
600 return;
601 };
602
604 if ((key >= 0)&&(key < [self numKeys])&&(keys[key]))
605 {
606 keys[key] = NO;
607 }
608 else
609 {
610 if (key > [self numKeys])
611 OOLog(kOOLogKeyCodeOutOfRange, @"Translated key: %d out of range", key);
612 }
613}
static NSString * kOOLogKeyUp

Referenced by OoliteApp::sendEvent:.

+ Here is the caller graph for this function:

◆ lastKeyWasShifted [1/2]

- (BOOL) lastKeyWasShifted

Definition at line 50 of file MyOpenGLView.m.

1090{
1091 return lastKeyShifted;
1092}

◆ lastKeyWasShifted [2/2]

- (BOOL) lastKeyWasShifted

◆ loadFullscreenSettings

- (int) loadFullscreenSettings

Definition at line 50 of file MyOpenGLView.m.

2800{
2801 currentSize=0;
2802 int width=0, height=0, refresh=0;
2803 unsigned i;
2804
2805 NSArray* cmdline_arguments = [[NSProcessInfo processInfo] arguments];
2806
2807 NSUserDefaults *userDefaults = [NSUserDefaults standardUserDefaults];
2808 if ([userDefaults objectForKey:@"display_width"])
2809 width = [userDefaults integerForKey:@"display_width"];
2810 if ([userDefaults objectForKey:@"display_height"])
2811 height = [userDefaults integerForKey:@"display_height"];
2812 if ([userDefaults objectForKey:@"display_refresh"])
2813 refresh = [userDefaults integerForKey:@"display_refresh"];
2814 if([userDefaults objectForKey:@"fullscreen"])
2815 fullScreen=[userDefaults boolForKey:@"fullscreen"];
2816
2817 // Check if -fullscreen or -windowed has been passed on the command line. If yes,
2818 // set it regardless of what is set by .GNUstepDefaults. If both are found in the
2819 // arguments list, the one that comes last wins.
2820 for (i = 0; i < [cmdline_arguments count]; i++)
2821 {
2822 if ([[cmdline_arguments objectAtIndex:i] isEqual:@"-fullscreen"]) fullScreen = YES;
2823 if ([[cmdline_arguments objectAtIndex:i] isEqual:@"-windowed"]) fullScreen = NO;
2824 }
2825
2826 if(width && height)
2827 {
2828 currentSize=[self findDisplayModeForWidth: width Height: height Refresh: refresh];
2829 return currentSize;
2830 }
2831 return currentSize;
2832}

◆ loadWindowSize

- (NSSize) loadWindowSize

Definition at line 50 of file MyOpenGLView.m.

2782{
2783 NSSize windowSize;
2784 NSUserDefaults *defaults=[NSUserDefaults standardUserDefaults];
2785 if([defaults objectForKey:@"window_width"] && [defaults objectForKey:@"window_height"])
2786 {
2787 windowSize=NSMakeSize([defaults integerForKey: @"window_width"],
2788 [defaults integerForKey: @"window_height"]);
2789 }
2790 else
2791 {
2793 }
2794 currentWindowSize=windowSize;
2795 return windowSize;
2796}

◆ modeAsSize:

- (NSSize) modeAsSize: (int) sizeIndex

◆ mouseDown:

- (void) mouseDown: (NSEvent *) theEvent

Definition at line 50 of file MyOpenGLView.m.

757 :(NSEvent *)theEvent
758{
759 if (doubleClick)
760 {
761 doubleClick = NO;
762 keys[gvMouseDoubleClick] = NO;
763 }
764 keys[gvMouseLeftButton] = YES; // 'a' down
765}

◆ mouseDragged:

- (void) mouseDragged: (NSEvent *) theEvent
implementation

Definition at line 50 of file MyOpenGLView.m.

811 :(NSEvent *)theEvent
812{
813 [self mouseMoved:theEvent];
814}

◆ mouseMoved:

- (void) mouseMoved: (NSEvent *) theEvent
implementation

Definition at line 50 of file MyOpenGLView.m.

791 :(NSEvent *)theEvent
792{
793 double mx = [theEvent locationInWindow].x - viewSize.width/2.0;
794 double my = [theEvent locationInWindow].y - viewSize.height/2.0;
795
796 if (display_z > 640.0)
797 {
799 my /= viewSize.height;
800 }
801 else
802 {
803 mx /= MAIN_GUI_PIXEL_WIDTH * viewSize.width / 640.0;
804 my /= MAIN_GUI_PIXEL_HEIGHT * viewSize.width / 640.0;
805 }
806
807 [self setVirtualJoystick:mx :-my];
808}
#define MAIN_GUI_PIXEL_WIDTH
#define MAIN_GUI_PIXEL_HEIGHT

◆ mouseUp:

- (void) mouseUp: (NSEvent *) theEvent

Definition at line 50 of file MyOpenGLView.m.

768 :(NSEvent *)theEvent
769{
770 NSTimeInterval timeBetweenClicks = [NSDate timeIntervalSinceReferenceDate] - timeIntervalAtLastClick;
771 timeIntervalAtLastClick += timeBetweenClicks;
772
773 if (!doubleClick)
774 {
775 doubleClick = (timeBetweenClicks < MOUSE_DOUBLE_CLICK_INTERVAL); // One fifth of a second
776 keys[gvMouseDoubleClick] = doubleClick;
777 }
778
779 keys[gvMouseLeftButton] = NO; // 'a' up
780}
#define MOUSE_DOUBLE_CLICK_INTERVAL

◆ mouseWheelDelta [1/2]

- (float) mouseWheelDelta

Definition at line 50 of file MyOpenGLView.m.

1113{
1115}
#define OOMOUSEWHEEL_DELTA
float _mouseWheelDelta

◆ mouseWheelDelta [2/2]

- (float) mouseWheelDelta

◆ mouseWheelState [1/2]

- (int) mouseWheelState

Definition at line 50 of file MyOpenGLView.m.

1102{
1103 if (_mouseWheelDelta > 0.0f)
1104 return gvMouseWheelUp;
1105 else if (_mouseWheelDelta < 0.0f)
1106 return gvMouseWheelDown;
1107 else
1108 return gvMouseWheelNeutral;
1109}
@ gvMouseWheelDown
@ gvMouseWheelNeutral
@ gvMouseWheelUp

◆ mouseWheelState [2/2]

- (int) mouseWheelState

◆ msaa

- (BOOL) msaa

Definition at line 50 of file MyOpenGLView.m.

2913{
2914 return _msaa;
2915}

◆ noteMouseInteractionModeChangedFrom:to: [1/2]

- (void) noteMouseInteractionModeChangedFrom: (OOMouseInteractionMode) oldMode
to: (OOMouseInteractionMode) newMode 

Definition at line 50 of file MyOpenGLView.m.

273{
274 UnapplyCursorState(oldMode);
275 ApplyCursorState(newMode);
276}
OOMouseInteractionMode
static void ApplyCursorState(OOMouseInteractionMode mode)
static void UnapplyCursorState(OOMouseInteractionMode mode)

◆ noteMouseInteractionModeChangedFrom:to: [2/2]

- (void) noteMouseInteractionModeChangedFrom: (OOMouseInteractionMode) oldMode
to: (OOMouseInteractionMode) newMode 

◆ noteMovedToBadDisplay

- (void) noteMovedToBadDisplay
implementation

Definition at line 50 of file MyOpenGLView.m.

317{
318 NSRunInformationalAlertPanel(DESC(@"oolite-mac-bad-display"), @"%@", nil, nil, nil, DESC(@"oolite-mac-bad-display-2"));
319}
#define DESC(key)
Definition Universe.h:846

◆ numKeys [1/2]

- (int) numKeys

Definition at line 50 of file MyOpenGLView.m.

1096{
1097 return NUM_KEYS;
1098}
#define NUM_KEYS

◆ numKeys [2/2]

- (int) numKeys

◆ otherMouseDragged:

- (void) otherMouseDragged: (NSEvent *) theEvent
implementation

Definition at line 50 of file MyOpenGLView.m.

840 :(NSEvent *)theEvent
841{
842 [self mouseMoved:theEvent];
843}

◆ pixelFormatAttributes

- (NSData *) pixelFormatAttributes

Definition at line 50 of file MyOpenGLView.m.

390{
392}

◆ pngSaveSurface:withSurface:

- (BOOL) pngSaveSurface: (NSString *) fileName
withSurface: (SDL_Surface *) surf 

Definition at line 50 of file MyOpenGLView.m.

1729 :(NSString *)fileName withSurface:(SDL_Surface *)surf
1730{
1731 FILE *fp;
1732 png_structp pngPtr;
1733 png_infop infoPtr;
1734 int i, colorType;
1735 png_bytep *rowPointers;
1736
1737 fp = fopen([fileName UTF8String], "wb");
1738 if (fp == NULL)
1739 {
1740 OOLog(@"pngSaveSurface.fileCreate.failed", @"Failed to create output screenshot file %@", fileName);
1741 return NO;
1742 }
1743
1744 // initialize png structures (no callbacks)
1745 pngPtr = png_create_write_struct(PNG_LIBPNG_VER_STRING, NULL, NULL, NULL);
1746 if (pngPtr == NULL)
1747 {
1748 return NO;
1749 }
1750
1751 infoPtr = png_create_info_struct(pngPtr);
1752 if (infoPtr == NULL) {
1753 png_destroy_write_struct(&pngPtr, (png_infopp)NULL);
1754 OOLog(@"pngSaveSurface.info_struct.failed", @"%@", @"png_create_info_struct error");
1755 exit(-1);
1756 }
1757
1758 if (setjmp(png_jmpbuf(pngPtr)))
1759 {
1760 png_destroy_write_struct(&pngPtr, &infoPtr);
1761 fclose(fp);
1762 exit(-1);
1763 }
1764
1765 png_init_io(pngPtr, fp);
1766
1767 colorType = PNG_COLOR_MASK_COLOR; /* grayscale not supported */
1768 if (surf->format->palette)
1769 {
1770 colorType |= PNG_COLOR_MASK_PALETTE;
1771 }
1772 else if (surf->format->Amask)
1773 {
1774 colorType |= PNG_COLOR_MASK_ALPHA;
1775 }
1776
1777 png_set_IHDR(pngPtr, infoPtr, surf->w, surf->h, 8, colorType, PNG_INTERLACE_NONE, PNG_COMPRESSION_TYPE_DEFAULT, PNG_FILTER_TYPE_DEFAULT);
1778
1779 // if we are outputting HDR, our backbuffer is linear, so gamma is 1.0. Make sure our png has this info
1780 // note: some image viewers seem to ignore the gAMA chunk; still, this is better than not having it at all
1781 if ([self hdrOutput]) png_set_gAMA(pngPtr, infoPtr, 1.0f);
1782
1783 // write the image
1784 png_write_info(pngPtr, infoPtr);
1785 png_set_packing(pngPtr);
1786
1787 rowPointers = (png_bytep*) malloc(sizeof(png_bytep)*surf->h);
1788 for (i = 0; i < surf->h; i++)
1789 {
1790 rowPointers[i] = (png_bytep)(Uint8 *)surf->pixels + i*surf->pitch;
1791 }
1792 png_write_image(pngPtr, rowPointers);
1793 png_write_end(pngPtr, infoPtr);
1794
1795 free(rowPointers);
1796 png_destroy_write_struct(&pngPtr, &infoPtr);
1797 fclose(fp);
1798
1799 return YES;
1800}

◆ pollControls [1/2]

- (void) pollControls

Definition at line 50 of file MyOpenGLView.m.

288{
289 if ([NSDate timeIntervalSinceReferenceDate] > timeIntervalAtLastMouseWheel + OOMOUSEWHEEL_EVENTS_DELAY_INTERVAL)
290 _mouseWheelDelta = 0.0f;
291}
#define OOMOUSEWHEEL_EVENTS_DELAY_INTERVAL
NSTimeInterval timeIntervalAtLastMouseWheel

◆ pollControls [2/2]

- (void) pollControls

◆ pollShiftKey [1/2]

+ (BOOL) pollShiftKey

Definition at line 50 of file MyOpenGLView.m.

1143{
1144 #define KEYMAP_GET(m, index) ((((uint8_t*)(m))[(index) >> 3] & (1L << ((index) & 7))) ? 1 : 0)
1145
1146 KeyMap map;
1147
1148 GetKeys(map);
1149 return KEYMAP_GET(map, 56) || KEYMAP_GET(map, 60); // Left shift or right shift -- although 60 shouldn't occur.
1150}
#define KEYMAP_GET(m, index)

◆ pollShiftKey [2/2]

+ (BOOL) pollShiftKey

◆ populateFullScreenModelist

- (void) populateFullScreenModelist

Definition at line 50 of file MyOpenGLView.m.

2716{
2717 int i;
2718 SDL_Rect **modes;
2719 NSMutableDictionary *mode;
2720
2721 screenSizes=[[NSMutableArray alloc] init];
2722
2723 // The default resolution (slot 0) is the resolution we are
2724 // already in since this is guaranteed to work.
2726 [screenSizes addObject: mode];
2727
2728 modes=SDL_ListModes(NULL, SDL_FULLSCREEN|SDL_HWSURFACE);
2729 if(modes == (SDL_Rect **)NULL)
2730 {
2731 OOLog(@"display.mode.list.none", @"%@", @"SDL didn't return any screen modes");
2732 return;
2733 }
2734
2735 if(modes == (SDL_Rect **)-1)
2736 {
2737 OOLog(@"display.mode.list.none", @"%@", @"SDL claims 'all resolutions available' which is unhelpful in the extreme");
2738 return;
2739 }
2740
2741 int lastw=[[mode objectForKey: kOODisplayWidth] intValue];
2742 int lasth=[[mode objectForKey: kOODisplayHeight] intValue];
2743 for(i=0; modes[i]; i++)
2744 {
2745 // SDL_ListModes often lists a mode several times,
2746 // presumably because each mode has several refresh rates.
2747 // But the modes pointer is an SDL_Rect which can't represent
2748 // refresh rates. WHY!?
2749 if(modes[i]->w != lastw || modes[i]->h != lasth)
2750 {
2751 // new resolution, save it
2752 mode=[NSMutableDictionary dictionary];
2753 [mode setValue: [NSNumber numberWithInt: (int)modes[i]->w]
2754 forKey: kOODisplayWidth];
2755 [mode setValue: [NSNumber numberWithInt: (int)modes[i]->h]
2756 forKey: kOODisplayHeight];
2757 [mode setValue: [NSNumber numberWithInt: 0]
2758 forKey: kOODisplayRefreshRate];
2759 if (![screenSizes containsObject:mode])
2760 {
2761 [screenSizes addObject: mode];
2762 OOLog(@"display.mode.list", @"Added res %d x %d", modes[i]->w, modes[i]->h);
2763 lastw=modes[i]->w;
2764 lasth=modes[i]->h;
2765 }
2766 }
2767 }
2768}
NSMutableDictionary * getNativeSize()

◆ recenterVirtualJoystick

- (void) recenterVirtualJoystick
implementation

Provided by category MyOpenGLView(Internal).

Definition at line 50 of file MyOpenGLView.m.

865{
866 if ([PLAYER guiScreen] == GUI_SCREEN_MAIN)
867 {
869 }
870}
#define PLAYER
GameController * sharedController()
void recenterVirtualJoystick()

◆ resetMouse [1/2]

- (void) resetMouse

Definition at line 50 of file MyOpenGLView.m.

784{
785 CGPoint centerPoint = CGPointMake(viewSize.width / 2.0, viewSize.height / 2.0);
786 CGWarpMouseCursorPosition(centerPoint);
787 [self setVirtualJoystick:0.0 :0.0];
788}

◆ resetMouse [2/2]

- (void) resetMouse

◆ resetSDLKeyModifiers

- (void) resetSDLKeyModifiers
implementation

Provided by category MyOpenGLView(OOPrivate).

Definition at line 50 of file MyOpenGLView.m.

1335{
1336 // probably not needed for Linux
1337}

◆ resetTypedString [1/2]

- (void) resetTypedString

Definition at line 50 of file MyOpenGLView.m.

219{
220 [typedString setString:@""];
221}

◆ resetTypedString [2/2]

- (void) resetTypedString

◆ rightMouseDown:

- (void) rightMouseDown: (NSEvent *) theEvent
implementation

Definition at line 50 of file MyOpenGLView.m.

846 :(NSEvent *)theEvent
847{
848 [self resetMouse];
849}

◆ rightMouseUp:

- (void) rightMouseUp: (NSEvent *) theEvent
implementation

Definition at line 50 of file MyOpenGLView.m.

852 :(NSEvent *)theEvent
853{
854 [self recenterVirtualJoystick];
855}

◆ saveWindowSize:

- (void) saveWindowSize: (NSSize) windowSize

Definition at line 50 of file MyOpenGLView.m.

2772 : (NSSize) windowSize
2773{
2774 NSUserDefaults *defaults=[NSUserDefaults standardUserDefaults];
2775 [defaults setInteger: (int)windowSize.width forKey: @"window_width"];
2776 [defaults setInteger: (int)windowSize.height forKey: @"window_height"];
2777 currentWindowSize=windowSize;
2778}

◆ scrollWheel:

- (void) scrollWheel: (NSEvent *) theEvent
implementation

Definition at line 50 of file MyOpenGLView.m.

816 :(NSEvent *)theEvent
817{
818 float dy = [theEvent scrollingDeltaY];
819
820 if (dy == 0)
821 return;
822
823 if (dy > 0)
824 {
825 if (_mouseWheelDelta >= 0)
826 _mouseWheelDelta += dy;
827 else
829 }
830 else
831 {
832 if (_mouseWheelDelta <= 0)
833 _mouseWheelDelta += dy;
834 else
836 }
837 timeIntervalAtLastMouseWheel = [NSDate timeIntervalSinceReferenceDate];
838}

◆ setDisplayMode:fullScreen:

- (void) setDisplayMode: (int) mode
fullScreen: (BOOL) fsm 

◆ setFov:fromFraction: [1/2]

- (void) setFov: (float) value
fromFraction: (BOOL) fromFraction 

Definition at line 1350 of file MyOpenGLView.m.

1370 :(float)value fromFraction:(BOOL)fromFraction
1371{
1372 _fov = fromFraction ? value : tanf((value / 2.0f) * M_PI / 180.0f);
1373}

◆ setFov:fromFraction: [2/2]

- (void) setFov: (float) value
fromFraction: (BOOL) fromFraction 

◆ setFullScreenMode:

- (void) setFullScreenMode: (BOOL) fsm

◆ setGameController: [1/2]

- (void) setGameController: (GameController *) controller

Definition at line 50 of file MyOpenGLView.m.

266 :(GameController *) controller
267{
268 gameController = controller;
269}
GameController * gameController

◆ setGameController: [2/2]

- (void) setGameController: (GameController *) controller

◆ setGammaValue: [1/2]

- (void) setGammaValue: (float) value

Definition at line 1350 of file MyOpenGLView.m.

1359 : (float) value
1360{
1361 // no-op
1362}

◆ setGammaValue: [2/2]

- (void) setGammaValue: (float) value

◆ setMouseInDeltaMode:

- (void) setMouseInDeltaMode: (BOOL) inDelta

Definition at line 50 of file MyOpenGLView.m.

2876 : (BOOL) inDelta
2877{
2878 mouseInDeltaMode=inDelta;
2879}
BOOL mouseInDeltaMode

◆ setMouseWheelDelta: [1/2]

- (void) setMouseWheelDelta: (float) newWheelDelta

Definition at line 50 of file MyOpenGLView.m.

1118 : (float) newWheelDelta
1119{
1120 _mouseWheelDelta = newWheelDelta * OOMOUSEWHEEL_DELTA;
1121}

◆ setMouseWheelDelta: [2/2]

- (void) setMouseWheelDelta: (float) newWheelDelta

◆ setMsaa:

- (void) setMsaa: (BOOL) newMsaa

Definition at line 50 of file MyOpenGLView.m.

2918 :(BOOL)newMsaa
2919{
2920 _msaa = !!newMsaa;
2921}

◆ setScreenSize:

- (void) setScreenSize: (int) sizeIndex

◆ setStringInput: [1/2]

- (void) setStringInput: (enum StringInput) value

Definition at line 50 of file MyOpenGLView.m.

188 :(enum StringInput)value
189{
190 allowingStringInput = value;
191}
StringInput

◆ setStringInput: [2/2]

- (void) setStringInput: (enum StringInput) value

◆ setTypedString: [1/2]

- (void) setTypedString: (NSString*) value

Definition at line 50 of file MyOpenGLView.m.

224 :(NSString *)value
225{
226 [typedString setString:value];
227}

◆ setTypedString: [2/2]

- (void) setTypedString: (NSString *) value

◆ setVirtualJoystick:vmx: [1/2]

- (void) setVirtualJoystick: (double)
vmx: (double) vmy 

Definition at line 50 of file MyOpenGLView.m.

983 :(double) vmx :(double) vmy
984{
987}

◆ setVirtualJoystick:vmx: [2/2]

- (void) setVirtualJoystick: (double)
vmx: (double) vmy 

◆ setWindowBorderless:

- (void) setWindowBorderless: (BOOL) borderless
implementation

Provided by category MyOpenGLView(OOPrivate).

Definition at line 50 of file MyOpenGLView.m.

1340 :(BOOL)borderless
1341{
1342 // do nothing on Linux
1343}

◆ snapShot: [1/2]

- (BOOL) snapShot: (NSString *) filename

Definition at line 50 of file MyOpenGLView.m.

423 :(NSString *)filename
424{
425 BOOL snapShotOK = YES;
426 NSSize v_size = backingViewSize;
427
428 int w = v_size.width;
429 int h = v_size.height;
430
431 if (w & 3)
432 w = w + 4 - (w & 3);
433
434 long nPixels = w * h + 1;
435
436 unsigned char *red = (unsigned char *)malloc(nPixels);
437 unsigned char *green = (unsigned char *)malloc(nPixels);
438 unsigned char *blue = (unsigned char *)malloc(nPixels);
439
440 // backup the previous directory
441 NSString *originalDirectory = [[NSFileManager defaultManager] currentDirectoryPath];
442 // use the snapshots directory
443 NSString *snapshotsDirectory = [[[GameController sharedController] snapshotsURLCreatingIfNeeded:YES] path];
444 if (![[NSFileManager defaultManager] changeCurrentDirectoryPath:snapshotsDirectory])
445 {
446 NSBeep();
447 OOLog(@"savedSnapshot.defaultPath.chdir.failed", @"Could not navigate to %@", snapshotsDirectory);
448 snapShotOK = NO;
449 goto FAIL;
450 }
451
452 BOOL withFilename = (filename != nil);
453 static unsigned imageNo = 0;
454 unsigned tmpImageNo = 0;
455 NSString *pathToPic = nil;
456 NSString *baseName = @"oolite";
457
458 if (withFilename)
459 {
460 baseName = filename;
461 pathToPic = [filename stringByAppendingString:@".png"];
462 }
463 else
464 {
465 tmpImageNo = imageNo;
466 }
467
468 if (withFilename && [[NSFileManager defaultManager] fileExistsAtPath:pathToPic])
469 {
470 OOLog(@"screenshot.filenameExists", @"Snapshot \"%@.png\" already exists - adding numerical sequence.", pathToPic);
471 pathToPic = nil;
472 }
473
474 if (pathToPic == nil)
475 {
476 do
477 {
478 tmpImageNo++;
479 pathToPic = [NSString stringWithFormat:@"%@-%03d.png", baseName, tmpImageNo];
480 } while ([[NSFileManager defaultManager] fileExistsAtPath:pathToPic]);
481 }
482
483 if (!withFilename)
484 {
485 imageNo = tmpImageNo;
486 }
487
488 OOLog(@"screenshot", @"Saved screen shot \"%@\" (%u x %u pixels).", pathToPic, w, h);
489
490 NSBitmapImageRep* bitmapRep =
491 [[NSBitmapImageRep alloc]
492 initWithBitmapDataPlanes:NULL // --> let the class allocate it
493 pixelsWide: w
494 pixelsHigh: h
495 bitsPerSample: 8 // each component is 8 bits (1 byte)
496 samplesPerPixel: 3 // number of components (R, G, B)
497 hasAlpha: NO // no transparency
498 isPlanar: NO // data integrated into single plane
499 colorSpaceName: NSDeviceRGBColorSpace
500 bytesPerRow: 3*w // can no longer let the class figure it out
501 bitsPerPixel: 24 // can no longer let the class figure it out
502 ];
503
504 unsigned char *pixels = [bitmapRep bitmapData];
505
506 OOGL(glReadPixels(0,0, w,h, GL_RED, GL_UNSIGNED_BYTE, red));
507 OOGL(glReadPixels(0,0, w,h, GL_GREEN, GL_UNSIGNED_BYTE, green));
508 OOGL(glReadPixels(0,0, w,h, GL_BLUE, GL_UNSIGNED_BYTE, blue));
509
510 int x,y;
511 for (y = 0; y < h; y++)
512 {
513 long index = (h - y - 1)*w;
514 for (x = 0; x < w; x++) // set bitmap pixels
515 {
516 *pixels++ = red[index];
517 *pixels++ = green[index];
518 *pixels++ = blue[index++];
519 }
520 }
521
522 [[bitmapRep representationUsingType:NSPNGFileType properties:[NSDictionary dictionaryWithObjectsAndKeys:[NSNumber numberWithBool:YES], NSImageInterlaced, NULL]]
523 writeToFile:pathToPic atomically:YES]; // save PNG representation of image
524
525 // free allocated objects and memory
526 [bitmapRep release];
527
528FAIL:
529 free(red);
530 free(green);
531 free(blue);
532
533 // return to the previous directory
534 [[NSFileManager defaultManager] changeCurrentDirectoryPath:originalDirectory];
535 return snapShotOK;
536}
#define FAIL(s)
NSURL * snapshotsURLCreatingIfNeeded:(BOOL create)
const char * filename
Definition ioapi.h:133

◆ snapShot: [2/2]

- (BOOL) snapShot: (NSString *) filename

◆ stringToClipboard: [1/2]

- (void) stringToClipboard: (NSString *) stringToCopy

Definition at line 50 of file MyOpenGLView.m.

539 :(NSString *)stringToCopy
540{
541 NSPasteboard *clipBoard = [NSPasteboard generalPasteboard];
542 [clipBoard declareTypes:[NSArray arrayWithObject:NSPasteboardTypeString] owner:nil];
543 [clipBoard setString:stringToCopy forType:NSPasteboardTypeString];
544}

◆ stringToClipboard: [2/2]

- (void) stringToClipboard: (NSString *) stringToCopy

◆ suppressKeysUntilKeyUp [1/2]

- (void) suppressKeysUntilKeyUp

Definition at line 50 of file MyOpenGLView.m.

1034{
1035 if (keys[gvMouseDoubleClick] == NO)
1036 {
1037 suppressKeys = YES;
1038 [self clearKeys];
1039 }
1040 else
1041 {
1042 [self clearMouse];
1043 }
1044}
@ gvMouseDoubleClick

◆ suppressKeysUntilKeyUp [2/2]

- (void) suppressKeysUntilKeyUp

◆ toggleScreenMode

- (void) toggleScreenMode

◆ touchesEndedWithEvent:

- (void) touchesEndedWithEvent: (NSEvent *) theEvent
implementation

Definition at line 50 of file MyOpenGLView.m.

858 :(NSEvent *)theEvent
859{
860 [self recenterVirtualJoystick];
861}

◆ translateKeyCode:

- (int) translateKeyCode: (int) input
implementation

Provided by category MyOpenGLView(Internal).

Definition at line 50 of file MyOpenGLView.m.

875 : (int) input
876{
877 int key = input;
878 switch ( input )
879 {
880 case NSUpArrowFunctionKey:
881 key = gvArrowKeyUp;
882 break;
883
884 case NSDownArrowFunctionKey:
885 key = gvArrowKeyDown;
886 break;
887
888 case NSLeftArrowFunctionKey:
889 key = gvArrowKeyLeft;
890 break;
891
892 case NSRightArrowFunctionKey:
893 key = gvArrowKeyRight;
894 break;
895
896 case NSF1FunctionKey:
897 key = gvFunctionKey1;
898 break;
899
900 case NSF2FunctionKey:
901 key = gvFunctionKey2;
902 break;
903
904 case NSF3FunctionKey:
905 key = gvFunctionKey3;
906 break;
907
908 case NSF4FunctionKey:
909 key = gvFunctionKey4;
910 break;
911
912 case NSF5FunctionKey:
913 key = gvFunctionKey5;
914 break;
915
916 case NSF6FunctionKey:
917 key = gvFunctionKey6;
918 break;
919
920 case NSF7FunctionKey:
921 key = gvFunctionKey7;
922 break;
923
924 case NSF8FunctionKey:
925 key = gvFunctionKey8;
926 break;
927
928 case NSF9FunctionKey:
929 key = gvFunctionKey9;
930 break;
931
932 case NSF10FunctionKey:
933 key = gvFunctionKey10;
934 break;
935
936 case NSF11FunctionKey:
937 key = gvFunctionKey11;
938 break;
939
940 case NSHomeFunctionKey:
941 key = gvHomeKey;
942 break;
943
944 case NSBackspaceCharacter:
945 key = gvBackspaceKey;
946 break;
947
948 case NSDeleteCharacter:
949 key = gvDeleteKey;
950 break;
951
952 case NSInsertFunctionKey:
953 key = gvInsertKey;
954 break;
955
956 case NSEndFunctionKey:
957 key = gvEndKey;
958 break;
959
960 case NSPageUpFunctionKey:
961 key = gvPageUpKey;
962 break;
963
964 case NSPageDownFunctionKey:
965 key = gvPageDownKey;
966 break;
967
968 case NSPrintScreenFunctionKey:
969 key = gvPrintScreenKey;
970 break;
971
972 case NSPauseFunctionKey:
973 key = gvPauseKey;
974 break;
975
976 default:
977 break;
978 }
979 return key;
980}
@ gvFunctionKey2
@ gvInsertKey
@ gvFunctionKey10
@ gvFunctionKey5
@ gvArrowKeyDown
@ gvFunctionKey9
@ gvFunctionKey4
@ gvEndKey
@ gvHomeKey
@ gvPauseKey
@ gvFunctionKey11
@ gvFunctionKey8
@ gvPageDownKey
@ gvFunctionKey3
@ gvArrowKeyUp
@ gvArrowKeyRight
@ gvFunctionKey6
@ gvArrowKeyLeft
@ gvFunctionKey7
@ gvPageUpKey
@ gvFunctionKey1

◆ typedString [1/2]

- (NSString *) typedString

◆ typedString [2/2]

- (NSString *) typedString

◆ UnapplyCursorState

+ (static void) UnapplyCursorState (OOMouseInteractionMode) mode
implementation

Definition at line 1350 of file MyOpenGLView.m.

1351{
1352 BOOL hidden, obscured;
1353 GetDesiredCursorState(mode, &hidden, &obscured);
1354 if (hidden) [NSCursor unhide];
1355 if (obscured) [NSCursor setHiddenUntilMouseMoves:NO];
1356}

◆ update

- (void) update
implementation

Definition at line 50 of file MyOpenGLView.m.

323{
324 NSOpenGLContext *context = [self openGLContext];
325
326 [context update];
327 int virtualScreen = [context currentVirtualScreen];
328 if (virtualScreen != _virtualScreen)
329 {
330 @try
331 {
333 _virtualScreen = virtualScreen;
334 }
335 @catch (NSException *exception)
336 {
337 /* Graphics reset failed, most likely because of OpenGL context
338 incompatibility. Reset to previous "virtual screen" (i.e.,
339 renderer). OS X's OpenGL implementation will take care of
340 copying
341 */
342 [context setCurrentVirtualScreen:_virtualScreen];
343 [[OOGraphicsResetManager sharedManager] resetGraphicsState]; // If this throws, we're screwed.
344
345 if ([[self gameController] inFullScreenMode])
346 {
347 [[self gameController] pauseFullScreenModeToPerform:@selector(noteMovedToBadDisplay) onTarget:self];
348 }
349 else
350 {
351 [self noteMovedToBadDisplay];
352 }
353 }
354 }
355}
BOOL inFullScreenMode()
OOGraphicsResetManager * sharedManager()

◆ updateScreen [1/2]

- (void) updateScreen

Definition at line 50 of file MyOpenGLView.m.

280{
281 if ([[self window] isVisible])
282 {
283 [self drawRect:NSMakeRect(0, 0, viewSize.width, viewSize.height)];
284 }
285}

◆ updateScreen [2/2]

- (void) updateScreen

◆ updateScreenWithVideoMode:

- (void) updateScreenWithVideoMode: (BOOL) v_mode

Definition at line 50 of file MyOpenGLView.m.

772 :(BOOL) v_mode
773{
774 if ((viewSize.width != surface->w)||(viewSize.height != surface->h)) // resized
775 {
776#if OOLITE_LINUX
777 m_glContextInitialized = NO; //probably not needed
778#endif
779 viewSize.width = surface->w;
780 viewSize.height = surface->h;
781 }
782
783 if (m_glContextInitialized == NO)
784 {
785 [self initialiseGLWithSize:viewSize useVideoMode:v_mode];
786 }
787
788 if (surface == 0)
789 return;
790
791 // do all the drawing!
792 //
793 if (UNIVERSE) [UNIVERSE drawUniverse];
794 else
795 {
796 // not set up yet, draw a black screen
797 glClearColor( 0.0, 0.0, 0.0, 0.0);
798 glClear( GL_COLOR_BUFFER_BIT);
799 }
800
801 SDL_GL_SwapBuffers();
802}

◆ viewSize [1/2]

- (NSSize) viewSize

◆ viewSize [2/2]

- (NSSize) viewSize

◆ virtualJoystickPosition [1/2]

- (NSPoint) virtualJoystickPosition

◆ virtualJoystickPosition [2/2]

- (NSPoint) virtualJoystickPosition

◆ x_offset [1/2]

- (GLfloat) x_offset

◆ x_offset [2/2]

- (GLfloat) x_offset

◆ y_offset [1/2]

- (GLfloat) y_offset

◆ y_offset [2/2]

- (GLfloat) y_offset

Member Data Documentation

◆ _colorSaturation

- (float) _colorSaturation
protected

Definition at line 219 of file MyOpenGLView.h.

◆ _fov

- (float) _fov
private

Definition at line 160 of file MyOpenGLView.h.

◆ _gamma

- (float) _gamma
protected

Definition at line 189 of file MyOpenGLView.h.

◆ _hdrOutput

- (BOOL) _hdrOutput
protected

Definition at line 221 of file MyOpenGLView.h.

◆ _mouseVirtualStickSensitivityFactor

- (float) _mouseVirtualStickSensitivityFactor
protected

Definition at line 180 of file MyOpenGLView.h.

◆ _mouseWheelDelta

- (float) _mouseWheelDelta
private

Definition at line 153 of file MyOpenGLView.h.

◆ _msaa

- (BOOL) _msaa
protected

Definition at line 191 of file MyOpenGLView.h.

◆ _pixelFormatAttributes

- (NSData*) _pixelFormatAttributes
private

Definition at line 163 of file MyOpenGLView.h.

◆ _virtualScreen

- (int) _virtualScreen
private

Definition at line 162 of file MyOpenGLView.h.

◆ allowingStringInput

- (enum StringInput) allowingStringInput
private

Definition at line 136 of file MyOpenGLView.h.

◆ backingViewSize

- (NSSize) backingViewSize
private

Definition at line 156 of file MyOpenGLView.h.

◆ bounds

- (NSRect) bounds
protected

Definition at line 187 of file MyOpenGLView.h.

◆ capsLockOn

- (BOOL) capsLockOn
private

Definition at line 135 of file MyOpenGLView.h.

◆ command

- (BOOL) command
private

Definition at line 135 of file MyOpenGLView.h.

◆ commandF

- (BOOL) commandF
private

Definition at line 139 of file MyOpenGLView.h.

◆ commandQ

- (BOOL) commandQ
private

Definition at line 138 of file MyOpenGLView.h.

◆ ctrl

- (BOOL) ctrl
private

Definition at line 135 of file MyOpenGLView.h.

◆ currentSize

- (int) currentSize
protected

Definition at line 195 of file MyOpenGLView.h.

◆ currentWindowSize

- (NSSize) currentWindowSize
protected

Definition at line 199 of file MyOpenGLView.h.

◆ display_z

- (GLfloat) display_z
private

Definition at line 157 of file MyOpenGLView.h.

◆ doubleClick

- (BOOL) doubleClick
private

Definition at line 148 of file MyOpenGLView.h.

◆ f12

- (BOOL) f12
private

Definition at line 140 of file MyOpenGLView.h.

◆ firstScreen

- (NSSize) firstScreen
protected

Definition at line 225 of file MyOpenGLView.h.

◆ fullScreen

- (BOOL) fullScreen
protected

Definition at line 196 of file MyOpenGLView.h.

◆ gameController

- (GameController *) gameController
private

Definition at line 126 of file MyOpenGLView.h.

◆ grabMouseStatus

- (BOOL) grabMouseStatus
protected

Definition at line 223 of file MyOpenGLView.h.

◆ isAlphabetKeyDown

- (BOOL) isAlphabetKeyDown
private

Definition at line 137 of file MyOpenGLView.h.

◆ keycodetrans

- (int) keycodetrans
private

Definition at line 142 of file MyOpenGLView.h.

◆ keyMappings_normal

- (NSDictionary *) keyMappings_normal
private

Definition at line 130 of file MyOpenGLView.h.

◆ keyMappings_shifted

- (NSDictionary *) keyMappings_shifted
private

Definition at line 131 of file MyOpenGLView.h.

◆ keys

- (BOOL) keys
private

Definition at line 128 of file MyOpenGLView.h.

◆ lastKeyShifted

- (BOOL) lastKeyShifted
private

Definition at line 135 of file MyOpenGLView.h.

◆ m_glContextInitialized

- (BOOL) m_glContextInitialized
private

Definition at line 144 of file MyOpenGLView.h.

◆ matrixManager

- (OOOpenGLMatrixManager *) matrixManager
private

Definition at line 165 of file MyOpenGLView.h.

◆ mouseDragStartPoint

- (NSPoint) mouseDragStartPoint
protected

Definition at line 168 of file MyOpenGLView.h.

◆ mouseInDeltaMode

- (BOOL) mouseInDeltaMode
protected

Definition at line 230 of file MyOpenGLView.h.

◆ mouseWarped

- (BOOL) mouseWarped
protected

Definition at line 170 of file MyOpenGLView.h.

◆ opt

- (BOOL) opt
private

Definition at line 135 of file MyOpenGLView.h.

◆ scancode2Unicode

- (int) scancode2Unicode
private

Definition at line 129 of file MyOpenGLView.h.

◆ screenSizes

- (NSMutableArray*) screenSizes
protected

Definition at line 194 of file MyOpenGLView.h.

◆ shift

- (BOOL) shift
private

Definition at line 135 of file MyOpenGLView.h.

◆ showSplashScreen

- (BOOL) showSplashScreen
protected

Definition at line 202 of file MyOpenGLView.h.

◆ squareX

- (double) squareX
protected

Definition at line 186 of file MyOpenGLView.h.

◆ squareY

- (double) squareY
protected

Definition at line 186 of file MyOpenGLView.h.

◆ suppressKeys

- (BOOL) suppressKeys
private

Definition at line 133 of file MyOpenGLView.h.

◆ surface

- (SDL_Surface*) surface
protected

Definition at line 200 of file MyOpenGLView.h.

◆ timeIntervalAtLastClick

- (NSTimeInterval) timeIntervalAtLastClick
private

Definition at line 146 of file MyOpenGLView.h.

◆ timeIntervalAtLastMouseWheel

- (NSTimeInterval) timeIntervalAtLastMouseWheel
private

Definition at line 147 of file MyOpenGLView.h.

◆ timeSinceLastMouseWheel

- (NSTimeInterval) timeSinceLastMouseWheel
protected

Definition at line 173 of file MyOpenGLView.h.

◆ typedString

- (NSString *) typedString
private

Definition at line 150 of file MyOpenGLView.h.

◆ viewSize

- (NSSize) viewSize
private

Definition at line 155 of file MyOpenGLView.h.

Referenced by HeadUpDisplay::drawScannerGrid.

◆ virtualJoystickPosition

- (NSPoint) virtualJoystickPosition
private

Definition at line 152 of file MyOpenGLView.h.

◆ x_offset

- (GLfloat) x_offset
private

Definition at line 158 of file MyOpenGLView.h.

◆ y_offset

- (GLfloat) y_offset
private

Definition at line 158 of file MyOpenGLView.h.


The documentation for this class was generated from the following files: