Fullscreen WIP
git-svn-id: http://svn.berlios.de/svnroot/repos/oolite-linux/trunk@33 127b21dd-08f5-0310-b4b7-95ae10353056
This commit is contained in:
parent
4c189f5e39
commit
e30fdfb6fc
@ -8,7 +8,7 @@ CONTENTDIR=$(APP_NAME).app/$(CONTENTS)
|
|||||||
GNUSTEP_OW=$(APP_NAME).app/Resources/Info-gnustep.plist
|
GNUSTEP_OW=$(APP_NAME).app/Resources/Info-gnustep.plist
|
||||||
|
|
||||||
after-all::
|
after-all::
|
||||||
rm -f $(CONTENTDIR)
|
rm -rf $(CONTENTDIR)
|
||||||
$(MKDIRS) $(CONTENTDIR)
|
$(MKDIRS) $(CONTENTDIR)
|
||||||
$(CP) -r Resources $(CONTENTDIR)/Resources
|
$(CP) -r Resources $(CONTENTDIR)/Resources
|
||||||
$(CP) Resources/Info-Oolite.plist $(GNUSTEP_OW)
|
$(CP) Resources/Info-Oolite.plist $(GNUSTEP_OW)
|
||||||
|
@ -40,6 +40,7 @@ Your fair use and other rights are in no way affected by the above.
|
|||||||
#import <Foundation/Foundation.h>
|
#import <Foundation/Foundation.h>
|
||||||
#import <AppKit/AppKit.h>
|
#import <AppKit/AppKit.h>
|
||||||
#import <AppKit/NSOpenGL.h>
|
#import <AppKit/NSOpenGL.h>
|
||||||
|
#include <X11/Xlib.h>
|
||||||
#else
|
#else
|
||||||
#import <Cocoa/Cocoa.h>
|
#import <Cocoa/Cocoa.h>
|
||||||
#endif
|
#endif
|
||||||
@ -67,7 +68,10 @@ extern int debug;
|
|||||||
IBOutlet NSTextField *splashProgressTextField;
|
IBOutlet NSTextField *splashProgressTextField;
|
||||||
IBOutlet NSView *splashView;
|
IBOutlet NSView *splashView;
|
||||||
IBOutlet MyOpenGLView *gameView;
|
IBOutlet MyOpenGLView *gameView;
|
||||||
|
IBOutlet MyOpenGLView *switchView;
|
||||||
IBOutlet NSWindow *gameWindow;
|
IBOutlet NSWindow *gameWindow;
|
||||||
|
IBOutlet NSWindow *fsGameWindow;
|
||||||
|
NSRect fsGeometry;
|
||||||
|
|
||||||
Universe *universe;
|
Universe *universe;
|
||||||
NSDate *old_time;
|
NSDate *old_time;
|
||||||
@ -165,6 +169,10 @@ extern int debug;
|
|||||||
- (void) playiTunesPlaylist:(NSString *)playlist_name;
|
- (void) playiTunesPlaylist:(NSString *)playlist_name;
|
||||||
- (void) pauseiTunes;
|
- (void) pauseiTunes;
|
||||||
|
|
||||||
|
#ifdef GNUSTEP
|
||||||
|
- (void) goX11Fullscreen;
|
||||||
|
#endif
|
||||||
|
|
||||||
@end
|
@end
|
||||||
|
|
||||||
|
|
||||||
|
@ -475,6 +475,15 @@ static int _compareModes(id arg1, id arg2, void *context)
|
|||||||
if (universe)
|
if (universe)
|
||||||
[universe update:delta_t];
|
[universe update:delta_t];
|
||||||
//
|
//
|
||||||
|
#ifdef GNUSTEP
|
||||||
|
// GNUstep's fullscreen is actually just a full screen window.
|
||||||
|
// So we use the same view regardless of mode.
|
||||||
|
if(gameView)
|
||||||
|
[gameView display];
|
||||||
|
else
|
||||||
|
NSLog(@"***** gameView not set : delta_t %f",(float)delta_t);
|
||||||
|
|
||||||
|
#else
|
||||||
if (fullscreen)
|
if (fullscreen)
|
||||||
{
|
{
|
||||||
if (universe)
|
if (universe)
|
||||||
@ -487,6 +496,7 @@ static int _compareModes(id arg1, id arg2, void *context)
|
|||||||
else
|
else
|
||||||
NSLog(@"***** gameView not set : delta_t %f",(float)delta_t);
|
NSLog(@"***** gameView not set : delta_t %f",(float)delta_t);
|
||||||
}
|
}
|
||||||
|
#endif
|
||||||
//
|
//
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -841,7 +851,68 @@ static int _compareModes(id arg1, id arg2, void *context)
|
|||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
#ifdef GNUSTEP
|
||||||
|
- (void) goX11Fullscreen
|
||||||
|
{
|
||||||
|
Display *dpy;
|
||||||
|
int screen;
|
||||||
|
|
||||||
|
// already full screen?
|
||||||
|
if(fullscreen)
|
||||||
|
return;
|
||||||
|
fullscreen=YES;
|
||||||
|
|
||||||
|
// use X11 to find the size of the current display.
|
||||||
|
dpy=XOpenDisplay(NULL);
|
||||||
|
if(!dpy)
|
||||||
|
{
|
||||||
|
NSLog(@"XOpenDisplay returned NULL!");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
screen=DefaultScreen(dpy);
|
||||||
|
fsGeometry=NSMakeRect(0, 0,
|
||||||
|
DisplayWidth(dpy, screen),
|
||||||
|
DisplayHeight(dpy, screen));
|
||||||
|
NSLog(@"fullscreen = %f x %f", fsGeometry.size.width, fsGeometry.size.height);
|
||||||
|
// done with X
|
||||||
|
XCloseDisplay(dpy);
|
||||||
|
|
||||||
|
fsGameWindow = [NSWindow alloc];
|
||||||
|
fsGameWindow = [gameWindow initWithContentRect: fsGeometry
|
||||||
|
styleMask: 0
|
||||||
|
backing: NSBackingStoreBuffered
|
||||||
|
defer: NO];
|
||||||
|
[fsGameWindow makeKeyAndOrderFront: nil];
|
||||||
|
/*
|
||||||
|
fullScreenContext = [[NSOpenGLContext alloc]
|
||||||
|
initWithFormat:[NSOpenGLView defaultPixelFormat]
|
||||||
|
shareContext:[gameView openGLContext]];
|
||||||
|
|
||||||
|
if (fullScreenContext == nil)
|
||||||
|
{
|
||||||
|
NSLog(@"***** Failed to create fullScreenContext");
|
||||||
|
return;
|
||||||
|
} */
|
||||||
|
|
||||||
|
switchView = [[MyOpenGLView alloc]
|
||||||
|
initWithFrame: fsGeometry
|
||||||
|
pixelFormat: [NSOpenGLView defaultPixelFormat]];
|
||||||
|
|
||||||
|
[fsGameWindow setContentView: switchView];
|
||||||
|
//[switchView setOpenGLContext: fullScreenContext];
|
||||||
|
[switchView setOpenGLContext: [gameView openGLContext]];
|
||||||
|
[[switchView openGLContext] setView: switchView];
|
||||||
|
[switchView drawRect: fsGeometry];
|
||||||
|
[fsGameWindow makeFirstResponder: switchView];
|
||||||
|
[[switchView openGLContext] makeCurrentContext];
|
||||||
|
[switchView initialiseGLWithSize: fsGeometry.size];
|
||||||
|
|
||||||
|
// set up the window to accept mouseMoved events
|
||||||
|
[fsGameWindow setAcceptsMouseMovedEvents:YES];
|
||||||
|
[self setGameView: switchView];
|
||||||
|
}
|
||||||
|
#endif // ifdef GNUSTEP
|
||||||
|
|
||||||
@end
|
@end
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
@ -3416,6 +3416,12 @@ static BOOL queryPressed;
|
|||||||
disc_operation_in_progress = NO;
|
disc_operation_in_progress = NO;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#ifdef GNUSTEP
|
||||||
|
if (([gui selectedRow] == display_row) && [gameView isDown:13])
|
||||||
|
{
|
||||||
|
[controller goX11Fullscreen];
|
||||||
|
}
|
||||||
|
#else
|
||||||
if (([gui selectedRow] == display_row)&&(([gameView isDown:gvArrowKeyRight])||([gameView isDown:gvArrowKeyLeft]))&&(!switching_resolution))
|
if (([gui selectedRow] == display_row)&&(([gameView isDown:gvArrowKeyRight])||([gameView isDown:gvArrowKeyLeft]))&&(!switching_resolution))
|
||||||
{
|
{
|
||||||
int direction = ([gameView isDown:gvArrowKeyRight]) ? 1 : -1;
|
int direction = ([gameView isDown:gvArrowKeyRight]) ? 1 : -1;
|
||||||
@ -3434,9 +3440,6 @@ static BOOL queryPressed;
|
|||||||
displayModeIndex = 0;
|
displayModeIndex = 0;
|
||||||
}
|
}
|
||||||
NSDictionary *mode = [modes objectAtIndex:displayModeIndex];
|
NSDictionary *mode = [modes objectAtIndex:displayModeIndex];
|
||||||
#ifdef GNUSTEP
|
|
||||||
// TODO: do something
|
|
||||||
#else
|
|
||||||
int modeWidth = [[mode objectForKey: (NSString *)kCGDisplayWidth] intValue];
|
int modeWidth = [[mode objectForKey: (NSString *)kCGDisplayWidth] intValue];
|
||||||
int modeHeight = [[mode objectForKey: (NSString *)kCGDisplayHeight] intValue];
|
int modeHeight = [[mode objectForKey: (NSString *)kCGDisplayHeight] intValue];
|
||||||
int modeRefresh = [[mode objectForKey: (NSString *)kCGDisplayRefreshRate] intValue];
|
int modeRefresh = [[mode objectForKey: (NSString *)kCGDisplayRefreshRate] intValue];
|
||||||
@ -3453,12 +3456,10 @@ static BOOL queryPressed;
|
|||||||
[universe guiUpdated];
|
[universe guiUpdated];
|
||||||
}
|
}
|
||||||
switching_resolution = YES;
|
switching_resolution = YES;
|
||||||
#endif
|
|
||||||
}
|
}
|
||||||
if ((![gameView isDown:gvArrowKeyRight])&&(![gameView isDown:gvArrowKeyLeft])&&(![gameView isDown:13]))
|
if ((![gameView isDown:gvArrowKeyRight])&&(![gameView isDown:gvArrowKeyLeft])&&(![gameView isDown:13]))
|
||||||
switching_resolution = NO;
|
switching_resolution = NO;
|
||||||
|
|
||||||
#ifndef GNUSTEP
|
|
||||||
if (([gui selectedRow] == speech_row)&&(([gameView isDown:gvArrowKeyRight])||([gameView isDown:gvArrowKeyLeft])))
|
if (([gui selectedRow] == speech_row)&&(([gameView isDown:gvArrowKeyRight])||([gameView isDown:gvArrowKeyLeft])))
|
||||||
{
|
{
|
||||||
GuiDisplayGen* gui = [universe gui];
|
GuiDisplayGen* gui = [universe gui];
|
||||||
@ -6184,14 +6185,8 @@ static BOOL toggling_music;
|
|||||||
mode=[(NSArray *)[controller displayModes] objectAtIndex:displayModeIndex];
|
mode=[(NSArray *)[controller displayModes] objectAtIndex:displayModeIndex];
|
||||||
}
|
}
|
||||||
#ifdef GNUSTEP
|
#ifdef GNUSTEP
|
||||||
// TODO: Full-screen mode selection, need to read X docs.
|
// Full screen or not full screen are the only options.
|
||||||
NSString *displayModeString=nil;
|
NSString *displayModeString=[NSString stringWithFormat:@" Full screen"];
|
||||||
if(!mode)
|
|
||||||
{
|
|
||||||
// We didn't get any full screen modes.
|
|
||||||
displayModeString=[NSString stringWithFormat:@" No fullscreen modes found"];
|
|
||||||
}
|
|
||||||
// TODO: else clause to init the string similar to the OS X build.
|
|
||||||
#else
|
#else
|
||||||
int modeWidth = [[mode objectForKey: (NSString *)kCGDisplayWidth] intValue];
|
int modeWidth = [[mode objectForKey: (NSString *)kCGDisplayWidth] intValue];
|
||||||
int modeHeight = [[mode objectForKey: (NSString *)kCGDisplayHeight] intValue];
|
int modeHeight = [[mode objectForKey: (NSString *)kCGDisplayHeight] intValue];
|
||||||
@ -6247,12 +6242,6 @@ static BOOL toggling_music;
|
|||||||
[gui setText:@" xine integration: OFF " forRow:ootunes_row align:GUI_ALIGN_CENTER];
|
[gui setText:@" xine integration: OFF " forRow:ootunes_row align:GUI_ALIGN_CENTER];
|
||||||
[gui setText:displayModeString forRow:display_row align:GUI_ALIGN_CENTER];
|
[gui setText:displayModeString forRow:display_row align:GUI_ALIGN_CENTER];
|
||||||
|
|
||||||
// If we didn't get any modes, grey it out.
|
|
||||||
if(!mode)
|
|
||||||
{
|
|
||||||
[gui setColor:[NSColor grayColor] forRow:display_row];
|
|
||||||
}
|
|
||||||
|
|
||||||
// quit menu option
|
// quit menu option
|
||||||
[gui setText:@" Exit game " forRow:quit_row align:GUI_ALIGN_CENTER];
|
[gui setText:@" Exit game " forRow:quit_row align:GUI_ALIGN_CENTER];
|
||||||
#else
|
#else
|
||||||
|
Loading…
x
Reference in New Issue
Block a user