Log in or register to post comments

Teapot cannot be drawn after removing `drawVideoBackground`

February 20, 2013 - 10:02pm #1

I am using `ImageTargets` sample.

(1)After I remove the line `QCAR::Renderer::getInstance().drawVideoBackground();` in `renderFrameQCAR`, the screen appears totally black and teapot cannot be drawn on the screen, even when `stones.jpg` is in the view of camera and `getNumTrackableResults` returns 1.

(2)I moved the line  `QCAR::Renderer::getInstance().drawVideoBackground();` after `for (int i = 0; i < state.getNumTrackableResults(); ++i)` loop, which draws the video background but the teapot cannot still be drawn, even when `stones.jpg` is in the view of camera and `getNumTrackableResults` returns 1.

I thought that teapot can be drawn when `getNumTrackableResults` returns 1. Can anyone explain this weird phenomena?

Teapot cannot be drawn after removing `drawVideoBackground`

February 21, 2013 - 11:29am #3

Hi, the reason of the issue is that you need to explicitly set the OpenGL viewport if you don't draw the videobackground via QCAR;

in practice, in your renderFrameQCAR() function you need to add this code in place of the removed drawVideoBackground():

 

// Set the viewport
    glViewport(viewportPosition_x, viewportPosition_y, viewportSize_x, viewportSize_y);

    // Explicitly render the Video Background
    // QCAR::Renderer::getInstance().drawVideoBackground();

Also, you need to declare these global variables:

int viewportPosition_x          = 0;
int viewportPosition_y          = 0;
int viewportSize_x              = 0;
int viewportSize_y              = 0;

And you need to compute their values in the configureVideoBackground() function, as shown here:

 viewportPosition_x =  (((int)(screenWidth  - config.mSize.data[0])) / (int) 2) + config.mPosition.data[0];
    viewportPosition_y =  (((int)(screenHeight - config.mSize.data[1])) / (int) 2) + config.mPosition.data[1];
    viewportSize_x = config.mSize.data[0];
    viewportSize_y = config.mSize.data[1];

Also, you need to disable to the config.mEnabled flag in the same function:

 config.mEnabled = false;

Note, the code snippets above refer to the Android implementation, but should be basically the same (with some minor adaptations) on iOS.

 

 

Teapot cannot be drawn after removing `drawVideoBackground`

February 21, 2013 - 11:17am #2

Hi,  I am currently investigating it; I will report to you asap.

Log in or register to post comments