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:com.golden.gamedev.engine.lwjgl.LWJGLGraphics.java

License:Open Source License

/** ************************************************************************* */

public boolean drawImage(Image img, int x, int y, ImageObserver observer) {
    this.startPainting();

    // store the current model matrix
    GL11.glPushMatrix();/*w  w w.  j a v a 2s .co  m*/

    // bind to the appropriate texture for this sprite
    Texture texture = this.textureLoader.getTexture((BufferedImage) img);
    texture.bind();

    // translate to the right location and prepare to draw
    GL11.glTranslatef(x, y, 0);

    // draw a quad textured to match the sprite
    GL11.glBegin(GL11.GL_QUADS);
    GL11.glTexCoord2f(0, 0);
    GL11.glVertex2f(0, 0);

    GL11.glTexCoord2f(0, texture.getHeight());
    GL11.glVertex2f(0, texture.getImageHeight());

    GL11.glTexCoord2f(texture.getWidth(), texture.getHeight());
    GL11.glVertex2f(texture.getImageWidth(), texture.getImageHeight());

    GL11.glTexCoord2f(texture.getWidth(), 0);
    GL11.glVertex2f(texture.getImageWidth(), 0);
    GL11.glEnd();

    // restore the model view matrix to prevent contamination
    GL11.glPopMatrix();

    this.endPainting();

    return true;
}

From source file:com.golden.gamedev.engine.lwjgl.LWJGLGraphics.java

License:Open Source License

public boolean drawImage(Image img, int x, int y, int width, int height, ImageObserver observer) {
    this.startPainting();

    GL11.glPushMatrix();//from   w ww  . j a  v  a2s  .  c  om

    Texture texture = this.textureLoader.getTexture((BufferedImage) img);
    texture.bind();

    GL11.glTranslatef(x, y, 0);

    GL11.glBegin(GL11.GL_QUADS);
    GL11.glTexCoord2f(0, 0);
    GL11.glVertex2f(0, 0);

    GL11.glTexCoord2f(0, texture.getHeight());
    GL11.glVertex2f(0, height);

    GL11.glTexCoord2f(texture.getWidth(), texture.getHeight());
    GL11.glVertex2f(width, height);

    GL11.glTexCoord2f(texture.getWidth(), 0);
    GL11.glVertex2f(width, 0);
    GL11.glEnd();

    GL11.glPopMatrix();

    this.endPainting();

    return true;
}

From source file:com.golden.gamedev.engine.lwjgl.LWJGLGraphics.java

License:Open Source License

public boolean drawImage(Image img, int dx1, int dy1, int dx2, int dy2, int sx1, int sy1, int sx2, int sy2,
        ImageObserver observer) {
    this.startPainting();

    Texture texture = this.textureLoader.getTexture((BufferedImage) img);
    texture.bind();/*  www.ja  v  a 2 s .co m*/

    float tx0 = ((float) sx1 / texture.getTextureWidth());
    float tx1 = ((float) sx2 / texture.getTextureWidth());
    float ty0 = ((float) sy1 / texture.getTextureHeight());
    float ty1 = ((float) sy2 / texture.getTextureHeight());

    GL11.glBegin(GL11.GL_QUADS);
    GL11.glTexCoord2f(tx0, ty0);
    GL11.glVertex2f(dx1, dy1);

    GL11.glTexCoord2f(tx1, ty0);
    GL11.glVertex2f(dx2, dy1);

    GL11.glTexCoord2f(tx1, ty1);
    GL11.glVertex2f(dx2, dy2);

    GL11.glTexCoord2f(tx0, ty1);
    GL11.glVertex2f(dx1, dy2);
    GL11.glEnd();

    this.endPainting();

    return true;
}

From source file:com.golden.gamedev.engine.lwjgl.LWJGLGraphics.java

License:Open Source License

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

    GL11.glColor4f((float) this.color.getRed() / 255f, (float) this.color.getGreen() / 255f,
            (float) this.color.getBlue() / 255f, (float) this.color.getAlpha() / 255f);
    GL11.glLineWidth(1.0f);

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

    GL11.glColor3f(1.0f, 1.0f, 1.0f);

    GL11.glEnable(GL11.GL_TEXTURE_2D);
}

From source file:com.golden.gamedev.engine.lwjgl.LWJGLGraphics.java

License:Open Source License

private void drawRect(int x, int y, int width, int height, int type, Color col) {
    GL11.glDisable(GL11.GL_TEXTURE_2D);//w w w.  ja va 2  s  .  c om

    GL11.glColor4f((float) col.getRed() / 255f, (float) col.getGreen() / 255f, (float) col.getBlue() / 255f,
            (float) col.getAlpha() / 255f);
    GL11.glLineWidth(1.0f);

    GL11.glBegin(type);
    GL11.glVertex2f(x, y);
    GL11.glVertex2f(x + width, y);
    GL11.glVertex2f(x + width, y + height);
    GL11.glVertex2f(x, y + height);
    GL11.glEnd();

    GL11.glColor3f(1.0f, 1.0f, 1.0f);

    GL11.glEnable(GL11.GL_TEXTURE_2D);
}

From source file:com.headswilllol.mineflat.gui.GuiElement.java

License:Open Source License

public void draw() {
    if (isActive()) {
        GL11.glColor4f(color.getX(), color.getY(), color.getZ(), color.getW());
        GL11.glBegin(GL11.GL_QUADS);
        GL11.glVertex2i(getAbsolutePosition().getX(), getAbsolutePosition().getY());
        GL11.glVertex2i(getAbsolutePosition().getX() + size.getX(), getAbsolutePosition().getY());
        GL11.glVertex2i(getAbsolutePosition().getX() + size.getX(), getAbsolutePosition().getY() + size.getY());
        GL11.glVertex2i(getAbsolutePosition().getX(), getAbsolutePosition().getY() + size.getY());
        GL11.glEnd();/* w ww .  jav  a2 s . c  om*/
        for (GuiElement ge : children.values()) {
            ge.draw();
        }
    }
}

From source file:com.headswilllol.mineflat.gui.TextField.java

License:Open Source License

@Override
public void draw() {
    if (isActive()) {
        GL11.glColor4f(bgColor.getX(), bgColor.getY(), bgColor.getZ(), bgColor.getW());
        GL11.glBegin(GL11.GL_QUADS);
        GL11.glVertex2i(getAbsolutePosition().getX(), getAbsolutePosition().getY());
        GL11.glVertex2i(getAbsolutePosition().getX() + getSize().getX(), getAbsolutePosition().getY());
        GL11.glVertex2i(getAbsolutePosition().getX() + getSize().getX(),
                getAbsolutePosition().getY() + getSize().getY());
        GL11.glVertex2i(getAbsolutePosition().getX(), getAbsolutePosition().getY() + getSize().getY());
        GL11.glEnd();/*from  w w  w.  ja  v  a  2  s .  co  m*/
        GL11.glColor4f(textColor.getX(), textColor.getY(), textColor.getZ(), textColor.getW());
        GraphicsHandler.drawString(getText(), getAbsolutePosition().getX() + 3,
                getAbsolutePosition().getY() + 3, getSize().getY() - 6, false);
        if (selected == this) {
            GL11.glBegin(GL11.GL_QUADS);
            int /* I got 'em foaming from the mouth and I just hit 'em with the */ baseX = getAbsolutePosition()
                    .getX()
                    + GraphicsHandler.getStringLength(getText().substring(0, column + 1), getSize().getY() - 6)
                    + 1;
            int baseY = getAbsolutePosition().getY() + 1;
            GL11.glVertex2i(baseX, baseY);
            GL11.glVertex2i(baseX + 2, baseY);
            GL11.glVertex2i(baseX + 2, baseY + getSize().getY() - 2);
            GL11.glVertex2i(baseX, baseY + getSize().getY() - 2);
            GL11.glEnd();
        }
    }
}

From source file:com.irr310.i3d.scene.I3dCamera.java

License:Open Source License

public void display(float width, float height) {

    this.currentWidth = width;
    this.currentHeight = height;

    GL11.glMatrixMode(GL11.GL_PROJECTION);
    GL11.glLoadIdentity();/*from   ww w .j a  v a  2  s .com*/
    GL11.glOrtho(0, width, 0, height, -2000.0, 2000.0);
    GL11.glMatrixMode(GL11.GL_MODELVIEW);
    GL11.glLoadIdentity();

    backgroundScene.display(this);

    GL11.glMatrixMode(GL11.GL_PROJECTION);
    GL11.glLoadIdentity();
    initPerspective();
    GL11.glMatrixMode(GL11.GL_MODELVIEW);
    GL11.glLoadIdentity();

    GL11.glPushMatrix();

    configureView(glu);

    if (!configured) {
        configured = true;
        if (cameraInitialisation != null) {
            cameraInitialisation.run();
            cameraInitialisation = null;
        }
    }

    GL11.glColor3f(1, 0, 0);
    GL11.glBegin(GL11.GL_LINES);
    GL11.glVertex3d(0, 0, 0);
    GL11.glVertex3d(100, 100, 100);
    GL11.glEnd();

    preDisplayScene();
    if (currentScene != null) {
        currentScene.display(this);
    }
    postDisplayScene();

    preDisplayGui();
    postDisplayGui();

    GL11.glMatrixMode(GL11.GL_PROJECTION);
    GL11.glLoadIdentity();
    GL11.glOrtho(0, width, 0, height, -2000.0, 2000.0);
    GL11.glMatrixMode(GL11.GL_MODELVIEW);
    GL11.glLoadIdentity();

    hudScene.display(this);

    GL11.glPopMatrix();

}

From source file:com.irr310.i3d.scene.I3dEye3DCamera.java

License:Open Source License

private void displayTarget() {

    GL11.glColor4f(1.0f, 0.5f, 0.5f, 0.8f);
    GL11.glLineWidth(1.2f);//from ww  w .j  ava  2 s.  c  o  m
    GL11.glBegin(GL11.GL_LINES);
    {

        GL11.glColor4f(1.0f, 0.0f, 0.0f, 0.8f);
        GL11.glVertex3d(-1, 0, 0);
        GL11.glVertex3d(1, 0, 0);

        GL11.glVertex3d(0.9, 0.1, 0);
        GL11.glVertex3d(1, 0, 0);

        GL11.glVertex3d(0.9, -0.1, 0);
        GL11.glVertex3d(1, 0, 0);

        // y
        GL11.glColor4f(0.0f, 1.0f, 0.0f, 0.8f);
        GL11.glVertex3d(0, -1, 0);
        GL11.glVertex3d(0, 1, 0);

        GL11.glVertex3d(0.1, 0.9, 0);
        GL11.glVertex3d(0, 1, 0);

        GL11.glVertex3d(-0.1, 0.9, 0);
        GL11.glVertex3d(0, 1, 0);

        // z
        GL11.glColor4f(0.0f, 0.0f, 1.0f, 0.8f);
        GL11.glVertex3d(0, 0, -1);
        GL11.glVertex3d(0, 0, 1);

        GL11.glVertex3d(0.1, 0, 0.9);
        GL11.glVertex3d(0, 0, 1);

        GL11.glVertex3d(-0.1, 0, 0.9);
        GL11.glVertex3d(0, 0, 1);

    }
    GL11.glEnd();

    GL11.glPointSize(1.2f);
    GL11.glBegin(GL11.GL_POINTS);
    {
        GL11.glVertex3d(position.x, position.y, position.z);

    }
    GL11.glEnd();

}

From source file:com.jmex.bui.background.TintedBackground.java

License:Open Source License

public void render(Renderer renderer, int x, int y, int width, int height, float alpha) {
    super.render(renderer, x, y, width, height, alpha);

    BComponent.applyDefaultStates();// w  w  w.  j a v a2 s . c o  m
    BImage.blendState.apply();

    GL11.glColor4f(_color.r, _color.g, _color.b, _color.a * alpha);
    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();
}