Example usage for org.lwjgl.opengl GL11 glEnd

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

Introduction

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

Prototype

public static native void glEnd();

Source Link

Document

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

Usage

From source file:com.darkcart.xdolf.util.RenderUtils.java

License:Open Source License

public static void drawCircle(float cx, float cy, float r, int num_segments, int c) {
    GL11.glScalef(0.5F, 0.5F, 0.5F);//from   w  w w.j  a  v  a  2  s  .c  o  m
    r *= 2;
    cx *= 2;
    cy *= 2;
    float f = (float) (c >> 24 & 0xff) / 255F;
    float f1 = (float) (c >> 16 & 0xff) / 255F;
    float f2 = (float) (c >> 8 & 0xff) / 255F;
    float f3 = (float) (c & 0xff) / 255F;
    float theta = (float) (2 * 3.1415926 / (num_segments));
    float p = (float) Math.cos(theta);//calculate the sine and cosine
    float s = (float) Math.sin(theta);
    float t;
    GL11.glColor4f(f1, f2, f3, f);
    float x = r;
    float y = 0;//start at angle = 0
    GL11.glEnable(3042);
    GL11.glDisable(3553);
    GL11.glEnable(GL11.GL_LINE_SMOOTH);
    GL11.glBlendFunc(770, 771);
    GL11.glBegin(GL11.GL_LINE_LOOP);
    for (int ii = 0; ii < num_segments; ii++) {
        GL11.glVertex2f(x + cx, y + cy);//final vertex vertex

        //rotate the stuff
        t = x;
        x = p * x - s * y;
        y = s * t + p * y;
    }
    GL11.glEnd();
    GL11.glEnable(3553);
    GL11.glDisable(3042);
    GL11.glDisable(GL11.GL_LINE_SMOOTH);
    GL11.glScalef(2F, 2F, 2F);
}

From source file:com.darkcart.xdolf.util.RenderUtils.java

License:Open Source License

public static void drawFullCircle(int cx, int cy, double r, int c) {
    GL11.glScalef(0.5F, 0.5F, 0.5F);/*w  ww . ja v a 2 s  . c  om*/
    r *= 2;
    cx *= 2;
    cy *= 2;
    float f = (float) (c >> 24 & 0xff) / 255F;
    float f1 = (float) (c >> 16 & 0xff) / 255F;
    float f2 = (float) (c >> 8 & 0xff) / 255F;
    float f3 = (float) (c & 0xff) / 255F;
    GL11.glEnable(3042);
    GL11.glDisable(3553);
    GL11.glEnable(GL11.GL_LINE_SMOOTH);
    GL11.glBlendFunc(770, 771);
    GL11.glColor4f(f1, f2, f3, f);
    GL11.glBegin(GL11.GL_TRIANGLE_FAN);
    for (int i = 0; i <= 360; i++) {
        double x = Math.sin((i * Math.PI / 180)) * r;
        double y = Math.cos((i * Math.PI / 180)) * r;
        GL11.glVertex2d(cx + x, cy + y);
    }
    GL11.glEnd();
    GL11.glDisable(GL11.GL_LINE_SMOOTH);
    GL11.glEnable(3553);
    GL11.glDisable(3042);
    GL11.glScalef(2F, 2F, 2F);
}

From source file:com.darkcart.xdolf.util.RenderUtils.java

License:Open Source License

public static void drawLogoutSpotTracer(LogoutSpot l) {
    try {/*from  www  .  j a v  a  2  s . c  o m*/
        GL11.glPushMatrix();
        GL11.glEnable(GL11.GL_LINE_SMOOTH);
        GL11.glDisable(GL11.GL_LIGHTING);
        GL11.glDisable(GL11.GL_DEPTH_TEST);
        GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F);
        GL11.glDisable(GL11.GL_TEXTURE_2D);
        GL11.glDepthMask(false);
        GL11.glBlendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA);
        GL11.glEnable(GL11.GL_BLEND);
        GL11.glLineWidth(1.5F);

        GL11.glColor3d(l.red, l.green, l.blue);
        GL11.glBegin(GL11.GL_LINE_LOOP);
        GL11.glVertex3d(0, 0, 0);
        GL11.glVertex3d(l.dX + 0.5, l.dY + 0.5, l.dZ + 0.5);
        GL11.glEnd();

        GL11.glDisable(GL11.GL_BLEND);
        GL11.glDepthMask(true);
        GL11.glEnable(GL11.GL_TEXTURE_2D);
        GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F);
        GL11.glEnable(GL11.GL_DEPTH_TEST);
        GL11.glEnable(GL11.GL_LIGHTING);
        GL11.glDisable(GL11.GL_LINE_SMOOTH);
        GL11.glPopMatrix();
    } catch (Exception e) {
    }
}

From source file:com.darkcart.xdolf.util.RenderUtils.java

License:Open Source License

public static void drawWayPointTracer(Waypoint w) {
    try {//from w  w  w  . j  av  a 2s.  c  om
        GL11.glPushMatrix();
        GL11.glEnable(GL11.GL_LINE_SMOOTH);
        GL11.glDisable(GL11.GL_LIGHTING);
        GL11.glDisable(GL11.GL_DEPTH_TEST);
        GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F);
        GL11.glDisable(GL11.GL_TEXTURE_2D);
        GL11.glDepthMask(false);
        GL11.glBlendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA);
        GL11.glEnable(GL11.GL_BLEND);
        GL11.glLineWidth(1.5F);
        GL11.glColor3d(w.red, w.green, w.blue);
        GL11.glBegin(GL11.GL_LINE_LOOP);
        Vec3d eyes = new Vec3d(0, 0, 1).rotatePitch(-(float) Math.toRadians(Wrapper.getPlayer().rotationPitch))
                .rotateYaw(-(float) Math.toRadians(Wrapper.getPlayer().rotationYaw));

        GL11.glVertex3d(eyes.xCoord, Wrapper.getPlayer().getEyeHeight() + eyes.yCoord, eyes.zCoord);
        GL11.glVertex3d(w.dX + 0.5, w.dY + 0.5, w.dZ + 0.5);
        GL11.glEnd();

        GL11.glDisable(GL11.GL_BLEND);
        GL11.glDepthMask(true);
        GL11.glEnable(GL11.GL_TEXTURE_2D);
        GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F);
        GL11.glEnable(GL11.GL_DEPTH_TEST);
        GL11.glEnable(GL11.GL_LIGHTING);
        GL11.glDisable(GL11.GL_LINE_SMOOTH);
        GL11.glPopMatrix();
    } catch (Exception e) {
    }
}

From source file:com.dbi.games.fortress.engine.graphics.Sprite.java

public void draw(int x, int y) {
    if (tex == null)
        return;//from w ww. j a v a 2  s.  co m
    GL11.glPushMatrix();

    tex.bind();
    GL11.glTranslatef(x, y, 0);

    GL11.glBegin(GL11.GL_QUADS);
    {
        GL11.glTexCoord2f(0, 0);
        GL11.glVertex2f(0, 0);

        GL11.glTexCoord2f(0, 1f);
        GL11.glVertex2f(0, getHeight());

        GL11.glTexCoord2f(1f, 1f);
        GL11.glVertex2f(getWidth(), getHeight());

        GL11.glTexCoord2f(1f, 0);
        GL11.glVertex2f(getWidth(), 0);

    }
    GL11.glEnd();

    GL11.glPopMatrix();
}

From source file:com.gameminers.ethereal.architect.ModelCanvas.java

License:Open Source License

@Override
protected void paintGL() {
    try {/*from   w w w .j  ava  2 s  .  c o  m*/
        if (getWidth() != current_width || getHeight() != current_height) {
            current_width = getWidth();
            current_height = getHeight();
            GL11.glViewport(0, 0, current_width, current_height);
        }
        GL11.glClearColor(0.0f, 0.6f, 0.5f, 1.0f);
        GL11.glClearDepth(1.0);
        GL11.glColor3f(1, 1, 1);
        GL11.glClear(GL11.GL_COLOR_BUFFER_BIT | GL11.GL_DEPTH_BUFFER_BIT);
        GL11.glMatrixMode(GL11.GL_PROJECTION);
        GL11.glEnable(GL11.GL_DEPTH_TEST);
        GL11.glDepthFunc(GL11.GL_LEQUAL);
        GL11.glLoadIdentity();
        GLU.gluPerspective(45.0f, (float) getWidth() / (float) getHeight(), 0.1f, 1000.0f);
        GL11.glHint(GL11.GL_PERSPECTIVE_CORRECTION_HINT, GL11.GL_NICEST);
        GL11.glMatrixMode(GL11.GL_MODELVIEW);
        GL11.glPushMatrix();
        GL11.glTranslatef(0, 0, zoom);
        GL11.glRotatef(angle, 0f, 1f, 0f);
        GL11.glRotatef(tilt, 1f, 0f, 0f);
        GL11.glTranslatef(-16, -16, -16);
        if (lit) {
            GL11.glEnable(GL11.GL_LIGHTING);
            GL11.glEnable(GL11.GL_LIGHT0);
            GL11.glLight(GL11.GL_LIGHT0, GL11.GL_POSITION, lightPosition);
            GL11.glLight(GL11.GL_LIGHT0, GL11.GL_AMBIENT, lightAmbient);
        } else {
            GL11.glDisable(GL11.GL_LIGHTING);
        }
        if (textured) {
            GL11.glEnable(GL11.GL_TEXTURE_2D);
        } else {
            GL11.glDisable(GL11.GL_TEXTURE_2D);
        }
        if (model != null) {
            if (model.isAmbientOcclusionEnabled()) {
                GL11.glShadeModel(GL11.GL_SMOOTH);
            } else {
                GL11.glShadeModel(GL11.GL_FLAT);
            }
            for (ModelElement ele : model.getElements()) {
                GL11.glPushMatrix();
                if (ele.isShade()) {
                    GL11.glEnable(GL11.GL_LIGHTING);
                } else {
                    GL11.glDisable(GL11.GL_LIGHTING);
                }
                float fromX = ele.getFrom()[0];
                float fromY = ele.getFrom()[1];
                float fromZ = ele.getFrom()[2];
                float toX = ele.getTo()[0];
                float toY = ele.getTo()[1];
                float toZ = ele.getTo()[2];

                float fX = (fromX > toX ? fromX : toX);
                float fY = (fromY > toY ? fromY : toY);
                float fZ = (fromZ > toZ ? fromZ : toZ);
                float tX = (fromX > toX ? toX : fromX);
                float tY = (fromY > toY ? toY : fromY);
                float tZ = (fromZ > toZ ? toZ : fromZ);

                GL11.glTranslatef(fX, fY, fZ);
                float scaleX = tX - fX;
                float scaleY = tY - fY;
                float scaleZ = tZ - fZ;
                GL11.glBegin(GL11.GL_QUADS);
                GL11.glNormal3f(0, 0, -1f);
                for (int i = 0; i < vertices.length / 3; i++) {
                    int faceIdx = i / 4;
                    ModelFace face;
                    switch (faceIdx) {
                    case 0:
                        face = ele.getFaces().getNorth();
                        break;
                    case 1:
                        face = ele.getFaces().getSouth();
                        break;
                    case 2:
                        face = ele.getFaces().getUp();
                        break;
                    case 3:
                        face = ele.getFaces().getDown();
                        break;
                    case 4:
                        face = ele.getFaces().getWest();
                        break;
                    case 5:
                        face = ele.getFaces().getEast();
                        break;
                    default:
                        face = null;
                        break;
                    }
                    int idx = i * 3;
                    float vX = vertices[idx] * scaleX;
                    float vY = vertices[idx + 1] * scaleY;
                    float vZ = vertices[idx + 2] * scaleZ;
                    /*float u;
                    float v;
                    GL11.glTexCoord2f(u, v);*/
                    GL11.glVertex3f(vX, vY, vZ);
                }
                GL11.glEnd();
                GL11.glPopMatrix();
            }
        }
        GL11.glPopMatrix();
        swapBuffers();
        repaint();
    } catch (LWJGLException e) {
        throw new RuntimeException(e);
    }
}

From source file:com.gameminers.mav.render.Rendering.java

License:Open Source License

public static void drawPolygon(float x, float y, float radius, float r, float g, float b, float a, int count,
        float z) {
    GL11.glPushMatrix();//from w  w w  . ja  va 2s .  c om
    GL11.glDisable(GL11.GL_TEXTURE_2D);
    GL11.glTranslatef(x, y, z);
    GL11.glColor4f(r, g, b, a);
    GL11.glBegin(GL11.GL_POLYGON);
    for (int i = 0; i < count; ++i) {
        GL11.glVertex2d(Math.sin(i / ((double) count) * 2 * Math.PI) * (radius),
                Math.cos(i / ((double) count) * 2 * Math.PI) * (radius));
    }
    GL11.glEnd();
    GL11.glEnable(GL11.GL_TEXTURE_2D);
    GL11.glPopMatrix();
}

From source file:com.gameminers.mav.render.Rendering.java

License:Open Source License

public static void drawTriangle(float x, float y, float radius, float r, float g, float b, float a, float z) {
    GL11.glPushMatrix();// ww  w .  j a va  2  s  .  c  o  m
    GL11.glDisable(GL11.GL_TEXTURE_2D);
    GL11.glTranslatef(x, y, z);
    GL11.glColor4f(r, g, b, a);
    GL11.glBegin(GL11.GL_TRIANGLES);
    for (int i = 0; i < 3; ++i) {
        GL11.glVertex2d(Math.sin(i / ((double) 3) * 2 * Math.PI) * (radius),
                Math.cos(i / 3D * 2 * Math.PI) * (radius));
    }
    GL11.glEnd();
    GL11.glEnable(GL11.GL_TEXTURE_2D);
    GL11.glPopMatrix();
}

From source file:com.gameminers.mav.render.Rendering.java

License:Open Source License

public static void drawRectangle(float x, float y, float width, float height, float r, float g, float b,
        float a, float z) {
    GL11.glPushMatrix();//from w  w  w  .ja va 2  s.co m
    GL11.glDisable(GL11.GL_TEXTURE_2D);
    GL11.glTranslatef(0, 0, z);
    GL11.glColor4f(r, g, b, a);
    GL11.glBegin(GL11.GL_QUADS);
    GL11.glVertex2f(x, y);
    GL11.glVertex2f(x + width, y);
    GL11.glVertex2f(x + width, y + height);
    GL11.glVertex2f(x, y + height);
    GL11.glEnd();
    GL11.glEnable(GL11.GL_TEXTURE_2D);
    GL11.glPopMatrix();
}

From source file:com.github.begla.blockmania.blocks.Block.java

License:Apache License

/**
 * Generates the display list used for rendering the block.
 *
 * @return The id of the display list//from w  w w  .j  a  va2  s  .c  o  m
 */
private int generateDisplayList() {
    int id = glGenLists(1);

    glNewList(id, GL11.GL_COMPILE);
    glBegin(GL_QUADS);
    GL11.glColor3f(1.0f, 1.0f, 1.0f);

    // TOP
    GL11.glTexCoord2f(calcTextureOffsetFor(SIDE.TOP).x, calcTextureOffsetFor(SIDE.TOP).y);
    GL11.glVertex3f(-0.5f, 0.5f, 0.5f);
    GL11.glTexCoord2f(calcTextureOffsetFor(SIDE.TOP).x + 0.0624f, calcTextureOffsetFor(SIDE.TOP).y);
    GL11.glVertex3f(0.5f, 0.5f, 0.5f);
    GL11.glTexCoord2f(calcTextureOffsetFor(SIDE.TOP).x + 0.0624f, calcTextureOffsetFor(SIDE.TOP).y + 0.0624f);
    GL11.glVertex3f(0.5f, 0.5f, -0.5f);
    GL11.glTexCoord2f(calcTextureOffsetFor(SIDE.TOP).x, calcTextureOffsetFor(SIDE.TOP).y + 0.0624f);
    GL11.glVertex3f(-0.5f, 0.5f, -0.5f);

    // LEFT
    GL11.glTexCoord2f(calcTextureOffsetFor(SIDE.LEFT).x, calcTextureOffsetFor(SIDE.LEFT).y + 0.0624f);
    GL11.glVertex3f(-0.5f, -0.5f, -0.5f);
    GL11.glTexCoord2f(calcTextureOffsetFor(SIDE.LEFT).x + 0.0624f, calcTextureOffsetFor(SIDE.LEFT).y + 0.0624f);
    GL11.glVertex3f(-0.5f, -0.5f, 0.5f);
    GL11.glTexCoord2f(calcTextureOffsetFor(SIDE.LEFT).x + 0.0624f, calcTextureOffsetFor(SIDE.LEFT).y);
    GL11.glVertex3f(-0.5f, 0.5f, 0.5f);
    GL11.glTexCoord2f(calcTextureOffsetFor(SIDE.LEFT).x, calcTextureOffsetFor(SIDE.LEFT).y);
    GL11.glVertex3f(-0.5f, 0.5f, -0.5f);

    // BACK
    GL11.glTexCoord2f(calcTextureOffsetFor(SIDE.BACK).x, calcTextureOffsetFor(SIDE.BACK).y + 0.0624f);
    GL11.glVertex3f(-0.5f, -0.5f, 0.5f);
    GL11.glTexCoord2f(calcTextureOffsetFor(SIDE.BACK).x + 0.0624f, calcTextureOffsetFor(SIDE.BACK).y + 0.0624f);
    GL11.glVertex3f(0.5f, -0.5f, 0.5f);
    GL11.glTexCoord2f(calcTextureOffsetFor(SIDE.BACK).x + 0.0624f, calcTextureOffsetFor(SIDE.BACK).y);
    GL11.glVertex3f(0.5f, 0.5f, 0.5f);
    GL11.glTexCoord2f(calcTextureOffsetFor(SIDE.BACK).x, calcTextureOffsetFor(SIDE.BACK).y);
    GL11.glVertex3f(-0.5f, 0.5f, 0.5f);

    // RIGHT
    GL11.glTexCoord2f(calcTextureOffsetFor(SIDE.RIGHT).x, calcTextureOffsetFor(SIDE.RIGHT).y);
    GL11.glVertex3f(0.5f, 0.5f, -0.5f);
    GL11.glTexCoord2f(calcTextureOffsetFor(SIDE.RIGHT).x + 0.0624f, calcTextureOffsetFor(SIDE.RIGHT).y);
    GL11.glVertex3f(0.5f, 0.5f, 0.5f);
    GL11.glTexCoord2f(calcTextureOffsetFor(SIDE.RIGHT).x + 0.0624f,
            calcTextureOffsetFor(SIDE.RIGHT).y + 0.0624f);
    GL11.glVertex3f(0.5f, -0.5f, 0.5f);
    GL11.glTexCoord2f(calcTextureOffsetFor(SIDE.RIGHT).x, calcTextureOffsetFor(SIDE.RIGHT).y + 0.0624f);
    GL11.glVertex3f(0.5f, -0.5f, -0.5f);

    GL11.glColor3f(0.5f, 0.5f, 0.5f);

    // FRONT
    GL11.glTexCoord2f(calcTextureOffsetFor(SIDE.FRONT).x, calcTextureOffsetFor(SIDE.FRONT).y);
    GL11.glVertex3f(-0.5f, 0.5f, -0.5f);
    GL11.glTexCoord2f(calcTextureOffsetFor(SIDE.FRONT).x + 0.0624f, calcTextureOffsetFor(SIDE.FRONT).y);
    GL11.glVertex3f(0.5f, 0.5f, -0.5f);
    GL11.glTexCoord2f(calcTextureOffsetFor(SIDE.FRONT).x + 0.0624f,
            calcTextureOffsetFor(SIDE.FRONT).y + 0.0624f);
    GL11.glVertex3f(0.5f, -0.5f, -0.5f);
    GL11.glTexCoord2f(calcTextureOffsetFor(SIDE.FRONT).x, calcTextureOffsetFor(SIDE.FRONT).y + 0.0624f);
    GL11.glVertex3f(-0.5f, -0.5f, -0.5f);
    // BOTTOM
    GL11.glTexCoord2f(calcTextureOffsetFor(SIDE.BOTTOM).x, calcTextureOffsetFor(SIDE.BOTTOM).y);
    GL11.glVertex3f(-0.5f, -0.5f, -0.5f);
    GL11.glTexCoord2f(calcTextureOffsetFor(SIDE.BOTTOM).x + 0.0624f, calcTextureOffsetFor(SIDE.BOTTOM).y);
    GL11.glVertex3f(0.5f, -0.5f, -0.5f);
    GL11.glTexCoord2f(calcTextureOffsetFor(SIDE.BOTTOM).x + 0.0624f,
            calcTextureOffsetFor(SIDE.BOTTOM).y + 0.0624f);
    GL11.glVertex3f(0.5f, -0.5f, 0.5f);
    GL11.glTexCoord2f(calcTextureOffsetFor(SIDE.BOTTOM).x, calcTextureOffsetFor(SIDE.BOTTOM).y + 0.0624f);
    GL11.glVertex3f(-0.5f, -0.5f, 0.5f);

    GL11.glEnd();
    glEndList();

    return id;
}