Example usage for org.lwjgl.opengl GL30 glGenerateMipmap

List of usage examples for org.lwjgl.opengl GL30 glGenerateMipmap

Introduction

In this page you can find the example usage for org.lwjgl.opengl GL30 glGenerateMipmap.

Prototype

public static void glGenerateMipmap(@NativeType("GLenum") int target) 

Source Link

Document

Generate mipmaps for a specified texture target.

Usage

From source file:se.angergard.engine.graphics.Texture.java

License:Apache License

private void loadTexture(ByteBuffer buffer, int textureID, int width, int height) {
    GL13.glActiveTexture(GL13.GL_TEXTURE0);
    GL11.glBindTexture(GL11.GL_TEXTURE_2D, textureID);

    GL11.glPixelStorei(GL11.GL_UNPACK_ALIGNMENT, 1);

    GL11.glTexImage2D(GL11.GL_TEXTURE_2D, 0, GL11.GL_RGBA, width, height, 0, GL11.GL_RGBA,
            GL11.GL_UNSIGNED_BYTE, buffer);

    // Not all computer will support this, fix //TODO
    GL30.glGenerateMipmap(GL11.GL_TEXTURE_2D);

    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.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_LINEAR_MIPMAP_LINEAR);
}

From source file:tk.ivybits.engine.gl.GL.java

License:Open Source License

public static void glGenerateMipmap(int a) {
    GL30.glGenerateMipmap(a);
}

From source file:wrath.client.graphics.Texture.java

License:Open Source License

/**
 * Constructor./* w w w .j a va2  s  . c  o m*/
 * @param textureFile The image {@link java.io.File} to load the texture from.
 */
protected Texture(File textureFile) {
    this.file = textureFile;
    this.texID = ClientUtils.getTexture(ClientUtils.loadImageFromFile(textureFile));
    Game.getCurrentInstance().getLogger()
            .println("Created texture ID '" + texID + "' from file '" + file.getName() + "'!");
    GL11.glEnable(GL11.GL_TEXTURE_2D);
    GL11.glBindTexture(GL11.GL_TEXTURE_2D, texID);
    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);
    if (Game.getCurrentInstance().getConfig().getBoolean("TexureMipmapping", true))
        GL30.glGenerateMipmap(GL11.GL_TEXTURE_2D);
    if (Game.getCurrentInstance().getConfig().getBoolean("AntiAliasingTexture", true)) {
        if (Game.getCurrentInstance().getConfig().getBoolean("TexureMipmapping", true)) {
            GL11.glTexParameteri(GL11.GL_TEXTURE_2D, GL11.GL_TEXTURE_MAG_FILTER, GL11.GL_LINEAR_MIPMAP_LINEAR);
            GL11.glTexParameteri(GL11.GL_TEXTURE_2D, GL11.GL_TEXTURE_MIN_FILTER, GL11.GL_LINEAR);
        } 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_NEAREST);
        }

    }
    Texture.unbindTextures();
    afterConstructor();
}

From source file:wrath.client.graphics.Texture.java

License:Open Source License

@Override
public void reload() {
    this.texID = ClientUtils.getTexture(ClientUtils.loadImageFromFile(file));
    GL11.glEnable(GL11.GL_TEXTURE_2D);/*from w w w  .j a  v  a  2  s  . com*/
    GL11.glBindTexture(GL11.GL_TEXTURE_2D, texID);
    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);
    if (Game.getCurrentInstance().getConfig().getBoolean("TexureMipmapping", true))
        GL30.glGenerateMipmap(GL11.GL_TEXTURE_2D);
    if (Game.getCurrentInstance().getConfig().getBoolean("AntiAliasingTexture", true)) {
        if (Game.getCurrentInstance().getConfig().getBoolean("TexureMipmapping", true)) {
            GL11.glTexParameteri(GL11.GL_TEXTURE_2D, GL11.GL_TEXTURE_MAG_FILTER, GL11.GL_LINEAR_MIPMAP_LINEAR);
            GL11.glTexParameteri(GL11.GL_TEXTURE_2D, GL11.GL_TEXTURE_MIN_FILTER, GL11.GL_LINEAR);
        } 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_NEAREST);
        }

    }
    Texture.unbindTextures();
    Game.getCurrentInstance().getLogger()
            .println("Created texture ID '" + texID + "' from file '" + file.getName() + "'!");
}