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
|
||||
|
||||
after-all::
|
||||
rm -f $(CONTENTDIR)
|
||||
rm -rf $(CONTENTDIR)
|
||||
$(MKDIRS) $(CONTENTDIR)
|
||||
$(CP) -r Resources $(CONTENTDIR)/Resources
|
||||
$(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 <AppKit/AppKit.h>
|
||||
#import <AppKit/NSOpenGL.h>
|
||||
#include <X11/Xlib.h>
|
||||
#else
|
||||
#import <Cocoa/Cocoa.h>
|
||||
#endif
|
||||
@ -67,7 +68,10 @@ extern int debug;
|
||||
IBOutlet NSTextField *splashProgressTextField;
|
||||
IBOutlet NSView *splashView;
|
||||
IBOutlet MyOpenGLView *gameView;
|
||||
IBOutlet MyOpenGLView *switchView;
|
||||
IBOutlet NSWindow *gameWindow;
|
||||
IBOutlet NSWindow *fsGameWindow;
|
||||
NSRect fsGeometry;
|
||||
|
||||
Universe *universe;
|
||||
NSDate *old_time;
|
||||
@ -165,6 +169,10 @@ extern int debug;
|
||||
- (void) playiTunesPlaylist:(NSString *)playlist_name;
|
||||
- (void) pauseiTunes;
|
||||
|
||||
#ifdef GNUSTEP
|
||||
- (void) goX11Fullscreen;
|
||||
#endif
|
||||
|
||||
@end
|
||||
|
||||
|
||||
|
@ -475,6 +475,15 @@ static int _compareModes(id arg1, id arg2, void *context)
|
||||
if (universe)
|
||||
[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 (universe)
|
||||
@ -487,6 +496,7 @@ static int _compareModes(id arg1, id arg2, void *context)
|
||||
else
|
||||
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
|
||||
|
||||
#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
|
||||
|
||||
|
||||
|
||||
|
@ -3416,6 +3416,12 @@ static BOOL queryPressed;
|
||||
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))
|
||||
{
|
||||
int direction = ([gameView isDown:gvArrowKeyRight]) ? 1 : -1;
|
||||
@ -3434,9 +3440,6 @@ static BOOL queryPressed;
|
||||
displayModeIndex = 0;
|
||||
}
|
||||
NSDictionary *mode = [modes objectAtIndex:displayModeIndex];
|
||||
#ifdef GNUSTEP
|
||||
// TODO: do something
|
||||
#else
|
||||
int modeWidth = [[mode objectForKey: (NSString *)kCGDisplayWidth] intValue];
|
||||
int modeHeight = [[mode objectForKey: (NSString *)kCGDisplayHeight] intValue];
|
||||
int modeRefresh = [[mode objectForKey: (NSString *)kCGDisplayRefreshRate] intValue];
|
||||
@ -3453,12 +3456,10 @@ static BOOL queryPressed;
|
||||
[universe guiUpdated];
|
||||
}
|
||||
switching_resolution = YES;
|
||||
#endif
|
||||
}
|
||||
if ((![gameView isDown:gvArrowKeyRight])&&(![gameView isDown:gvArrowKeyLeft])&&(![gameView isDown:13]))
|
||||
switching_resolution = NO;
|
||||
|
||||
#ifndef GNUSTEP
|
||||
if (([gui selectedRow] == speech_row)&&(([gameView isDown:gvArrowKeyRight])||([gameView isDown:gvArrowKeyLeft])))
|
||||
{
|
||||
GuiDisplayGen* gui = [universe gui];
|
||||
@ -6184,14 +6185,8 @@ static BOOL toggling_music;
|
||||
mode=[(NSArray *)[controller displayModes] objectAtIndex:displayModeIndex];
|
||||
}
|
||||
#ifdef GNUSTEP
|
||||
// TODO: Full-screen mode selection, need to read X docs.
|
||||
NSString *displayModeString=nil;
|
||||
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.
|
||||
// Full screen or not full screen are the only options.
|
||||
NSString *displayModeString=[NSString stringWithFormat:@" Full screen"];
|
||||
#else
|
||||
int modeWidth = [[mode objectForKey: (NSString *)kCGDisplayWidth] 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: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
|
||||
[gui setText:@" Exit game " forRow:quit_row align:GUI_ALIGN_CENTER];
|
||||
#else
|
||||
|
Loading…
x
Reference in New Issue
Block a user