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:fr.def.iss.vd2.lib_v3d.element.basemap.PolyBasemap.java

License:Open Source License

private void draw() {

    vertices.clear();/*from   w  ww. j  av a 2 s  .c o m*/
    stripVertexCount.clear();

    float dx = -(minX / 2 + maxX / 2) * innerScale;
    float dy = -(minY / 2 + maxY / 2) * innerScale;

    GL11.glPushMatrix();
    GL11.glTranslatef(dx, dy, 0);
    GL11.glScalef(innerScale, innerScale, innerScale);

    while (stripVertexCount.hasRemaining()) {
        int lineLenght = stripVertexCount.get();

        GL11.glBegin(GL11.GL_LINE_STRIP); // Draw line
        for (int j = 0; j < lineLenght; j++) {

            if (vertices.remaining() >= 2) {
                float x = vertices.get();
                float y = vertices.get();
                GL11.glVertex3f(x, y, 0.0f);
            } else {
                // we should log the problem, but this method is called too
                // often (each time GL redraws). We don't want to flood the
                // logs, so we just ignore the problem silently. The
                // correctness of the data should be done at load time.
            }
        }

        GL11.glEnd();

    }

    GL11.glPopMatrix();

}

From source file:fr.def.iss.vd2.lib_v3d.element.V3DBoundingBox.java

License:Open Source License

public void display() {

    if (showCenter) {
        GL11.glColor4f(centerColor.r, centerColor.g, centerColor.b, centerColor.a);
        GL11.glPointSize(4.0f);/*from w  w w  .  j  a va2  s.c o  m*/
        GL11.glBegin(GL11.GL_POINTS);

        GL11.glVertex3d(center.x, center.y, center.z);

        GL11.glEnd();
    }
    if (flat || size.z == 0) {
        displayFlat();
    } else {
        displayThick();
    }
}

From source file:fr.def.iss.vd2.lib_v3d.element.V3DBoundingBox.java

License:Open Source License

public void displayFlatLines() {
    float x0 = position.x - size.x / 2;
    float y0 = position.y - size.y / 2;
    float x1 = position.x + size.x / 2;
    float y1 = position.y + size.y / 2;

    GL11.glColor4f(lineColor.r, lineColor.g, lineColor.b, lineColor.a);
    GL11.glLineWidth(2.0f);/*from   w w w . j  ava 2s  . c o m*/
    GL11.glBegin(GL11.GL_LINE_LOOP);

    GL11.glVertex3d(x0, y1, 0);
    GL11.glVertex3d(x0, y0, 0);
    GL11.glVertex3d(x1, y0, 0);
    GL11.glVertex3d(x1, y1, 0);

    GL11.glEnd();
}

From source file:fr.def.iss.vd2.lib_v3d.element.V3DBoundingBox.java

License:Open Source License

public void displayFlatFaces() {
    float x0 = position.x - size.x / 2;
    float y0 = position.y - size.y / 2;
    float x1 = position.x + size.x / 2;
    float y1 = position.y + size.y / 2;
    GL11.glColor4f(faceColor.r, faceColor.g, faceColor.b, faceColor.a);
    GL11.glBegin(GL11.GL_QUADS);

    GL11.glVertex3d(x0, y1, 0);// w w  w .jav  a  2  s  . c  om
    GL11.glVertex3d(x0, y0, 0);
    GL11.glVertex3d(x1, y0, 0);
    GL11.glVertex3d(x1, y1, 0);

    GL11.glEnd();
}

From source file:fr.def.iss.vd2.lib_v3d.element.V3DBoundingBox.java

License:Open Source License

public void displayThickLines() {
    float x0 = position.x - size.x / 2;
    float x1 = position.x + size.x / 2;
    float y0 = position.y - size.y / 2;
    float y1 = position.y + size.y / 2;
    float z0 = position.z - size.z / 2;
    float z1 = position.z + size.z / 2;

    GL11.glColor4f(lineColor.r, lineColor.g, lineColor.b, lineColor.a);
    GL11.glLineWidth(2.0f);//  www .  j a  v  a2s  .  c om
    GL11.glBegin(GL11.GL_LINE_LOOP);

    GL11.glVertex3d(x0, y0, z1);
    GL11.glVertex3d(x0, y1, z1);
    GL11.glVertex3d(x1, y1, z1);
    GL11.glVertex3d(x1, y0, z1);

    GL11.glEnd();

    GL11.glBegin(GL11.GL_LINE_LOOP);

    GL11.glVertex3d(x0, y1, z0);
    GL11.glVertex3d(x0, y0, z0);
    GL11.glVertex3d(x1, y0, z0);
    GL11.glVertex3d(x1, y1, z0);

    GL11.glEnd();

    GL11.glBegin(GL11.GL_LINES);

    GL11.glVertex3d(x0, y1, z1);
    GL11.glVertex3d(x0, y1, z0);
    GL11.glVertex3d(x0, y0, z1);
    GL11.glVertex3d(x0, y0, z0);
    GL11.glVertex3d(x1, y0, z1);
    GL11.glVertex3d(x1, y0, z0);
    GL11.glVertex3d(x1, y1, z1);
    GL11.glVertex3d(x1, y1, z0);

    GL11.glEnd();
}

From source file:fr.def.iss.vd2.lib_v3d.element.V3DBoundingBox.java

License:Open Source License

public void displayThickFaces() {
    float x0 = position.x - size.x / 2;
    float x1 = position.x + size.x / 2;
    float y0 = position.y - size.y / 2;
    float y1 = position.y + size.y / 2;
    float z0 = position.z - size.z / 2;
    float z1 = position.z + size.z / 2;

    GL11.glColor4f(faceColor.r, faceColor.g, faceColor.b, faceColor.a);
    GL11.glBegin(GL11.GL_QUADS);

    GL11.glVertex3d(x0, y0, z1);/*  w ww . j  a va  2 s  . c om*/
    GL11.glVertex3d(x0, y0, z0);
    GL11.glVertex3d(x1, y0, z0);
    GL11.glVertex3d(x1, y0, z1);

    GL11.glVertex3d(x0, y1, z1);
    GL11.glVertex3d(x0, y1, z0);
    GL11.glVertex3d(x0, y0, z0);
    GL11.glVertex3d(x0, y0, z1);

    GL11.glVertex3d(x1, y1, z1);
    GL11.glVertex3d(x1, y1, z0);
    GL11.glVertex3d(x0, y1, z0);
    GL11.glVertex3d(x0, y1, z1);

    GL11.glVertex3d(x1, y0, z1);
    GL11.glVertex3d(x1, y0, z0);
    GL11.glVertex3d(x1, y1, z0);
    GL11.glVertex3d(x1, y1, z1);

    GL11.glVertex3d(x0, y0, z0);
    GL11.glVertex3d(x0, y1, z0);
    GL11.glVertex3d(x1, y1, z0);
    GL11.glVertex3d(x1, y0, z0);

    GL11.glVertex3d(x0, y1, z1);
    GL11.glVertex3d(x0, y0, z1);
    GL11.glVertex3d(x1, y0, z1);
    GL11.glVertex3d(x1, y1, z1);

    GL11.glEnd();
}

From source file:fr.def.iss.vd2.lib_v3d.element.V3DBox.java

License:Open Source License

@Override
protected void doDisplay(I3dCamera camera) {
    float x0 = -size.x / 2;
    float x1 = size.x / 2;
    float y0 = -size.y / 2;
    float y1 = size.y / 2;
    float z0 = -size.z / 2;
    float z1 = size.z / 2;

    if (renderMode == RenderMode.PLAIN) {

        //GL11.glEnable(GL11.GL_LIGHTING);

        GL11.glBegin(GL11.GL_QUADS);

        GL11.glNormal3f(0, 1, 0);/*  ww w  . j  ava 2 s .c  om*/
        GL11.glVertex3d(x0, y0, z1);
        GL11.glVertex3d(x0, y0, z0);
        GL11.glVertex3d(x1, y0, z0);
        GL11.glVertex3d(x1, y0, z1);

        GL11.glNormal3f(1, 0, 0);
        GL11.glVertex3d(x0, y1, z1);
        GL11.glVertex3d(x0, y1, z0);
        GL11.glVertex3d(x0, y0, z0);
        GL11.glVertex3d(x0, y0, z1);

        GL11.glNormal3f(0, -1, 0);
        GL11.glVertex3d(x1, y1, z1);
        GL11.glVertex3d(x1, y1, z0);
        GL11.glVertex3d(x0, y1, z0);
        GL11.glVertex3d(x0, y1, z1);

        GL11.glNormal3f(-1, 0, 0);
        GL11.glVertex3d(x1, y0, z1);
        GL11.glVertex3d(x1, y0, z0);
        GL11.glVertex3d(x1, y1, z0);
        GL11.glVertex3d(x1, y1, z1);

        GL11.glNormal3f(0, 0, 1);
        GL11.glVertex3d(x0, y0, z0);
        GL11.glVertex3d(x0, y1, z0);
        GL11.glVertex3d(x1, y1, z0);
        GL11.glVertex3d(x1, y0, z0);

        GL11.glNormal3f(0, 0, -1);
        GL11.glVertex3d(x0, y1, z1);
        GL11.glVertex3d(x0, y0, z1);
        GL11.glVertex3d(x1, y0, z1);
        GL11.glVertex3d(x1, y1, z1);

        GL11.glEnd();

        GL11.glDisable(GL11.GL_LIGHTING);
    }
    if (renderMode == RenderMode.SOLID) {

        GL11.glLineWidth(thickness);

        GL11.glEnable(GL11.GL_LINE_STIPPLE);
        GL11.glLineStipple(stippleFactor, stipplePattern);

        GL11.glBegin(GL11.GL_LINE_LOOP);

        GL11.glVertex3d(x0, y0, z1);
        GL11.glVertex3d(x0, y1, z1);
        GL11.glVertex3d(x1, y1, z1);
        GL11.glVertex3d(x1, y0, z1);

        GL11.glEnd();

        GL11.glBegin(GL11.GL_LINE_LOOP);

        GL11.glVertex3d(x0, y1, z0);
        GL11.glVertex3d(x0, y0, z0);
        GL11.glVertex3d(x1, y0, z0);
        GL11.glVertex3d(x1, y1, z0);

        GL11.glEnd();

        GL11.glBegin(GL11.GL_LINES);

        GL11.glVertex3d(x0, y1, z1);
        GL11.glVertex3d(x0, y1, z0);
        GL11.glVertex3d(x0, y0, z1);
        GL11.glVertex3d(x0, y0, z0);
        GL11.glVertex3d(x1, y0, z1);
        GL11.glVertex3d(x1, y0, z0);
        GL11.glVertex3d(x1, y1, z1);
        GL11.glVertex3d(x1, y1, z0);

        GL11.glEnd();

        GL11.glDisable(GL11.GL_LINE_STIPPLE);
    }
}

From source file:fr.def.iss.vd2.lib_v3d.element.V3DCircle.java

License:Open Source License

private void drawCircle() {
    GL11.glBegin(GL11.GL_TRIANGLE_FAN);

    if (customColor) {
        GL11.glPushAttrib(GL11.GL_CURRENT_BIT);
        GL11.glEnable(GL11.GL_ALPHA_TEST);
        GL11.glBlendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA);
        GL11.glColor3f(innerColor.r, innerColor.g, innerColor.b);
    }//www.j ava 2 s  . c om
    GL11.glVertex3f(0.0f, 0.0f, 0.0f); // center

    float step = 2f * (float) Math.PI / (float) quality;
    if (customColor) {

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

    for (int i = 0; i <= quality; i++) {
        GL11.glVertex3f((float) (radius * Math.cos(step * i)), (float) (radius * Math.sin(step * i)), 0f);
    }

    if (customColor) {

        GL11.glDisable(GL11.GL_ALPHA_TEST);
        GL11.glPopAttrib();
    }

    GL11.glEnd();

}

From source file:fr.def.iss.vd2.lib_v3d.element.V3DCircle.java

License:Open Source License

private void drawExternCircle() {

    float step = 2f * (float) Math.PI / (float) quality;

    if (customColor) {
        GL11.glPushAttrib(GL11.GL_CURRENT_BIT);
        GL11.glEnable(GL11.GL_ALPHA_TEST);
        GL11.glBlendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA);
    }/*  w w  w  . j av a  2  s.c  o  m*/

    GL11.glBegin(GL11.GL_TRIANGLE_STRIP);

    for (int i = 0; i <= quality; i++) {
        if (customColor) {
            GL11.glColor4f(innerColor.r, innerColor.g, innerColor.b, innerColor.a);
        }
        GL11.glVertex3f((float) (innerRadius * Math.cos(step * i)), (float) (innerRadius * Math.sin(step * i)),
                0f);

        if (customColor) {
            GL11.glColor4f(outerColor.r, outerColor.g, outerColor.b, outerColor.a);
        }
        GL11.glVertex3f((float) (radius * Math.cos(step * i)), (float) (radius * Math.sin(step * i)), 0f);
    }

    GL11.glEnd();

    if (customColor) {
        GL11.glDisable(GL11.GL_ALPHA_TEST);
        GL11.glPopAttrib();
    }

}

From source file:fr.def.iss.vd2.lib_v3d.element.V3DCircle.java

License:Open Source License

private void drawSolidCircle() {
    float step = 2f * (float) Math.PI / (float) quality;

    GL11.glBegin(GL11.GL_LINE_LOOP);

    for (int i = 0; i <= quality; i++) {
        GL11.glVertex3f((float) (radius * Math.cos(step * i)), (float) (radius * Math.sin(step * i)), 0f);
    }//from w ww  .  j a va 2 s  .  co m

    GL11.glEnd();

    GL11.glBegin(GL11.GL_POINTS);

    for (int i = 0; i <= quality; i++) {
        GL11.glVertex3f((float) (radius * Math.cos(step * i)), (float) (radius * Math.sin(step * i)), 0f);
    }

    GL11.glEnd();

}