Oolite 1.91.0.7644-241112-7f5034b
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
 
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.

1595 :(float)colorSaturationAdjustment;
1596{
1597 _colorSaturation += colorSaturationAdjustment;
1599}
#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.

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

◆ 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.

1590{
1591 return _colorSaturation;
1592}

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.

2859{
2860 NSDictionary *mode=[screenSizes objectAtIndex: currentSize];
2861
2862 if(mode)
2863 {
2864 return NSMakeSize([[mode objectForKey: kOODisplayWidth] intValue],
2865 [[mode objectForKey: kOODisplayHeight] intValue]);
2866 }
2867 OOLog(@"display.mode.unknown", @"%@", @"Screen size unknown!");
2869}
#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.

754{
755 [self updateScreen];
756}

◆ 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:833
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.

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

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

1318 :(BOOL) value
1319{
1320 // do nothing
1321}

◆ 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.

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

◆ hdrOutput

- (BOOL) hdrOutput

Definition at line 50 of file MyOpenGLView.m.

1343{
1344 return NO;
1345}

◆ indexOfCurrentSize

- (int) indexOfCurrentSize

◆ inFullScreenMode

- (BOOL) inFullScreenMode

Definition at line 50 of file MyOpenGLView.m.

668{
669 return fullScreen;
670}

◆ 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.

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

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

1349{
1350 return NO;
1351}

◆ isRunningOnPrimaryDisplayDevice

- (BOOL) isRunningOnPrimaryDisplayDevice

Definition at line 50 of file MyOpenGLView.m.

1313{
1314 return YES;
1315}

◆ 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.

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

◆ loadWindowSize

- (NSSize) loadWindowSize

Definition at line 50 of file MyOpenGLView.m.

2778{
2779 NSSize windowSize;
2780 NSUserDefaults *defaults=[NSUserDefaults standardUserDefaults];
2781 if([defaults objectForKey:@"window_width"] && [defaults objectForKey:@"window_height"])
2782 {
2783 windowSize=NSMakeSize([defaults integerForKey: @"window_width"],
2784 [defaults integerForKey: @"window_height"]);
2785 }
2786 else
2787 {
2789 }
2790 currentWindowSize=windowSize;
2791 return windowSize;
2792}

◆ 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.

2909{
2910 return _msaa;
2911}

◆ 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:839

◆ 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.

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

◆ 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.

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

1331{
1332 // probably not needed for Linux
1333}

◆ 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.

2768 : (NSSize) windowSize
2769{
2770 NSUserDefaults *defaults=[NSUserDefaults standardUserDefaults];
2771 [defaults setInteger: (int)windowSize.width forKey: @"window_width"];
2772 [defaults setInteger: (int)windowSize.height forKey: @"window_height"];
2773 currentWindowSize=windowSize;
2774}

◆ 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.

2872 : (BOOL) inDelta
2873{
2874 mouseInDeltaMode=inDelta;
2875}
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.

2914 :(BOOL)newMsaa
2915{
2916 _msaa = !!newMsaa;
2917}

◆ 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.

1336 :(BOOL)borderless
1337{
1338 // do nothing on Linux
1339}

◆ 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.

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

◆ 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 218 of file MyOpenGLView.h.

◆ _fov

- (float) _fov
private

Definition at line 160 of file MyOpenGLView.h.

◆ _gamma

- (float) _gamma
protected

Definition at line 188 of file MyOpenGLView.h.

◆ _hdrOutput

- (BOOL) _hdrOutput
protected

Definition at line 220 of file MyOpenGLView.h.

◆ _mouseWheelDelta

- (float) _mouseWheelDelta
private

Definition at line 153 of file MyOpenGLView.h.

◆ _msaa

- (BOOL) _msaa
protected

Definition at line 190 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 186 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 194 of file MyOpenGLView.h.

◆ currentWindowSize

- (NSSize) currentWindowSize
protected

Definition at line 198 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 224 of file MyOpenGLView.h.

◆ fullScreen

- (BOOL) fullScreen
protected

Definition at line 195 of file MyOpenGLView.h.

◆ gameController

- (GameController *) gameController
private

Definition at line 126 of file MyOpenGLView.h.

◆ grabMouseStatus

- (BOOL) grabMouseStatus
protected

Definition at line 222 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 169 of file MyOpenGLView.h.

◆ mouseInDeltaMode

- (BOOL) mouseInDeltaMode
protected

Definition at line 229 of file MyOpenGLView.h.

◆ mouseWarped

- (BOOL) mouseWarped
protected

Definition at line 171 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 193 of file MyOpenGLView.h.

◆ shift

- (BOOL) shift
private

Definition at line 135 of file MyOpenGLView.h.

◆ showSplashScreen

- (BOOL) showSplashScreen
protected

Definition at line 201 of file MyOpenGLView.h.

◆ squareX

- (double) squareX
protected

Definition at line 185 of file MyOpenGLView.h.

◆ squareY

- (double) squareY
protected

Definition at line 185 of file MyOpenGLView.h.

◆ suppressKeys

- (BOOL) suppressKeys
private

Definition at line 133 of file MyOpenGLView.h.

◆ surface

- (SDL_Surface*) surface
protected

Definition at line 199 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 174 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: