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:game.core.gfx.DrawRectangleBehavior.java

License:Open Source License

@Override
public void draw(GameObject target) {
    color.glColor();//from w  ww  . j  av a 2  s  . com
    GL11.glBegin(GL11.GL_QUADS);
    GL11.glVertex2f(1.0f, 1.0f);
    GL11.glVertex2f(1.0f, -1.0f);
    GL11.glVertex2f(-1.0f, -1.0f);
    GL11.glVertex2f(-1.0f, 1.0f);
    GL11.glEnd();
}

From source file:game.engine.core.CoreModule.java

License:Open Source License

/**
 * Constructor./*from   w ww . j av  a  2  s.c  o  m*/
 * 
 * @param scriptEngine the Nashorn engine
 */
public CoreModule(ScriptEngine scriptEngine) {
    try {

        final EventListener positionTransformListener = new EventListener(null, "beforeDraw") {
            @Override
            public void handleEvent(GameObject gameObject, Object payload) {
                PositionData data = (PositionData) gameObject.get(CoreModule.this.position);
                GL11.glTranslatef(data.x, data.y, 0.0f);
            }
        };

        position = new Behavior(new Applicator() {
            @Override
            public void apply(GameObject target, Object rawParameters, Behavior behavior) {
                PositionData data = new PositionData();
                if (rawParameters != null) {
                    JSObject parameters = (JSObject) jdk.nashorn.api.scripting.ScriptUtils.wrap(rawParameters);
                    if (parameters.getMember("x") instanceof Number) {
                        data.x = ((Number) parameters.getMember("x")).floatValue();
                    }
                    if (parameters.getMember("y") instanceof Number) {
                        data.y = ((Number) parameters.getMember("y")).floatValue();
                    }
                }
                target.set(CoreModule.this.position, data);
                target.addListener(positionTransformListener);
            }
        });

        final EventListener drawRectangleListener = new EventListener(null, "draw") {
            @Override
            public void handleEvent(GameObject gameObject, Object payload) {
                GL11.glColor4ub((byte) 255, (byte) 255, (byte) 255, (byte) 255);
                GL11.glBegin(GL11.GL_QUADS);
                GL11.glVertex2f(1.0f, 1.0f);
                GL11.glVertex2f(1.0f, -1.0f);
                GL11.glVertex2f(-1.0f, -1.0f);
                GL11.glVertex2f(-1.0f, 1.0f);
                GL11.glEnd();
            }
        };

        rectangle = new Behavior(new Applicator() {
            @Override
            public void apply(GameObject target, Object parameters, Behavior behavior) {
                target.addListener(drawRectangleListener);
            }
        });

        leftRight = new Behavior(new Applicator() {
            @Override
            public void apply(GameObject target, Object parameters, Behavior behavior) {
                target.set(leftRight, "left");
            }
        });

        final EventListener drawSpriteListener = new EventListener(null, "draw") {
            @Override
            public void handleEvent(GameObject gameObject, Object payload) {
                SpriteProvider spriteProvider = (SpriteProvider) gameObject.get(sprite);
                if (spriteProvider != null) {
                    Sprite sprite = spriteProvider.provideSprite(gameObject);
                    if (sprite != null) {
                        sprite.draw();
                    }
                }
            }
        };

        sprite = new Behavior(new Applicator() {
            @Override
            public void apply(GameObject target, Object parameters, Behavior behavior) {
                if (parameters instanceof SpriteProvider) {
                    target.set(sprite, parameters);
                } else {
                    throw new RuntimeException("invalid sprite provider");
                }
                target.addListener(drawSpriteListener);
            }
        });

    } catch (Exception e) {
        throw new RuntimeException(e);
    }
}

From source file:game.engine.gfx.Sprite.java

License:Open Source License

/**
 * Draws this sprite at the current origin.
 *///from   w  w w  . ja  va  2s  . c  o m
public void draw() {
    GL11.glEnable(GL11.GL_TEXTURE_2D);
    glBindTexture();
    GL11.glColor3ub((byte) 255, (byte) 255, (byte) 255);
    GL11.glBegin(GL11.GL_QUADS);
    glVertices();
    GL11.glEnd();
}

From source file:game.graphics.GUI_Button.java

License:Open Source License

public void Render() {
    texture.bind();//from   w w w  . j  a  v a 2s .c o  m
    GL11.glBegin(GL11.GL_QUADS);

    GL11.glTexCoord2f(0, 0);
    GL11.glVertex3f(ScreenX, ScreenY, 0);

    GL11.glTexCoord2f(0, 1);
    GL11.glVertex3f(ScreenX, ScreenY + ScreenButtonHeight * (MouseInsideMe ? MouseOverMultiplier : 1), 0);

    GL11.glTexCoord2f(1, 1);
    GL11.glVertex3f(ScreenX + ScreenButtonWidth * (MouseInsideMe ? MouseOverMultiplier : 1),
            ScreenY + ScreenButtonHeight * (MouseInsideMe ? MouseOverMultiplier : 1), 0);

    GL11.glTexCoord2f(1, 0);
    GL11.glVertex3f(ScreenX + ScreenButtonWidth * (MouseInsideMe ? MouseOverMultiplier : 1), ScreenY, 0);

    GL11.glEnd();

}

From source file:game.graphics.GUI_Console.java

License:Open Source License

public void Render() {
    if (Enabled) {
        texture.bind();// w  w  w .  jav a2  s  . co  m
        GL11.glBegin(GL11.GL_QUADS);

        GL11.glTexCoord2f(0, 0);
        GL11.glVertex3f(ScreenX, ScreenY, 0);

        GL11.glTexCoord2f(0, 1);
        GL11.glVertex3f(ScreenX, ScreenY + ScreenButtonHeight, 0);

        GL11.glTexCoord2f(1, 1);
        GL11.glVertex3f(ScreenX + ScreenButtonWidth, ScreenY + ScreenButtonHeight, 0);

        GL11.glTexCoord2f(1, 0);
        GL11.glVertex3f(ScreenX + ScreenButtonWidth, ScreenY, 0);

        GL11.glEnd();
        font.drawString(ScreenX + 10, ScreenY + 10, Log, Color.green);
        font.drawString(ScreenX + 10, ScreenY + ScreenButtonHeight - 30, "> " + Prompt, Color.green);
    }

}

From source file:game.graphics.GUI_InvDisplay.java

License:Open Source License

@Override
public void Render() {
    if (Enabled) {

        texture.bind();// w ww  . ja  v  a  2 s . co m

        GL11.glBegin(GL11.GL_QUADS);

        GL11.glTexCoord2f(0, 0);
        GL11.glVertex3f(ScreenX, ScreenY, 0);

        GL11.glTexCoord2f(0, 1);
        GL11.glVertex3f(ScreenX, ScreenY + ScreenButtonHeight, 0);

        GL11.glTexCoord2f(1, 1);
        GL11.glVertex3f(ScreenX + ScreenButtonWidth, ScreenY + ScreenButtonHeight, 0);

        GL11.glTexCoord2f(1, 0);
        GL11.glVertex3f(ScreenX + ScreenButtonWidth, ScreenY, 0);

        GL11.glEnd();

        for (int i = 0; i < Buttons.size(); i++) {
            Buttons.get(i).Render();
        }

        player.getInventory().Render(ScreenX + 230, ScreenY + 30, font);

    }

}

From source file:game.graphics.GUI_Layer.java

License:Open Source License

public void Box(int x, int y, int w, int h, Color c) {
    GL11.glDisable(GL11.GL_TEXTURE_2D);//  w  w w .j a  v  a  2  s  .com
    c.bind();
    GL11.glBegin(GL11.GL_QUADS);

    // GL11.glTexCoord2f(0, 0);
    GL11.glVertex3f(x, y, 0);

    // GL11.glTexCoord2f(0, 1);
    GL11.glVertex3f(x, y + h, 0);

    // GL11.glTexCoord2f(1, 1);
    GL11.glVertex3f(x + w, y + h, 0);

    // GL11.glTexCoord2f(1, 0);
    GL11.glVertex3f(x + w, y, 0);

    GL11.glEnd();
    Color.white.bind();
    GL11.glEnable(GL11.GL_TEXTURE_2D);
}

From source file:game.graphics.GUI_Object.java

License:Open Source License

private void RenderBackground() {
    texture.bind();/* w w  w . j  a  v  a  2  s.c  om*/
    GL11.glBegin(GL11.GL_QUADS);

    GL11.glTexCoord2f(0, 0);
    GL11.glVertex3f(EntityWindowX, EntityWindowY, 0);

    GL11.glTexCoord2f(0, 1);
    GL11.glVertex3f(EntityWindowX, EntityWindowY + EntityHeight, 0);

    GL11.glTexCoord2f(1, 1);
    GL11.glVertex3f(EntityWindowX + EntityWidth, EntityWindowY + EntityHeight, 0);

    GL11.glTexCoord2f(1, 0);
    GL11.glVertex3f(EntityWindowX + EntityWidth, EntityWindowY, 0);

    GL11.glEnd();
}

From source file:game.graphics.GUI_PrefabMap.java

License:Open Source License

private void RenderTile(int x, int y, int i) {
    GL11.glBegin(GL11.GL_QUADS);/* w  ww. j  a v a 2 s . c  om*/
    TileDefinition.setColor(i);
    GL11.glVertex3f(x, y, 0);

    GL11.glVertex3f(x, y + TileHeight, 0);

    GL11.glVertex3f(x + TileWidth, y + TileHeight, 0);

    GL11.glVertex3f(x + TileWidth, y, 0);

    GL11.glEnd();

}

From source file:game.graphics.GUI_PrefabPalette.java

License:Open Source License

private void RenderTile(int x, int y, int width, int height, int i) {
    Color.white.bind();//from www . ja va 2  s  .c  o  m
    GL11.glBegin(GL11.GL_QUADS);

    TileDefinition.setColor(i);
    GL11.glVertex3f(x, y, 0);

    GL11.glVertex3f(x, y + height, 0);

    GL11.glVertex3f(x + width, y + height, 0);

    GL11.glVertex3f(x + width, y, 0);

    GL11.glEnd();

}