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.geekygoblin.nedetlesmaki.game.systems.DrawSystem.java

License:Open Source License

private void drawLevel(LevelBackground level) {

    GL11.glPushMatrix();//w w  w . j av a 2 s  . com
    GL11.glLoadIdentity();
    IPlay backgroundAnimationPlay = level.getBackground();
    backgroundAnimationPlay.update((long) (world.getDelta() * 1000L));
    final IAnimationFrame currentFrame = backgroundAnimationPlay.getCurrentFrame();
    GL11.glBindTexture(GL11.GL_TEXTURE_2D, (Integer) currentFrame.getImage().getId());
    float x1 = -VirtualResolution.WIDTH / 2.0f;
    float x2 = VirtualResolution.WIDTH / 2.0f;
    float y1 = VirtualResolution.HEIGHT / 2.0f;
    float y2 = -VirtualResolution.HEIGHT / 2.0f;
    float u1 = currentFrame.getU1();
    float u2 = currentFrame.getU2();

    float v1 = currentFrame.getV2();
    float v2 = currentFrame.getV1();
    GL11.glBegin(GL11.GL_QUADS);
    GL11.glTexCoord2f(u1, v1);
    GL11.glVertex2f(x1, y2);
    GL11.glTexCoord2f(u2, v1);
    GL11.glVertex2f(x2, y2);
    GL11.glTexCoord2f(u2, v2);
    GL11.glVertex2f(x2, y1);
    GL11.glTexCoord2f(u1, v2);
    GL11.glVertex2f(x1, y1);
    GL11.glEnd();
    GL11.glPopMatrix();
}

From source file:org.javateerz.EasyGL.GLRect.java

License:Open Source License

/**
 * Draws the OpenGL rectangle on the display
 */// w  w  w .j  a v a2s .co m
public void draw() {
    GL11.glPushMatrix();

    // disable textures
    GL11.glDisable(TEXTURE_TARGET);

    // move to selected location
    GL11.glTranslatef(x, y, 0);

    // set color for drawing
    GL11.glColor4f((float) color.getRed() / 255, (float) color.getGreen() / 255, (float) color.getBlue() / 255,
            (float) color.getAlpha() / 255);

    // draw a quadrilateral
    GL11.glBegin(GL11.GL_QUADS);
    GL11.glVertex2f(0, 0);
    GL11.glVertex2f(0, height);
    GL11.glVertex2f(width, height);
    GL11.glVertex2f(width, 0);
    GL11.glEnd();

    GL11.glPopMatrix();
}

From source file:org.jmangos.tools.openGL.FontTT.java

License:Open Source License

private void drawtexture(final Texture texture, final float ratio, final float x, final float y,
        final Color color, final float rotx, final float roty, final float rotz) {

    // Get the appropriate measurements from the texture itself
    final float imgwidth = texture.getImageWidth() * ratio;
    final float imgheight = -texture.getImageHeight() * ratio;
    final float texwidth = texture.getWidth();
    final float texheight = texture.getHeight();

    // Bind the texture
    texture.bind();//www  .j  a v  a2s .  c om

    // translate to the right location
    GL11.glColor4f(color.getRed(), color.getGreen(), color.getBlue(), color.getAlpha());

    // draw a quad with to place the character onto
    GL11.glBegin(GL11.GL_QUADS);
    {
        GL11.glTexCoord2f(0, 0);
        GL11.glVertex2f(0 + x, 0 - y);

        GL11.glTexCoord2f(0, texheight);
        GL11.glVertex2f(0 + x, imgheight - y);

        GL11.glTexCoord2f(texwidth, texheight);
        GL11.glVertex2f(imgwidth + x, imgheight - y);

        GL11.glTexCoord2f(texwidth, 0);
        GL11.glVertex2f(imgwidth + x, 0 - y);
    }
    GL11.glEnd();

}

From source file:org.jogamp.glg2d.impl.gl2.GL2ImageDrawer.java

License:Apache License

@Override
protected void applyTexture(Texture texture, float dx1, float dy1, float dx2, float dy2, float sx1, float sy1,
        float sx2, float sy2) {
    GL11.glBegin(GL11.GL_QUADS);//from  w  w w  . j  a va  2s. c  o  m

    // SW
    GL11.glTexCoord2f(sx1, sy2);
    GL11.glVertex2f(dx1, dy2);
    // SE
    GL11.glTexCoord2f(sx2, sy2);
    GL11.glVertex2f(dx2, dy2);
    // NE
    GL11.glTexCoord2f(sx2, sy1);
    GL11.glVertex2f(dx2, dy1);
    // NW
    GL11.glTexCoord2f(sx1, sy1);
    GL11.glVertex2f(dx1, dy1);

    GL11.glEnd();
}

From source file:org.joge.core.draw.font.Font.java

License:Open Source License

public void render(String text, Color color, float xpos, float ypos) {
    Texture tex;/*  w  w w .ja  v a 2  s . co m*/
    char[] chars = text.toCharArray();
    float textWidth = 0;
    for (int i = 0; i < chars.length; i++) {
        tex = charArray[(int) chars[i]];
        width = tex.getImageWidth();
        height = tex.getImageHeight();
        tWidth = tex.getWidth();
        tHeight = tex.getHeight();
        tex.bind();
        GL11.glTranslatef(xpos + textWidth, ypos, 0);
        GL11.glColor3f(color.r, color.g, color.b);
        GL11.glBegin(GL11.GL_QUADS);
        {
            GL11.glTexCoord2f(tOffsetX, tOffsetY);
            GL11.glVertex2f(0, 0);
            GL11.glTexCoord2f(tOffsetX, tHeight + tOffsetY);
            GL11.glVertex2f(0, height);
            GL11.glTexCoord2f(tWidth + tOffsetX, tHeight + tOffsetY);
            GL11.glVertex2f(width, height);
            GL11.glTexCoord2f(tWidth + tOffsetX, tOffsetY);
            GL11.glVertex2f(width, 0);
        }
        GL11.glEnd();
        GL11.glLoadIdentity();
        textWidth += tex.getWidth() * fontSize;
    }

}

From source file:org.joge.core.draw.Graphics.java

License:Open Source License

public void drawLine(float x1, float y1, float x2, float y2) {
    setColor();/*from ww  w  .  j  a  v a  2s.co m*/
    disableGl();
    GL11.glBegin(GL11.GL_LINES);
    GL11.glVertex2f(x1, y1);
    GL11.glVertex2f(x2, y2);
    GL11.glEnd();
    enableGl();
}

From source file:org.joge.core.draw.Graphics.java

License:Open Source License

public void drawRect(float x1, float y1, float width, float height) {
    setColor();/*from ww  w  .jav a 2 s.  c om*/
    disableGl();
    GL11.glBegin(GL11.GL_LINE_STRIP);
    GL11.glVertex2f(x1, y1);
    GL11.glVertex2f(x1 + width, y1);
    GL11.glVertex2f(x1 + width, y1 + height);
    GL11.glVertex2f(x1, y1 + height);
    GL11.glVertex2f(x1, y1);
    GL11.glEnd();
    enableGl();
}

From source file:org.joge.core.draw.Graphics.java

License:Open Source License

public void fillRect(float x, float y, float width, float height) {
    setColor();//from   w w w  .j av a  2  s  .co m
    disableGl();
    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();
    enableGl();
}

From source file:org.joge.core.draw.Graphics.java

License:Open Source License

public void fillMultiColoredRect(float x, float y, float width, float height, Color c1, Color c2, Color c3,
        Color c4) {//from www .j  a  v a  2 s  . co  m
    setColor();
    disableGl();
    GL11.glBegin(GL11.GL_QUADS);
    GL11.glColor4f(c1.r, c1.g, c1.b, c1.a);
    GL11.glVertex2f(x, y);
    GL11.glColor4f(c2.r, c2.g, c2.b, c2.a);
    GL11.glVertex2f(x + width, y);
    GL11.glColor4f(c3.r, c3.g, c3.b, c3.a);
    GL11.glVertex2f(x + width, y + height);
    GL11.glColor4f(c4.r, c4.g, c4.b, c4.a);
    GL11.glVertex2f(x, y + height);
    GL11.glEnd();
    enableGl();
}

From source file:org.joge.core.draw.Graphics.java

License:Open Source License

public void fillRect2(float x, float y, float x2, float y2) {
    setColor();//from  w ww . java2  s.c  o m
    disableGl();
    GL11.glBegin(GL11.GL_QUADS);
    GL11.glVertex2f(x, y);
    GL11.glVertex2f(x2, y);
    GL11.glVertex2f(x2, y2);
    GL11.glVertex2f(x, y2);
    GL11.glEnd();
    enableGl();
}