[SOLVED] OGRE + Vuforia QCAR + Android = black background

Discussion of issues specific to mobile platforms such as iOS, Android, Symbian and Meego.
roman_s
Gnoblar
Posts: 2
Joined: Sun Jul 28, 2013 2:28 pm

[SOLVED] OGRE + Vuforia QCAR + Android = black background

Post by roman_s »

Hello everybody,

I have android app with augmented reality by vuforia.
But:
GalaxyTab P7510 CyanogenMod 10.2 = Android 4.3.1 - camera is on background - works - see attachment 1
GalaxyS3 I9300 - stock Android 4.1.2 - shows black background :/ - see attachement 2

I have RelativeLayout with addView(), one GLSurfaceView as background, second SurfaceView with Ogre.
When I remove mRoot->renderOneFrame(), then I see camera, but not Ogre, of course.

Ogre v1-9 branch, commit Sun Sep 15 12:08:53 2013 +0300 Code cleanup
NDK r8e
Built on Linux

Here is some code:

Ogre SurfaceView rendering:

Code: Select all

glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);

glEnable(GL_BLEND);
glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
glEnable(GL_DEPTH_TEST);
glEnable(GL_CULL_FACE);

try {
    mRenderWnd->windowMovedOrResized();
    mRoot->renderOneFrame();
}
catch(Ogre::RenderingAPIException ex) {
}

glDisable(GL_BLEND);
glDisable(GL_DEPTH_TEST);
Vuforia GLSurfaceView rendering:

Code: Select all

QCAR::State state = QCAR::Renderer::getInstance().begin();

QCAR::Renderer::getInstance().drawVideoBackground();

QCAR::Renderer::getInstance().end();
Viewport:

Code: Select all

viewport->setClearEveryFrame(true, Ogre::FBT_DEPTH|Ogre::FBT_STENCIL);
Some Java stuff:

Code: Select all

mGlView = new ARGLSurfaceView(this);
mGlView.init(mQCARFlags, translucent, depthSize, stencilSize);
mGlView.setRenderer(mGlView);
mGlView.setRenderMode(GLSurfaceView.RENDERMODE_WHEN_DIRTY);

mSurfaceView = new OgreSurfaceView(this);
mSurfaceView.setVisibility(View.INVISIBLE);
mMainLayout.addView(mSurfaceView, new ViewGroup.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.MATCH_PARENT));

mLoadingIndicator.bringToFront();

mSurfaceView.setVisibility(View.VISIBLE);

// then ...

mGlView.mIsActive = true;
mMainLayout.addView(mGlView, new ViewGroup.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.MATCH_PARENT));

mGlView.setVisibility(View.VISIBLE);

// then ...

QCARJNI.startCamera();

// the both Views has:

holder.setFormat(PixelFormat.TRANSLUCENT);
Thanks for any help or ideas.

Roman

[UPDATE] Test GalaxyTab 10.2 stock Android 4.2 - the same black background

[SOLVED]
Okay, I have moved QCAR rendering stuff from QCAR GLSurfaceView to OGRE's SurfaceView. First QCAR begin and drawVideo, then render OGRE and QCAR end.

And everything works!!!

Thanks to OGRE!!!
android88
Gnoblar
Posts: 2
Joined: Thu Jun 11, 2015 3:59 am

Re: [SOLVED] OGRE + Vuforia QCAR + Android = black backgroun

Post by android88 »

Hello, I am also integrated qcar + ogre, and your problem, I still can not be content ogre superimposed on the camera content qcar, my code is as follows:

Code: Select all


    m_pViewport->setClearEveryFrame(true, Ogre::FBT_DEPTH | Ogre::FBT_STENCIL);

    glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);

    QCAR::State state = QCAR::Renderer::getInstance().begin();
    QCAR::Renderer::getInstance().drawVideoBackground();

    glEnable(GL_BLEND);
    glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
    glEnable(GL_DEPTH_TEST);
    glEnable(GL_CULL_FACE);

    if (QCAR::Renderer::getInstance().getVideoBackgroundConfig().mReflection == QCAR::VIDEO_BACKGROUND_REFLECTION_ON) {
        glFrontFace(GL_CW); //Front camera
    }
    else {
        glFrontFace(GL_CCW); //Back camera
    }

    m_pRoot->renderOneFrame();
    m_pRenderWnd->update();
    
    glDisable(GL_BLEND);
    glDisable(GL_DEPTH_TEST);
    glDisable(GL_CULL_FACE);

    QCAR::Renderer::getInstance().end();

    m_pRenderWnd->swapBuffers();

I hope you can provide some portion of your qcar + ogre rendering code, thank you very much!