Example usage for org.lwjgl.opengl GL11 glBegin

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

Introduction

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

Prototype

public static native void glBegin(@NativeType("GLenum") int mode);

Source Link

Document

Begins the definition of vertex attributes of a sequence of primitives to be transferred to the GL.

Usage

From source file:com.mtbs3d.minecrift.VRRenderer.java

License:LGPL

public void drawQuad2(float displayWidth, float displayHeight, float scale) {
    float aspect = displayHeight / displayWidth;

    GL11.glBegin(GL11.GL_QUADS);

    GL11.glTexCoord2f(0.0f, 0.0f);/*from  ww  w .  j a  v a2  s  . c  o  m*/
    GL11.glVertex3f(-1.0f * scale, -1.0f * aspect * scale, 0.0f); // Bottom Left  Of The Texture and Quad
    GL11.glTexCoord2f(1.0f, 0.0f);
    GL11.glVertex3f(1.0f * scale, -1.0f * aspect * scale, 0.0f); // Bottom Right Of The Texture and Quad
    GL11.glTexCoord2f(1.0f, 1.0f);
    GL11.glVertex3f(1.0f * scale, 1.0f * aspect * scale, 0.0f); // Top    Right Of The Texture and Quad
    GL11.glTexCoord2f(0.0f, 1.0f);
    GL11.glVertex3f(-1.0f * scale, 1.0f * aspect * scale, 0.0f); // Top    Left  Of The Texture and Quad

    GL11.glEnd();
}

From source file:com.ogrekill.textMessage.java

public void textMessage() {
    GL11.glBegin(GL11.GL_QUADS);
    GL11.glVertex2f(0, 0);
    GL11.glVertex2f(800, 0);
    GL11.glVertex2f(800, 200);
    GL11.glVertex2f(0, 200);
}

From source file:com.parachute.client.RenderParachute.java

License:Open Source License

public void renderLargeParachuteCords(EntityPlayer rider, float center) {
    float zOffset = 3.0F;
    float x = 0.0F;
    float y = 2.5F;
    if (Minecraft.getMinecraft().gameSettings.thirdPersonView == 0) { // first person view
        y = 1.5F;/*  w w w  .  jav a 2  s  .com*/
    }
    float zl = -zOffset;
    float zr = zOffset;

    float b = rider.getBrightness(center);

    GlStateManager.pushMatrix();
    GL11.glDisable(GL11.GL_TEXTURE_2D);
    GL11.glDisable(GL11.GL_LIGHTING);

    GlStateManager.scale(0.0625F, -1.0F, 0.0625F);

    GL11.glBegin(GL11.GL_LINES);
    // left end
    GlStateManager.color(b * 0.5F, b * 0.5F, b * 0.65F); // slightly blue

    GL11.glVertex3f(-8F, 0.37F, -31.5F); // top - front
    GL11.glVertex3f(x, y, zl); // bottom

    GL11.glVertex3f(8F, 0.37F, -31.5F); // ...back
    GL11.glVertex3f(x, y, zl);

    // left middle
    GL11.glVertex3f(-8F, 0.12F, -16F);
    GL11.glVertex3f(x, y, zl);

    GL11.glVertex3f(8F, 0.12F, -16F);
    GL11.glVertex3f(x, y, zl);

    // right end
    GlStateManager.color(b * 0.65F, b * 0.5F, b * 0.5F); // slightly red

    GL11.glVertex3f(-8F, 0.37F, 31.5F);
    GL11.glVertex3f(x, y, zr);

    GL11.glVertex3f(8F, 0.37F, 31.5F);
    GL11.glVertex3f(x, y, zr);

    // right middle
    GL11.glVertex3f(-8F, 0.12F, 16F);
    GL11.glVertex3f(x, y, zr);

    GL11.glVertex3f(8F, 0.12F, 16F);
    GL11.glVertex3f(x, y, zr);

    // center
    GlStateManager.color(b * 0.5F, b * 0.65F, b * 0.5F); // slightly green

    GL11.glVertex3f(-8F, 0F, 0F);
    GL11.glVertex3f(x, y, zl); // first center cord goes to the left 

    GL11.glVertex3f(8F, 0F, 0F);
    GL11.glVertex3f(x, y, zl);

    GL11.glVertex3f(-8F, 0F, 0F); // second center cord goes to the right
    GL11.glVertex3f(x, y, zr);

    GL11.glVertex3f(8F, 0F, 0F);
    GL11.glVertex3f(x, y, zr);

    GL11.glEnd();

    GL11.glEnable(GL11.GL_LIGHTING);
    GL11.glEnable(GL11.GL_TEXTURE_2D);
    GlStateManager.popMatrix();
}

From source file:com.parachute.client.RenderParachute.java

License:Open Source License

public void renderSmallParachuteCords(EntityPlayer rider, float center) {
    float zOffset = 3.0F;
    float x = 0.0F;
    float y = 1.5F;
    if (Minecraft.getMinecraft().gameSettings.thirdPersonView == 0) { // first person view
        y = 1.25F;/*from w ww  .  ja  v a 2  s  .  c o m*/
    }
    float zl = -zOffset;
    float zr = zOffset;

    float b = rider.getBrightness(center);

    GlStateManager.pushMatrix();
    GL11.glDisable(GL11.GL_TEXTURE_2D);
    GL11.glDisable(GL11.GL_LIGHTING);

    GlStateManager.scale(0.0625F, -1.0F, 0.0625F);

    GL11.glBegin(GL11.GL_LINES);
    // left side
    GlStateManager.color(b * 0.5F, b * 0.5F, b * 0.65F); // slightly blue

    GL11.glVertex3f(-8F, 0.25F, -23.5F);
    GL11.glVertex3f(x, y, zl);

    GL11.glVertex3f(8F, 0.25F, -23.5F);
    GL11.glVertex3f(x, y, zl);

    // front
    GL11.glVertex3f(-8F, 0F, -8F);
    GL11.glVertex3f(x, y, zl);

    GL11.glVertex3f(8F, 0F, -8F);
    GL11.glVertex3f(x, y, zl);

    // right side
    GlStateManager.color(b * 0.65F, b * 0.5F, b * 0.5F); // slightly red

    GL11.glVertex3f(-8F, 0.25F, 23.5F);
    GL11.glVertex3f(x, y, zr);

    GL11.glVertex3f(8F, 0.25F, 23.5F);
    GL11.glVertex3f(x, y, zr);

    // back
    GL11.glVertex3f(-8F, 0F, 8F);
    GL11.glVertex3f(x, y, zr);

    GL11.glVertex3f(8F, 0F, 8F);
    GL11.glVertex3f(x, y, zr);
    GL11.glEnd();

    GL11.glEnable(GL11.GL_LIGHTING);
    GL11.glEnable(GL11.GL_TEXTURE_2D);
    GlStateManager.popMatrix();
}

From source file:com.runescape.client.revised.editor.modelviewer.Generator.java

License:Open Source License

public void draw() {
    GL11.glBegin(GL11.GL_QUADS);
    for (int i = 0; i < this.particleCount; i++) {
        if (this.particles[i] != null) {
            GL11.glTexImage2D(GL11.GL_TEXTURE_2D, 0, GL11.GL_RGBA, this.decParticle.getWidth(),
                    this.decParticle.getHeight(), 0, GL11.GL_RGBA, GL11.GL_UNSIGNED_BYTE, this.bufParticle);
            GL11.glBindTexture(GL11.GL_ADD, GL11.GL_LOAD);
            GL11.glBindTexture(GL11.GL_TEXTURE_2D, 1);
            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.glPushMatrix();//from   w ww.ja  v a 2s .c  o  m
            GL11.glTranslated(this.particles[i].x + (Main.getMain().getCanvas().getX() / 2),
                    this.particles[i].y + (Main.getMain().getCanvas().getY() / 2), 0);
            this.particles[i].draw();
            GL11.glPopMatrix();
        }
    }
    GL11.glEnd();
}

From source file:com.runescape.client.revised.editor.modelviewer.Model3D.java

License:Open Source License

public void render(final float x, final float y, final float z, final float rx, final float ry, final float rz,
        final float sx, final float sy, final float sz) {
    GL11.glLoadIdentity();//from   ww  w .j  a va  2  s . c o m
    GL11.glTranslatef(x, y, z);
    GL11.glRotatef(rx, 1.0F, 0.0F, 0.0F);
    GL11.glRotatef(ry, 0.0F, 1.0F, 0.0F);
    GL11.glRotatef(rz, 0.0F, 0.0F, 1.0F);
    GL11.glScalef(sx, sy, sz);
    final short[] tri_x = this.triangle_viewspace_x;
    final short[] tri_y = this.triangle_viewspace_y;
    final short[] tri_z = this.triangle_viewspace_z;
    // final short[] tex_map_x = this.texture_map_x;
    // final short[] tex_map_y = this.texture_map_y;
    // final short[] tex_map_z = this.texture_map_z;
    final short[] textures = this.textures;
    final int[] vertices_x = this.vertices_x;
    final int[] vertices_y = this.vertices_y;
    final int[] vertices_z = this.vertices_z;
    final short[] colors = this.colors;
    final float model_scale = 4.0F;
    final float texture_scale = 1.0F;
    if (this.pointers != null) {
        //glEnable(GL_DEPTH_TEST);
        GL11.glEnable(GL11.GL_TEXTURE_2D);
        //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);
    }
    Texture texture = null;
    for (int triangle = 0; triangle != this.triangle_count; ++triangle) {
        if ((this.alpha != null) && (this.alpha[triangle] == -1)) {
            continue;
        }
        final int point_a = tri_x[triangle];
        final int point_b = tri_y[triangle];
        final int point_c = tri_z[triangle];
        final int color = Model.hsl2rgb[colors[triangle] & 0xffff];
        int triangle_type;
        if (this.face_fill_attributes == null) {
            triangle_type = 0;
        } else {
            triangle_type = this.face_fill_attributes[triangle] & 3;
        }
        if ((textures != null) && (textures[triangle] != -1)) {
            final int id = textures[triangle] & 0xffff;
            if (ModelConstants.ENABLE_MODEL_TEXTURES && ((texture == null) && (id != -1))) {
                texture = TextureCache.get(id);
            }
            if (texture != null) {
                texture.bind();
            }
        }
        final boolean textured = ModelConstants.ENABLE_MODEL_TEXTURES && (texture != null);
        GL11.glBegin(GL11.GL_TRIANGLES);
        GL11.glColor4ub((byte) (color >>> 16), (byte) (color >>> 8), (byte) color,
                (byte) (this.alpha == null ? 0xff : ~this.alpha[triangle]));
        switch (triangle_type) {
        case 0://shaded triangle
        case 1://flat triangle
            if (textured) {
                GL11.glTexCoord2f(0.0F, 0.0F);
            }
            GL11.glVertex3f(vertices_x[point_a] / model_scale, vertices_y[point_a] / model_scale,
                    vertices_z[point_a] / model_scale);
            if (textured) {
                GL11.glTexCoord2f(0.0F, texture_scale / model_scale);
            }
            GL11.glVertex3f(vertices_x[point_b] / model_scale, vertices_y[point_b] / model_scale,
                    vertices_z[point_b] / model_scale);
            if (textured) {
                GL11.glTexCoord2f(texture_scale / model_scale, texture_scale / model_scale);
            }
            GL11.glVertex3f(vertices_x[point_c] / model_scale, vertices_y[point_c] / model_scale,
                    vertices_z[point_c] / model_scale);
            break;
        case 2://textured?
        case 3://textured?
            final int ptr = this.face_fill_attributes[triangle] >> 2;
            final int tex_point_a = this.texture_map_x[ptr];
            final int tex_point_b = this.texture_map_y[ptr];
            final int tex_point_c = this.texture_map_z[ptr];
            GL11.glTexCoord2f(0.0F, 0.0F);
            GL11.glVertex3f(vertices_x[tex_point_a] / model_scale, vertices_y[tex_point_a] / model_scale,
                    vertices_z[tex_point_a] / model_scale);
            GL11.glTexCoord2f(0.0F, texture_scale / model_scale);
            GL11.glVertex3f(vertices_x[tex_point_b] / model_scale, vertices_y[tex_point_b] / model_scale,
                    vertices_z[tex_point_b] / model_scale);
            GL11.glTexCoord2f(texture_scale / model_scale, texture_scale / model_scale);
            GL11.glVertex3f(vertices_x[tex_point_c] / model_scale, vertices_y[tex_point_c] / model_scale,
                    vertices_z[tex_point_c] / model_scale);
            break;
        }
        GL11.glEnd();
    }
    if (texture != null) {
        GL11.glDisable(GL11.GL_TEXTURE_2D);
    }
}

From source file:com.rvantwisk.cnctools.controls.opengl.OpenGLRenderer.java

License:Open Source License

protected void drawAxis(float length) {
    GL11.glPushMatrix();//from ww  w.  j a va  2 s  .co  m
    this.viewModel.ui_transform(length + length / 2.0f);

    float[][] axis = { { length, 0.0f, 0.0f }, { 0.0f, -length, 0.0f }, { 0.0f, 0.0f, length } };
    float[][] colors = { { 1.0f, 0.0f, 0.0f }, { 0.0f, 1.0f, 0.0f }, { 0.0f, 0.5f, 1.0f } };
    String[] names = { "X", "Y", "Z" };

    GL11.glBegin(GL11.GL_LINES);
    for (int i = 0; i < 3; i++) {
        GL11.glColor3f(colors[i][0], colors[i][1], colors[i][2]);
        GL11.glVertex3f(0.0f, 0.0f, 0.0f);
        GL11.glVertex3f(axis[i][0], axis[i][1], axis[i][2]);
    }
    GL11.glEnd();

    // TODO optmize text rendering, lack of glutBitmapCharacter forces me to do it differently.
    for (int i = 0; i < 3; i++) {
        GL11.glPushMatrix();
        GL11.glColor3f(colors[i][0], colors[i][1], colors[i][2]);

        // http://breadmilkbeercigarettes.com/bmbc/shelves/users/bbb/src/java/SpinningTextureCube.php
        GL11.glTranslatef(Math.round(axis[i][0]), Math.round(axis[i][1]), Math.round(axis[i][2]));
        GL11.glRotatef(camera.getElevation() + 90f, 1.0f, 0.0f, 0.0f);
        GL11.glRotatef(-camera.getAzimuth(), 0.0f, 1.0f, 0.0f);
        SimpleText.drawString(names[i], 0.0f, 0.0f, 0.0f);

        //            GL11.glRasterPos3f(Math.round(axis[i][0]), Math.round(axis[i][1]), Math.round(axis[i][2]));
        //            SimpleText.drawString(names[i], 0, 0);

        GL11.glPopMatrix();

    }

    GL11.glPopMatrix();
}

From source file:com.rvantwisk.cnctools.controls.opengl.PlatformActor.java

License:Open Source License

@Override
public void initialize() {

    display_list = GL11.glGenLists(1);// w ww  . j ava 2  s. co  m

    GL11.glNewList(display_list, GL11.GL_COMPILE);

    // draw the grid
    GL11.glBegin(GL11.GL_LINES);

    for (int i = xneg; i <= xpos; i += openNess) {
        setColor(i);
        GL11.glVertex3f(i, yneg, ZPOS);
        GL11.glVertex3f(i, ypos, ZPOS);
    }

    for (int i = yneg; i <= ypos; i += openNess) {
        setColor(i);
        GL11.glVertex3f(xneg, i, ZPOS);
        GL11.glVertex3f(xpos, i, ZPOS);
    }

    GL11.glColor4f(color_fill[0], color_fill[1], color_fill[2], color_fill[3]);
    GL11.glRectf(xneg, yneg, xpos, ypos);
    GL11.glEnd();

    GL11.glEndList();
}

From source file:com.samrj.devil.graphics.GraphicsUtil.java

public static void drawCircle(Vec2 pos, float radius, int segments, int mode) {
    float dt = 8.0f / segments;
    GL11.glBegin(mode);
    for (float t = 0.0f; t < 8.0f; t += dt)
        glVertex(Util.squareDir(t).normalize().mult(radius).add(pos));
    GL11.glEnd();/*from   w w  w.  j  a  v  a2s  .  c  om*/
}

From source file:com.samrj.devil.ui.Font.java

License:Open Source License

public void draw(String text, Vec2 pos, Vec2 align) {
    pos = new Vec2(pos.x, pos.y - cellHeight);
    align = new Vec2(align.x - 1.0f, -align.y - 1.0f).mult(0.5f);
    align.x *= getWidth(text);/*from www  .  j a  v  a2  s .  c om*/
    align.y *= -height;
    pos.add(align);

    GL11.glMatrixMode(GL11.GL_MODELVIEW);
    GL11.glPushMatrix();
    GL11.glTranslatef(Math.round(pos.x), Math.round(pos.y), 0.0f);

    float x0 = 0f;
    GL11.glEnable(GL11.GL_TEXTURE_2D);
    tex.bind();
    GL11.glBegin(GL11.GL_QUADS);
    for (int i = 0; i < text.length(); i++) {
        int charbits = text.charAt(i) - 32;
        int fontposx = charbits & 0xF;
        int fontposy = 15 - (charbits >> 4);
        float u0 = fontposx++ / 16f;
        float v0 = fontposy++ / 16f;
        float u1 = fontposx / 16f;
        float v1 = fontposy / 16f;

        float x1 = x0 + cellHeight;

        GL11.glTexCoord2f(u0, v0);
        GL11.glVertex2f(x0, 0f);
        GL11.glTexCoord2f(u0, v1);
        GL11.glVertex2f(x0, cellHeight);
        GL11.glTexCoord2f(u1, v1);
        GL11.glVertex2f(x1, cellHeight);
        GL11.glTexCoord2f(u1, v0);
        GL11.glVertex2f(x1, 0f);

        x0 += getWidth(text.charAt(i));
    }
    GL11.glEnd();
    GL11.glDisable(GL11.GL_TEXTURE_2D);

    GL11.glPopMatrix();
}