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:zildo.platform.filter.LwjglCircleFilter.java

License:Open Source License

@Override
public boolean renderFilter() {
    graphicStuff.fbo.endRendering();// w w  w  .  ja  va2s .c o  m

    // Get on top of screen and disable blending
    GL11.glMatrixMode(GL11.GL_MODELVIEW);
    GL11.glLoadIdentity();
    GL11.glMatrixMode(GL11.GL_PROJECTION);
    GL11.glPushMatrix();
    GL11.glTranslatef(0, -sizeY, 1);

    Vector3f curColor = ClientEngineZildo.ortho.getFilteredColor();
    GL11.glColor3f(curColor.x, curColor.y, curColor.z);

    GL11.glBindTexture(GL11.GL_TEXTURE_2D, textureID);
    super.render();
    GL11.glBegin(GL11.GL_QUADS);
    int radius = (int) (coeffLevel * (255 - getFadeLevel())); // + 20;
    int radiusSquare = (int) Math.pow(radius, 2);
    int col = 0;

    int sizeA = center.y - radius;
    int sizeB = Zildo.viewPortY - (center.y + radius);

    // 1) Draw the two areas outside the circle
    if (sizeA > 0) {
        ClientEngineZildo.ortho.boxOpti(0, 0, Zildo.viewPortX, sizeA, col, null);
    }
    if (sizeB > 0) {
        ClientEngineZildo.ortho.boxOpti(0, center.y + radius, Zildo.viewPortX, sizeB, col, null);
    }

    // 2) Draw the circle area
    int startI = Math.max(0, sizeA);
    int endI = Math.min(Zildo.viewPortY, center.y + radius);

    for (int i = startI; i < endI; i++) {
        int start = (int) Math.pow(i - center.y, 2);

        // Calculate DELTA and 2 roots x1 & x2
        double delta = 4 * (radiusSquare - start);
        double squareRootDelta = Math.sqrt(delta);
        int x1 = (int) (center.x - squareRootDelta / 2);
        int x2 = (int) (center.x + squareRootDelta / 2);
        ClientEngineZildo.ortho.boxOpti(0, i, x1, 1, col, null);
        ClientEngineZildo.ortho.boxOpti(x2, i, Zildo.viewPortX - x2, 1, col, null);
    }
    GL11.glEnd();
    GL11.glPopMatrix();

    // Reset full color
    GL11.glColor3f(1, 1, 1);
    GL11.glMatrixMode(GL11.GL_MODELVIEW);
    GL11.glDisable(GL11.GL_BLEND);

    return true;
}

From source file:zildo.platform.filter.LwjglCloudFilter.java

License:Open Source License

@Override
public boolean renderFilter() {

    super.startInitialization();
    updateQuad(0, 0, u, v, Reverse.NOTHING);
    this.endInitialization();

    GL11.glMatrixMode(GL11.GL_MODELVIEW);
    GL11.glLoadIdentity();//  w  ww  .  ja  v  a 2  s  . c o  m
    GL11.glMatrixMode(GL11.GL_PROJECTION);
    GL11.glPushMatrix();
    GL11.glTranslatef(0, -sizeY, 1);

    float colorFactor = 0.2f;
    GL11.glColor4f(colorFactor, colorFactor, colorFactor, 0.1f);
    GL11.glEnable(GL11.GL_BLEND);
    GL11.glBlendFunc(GL11.GL_ZERO, GL11.GL_ONE_MINUS_SRC_COLOR);

    GL11.glBindTexture(GL11.GL_TEXTURE_2D, ClientEngineZildo.tileEngine.texCloudId);
    super.render();

    GL11.glDisable(GL11.GL_BLEND);

    GL11.glPopMatrix();

    GL11.glMatrixMode(GL11.GL_MODELVIEW);
    return true;
}

From source file:zildo.platform.filter.LwjglFitToScreenFilter.java

License:Open Source License

@Override
public boolean renderFilter() {

    // Select right texture
    GL11.glBindTexture(GL11.GL_TEXTURE_2D, ClientEngineZildo.tileEngine.texBackMenuId);

    GL11.glMatrixMode(GL11.GL_MODELVIEW);
    GL11.glLoadIdentity();/*w  w w .j  a v  a2  s.  c o  m*/
    GL11.glMatrixMode(GL11.GL_PROJECTION);
    GL11.glPushMatrix();
    GL11.glTranslatef(0, -sizeY, 1);

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

    if (!resized) {
        startInitialization();
        updateQuad(0, 0, 1, 0.1f, Reverse.HORIZONTAL);
        endInitialization();
        startInitialization();
        updateTextureCoordinates(0, 0, textureSizeX, -textureSizeY, false);
        endInitialization();
        resized = true;
    }
    // This filter is in charge to alter all screen colors
    Vector3f v = ClientEngineZildo.ortho.getFilteredColor();
    GL11.glColor3f(v.x, v.y, v.z);

    // Draw texture with depth
    super.render();

    GL11.glDisable(GL11.GL_BLEND);

    // Reset full color
    GL11.glColor3f(1, 1, 1);

    GL11.glPopMatrix();

    GL11.glMatrixMode(GL11.GL_MODELVIEW);
    return true;
}

From source file:zildo.platform.opengl.GLUtils.java

License:Open Source License

public static int generateTexture(int sizeX, int sizeY) {
    IntBuffer buf = ByteBuffer.allocateDirect(4).order(ByteOrder.nativeOrder()).asIntBuffer();
    GL11.glGenTextures(buf); // Create Texture In OpenGL
    int textureID = buf.get(0);
    GL11.glBindTexture(GL11.GL_TEXTURE_2D, textureID);
    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_LINEAR);

    GL11.glTexImage2D(GL11.GL_TEXTURE_2D, 0, GL11.GL_RGBA, ZUtils.adjustTexSize(sizeX),
            ZUtils.adjustTexSize(sizeY), 0, GL11.GL_RGBA, GL11.GL_UNSIGNED_BYTE, (ByteBuffer) null);

    return textureID;
}

From source file:zsawyer.mods.stereoscopic3d.MinecraftCopy.java

License:Open Source License

/**
 * Displays a new screen./*from w ww.ja  v a 2  s  .  c o  m*/
 */
public static void loadScreen() throws LWJGLException {
    ScaledResolution var1 = new ScaledResolution(mc.gameSettings, mc.displayWidth, mc.displayHeight);
    GL11.glClear(16640);
    GL11.glMatrixMode(GL11.GL_PROJECTION);
    GL11.glLoadIdentity();
    GL11.glOrtho(0.0D, var1.getScaledWidth_double(), var1.getScaledHeight_double(), 0.0D, 1000.0D, 3000.0D);
    GL11.glMatrixMode(GL11.GL_MODELVIEW);
    GL11.glLoadIdentity();
    GL11.glTranslatef(0.0F, 0.0F, -2000.0F);
    GL11.glViewport(0, 0, mc.displayWidth, mc.displayHeight);
    GL11.glClearColor(0.0F, 0.0F, 0.0F, 0.0F);
    GL11.glDisable(GL11.GL_LIGHTING);
    GL11.glEnable(GL11.GL_TEXTURE_2D);
    GL11.glDisable(GL11.GL_FOG);
    Tessellator var2 = Tessellator.instance;
    GL11.glBindTexture(GL11.GL_TEXTURE_2D, mc.renderEngine.getTexture("/title/mojang.png"));
    var2.startDrawingQuads();
    var2.setColorOpaque_I(16777215);
    var2.addVertexWithUV(0.0D, (double) mc.displayHeight, 0.0D, 0.0D, 0.0D);
    var2.addVertexWithUV((double) mc.displayWidth, (double) mc.displayHeight, 0.0D, 0.0D, 0.0D);
    var2.addVertexWithUV((double) mc.displayWidth, 0.0D, 0.0D, 0.0D, 0.0D);
    var2.addVertexWithUV(0.0D, 0.0D, 0.0D, 0.0D, 0.0D);
    var2.draw();
    GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F);
    var2.setColorOpaque_I(16777215);
    short var3 = 256;
    short var4 = 256;
    mc.scaledTessellator((var1.getScaledWidth() - var3) / 2, (var1.getScaledHeight() - var4) / 2, 0, 0, var3,
            var4);
    GL11.glDisable(GL11.GL_LIGHTING);
    GL11.glDisable(GL11.GL_FOG);
    GL11.glEnable(GL11.GL_ALPHA_TEST);
    GL11.glAlphaFunc(GL11.GL_GREATER, 0.1F);
    Display.swapBuffers();
}