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:net.phatcode.rel.multimedia.Graphics.java

License:Open Source License

public void drawLine(int x1, int y1, int x2, int y2, float r, float g, float b, float a) {
    GL11.glDisable(GL11.GL_TEXTURE_2D);//from  www  .  ja  v a  2 s.c  o  m
    GL11.glColor4f(r, g, b, a);

    GL11.glBegin(GL11.GL_LINES);
    GL11.glVertex2i(x1, y1);
    GL11.glVertex2i(x2, y2);
    GL11.glEnd();

    GL11.glEnable(GL11.GL_TEXTURE_2D);

    GL11.glColor4f(1, 1, 1, 1);

}

From source file:net.phatcode.rel.multimedia.Graphics.java

License:Open Source License

public void drawLine(int x1, int y1, int x2, int y2) {
    GL11.glDisable(GL11.GL_TEXTURE_2D);//from  w w w.  j  av  a 2 s  . c  o  m

    GL11.glBegin(GL11.GL_LINES);
    GL11.glVertex2i(x1, y1);
    GL11.glVertex2i(x2, y2);
    GL11.glEnd();

    GL11.glEnable(GL11.GL_TEXTURE_2D);

}

From source file:net.phatcode.rel.multimedia.Graphics.java

License:Open Source License

public void drawBox(int x1, int y1, int x2, int y2, float r, float g, float b, float a) {
    GL11.glDisable(GL11.GL_TEXTURE_2D);/*www  .j ava  2  s .  co m*/
    GL11.glColor4f(r, g, b, a);

    GL11.glBegin(GL11.GL_LINE_STRIP);
    GL11.glVertex2i(x1, y1);
    GL11.glVertex2i(x2, y1);
    GL11.glVertex2i(x2, y2);
    GL11.glVertex2i(x1, y2);
    GL11.glVertex2i(x1, y1);
    GL11.glEnd();

    GL11.glEnable(GL11.GL_TEXTURE_2D);

    GL11.glColor4f(1, 1, 1, 1);

}

From source file:net.phatcode.rel.multimedia.Graphics.java

License:Open Source License

public void drawBox(int x1, int y1, int x2, int y2) {
    GL11.glDisable(GL11.GL_TEXTURE_2D);/*  w w w.  j  a  v a2  s.c  o  m*/

    GL11.glBegin(GL11.GL_LINE_STRIP);
    GL11.glVertex2i(x1, y1);
    GL11.glVertex2i(x2, y1);
    GL11.glVertex2i(x2, y2);
    GL11.glVertex2i(x1, y2);
    GL11.glVertex2i(x1, y1);
    GL11.glEnd();

    GL11.glEnable(GL11.GL_TEXTURE_2D);

}

From source file:net.phatcode.rel.multimedia.Graphics.java

License:Open Source License

public void drawBoxFilled(int x1, int y1, int x2, int y2, float r, float g, float b, float a) {
    GL11.glDisable(GL11.GL_TEXTURE_2D);/*from  w w  w  .j  av a  2 s.c  om*/
    GL11.glColor4f(r, g, b, a);

    x2++;
    y2++;

    GL11.glBegin(GL11.GL_QUADS);

    GL11.glVertex2i(x1, y1);
    GL11.glVertex2i(x1, y2);
    GL11.glVertex2i(x2, y2);
    GL11.glVertex2i(x2, y1);

    GL11.glEnd();

    GL11.glEnable(GL11.GL_TEXTURE_2D);

    GL11.glColor4f(1, 1, 1, 1);

}

From source file:net.phatcode.rel.multimedia.Graphics.java

License:Open Source License

public void drawBoxFilled(int x1, int y1, int x2, int y2) {
    GL11.glDisable(GL11.GL_TEXTURE_2D);/*from   www  .  j a v  a 2s .c o  m*/

    x2++;
    y2++;

    GL11.glBegin(GL11.GL_QUADS);

    GL11.glVertex2i(x1, y1);
    GL11.glVertex2i(x1, y2);
    GL11.glVertex2i(x2, y2);
    GL11.glVertex2i(x2, y1);

    GL11.glEnd();

    GL11.glEnable(GL11.GL_TEXTURE_2D);

}

From source file:net.phatcode.rel.multimedia.Graphics.java

License:Open Source License

public void drawEllipse(int x, int y, int a, int b, int degrees, float red, float green, float blue,
        float alpha) {

    // these constants decide the quality of the ellipse
    final float pi = (float) Math.PI;
    final float twopi = 2 * pi; //        two pi (radians in a circle)
    final int face_length = 8; //        approx. face length in pixels
    final int max_faces = 256; //        maximum number of faces in ellipse
    final int min_faces = 16; //        minimum number of faces in ellipse

    // approx. ellipse circumference (hudson's method)
    float h = (a - b * a - b) / (float) (a + b * a + b);
    float circumference = 0.25f * pi * (a + b) * (3 * (1 + h * 0.25f) + 1 / (1 - h * 0.25f));

    // number of faces in ellipse
    int num_faces = (int) (circumference / (float) face_length);

    // clamp number of faces
    if (num_faces > max_faces)
        num_faces = max_faces;/*from w ww .j  a v a2  s  .  co  m*/
    if (num_faces < min_faces)
        num_faces = min_faces;

    // keep number of faces divisible by 4
    num_faces -= (num_faces & 3);

    // precalc cosine theta
    float angle = degrees * pi / 180.0f;
    float s = (float) Math.sin(twopi / (float) num_faces);
    float c = (float) Math.cos(twopi / (float) num_faces);
    float xx = 1;
    float yy = 0;
    float xt;
    float ax = (float) Math.cos(angle);
    float ay = (float) Math.sin(angle);

    // draw ellipse
    GL11.glDisable(GL11.GL_TEXTURE_2D);
    GL11.glColor4f(red, green, blue, alpha);

    int i;
    GL11.glBegin(GL11.GL_LINE_LOOP);

    for (i = 0; i < num_faces; i++) {
        xt = xx;
        xx = c * xx - s * yy;
        yy = s * xt + c * yy;
        GL11.glVertex2f(x + a * xx * ax - b * yy * ay, y + a * xx * ay + b * yy * ax);
    }

    GL11.glVertex2f(x + a * ax, y + a * ay);

    GL11.glEnd();

    GL11.glEnable(GL11.GL_TEXTURE_2D);

    GL11.glColor4f(1, 1, 1, 1);

}

From source file:net.phatcode.rel.multimedia.Graphics.java

License:Open Source License

public void drawEllipse(int x, int y, int a, int b, int degrees) {

    // these constants decide the quality of the ellipse
    final float pi = (float) Math.PI;
    final float twopi = 2 * pi; //        two pi (radians in a circle)
    final int face_length = 8; //        approx. face length in pixels
    final int max_faces = 256; //        maximum number of faces in ellipse
    final int min_faces = 16; //        minimum number of faces in ellipse

    // approx. ellipse circumference (hudson's method)
    float h = (a - b * a - b) / (float) (a + b * a + b);
    float circumference = 0.25f * pi * (a + b) * (3 * (1 + h * 0.25f) + 1 / (1 - h * 0.25f));

    // number of faces in ellipse
    int num_faces = (int) (circumference / (float) face_length);

    // clamp number of faces
    if (num_faces > max_faces)
        num_faces = max_faces;//from   w  ww  . j  a v a 2  s .  c  om
    if (num_faces < min_faces)
        num_faces = min_faces;

    // keep number of faces divisible by 4
    num_faces -= (num_faces & 3);

    // precalc cosine theta
    float angle = degrees * pi / 180.0f;
    float s = (float) Math.sin(twopi / (float) num_faces);
    float c = (float) Math.cos(twopi / (float) num_faces);
    float xx = 1;
    float yy = 0;
    float xt;
    float ax = (float) Math.cos(angle);
    float ay = (float) Math.sin(angle);

    // draw ellipse
    GL11.glDisable(GL11.GL_TEXTURE_2D);

    int i;
    GL11.glBegin(GL11.GL_LINE_LOOP);

    for (i = 0; i < num_faces; i++) {
        xt = xx;
        xx = c * xx - s * yy;
        yy = s * xt + c * yy;
        GL11.glVertex2f(x + a * xx * ax - b * yy * ay, y + a * xx * ay + b * yy * ax);
    }

    GL11.glVertex2f(x + a * ax, y + a * ay);

    GL11.glEnd();

    GL11.glEnable(GL11.GL_TEXTURE_2D);

}

From source file:net.phatcode.rel.multimedia.Graphics.java

License:Open Source License

public void drawEllipseFilled(int x, int y, int a, int b, int degrees, float red, float green, float blue,
        float alpha) {

    // these constants decide the quality of the ellipse
    final float pi = (float) Math.PI;
    final float twopi = 2 * pi; //        two pi (radians in a circle)
    final int face_length = 8; //        approx. face length in pixels
    final int max_faces = 256; //        maximum number of faces in ellipse
    final int min_faces = 16; //        minimum number of faces in ellipse

    // approx. ellipse circumference (hudson's method)
    float h = (a - b * a - b) / (float) (a + b * a + b);
    float circumference = 0.25f * pi * (a + b) * (3 * (1 + h * 0.25f) + 1 / (1 - h * 0.25f));

    // number of faces in ellipse
    int num_faces = (int) (circumference / (float) face_length);

    // clamp number of faces
    if (num_faces > max_faces)
        num_faces = max_faces;//from  w w w.  j ava2  s  .c  om
    if (num_faces < min_faces)
        num_faces = min_faces;

    // keep number of faces divisible by 4
    num_faces -= (num_faces & 3);

    // precalc cosine theta
    float angle = degrees * pi / 180.0f;
    float s = (float) Math.sin(twopi / (float) num_faces);
    float c = (float) Math.cos(twopi / (float) num_faces);
    float xx = 1;
    float yy = 0;
    float xt;
    float ax = (float) Math.cos(angle);
    float ay = (float) Math.sin(angle);

    // draw ellipse
    GL11.glDisable(GL11.GL_TEXTURE_2D);
    GL11.glColor4f(red, green, blue, alpha);

    int i;
    GL11.glBegin(GL11.GL_TRIANGLE_FAN);

    for (i = 0; i < num_faces; i++) {
        xt = xx;
        xx = c * xx - s * yy;
        yy = s * xt + c * yy;
        GL11.glVertex2f(x + a * xx * ax - b * yy * ay, y + a * xx * ay + b * yy * ax);
    }

    GL11.glVertex2f(x + a * ax, y + a * ay);

    GL11.glEnd();

    GL11.glEnable(GL11.GL_TEXTURE_2D);

    GL11.glColor4f(1, 1, 1, 1);

}

From source file:net.phatcode.rel.multimedia.Graphics.java

License:Open Source License

public void drawEllipseFilled(int x, int y, int a, int b, int degrees) {

    // these constants decide the quality of the ellipse
    final float pi = (float) Math.PI;
    final float twopi = 2 * pi; //        two pi (radians in a circle)
    final int face_length = 8; //        approx. face length in pixels
    final int max_faces = 256; //        maximum number of faces in ellipse
    final int min_faces = 16; //        minimum number of faces in ellipse

    // approx. ellipse circumference (hudson's method)
    float h = (a - b * a - b) / (float) (a + b * a + b);
    float circumference = 0.25f * pi * (a + b) * (3 * (1 + h * 0.25f) + 1 / (1 - h * 0.25f));

    // number of faces in ellipse
    int num_faces = (int) (circumference / (float) face_length);

    // clamp number of faces
    if (num_faces > max_faces)
        num_faces = max_faces;/*w ww. j av a2s.c  o  m*/
    if (num_faces < min_faces)
        num_faces = min_faces;

    // keep number of faces divisible by 4
    num_faces -= (num_faces & 3);

    // precalc cosine theta
    float angle = degrees * pi / 180.0f;
    float s = (float) Math.sin(twopi / (float) num_faces);
    float c = (float) Math.cos(twopi / (float) num_faces);
    float xx = 1;
    float yy = 0;
    float xt;
    float ax = (float) Math.cos(angle);
    float ay = (float) Math.sin(angle);

    // draw ellipse
    GL11.glDisable(GL11.GL_TEXTURE_2D);

    int i;
    GL11.glBegin(GL11.GL_TRIANGLE_FAN);

    for (i = 0; i < num_faces; i++) {
        xt = xx;
        xx = c * xx - s * yy;
        yy = s * xt + c * yy;
        GL11.glVertex2f(x + a * xx * ax - b * yy * ay, y + a * xx * ay + b * yy * ax);
    }

    GL11.glVertex2f(x + a * ax, y + a * ay);

    GL11.glEnd();

    GL11.glEnable(GL11.GL_TEXTURE_2D);

}