Search code examples
c#openglopentk

OpenTK 4: Is this how to set anisotropic filtering?


In migrating to OpenTK4, I don't know if this is the correct way to set my value for anisotropic filtering.

Is it:

float value = 1.0f;  // Dummy value for example

GL.TexParameter(target, (TextureParameterName)0x84FE, value);

Is there an enum defined somewhere I can cast in its place? Instead of a hex code, that is.


Solution

  • Anisotropic filtering is part of the OpenGL 4.6 standard. See OpenGL 4.6 API Core Profile Specification - 8.10 Texture Parameters.
    However, the texture parameter TEXTURE_MAX_ANISOTROPY_ (0x84FE, 34046) is missing in enum TextureParameterName (namespace OpenTK.Graphics.OpenGL4).
    In addition the parameter MAX_TEXTURE_MAX_ANISOTROPY (0x84FF, 34047) is missing in enum GetPName.


    I have created an issue in the OpenTK GitHub repository:
    Texture parameter TEXTURE_MAX_ANISOTROPY is missing #1270

    The issue will be fixed in OpenTK 5. One workaround is to use enum All and cast it to the correct type:

    float maxTextureMaxAnisotropy = GL.GetFloat((GetPName)All.MaxTextureMaxAnisotropy);
    GL.TexParameter(target, (TextureParameterName)All.TextureMaxAnisotropy, maxTextureMaxAnisotropy);