Example usage for org.lwjgl.opengl GL11 GL_TEXTURE_ENV

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

Introduction

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

Prototype

int GL_TEXTURE_ENV

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

Click Source Link

Document

TextureEnvTarget

Usage

From source file:org.fenggui.binding.render.lwjgl.LWJGLOpenGL.java

License:Open Source License

public void setTexEnvModeDecal() {
    //GL11.glBlendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA);
    GL11.glTexEnvf(GL11.GL_TEXTURE_ENV, GL11.GL_TEXTURE_ENV_MODE, GL11.GL_DECAL);
    //GL11.glTexEnvf(GL11.GL_TEXTURE_ENV, GL11.GL_TEXTURE_ENV_COLOR, GL11.GL_LUMINANCE_ALPHA);
}

From source file:org.fenggui.binding.render.lwjgl.LWJGLOpenGL.java

License:Open Source License

public void setTexEnvModeModulate() {
    GL11.glTexEnvf(GL11.GL_TEXTURE_ENV, GL11.GL_TEXTURE_ENV_MODE, GL11.GL_MODULATE);
    //GL11.glTexEnvf(GL11.GL_TEXTURE_ENV, GL11.GL_TEXTURE_ENV_MODE, GL11.GL_MODULATE);
}

From source file:org.fenggui.binding.render.lwjgl.LWJGLOpenGL.java

License:Open Source License

public void setupStateVariables(boolean depthTestEnabled) {
    GL11.glEnable(GL11.GL_BLEND);/*from   w  w w. j a va 2 s . c  om*/
    //      GL11.glBlendFunc(GL11.GL_ONE, GL11.GL_ONE_MINUS_SRC_ALPHA);
    GL11.glBlendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA);

    if (depthTestEnabled)
        GL11.glDisable(GL11.GL_DEPTH_TEST);

    GL11.glShadeModel(GL11.GL_SMOOTH);
    GL11.glDisable(GL11.GL_LIGHTING);
    GL11.glDisable(GL11.GL_FOG);
    GL11.glDisable(GL11.GL_DITHER);

    GL11.glEnable(GL11.GL_SCISSOR_TEST);
    //GL11.glPolygonMode(GL11.GL_FRONT, GL11.GL_FILL);
    GL11.glPolygonMode(GL11.GL_FRONT_AND_BACK, GL11.GL_FILL);
    GL11.glDisable(GL11.GL_LINE_STIPPLE);

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

    //GL11.glDisable(GL11.GL_TEXTURE_GEN_S);
    GL11.glDisable(GL11.GL_CULL_FACE);
    //      GL11.glEnable(GL11.GL_CULL_FACE);
    GL11.glEnable(GL11.GL_NORMALIZE);
    GL11.glFrontFace(GL11.GL_CW);
    GL11.glCullFace(GL11.GL_BACK);
    // disabling textures after setting state values. They would
    // be ignored otherwise (i think)
    GL11.glDisable(GL11.GL_TEXTURE_2D);
    GL11.glDisable(GL11.GL_TEXTURE_1D);
}

From source file:org.fenggui.render.lwjgl.LWJGLOpenGL.java

License:Open Source License

public void setupStateVariables(boolean depthTestEnabled) {
    GL11.glEnable(GL11.GL_BLEND);/*from w  ww.  j a  va  2s  . c  om*/
    GL11.glBlendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA);

    if (depthTestEnabled)
        GL11.glDisable(GL11.GL_DEPTH_TEST);

    GL11.glShadeModel(GL11.GL_SMOOTH);
    GL11.glDisable(GL11.GL_LIGHTING);
    GL11.glDisable(GL11.GL_FOG);
    GL11.glDisable(GL11.GL_DITHER);

    GL11.glEnable(GL11.GL_SCISSOR_TEST);
    //GL11.glPolygonMode(GL11.GL_FRONT, GL11.GL_FILL);
    GL11.glPolygonMode(GL11.GL_FRONT_AND_BACK, GL11.GL_FILL);
    GL11.glEnable(GL11.GL_NORMALIZE);
    GL11.glDisable(GL11.GL_LINE_STIPPLE);

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

    //GL11.glDisable(GL11.GL_TEXTURE_GEN_S);
    GL11.glDisable(GL11.GL_CULL_FACE);
    GL11.glEnable(GL11.GL_NORMALIZE);
    GL11.glFrontFace(GL11.GL_CW);
    GL11.glCullFace(GL11.GL_BACK);
    // disabling textures after setting state values. They would
    // be ignored otherwise (i think)
    GL11.glDisable(GL11.GL_TEXTURE_2D);
    GL11.glDisable(GL11.GL_TEXTURE_1D);

}

From source file:org.free.jake2.render.lwjgl.Image.java

License:Open Source License

void GL_TexEnv(int mode /* GLenum */) {

    if (mode != lastmodes[gl_state.currenttmu]) {
        GL11.glTexEnvi(GL11.GL_TEXTURE_ENV, GL11.GL_TEXTURE_ENV_MODE, mode);
        lastmodes[gl_state.currenttmu] = mode;
    }/*from  w  ww.  j  a v a  2  s.  c o m*/
}

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 w w  w  .j a va2 s. c o m
     * 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 {//w ww  .  j a v  a2s. c  om
        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!");
    }/* www.  ja va2s  .  c o  m*/

    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() {
    return GL11.GL_TEXTURE_ENV;
}

From source file:terminal.gld.TrueTypeFont.java

License:Open Source License

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