Log in or register to post comments

Isgl3d and vuforia sdk

March 27, 2012 - 12:39pm #1

Hello.

I want integrate vuforia sdk with Isgl3d framework.

I changed ImageTarget example from the vuforia sdk samples. In
ImageTargetAppDelegate.mm add isgl view with transparent
background over the arParentController.view but I get a black screen.

When I commented out this:
//[[Isgl3dDirector sharedInstance] run]

then I normaly see my video camera image.

May be something wrong with cleaning background? But I set the transparency:

[Isgl3dDirector sharedInstance].backgroundColorString = @"00000000";
..
..
_viewController.view.backgroundColor = [UIColor clearColor];
_viewController.view.opaque = NO;

This is my ImageTargetAppDelegate.mm:

#import "ImageTargetsAppDelegate.h"
#import "ARParentViewController.h"
#import "QCARutils.h"
#import "Isgl3d.h"
#import "Isgl3dViewController.h"
#import "GWViewManager.h"
#import "GWPlayersListViewController.h"

@implementation ImageTargetsAppDelegate

static BOOL firstTime = YES;

// test to see if the screen has hi-res mode
- (BOOL) isRetinaEnabled{
    return ([[UIScreen mainScreen] respondsToSelector:@selector(displayLinkWithTarget:selector:)]
            &&
            ([UIScreen mainScreen].scale == 2.0));
}

// Setup a continuation of the splash screen until the camera is initialised
- (void) setupSplashContinuation{
    CGRect screenBounds = [[UIScreen mainScreen] bounds];
    
    // first get the splash screen continuation in place
    NSString *splashImageName = @"Default.png";
    if (screenBounds.size.width == 768)
        splashImageName = @"Default-Portrait~ipad.png";
    else if ((screenBounds.size.width == 320) && [self isRetinaEnabled])
        splashImageName = @"Default@2x.png";
    
    UIImage *image = [UIImage imageNamed:splashImageName];
    splashV = [[UIImageView alloc] initWithImage:image];
    splashV.frame = screenBounds;
    [window addSubview:splashV];

    // poll to see if the camera video stream has started and if so remove the splash screen.
    [NSTimer scheduledTimerWithTimeInterval:0.2 target:self selector:@selector(removeSplash:) userInfo:nil repeats:YES];
}


// this is the application entry point
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions{
    QCARutils *qUtils = [QCARutils getInstance];
    
    CGRect screenBounds = [[UIScreen mainScreen] bounds];
    window = [[UIWindow alloc] initWithFrame: screenBounds];
    
    [self setupSplashContinuation];
    
    // Provide a list of targets we're expecting - the first in the list is the default
    [qUtils addTargetName:@"Stones & Chips" atPath:@"StonesAndChips.xml"];
    [qUtils addTargetName:@"Tarmac" atPath:@"Tarmac.xml"];
    
    // Add the EAGLView and the overlay view to the window
    arParentViewController = [[ARParentViewController alloc] init];
    arParentViewController.arViewRect = screenBounds;
    [window insertSubview:arParentViewController.view atIndex:0];
    //[window addSubview:arParentViewController.view];
    [window makeKeyAndVisible];
    
    // Set the background transparent
	[Isgl3dDirector sharedInstance].backgroundColorString = @"00000000"; 
    // Create the UIViewController
	_viewController = [[Isgl3dViewController alloc] init];
	_viewController.wantsFullScreenLayout = YES;
    
	// Create OpenGL view (here for OpenGL ES 1.1)
	Isgl3dEAGLView * glView = [Isgl3dEAGLView viewWithFrameForES1:[window bounds]];
    
	// Set view in director
	[Isgl3dDirector sharedInstance].openGLView = glView;
	
	// Enable retina display : uncomment if desired
	[[Isgl3dDirector sharedInstance] enableRetinaDisplay:YES];
    
	// Enables anti aliasing (MSAA) : uncomment if desired (note may not be available on all devices and can have performance cost)
    [Isgl3dDirector sharedInstance].antiAliasingEnabled = YES;
	
	// Set the animation frame rate
	[[Isgl3dDirector sharedInstance] setAnimationInterval:1.0/60];
    
	// Add the OpenGL view to the view controller
	_viewController.view = glView;
	// Make the opengl view transparent
	_viewController.view.backgroundColor = [UIColor clearColor];
	_viewController.view.opaque = NO;
	// Add view to window and make visible
	[window addSubview:_viewController.view];
	[window makeKeyAndVisible];
    
	[_viewController.view addSubview:[GWViewManager instance].playersList.view];
    
	// Creates the view(s) and adds them to the director
	//Isgl3dView *sceneView = [GWViewManager instance].helloWorldView; 
	//[[Isgl3dDirector sharedInstance] addView:sceneView];
	
	//Isgl3dView *uiView = [GWViewManager instance].interfaceView;
	//[[Isgl3dDirector sharedInstance] addView:uiView];
	
	//Isgl3dView *toolPanelView = [GWViewManager instance].toolPanelView;
	//[[Isgl3dDirector sharedInstance] addView:toolPanelView];
	
	// Run the director
	[[Isgl3dDirector sharedInstance] run];
    
    return YES;
}

- (void) removeSplash:(NSTimer *)theTimer{
    // poll to see if the camera video stream has started and if so remove the splash screen.
    if ([QCARutils getInstance].videoStreamStarted == YES)
    {
        [splashV removeFromSuperview];
        [theTimer invalidate];
    }
}


- (void)applicationDidBecomeActive:(UIApplication *)application{
    // don't do this straight after startup - the view controller will do it
    if (firstTime == NO)
    {
        // do the same as when the view is shown
        [arParentViewController viewDidAppear:NO];
    }
    firstTime = NO;
    [[Isgl3dDirector sharedInstance] resume];
}

- (void)applicationWillResignActive:(UIApplication *)application{
    // do the same as when the view has dissappeared
    [arParentViewController viewDidDisappear:NO];
    [[Isgl3dDirector sharedInstance] pause];
}


- (void)applicationWillTerminate:(UIApplication *)application{
        // Remove the OpenGL view from the view controller
	[[Isgl3dDirector sharedInstance].openGLView removeFromSuperview];
	
	// End and reset the director	
	[Isgl3dDirector resetInstance];
	
	// Release
	[_viewController release];
	_viewController = nil;
	[window release];
	window = nil;
}

- (void) applicationDidEnterBackground:(UIApplication *)application {
	[[Isgl3dDirector sharedInstance] stopAnimation];
}

- (void) applicationWillEnterForeground:(UIApplication *)application {
	[[Isgl3dDirector sharedInstance] startAnimation];
}

- (void) applicationDidReceiveMemoryWarning:(UIApplication *)application {
	[[Isgl3dDirector sharedInstance] onMemoryWarning];
}

- (void) applicationSignificantTimeChange:(UIApplication *)application {
	[[Isgl3dDirector sharedInstance] onSignificantTimeChange];
}

- (void)dealloc{
        if(arParentViewController){
		[arParentViewController release];
	}
	if (_viewController) {
		[_viewController release];
	}
	if (window) {
		[window release];
	}
	
	[GWViewManager destroy];	
	[super dealloc];
}

@end
 

Re: Isgl3d and vuforia sdk

March 30, 2012 - 8:52am #5

Hi little, we have no experience of this platform, but if you have no renderFrameQCAR you can make the calls that renderFrameQCAR makes from your own code. You drive the rendering refresh. Note that the OpenGL state may get interfered with so you may need to reset some state after you've made the calls if you need it back to a known state.

Hope that helps.

Re: Isgl3d and vuforia sdk

March 29, 2012 - 8:17am #4

Or may be I can simply add VideoCamera view, on top of it Isgl3dView, and in the Isgl3d frame render method I can call QCAR methods to get marker position, orientation and scale?

Re: Isgl3d and vuforia sdk

March 29, 2012 - 8:07am #3

No, I have not see any objects. Just black screen

Now, I try to add simple cube - Isgl3dTutorial1View from Isgl3d samples, and I see in the XCode "All Output":

iSGL3D : ERROR : Error uploading texture. glError: 0x0506 underlying OpenGL error : unknown error

// this is the application entry point
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
{
    CGRect screenBounds = [[UIScreen mainScreen] bounds];
    window = [[UIWindow alloc] initWithFrame: screenBounds];
    
    QCARutils *qUtils = [QCARutils getInstance];
    
    [self setupSplashContinuation];
    
    // Provide a list of targets we're expecting - the first in the list is the default
    [qUtils addTargetName:@"Stones & Chips" atPath:@"StonesAndChips.xml"];
    [qUtils addTargetName:@"Tarmac" atPath:@"Tarmac.xml"];
    
    // Add the EAGLView and the overlay view to the window
    arParentViewController = [[ARParentViewController alloc] init];
    arParentViewController.arViewRect = screenBounds;
    [window insertSubview:arParentViewController.view atIndex:0];
    [window makeKeyAndVisible];
   
    // Instantiate the Isgl3dDirector and set background color 
    [Isgl3dDirector sharedInstance].backgroundColorString = @"333333ff"; 
    // Set the device orientation 
    [Isgl3dDirector sharedInstance].deviceOrientation = Isgl3dOrientationPortrait; 
    // Set the director to display the FPS 
    [Isgl3dDirector sharedInstance].displayFPS = YES; 
   
    Isgl3dEAGLView *glView = [Isgl3dEAGLView viewWithFrameForES1:[window bounds]];
    
    [Isgl3dDirector sharedInstance].openGLView = glView;
    Isgl3dView * view = [Isgl3dTutorial1View view];
	[[Isgl3dDirector sharedInstance] addView:view];
    viewController = [[Isgl3dViewController alloc] init];
    viewController.wantsFullScreenLayout = YES;
    viewController.view = glView;
    
    //add simple cube
    Isgl3dView * cubeView = [Isgl3dTutorial1View view];
    [[Isgl3dDirector sharedInstance] addView:cubeView];
    
    [window addSubview:viewController.view];
    [window makeKeyAndVisible];
    
    [[Isgl3dDirector sharedInstance] enableRetinaDisplay:YES]; 

    // Set the animation frame rate 
    [[Isgl3dDirector sharedInstance] setAnimationInterval:1.0/60]; 

    // Run the director 
    [[Isgl3dDirector sharedInstance] run]; 
    
    return YES;
}

May be it happened because Vuforia SDK has AR_EAGLView and Isgl3d has its own Isgl3dEAGLView.

How do you think will help a create my own Isgl3dAR_EAGLView inherited from Isgl3dEAGLView and implemented functionality from AR_EAGLView?

Re: Isgl3d and vuforia sdk

March 28, 2012 - 8:10am #2

Hi little,

I may be wrong, but the immediate reading is that Isgl3d itself is clearing the background of the EAGLContext, or drawing in a background with a mesh - do you see any objects drawn by Isgl3d, over the black background?

If this is the case look to see if Isgl3d has transparency/background settings.

Log in or register to post comments