Example usage for org.lwjgl.opengl GL11 GL_TEXTURE_ENV_MODE

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

Introduction

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

Prototype

int GL_TEXTURE_ENV_MODE

To view the source code for org.lwjgl.opengl GL11 GL_TEXTURE_ENV_MODE.

Click Source Link

Document

TextureEnvParameter

Usage

From source file:org.jogamp.glg2d.impl.gl2.GL2ImageDrawer.java

License:Apache License

@Override
protected void begin(Texture texture, AffineTransform xform, Color bgcolor) {
    GL11.glTexEnvi(GL11.GL_TEXTURE_ENV, GL11.GL_TEXTURE_ENV_MODE, GL11.GL_MODULATE);
    GL11.glTexParameterf(GL11.GL_TEXTURE_ENV, GL11.GL_TEXTURE_ENV_MODE, GL11.GL_BLEND);

    /*/*from ww  w. ja  va2  s .c om*/
     * FIXME This is unexpected since we never disable blending, but in some
     * cases it interacts poorly with multiple split panes, scroll panes and the
     * text renderer to disable blending.
     */
    g2d.setComposite(g2d.getComposite());

    GL11.glEnable(GL11.GL_TEXTURE_2D);
    texture.bind();

    savedTransform = null;
    if (xform != null && !xform.isIdentity()) {
        savedTransform = g2d.getTransform();
        g2d.transform(xform);
    }

    g2d.getColorHelper().setColorRespectComposite(bgcolor == null ? Color.white : bgcolor);
}

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   ww w.ja v a  2 s. c o  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.spout.engine.resources.ClientTexture.java

License:Open Source License

@Override
public void load() {
    if (textureID != -1) {
        throw new IllegalStateException("Cannot load an already loaded texture!");
    }//w  w  w  . j  a  v  a  2s . c  om

    GL11.glEnable(GL11.GL_TEXTURE_2D);

    textureID = GL11.glGenTextures();
    GL11.glBindTexture(GL11.GL_TEXTURE_2D, textureID);

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

    /*if (((Client) Spout.getEngine()).getRenderMode() != RenderMode.GL30) {
            
       //Use Mipmaps
       GL11.glTexParameteri(GL11.GL_TEXTURE_2D, GL14.GL_GENERATE_MIPMAP, GL11.GL_TRUE);
    }*/

    GL11.glTexParameteri(GL11.GL_TEXTURE_2D, GL12.GL_TEXTURE_BASE_LEVEL, 0);
    GL11.glTexParameteri(GL11.GL_TEXTURE_2D, GL12.GL_TEXTURE_MAX_LEVEL, 0);

    //Bilinear Filter the closest mipmap
    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_MAG_FILTER, GL11.GL_LINEAR);

    //Wrap the texture
    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);

    int width = image.getWidth();
    int height = image.getHeight();

    int[] pixels = new int[width * height];
    image.getRGB(0, 0, width, height, pixels, 0, width);

    ByteBuffer buffer = BufferUtils.createByteBuffer(width * height * 4);
    for (int x = 0; x < width; x++) {
        for (int y = 0; y < height; y++) {
            int pixel = pixels[y * width + x];
            buffer.put((byte) ((pixel >> 16) & 0xFF)); // Red component
            buffer.put((byte) ((pixel >> 8) & 0xFF)); // Green component
            buffer.put((byte) (pixel & 0xFF)); // Blue component
            buffer.put((byte) ((pixel >> 24) & 0xFF)); // Alpha component. Only for RGBA
        }
    }

    buffer.flip();
    //if (((Client) Spout.getEngine()).getRenderMode() == RenderMode.GL30) {
    //   GL30.glGenerateMipmap(textureID);
    //}

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

    //EXTFramebufferObject.glGenerateMipmapEXT(GL11.GL_TEXTURE_2D); //Not sure if this extension is supported on most cards. 
}

From source file:org.voxels.platform.LWJGLOpenGLAdapter.java

License:Open Source License

@Override
public int GL_TEXTURE_ENV_MODE() {
    return GL11.GL_TEXTURE_ENV_MODE;
}

From source file:terminal.gld.TrueTypeFont.java

License:Open Source License

public static int loadImage(BufferedImage bufferedImage) {
    try {//from w  w  w .  java  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;
}