Hi

you should let osg know of what are you doing with opengl state, or revert it 
back when done drawing your texture.
f.e. if osg thinks that active texture unit is 0, and it actually 5 after your 
gl stuff bad things can happed, as next osg call to glBindTexture will leave 
texture unit 0 without texture assigned, and it will sit unused in slot 5.

if you can use osg state in place where you call gl functions, i can suggest 
you to use osg state setActiveTexture(...) instead of glActiveTexture calls, 
and set active texture back (you can get current with osg state 
getActiveTexture()) after you finished with your texture.
if not - you can try just call glActiveTexture(GL_TEXTURE0); after you are done.

Cheers.

17.09.2012, 23:12, "Thomas Hogarth" <thomas.hoga...@gmail.com>:
> Hi All
>
> So I'm using an extension on iOS that allows me to fast draw video frames
> coming from the camera in OpenGL.
>
> The requirement though is that I bind and create the texture during a 
> callback so I have to call makeCurrent on the osg context then do manual 
> OpenGL commands, like below.
>
> Code:
>     _viewer->getCamera()->getGraphicsContext()->makeCurrent();
>
>     [self cleanUpTextures];
>
>     // CVOpenGLESTextureCacheCreateTextureFromImage will create GLES texture
>     // optimally from CVImageBufferRef.
>
>     glActiveTexture(GL_TEXTURE5);
>     err = CVOpenGLESTextureCacheCreateTextureFromImage(kCFAllocatorDefault,
>                                                        _videoTextureCache,
>                                                        pixelBuffer,
>                                                        NULL,
>                                                        GL_TEXTURE_2D,
>                                                        GL_RGBA,
>                                                        width,
>                                                        height,
>                                                        GL_BGRA,
>                                                        GL_UNSIGNED_BYTE,
>                                                        0,
>                                                        &_lumaTexture);
>     if (err)
>     {
>         NSLog(@"Error at CVOpenGLESTextureCacheCreateTextureFromImage %d", 
> err);
>     }
>
>     glBindTexture(CVOpenGLESTextureGetTarget(_lumaTexture), 
> CVOpenGLESTextureGetName(_lumaTexture));
>         glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE);
>         glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE);
>
> I then use a uniform to tell osg where to look for the texture, in this case 
> channel 5 and everything works fine. The problems start when I introduce 
> models loaded and rendered with osg. All the models only use textures in 
> channel 0, but as soon as I start using them the video quad goes black and 
> other textures start flickering.
>
> My guess is osg is is doing something to my texture, is there a way to tell 
> osg to leave a certain channel alone, or some other sort of magic?
>
> Thanks
> Tom
>
> ------------------
> Read this topic online here:
> http://forum.openscenegraph.org/viewtopic.php?p=50157#50157
>
> _______________________________________________
> osg-users mailing list
> osg-users@lists.openscenegraph.org
> http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org
_______________________________________________
osg-users mailing list
osg-users@lists.openscenegraph.org
http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org

Reply via email to