Log in or register to post comments

Video background initialisation causes loss of texture on my model

February 15, 2013 - 1:16am #1

Hi guys, 

Im loading up a model using C++ and OpenGLES and it looses the texture depending on where i load the texture in OpenGLES. 

 

If i load the model before QCAR::CameraDevice::getInstance().start() is called the texture is rendered which leads me to believe that a GL state stops the texture from loading correctly.

 

Also if i remove QCAR::Renderer::getInstance().drawVideoBackground(); from my render loop it also renders the texture on the model.

 

So i have got to the point where i know its the rendering of the video texture to the quad or loading the texture. 

 

I have read this https://developer.vuforia.com/resources/dev-guide/opengl-state-changes-video-background-renderer and it doesnt fix the issue. 

 

Jim @Dev2rights

 

 

Video background initialisation causes loss of texture on my mod

February 19, 2013 - 8:38am #4

Hi Dev2rights,

I have checked with one of our OpenGL ES gurus and here is the summary.

Vuforia assumes it gets the GL state "Dirty" so it is the responsibility of the developer to restore the desired GL state after drawVideoBackground() and bindVideoBackground.  So the advice is to cache the Texture and Enable states using the following Open GL ES API  and restore them after the problematic call:

 

At present there is no implicit saving of the GL states, though as you might imagine to do this on every frame could be expensive.

The other idea I had was that you may be able to use a specific texture unit but this is unlikely to work. 

HTH

N

 

Video background initialisation causes loss of texture on my mod

February 18, 2013 - 9:57am #3

Hi Nalin, 

 

Yeah i have been line by line through (void)renderFrameQCAR, hence how i determined that if i just render my model and not the camera it still renders the texture. In turn if i load the texture before the call to QCAR::CameraDevice::getInstance().start() it works fine. Which suggests its an issue with the texture unit used or perhaps a glState that is set after that fucntion call. But without being able to see the implmentation of QCAR::CameraDevice::getInstance().start() its near impossible to determine. Ive taken a far from ideal route of restarting the camera and loadign models and textures each time i load a new scene in my engine. But this is a work around not a soloution ofcourse, so any suggestions would be appreciated. Or its a case of trying every glEnable / glDisable permutation till i work it out.

 

Dev2rights

Video background initialisation causes loss of texture on my mod

February 18, 2013 - 7:24am #2

It might be a good idea if you go through the  (void)renderFrameQCAR in order to check the render loop order which is pretty self explanatory.

However it is worth bearing in mind that this happens on a background thread, which can be the cause of texture problems, so best not to do any loading/initialisation here at all.  If you have to do this then you may need to wrap up the methods within performSelectorOnMainThread(), however you may still need to be careful of threading issues.

As a result the samples set up all their textures and models as part of the initialisation phase - see setup3DObjects() as an example.  Then when it comes to rendering these within renderFrameQCAR() simply sets up the states/buffers and binds the textures before calling glDrawElements()

HTH

N

 

 

 

 

 

Log in or register to post comments