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.lukke100.sbdi.Draw.java

License:Open Source License

static public void drawCircle(double xCoord, double yCoord, double radius, int segments) {
    GL11.glColor3d(red, green, blue);//from w ww. j av  a2  s  .c o m
    GL11.glBegin(GL11.GL_TRIANGLE_FAN);
    // GL11.glVertex2d(xCoord, yCoord);
    double deltaAngle = (2 * Math.PI) / segments;
    for (double angle = 0; angle < Math.PI * 2; angle += deltaAngle) {
        GL11.glVertex2d(xCoord + Math.cos(angle) * radius, yCoord + Math.sin(angle) * radius);
    }
    GL11.glEnd();
}

From source file:com.lukke100.sbdi.Draw.java

License:Open Source License

static public void drawHollowCircle(double xCoord, double yCoord, double radius, int segments) {
    GL11.glColor3d(red, green, blue);/*w  w w . jav a2 s .co  m*/
    double theta = (2 * Math.PI) / segments;
    double c = Math.cos(theta);
    double s = Math.sin(theta);
    double t;

    double x = radius; // start at angle = 0
    double y = 0;

    GL11.glBegin(GL11.GL_LINE_LOOP);
    for (int ii = 0; ii < segments; ii++) {
        GL11.glVertex2d(x + xCoord, y + yCoord); // output vertex

        // apply the rotation matrix
        t = x;
        x = c * x - s * y;
        y = s * t + c * y;
    }
    GL11.glEnd();
}

From source file:com.lukke100.sbdi.Draw.java

License:Open Source License

static public void drawHollowRectangle(double xCoord, double yCoord, double width, double height) {
    GL11.glColor3d(red, green, blue);/*from  w w w  . j  av  a  2  s .c  o  m*/
    width--;
    height--;
    GL11.glBegin(GL11.GL_LINE_LOOP);
    GL11.glVertex2d(xCoord, yCoord);
    GL11.glVertex2d(xCoord + width, yCoord);
    GL11.glVertex2d(xCoord + width, yCoord + height);
    GL11.glVertex2d(xCoord, yCoord + height);
    GL11.glEnd();
}

From source file:com.lukke100.sbdi.Draw.java

License:Open Source License

static public void drawHollowSquare(double xCoord, double yCoord, double size) {
    GL11.glColor3d(red, green, blue);/*from w  w w .  j  a v  a2  s.c  o  m*/
    size--;
    GL11.glBegin(GL11.GL_LINE_LOOP);
    GL11.glVertex2d(xCoord, yCoord);
    GL11.glVertex2d(xCoord + size, yCoord);
    GL11.glVertex2d(xCoord + size, yCoord + size);
    GL11.glVertex2d(xCoord, yCoord + size);
    GL11.glEnd();
}

From source file:com.lukke100.sbdi.Draw.java

License:Open Source License

static public void drawRectangle(double xCoord, double yCoord, double width, double height) {
    GL11.glColor3d(red, green, blue);/* ww  w .  j  a  v a 2 s .  c  om*/
    GL11.glBegin(GL11.GL_QUADS);
    GL11.glVertex2d(xCoord, yCoord);
    GL11.glVertex2d(xCoord + width, yCoord);
    GL11.glVertex2d(xCoord + width, yCoord + height);
    GL11.glVertex2d(xCoord, yCoord + height);
    GL11.glEnd();
}

From source file:com.lukke100.sbdi.Draw.java

License:Open Source License

static public void drawSquare(double xCoord, double yCoord, double size) {
    GL11.glColor3d(red, green, blue);//from   w ww .  j  ava2 s  . c o m
    GL11.glBegin(GL11.GL_QUADS);
    GL11.glVertex2d(xCoord, yCoord);
    GL11.glVertex2d(xCoord + size, yCoord);
    GL11.glVertex2d(xCoord + size, yCoord + size);
    GL11.glVertex2d(xCoord, yCoord + size);
    GL11.glEnd();
}

From source file:com.mrcrayfish.furniture.render.tileentity.BlenderRenderer.java

License:Open Source License

@Override
public void renderTileEntityAt(TileEntity tileEntity, double posX, double posY, double posZ, float p_180535_8_,
        int p_180535_9_) {
    TileEntityBlender blender = (TileEntityBlender) tileEntity;
    ItemStack[] ingredients = blender.getIngredients();

    GL11.glPushMatrix();/*from  ww w .  j  a v  a 2 s. co  m*/
    GL11.glTranslatef((float) posX + 0.5F, (float) posY + 0.2F, (float) posZ + 0.5F);
    GL11.glScalef(0.65F, 0.65F, 0.65F);
    entityFood.hoverStart = 0.0F;
    for (int i = 0; i < ingredients.length; i++) {
        if (ingredients[i] != null) {
            entityFood.setEntityItemStack(ingredients[i]);
            GL11.glRotatef(i * -90F, 0, 1, 0);
            GL11.glRotatef(blender.progress * 18F, 0, 1, 0);
            Minecraft.getMinecraft().getRenderManager().renderEntityWithPosYaw(entityFood, 0.0D, 0.2D, 0.0D,
                    0.0F, 0.0F);
        }
    }
    GL11.glPopMatrix();

    if (blender.isBlending() | blender.drinkCount > 0) {
        Tessellator tessellator = Tessellator.getInstance();
        GL11.glPushMatrix();
        GL11.glTranslatef((float) posX + 0.5F, (float) posY + 0.05F, (float) posZ + 0.5F);
        GL11.glAlphaFunc(GL11.GL_GREATER, 0.1F);
        GL11.glDisable(GL11.GL_CULL_FACE);
        GL11.glDisable(GL11.GL_TEXTURE_2D);
        GL11.glDisable(GL11.GL_LIGHTING);
        GL11.glBlendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA);
        GL11.glEnable(GL11.GL_BLEND);

        float alpha = blender.isBlending() ? (blender.progress / 200F) : (blender.drinkCount > 0 ? 1.0F : 0.0F);
        GL11.glColor4f(blender.currentRed / 255F, blender.currentGreen / 255F, blender.currentBlue / 255F,
                alpha);

        float height = blender.isBlending() ? 0.8F : (0.275F + (0.525F * (blender.drinkCount / 6F)));
        GL11.glBegin(GL11.GL_QUADS);

        // North Face
        GL11.glVertex3d(-0.2, 0.275, -0.2);
        GL11.glVertex3d(0.2, 0.275, -0.2);
        GL11.glVertex3d(0.2, height, -0.2);
        GL11.glVertex3d(-0.2, height, -0.2);

        // South Face
        GL11.glVertex3d(-0.2, 0.275, 0.2);
        GL11.glVertex3d(0.2, 0.275, 0.2);
        GL11.glVertex3d(0.2, height, 0.2);
        GL11.glVertex3d(-0.2, height, 0.2);

        // West Face
        GL11.glVertex3d(-0.2, 0.275, -0.2);
        GL11.glVertex3d(-0.2, 0.275, 0.2);
        GL11.glVertex3d(-0.2, height, 0.2);
        GL11.glVertex3d(-0.2, height, -0.2);

        // East Face
        GL11.glVertex3d(0.2, 0.275, -0.2);
        GL11.glVertex3d(0.2, 0.275, 0.2);
        GL11.glVertex3d(0.2, height, 0.2);
        GL11.glVertex3d(0.2, height, -0.2);

        // Top Face
        GL11.glVertex3d(-0.2, height, -0.2);
        GL11.glVertex3d(0.2, height, -0.2);
        GL11.glVertex3d(0.2, height, 0.2);
        GL11.glVertex3d(-0.2, height, 0.2);

        // Bottom Face
        GL11.glVertex3d(-0.2, 0.275, -0.2);
        GL11.glVertex3d(0.2, 0.275, -0.2);
        GL11.glVertex3d(0.2, 0.275, 0.2);
        GL11.glVertex3d(-0.2, 0.275, 0.2);

        GL11.glEnd();

        GL11.glDisable(GL11.GL_BLEND);
        GL11.glEnable(GL11.GL_LIGHTING);
        GL11.glEnable(GL11.GL_TEXTURE_2D);
        GL11.glAlphaFunc(GL11.GL_GREATER, 0.5F);

        GL11.glPopMatrix();
    }
}

From source file:com.mrcrayfish.furniture.render.tileentity.CupRenderer.java

License:Open Source License

@Override
public void renderTileEntityAt(TileEntity tileEntity, double posX, double posY, double posZ, float p_180535_8_,
        int p_180535_9_) {
    TileEntityCup tileEntityCup = (TileEntityCup) tileEntity;
    if (tileEntityCup.getDrink() != null) {
        Tessellator tessellator = Tessellator.getInstance();
        GL11.glPushMatrix();/*from  ww w.  j  a  va  2  s.  c om*/
        GL11.glTranslatef((float) posX + 0.5F, (float) posY, (float) posZ + 0.5F);
        GL11.glAlphaFunc(GL11.GL_GREATER, 0.1F);
        GL11.glDisable(GL11.GL_CULL_FACE);
        GL11.glDisable(GL11.GL_TEXTURE_2D);
        GL11.glDisable(GL11.GL_LIGHTING);
        GL11.glBlendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA);
        GL11.glEnable(GL11.GL_BLEND);

        GL11.glColor4f(tileEntityCup.red / 255F, tileEntityCup.green / 255F, tileEntityCup.blue / 255F, 1.0F);

        GL11.glBegin(GL11.GL_QUADS);

        // North Face
        GL11.glVertex3d(-0.125, 0.5 * 0.0625, -0.125);
        GL11.glVertex3d(0.125, 0.5 * 0.0625, -0.125);
        GL11.glVertex3d(0.125, 0.4, -0.125);
        GL11.glVertex3d(-0.125, 0.4, -0.125);

        // South Face
        GL11.glVertex3d(-0.125, 0.5 * 0.0625, 0.125);
        GL11.glVertex3d(0.125, 0.5 * 0.0625, 0.125);
        GL11.glVertex3d(0.125, 0.4, 0.125);
        GL11.glVertex3d(-0.125, 0.4, 0.125);

        // West Face
        GL11.glVertex3d(-0.125, 0.5 * 0.0625, -0.125);
        GL11.glVertex3d(-0.125, 0.5 * 0.0625, 0.125);
        GL11.glVertex3d(-0.125, 0.4, 0.125);
        GL11.glVertex3d(-0.125, 0.4, -0.125);

        // East Face
        GL11.glVertex3d(0.125, 0.5 * 0.0625, -0.125);
        GL11.glVertex3d(0.125, 0.5 * 0.0625, 0.125);
        GL11.glVertex3d(0.125, 0.4, 0.125);
        GL11.glVertex3d(0.125, 0.4, -0.125);

        // Top Face
        GL11.glVertex3d(-0.125, 0.4, -0.125);
        GL11.glVertex3d(0.125, 0.4, -0.125);
        GL11.glVertex3d(0.125, 0.4, 0.125);
        GL11.glVertex3d(-0.125, 0.4, 0.125);

        // Bottom Face
        GL11.glVertex3d(-0.125, 0.5 * 0.0625, -0.125);
        GL11.glVertex3d(0.125, 0.5 * 0.0625, -0.125);
        GL11.glVertex3d(0.125, 0.5 * 0.0625, 0.125);
        GL11.glVertex3d(-0.125, 0.5 * 0.0625, 0.125);

        GL11.glEnd();

        GL11.glDisable(GL11.GL_BLEND);
        GL11.glEnable(GL11.GL_LIGHTING);
        GL11.glEnable(GL11.GL_TEXTURE_2D);
        GL11.glAlphaFunc(GL11.GL_GREATER, 0.5F);

        GL11.glPopMatrix();
    }
}

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

License:LGPL

public void drawQuad() {
    // this func just draws a perfectly normal box with some texture coordinates
    GL11.glBegin(GL11.GL_QUADS);

    // Front Face
    GL11.glTexCoord2f(0.0f, 0.0f);//w  ww .  j  a  v a  2  s  . co m
    GL11.glVertex3f(-1.0f, -1.0f, 0.0f); // Bottom Left Of The Texture and Quad
    GL11.glTexCoord2f(1.0f, 0.0f);
    GL11.glVertex3f(1.0f, -1.0f, 0.0f); // Bottom Right Of The Texture and Quad
    GL11.glTexCoord2f(1.0f, 1.0f);
    GL11.glVertex3f(1.0f, 1.0f, 0.0f); // Top Right Of The Texture and Quad
    GL11.glTexCoord2f(0.0f, 1.0f);
    GL11.glVertex3f(-1.0f, 1.0f, 0.0f); // Top Left Of The Texture and Quad

    GL11.glEnd();
}

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

License:LGPL

public void drawLatencyTesterColoredQuad(float r, float g, float b, float a) {
    GL11.glDisable(GL11.GL_TEXTURE_2D);//from  w  w  w.  java2  s .  c  o  m
    GL11.glEnable(GL11.GL_BLEND);

    // Setup ortho projection
    GL11.glMatrixMode(GL11.GL_PROJECTION);
    GL11.glLoadIdentity();
    GL11.glMatrixMode(GL11.GL_MODELVIEW);
    GL11.glLoadIdentity();

    GL11.glTranslatef(0.0f, 0.0f, -0.7f);

    // Cover the appropriate areas of the screen with the colored quad
    GL11.glBegin(GL11.GL_QUADS);

    GL11.glColor4f(r, g, b, a);

    GL11.glVertex3f(-0.6f, -0.6f, 0.0f); // Bottom Left Of The Texture and Quad
    GL11.glVertex3f(0.6f, -0.6f, 0.0f); // Bottom Right Of The Texture and Quad
    GL11.glVertex3f(0.6f, 0.6f, 0.0f); // Top Right Of The Texture and Quad
    GL11.glVertex3f(-0.6f, 0.6f, 0.0f); // Top Left Of The Texture and Quad

    GL11.glEnd();

    GL11.glDisable(GL11.GL_BLEND);
    GL11.glEnable(GL11.GL_TEXTURE_2D);
}