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:de.kitsunealex.projectx.client.render.block.RenderHelper.java

License:Open Source License

protected int[] disableMipmap() {
    int min = GL11.glGetTexParameteri(GL11.GL_TEXTURE_2D, GL11.GL_TEXTURE_MIN_FILTER);
    int mag = GL11.glGetTexParameteri(GL11.GL_TEXTURE_2D, GL11.GL_TEXTURE_MAG_FILTER);
    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);
    return new int[] { min, mag };
}

From source file:de.kitsunealex.projectx.client.render.block.RenderHelper.java

License:Open Source License

protected void enableMipmap(int[] data) {
    GL11.glTexParameteri(GL11.GL_TEXTURE_2D, GL11.GL_TEXTURE_MIN_FILTER, data[0]);
    GL11.glTexParameteri(GL11.GL_TEXTURE_2D, GL11.GL_TEXTURE_MAG_FILTER, data[1]);
}

From source file:dripdisplay.DripDisplayLWJGL.java

private void initTextures() {

    // enable alpha blending
    GL11.glEnable(GL11.GL_BLEND);/*  w w  w .  j  a  v  a2  s  .  c om*/

    GL11.glBlendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA);

    levelmap = new TextureMapper();

    levelmap.initSheet(
            this.getClass().getResource("/dripimages/cavebackground_6level_spritesheet_4_12_2014.png"), "PNG");
    levelmap.addSpriteLocation("cavebackground", new Rectangle2D.Float(.439f, .2944f, .219f, .294f));
    levelmap.addSpriteLocation("caveforeground", new Rectangle2D.Float(.66f, 0f, .219f, .294f));
    levelmap.addSpriteLocation("cavebackgrounddark", new Rectangle2D.Float(0f, .608f, .219f, .294f));
    levelmap.addSpriteLocation("icebackground", new Rectangle2D.Float(.439f, 0f, .219f, .294f));
    levelmap.addSpriteLocation("halficebackground", new Rectangle2D.Float(.22f, .607f, .219f, .294f));
    levelmap.addSpriteLocation("largebackground", new Rectangle2D.Float(.01f, .01f, .428f, .595f));
    levelmap.addSpriteLocation("shade", new Rectangle2D.Float(.11f, .63f, .1f, .05f));
    levelmap.addSpriteLocation("empty", new Rectangle2D.Float(.667f, 0.63f, .1f, .1f));

    playermap = new TextureMapper();

    playermap.initSheet(this.getClass().getResource("/dripimages/drip_spritesheet_11_11_2014.png"), "PNG");
    playermap.addSpriteLocation("drippyL", new Rectangle2D.Float(0f, .5f, .25f, .5f));
    playermap.addSpriteLocation("drippyR", new Rectangle2D.Float(.25f, .5f, .25f, .5f));
    playermap.addSpriteLocation("icey", new Rectangle2D.Float(.5f, 0f, .25f, .5f));
    playermap.addSpriteLocation("cloudyL", new Rectangle2D.Float(0f, 0f, .25f, .5f));
    playermap.addSpriteLocation("cloudyR", new Rectangle2D.Float(.25f, 0f, .25f, .5f));

    scenerymap = new TextureMapper();

    scenerymap.initSheet(this.getClass().getResource("/dripimages/scenery_spritesheet_4_12_2014.png"), "PNG");
    scenerymap.addSpriteLocation("mossflat", new Rectangle2D.Float(0f, 0f, .298f, .064f));
    scenerymap.addSpriteLocation("mosscurve", new Rectangle2D.Float(0f, .0643f, .298f, .064f));
    scenerymap.addSpriteLocation("platform", new Rectangle2D.Float(.001f, .13f, .297f, .049f));
    scenerymap.addSpriteLocation("iceplatform", new Rectangle2D.Float(0f, .18f, .3f, .025f));
    scenerymap.addSpriteLocation("fatplatform", new Rectangle2D.Float(0f, .205f, .295f, .075f));
    scenerymap.addSpriteLocation("largestalactite", new Rectangle2D.Float(0f, 0.2932f, .29f, .5198f));
    scenerymap.addSpriteLocation("largestalagmite", new Rectangle2D.Float(.3f, 0f, .285f, .515f));
    scenerymap.addSpriteLocation("smallstalagmite", new Rectangle2D.Float(.267f, .518f, .238f, .33f));
    scenerymap.addSpriteLocation("smallstalactite", new Rectangle2D.Float(.585f, 0f, .238f, .33f));
    scenerymap.addSpriteLocation("squareplatform", new Rectangle2D.Float(.588f, .331f, .195f, .195f));
    scenerymap.addSpriteLocation("leftmoss", new Rectangle2D.Float(.5f, .5275f, .181f, .064f));
    scenerymap.addSpriteLocation("rightmoss", new Rectangle2D.Float(.5f, .5917f, .181f, .0643f));

    treemap = new TextureMapper();

    treemap.initSheet(this.getClass().getResource("/dripimages/moredecoration_spritesheet_3_12_2014.png"),
            "PNG");
    treemap.addSpriteLocation("tree1", new Rectangle2D.Float(.932f, 0f, .07f, .2f));
    treemap.addSpriteLocation("tree2", new Rectangle2D.Float(.327f, 0f, .213f, .543f));
    treemap.addSpriteLocation("tree3", new Rectangle2D.Float(0f, 0f, .3255f, .99f));
    treemap.addSpriteLocation("root", new Rectangle2D.Float(.737f, .575f, .027f, .3f));

    interactivemap = new TextureMapper();

    interactivemap.initSheet(this.getClass().getResource("/dripimages/interactive_spritesheet_22_11_2014.png"),
            "PNG");
    interactivemap.addSpriteLocation("iceright", new Rectangle2D.Float(0f, 0f, .1325f, .85f));
    interactivemap.addSpriteLocation("rockright", new Rectangle2D.Float(.1325f, 0f, .1325f, .85f));
    interactivemap.addSpriteLocation("iceleft", new Rectangle2D.Float(.265f, 0f, .1325f, .85f));
    interactivemap.addSpriteLocation("rockleft", new Rectangle2D.Float(.3975f, 0f, .1325f, .85f));

    decorationmap = new TextureMapper();

    decorationmap.initSheet(this.getClass().getResource("/dripimages/decoration_spritesheet_18_11_2014.png"),
            "PNG");
    decorationmap.addSpriteLocation("grass", new Rectangle2D.Float(0f, 0f, .582f, .0445f));
    decorationmap.addSpriteLocation("shroom1", new Rectangle2D.Float(0f, .05f, .205f, .162f));
    decorationmap.addSpriteLocation("shroom2", new Rectangle2D.Float(0f, .212f, .205f, .162f));
    decorationmap.addSpriteLocation("shroom3", new Rectangle2D.Float(.205f, .0483f, .21f, .165f));
    decorationmap.addSpriteLocation("shroom4", new Rectangle2D.Float(.205f, .216f, .21f, .165f));
    decorationmap.addSpriteLocation("grass1", new Rectangle2D.Float(.415f, .05f, .153f, .37f));
    decorationmap.addSpriteLocation("grass2", new Rectangle2D.Float(.588f, 0f, .153f, .37f));
    decorationmap.addSpriteLocation("grass3", new Rectangle2D.Float(.75f, 0f, .153f, .37f));
    decorationmap.addSpriteLocation("grass4", new Rectangle2D.Float(0f, .375f, .1512f, .37f));
    decorationmap.addSpriteLocation("shroom", new Rectangle2D.Float(.153f, .375f, .1506f, .162f));

    threatmap = new TextureMapper();

    threatmap.initSheet(this.getClass().getResource("/dripimages/fireice_spritesheet_16_11_2014.png"), "PNG");
    threatmap.addSpriteLocation("fire1", new Rectangle2D.Float(.00f, 0f, .155f, .403f));
    threatmap.addSpriteLocation("fire2", new Rectangle2D.Float(.156f, 0f, .155f, .403f));
    threatmap.addSpriteLocation("fire3", new Rectangle2D.Float(.312f, 0f, .154f, .403f));
    threatmap.addSpriteLocation("ice1", new Rectangle2D.Float(.47f, 0f, .15f, .41f));
    threatmap.addSpriteLocation("ice2", new Rectangle2D.Float(.0f, .4f, .15f, .41f));
    threatmap.addSpriteLocation("ice3", new Rectangle2D.Float(.1f, .4f, .15f, .41f));

    healingmap = new TextureMapper();

    healingmap.initSheet(this.getClass().getResource("/dripimages/pooldrip_spritesheet_16_11_2014.png"), "PNG");
    healingmap.addSpriteLocation("pool1", new Rectangle2D.Float(0f, 0f, .39f, .085f));
    healingmap.addSpriteLocation("pool2", new Rectangle2D.Float(0f, 0f, .39f, .085f));
    healingmap.addSpriteLocation("pool3", new Rectangle2D.Float(0f, 0f, .39f, .085f));
    healingmap.addSpriteLocation("pool4", new Rectangle2D.Float(0f, 0f, .39f, .085f));
    healingmap.addSpriteLocation("pool5", new Rectangle2D.Float(0f, 0f, .39f, .085f));
    healingmap.addSpriteLocation("drop1", new Rectangle2D.Float(.0f, 0f, .15f, .1f));
    healingmap.addSpriteLocation("drop2", new Rectangle2D.Float(.0f, 0f, .15f, .1f));
    healingmap.addSpriteLocation("drop3", new Rectangle2D.Float(.0f, 0f, .15f, .1f));
    healingmap.addSpriteLocation("drop4", new Rectangle2D.Float(.0f, 0f, .15f, .1f));
    healingmap.addSpriteLocation("drop5", new Rectangle2D.Float(.0f, 0f, .15f, .1f));
    healingmap.addSpriteLocation("drop6", new Rectangle2D.Float(.0f, 0f, .15f, .1f));
    healingmap.addSpriteLocation("drop7", new Rectangle2D.Float(.0f, 0f, .15f, .1f));

    healthmap = new TextureMapper();

    healthmap.initSheet(this.getClass().getResource("/dripimages/waterhealth_spritesheet_11_11_2014.png"),
            "PNG");
    healthmap.addSpriteLocation("10", new Rectangle2D.Float(0f, 0f, .25f, .25f));
    healthmap.addSpriteLocation("20", new Rectangle2D.Float(0f, .25f, .25f, .25f));
    healthmap.addSpriteLocation("30", new Rectangle2D.Float(.25f, .25f, .25f, .25f));
    healthmap.addSpriteLocation("40", new Rectangle2D.Float(.5f, 0f, .25f, .25f));
    healthmap.addSpriteLocation("50", new Rectangle2D.Float(.5f, .25f, .25f, .25f));
    healthmap.addSpriteLocation("60", new Rectangle2D.Float(.75f, 0f, .25f, .25f));
    healthmap.addSpriteLocation("70", new Rectangle2D.Float(.75f, .25f, .25f, .25f));
    healthmap.addSpriteLocation("80", new Rectangle2D.Float(0f, .5f, .25f, .25f));
    healthmap.addSpriteLocation("90", new Rectangle2D.Float(0f, .75f, .25f, .25f));
    healthmap.addSpriteLocation("100", new Rectangle2D.Float(.25f, 0f, .25f, .25f));
    healthmap.addSpriteLocation("0", new Rectangle2D.Float(.9f, .9f, .01f, .01f));
    healthmap.addSpriteLocation("porthole", new Rectangle2D.Float(.25f, .5f, .25f, .25f));

    numbermap = new TextureMapper();

    numbermap.initSheet(this.getClass().getResource("/dripimages/number_spritesheet_11_11_2014.png"), "PNG");
    numbermap.addSpriteLocation("0", new Rectangle2D.Float(0f, 0f, .2f, .2f));
    numbermap.addSpriteLocation("1", new Rectangle2D.Float(.21f, 0f, .2f, .2f));
    numbermap.addSpriteLocation("2", new Rectangle2D.Float(.42f, 0f, .2f, .2f));
    numbermap.addSpriteLocation("3", new Rectangle2D.Float(.63f, 0f, .2f, .2f));
    numbermap.addSpriteLocation("4", new Rectangle2D.Float(0f, .206f, .2f, .2f));
    numbermap.addSpriteLocation("5", new Rectangle2D.Float(.21f, .206f, .2f, .2f));
    numbermap.addSpriteLocation("6", new Rectangle2D.Float(.42f, .206f, .2f, .206f));
    numbermap.addSpriteLocation("7", new Rectangle2D.Float(.63f, .206f, .2f, .206f));
    numbermap.addSpriteLocation("8", new Rectangle2D.Float(0f, .41f, .2f, .206f));
    numbermap.addSpriteLocation("9", new Rectangle2D.Float(.21f, .41f, .2f, .206f));
    numbermap.addSpriteLocation("blank", new Rectangle2D.Float(.63f, .41f, .2f, .206f));

    temperaturemap = new TextureMapper();

    temperaturemap.initSheet(this.getClass().getResource("/dripimages/temperature_spritesheet_17_11_2014.png"),
            "PNG");
    temperaturemap.addSpriteLocation("temp10", new Rectangle2D.Float(0f, 0f, .18f, .28f));
    temperaturemap.addSpriteLocation("temp20", new Rectangle2D.Float(.18f, 0f, .18f, .28f));
    temperaturemap.addSpriteLocation("temp30", new Rectangle2D.Float(.36f, 0f, .18f, .28f));
    temperaturemap.addSpriteLocation("temp40", new Rectangle2D.Float(.54f, 0f, .18f, .28f));
    temperaturemap.addSpriteLocation("temp50", new Rectangle2D.Float(0f, .288f, .18f, .28f));
    temperaturemap.addSpriteLocation("temp60", new Rectangle2D.Float(.18f, .288f, .18f, .28f));
    temperaturemap.addSpriteLocation("temp70", new Rectangle2D.Float(.36f, .288f, .18f, .28f));
    temperaturemap.addSpriteLocation("temp80", new Rectangle2D.Float(.54f, .288f, .18f, .28f));
    temperaturemap.addSpriteLocation("temp90", new Rectangle2D.Float(0f, .576f, .18f, .28f));

    menumap = new TextureMapper();

    menumap.initSheet(this.getClass().getResource("/dripimages/menu_spritesheet_1_12_2014.png"), "PNG");
    menumap.addSpriteLocation("levelcomplete", new Rectangle2D.Float(0f, 0f, .5f, .15f));
    menumap.addSpriteLocation("darken", new Rectangle2D.Float(0f, .2f, .1f, .1f));
    menumap.addSpriteLocation("paused", new Rectangle2D.Float(0f, .44f, .39f, .27f));
    menumap.addSpriteLocation("pressspacedark", new Rectangle2D.Float(0f, .715f, .35f, .0618f));
    menumap.addSpriteLocation("pressspacelight", new Rectangle2D.Float(0f, .78f, .35f, .0601f));
    menumap.addSpriteLocation("optionsdark", new Rectangle2D.Float(0f, .84f, .17f, .12f));
    menumap.addSpriteLocation("optionslight", new Rectangle2D.Float(0.17f, 0.84f, .17f, .12f));
    menumap.addSpriteLocation("quitlight", new Rectangle2D.Float(0.64f, .695f, .09f, .13f));
    menumap.addSpriteLocation("quitdark", new Rectangle2D.Float(0.5f, 0f, .09f, .13f));
    menumap.addSpriteLocation("d", new Rectangle2D.Float(0.39f, 0f, .39f, 1f));
    menumap.addSpriteLocation("r", new Rectangle2D.Float(0.39f, 0f, .39f, 1f));
    menumap.addSpriteLocation("drip", new Rectangle2D.Float(0.39f, 0f, .39f, 1f));
    menumap.addSpriteLocation("i", new Rectangle2D.Float(0.39f, 0f, .39f, 1f));
    menumap.addSpriteLocation("p", new Rectangle2D.Float(0.39f, 0f, .39f, 1f));

    leveleditormap = new TextureMapper();

    leveleditormap.initSheet(this.getClass().getResource("/dripimages/leveleditor_spritesheet_22_11_2014.png"),
            "PNG");
    leveleditormap.addSpriteLocation("bottombar", new Rectangle2D.Float(0f, 0f, .78f, .195f));
    leveleditormap.addSpriteLocation("sidebar", new Rectangle2D.Float(0f, .195f, .195f, .78f));

    GL11.glTexParameteri(GL11.GL_TEXTURE_2D, GL11.GL_TEXTURE_WRAP_S, GL11.GL_REPEAT);

    GL11.glEnable(GL11.GL_TEXTURE_2D);
}

From source file:edu.csun.ecs.cs.multitouchj.ui.graphic.image.TextureHandler.java

License:Apache License

public Texture generateTexture(Image image) {
    Integer textureId = generateTextureId();
    ByteBuffer imageData = prepareImage(image);

    GL11.glEnable(EXTTextureRectangle.GL_TEXTURE_RECTANGLE_EXT);
    GL11.glBindTexture(EXTTextureRectangle.GL_TEXTURE_RECTANGLE_EXT, textureId.intValue());

    GL11.glTexParameteri(EXTTextureRectangle.GL_TEXTURE_RECTANGLE_EXT, GL11.GL_TEXTURE_MIN_FILTER,
            GL11.GL_NEAREST);/* www .  ja va 2  s.  c  o  m*/
    GL11.glTexParameteri(EXTTextureRectangle.GL_TEXTURE_RECTANGLE_EXT, GL11.GL_TEXTURE_MAG_FILTER,
            GL11.GL_NEAREST);
    // GL11.glTexParameteri(EXTTextureRectangle.GL_TEXTURE_RECTANGLE_EXT,
    // GL11.GL_TEXTURE_WRAP_S, GL11.GL_CLAMP);
    // GL11.glTexParameteri(EXTTextureRectangle.GL_TEXTURE_RECTANGLE_EXT,
    // GL11.GL_TEXTURE_WRAP_T, GL11.GL_CLAMP);
    GL11.glTexImage2D(EXTTextureRectangle.GL_TEXTURE_RECTANGLE_EXT, 0,
            (image.hasAlpha()) ? GL11.GL_RGBA8 : GL11.GL_RGB8, image.getWidth(), image.getHeight(), 0,
            (image.hasAlpha()) ? GL11.GL_RGBA : GL11.GL_RGB, GL11.GL_UNSIGNED_BYTE, imageData);

    System.out.println("Texture generated: " + textureId);

    return new Texture(textureId, image);
}

From source file:espresso3d.engine.fileloaders.E3DImageLoader.java

License:Open Source License

public static E3DTexture loadImageIntoGL(E3DEngine engine, String textureName, Image image) {
    // Extract The Image
    BufferedImage tex = new BufferedImage(image.getWidth(null), image.getHeight(null),
            BufferedImage.TYPE_3BYTE_BGR);

    Graphics2D g = (Graphics2D) tex.getGraphics();
    g.drawImage(image, null, null);/*from w  ww. j a va2 s.c  o m*/
    g.dispose();

    // Flip Image
    AffineTransform tx = AffineTransform.getScaleInstance(1, -1);
    tx.translate(0, -image.getHeight(null));
    AffineTransformOp op = new AffineTransformOp(tx, AffineTransformOp.TYPE_NEAREST_NEIGHBOR);
    tex = op.filter(tex, null);

    // Put Image In Memory
    ByteBuffer scratch = ByteBuffer.allocateDirect(4 * tex.getWidth() * tex.getHeight());

    byte data[] = (byte[]) tex.getRaster().getDataElements(0, 0, tex.getWidth(), tex.getHeight(), null);
    scratch.clear();
    scratch.put(data);
    scratch.rewind();

    // Create A IntBuffer For Image Address In Memory   
    IntBuffer buf = ByteBuffer.allocateDirect(4).order(ByteOrder.nativeOrder()).asIntBuffer();
    GL11.glGenTextures(buf); // Create Texture In OpenGL   

    GL11.glBindTexture(GL11.GL_TEXTURE_2D, buf.get(0));
    // Typical Texture Generation Using Data From The Image

    // Linear Filtering
    GL11.glTexParameteri(GL11.GL_TEXTURE_2D, GL11.GL_TEXTURE_MIN_FILTER, GL11.GL_LINEAR);
    // Linear Filtering
    GL11.glTexParameteri(GL11.GL_TEXTURE_2D, GL11.GL_TEXTURE_MAG_FILTER, GL11.GL_LINEAR);
    // Generate The Texture
    GLU.gluBuild2DMipmaps(GL11.GL_TEXTURE_2D, 3, tex.getWidth(), tex.getHeight(), GL11.GL_RGB,
            GL11.GL_UNSIGNED_BYTE, scratch);
    //      GL11.glTexImage2D(GL11.GL_TEXTURE_2D, 0, GL11.GL_RGB, tex.getWidth(), tex.getHeight(), 0, GL11.GL_RGB, GL11.GL_UNSIGNED_BYTE, scratch);

    E3DTexture texture = new E3DTexture(engine, textureName, buf.get(0));
    texture.setWidth(image.getWidth(null));
    texture.setHeight(image.getHeight(null));

    return texture; // Return Image Address In Memory       
}

From source file:eu.over9000.veya.gui.TrueTypeFont.java

License:Open Source License

private void buildTexture(final BufferedImage imgTemp) throws IOException {
    textureId = GL11.glGenTextures();/*from w  w  w  .ja v  a 2s .com*/

    GL11.glBindTexture(GL11.GL_TEXTURE_2D, textureId);

    final ByteArrayOutputStream byteArrayOutputStream = new ByteArrayOutputStream();
    ImageIO.write(imgTemp, "png", byteArrayOutputStream);
    final PNGDecoder decoder = new PNGDecoder(new ByteArrayInputStream(byteArrayOutputStream.toByteArray()));
    final ByteBuffer buffer = BufferUtils.createByteBuffer(4 * decoder.getWidth() * decoder.getHeight());
    decoder.decode(buffer, decoder.getWidth() * 4, PNGDecoder.Format.RGBA);
    buffer.flip();

    GL11.glTexImage2D(GL11.GL_TEXTURE_2D, 0, GL11.GL_RGBA, decoder.getWidth(), decoder.getHeight(), 0,
            GL11.GL_RGBA, GL11.GL_UNSIGNED_BYTE, buffer);
    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);
}

From source file:eu.over9000.veya.rendering.Shadow.java

License:Open Source License

public void init() {
    depthMap = GL11.glGenTextures();//from ww  w .jav  a  2s . com
    GL11.glBindTexture(GL11.GL_TEXTURE_2D, depthMap);
    GL11.glTexImage2D(GL11.GL_TEXTURE_2D, 0, GL11.GL_DEPTH_COMPONENT, SHADOW_WIDTH, SHADOW_HEIGHT, 0,
            GL11.GL_DEPTH_COMPONENT, GL11.GL_FLOAT, (ByteBuffer) null);
    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.glTexParameteri(GL11.GL_TEXTURE_2D, GL11.GL_TEXTURE_WRAP_S, GL13.GL_CLAMP_TO_BORDER);
    GL11.glTexParameteri(GL11.GL_TEXTURE_2D, GL11.GL_TEXTURE_WRAP_T, GL13.GL_CLAMP_TO_BORDER);

    shadowFBO = GL30.glGenFramebuffers();
    GL30.glBindFramebuffer(GL30.GL_FRAMEBUFFER, shadowFBO);
    GL30.glFramebufferTexture2D(GL30.GL_FRAMEBUFFER, GL30.GL_DEPTH_ATTACHMENT, GL11.GL_TEXTURE_2D, depthMap, 0);
    GL11.glDrawBuffer(GL11.GL_NONE);
    GL11.glReadBuffer(GL11.GL_NONE);
    GL30.glBindFramebuffer(GL30.GL_FRAMEBUFFER, 0);
}

From source file:eu.over9000.veya.util.TextureLoader.java

License:Open Source License

public static int loadFontTexture(final int textureUnit) {

    final int texId = GL11.glGenTextures();

    try {/*from  w  w  w  .j a  v  a 2s. c  om*/
        final InputStream in = TextureLoader.class.getResourceAsStream("/textures/font.png");
        final PNGDecoder decoder = new PNGDecoder(in);

        final int sourceTexWidth = decoder.getWidth();
        final int sourceTexHeight = decoder.getHeight();

        final ByteBuffer byteBuffer = ByteBuffer.allocateDirect(4 * decoder.getWidth() * decoder.getHeight());
        decoder.decode(byteBuffer, decoder.getWidth() * 4, Format.RGBA);
        byteBuffer.flip();

        GL13.glActiveTexture(textureUnit);
        GL11.glBindTexture(GL11.GL_TEXTURE_2D, texId);
        GL11.glTexImage2D(GL11.GL_TEXTURE_2D, 0, GL11.GL_RGB, sourceTexWidth, sourceTexHeight, 0, GL11.GL_RGBA,
                GL11.GL_UNSIGNED_BYTE, byteBuffer);

        // Setup the ST coordinate system
        GL11.glTexParameteri(GL11.GL_TEXTURE_2D, GL11.GL_TEXTURE_WRAP_S, GL12.GL_CLAMP_TO_EDGE);
        GL11.glTexParameteri(GL11.GL_TEXTURE_2D, GL11.GL_TEXTURE_WRAP_T, GL12.GL_CLAMP_TO_EDGE);

        // Setup what to do when the texture has to be scaled
        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);

        org.lwjgl.opengl.Util.checkGLError();

        GL11.glBindTexture(GL11.GL_TEXTURE_2D, 0);

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

    return texId;
}

From source file:eu.over9000.veya.util.TextureLoader.java

License:Open Source License

public static int loadBlockTexture(final int textureUnit) {

    final InputStream in = TextureLoader.class.getResourceAsStream("/textures/blocks.png");
    ByteBuffer convertedBuffer = null;
    int sourceTexWidth = 0;
    int sourceTexHeight = 0;
    int texCount = 0;

    try {/*from  w  w w.  j  a va2  s  .  c o m*/
        // Link the PNG decoder to this stream
        final PNGDecoder decoder = new PNGDecoder(in);

        // Get the width and height of the texture
        sourceTexWidth = decoder.getWidth();
        sourceTexHeight = decoder.getHeight();

        texCount = sourceTexWidth / TextureLoader.TEXTURE_WIDTH
                * (sourceTexHeight / TextureLoader.TEXTURE_WIDTH);

        // Decode the PNG file in a ByteBuffer
        final ByteBuffer buf = ByteBuffer.allocateDirect(4 * decoder.getWidth() * decoder.getHeight());
        decoder.decode(buf, decoder.getWidth() * 4, Format.RGBA);
        buf.flip();

        convertedBuffer = TextureLoader.convertBuffer(buf, sourceTexWidth, sourceTexHeight);

        in.close();

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

    // Create a new texture object in memory and bind it
    final int texId = GL11.glGenTextures();
    GL13.glActiveTexture(textureUnit);
    GL11.glBindTexture(GL30.GL_TEXTURE_2D_ARRAY, texId);

    // All RGB bytes are aligned to each other and each component is 1 byte
    GL11.glPixelStorei(GL11.GL_UNPACK_ALIGNMENT, 1);

    // Upload the texture model and generate mip maps (for scaling)
    // GL11.glTexImage2D(GL11.GL_TEXTURE_2D, 0, GL11.GL_RGB, tWidth, tHeight, 0, GL11.GL_RGBA, GL11.GL_UNSIGNED_BYTE, buf);
    GL12.glTexImage3D(GL30.GL_TEXTURE_2D_ARRAY, 0, GL11.GL_RGBA, TextureLoader.TEXTURE_WIDTH,
            TextureLoader.TEXTURE_HEIGHT, texCount, 0, GL11.GL_RGBA, GL11.GL_UNSIGNED_BYTE, convertedBuffer);
    GL30.glGenerateMipmap(GL30.GL_TEXTURE_2D_ARRAY);

    // Setup the ST coordinate system
    GL11.glTexParameteri(GL30.GL_TEXTURE_2D_ARRAY, GL11.GL_TEXTURE_WRAP_S, GL12.GL_CLAMP_TO_EDGE);
    GL11.glTexParameteri(GL30.GL_TEXTURE_2D_ARRAY, GL11.GL_TEXTURE_WRAP_T, GL12.GL_CLAMP_TO_EDGE);

    // Setup what to do when the texture has to be scaled
    GL11.glTexParameteri(GL30.GL_TEXTURE_2D_ARRAY, GL11.GL_TEXTURE_MAG_FILTER, GL11.GL_NEAREST);
    GL11.glTexParameteri(GL30.GL_TEXTURE_2D_ARRAY, GL11.GL_TEXTURE_MIN_FILTER, GL11.GL_NEAREST_MIPMAP_LINEAR);

    org.lwjgl.opengl.Util.checkGLError();

    System.out
            .println("loading block texture, id=" + texId + ", w=" + sourceTexWidth + ", h=" + sourceTexHeight);

    GL11.glBindTexture(GL30.GL_TEXTURE_2D_ARRAY, 0);

    return texId;
}

From source file:fi.conf.ae.gl.texture.GLTextureRoutines.java

License:LGPL

/**
 * Request unused OpenGL texture ID's./*  w  ww . j ava2 s.  co m*/
 * 
 * @param count - How many texture IDs are being requested.
 * @return Requested texture ID's as integer array.
 */
public static int[] allocateGLTextureIDs(int count) {
    if (count > textureIDbuffer.capacity()) {
        allocateNewTextureIDBuffer(count);
    }

    textureIDbuffer.clear();
    textureIDbuffer.limit(count);

    GL11.glGenTextures(textureIDbuffer);

    int[] textureIDs = new int[count];

    for (int i = 0; i < count; i++) {
        if (!textureIDbuffer.hasRemaining())
            break;
        textureIDs[i] = textureIDbuffer.get();

        // preset this texture's minification and magnification filter
        int prevTextureID = bindTexture(textureIDs[i]);
        //         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.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_NEAREST);

        bindTexture(prevTextureID);
    }

    return textureIDs;
}