Example usage for org.lwjgl.opengl GL11 glTexEnvf

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

Introduction

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

Prototype

public static native void glTexEnvf(@NativeType("GLenum") int target, @NativeType("GLenum") int pname,
        @NativeType("GLfloat") float param);

Source Link

Document

Float version of #glTexEnvi TexEnvi .

Usage

From source file:org.jtrfp.mtmx.internal.TextureLoader.java

License:Open Source License

@Override
public ITexture load(RawImage rawImage) throws EngineException {
    BufferedImage bufferedImage = null;

    try {//from  w ww .j  a  v  a  2s.co m
        bufferedImage = rawImage.toImage();
    } catch (FileStoreException e) {
        throw new EngineException("Could not convert texture image.", e);
    }

    final int type = GL11.GL_TEXTURE_2D;
    final int width = bufferedImage.getWidth();
    final int height = bufferedImage.getHeight();

    int textureId = createTextureId();
    Texture texture = new Texture(type, textureId, width, height);
    GL11.glBindTexture(type, textureId); // really neccessary here?

    ByteBuffer buffer = makeByteBuffer(bufferedImage, width, height);
    GL11.glTexParameteri(type, GL11.GL_TEXTURE_MIN_FILTER, GL11.GL_LINEAR);
    GL11.glTexParameteri(type, GL11.GL_TEXTURE_MAG_FILTER, GL11.GL_LINEAR);
    GL11.glTexEnvf(GL11.GL_TEXTURE_ENV, GL11.GL_TEXTURE_ENV_MODE, GL11.GL_MODULATE);
    GL11.glTexImage2D(type, 0, GL11.GL_RGB, width, height, 0, GL11.GL_RGB, GL11.GL_UNSIGNED_BYTE, buffer);
    System.out.println("Created texture " + textureId);
    return texture;
}

From source file:org.spoutcraft.client.config.MipMapUtils.java

License:Open Source License

public static void onTick(int texture, float targetFade, float currentFade) {
    GL11.glPushMatrix();/*  www.j  a  va 2  s.  c o  m*/
    SpoutClient.getHandle().renderEngine.bindTexture(texture);

    if (targetFade != currentFade) {
        if (targetFade < currentFade) {
            currentFade -= 0.01f;
            if (currentFade <= targetFade) {
                currentFade = targetFade;
            }
        } else {
            currentFade += 0.01f;
            if (currentFade >= targetFade) {
                currentFade = targetFade;
            }
        }

        if (currentFade <= 0.0f) {
            GL11.glTexParameteri(GL11.GL_TEXTURE_2D, GL11.GL_TEXTURE_MIN_FILTER, GL11.GL_NEAREST);
            GL11.glAlphaFunc(GL11.GL_GREATER, 0.01F); // Default blend state

            updateTerrain = false;
            GL11.glPopMatrix();
            return;
        } else {
            GL11.glTexEnvf(GL14.GL_TEXTURE_FILTER_CONTROL, GL14.GL_TEXTURE_LOD_BIAS,
                    getMipmapLevels(texture) * (currentFade - 1.0f));
        }
    }

    switch (mode) {
    case 1:
        GL30.glGenerateMipmap(GL11.GL_TEXTURE_2D);
        break;
    case 2:
        EXTFramebufferObject.glGenerateMipmapEXT(GL11.GL_TEXTURE_2D);
        break;
    }
    GL11.glAlphaFunc(GL11.GL_GEQUAL, 0.3F); // More strict blend state
    GL11.glPopMatrix();
}

From source file:terminal.gld.TrueTypeFont.java

License:Open Source License

public static int loadImage(BufferedImage bufferedImage) {
    try {//from w w w  .j  ava2  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_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:tk.ivybits.engine.gl.GL.java

License:Open Source License

public static void glTexEnvf(int a, int b, float c) {
    GL11.glTexEnvf(a, b, c);
}