Java 类org.lwjgl.opengl.EXTTextureFilterAnisotropic 实例源码

项目:Mystic-Bastion    文件:Loader.java   
public int loadTexture(String fileName) {
    Texture texture = null;
    try {
        texture = TextureLoader.getTexture("PNG",
                new FileInputStream(MainGameLoop.fileManager.getTextureFile(fileName)));
        GL30.glGenerateMipmap(GL11.GL_TEXTURE_2D);
        GL11.glTexParameteri(GL11.GL_TEXTURE_2D, GL11.GL_TEXTURE_MIN_FILTER, GL11.GL_LINEAR_MIPMAP_LINEAR);
        GL11.glTexParameterf(GL11.GL_TEXTURE_2D, GL14.GL_TEXTURE_LOD_BIAS, 0);
        if (GLContext.getCapabilities().GL_EXT_texture_filter_anisotropic) {
            float amount = Math.min(4f,
                    GL11.glGetFloat(EXTTextureFilterAnisotropic.GL_MAX_TEXTURE_MAX_ANISOTROPY_EXT));
            GL11.glTexParameterf(GL11.GL_TEXTURE_2D, EXTTextureFilterAnisotropic.GL_TEXTURE_MAX_ANISOTROPY_EXT,
                    amount);
        } else {
            System.out.println("Filter Anisotropic Not Supported");
        }
    } catch (Exception e) {
        e.printStackTrace();
        System.err.println("Tried to load texture " + fileName + ".png , didn't work");
        System.exit(-1);
    }
    textures.add(texture.getTextureID());
    return texture.getTextureID();
}
项目:OpenGL-Animation    文件:TextureUtils.java   
protected static int loadTextureToOpenGL(TextureData data, TextureBuilder builder) {
    int texID = GL11.glGenTextures();
    GL13.glActiveTexture(GL13.GL_TEXTURE0);
    GL11.glBindTexture(GL11.GL_TEXTURE_2D, texID);
    GL11.glPixelStorei(GL11.GL_UNPACK_ALIGNMENT, 1);
    GL11.glTexImage2D(GL11.GL_TEXTURE_2D, 0, GL11.GL_RGBA, data.getWidth(), data.getHeight(), 0, GL12.GL_BGRA,
            GL11.GL_UNSIGNED_BYTE, data.getBuffer());
    if (builder.isMipmap()) {
        GL30.glGenerateMipmap(GL11.GL_TEXTURE_2D);
        GL11.glTexParameteri(GL11.GL_TEXTURE_2D, GL11.GL_TEXTURE_MAG_FILTER, GL11.GL_LINEAR);
        GL11.glTexParameteri(GL11.GL_TEXTURE_2D, GL11.GL_TEXTURE_MIN_FILTER, GL11.GL_LINEAR_MIPMAP_LINEAR);
        if (builder.isAnisotropic() && GLContext.getCapabilities().GL_EXT_texture_filter_anisotropic) {
            GL11.glTexParameterf(GL11.GL_TEXTURE_2D, GL14.GL_TEXTURE_LOD_BIAS, 0);
            GL11.glTexParameterf(GL11.GL_TEXTURE_2D, EXTTextureFilterAnisotropic.GL_TEXTURE_MAX_ANISOTROPY_EXT,
                    4.0f);
        }
    } else if (builder.isNearest()) {
        GL11.glTexParameteri(GL11.GL_TEXTURE_2D, GL11.GL_TEXTURE_MAG_FILTER, GL11.GL_NEAREST);
        GL11.glTexParameteri(GL11.GL_TEXTURE_2D, GL11.GL_TEXTURE_MIN_FILTER, GL11.GL_NEAREST);
    } else {
        GL11.glTexParameteri(GL11.GL_TEXTURE_2D, GL11.GL_TEXTURE_MAG_FILTER, GL11.GL_LINEAR);
        GL11.glTexParameteri(GL11.GL_TEXTURE_2D, GL11.GL_TEXTURE_MIN_FILTER, GL11.GL_LINEAR);
    }
    if (builder.isClampEdges()) {
        GL11.glTexParameteri(GL11.GL_TEXTURE_2D, GL11.GL_TEXTURE_WRAP_S, GL12.GL_CLAMP_TO_EDGE);
        GL11.glTexParameteri(GL11.GL_TEXTURE_2D, GL11.GL_TEXTURE_WRAP_T, GL12.GL_CLAMP_TO_EDGE);
    } else {
        GL11.glTexParameteri(GL11.GL_TEXTURE_2D, GL11.GL_TEXTURE_WRAP_S, GL11.GL_REPEAT);
        GL11.glTexParameteri(GL11.GL_TEXTURE_2D, GL11.GL_TEXTURE_WRAP_T, GL11.GL_REPEAT);
    }
    GL11.glBindTexture(GL11.GL_TEXTURE_2D, 0);
    return texID;
}
项目:OcclusionQueries    文件:TextureUtils.java   
protected static int loadTextureToOpenGL(TextureData data, TextureBuilder builder) {
    int texID = GL11.glGenTextures();
    GL13.glActiveTexture(GL13.GL_TEXTURE0);
    GL11.glBindTexture(GL11.GL_TEXTURE_2D, texID);
    GL11.glPixelStorei(GL11.GL_UNPACK_ALIGNMENT, 1);
    GL11.glTexImage2D(GL11.GL_TEXTURE_2D, 0, GL11.GL_RGBA, data.getWidth(), data.getHeight(), 0, GL12.GL_BGRA,
            GL11.GL_UNSIGNED_BYTE, data.getBuffer());
    if (builder.isMipmap()) {
        GL30.glGenerateMipmap(GL11.GL_TEXTURE_2D);
        GL11.glTexParameteri(GL11.GL_TEXTURE_2D, GL11.GL_TEXTURE_MAG_FILTER, GL11.GL_LINEAR);
        GL11.glTexParameteri(GL11.GL_TEXTURE_2D, GL11.GL_TEXTURE_MIN_FILTER, GL11.GL_LINEAR_MIPMAP_LINEAR);
        if (builder.isAnisotropic() && GLContext.getCapabilities().GL_EXT_texture_filter_anisotropic) {
            GL11.glTexParameterf(GL11.GL_TEXTURE_2D, GL14.GL_TEXTURE_LOD_BIAS, 0);
            GL11.glTexParameterf(GL11.GL_TEXTURE_2D, EXTTextureFilterAnisotropic.GL_TEXTURE_MAX_ANISOTROPY_EXT,
                    4.0f);
        }
    } else if (builder.isNearest()) {
        GL11.glTexParameteri(GL11.GL_TEXTURE_2D, GL11.GL_TEXTURE_MAG_FILTER, GL11.GL_NEAREST);
        GL11.glTexParameteri(GL11.GL_TEXTURE_2D, GL11.GL_TEXTURE_MIN_FILTER, GL11.GL_NEAREST);
    } else {
        GL11.glTexParameteri(GL11.GL_TEXTURE_2D, GL11.GL_TEXTURE_MAG_FILTER, GL11.GL_LINEAR);
        GL11.glTexParameteri(GL11.GL_TEXTURE_2D, GL11.GL_TEXTURE_MIN_FILTER, GL11.GL_LINEAR);
    }
    if (builder.isClampEdges()) {
        GL11.glTexParameteri(GL11.GL_TEXTURE_2D, GL11.GL_TEXTURE_WRAP_S, GL12.GL_CLAMP_TO_EDGE);
        GL11.glTexParameteri(GL11.GL_TEXTURE_2D, GL11.GL_TEXTURE_WRAP_T, GL12.GL_CLAMP_TO_EDGE);
    } else {
        GL11.glTexParameteri(GL11.GL_TEXTURE_2D, GL11.GL_TEXTURE_WRAP_S, GL11.GL_REPEAT);
        GL11.glTexParameteri(GL11.GL_TEXTURE_2D, GL11.GL_TEXTURE_WRAP_T, GL11.GL_REPEAT);
    }
    GL11.glBindTexture(GL11.GL_TEXTURE_2D, 0);
    return texID;
}
项目:JavaGraphicsEngine    文件:ImageLoader.java   
/**
 * Loads buffered image to graphics card
 * 
 * @param bImage        Buffered image describing the image
 * @return              Integer describing the image's location on the GPU
 */ 
protected int loadTexture(BufferedImage bImage) {
    LuminosImage image = LuminosImage.loadImage(bImage, Format.RGBA);

    int textureID = glGenTextures();

    glGenerateMipmap(GL_TEXTURE_2D);
    glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR_MIPMAP_LINEAR);
    glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_LOD_BIAS, -0.6f);

    if(getCapabilities().GL_EXT_texture_filter_anisotropic) {
        float amount = Math.min(4f, glGetFloat(EXTTextureFilterAnisotropic.GL_MAX_TEXTURE_MAX_ANISOTROPY_EXT));
        glTexParameterf(GL_TEXTURE_2D, EXTTextureFilterAnisotropic.GL_TEXTURE_MAX_ANISOTROPY_EXT, amount);
    }

    glBindTexture(GL_TEXTURE_2D, textureID);

    glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL12.GL_CLAMP_TO_EDGE);
    glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL12.GL_CLAMP_TO_EDGE);


    glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST);
    glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST);

    glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA8, image.getWidth(), image.getHeight(), 0, GL_RGBA, GL_UNSIGNED_BYTE, image.getBuffer());

    Loader.textures.add(textureID);
    return textureID;
}
项目:JavaGraphicsEngine    文件:ImageLoader.java   
/**
 * Loads a PNG File to the graphics card
 * 
 * @param fileName      Location of the PNG file
 * @return              Integer describing the location of the image on the GPU
 * @throws IOException  Exception for if file isn't found or cannot be handled
 */
protected int loadTexture(String fileName) throws Exception {
    LuminosImage image = LuminosImage.loadImage(fileName, Format.RGBA);

    int textureID = glGenTextures();

    glGenerateMipmap(GL_TEXTURE_2D);
    glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR_MIPMAP_LINEAR);
    glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_MIN_LOD, -50.f);
    glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_MAX_LOD, 5.0f);
    glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_LOD_BIAS, -.6f);

    if(getCapabilities().GL_EXT_texture_filter_anisotropic) {
        float amount = Math.min(4f, glGetFloat(EXTTextureFilterAnisotropic.GL_MAX_TEXTURE_MAX_ANISOTROPY_EXT));
        glTexParameterf(GL_TEXTURE_2D, EXTTextureFilterAnisotropic.GL_TEXTURE_MAX_ANISOTROPY_EXT, amount);
    }

    glBindTexture(GL_TEXTURE_2D, textureID);

    glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_REPEAT);
    glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_REPEAT);


    glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST);
    glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST);

    glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA8, image.getWidth(), image.getHeight(), 0, GL_RGBA, GL_UNSIGNED_BYTE, image.getBuffer());

    Loader.textures.add(textureID);
    return textureID;
}
项目:sandbox    文件:Loader.java   
public int loadTexture(boolean root, String directory, String file, float bias) {
    Texture texture = null;
    if (!file.toLowerCase().endsWith(".png")) file += ".png";
    try {
        String path = directory + "/" + file;
        if (!root) path = "assets/" + path;
        texture = TextureLoader.getTexture("PNG", net.gogo98901.util.Loader.getResourceAsStream(path));
        GL30.glGenerateMipmap(GL11.GL_TEXTURE_2D);
        GL11.glTexParameteri(GL11.GL_TEXTURE_2D, GL11.GL_TEXTURE_MIN_FILTER, GL11.GL_LINEAR_MIPMAP_LINEAR);
        GL11.glTexParameterf(GL11.GL_TEXTURE_2D, GL14.GL_TEXTURE_LOD_BIAS, bias);
        GL11.glTexParameteri(GL11.GL_TEXTURE_2D, GL11.GL_TEXTURE_MAG_FILTER, GL11.GL_LINEAR);
        GL11.glTexParameteri(GL11.GL_TEXTURE_2D, GL11.GL_TEXTURE_WRAP_S, GL11.GL_REPEAT);
        GL11.glTexParameteri(GL11.GL_TEXTURE_2D, GL11.GL_TEXTURE_WRAP_T, GL11.GL_REPEAT);
        if (directory != "fonts") {
            if (GLContext.getCapabilities().GL_EXT_texture_filter_anisotropic) {
                if (Config.anisotropic.get()) {
                    GL11.glTexParameterf(GL11.GL_TEXTURE_2D, GL14.GL_TEXTURE_LOD_BIAS, 0F);

                    float amount = Math.min(4F, GL11.glGetFloat(EXTTextureFilterAnisotropic.GL_MAX_TEXTURE_MAX_ANISOTROPY_EXT));
                    GL11.glTexParameterf(GL11.GL_TEXTURE_2D, EXTTextureFilterAnisotropic.GL_TEXTURE_MAX_ANISOTROPY_EXT, amount);
                } else {
                    Log.info("GL: Anisotropic filtering disabled by config");
                }
            } else {
                Log.warn("GL: Anisotropic filtering not supported");
            }
        }
    } catch (IOException e) {
        Log.warn("Could not read texture '" + file + "'");
        Log.stackTrace(e);
    }
    textures.add(texture.getTextureID());
    return texture.getTextureID();
}
项目:OpenGL-Worlds    文件:WorldRenderer.java   
private static int loadTexture(String texName) {
    try(InputStream in = Resources.getInputStream("textures/" + texName)) {
        PNGDecoder decoder = new PNGDecoder(in);

        int width = decoder.getWidth();
        int height = decoder.getHeight();

        ByteBuffer data = BufferUtils.createByteBuffer(width * height * 4);
        decoder.decode(data, width * 4, Format.RGBA);
        data.flip();

        int tex = glGenTextures();
        glBindTexture(GL_TEXTURE_2D, tex);
        glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE);
        glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE);
        glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
        glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR_MIPMAP_LINEAR);
        glTexParameteri(GL_TEXTURE_2D, EXTTextureFilterAnisotropic.GL_TEXTURE_MAX_ANISOTROPY_EXT, glGetInteger(EXTTextureFilterAnisotropic.GL_MAX_TEXTURE_MAX_ANISOTROPY_EXT));
        glTexImage2D(GL_TEXTURE_2D, 0, GL_RGB8, width, height, 0, GL_RGBA, GL_UNSIGNED_BYTE, data);
        glGenerateMipmap(GL_TEXTURE_2D);
        glBindTexture(GL_TEXTURE_2D, 0);

        return tex;
    }
    catch(Exception exc) {
        throw new RuntimeException("Failed to load " + texName, exc);
    }
}
项目:warp    文件:Texture.java   
public void enableAnisotropy(int level) {
    if (isAnisotropySupported())
        glTexParameteri(type, EXTTextureFilterAnisotropic.GL_TEXTURE_MAX_ANISOTROPY_EXT, level);
    else throw new RuntimeException("Anisotropic filtering is not supported.");
}
项目:warp    文件:Texture.java   
public void disableAnisotropy() {
    if (isAnisotropySupported())
        glTexParameteri(type, EXTTextureFilterAnisotropic.GL_TEXTURE_MAX_ANISOTROPY_EXT, 0);
    else throw new RuntimeException("Anisotropic filtering is not supported.");
}
项目:PhET    文件:LwjglRenderer.java   
@SuppressWarnings("fallthrough")
    private void setupTextureParams(Texture tex) {
        Image image = tex.getImage();
        int target = convertTextureType(tex.getType(), image != null ? image.getMultiSamples() : 1);

        // filter things
        int minFilter = convertMinFilter(tex.getMinFilter());
        int magFilter = convertMagFilter(tex.getMagFilter());
        glTexParameteri(target, GL_TEXTURE_MIN_FILTER, minFilter);
        glTexParameteri(target, GL_TEXTURE_MAG_FILTER, magFilter);

        if (tex.getAnisotropicFilter() > 1) {
            if (GLContext.getCapabilities().GL_EXT_texture_filter_anisotropic) {
                glTexParameterf(target,
                        EXTTextureFilterAnisotropic.GL_TEXTURE_MAX_ANISOTROPY_EXT,
                        tex.getAnisotropicFilter());
            }
        }

        if (context.pointSprite) {
            return; // Attempt to fix glTexParameter crash for some ATI GPUs
        }
        // repeat modes
        switch (tex.getType()) {
            case ThreeDimensional:
            case CubeMap: // cubemaps use 3D coords
                glTexParameteri(target, GL_TEXTURE_WRAP_R, convertWrapMode(tex.getWrap(WrapAxis.R)));
            case TwoDimensional:
            case TwoDimensionalArray:
                glTexParameteri(target, GL_TEXTURE_WRAP_T, convertWrapMode(tex.getWrap(WrapAxis.T)));
                // fall down here is intentional..
//            case OneDimensional:
                glTexParameteri(target, GL_TEXTURE_WRAP_S, convertWrapMode(tex.getWrap(WrapAxis.S)));
                break;
            default:
                throw new UnsupportedOperationException("Unknown texture type: " + tex.getType());
        }

        // R to Texture compare mode
        if (tex.getShadowCompareMode() != Texture.ShadowCompareMode.Off) {
            glTexParameteri(target, GL_TEXTURE_COMPARE_MODE, GL_COMPARE_R_TO_TEXTURE);
            glTexParameteri(target, GL_DEPTH_TEXTURE_MODE, GL_INTENSITY);
            if (tex.getShadowCompareMode() == Texture.ShadowCompareMode.GreaterOrEqual) {
                glTexParameteri(target, GL_TEXTURE_COMPARE_FUNC, GL_GEQUAL);
            } else {
                glTexParameteri(target, GL_TEXTURE_COMPARE_FUNC, GL_LEQUAL);
            }
        }
    }
项目:CR    文件:Texture.java   
private int loadTexture(String name){
    int[] pixels = new int[width*height];

    img.getRGB(0, 0, width, height, pixels, 0, width);

    ByteBuffer buffer = BufferUtils.createByteBuffer(width*height*4);
    boolean hasAlpha = img.getColorModel().hasAlpha();

    //loop through all the pixels and extract the red, green, blue and alpha components
    //and put them in the buffer which will then be sent to the gpu
    for(int y = 0; y < height; y++)
        for(int x = 0; x < width; x++){
            int pixelData = pixels[x + (y*width)];
            buffer.put((byte) ((pixelData >> 16) & 0xFF));  //RED Component
            buffer.put((byte) ((pixelData >> 8) & 0xFF));   //GREEN Component
            buffer.put((byte) (pixelData & 0xFF));          //BLUE Component
            if(hasAlpha)
                buffer.put((byte) ((pixelData >> 24) & 0xFF)); //ALPHA Component
            else buffer.put((byte) 0xFF);
        }

    buffer.flip();

    int id = glGenTextures();

    glBindTexture(GL_TEXTURE_2D, id);

    glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE);
    glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE);

    glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST);
    glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST);

    GL11.glTexParameteri(GL11.GL_TEXTURE_2D, EXTTextureFilterAnisotropic.GL_TEXTURE_MAX_ANISOTROPY_EXT, 16);

    //send the texture data to the gpu
    glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA8, width, height, 0, GL_RGBA, GL_UNSIGNED_BYTE, buffer);

    buffer = null;


    glBindTexture(GL_TEXTURE_2D, 0);

    return id;
}
项目:cuina    文件:TextureLoader.java   
/**
    * Ladet eine Textur zum angegebenen BufferedImage.
    * @param bufferedImage Image mit den Bildinformationen.
    * @return die geladene Textur.
    */
private Texture getTexture(BufferedImage bufferedImage, int flags)
{
    int textureID =  glGenTextures();
    int srcWidth = bufferedImage.getWidth();
    int srcHeight = bufferedImage.getHeight();
    boolean alpha = bufferedImage.getColorModel().hasAlpha();
    ColorSpace colorSpace = bufferedImage.getColorModel().getColorSpace();
    switch(colorSpace.getType())
    {
        case ColorSpace.TYPE_RGB: break;
        default: throw new IllegalArgumentException("unsupported color-format: " + getColorFormat(colorSpace));
    }
    int colorFormat = alpha ? GL_RGBA : GL_RGB;

    Texture texture = new Texture(GL_TEXTURE_2D, textureID, srcWidth, srcHeight);

    byte[] data = ((DataBufferByte) bufferedImage.getRaster().getDataBuffer()).getData();
    convertColorFormat(data, alpha);

    ByteBuffer buffer = ByteBuffer.allocateDirect(data.length);
    buffer.order(ByteOrder.nativeOrder());
    buffer.put(data, 0, data.length);
    buffer.flip();

    GLCache.bindTexture(texture);
    glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR);
    glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);

    if ((flags & ANIOTROPIC) != 0)
    {
        // Due to LWJGL buffer check, you can't use smaller sized buffers (min_size = 16 for glGetFloat()).
        FloatBuffer max_a = BufferUtils.createFloatBuffer(16);
        // Grab the maximum anisotropic filter.
        GL11.glGetFloat(EXTTextureFilterAnisotropic.GL_MAX_TEXTURE_MAX_ANISOTROPY_EXT, max_a);
        System.out.println(max_a.get(0));
        // Set up the anisotropic filter.
        GL11.glTexParameterf(GL11.GL_TEXTURE_2D, EXTTextureFilterAnisotropic.GL_TEXTURE_MAX_ANISOTROPY_EXT,
                max_a.get(0));
    }

    if (texture.getWidth() != srcWidth || texture.getHeight() != srcHeight)
    {
        GL11.glTexImage2D(GL_TEXTURE_2D, 0, colorFormat,
                texture.getWidth(), texture.getHeight(), 0, colorFormat,
                GL_UNSIGNED_BYTE, (ByteBuffer) null);
        GL11.glTexSubImage2D(GL_TEXTURE_2D, 0, 0, 0,
                srcWidth, srcHeight, colorFormat, GL_UNSIGNED_BYTE, buffer);
    }
    else
    {
        GL11.glTexImage2D(GL_TEXTURE_2D, 0, colorFormat,
                texture.getWidth(), texture.getHeight(), 0, colorFormat,
                GL_UNSIGNED_BYTE, buffer);
    }
    Util.checkGLError();

    return texture;
}
项目:MikuMikuStudio    文件:LwjglRenderer.java   
@SuppressWarnings("fallthrough")
    private void setupTextureParams(Texture tex) {
        Image image = tex.getImage();
        int target = convertTextureType(tex.getType(), image != null ? image.getMultiSamples() : 1);

        // filter things
        int minFilter = convertMinFilter(tex.getMinFilter());
        int magFilter = convertMagFilter(tex.getMagFilter());
        glTexParameteri(target, GL_TEXTURE_MIN_FILTER, minFilter);
        glTexParameteri(target, GL_TEXTURE_MAG_FILTER, magFilter);

        if (tex.getAnisotropicFilter() > 1) {
            if (GLContext.getCapabilities().GL_EXT_texture_filter_anisotropic) {
                glTexParameterf(target,
                        EXTTextureFilterAnisotropic.GL_TEXTURE_MAX_ANISOTROPY_EXT,
                        tex.getAnisotropicFilter());
            }
        }

        if (context.pointSprite) {
            return; // Attempt to fix glTexParameter crash for some ATI GPUs
        }
        // repeat modes
        switch (tex.getType()) {
            case ThreeDimensional:
            case CubeMap: // cubemaps use 3D coords
                glTexParameteri(target, GL_TEXTURE_WRAP_R, convertWrapMode(tex.getWrap(WrapAxis.R)));
            case TwoDimensional:
            case TwoDimensionalArray:
                glTexParameteri(target, GL_TEXTURE_WRAP_T, convertWrapMode(tex.getWrap(WrapAxis.T)));
                // fall down here is intentional..
//            case OneDimensional:
                glTexParameteri(target, GL_TEXTURE_WRAP_S, convertWrapMode(tex.getWrap(WrapAxis.S)));
                break;
            default:
                throw new UnsupportedOperationException("Unknown texture type: " + tex.getType());
        }

        // R to Texture compare mode
        if (tex.getShadowCompareMode() != Texture.ShadowCompareMode.Off) {
            glTexParameteri(target, GL_TEXTURE_COMPARE_MODE, GL_COMPARE_R_TO_TEXTURE);
            glTexParameteri(target, GL_DEPTH_TEXTURE_MODE, GL_INTENSITY);
            if (tex.getShadowCompareMode() == Texture.ShadowCompareMode.GreaterOrEqual) {
                glTexParameteri(target, GL_TEXTURE_COMPARE_FUNC, GL_GEQUAL);
            } else {
                glTexParameteri(target, GL_TEXTURE_COMPARE_FUNC, GL_LEQUAL);
            }
        }
    }