Example usage for org.lwjgl.opengl GL11 glBindTexture

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

Introduction

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

Prototype

public static void glBindTexture(@NativeType("GLenum") int target, @NativeType("GLuint") int texture) 

Source Link

Document

Binds the a texture to a texture target.

Usage

From source file:go.graphics.swing.opengl.LWJGLDrawContext.java

License:Open Source License

@Override
public void fillQuad(float x1, float y1, float x2, float y2) {
    ByteBuffer quadPoints = ByteBuffer.allocateDirect(4 * 2 * 4);
    quadPoints.order(ByteOrder.nativeOrder());
    FloatBuffer floatBuff = quadPoints.asFloatBuffer();
    floatBuff.put(x1);/*from   w w w .  jav a2 s  .  co m*/
    floatBuff.put(y1);

    floatBuff.put(x1);
    floatBuff.put(y2);

    floatBuff.put(x2);
    floatBuff.put(y2);

    floatBuff.put(x2);
    floatBuff.put(y1);

    floatBuff.position(0);

    GL11.glBindTexture(GL11.GL_TEXTURE_2D, 0);
    GL11.glDisableClientState(GL11.GL_TEXTURE_COORD_ARRAY);
    GL11.glVertexPointer(2, GL11.GL_FLOAT, 0, floatBuff);
    GL11.glDrawArrays(GL11.GL_QUADS, 0, 4);
    GL11.glEnableClientState(GL11.GL_TEXTURE_COORD_ARRAY);
}

From source file:go.graphics.swing.opengl.LWJGLDrawContext.java

License:Open Source License

@Override
public void drawLine(float[] points, boolean loop) {
    if (points.length % 3 != 0) {
        throw new IllegalArgumentException("Point array length needs to be multiple of 3.");
    }//from w w w .ja v a  2s. c  o  m
    ByteBuffer floatBuff = generateTemporaryFloatBuffer(points);

    GL11.glBindTexture(GL11.GL_TEXTURE_2D, 0);
    GL11.glDisableClientState(GL11.GL_TEXTURE_COORD_ARRAY);
    GL11.glVertexPointer(3, GL11.GL_FLOAT, 0, floatBuff);
    GL11.glDrawArrays(loop ? GL11.GL_LINE_LOOP : GL11.GL_LINE_STRIP, 0, points.length / 3);
    GL11.glEnableClientState(GL11.GL_TEXTURE_COORD_ARRAY);
}

From source file:go.graphics.swing.opengl.LWJGLDrawContext.java

License:Open Source License

@Override
public TextureHandle generateTexture(int width, int height, ShortBuffer data) {
    // 1 byte aligned.
    GL11.glPixelStorei(GL11.GL_UNPACK_ALIGNMENT, 1);

    int texture = GL11.glGenTextures();
    if (texture == 0) {
        return null;
    }//from  w  w w .java2 s .c o m

    //fix strange alpha test problem (minimap and landscape are unaffected)
    ShortBuffer bfr = BufferUtils.createShortBuffer(data.capacity());
    int cap = data.capacity();
    for (int i = 0; i != cap; i++)
        bfr.put(i, data.get(i));

    GL11.glBindTexture(GL11.GL_TEXTURE_2D, texture);
    GL11.glTexImage2D(GL11.GL_TEXTURE_2D, 0, GL11.GL_RGBA, width, height, 0, GL11.GL_RGBA,
            GL12.GL_UNSIGNED_SHORT_4_4_4_4, bfr);
    setTextureParameters();

    return new LWJGLTextureHandle(this, texture);
}

From source file:go.graphics.swing.opengl.LWJGLDrawContext.java

License:Open Source License

private void bindTexture(TextureHandle texture) throws IllegalBufferException {
    int id;//  w ww .  jav a 2 s .c  o m
    if (texture == null) {
        id = 0;
    } else {
        if (!texture.isValid()) {
            throw new IllegalBufferException("Texture handle is not valid: " + texture);
        }
        id = texture.getInternalId();
    }
    GL11.glBindTexture(GL11.GL_TEXTURE_2D, id);
}

From source file:group.project.unknown.level.Spritesheet.java

License:Apache License

public void bind() {
    GL11.glBindTexture(GL11.GL_TEXTURE_2D, texture.getTextureID());
}

From source file:group.project.unknown.level.Spritesheet.java

License:Apache License

public void unbind() {
    GL11.glBindTexture(GL11.GL_TEXTURE_2D, 0);
}

From source file:gui.lwjgl.GUIRenderer.java

@Override
public void render(GUIRenderable element) {
    GL30.glBindVertexArray(element.getGUIElement().getVaoID());
    GL20.glEnableVertexAttribArray(VERTEX_POSITIONS);
    GL20.glEnableVertexAttribArray(TEXTURE_COORDS);

    Matrix4f transformationMatrix = Maths.createTransformationMatrix(
            new Vector2f(((2.0f * element.getGUIElement().getPosition().x) / Display.getWidth() - 1),
                    -1 * ((2.0f * element.getGUIElement().getPosition().y) / Display.getHeight()) + 1f),
            element.getGUIElement().getRotation(),
            element.getGUIElement().getWidth() / (float) (Display.getWidth() / 2),
            element.getGUIElement().getHeight() / (float) (Display.getHeight() / 2));

    this.loadUniformMatrix("transformationMatrix", transformationMatrix);

    GL13.glActiveTexture(GL13.GL_TEXTURE0);
    GL11.glBindTexture(GL11.GL_TEXTURE_2D, element.getGUIElement().getTexture().getTextureID());
    GL11.glDrawArrays(GL11.GL_TRIANGLES, 0, 6);

    GL20.glDisableVertexAttribArray(VERTEX_POSITIONS);
    GL20.glDisableVertexAttribArray(TEXTURE_COORDS);
    GL30.glBindVertexArray(0);// w w w  . java2 s . c o m
}

From source file:hellfirepvp.astralsorcery.client.util.resource.BindableResource.java

License:Open Source License

public void bind() {
    if (AssetLibrary.reloading)
        return; //we do nothing but wait.
    if (resource == null) {
        allocateGlId();//from  ww w .ja  va2s.  c  o  m
    }
    GL11.glBindTexture(GL11.GL_TEXTURE_2D, resource.getGlTextureId());
    //GlStateManager.bindTexture(resource.getGlTextureId());
}

From source file:illarion.graphics.lwjgl.DriverSettingsLWJGL.java

License:Open Source License

/**
 * Setup OpenGL to render a texture.//from   w ww .j  a v a2  s  .  com
 * 
 * @param textureID the ID of the texture that shall be bind
 */
public void enableTexture(final int textureID) {
    if (currentMode != MODE_TEXTURE) {
        disableLast();
        GL11.glEnable(GL11.GL_TEXTURE_2D);
        currentMode = MODE_TEXTURE;
    }

    if ((currentTexture != textureID) && (textureID > -1)) {
        GL11.glBindTexture(GL11.GL_TEXTURE_2D, textureID);
    }
    currentTexture = textureID;
}

From source file:illarion.graphics.lwjgl.DriverSettingsLWJGL.java

License:Open Source License

/**
 * Setup OpenGL to render a texture by using texture pointers.
 * /*from w  ww.java 2  s . c o  m*/
 * @param textureID the ID of the texture that shall be bind
 */
public void enableTexturePointer(final int textureID) {
    if (currentMode != MODE_TEXTUREPOINTER) {
        disableLast();
        GL11.glEnable(GL11.GL_TEXTURE_2D);
        GL11.glEnableClientState(GL11.GL_VERTEX_ARRAY);
        GL11.glEnableClientState(GL11.GL_TEXTURE_COORD_ARRAY);
        currentMode = MODE_TEXTUREPOINTER;
    }

    if ((currentTexture != textureID) && (textureID > -1)) {
        GL11.glBindTexture(GL11.GL_TEXTURE_2D, textureID);
    }
    currentTexture = textureID;
}