Hi,
Here it is :
Code:
#include <RenderBox/GLBoxWrappers/GLBoxOsgTexture.h>
#include <GLBox/Texture/Texture.h>
//
MyTexture::MyTexture()
: osg::StateAttribute ()
, p_CustomerTexture (NULL)
{
}
//
MyTexture::MyTexture(CustomerTexture* pCustomerTexture)
: osg::StateAttribute ()
, p_CustomerTexture (NULL)
{
setCustomerTexture(pCustomerTexture);
}
//
MyTexture::MyTexture(const MyTexture& texture, const osg::CopyOp& copyop)
: osg::StateAttribute (texture, copyop)
, p_CustomerTexture (NULL)
{
setCustomerTexture(texture.customerTexture());
}
//
osg::Object* MyTexture::cloneType() const
{
return new MyTexture ();
}
//
osg::Object* MyTexture::clone(const osg::CopyOp& copyop) const
{
return new MyTexture (*this, copyop);
}
//
bool MyTexture::isSameKindAs(const osg::Object* pObj) const
{
return dynamic_cast<const MyTexture *>(pObj)!=NULL;
}
//
const char* MyTexture::libraryName() const
{
return "MyLibrary";
}
//
const char* MyTexture::className() const
{
return "MyTexture";
}
//
MyTexture::~Texture()
{
}
//
CustomerTexture* MyTexture::customerTexture() const
{
return p_CustomerTexture;
}
//
void MyTexture::setCustomerTexture(CustomerTexture* pCustomerTexture)
{
p_CustomerTexture = pCustomerTexture;
}
//
osg::StateAttribute::Type MyTexture::getType() const
{
return osg::StateAttribute::TEXTURE;
}
//
bool MyTexture::isTextureAttribute() const
{
return true;
}
//
int MyTexture::compare(const osg::StateAttribute& stateAttribute) const
{
MyTexture const* pOther = dynamic_cast<MyTexture
const*>(&stateAttribute);
if (pOther != NULL)
{
if (p_CustomerTexture == pOther->GLBoxTexture())
{
return 0;
}
return 1;
}
return -1;
}
//
bool MyTexture::getModeUsage(osg::StateAttribute::ModeUsage& modeUsage) const
{
if (p_CustomerTexture != NULL)
{
modeUsage.usesTextureMode(p_CustomerTexture->target());
return true;
}
return false;
}
//
void MyTexture::apply(osg::State& /*state*/) const
{
if (p_CustomerTexture != NULL)
{
// Execute a "glBind" using the pre-allocated customer texure id
// Take care of mulitple context/sharing contexts....
p_CustomerTexture->bindYourCustomerTexture();
}
}
//
void MyTexture::compileGLObjects(osg::State& /*state*/) const
{
// Nothing to do : the OpenGL texture should be managed by the
"CustomerTexture" class
}
//
void MyTexture::resizeGLObjectBuffers(unsigned int /*maxSize*/)
{
// Nothing to do : the OpenGL texture should be managed by the
"CustomerTexture" class
}
//
void MyTexture::releaseGLObjects(osg::State* /*pState*/) const
{
// Nothing to do : the OpenGL texture should be managed by the
"CustomerTexture" class
}
Cheers,
Aurelien
------------------
Read this topic online here:
http://forum.openscenegraph.org/viewtopic.php?p=56708#56708
_______________________________________________
osg-users mailing list
[email protected]
http://lists.openscenegraph.org/listinfo.cgi/osg-users-openscenegraph.org