Log in or register to post comments

QCAR Changing GLES state

August 14, 2011 - 12:19am #1

Hi

I'm trying to combine using the Irrlicht renderer with the QCAR SDK in an iOS app so that I can render my scene in Irrlicht using the data provided by QCAR.
The problem I have is that Irrlicht assumes GLES is in the same state the beginning of the next frame as it was in the previous frame. QCAR seems to be altering the state, presumably to render the camera image as a full screen quad. I know it is changing the shader program. Does anyone know what else it changes?
This is roughly what I'm doing in renderFrameQCAR:
QCAR::Renderer().begin();


QCAR::Renderer().end();

I want to backup/restore the relevant GLES states so that Irrlicht can start with the state the same as it left it. Cheers, Mark.

Re: QCAR Changing GLES state

October 17, 2011 - 10:27pm #6

Soldmeadow, I'm keen to use cocos3d with QCAR but I'm having problems integrating the 2 EAGLViews - like it's been posted under the subject of "Cocos2d and QCAR project integration". I'd really appreciate hearing how you overcame this.

Re: QCAR Changing GLES state

August 23, 2011 - 5:47am #5
TheDoktor wrote:

Hi

The problem I have is that Irrlicht assumes GLES is in the same state the beginning of the next frame as it was in the previous frame. QCAR seems to be altering the state, presumably to render the camera image as a full screen quad. I know it is changing the shader program. Does anyone know what else it changes?

Cheers,
Mark.

I had exactly the same question a few weeks back when I tried to use a 3d graphics engine with QCAR. I still don't know the exact answer to that question so I'm as interested as you are in getting this particular answer.

I did managed, however, to make QCAR work with my 3d engine. My workaround was to look at the state of the OpenGL context at creation time, set this exact context before rendering my 3d objects and setting it back as it was left by QCAR after the begin() call before the next iteration. It is not as efficient as it could be though. My pseudo code :

QCAR::Renderer().begin();



QCAR::Renderer().end();

Hope it helps.

Re: QCAR Changing GLES state

August 15, 2011 - 7:32pm #4

I have my project set up exactly like the ImageTargets example and am working on iOS.

I get two images in my frame. One in YUV and the other RGB565. You need to iterate over the images in the frame to get the one in the format you want. There is some code in the forums if you search for getPixels().

The RGB565 image can be loaded into a texture on iOS using:

glTexImage2D(GL_TEXTURE_2D, 0, GL_RGB, (GLsizei) pixelWidth, (GLsizei) pixelHeight, 0, GL_RGB, GL_UNSIGNED_SHORT_5_6_5, data);

Where data is the void pointer returned by getPixels().

Re: QCAR Changing GLES state

August 15, 2011 - 8:19am #3

Cheers soldmeadow,

I had a look at that page you suggested and it doesn't seem to detail all the GLES2 state changes (e.g.. changing the program).
The solution you've suggested is a better option though which is what I'm going to use. Did you use QCAR::setFrameFormat(QCAR::RGB888, true); to enable the converter or did you convert from YUV another way?

Thank you very much for your help,
Mark.

Re: QCAR Changing GLES state

August 14, 2011 - 5:58pm #2

It is explained in the Developer Guide under Tips,Tricks... the section entitled OpenGL State Changes in Video Background Renderer.

I had similar issues integrating cocos3d. I ended up just streaming the QCAR camera feed into a texture that I render using cocos3d's renderer on the main thread. This gives more flexibility for doing things like animated scene transitions. I thought it may be too slow but it is very fast e.g 3GS hovers between 50-60fps and a 4G iPod Touch is 60fps when rendering the camera feed and about 20 non batched line draws.

Log in or register to post comments