TV-Out?

Monkey Targets Forums/iOS/TV-Out?

Spinal(Posted 2013) [#1]
Hi guys, Couldn't find anything about this here and very little elsewhere. I'm trying to enable tv-out for my monkey game, I have added the following code to application didFinishLaunchingWithOptions: in xcode -

    // TV output support
    if([[UIScreen screens] count] == 1)
    {
        // Do what you normally do
    } else {
        CGSize max;
        UIScreenMode *maxScreenMode = nil;
        UIScreen *external = [[UIScreen screens] objectAtIndex: 1];
        UIScreenMode *current = [[[[UIScreen screens] objectAtIndex:1] availableModes] objectAtIndex: [[external availableModes] count]-1]; // use highest resolution
        max = current.size;
        maxScreenMode = current;
        external.currentMode = maxScreenMode;
        external.overscanCompensation = 3; // allow full screen
        UIWindow* tvoutWindow;
        tvoutWindow = [[UIWindow alloc] initWithFrame: CGRectMake(0, 0, max.width,max.height)];
        tvoutWindow.userInteractionEnabled = NO;
        tvoutWindow.screen = external;
        tvoutWindow.hidden = NO;
        tvoutWindow.backgroundColor = [UIColor greenColor];
        tvoutWindow.rootViewController=viewController;
        [tvoutWindow makeKeyAndVisible];
    }


I get a nice green screen on my TV, but nothing else. I assume I have missed a set in the process, can anyone tell me what it is that I have missed?

Also, once working, how would I go about displaying two different screens? such as the game screen on the TV and some sort of controller on the iOS device?


Spinal(Posted 2013) [#2]
Nobody at all?


rIKmAN(Posted 2013) [#3]
I was going to post but thought someone with more knowledge might chip in as I have no knowledge of the tv-out stuff at all.

First thing I'd test is that the green screen you are getting is coming from 'tvoutWindow.backgroundColor = [UIColor greenColor];' and not just a random signal output problem.

If you change the colour does the screen change also?

The next thing I would look at would be the viewController - isn't it called something else in Monkey (MonkeyView?)...so you may need to be using the Monkey one rather than the standard viewController?

Probably doesn't help, and probably wrong, but at least it's a reply :)


Spinal(Posted 2013) [#4]
OK, the following code will show the ios screen on the tv, but not at the correct size or rotation...

@implementation MonkeyAppDelegate
-(BOOL)shouldAutorotate {
    return YES;
}
- (NSUInteger)supportedInterfaceOrientations{
    return UIInterfaceOrientationMaskLandscapeRight;
}

UIWindow* tvoutWindow;
-(BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary*)launchOptions{

    // TV output support
    if([[UIScreen screens] count] == 1)
    {
        // Do what you normally do
    } else {
        CGSize max;
        UIScreenMode *maxScreenMode = nil;
        UIScreen *external = [[UIScreen screens] objectAtIndex: 1];
        UIScreenMode *current = [[[[UIScreen screens] objectAtIndex:1] availableModes] objectAtIndex: [[external availableModes] count]-1]; // use highest resolution
        max = current.size;
        maxScreenMode = current;
        external.currentMode = maxScreenMode;
        external.overscanCompensation = 3; // allow full screen
       
        tvoutWindow = [[UIWindow alloc] initWithFrame: CGRectMake(0, 0, max.width,max.height)];
        tvoutWindow.userInteractionEnabled = NO;
        tvoutWindow.screen = external;
        tvoutWindow.hidden = NO;
        tvoutWindow.backgroundColor = [UIColor greenColor];
        [tvoutWindow makeKeyAndVisible];
        [UIApplication sharedApplication].statusBarOrientation = UIInterfaceOrientationLandscapeRight;
    }
	
	//WUD? Can't set this in IB or it breaks 5.1.1?
	//
	if( [_window respondsToSelector:@selector(rootViewController)] ){
        _window.rootViewController=viewController;
        tvoutWindow.rootViewController=viewController;
        [tvoutWindow addSubview:viewController.view];
	}
	
    [_window makeKeyAndVisible];
    
	game=new BBMonkeyGame();
    
    try{
    
		bb_std_main( 0,0 );
    	
    }catch(...){
    
		exit( -1 );
    }
    
    if( !game->Delegate() ) exit( 0 );

	game->StartGame();

	return YES;
}

@end


My monkey game is landscape, but on the tv it's rotated to portrait at the top left of the screen and at the ipad screen size with the green background filling the rest of the space, rather than scaled to the full screen (which my game is capable of).


rIKmAN(Posted 2013) [#5]
I'm assuming that the Home screen and other apps are scaled correctly?


Spinal(Posted 2013) [#6]
The home screen and most other apps use the ios built in mirroring, so I only get 1024*768 stretched. I've tested this on a couple of my cocos2d games and they work fine, the screen size is recognised as 1920*1080.
This method is definitely creating the 1920*1080 screen, but it isn't rendering the monkey out put at that size.


rIKmAN(Posted 2013) [#7]
What do DeviceWidth() and DeviceHeight() report when in tv-out mode?

Do you use autofit or similar code of your own to handle scaling between different resolutions?


Spinal(Posted 2013) [#8]
DeviceWidth() and DeviceHeight() report the size of the ios screen, not the tv screen. I'm currently using a framework by Jayenkai (http://jayenkai.socoder.net/2013/03/monkey-skeleton-13-03-23/), which as you can see here - http://socoder.net/monkey/SpikeDislike2/MonkeyGame.html - is more than capable of utilising whatever screen resolutions you give it.


Spinal(Posted 2013) [#9]
Nobody have any idea?


rIKmAN(Posted 2013) [#10]
Can you get a screenshot / photo of it on your TV, might help people understand what your problem is.


Spinal(Posted 2013) [#11]
Looks like this...




Spinal(Posted 2013) [#12]
Nothing at all? Perhaps I'm the only person even remotely interested in providing a 1080p version of my game to people who plug their iOS device into their TV :-(


ElectricBoogaloo(Posted 2013) [#13]
Looking that way ;)
My Dev Center is split across two floors*, and I'm too lazy to run up and down the stairs to keep fiddling about with this stuff! Sorry..

* that makes me sound posh, and professional! What I mean is that my Apple TV is connected to the big-telly downstairs, and my Mac Mini is all the way upstairs.. That's a lot of piddling about, and I'm too unhealthy to attempt it!