Example usage for org.lwjgl.opengl GL11 GL_VERTEX_ARRAY

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

Introduction

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

Prototype

int GL_VERTEX_ARRAY

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

Click Source Link

Document

vertex_array

Usage

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

License:Open Source License

public LWJGLDrawContext(GLCapabilities glcaps) {
    this.glcaps = glcaps;

    GL11.glEnableClientState(GL11.GL_VERTEX_ARRAY);
    GL11.glEnableClientState(GL11.GL_TEXTURE_COORD_ARRAY);

    GL11.glBlendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA);
    GL11.glEnable(GL11.GL_BLEND);/*w  w w. j a v  a  2s .  c  o  m*/
    GL11.glEnable(GL11.GL_ALPHA_TEST);
    GL11.glDepthFunc(GL11.GL_LEQUAL);
    GL11.glEnable(GL11.GL_DEPTH_TEST);

    GL11.glEnable(GL11.GL_TEXTURE_2D);

    canUseVBOs = glcaps.GL_ARB_vertex_buffer_object;
}

From source file:hellfirepvp.astralsorcery.client.sky.RenderDefaultSkybox.java

License:Open Source License

private static void renderDefaultSkybox(float partialTicks) {
    GlStateManager.disableTexture2D();//from  w  ww  .  j  a  v  a2 s. c o m
    Vec3d vec3 = Minecraft.getMinecraft().world.getSkyColor(Minecraft.getMinecraft().getRenderViewEntity(),
            partialTicks);
    float f = (float) vec3.xCoord;
    float f1 = (float) vec3.yCoord;
    float f2 = (float) vec3.zCoord;

    if (Minecraft.getMinecraft().gameSettings.anaglyph) {
        float f3 = (f * 30.0F + f1 * 59.0F + f2 * 11.0F) / 100.0F;
        float f4 = (f * 30.0F + f1 * 70.0F) / 100.0F;
        float f5 = (f * 30.0F + f2 * 70.0F) / 100.0F;
        f = f3;
        f1 = f4;
        f2 = f5;
    }

    GlStateManager.color(f, f1, f2);
    Tessellator tessellator = Tessellator.getInstance();
    net.minecraft.client.renderer.VertexBuffer vb = tessellator.getBuffer();
    GlStateManager.depthMask(false);
    GlStateManager.enableFog();
    GlStateManager.color(f, f1, f2);

    if (OpenGlHelper.useVbo()) {
        skyVBO.bindBuffer();
        GL11.glEnableClientState(GL11.GL_VERTEX_ARRAY);
        GL11.glVertexPointer(3, GL11.GL_FLOAT, 12, 0L);
        skyVBO.drawArrays(7);
        skyVBO.unbindBuffer();
        GL11.glDisableClientState(GL11.GL_VERTEX_ARRAY);
    } else {
        GlStateManager.callList(glSkyList);
    }

    GlStateManager.disableFog();
    GlStateManager.disableAlpha();
    GlStateManager.enableBlend();
    GlStateManager.tryBlendFuncSeparate(770, 771, 1, 0);
    RenderHelper.disableStandardItemLighting();
    float[] afloat = Minecraft.getMinecraft().world.provider.calcSunriseSunsetColors(
            Minecraft.getMinecraft().world.getCelestialAngle(partialTicks), partialTicks);

    if (afloat != null) {
        GlStateManager.disableTexture2D();
        GlStateManager.shadeModel(7425);
        GlStateManager.pushMatrix();
        GlStateManager.rotate(90.0F, 1.0F, 0.0F, 0.0F);
        GlStateManager.rotate(
                MathHelper.sin(Minecraft.getMinecraft().world.getCelestialAngleRadians(partialTicks)) < 0.0F
                        ? 180.0F
                        : 0.0F,
                0.0F, 0.0F, 1.0F);
        GlStateManager.rotate(90.0F, 0.0F, 0.0F, 1.0F);
        float f6 = afloat[0];
        float f7 = afloat[1];
        float f8 = afloat[2];

        if (Minecraft.getMinecraft().gameSettings.anaglyph) {
            float f9 = (f6 * 30.0F + f7 * 59.0F + f8 * 11.0F) / 100.0F;
            float f10 = (f6 * 30.0F + f7 * 70.0F) / 100.0F;
            float f11 = (f6 * 30.0F + f8 * 70.0F) / 100.0F;
            f6 = f9;
            f7 = f10;
            f8 = f11;
        }

        vb.begin(6, DefaultVertexFormats.POSITION_COLOR);
        vb.pos(0.0D, 100.0D, 0.0D).color(f6, f7, f8, afloat[3]).endVertex();
        //int j = 16;

        for (int l = 0; l <= 16; ++l) {
            float f21 = (float) l * (float) Math.PI * 2.0F / 16.0F;
            float f12 = MathHelper.sin(f21);
            float f13 = MathHelper.cos(f21);
            vb.pos((double) (f12 * 120.0F), (double) (f13 * 120.0F), (double) (-f13 * 40.0F * afloat[3]))
                    .color(afloat[0], afloat[1], afloat[2], 0.0F).endVertex();
        }

        tessellator.draw();
        GlStateManager.popMatrix();
        GlStateManager.shadeModel(7424);
    }

    GlStateManager.enableTexture2D();
    GlStateManager.tryBlendFuncSeparate(770, 1, 1, 0);
    GlStateManager.pushMatrix();
    float f16 = 1.0F - Minecraft.getMinecraft().world.getRainStrength(partialTicks);
    GlStateManager.color(1.0F, 1.0F, 1.0F, f16);
    GlStateManager.rotate(-90.0F, 0.0F, 1.0F, 0.0F);
    GlStateManager.rotate(Minecraft.getMinecraft().world.getCelestialAngle(partialTicks) * 360.0F, 1.0F, 0.0F,
            0.0F);
    float f17 = 30.0F;
    Minecraft.getMinecraft().renderEngine.bindTexture(MC_DEF_SUN_PNG);
    vb.begin(7, DefaultVertexFormats.POSITION_TEX);
    vb.pos((double) (-f17), 100.0D, (double) (-f17)).tex(0.0D, 0.0D).endVertex();
    vb.pos((double) f17, 100.0D, (double) (-f17)).tex(1.0D, 0.0D).endVertex();
    vb.pos((double) f17, 100.0D, (double) f17).tex(1.0D, 1.0D).endVertex();
    vb.pos((double) (-f17), 100.0D, (double) f17).tex(0.0D, 1.0D).endVertex();
    tessellator.draw();
    f17 = 20.0F;
    Minecraft.getMinecraft().renderEngine.bindTexture(MC_DEF_MOON_PHASES_PNG);
    int i = Minecraft.getMinecraft().world.getMoonPhase();
    int k = i % 4;
    int i1 = i / 4 % 2;
    float f22 = (float) (k) / 4.0F;
    float f23 = (float) (i1) / 2.0F;
    float f24 = (float) (k + 1) / 4.0F;
    float f14 = (float) (i1 + 1) / 2.0F;
    vb.begin(7, DefaultVertexFormats.POSITION_TEX);
    vb.pos((double) (-f17), -100.0D, (double) f17).tex((double) f24, (double) f14).endVertex();
    vb.pos((double) f17, -100.0D, (double) f17).tex((double) f22, (double) f14).endVertex();
    vb.pos((double) f17, -100.0D, (double) (-f17)).tex((double) f22, (double) f23).endVertex();
    vb.pos((double) (-f17), -100.0D, (double) (-f17)).tex((double) f24, (double) f23).endVertex();
    tessellator.draw();
    GlStateManager.disableTexture2D();
    float f15 = Minecraft.getMinecraft().world.getStarBrightness(partialTicks) * f16;

    if (f15 > 0.0F) {
        GlStateManager.color(f15, f15, f15, f15);

        if (OpenGlHelper.useVbo()) {
            starVBO.bindBuffer();
            GL11.glEnableClientState(GL11.GL_VERTEX_ARRAY);
            GL11.glVertexPointer(3, GL11.GL_FLOAT, 12, 0L);
            starVBO.drawArrays(7);
            starVBO.unbindBuffer();
            GL11.glDisableClientState(GL11.GL_VERTEX_ARRAY);
        } else {
            GlStateManager.callList(starGLCallList);
        }
    }

    GlStateManager.color(1.0F, 1.0F, 1.0F, 1.0F);
    GlStateManager.disableBlend();
    GlStateManager.enableAlpha();
    GlStateManager.enableFog();
    GlStateManager.popMatrix();
    GlStateManager.disableTexture2D();
    GlStateManager.color(0.0F, 0.0F, 0.0F);
    double d0 = Minecraft.getMinecraft().player.getPositionEyes(partialTicks).yCoord
            - Minecraft.getMinecraft().world.getHorizon();

    if (d0 < 0.0D) {
        GlStateManager.pushMatrix();
        GlStateManager.translate(0.0F, 12.0F, 0.0F);

        if (OpenGlHelper.useVbo()) {
            sky2VBO.bindBuffer();
            GL11.glEnableClientState(GL11.GL_VERTEX_ARRAY);
            GL11.glVertexPointer(3, GL11.GL_FLOAT, 12, 0L);
            sky2VBO.drawArrays(7);
            sky2VBO.unbindBuffer();
            GL11.glDisableClientState(GL11.GL_VERTEX_ARRAY);
        } else {
            GlStateManager.callList(glSkyList2);
        }

        GlStateManager.popMatrix();
        //float f18 = 1.0F;
        float f19 = -((float) (d0 + 65.0D));
        //float f20 = -1.0F;
        vb.begin(7, DefaultVertexFormats.POSITION_COLOR);
        vb.pos(-1.0D, (double) f19, 1.0D).color(0, 0, 0, 255).endVertex();
        vb.pos(1.0D, (double) f19, 1.0D).color(0, 0, 0, 255).endVertex();
        vb.pos(1.0D, -1.0D, 1.0D).color(0, 0, 0, 255).endVertex();
        vb.pos(-1.0D, -1.0D, 1.0D).color(0, 0, 0, 255).endVertex();
        vb.pos(-1.0D, -1.0D, -1.0D).color(0, 0, 0, 255).endVertex();
        vb.pos(1.0D, -1.0D, -1.0D).color(0, 0, 0, 255).endVertex();
        vb.pos(1.0D, (double) f19, -1.0D).color(0, 0, 0, 255).endVertex();
        vb.pos(-1.0D, (double) f19, -1.0D).color(0, 0, 0, 255).endVertex();
        vb.pos(1.0D, -1.0D, -1.0D).color(0, 0, 0, 255).endVertex();
        vb.pos(1.0D, -1.0D, 1.0D).color(0, 0, 0, 255).endVertex();
        vb.pos(1.0D, (double) f19, 1.0D).color(0, 0, 0, 255).endVertex();
        vb.pos(1.0D, (double) f19, -1.0D).color(0, 0, 0, 255).endVertex();
        vb.pos(-1.0D, (double) f19, -1.0D).color(0, 0, 0, 255).endVertex();
        vb.pos(-1.0D, (double) f19, 1.0D).color(0, 0, 0, 255).endVertex();
        vb.pos(-1.0D, -1.0D, 1.0D).color(0, 0, 0, 255).endVertex();
        vb.pos(-1.0D, -1.0D, -1.0D).color(0, 0, 0, 255).endVertex();
        vb.pos(-1.0D, -1.0D, -1.0D).color(0, 0, 0, 255).endVertex();
        vb.pos(-1.0D, -1.0D, 1.0D).color(0, 0, 0, 255).endVertex();
        vb.pos(1.0D, -1.0D, 1.0D).color(0, 0, 0, 255).endVertex();
        vb.pos(1.0D, -1.0D, -1.0D).color(0, 0, 0, 255).endVertex();
        tessellator.draw();
    }

    if (Minecraft.getMinecraft().world.provider.isSkyColored()) {
        GlStateManager.color(f * 0.2F + 0.04F, f1 * 0.2F + 0.04F, f2 * 0.6F + 0.1F);
    } else {
        GlStateManager.color(f, f1, f2);
    }

    GlStateManager.pushMatrix();
    GlStateManager.translate(0.0F, -((float) (d0 - 16.0D)), 0.0F);
    GlStateManager.callList(glSkyList2);
    GlStateManager.popMatrix();
    GlStateManager.enableTexture2D();
    GlStateManager.depthMask(true);
}

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

License:Open Source License

/**
 * Setup OpenGL to render dots.//ww  w  . j  a  v a2 s  .  com
 */
public void enableDrawDot() {
    if (currentMode != MODE_DRAWDOT) {
        disableLast();
        final int quality = Graphics.getInstance().getQuality();
        if (quality >= Graphics.QUALITY_NORMAL) {
            GL11.glEnable(GL11.GL_POINT_SMOOTH);
            if (quality >= Graphics.QUALITY_HIGH) {
                GL11.glHint(GL11.GL_POINT_SMOOTH_HINT, GL11.GL_NICEST);
            } else {
                GL11.glHint(GL11.GL_POINT_SMOOTH_HINT, GL11.GL_FASTEST);
            }
        } else {
            GL11.glDisable(GL11.GL_POINT_SMOOTH);
        }
        GL11.glEnableClientState(GL11.GL_VERTEX_ARRAY);
        currentMode = MODE_DRAWDOT;
    }
}

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

License:Open Source License

/**
 * Setup OpenGL to render lines./* ww  w. j  av a  2  s  .  c  o m*/
 */
public void enableDrawLine() {
    if (currentMode != MODE_DRAWLINE) {
        disableLast();
        final int quality = Graphics.getInstance().getQuality();
        if (quality >= Graphics.QUALITY_NORMAL) {
            GL11.glEnable(GL11.GL_LINE_SMOOTH);
            if (quality >= Graphics.QUALITY_HIGH) {
                GL11.glHint(GL11.GL_LINE_SMOOTH_HINT, GL11.GL_NICEST);
            } else {
                GL11.glHint(GL11.GL_LINE_SMOOTH_HINT, GL11.GL_FASTEST);
            }
        } else {
            GL11.glDisable(GL11.GL_LINE_SMOOTH);
        }
        GL11.glEnableClientState(GL11.GL_VERTEX_ARRAY);
        currentMode = MODE_DRAWLINE;
    }
}

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

License:Open Source License

/**
 * Setup OpenGL to render something generic.
 *//* w w  w  .  j a v a  2  s  . co m*/
public void enableDrawOther() {
    if (currentMode != MODE_DRAWOTHER) {
        disableLast();
        GL11.glEnableClientState(GL11.GL_VERTEX_ARRAY);
        currentMode = MODE_DRAWOTHER;
    }
}

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

License:Open Source License

/**
 * Setup OpenGL to render polygons./*from w  ww  . j av  a 2s  .  co m*/
 */
public void enableDrawPoly() {
    if (currentMode != MODE_DRAWPOLY) {
        disableLast();
        final int quality = Graphics.getInstance().getQuality();
        if (quality == Graphics.QUALITY_MAX) {
            GL11.glEnable(GL11.GL_POLYGON_SMOOTH);
            GL11.glHint(GL11.GL_POLYGON_SMOOTH_HINT, GL11.GL_NICEST);
        } else {
            GL11.glDisable(GL11.GL_POLYGON_SMOOTH);
        }
        GL11.glEnableClientState(GL11.GL_VERTEX_ARRAY);
        currentMode = MODE_DRAWPOLY;
    }
}

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

License:Open Source License

/**
 * Setup OpenGL to render a texture by using texture pointers.
 * /*from   ww w .  ja  v  a2  s.  co  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;
}

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

License:Open Source License

/**
 * Disable the last activated mode.//from w  w  w .  ja  v a2  s .c om
 */
private void disableLast() {
    if (currentMode == MODE_TEXTURE) {
        GL11.glDisable(GL11.GL_TEXTURE_2D);
    } else if (currentMode == MODE_TEXTUREPOINTER) {
        GL11.glDisable(GL11.GL_TEXTURE_2D);
        GL11.glDisableClientState(GL11.GL_VERTEX_ARRAY);
        GL11.glDisableClientState(GL11.GL_TEXTURE_COORD_ARRAY);
    } else if (currentMode == MODE_DRAWDOT) {
        GL11.glDisable(GL11.GL_POINT_SMOOTH);
        GL11.glDisableClientState(GL11.GL_VERTEX_ARRAY);
    } else if (currentMode == MODE_DRAWLINE) {
        GL11.glDisable(GL11.GL_LINE_SMOOTH);
        GL11.glDisableClientState(GL11.GL_VERTEX_ARRAY);
    } else if (currentMode == MODE_DRAWPOLY) {
        GL11.glDisable(GL11.GL_POLYGON_SMOOTH);
        GL11.glDisableClientState(GL11.GL_VERTEX_ARRAY);
    } else if (currentMode == MODE_DRAWPOLY) {
        GL11.glDisable(GL11.GL_POLYGON_SMOOTH);
        GL11.glDisableClientState(GL11.GL_VERTEX_ARRAY);
    }
}

From source file:im.bci.jnuit.lwjgl.sprite.SpriteBatcher.java

License:Open Source License

public void begin() {
    GL11.glEnableClientState(GL11.GL_VERTEX_ARRAY);
    GL11.glEnableClientState(GL11.GL_TEXTURE_COORD_ARRAY);
}

From source file:im.bci.jnuit.lwjgl.sprite.SpriteBatcher.java

License:Open Source License

public void end() {
    flush();
    GL11.glDisableClientState(GL11.GL_VERTEX_ARRAY);
    GL11.glDisableClientState(GL11.GL_TEXTURE_COORD_ARRAY);
}