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:org.ajgl.graphics.Immediate.java

License:Open Source License

/**
 * Draws a shape using glBegin / Primitive mode. And adds a texture to it.
 * @param beginMode - OpenGL begin mode/*from  w  ww .j av a 2  s. c o  m*/
 * @param textureID - The texture id to be used
 * @param vertexValues - Array of vertices
 * @param textureValues - Array of local texture vertices
 */
@OpenGLInfo(fwdCompatible = false, openGLVersion = "1.1", status = "Deprecated")
public static void fourPointdraw(@BeginMode int beginMode, int textureID, float[] vertexValues,
        float[] textureValues) {
    GL11.glBindTexture(GL11.GL_TEXTURE_2D, textureID);
    GL11.glBegin(beginMode);
    for (int i = 0, j = 0; i < vertexValues.length - 3; i += 4, j += 2) {
        GL11.glTexCoord2f(textureValues[j], textureValues[j + 1]);
        GL11.glVertex4f(vertexValues[i], vertexValues[i + 1], vertexValues[i + 2], vertexValues[i + 3]);
    }
    GL11.glEnd();
}

From source file:org.ajgl.graphics.Immediate.java

License:Open Source License

/**
 * Draws a shape using glBegin / Primitive mode. Adds color and texture to it. 
 * Note that {@code colorValues} should have four values per vertex.
 * @param beginMode - OpenGL begin mode//from ww  w  . j  a v  a2 s . c  o  m
 * @param textureID - The texture id to be used
 * @param vertexValues - Array of vertices
 * @param colorValues - Array of color vertices
 * @param textureValues - Array of local texture vertices
 */
@OpenGLInfo(fwdCompatible = false, openGLVersion = "1.1", status = "Deprecated")
public static void twoPointdraw(@BeginMode int beginMode, int textureID, float[] vertexValues,
        float[] colorValues, float[] textureValues) {
    GL11.glBindTexture(GL11.GL_TEXTURE_2D, textureID);
    GL11.glBegin(beginMode);
    for (int i = 0, j = 0; i < vertexValues.length - 1; i += 2, j += 4) {
        GL11.glColor4f(colorValues[j], colorValues[j + 1], colorValues[j + 2], colorValues[j + 3]);
        GL11.glTexCoord2f(textureValues[i], textureValues[i + 1]);
        GL11.glVertex2f(vertexValues[i], vertexValues[i + 1]);
    }
    GL11.glEnd();
}

From source file:org.ajgl.graphics.Immediate.java

License:Open Source License

/**
 * Draws a shape using glBegin / Primitive mode. Adds color and texture to it. 
 * Note that {@code colorValues} should have four values per vertex.
 * @param beginMode - OpenGL begin mode//ww w  .  j av  a2s. c om
 * @param textureID - The texture id to be used
 * @param vertexValues - Array of vertices
 * @param colorValues - Array of color vertices
 * @param textureValues - Array of local texture vertices
 */
@OpenGLInfo(fwdCompatible = false, openGLVersion = "1.1", status = "Deprecated")
public static void threePointdraw(@BeginMode int beginMode, int textureID, float[] vertexValues,
        float[] colorValues, float[] textureValues) {
    GL11.glBindTexture(GL11.GL_TEXTURE_2D, textureID);
    GL11.glBegin(beginMode);
    for (int i = 0, j = 0, k = 0; i < vertexValues.length - 2; i += 3, j += 4, k += 2) {
        GL11.glColor4f(colorValues[j], colorValues[j + 1], colorValues[j + 2], colorValues[j + 3]);
        GL11.glTexCoord2f(textureValues[k], textureValues[k + 1]);
        GL11.glVertex3f(vertexValues[i], vertexValues[i + 1], vertexValues[i + 2]);
    }
    GL11.glEnd();
}

From source file:org.ajgl.graphics.Immediate.java

License:Open Source License

/**
 * Draws a shape using glBegin / Primitive mode. Adds color and texture to it. 
 * Note that {@code colorValues} should have four values per vertex.
 * @param beginMode - OpenGL begin mode/*from  www .j a  v  a  2s.co  m*/
 * @param textureID - The texture id to be used
 * @param vertexValues - Array of vertices
 * @param colorValues - Array of color vertices
 * @param textureValues - Array of local texture vertices
 */
@OpenGLInfo(fwdCompatible = false, openGLVersion = "1.1", status = "Deprecated")
public static void fourPointdraw(@BeginMode int beginMode, int textureID, float[] vertexValues,
        float[] colorValues, float[] textureValues) {
    GL11.glBindTexture(GL11.GL_TEXTURE_2D, textureID);
    GL11.glBegin(beginMode);
    for (int i = 0, j = 0, k = 0; i < vertexValues.length - 3; i += 4, j += 4, k += 2) {
        GL11.glColor4f(colorValues[j], colorValues[j + 1], colorValues[j + 2], colorValues[j + 3]);
        GL11.glTexCoord2f(textureValues[k], textureValues[k + 1]);
        GL11.glVertex4f(vertexValues[i], vertexValues[i + 1], vertexValues[i + 2], vertexValues[i + 3]);
    }
    GL11.glEnd();
}

From source file:org.cogaen.lwjgl.scene.CircleVisual.java

License:Open Source License

@Override
public void render() {
    //TODO use display list
    getColor().apply();/*from   www  .ja v  a  2s.  c  om*/

    GL11.glBegin(this.glMode);
    double r = this.radius * getScale();
    for (int i = 0; i < 360; i += 10) {
        double degInRad = i * DEG2RAD;
        GL11.glVertex2d(Math.cos(degInRad) * r, Math.sin(degInRad) * r);
    }
    GL11.glEnd();
}

From source file:org.cogaen.lwjgl.scene.PointVisual.java

License:Open Source License

@Override
public void render() {
    getColor().apply();
    GL11.glBegin(GL11.GL_POINTS);
    GL11.glVertex2f(0f, 0f);
    GL11.glEnd();
}

From source file:org.cogaen.lwjgl.scene.RectangleVisual.java

License:Open Source License

@Override
public void render() {
    getColor().apply();//from  w  w  w  .j a v a 2 s  .c o  m

    GL11.glBegin(this.glMode);
    GL11.glVertex2d(-this.halfWidth * getScale(), -this.halfHeight * getScale());
    GL11.glVertex2d(this.halfWidth * getScale(), -this.halfHeight * getScale());
    GL11.glVertex2d(this.halfWidth * getScale(), this.halfHeight * getScale());
    GL11.glVertex2d(-this.halfWidth * getScale(), this.halfHeight * getScale());
    GL11.glEnd();
}

From source file:org.cogaen.lwjgl.scene.SpriteFxVisual.java

License:Open Source License

@Override
public void render() {
    if (this.flipVertical) {
        GL11.glScaled(1, -1, 1);//from ww w. j a v  a 2  s.  c  o m
    }

    if (this.shadow) {
        double dx = this.halfWidth * getScale() * 0.02;
        double dy = this.halfWidth * getScale() * 0.02;
        GL11.glColor4d(getColor().getRed() * 0.1, getColor().getGreen() * 0.1, getColor().getBlue() * 0.1, 0.7);

        GL11.glBegin(GL11.GL_QUADS);
        GL11.glTexCoord2f(0.0f, this.texture.getHeight());
        GL11.glVertex2d(-this.halfWidth * getScale() + dx, -this.halfHeight * getScale() - dy);

        GL11.glTexCoord2f(this.texture.getWidth(), this.texture.getHeight());
        GL11.glVertex2d(this.halfWidth * getScale() + dx, -this.halfHeight * getScale() - dy);

        GL11.glTexCoord2f(this.texture.getWidth(), 0);
        GL11.glVertex2d(this.halfWidth * getScale() + dx, this.halfHeight * getScale() - dy);

        GL11.glTexCoord2f(0.0f, 0.0f);
        GL11.glVertex2d(-this.halfWidth * getScale() + dx, this.halfHeight * getScale() - dy);
    }

    getColor().apply();

    GL11.glBegin(GL11.GL_QUADS);
    GL11.glTexCoord2f(0.0f, this.texture.getHeight());
    GL11.glVertex2d(-this.halfWidth * getScale(), -this.halfHeight * getScale());

    GL11.glTexCoord2f(this.texture.getWidth(), this.texture.getHeight());
    GL11.glVertex2d(this.halfWidth * getScale(), -this.halfHeight * getScale());

    GL11.glTexCoord2f(this.texture.getWidth(), 0);
    GL11.glVertex2d(this.halfWidth * getScale(), this.halfHeight * getScale());

    GL11.glTexCoord2f(0.0f, 0.0f);
    GL11.glVertex2d(-this.halfWidth * getScale(), this.halfHeight * getScale());

    if (this.mirror) {
        GL11.glColor4d(getColor().getRed() * 0.7, getColor().getGreen() * 0.7, getColor().getBlue() * 0.7, 0.7);

        GL11.glTexCoord2f(0.0f, this.texture.getHeight());
        GL11.glVertex2d(-this.halfWidth * getScale(), -this.halfHeight * getScale());

        GL11.glTexCoord2f(this.texture.getWidth(), this.texture.getHeight());
        GL11.glVertex2d(this.halfWidth * getScale(), -this.halfHeight * getScale());

        GL11.glColor4d(getColor().getRed(), getColor().getGreen(), getColor().getBlue(), 0);
        GL11.glTexCoord2f(this.texture.getWidth(), this.texture.getHeight() / 2);
        GL11.glVertex2d(this.halfWidth * getScale(), -this.halfHeight * 2 * getScale());

        GL11.glTexCoord2f(0.0f, this.texture.getHeight() / 2);
        GL11.glVertex2d(-this.halfWidth * getScale(), -this.halfHeight * 2 * getScale());
    }

    GL11.glEnd();
}

From source file:org.cogaen.lwjgl.scene.SpriteVisual.java

License:Open Source License

@Override
public void render() {
    getColor().apply();//from ww  w  .ja  v a 2s.  c  om

    if (this.flipVertical) {
        GL11.glScaled(1, -1, 1);
    }

    GL11.glBegin(GL11.GL_QUADS);
    GL11.glTexCoord2f(0.0f, this.texture.getHeight());
    GL11.glVertex2d(-this.halfWidth * getScale(), -this.halfHeight * getScale());

    GL11.glTexCoord2f(this.texture.getWidth(), this.texture.getHeight());
    GL11.glVertex2d(this.halfWidth * getScale(), -this.halfHeight * getScale());

    GL11.glTexCoord2f(this.texture.getWidth(), 0);
    GL11.glVertex2d(this.halfWidth * getScale(), this.halfHeight * getScale());

    GL11.glTexCoord2f(0.0f, 0.0f);
    GL11.glVertex2d(-this.halfWidth * getScale(), this.halfHeight * getScale());
    GL11.glEnd();
}

From source file:org.cogaen.lwjgl.scene.TextBlockVisual.java

License:Open Source License

@Override
public void render() {
    GL11.glPushMatrix();//from  w  w  w  .  ja  v  a2s. c  o m
    GL11.glScaled(getScale(), -getScale(), 1);
    getColor().apply();

    org.newdawn.slick.Color utilColor = new org.newdawn.slick.Color((int) (getColor().getRed() * 255),
            (int) (getColor().getGreen() * 255), (int) (getColor().getBlue() * 255),
            (int) (getColor().getAlpha() * 255));

    if (this.timeStamp < this.timer.getTime()) {
        this.timeStamp = this.timer.getTime() + BLINK_TIME;
        this.cursorOn = !this.cursorOn;
    }

    for (int i = 0; i < this.lines.length; ++i) {
        this.ttf.drawString((float) (-this.width / 2),
                (float) (-this.height / 2 + i * ttf.getHeight() * LINE_SPACE), this.lines[i].toString(),
                utilColor);
    }

    if (this.cursorOn && this.showCursor) {
        GL11.glDisable(GL11.GL_TEXTURE_2D);
        GL11.glEnable(GL11.GL_BLEND);

        double offsetX;
        if (this.curX == 0) {
            offsetX = 0;
        } else if (this.curX >= this.lines[this.curY].length()) {
            offsetX = this.ttf.getWidth(this.lines[this.curY].substring(0, this.lines[this.curY].length()));
        } else {
            offsetX = this.ttf.getWidth(this.lines[this.curY].substring(0, this.curX));
        }
        double offsetY = this.curY * this.ttf.getHeight() * LINE_SPACE;

        double x = -this.width / 2 + offsetX;
        double y = -this.height / 2 + offsetY + this.ttf.getHeight() / 2;
        double curHeight = this.ttf.getHeight() / 2 * 0.8;

        GL11.glBegin(GL11.GL_LINES);
        GL11.glVertex2d(x, y + curHeight);
        GL11.glVertex2d(x, y - curHeight);
        GL11.glEnd();
    }
    GL11.glPopMatrix();
}