[osg-users] glActiveTextureARB in OSG

Robert Osfield robert.osfield at gmail.com
Thu Mar 12 03:45:07 PDT 2009

Hi Martin,

On Thu, Mar 12, 2009 at 10:36 AM, Großer Martin <grosser.martin at gmx.de> wrote:
> I'd like to use a OSG class. But I don't know which class I can use.
> There are no way to change the active texture in osg or can I reset the
> opengl state machine? After the rendering ( frame() ) the active texture
> is not TEXTURE0_ARB, but that is what I need.

Use osg::State::setClientActiveTextureUnit(unsigned int unit);

It's implementation as:

bool State::setClientActiveTextureUnit( unsigned int unit )
    if (unit!=_currentClientActiveTextureUnit)
        if (_glClientActiveTexture && unit < (unsigned int)_glMaxTextureCoords)
            _currentClientActiveTextureUnit = unit;
            return unit==0;
    return true;

I would however recommend using OSG objects to do rendering, as well
as my previously stated reasons it also will mean that you won't have
clunky high level code trying to manage drawing of the OSG and OpenGL
code.  For instance you meantion rendering after viewer.frame() which
suggests you're making the assumption that you are working on a single
graphics context single thread and that the viewer hasn't released the
graphics context.  You can do all of these things but you have to know
what you are doing.

If you do things in the scene graph, all the management of multiple
graphics contexts and threading will just fall out for free.


More information about the osg-users mailing list