Game Development Community

Bug setOpenGLAnisotropy

by Duncan Gray · in Torque Game Engine · 04/27/2007 (9:32 pm) · 0 replies

The glTexParameterf call in gTexManager.cc returns a value error, if you bother to check it.
The reason appears to be that when used with GL_TEXTURE_MAX_ANISOTROPY_EXT you need to pass a value of 1 or greater, but not zero.

Unfortunately the standard code passes in a value of zero.

There was some noise back in this thread

but it seems nothing came from that.

ConsoleFunction(setOpenGLAnisotropy, void, 2, 2, "setOpenGLAnisotropy(0-1);")
{
   argc;
   F32 val = dAtof(argv[1]);
   if (val < 0.0)
      val = 0.0;
   if (val > dglGetMaxAnisotropy())
      val = dglGetMaxAnisotropy();
   sgTextureAnisotropy = val;

   if(dglDoesSupportTexAnisotropy())
      glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_MAX_ANISOTROPY_EXT, sgTextureAnisotropy *  dglGetMaxAnisotropy());
}

change to


ConsoleFunction(setOpenGLAnisotropy, void, 2, 2, "setOpenGLAnisotropy(0-1);")
{
   argc;
   F32 val = dAtof(argv[1]);
   [b]if (val <= 0.0)
      val = 1.0;[/b]
   if (val > dglGetMaxAnisotropy())
      val = dglGetMaxAnisotropy();
   sgTextureAnisotropy = val;

   if(dglDoesSupportTexAnisotropy())
      glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_MAX_ANISOTROPY_EXT, sgTextureAnisotropy *  dglGetMaxAnisotropy());
}

or do something else, but don't allow sgTextureAnisotropy * dglGetMaxAnisotropy() to be less than 1