Log in or register to post comments

Using external projector to show OpenGL EAGLView

September 24, 2012 - 3:49am #1

Hi everybody,

i build an app that shows videos on top of the tags, and it works very well (I'm developing on iOS). But, now I want to show the EAGLView stuff on an external display but I can't. I slighly modified applicationDidFinishingLauchingWithOptions: like this:

 

- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions

{

    QCARutils *qUtils = [QCARutils getInstance];

CGRect screenBounds ;

    if ([[UIScreen screens] count] > 1)

{

        // Associate the window with the second screen.

        // The main screen is always at index 0.

UIScreen*secondScreen = [[UIScreenscreens] objectAtIndex:1];

CGRectscreenBounds = secondScreen.bounds;

UIWindow *_secondWindow;

_secondWindow = [[UIWindowalloc] initWithFrame:screenBounds];

_secondWindow.screen = secondScreen;

         // Go ahead and show the window.

_secondWindow.hidden = NO;

window = _secondWindow;

}

else {

screenBounds = [[UIScreenmainScreen] bounds];

window = [[UIWindowalloc] initWithFrame: screenBounds];

}

    // Provide a list of targets we're expecting - the first in the list is the default

    [qUtils addTargetName:@"WonderBook" atPath:@"wonderbook.xml"];

    if(![[UIApplication sharedApplication] isScreenMirroringActive]){

        [[UIApplication sharedApplication] setupScreenMirroring];

}

    // Add the EAGLView and the overlay view to the window

    arParentViewController = [[VPParentViewController alloc] init];

    arParentViewController.arViewRect = screenBounds;

    [window insertSubview: arParentViewController.view atIndex:0];

    [window makeKeyAndVisible];

    [window layoutSubviews];

    return YES;

I'm using this simple library that works well but is too slow 'cause doesn't use OpenGL but every frames is captured and shown on both display.
Is there a simpler way to show everything that happens on main screen ([UIScreen mainScreen]) directly on another external screen and draw on it?

Thanks in advance

Best regards.  

Using external projector to show OpenGL EAGLView

September 26, 2012 - 3:24am #7

That's awesome

great stuff! and thanks for sharing

Using external projector to show OpenGL EAGLView

September 26, 2012 - 2:33am #6

Solved.
I had to disable the [UIScreen mainScreen] and add the EAGLView to the ViewController attached to the UIWindow *externalWindow.

So everything now is drawn on the external display. And best of all, I don't need external mirroring class anymore.

Thanks for your precious help.

This is the code that i wrote for didFinishLaunchingWithOptions

- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions

{

    QCARutils *qUtils = [QCARutils getInstance];

    

    CGRect screenBounds ;

    

    

    if ([[UIScreen screens] count] > 1) {

        

        // Associate the window with the second screen.

        // The main screen is always at index 0.

        UIScreen    *externalScreen = [[UIScreen screens] objectAtIndex:1];

        CGRect      screenBounds = externalScreen.bounds;

        UIWindow    *externalWindow;

     

        externalWindow = [[UIWindow alloc] initWithFrame:screenBounds];

        externalWindow.screen = externalScreen;

        externalWindow.hidden = NO;

        arParentViewController = [[VPParentViewController alloc] init];

        [arParentViewController loadView];

        [externalWindow addSubview: arParentViewController.getARView];              

    } else {

        

        screenBounds = [[UIScreen mainScreen] bounds];

        window = [[UIWindow alloc] initWithFrame: screenBounds];

        arParentViewController = [[VPParentViewController alloc] init];

        arParentViewController.arViewRect = screenBounds;

        [window insertSubview: arParentViewController.view atIndex:0];

        [window makeKeyAndVisible];

        [window layoutSubviews];

 

    }

    

    /* Don't need you anymore

    if(![[UIApplication sharedApplication] isScreenMirroringActive]){

        [[UIApplication sharedApplication] setupScreenMirroring];

    }

    */

  

    [qUtils addTargetName:@"myPersonalXML" atPath:@"myPersonalXML.xml"];

    

    return YES;

}

This saved my live. 

Thanks again.

Using external projector to show OpenGL EAGLView

September 25, 2012 - 7:15am #5

NalinS wrote:

I had a quick look at the library you had a look to but could find no documentation :(

I guess at a high level (assuming its possible) there might be two approaches:

  • Create two windows instead of one and create a single EAGLContext that is linked to both
  • Create two windows and create a two EAGLContexts, and draw into both

The first approach is likely to be faster, though as I said I am not sure if it is possible.  Another variation on the second approach rather than draw into both EAGLContexts, just draw into one and copy the texture into the second context.

The EAGLContext is set up in AR_EAGLView.mm in initWithFrame() so you might want to explore this a bit more.

HTH

N

 

I think that first solution should be better.
It's not an easy task, though, to link a  EAGLContext to 2 UIwindow.

Thanks..I'll let you know.

 

Using external projector to show OpenGL EAGLView

September 25, 2012 - 2:50am #4

I had a quick look at the library you had a look to but could find no documentation :(

I guess at a high level (assuming its possible) there might be two approaches:

  • Create two windows instead of one and create a single EAGLContext that is linked to both
  • Create two windows and create a two EAGLContexts, and draw into both

The first approach is likely to be faster, though as I said I am not sure if it is possible.  Another variation on the second approach rather than draw into both EAGLContexts, just draw into one and copy the texture into the second context.

The EAGLContext is set up in AR_EAGLView.mm in initWithFrame() so you might want to explore this a bit more.

HTH

N

Using external projector to show OpenGL EAGLView

September 25, 2012 - 1:37am #3

NalinS wrote:

I guess the simplest way to achieve this is to run it on an iPad that is connected up to an external display via a simple cable.

... but maybe this is not what you want?

Yeah, exactly I have to use an iPhone (iPad should be too big)... 

I'm dealing with CAEGLayer and EaglView class but I couldn't find the code where the  you can say to OpenGL to draw in another UIwindow...
 

Using external projector to show OpenGL EAGLView

September 24, 2012 - 9:33am #2

I guess the simplest way to achieve this is to run it on an iPad that is connected up to an external display via a simple cable.

... but maybe this is not what you want?

N

Log in or register to post comments