Пример #1
0
    void bindTexture(size_t unit, const TexturePtr& texture) {
        if (unit > 0) {
            // Only call this function if we know multitexturing is
            // supported.
            glActiveTextureARB(GL_TEXTURE0_ARB + unit);
        }

        if (texture) {
            /// @todo With shaders, you don't need to glEnable the texture.
            glEnable(GL_TEXTURE_2D);
            glBindTexture(GL_TEXTURE_2D, texture->getHandle());
        } else {
            glDisable(GL_TEXTURE_2D);
            glBindTexture(GL_TEXTURE_2D, 0);
        }

        if (unit > 0) {
            glActiveTextureARB(GL_TEXTURE0_ARB);
        }
    }
Пример #2
0
void kore::
  TexturesComponent::addTexture(TexturePtr tex,
                                const bool useMipMaps /*=true*/,
                                const TextureSampler* sampler /*= NULL*/ ) {
  if (std::find(_vTextures.begin(),
                _vTextures.end(), tex) != _vTextures.end()) {
    return;
  }

  STextureInfo* texInfo = new STextureInfo;
  texInfo->texLocation = tex->getHandle();
  texInfo->texTarget = tex->getProperties().targetType;
  _vTextureInfos.push_back(texInfo);

  ShaderData shaderdata;
  shaderdata.type = GL_TEXTURE;
  shaderdata.name = tex->getName();
  shaderdata.data = texInfo;
  shaderdata.component = this;
  _shaderData.push_back(shaderdata);
  // Tex unit is defined by shader
}