コード例 #1
0
ファイル: texstate.c プロジェクト: karolherbst/mesa
/* GL_ARB_multitexture */
void GLAPIENTRY
_mesa_ActiveTexture(GLenum texture)
{
    const GLuint texUnit = texture - GL_TEXTURE0;
    GLuint k;
    GET_CURRENT_CONTEXT(ctx);

    if (MESA_VERBOSE & (VERBOSE_API|VERBOSE_TEXTURE))
        _mesa_debug(ctx, "glActiveTexture %s\n",
                    _mesa_enum_to_string(texture));

    if (ctx->Texture.CurrentUnit == texUnit)
        return;

    k = _mesa_max_tex_unit(ctx);

    assert(k <= ARRAY_SIZE(ctx->Texture.Unit));

    if (texUnit >= k) {
        _mesa_error(ctx, GL_INVALID_ENUM, "glActiveTexture(texture=%s)",
                    _mesa_enum_to_string(texture));
        return;
    }

    FLUSH_VERTICES(ctx, _NEW_TEXTURE);

    ctx->Texture.CurrentUnit = texUnit;
    if (ctx->Transform.MatrixMode == GL_TEXTURE) {
        /* update current stack pointer */
        ctx->CurrentStack = &ctx->TextureMatrixStack[texUnit];
    }
}
コード例 #2
0
ファイル: texstate.c プロジェクト: ChristophHaag/mesa-mesa
/* GL_ARB_multitexture */
static ALWAYS_INLINE void
active_texture(GLenum texture, bool no_error)
{
   const GLuint texUnit = texture - GL_TEXTURE0;

   GET_CURRENT_CONTEXT(ctx);

   if (MESA_VERBOSE & (VERBOSE_API|VERBOSE_TEXTURE))
      _mesa_debug(ctx, "glActiveTexture %s\n",
                  _mesa_enum_to_string(texture));

   if (ctx->Texture.CurrentUnit == texUnit)
      return;

   if (!no_error) {
      GLuint k = _mesa_max_tex_unit(ctx);

      assert(k <= ARRAY_SIZE(ctx->Texture.Unit));

      if (texUnit >= k) {
         _mesa_error(ctx, GL_INVALID_ENUM, "glActiveTexture(texture=%s)",
                     _mesa_enum_to_string(texture));
         return;
      }
   }


   /* The below flush call seems useless because
    * gl_context::Texture::CurrentUnit is not used by
    * _mesa_update_texture_state() and friends.
    *
    * However removing the flush
    * introduced some blinking textures in UT2004. More investigation is
    * needed to find the root cause.
    *
    * https://bugs.freedesktop.org/show_bug.cgi?id=105436
    */
   FLUSH_VERTICES(ctx, _NEW_TEXTURE_STATE);

   ctx->Texture.CurrentUnit = texUnit;
   if (ctx->Transform.MatrixMode == GL_TEXTURE) {
      /* update current stack pointer */
      ctx->CurrentStack = &ctx->TextureMatrixStack[texUnit];
   }
}