Esempio n. 1
0
void TextureObjRefChunk::changeFrom(DrawEnv    *pEnv,
                                    StateChunk *old   ,
                                    UInt32      idx )
{
    // change from me to me?
    // this assumes I haven't changed in the meantime.
    // is that a valid assumption?
    if(old == this)
        return;

    pEnv->incNumChunkChanges();

    Window *pWin = pEnv->getWindow();

    if(activateTexture(pWin, idx))
        return; // trying to access too many textures

    if(this->getOsgGLId() != 0)
    {
        glBindTexture(this->getTarget(), 
                      pWin->getGLObjectId(this->getOsgGLId()));
    }
    else
    {
        glBindTexture(this->getTarget(), 
                      this->getOglGLId());
    }

    pEnv->setActiveTexTarget(idx, this->getTarget());

    glEnable(this->getTarget());
}
void TextureObjRefChunk::deactivate(DrawEnv *pEnv, UInt32 idx)
{
    Window *pWin = pEnv->getWindow();

    if(activateTexture(pWin, idx))
        return; // trying to access too many textures

    glDisable(this->getTarget());

    pEnv->setActiveTexTarget(idx, GL_NONE);
}
void TextureObjRefChunk::activate(DrawEnv *pEnv, UInt32 idx)
{    
    Window *pWin = pEnv->getWindow();

    if(activateTexture(pWin, idx))
        return; // trying to access too many textures

    glBindTexture(this->getTarget(), 
                  pWin->getGLObjectId(this->getGLId()));

    pEnv->setActiveTexTarget(idx, this->getTarget());

    glEnable(this->getTarget());
}
Esempio n. 4
0
	void Shader::setValue(const std::string& name, const GLBuffer_Ptr& value, int textureUnit /*= -1*/ )
	{
		sf::Int32 loc = glGetUniformLocation(m_program, name.c_str());
		if (loc > -1)
		{
			if (textureUnit < 0)
			{
				textureUnit = nextTextureUnit();
			}
			ActivateTexture activateTexture(textureUnit);
			value->bind();
			glUniform1i(loc, textureUnit);
		}
	}