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:net.minecraft.src.PaintWorld.java

License:Open Source License

public void getTextureForFace(int face) {
    PaintFace pface = renderBlock.paintedFaces[face];
    if (textureBuffer == null) {
        textureBuffer = ByteBuffer.allocateDirect(ARRAY_SIZE);
        textureBuffer.order(ByteOrder.nativeOrder());
    }/*w  ww.j  a v a 2s.  c o m*/
    if (textureId <= 0) {
        textureId = GL11.glGenTextures();
        GL11.glBindTexture(GL11.GL_TEXTURE_2D, textureId);
        GL11.glTexParameteri(GL11.GL_TEXTURE_2D, GL11.GL_TEXTURE_MIN_FILTER, GL11.GL_NEAREST);
        GL11.glTexParameteri(GL11.GL_TEXTURE_2D, GL11.GL_TEXTURE_MAG_FILTER, GL11.GL_NEAREST);
    }
    GL11.glBindTexture(GL11.GL_TEXTURE_2D, textureId);
    textureBuffer.clear();
    textureBuffer.put(pface.points);
    textureBuffer.flip();
    GL11.glTexImage2D(GL11.GL_TEXTURE_2D, 0, GL11.GL_RGBA, ROW, ROW, 0, GL11.GL_RGBA, GL11.GL_BYTE,
            textureBuffer);
}

From source file:net.smert.frameworkgl.opengl.helpers.TextureHelper.java

License:Apache License

public void setClamping(int wrapR, int wrapS, int wrapT) {
    GL11.glTexParameteri(textureTarget, GL12.GL_TEXTURE_WRAP_R, wrapR);
    GL11.glTexParameteri(textureTarget, GL11.GL_TEXTURE_WRAP_S, wrapS);
    GL11.glTexParameteri(textureTarget, GL11.GL_TEXTURE_WRAP_T, wrapT);
}

From source file:net.smert.frameworkgl.opengl.helpers.TextureHelper.java

License:Apache License

public void setCompareFunction(int compareFunc) {
    GL11.glTexParameteri(textureTarget, GL14.GL_TEXTURE_COMPARE_FUNC, compareFunc);
}

From source file:net.smert.frameworkgl.opengl.helpers.TextureHelper.java

License:Apache License

public void setCompareMode(int compareMode) {
    GL11.glTexParameteri(textureTarget, GL14.GL_TEXTURE_COMPARE_MODE, compareMode);
}

From source file:net.smert.frameworkgl.opengl.helpers.TextureHelper.java

License:Apache License

public void setFilters(int magFilter, int minFilter) {
    GL11.glTexParameteri(textureTarget, GL11.GL_TEXTURE_MAG_FILTER, magFilter);
    GL11.glTexParameteri(textureTarget, GL11.GL_TEXTURE_MIN_FILTER, minFilter);
}

From source file:nintendofan9797.core.textureengine.codechicken.render.TextureUtils.java

public static void prepareTexture(int target, int texture, int min_mag_filter, int wrap) {
    GL11.glBindTexture(target, texture);
    engine().resetBoundTexture();/*from w  w w.jav  a 2 s .  c  o  m*/
    GL11.glTexParameteri(target, GL11.GL_TEXTURE_MIN_FILTER, min_mag_filter);
    GL11.glTexParameteri(target, GL11.GL_TEXTURE_MAG_FILTER, min_mag_filter);
    switch (target) {
    case GL12.GL_TEXTURE_3D:
        GL11.glTexParameteri(target, GL12.GL_TEXTURE_WRAP_R, wrap);
    case GL11.GL_TEXTURE_2D:
        GL11.glTexParameteri(target, GL11.GL_TEXTURE_WRAP_T, wrap);
    case GL11.GL_TEXTURE_1D:
        GL11.glTexParameteri(target, GL11.GL_TEXTURE_WRAP_S, wrap);
    }
}

From source file:okkapel.kkplglutil.util.TextureLoader.java

License:Open Source License

public static Texture loadTexture(File imgFile, boolean pixelated) // Needs rewriting
{
    String fullFilePath = null;//  ww w.  j av a  2  s .  c o  m
    try {
        fullFilePath = imgFile.getAbsolutePath();

        // The image
        BufferedImage image = ImageIO.read(imgFile);

        // The image pixel data
        int[] pixels = new int[image.getWidth() * image.getHeight() * 4];

        // Write the pixel data into the array
        image.getRGB(0, 0, image.getWidth(), image.getHeight(), pixels, 0, image.getWidth());

        // Create a byte buffer for pixel data
        ByteBuffer pixelBuffer = BufferUtils.createByteBuffer(image.getWidth() * image.getHeight() * 4);

        // Put pixel data into the buffer
        for (int y = 0; y < image.getHeight(); y++) {
            for (int x = 0; x < image.getWidth(); x++) {
                // Get the pixel from the array
                int pixel = pixels[y * image.getWidth() + x];

                // Red
                pixelBuffer.put((byte) ((pixel >> 16) & 255));

                // Green
                pixelBuffer.put((byte) ((pixel >> 8) & 255));

                // Blue
                pixelBuffer.put((byte) ((pixel) & 255));

                // Alpha
                pixelBuffer.put((byte) ((pixel >> 24) & 255));
            }
        }

        pixelBuffer.flip();

        int id = GL11.glGenTextures();

        Texture ret = new Texture(id, image.getWidth(), image.getHeight());

        GL11.glBindTexture(GL11.GL_TEXTURE_2D, id);

        //            Engine.out.debug(id);

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

        if (pixelated) {
            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);
        }

        GL11.glBindTexture(GL11.GL_TEXTURE_2D, 0);

        return ret;
    } catch (IOException e) {
        e.printStackTrace();
        System.err.println("Failed to load texture from file: " + fullFilePath);
    }

    return null; // TODO: return missing texture
}

From source file:opengl.test.object.CaroTable.java

@Override
protected void initVertex() {
    GL30.glBindVertexArray(vao);//bind vao  

    // position        color       texCoord

    float[] data = new float[] { -0.5f, -0.5f, 0f, 1f, 1f, 1f, 0f, 0f, 0.5f, -0.5f, 0f, 1f, 1f, 1f, 1f, 0f,
            -0.5f, 0.5f, 0f, 1f, 1f, 1f, 0f, 1f, 0.5f, 0.5f, 0f, 1f, 1f, 1f, 1f, 1f };

    dataBuffer = BufferUtils.createFloatBuffer(data.length);
    dataBuffer.put(data);/*from  w  ww . j a  va2s .c  om*/
    dataBuffer.flip();
    Logger.getGlobal().log(Level.SEVERE, "FloatBuffer capacity  : " + dataBuffer.capacity());

    this.vbo = GL15.glGenBuffers();
    GL15.glBindBuffer(GL15.GL_ARRAY_BUFFER, this.vbo);
    GL15.glBufferData(GL15.GL_ARRAY_BUFFER, dataBuffer, GL15.GL_STATIC_DRAW);

    this.VertexAttribPointer();

    int[] indices = { 0, 1, 2, 2, 1, 3 };
    IntBuffer indicesBuffer = BufferUtils.createIntBuffer(indices.length);
    indicesBuffer.put(indices);
    indicesBuffer.flip();
    this.ebo = GL15.glGenBuffers();
    GL15.glBindBuffer(GL15.GL_ELEMENT_ARRAY_BUFFER, this.ebo);
    GL15.glBufferData(GL15.GL_ELEMENT_ARRAY_BUFFER, indicesBuffer, GL15.GL_DYNAMIC_DRAW);

    IntBuffer w = BufferUtils.createIntBuffer(1);
    IntBuffer h = BufferUtils.createIntBuffer(1);
    IntBuffer comp = BufferUtils.createIntBuffer(1);
    STBImage.stbi_set_flip_vertically_on_load(1);
    ByteBuffer image = STBImage.stbi_load("resource/3x3grid.png", w, h, comp, 0);

    int weight = w.get(0);
    int height = h.get(0);
    int compe = comp.get(0);

    Logger.getGlobal().log(Level.FINEST,
            "STBImage load status : " + weight + " " + height + " " + compe + " " + image);

    textureID = GL11.glGenTextures();
    GL11.glBindTexture(GL11.GL_TEXTURE_2D, textureID);
    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_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, weight, height, 0, GL11.GL_RGBA,
            GL11.GL_UNSIGNED_BYTE, image);

    GL30.glBindVertexArray(0);//unbind vao
}

From source file:opengl.test.object.cube.wall.java

/**
 * Must be override/*  ww w.  ja  v a 2  s.c o  m*/
 */
@Override
protected void initVertex() {

    GL30.glBindVertexArray(vao);//bind

    IntBuffer w = BufferUtils.createIntBuffer(1);
    IntBuffer h = BufferUtils.createIntBuffer(1);
    IntBuffer comp = BufferUtils.createIntBuffer(1);
    STBImage.stbi_set_flip_vertically_on_load(1);
    ByteBuffer image = STBImage.stbi_load(this.path, w, h, comp, 0);

    int weight = w.get(0);
    int height = h.get(0);
    int compe = comp.get(0);
    //System.out.println(weight+":"+height+":"+this.path);
    float[] data = new float[] { -x, -y, 0f, 1f, 1f, 1f, 0f, 0f, x, -y, 0f, 1f, 1f, 1f,
            (2 * x) * (this.repeatCount), 0f, -x, y, 0f, 1f, 1f, 1f, 0f, (2 * y) * (this.repeatCount), x, y, 0f,
            1f, 1f, 1f, (2 * x) * (this.repeatCount), (2 * y) * (this.repeatCount), };
    dataBuffer = BufferUtils.createFloatBuffer(data.length);
    dataBuffer.put(data);
    dataBuffer.flip();
    Logger.getGlobal().log(Level.SEVERE, "FloatBuffer capacity  : " + dataBuffer.capacity());

    this.vbo = GL15.glGenBuffers();
    GL15.glBindBuffer(GL15.GL_ARRAY_BUFFER, this.vbo);
    GL15.glBufferData(GL15.GL_ARRAY_BUFFER, dataBuffer, GL15.GL_STATIC_DRAW);

    this.VertexAttribPointer();

    int[] indices = { 0, 1, 2, 2, 1, 3, };
    IntBuffer indicesBuffer = BufferUtils.createIntBuffer(indices.length);
    indicesBuffer.put(indices);
    indicesBuffer.flip();
    this.ebo = GL15.glGenBuffers();
    GL15.glBindBuffer(GL15.GL_ELEMENT_ARRAY_BUFFER, this.ebo);
    GL15.glBufferData(GL15.GL_ELEMENT_ARRAY_BUFFER, indicesBuffer, GL15.GL_DYNAMIC_DRAW);

    textureID = GL11.glGenTextures();
    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.glTexParameteri(textureID, GL11.GL_TEXTURE_WRAP_S, GL11.GL_REPEAT);
    GL11.glTexParameteri(textureID, GL11.GL_TEXTURE_WRAP_T, GL11.GL_REPEAT);

    GL11.glTexImage2D(GL11.GL_TEXTURE_2D, 0, GL11.GL_RGBA, weight, height, 0, GL11.GL_RGBA,
            GL11.GL_UNSIGNED_BYTE, image);

    GL30.glBindVertexArray(0);//unbind
}

From source file:opengl.test.object.endgame.endgame.java

@Override
protected void initVertex() {
    GL30.glBindVertexArray(vao);//bind vao  

    Object[] dataInput = objLoad.Wavefront(
            endgame.class.getClassLoader().getResourceAsStream("opengl/test/object/endgame/endgame.obj"), 1.0f,
            1.0f, 1.0f);//from   w w  w  . j  a va 2  s .  c om
    super.dataBuffer = (FloatBuffer) dataInput[0];
    this.size = (int) dataInput[1];

    this.vbo = GL15.glGenBuffers();
    GL15.glBindBuffer(GL15.GL_ARRAY_BUFFER, this.vbo);
    GL15.glBufferData(GL15.GL_ARRAY_BUFFER, super.dataBuffer, GL15.GL_STATIC_DRAW);

    this.VertexAttribPointer();

    IntBuffer w = BufferUtils.createIntBuffer(1);
    IntBuffer h = BufferUtils.createIntBuffer(1);
    IntBuffer comp = BufferUtils.createIntBuffer(1);
    STBImage.stbi_set_flip_vertically_on_load(1);
    ByteBuffer image = STBImage.stbi_load("resource/win.png", w, h, comp, 0);

    textureIDWIN = GL11.glGenTextures();
    GL11.glBindTexture(GL11.GL_TEXTURE_2D, textureIDWIN);
    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_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, w.get(0), h.get(0), 0, GL11.GL_RGBA,
            GL11.GL_UNSIGNED_BYTE, image);

    image = STBImage.stbi_load("resource/lose.png", w, h, comp, 0);

    textureIDLOSE = GL11.glGenTextures();
    GL11.glBindTexture(GL11.GL_TEXTURE_2D, textureIDLOSE);
    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_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, w.get(0), h.get(0), 0, GL11.GL_RGBA,
            GL11.GL_UNSIGNED_BYTE, image);

    image = STBImage.stbi_load("resource/draw.png", w, h, comp, 0);

    textureIDDRAW = GL11.glGenTextures();
    GL11.glBindTexture(GL11.GL_TEXTURE_2D, textureIDDRAW);
    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_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, w.get(0), h.get(0), 0, GL11.GL_RGBA,
            GL11.GL_UNSIGNED_BYTE, image);

    GL30.glBindVertexArray(0);//unbind vao
}