Example usage for org.lwjgl.opengl GL11 glTexParameteri

List of usage examples for org.lwjgl.opengl GL11 glTexParameteri

Introduction

In this page you can find the example usage for org.lwjgl.opengl GL11 glTexParameteri.

Prototype

public static void glTexParameteri(@NativeType("GLenum") int target, @NativeType("GLenum") int pname,
        @NativeType("GLint") int param) 

Source Link

Document

Sets the integer value of a texture parameter, which controls how the texel array is treated when specified or changed, and when applied to a fragment.

Usage

From source file:zildo.fwk.gfx.engine.TextureEngine.java

License:Open Source License

public void generateTexture() {

    // Create A IntBuffer For Image Address In Memory
    IntBuffer buf = ByteBuffer.allocateDirect(4).order(ByteOrder.nativeOrder()).asIntBuffer();
    GL11.glGenTextures(buf); // Create Texture In OpenGL

    GL11.glBindTexture(GL11.GL_TEXTURE_2D, buf.get(0));
    // Typical Texture Generation Using Data From The Image

    int wrapping = GL11.GL_REPEAT; // Wrap texture (useful for cloud)
    GL11.glTexParameteri(GL11.GL_TEXTURE_2D, GL11.GL_TEXTURE_WRAP_S, wrapping);
    GL11.glTexParameteri(GL11.GL_TEXTURE_2D, GL11.GL_TEXTURE_WRAP_T, wrapping);

    int filtering = GL11.GL_NEAREST;
    // Linear Filtering
    GL11.glTexParameteri(GL11.GL_TEXTURE_2D, GL11.GL_TEXTURE_MIN_FILTER, filtering);
    GL11.glTexParameteri(GL11.GL_TEXTURE_2D, GL11.GL_TEXTURE_MAG_FILTER, filtering);
    // Generate The Texture
    GL11.glTexImage2D(GL11.GL_TEXTURE_2D, 0, textureFormat, 256, 256, 0, textureFormat, GL11.GL_UNSIGNED_BYTE,
            scratch);/*from w w  w . java2 s .c o  m*/

    // Reset bytebuffer scratch
    scratch.clear();

    // Store texture id
    textureTab[n_Texture] = buf.get(0);

    // Ready for next one
    n_Texture++;
}

From source file:zildo.fwk.opengl.Utils.java

License:Open Source License

public static int generateTexture(int sizeX, int sizeY) {
    IntBuffer buf = ByteBuffer.allocateDirect(4).order(ByteOrder.nativeOrder()).asIntBuffer();
    GL11.glGenTextures(buf); // Create Texture In OpenGL
    int textureID = buf.get(0);
    GL11.glBindTexture(GL11.GL_TEXTURE_2D, textureID);
    GL11.glTexParameteri(GL11.GL_TEXTURE_2D, GL11.GL_TEXTURE_MIN_FILTER, GL11.GL_LINEAR);
    GL11.glTexParameteri(GL11.GL_TEXTURE_2D, GL11.GL_TEXTURE_MAG_FILTER, GL11.GL_LINEAR);

    GL11.glTexImage2D(GL11.GL_TEXTURE_2D, 0, GL11.GL_RGBA, adjustTexSize(sizeX), adjustTexSize(sizeY), 0,
            GL11.GL_RGBA, GL11.GL_UNSIGNED_BYTE, (ByteBuffer) null);

    return textureID;
}

From source file:zildo.fwk.opengl.Utils.java

License:Open Source License

public static void copyScreenToTexture(int p_texId, int p_sizeX, int p_sizeY) {
    GL11.glBindTexture(GL11.GL_TEXTURE_2D, p_texId);

    GL11.glTexParameteri(GL11.GL_TEXTURE_2D, GL11.GL_TEXTURE_MIN_FILTER, GL11.GL_LINEAR);
    GL11.glTexParameteri(GL11.GL_TEXTURE_2D, GL11.GL_TEXTURE_MAG_FILTER, GL11.GL_LINEAR);

    GL11.glCopyTexImage2D(GL11.GL_TEXTURE_2D, 0, GL11.GL_RGBA, 0, 0, p_sizeX, p_sizeY, 0);
}

From source file:zildo.platform.engine.LwjglTextureEngine.java

License:Open Source License

@Override
public int doGenerateTexture() {
    scratch.position(0);// w ww .  ja v  a2s  . co  m

    // Create A IntBuffer For Image Address In Memory
    IntBuffer buf = ByteBuffer.allocateDirect(4).order(ByteOrder.nativeOrder()).asIntBuffer();
    GL11.glGenTextures(buf); // Create Texture In OpenGL

    GL11.glBindTexture(GL11.GL_TEXTURE_2D, buf.get(0));
    // Typical Texture Generation Using Data From The Image

    int wrapping = GL11.GL_REPEAT; // Wrap texture (useful for cloud)
    GL11.glTexParameteri(GL11.GL_TEXTURE_2D, GL11.GL_TEXTURE_WRAP_S, wrapping);
    GL11.glTexParameteri(GL11.GL_TEXTURE_2D, GL11.GL_TEXTURE_WRAP_T, wrapping);

    int filtering = GL11.GL_NEAREST;
    // Linear Filtering
    GL11.glTexParameteri(GL11.GL_TEXTURE_2D, GL11.GL_TEXTURE_MIN_FILTER, filtering);
    GL11.glTexParameteri(GL11.GL_TEXTURE_2D, GL11.GL_TEXTURE_MAG_FILTER, filtering);
    // Generate The Texture
    GL11.glTexImage2D(GL11.GL_TEXTURE_2D, 0, getTextureFormat(), 256, 256, 0, getTextureFormat(),
            GL11.GL_UNSIGNED_BYTE, scratch);

    return buf.get(0);
}

From source file:zildo.platform.engine.LwjglTextureEngine.java

License:Open Source License

@Override
public int loadTexture(String name) {
    try {/* w w w.  j av a2s . c o  m*/
        Texture tex = TextureLoader.getTexture("PNG",
                new FileInputStream(Constantes.DATA_PATH + "textures/" + name + ".png"));

        int id = tex.getTextureID();

        GL11.glBindTexture(GL11.GL_TEXTURE_2D, id);
        // Typical Texture Generation Using Data From The Image

        int wrapping = GL11.GL_REPEAT; // Wrap texture (useful for cloud)
        GL11.glTexParameteri(GL11.GL_TEXTURE_2D, GL11.GL_TEXTURE_WRAP_S, wrapping);
        GL11.glTexParameteri(GL11.GL_TEXTURE_2D, GL11.GL_TEXTURE_WRAP_T, wrapping);

        int filtering = GL11.GL_NEAREST;
        // Linear Filtering
        GL11.glTexParameteri(GL11.GL_TEXTURE_2D, GL11.GL_TEXTURE_MIN_FILTER, filtering);
        GL11.glTexParameteri(GL11.GL_TEXTURE_2D, GL11.GL_TEXTURE_MAG_FILTER, filtering);

        // Store texture id
        textureTab[n_Texture] = tex.getTextureID();
        alphaTab[n_Texture] = true;

        // Ready for next one
        n_Texture++;

        return tex.getTextureID();
    } catch (Exception e) {
        throw new RuntimeException("Can't load texture " + name, e.getCause());
    }

}

From source file:zildo.platform.opengl.GLUtils.java

License:Open Source License

public static int generateTexture(int sizeX, int sizeY) {
    IntBuffer buf = ByteBuffer.allocateDirect(4).order(ByteOrder.nativeOrder()).asIntBuffer();
    GL11.glGenTextures(buf); // Create Texture In OpenGL
    int textureID = buf.get(0);
    GL11.glBindTexture(GL11.GL_TEXTURE_2D, textureID);
    GL11.glTexParameteri(GL11.GL_TEXTURE_2D, GL11.GL_TEXTURE_MIN_FILTER, GL11.GL_LINEAR);
    GL11.glTexParameteri(GL11.GL_TEXTURE_2D, GL11.GL_TEXTURE_MAG_FILTER, GL11.GL_LINEAR);

    GL11.glTexImage2D(GL11.GL_TEXTURE_2D, 0, GL11.GL_RGBA, ZUtils.adjustTexSize(sizeX),
            ZUtils.adjustTexSize(sizeY), 0, GL11.GL_RGBA, GL11.GL_UNSIGNED_BYTE, (ByteBuffer) null);

    return textureID;
}