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:com.ardor3d.scene.state.lwjgl.LwjglTextureStateUtil.java

License:Open Source License

/**
 * Check if the wrap mode of this particular texture has been changed and apply as needed.
 * /*from  w  w w. ja v  a 2  s .co  m*/
 * @param cubeMap
 *            our texture object
 * @param texRecord
 *            our record of the last state of the unit in gl
 * @param record
 */
public static void applyWrap(final TextureCubeMap cubeMap, final TextureRecord texRecord, final int unit,
        final TextureStateRecord record, final ContextCapabilities caps) {
    if (!caps.isTextureCubeMapSupported()) {
        return;
    }

    final int wrapS = getGLWrap(cubeMap.getWrap(WrapAxis.S), caps);
    final int wrapT = getGLWrap(cubeMap.getWrap(WrapAxis.T), caps);
    final int wrapR = getGLWrap(cubeMap.getWrap(WrapAxis.R), caps);

    if (!texRecord.isValid() || texRecord.wrapS != wrapS) {
        checkAndSetUnit(unit, record, caps);
        GL11.glTexParameteri(ARBTextureCubeMap.GL_TEXTURE_CUBE_MAP_ARB, GL11.GL_TEXTURE_WRAP_S, wrapS);
        texRecord.wrapS = wrapS;
    }
    if (!texRecord.isValid() || texRecord.wrapT != wrapT) {
        checkAndSetUnit(unit, record, caps);
        GL11.glTexParameteri(ARBTextureCubeMap.GL_TEXTURE_CUBE_MAP_ARB, GL11.GL_TEXTURE_WRAP_T, wrapT);
        texRecord.wrapT = wrapT;
    }
    if (!texRecord.isValid() || texRecord.wrapR != wrapR) {
        checkAndSetUnit(unit, record, caps);
        GL11.glTexParameteri(ARBTextureCubeMap.GL_TEXTURE_CUBE_MAP_ARB, GL12.GL_TEXTURE_WRAP_R, wrapR);
        texRecord.wrapR = wrapR;
    }
}

From source file:com.auroraengine.opengl.GLTexture.java

License:Open Source License

@Override
public void update() throws GLException {
    if (tex_ref != 0) {
        GL11.glBindTexture(GL11.GL_TEXTURE_2D, tex_ref);

        GL11.glTexParameteri(GL11.GL_TEXTURE_2D, GL11.GL_TEXTURE_MIN_FILTER, min_filter);
        GL11.glTexParameteri(GL11.GL_TEXTURE_2D, GL11.GL_TEXTURE_MAG_FILTER, mag_filter);

        GL11.glTexParameteri(GL11.GL_TEXTURE_2D, GL11.GL_TEXTURE_WRAP_S, wrap_s);
        GL11.glTexParameteri(GL11.GL_TEXTURE_2D, GL11.GL_TEXTURE_WRAP_T, wrap_t);

        if (image_modified) {
            ByteBuffer bb = ByteBuffer.allocateDirect(4 * img.getWidth() * img.getHeight());
            GL11.glTexImage2D(GL11.GL_TEXTURE_2D, 0, GL12.GL_BGRA, img.getWidth(), img.getHeight(), 0,
                    GL12.GL_BGRA, GL11.GL_UNSIGNED_BYTE, bb);
            // TODO: Redirect images to buffers
        }/*w  ww . ja v a2  s. c  o  m*/
    }
}

From source file:com.badlogic.gdx.backends.jglfw.JglfwGL20.java

License:Apache License

public void glTexParameteri(int target, int pname, int param) {
    GL11.glTexParameteri(target, pname, param);
}

From source file:com.damagedearth.Utilities.Components.TrueTypeFont.java

License:Open Source License

public static int loadImage(BufferedImage bufferedImage) {
    try {/*  w  w w.  j  a v  a  2  s .  co  m*/
        short width = (short) bufferedImage.getWidth();
        short height = (short) bufferedImage.getHeight();
        //textureLoader.bpp = bufferedImage.getColorModel().hasAlpha() ? (byte)32 : (byte)24;
        int bpp = (byte) bufferedImage.getColorModel().getPixelSize();
        ByteBuffer byteBuffer;
        DataBuffer db = bufferedImage.getData().getDataBuffer();
        if (db instanceof DataBufferInt) {
            int intI[] = ((DataBufferInt) (bufferedImage.getData().getDataBuffer())).getData();
            byte newI[] = new byte[intI.length * 4];
            for (int i = 0; i < intI.length; i++) {
                byte b[] = intToByteArray(intI[i]);
                int newIndex = i * 4;

                newI[newIndex] = b[1];
                newI[newIndex + 1] = b[2];
                newI[newIndex + 2] = b[3];
                newI[newIndex + 3] = b[0];
            }

            byteBuffer = ByteBuffer.allocateDirect(width * height * (bpp / 8)).order(ByteOrder.nativeOrder())
                    .put(newI);
        } else {
            byteBuffer = ByteBuffer.allocateDirect(width * height * (bpp / 8)).order(ByteOrder.nativeOrder())
                    .put(((DataBufferByte) (bufferedImage.getData().getDataBuffer())).getData());
        }
        byteBuffer.flip();

        int internalFormat = GL11.GL_RGBA8, format = GL11.GL_RGBA;
        IntBuffer textureId = BufferUtils.createIntBuffer(1);
        ;
        GL11.glGenTextures(textureId);
        GL11.glBindTexture(GL11.GL_TEXTURE_2D, textureId.get(0));

        GL11.glTexParameteri(GL11.GL_TEXTURE_2D, GL11.GL_TEXTURE_WRAP_S, GL11.GL_CLAMP);
        GL11.glTexParameteri(GL11.GL_TEXTURE_2D, GL11.GL_TEXTURE_WRAP_T, GL11.GL_CLAMP);

        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.glTexEnvf(GL11.GL_TEXTURE_ENV, GL11.GL_TEXTURE_ENV_MODE, GL11.GL_MODULATE);

        GLU.gluBuild2DMipmaps(GL11.GL_TEXTURE_2D, internalFormat, width, height, format, GL11.GL_UNSIGNED_BYTE,
                byteBuffer);
        return textureId.get(0);

    } catch (Exception e) {
        e.printStackTrace();
        System.exit(-1);
    }

    return -1;
}

From source file:com.dinasgames.engine.graphics.Texture.java

public boolean create(int width, int height) {

    if (width == 0 && height == 0) {
        return false;
    }//from  w  w  w .java 2 s  .c  o  m

    Vector2i actualSize = new Vector2i(getValidSize(width), getValidSize(height));

    int maxSize = getMaximumSize();
    if ((actualSize.x > maxSize) || (actualSize.y > maxSize)) {
        System.out.println("Failed to create texture, its internal size is too high (" + actualSize.x + ", "
                + actualSize.y + ") maximum is (" + maxSize + ", " + maxSize + ")");
        return false;
    }

    mWidth = width;
    mHeight = height;
    mActualWidth = actualSize.x;
    mActualHeight = actualSize.y;
    mPixelsFlipped = false;

    if (mTexture <= 0) {
        mTexture = GL11.glGenTextures();
    }

    int textureEdgeClamp = GL.clampToEdge();

    GL11.glBindTexture(GL11.GL_TEXTURE_2D, mTexture);
    GL11.glTexImage2D(GL11.GL_TEXTURE_2D, 0, GL11.GL_RGBA, mActualWidth, mActualHeight, 0, GL11.GL_RGBA,
            GL11.GL_UNSIGNED_BYTE, 0);
    GL11.glTexParameteri(GL11.GL_TEXTURE_2D, GL11.GL_TEXTURE_WRAP_S,
            (mRepeated ? GL11.GL_REPEAT : textureEdgeClamp));
    GL11.glTexParameteri(GL11.GL_TEXTURE_2D, GL11.GL_TEXTURE_WRAP_T,
            (mRepeated ? GL11.GL_REPEAT : textureEdgeClamp));
    GL11.glTexParameteri(GL11.GL_TEXTURE_2D, GL11.GL_TEXTURE_MAG_FILTER,
            (mSmooth ? GL11.GL_LINEAR : GL11.GL_NEAREST));
    GL11.glTexParameteri(GL11.GL_TEXTURE_2D, GL11.GL_TEXTURE_MIN_FILTER,
            (mSmooth ? GL11.GL_LINEAR : GL11.GL_NEAREST));
    mCacheId = getUniqueId();

    return true;

}

From source file:com.dinasgames.engine.graphics.Texture.java

public Texture setSmooth(boolean smooth) {

    if (smooth != mSmooth) {

        mSmooth = smooth;/*  www  .  ja v  a  2  s .  c  o m*/

        if (mTexture > 0) {
            GL11.glBindTexture(GL11.GL_TEXTURE_2D, mTexture);
            GL11.glTexParameteri(GL11.GL_TEXTURE_2D, GL11.GL_TEXTURE_MAG_FILTER,
                    (mSmooth ? GL11.GL_LINEAR : GL11.GL_NEAREST));
            GL11.glTexParameteri(GL11.GL_TEXTURE_2D, GL11.GL_TEXTURE_MIN_FILTER,
                    (mSmooth ? GL11.GL_LINEAR : GL11.GL_NEAREST));
        }

    }

    return this;

}

From source file:com.dinasgames.engine.graphics.Texture.java

public Texture setRepeated(boolean repeated) {

    if (mRepeated != repeated) {

        mRepeated = repeated;//from w w  w.  j a va  2 s .c  o m

        if (mTexture > 0) {

            int textureEdgeClamp = GL.clampToEdge();

            GL11.glBindTexture(GL11.GL_TEXTURE_2D, mTexture);
            GL11.glTexParameteri(GL11.GL_TEXTURE_2D, GL11.GL_TEXTURE_WRAP_S,
                    (mRepeated ? GL11.GL_REPEAT : textureEdgeClamp));
            GL11.glTexParameteri(GL11.GL_TEXTURE_2D, GL11.GL_TEXTURE_WRAP_T,
                    (mRepeated ? GL11.GL_REPEAT : textureEdgeClamp));

        }

    }

    return this;

}

From source file:com.dyonovan.tcnodetracker.lib.truetyper.TrueTypeFont.java

License:Open Source License

public static int loadImage(BufferedImage bufferedImage) {
    try {// w w  w . ja  va2 s .c om
        short width = (short) bufferedImage.getWidth();
        short height = (short) bufferedImage.getHeight();
        //textureLoader.bpp = bufferedImage.getColorModel().hasAlpha() ? (byte)32 : (byte)24;
        int bpp = (byte) bufferedImage.getColorModel().getPixelSize();
        ByteBuffer byteBuffer;
        DataBuffer db = bufferedImage.getData().getDataBuffer();
        if (db instanceof DataBufferInt) {
            int intI[] = ((DataBufferInt) (bufferedImage.getData().getDataBuffer())).getData();
            byte newI[] = new byte[intI.length * 4];
            for (int i = 0; i < intI.length; i++) {
                byte b[] = intToByteArray(intI[i]);
                int newIndex = i * 4;

                newI[newIndex] = b[1];
                newI[newIndex + 1] = b[2];
                newI[newIndex + 2] = b[3];
                newI[newIndex + 3] = b[0];
            }

            byteBuffer = ByteBuffer.allocateDirect(width * height * (bpp / 8)).order(ByteOrder.nativeOrder())
                    .put(newI);
        } else {
            byteBuffer = ByteBuffer.allocateDirect(width * height * (bpp / 8)).order(ByteOrder.nativeOrder())
                    .put(((DataBufferByte) (bufferedImage.getData().getDataBuffer())).getData());
        }
        byteBuffer.flip();

        int internalFormat = GL11.GL_RGBA8, format = GL11.GL_RGBA;
        IntBuffer textureId = BufferUtils.createIntBuffer(1);
        ;
        GL11.glGenTextures(textureId);
        GL11.glBindTexture(GL11.GL_TEXTURE_2D, textureId.get(0));

        GL11.glTexParameteri(GL11.GL_TEXTURE_2D, GL11.GL_TEXTURE_WRAP_S, GL11.GL_CLAMP);
        GL11.glTexParameteri(GL11.GL_TEXTURE_2D, GL11.GL_TEXTURE_WRAP_T, GL11.GL_CLAMP);

        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);
        //GL11.glTexParameteri(GL11.GL_TEXTURE_2D, GL11.GL_TEXTURE_MIN_FILTER, GL11.GL_LINEAR);
        //GL11.glTexParameteri(GL11.GL_TEXTURE_2D, GL11.GL_TEXTURE_MIN_FILTER, GL11.GL_LINEAR_MIPMAP_NEAREST);

        //GL11.glTexParameteri(GL11.GL_TEXTURE_2D, GL11.GL_TEXTURE_MIN_FILTER, GL11.GL_LINEAR_MIPMAP_LINEAR);
        //GL11.glTexParameteri(GL11.GL_TEXTURE_2D, GL11.GL_TEXTURE_MIN_FILTER, GL11.GL_NEAREST_MIPMAP_LINEAR);
        //GL11.glTexParameteri(GL11.GL_TEXTURE_2D, GL11.GL_TEXTURE_MIN_FILTER, GL11.GL_NEAREST_MIPMAP_NEAREST);

        GL11.glTexEnvf(GL11.GL_TEXTURE_ENV, GL11.GL_TEXTURE_ENV_MODE, GL11.GL_MODULATE);

        GLU.gluBuild2DMipmaps(GL11.GL_TEXTURE_2D, internalFormat, width, height, format, GL11.GL_UNSIGNED_BYTE,
                byteBuffer);
        return textureId.get(0);

    } catch (Exception e) {
        e.printStackTrace();
        System.exit(-1);
    }

    return -1;
}

From source file:com.enderville.mod.client.gui.mainmenu.MenuBaseEnderVille.java

License:LGPL

/**
 * Renders the skybox in the main menu/*  w  ww  .j av  a2 s  .  c o  m*/
 */
private void renderSkybox(int par1, int par2, float par3) {
    GL11.glViewport(0, 0, 256, 256);
    this.drawPanorama(par1, par2, par3);
    GL11.glDisable(GL11.GL_TEXTURE_2D);
    GL11.glEnable(GL11.GL_TEXTURE_2D);
    this.rotateAndBlurSkybox(par3);
    this.rotateAndBlurSkybox(par3);
    this.rotateAndBlurSkybox(par3);
    this.rotateAndBlurSkybox(par3);
    this.rotateAndBlurSkybox(par3);
    this.rotateAndBlurSkybox(par3);
    this.rotateAndBlurSkybox(par3);
    this.rotateAndBlurSkybox(par3);
    GL11.glViewport(0, 0, this.mc.displayWidth, this.mc.displayHeight);
    Tessellator tessellator = Tessellator.instance;
    tessellator.startDrawingQuads();
    float f1 = this.width > this.height ? 120.0F / (float) this.width : 120.0F / (float) this.height;
    float f2 = (float) this.height * f1 / 256.0F;
    float f3 = (float) this.width * f1 / 256.0F;
    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);
    //        tessellator.setColorRGBA_F(1.0F, 1.0F, 1.0F, 1.0F);
    int k = this.width;
    int l = this.height;
    tessellator.addVertexWithUV(0.0D, (double) l, (double) this.zLevel, (double) (0.5F - f2),
            (double) (0.5F + f3));
    tessellator.addVertexWithUV((double) k, (double) l, (double) this.zLevel, (double) (0.5F - f2),
            (double) (0.5F - f3));
    tessellator.addVertexWithUV((double) k, 0.0D, (double) this.zLevel, (double) (0.5F + f2),
            (double) (0.5F - f3));
    tessellator.addVertexWithUV(0.0D, 0.0D, (double) this.zLevel, (double) (0.5F + f2), (double) (0.5F + f3));
    tessellator.draw();
}

From source file:com.flowpowered.caustic.lwjgl.gl20.GL20Texture.java

License:MIT License

@Override
public void setWraps(WrapMode horizontalWrap, WrapMode verticalWrap) {
    checkCreated();/*from  ww w .  j a  v  a  2s .  c om*/
    if (horizontalWrap == null) {
        throw new IllegalArgumentException("Horizontal wrap cannot be null");
    }
    if (verticalWrap == null) {
        throw new IllegalArgumentException("Vertical wrap cannot be null");
    }
    // Bind the texture
    GL11.glBindTexture(GL11.GL_TEXTURE_2D, id);
    // Set the vertical and horizontal texture wraps
    GL11.glTexParameteri(GL11.GL_TEXTURE_2D, GL11.GL_TEXTURE_WRAP_S, horizontalWrap.getGLConstant());
    GL11.glTexParameteri(GL11.GL_TEXTURE_2D, GL11.GL_TEXTURE_WRAP_T, verticalWrap.getGLConstant());
    // Unbind the texture
    GL11.glBindTexture(GL11.GL_TEXTURE_2D, 0);
    // Check for errors
    LWJGLUtil.checkForGLError();
}