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:name.martingeisse.swtlib.canvas.OpenGlImageBlockCanvas.java

License:Open Source License

@Override
protected void drawBlock(final int x, final int y) {
    palette.safeBind(getBlock(x, y));/*from w  w w.  j ava  2s. c o m*/
    GL11.glTexParameterf(GL11.GL_TEXTURE_2D, GL11.GL_TEXTURE_MAG_FILTER, GL11.GL_NEAREST);

    // glBegin/glEnd must be called per block because of changing textures
    GL11.glBegin(GL11.GL_QUADS);
    GL11.glTexCoord2f(0.0f, 0.0f);
    GL11.glVertex2i(x, y);
    GL11.glTexCoord2f(1.0f, 0.0f);
    GL11.glVertex2i(x + 1, y);
    GL11.glTexCoord2f(1.0f, 1.0f);
    GL11.glVertex2i(x + 1, y + 1);
    GL11.glTexCoord2f(0.0f, 1.0f);
    GL11.glVertex2i(x, y + 1);
    GL11.glEnd();

}

From source file:net.ae97.notlet.client.GameInstance.java

License:Open Source License

private static void renderHUD(Player player) {

    textureMapping.get("SMALLLET").bind();
    GL11.glBegin(GL11.GL_QUADS);
    GL11.glTexCoord2f(0, 0);/*w  w w. jav  a2  s  .  c  o m*/
    GL11.glVertex2f(200, 608);
    GL11.glTexCoord2f(1, 0);
    GL11.glVertex2f(400, 608);
    GL11.glTexCoord2f(1, 1);
    GL11.glVertex2f(400, 648);
    GL11.glTexCoord2f(0, 1);
    GL11.glVertex2f(200, 648);
    GL11.glEnd();

    font.drawString(65, 610, Integer.toString(player.getHp()), Color.white);
    textureMapping.get("healthbar").bind();
    GL11.glBegin(GL11.GL_QUADS);
    GL11.glTexCoord2f(0, 0);
    GL11.glVertex2f(20, 610);
    GL11.glTexCoord2f(1, 0);
    GL11.glVertex2f(60, 610);
    GL11.glTexCoord2f(1, 1);
    GL11.glVertex2f(60, 630);
    GL11.glTexCoord2f(0, 1);
    GL11.glVertex2f(20, 630);
    GL11.glEnd();
}

From source file:net.ae97.notlet.client.GameInstance.java

License:Open Source License

private static void renderEntity(Entity entity) {
    int SpriteScaleFactor = 1;
    double x = entity.getLocation().getX();
    double y = entity.getLocation().getY();
    Texture texture = textureMapping.get(entity.getSprite());
    texture.bind();//from   w w  w .java 2  s .c  o m
    GL11.glBegin(GL11.GL_QUADS);
    GL11.glTexCoord2f(0, 0);
    GL11.glVertex2d(x * 32, y * 32);
    GL11.glTexCoord2f(1, 0);
    GL11.glVertex2d((x * 32) + texture.getTextureWidth() * SpriteScaleFactor, y * 32);
    GL11.glTexCoord2f(1, 1);
    GL11.glVertex2d((x * 32) + texture.getTextureWidth() * SpriteScaleFactor,
            (y * 32) + texture.getTextureHeight() * SpriteScaleFactor);
    GL11.glTexCoord2f(0, 1);
    GL11.glVertex2d(x * 32, (y * 32) + texture.getTextureHeight() * SpriteScaleFactor);
    if (entity instanceof Arrow) {
        Arrow arrow = (Arrow) entity;
        switch (arrow.getFacingDirection()) {
        case DOWN:
            GL11.glRotated(90, 0, 0, 0);
        case LEFT:
            GL11.glRotated(90, 0, 0, 0);
        case UP:
            GL11.glRotated(90, 0, 0, 0);
        }
    }
    GL11.glEnd();
}

From source file:net.ae97.notlet.client.GameInstance.java

License:Open Source License

public static void renderFG(int x, int y) {
    GL11.glBegin(GL11.GL_QUADS);
    GL11.glTexCoord2f(0, 0);//from w w  w . j ava  2s .  c  om
    GL11.glVertex2f(x, y);
    GL11.glTexCoord2f(1, 0);
    GL11.glVertex2f(x + 32, y);
    GL11.glTexCoord2f(1, 1);
    GL11.glVertex2f(x + 32, y + 32);
    GL11.glTexCoord2f(0, 1);
    GL11.glVertex2f(x, y + 32);
    GL11.glEnd();
}

From source file:net.BiggerOnTheInside.Binder.BlockRenderer.java

License:Open Source License

public static void renderBlock(Block b, float x, float y, float z) {
    GL11.glPushMatrix();/*from   w ww  . j a va 2 s .  com*/
    GL11.glTexParameteri(GL11.GL_TEXTURE_2D, GL11.GL_TEXTURE_MIN_FILTER, GL11.GL_NEAREST);
    GL11.glTexParameteri(GL11.GL_TEXTURE_2D, GL11.GL_TEXTURE_MAG_FILTER, GL11.GL_NEAREST);
    GL11.glTranslatef(x * 2f, y * 2f, z * 2f);
    GL11.glBegin(GL11.GL_QUADS);
    GL11.glColor3f(1f, 1f, 1f);

    // Top face.
    GL11.glTexCoord2f(b.getTextureCoordinates(BlockFace.Top).x(), b.getTextureCoordinates(BlockFace.Top).y());
    GL11.glVertex3f(1.0f, 1.0f, -1.0f);
    GL11.glTexCoord2f(b.getTextureCoordinates(BlockFace.Top).x() + Globals.TEXTURE_SIZE,
            b.getTextureCoordinates(BlockFace.Top).y());
    GL11.glVertex3f(-1.0f, 1.0f, -1.0f);
    GL11.glTexCoord2f(b.getTextureCoordinates(BlockFace.Top).x() + Globals.TEXTURE_SIZE,
            b.getTextureCoordinates(BlockFace.Top).y() + Globals.TEXTURE_SIZE);
    GL11.glVertex3f(-1.0f, 1.0f, 1.0f);
    GL11.glTexCoord2f(b.getTextureCoordinates(BlockFace.Top).x(),
            b.getTextureCoordinates(BlockFace.Top).y() + Globals.TEXTURE_SIZE);
    GL11.glVertex3f(1.0f, 1.0f, 1.0f);

    // Bottom.
    GL11.glTexCoord2f(b.getTextureCoordinates(BlockFace.Bottom).x(),
            b.getTextureCoordinates(BlockFace.Bottom).y());
    GL11.glVertex3f(1.0f, -1.0f, 1.0f);
    GL11.glTexCoord2f(b.getTextureCoordinates(BlockFace.Bottom).x() + Globals.TEXTURE_SIZE,
            b.getTextureCoordinates(BlockFace.Bottom).y());
    GL11.glVertex3f(-1.0f, -1.0f, 1.0f);
    GL11.glTexCoord2f(b.getTextureCoordinates(BlockFace.Bottom).x() + Globals.TEXTURE_SIZE,
            b.getTextureCoordinates(BlockFace.Bottom).y() + Globals.TEXTURE_SIZE);
    GL11.glVertex3f(-1.0f, -1.0f, -1.0f);
    GL11.glTexCoord2f(b.getTextureCoordinates(BlockFace.Bottom).x(),
            b.getTextureCoordinates(BlockFace.Bottom).y() + Globals.TEXTURE_SIZE);
    GL11.glVertex3f(1.0f, -1.0f, -1.0f);

    // Front.
    GL11.glTexCoord2f(b.getTextureCoordinates(BlockFace.Front).x(),
            b.getTextureCoordinates(BlockFace.Front).y());
    GL11.glVertex3f(1.0f, 1.0f, 1.0f);
    GL11.glTexCoord2f(b.getTextureCoordinates(BlockFace.Front).x() + Globals.TEXTURE_SIZE,
            b.getTextureCoordinates(BlockFace.Front).y());
    GL11.glVertex3f(-1.0f, 1.0f, 1.0f);
    GL11.glTexCoord2f(b.getTextureCoordinates(BlockFace.Front).x() + Globals.TEXTURE_SIZE,
            b.getTextureCoordinates(BlockFace.Front).y() + Globals.TEXTURE_SIZE);
    GL11.glVertex3f(-1.0f, -1.0f, 1.0f);
    GL11.glTexCoord2f(b.getTextureCoordinates(BlockFace.Front).x(),
            b.getTextureCoordinates(BlockFace.Front).y() + Globals.TEXTURE_SIZE);
    GL11.glVertex3f(1.0f, -1.0f, 1.0f);

    // Back.
    GL11.glTexCoord2f(b.getTextureCoordinates(BlockFace.Back).x(), b.getTextureCoordinates(BlockFace.Back).y());
    GL11.glVertex3f(1.0f, -1.0f, -1.0f);
    GL11.glTexCoord2f(b.getTextureCoordinates(BlockFace.Back).x() + Globals.TEXTURE_SIZE,
            b.getTextureCoordinates(BlockFace.Back).y());
    GL11.glVertex3f(-1.0f, -1.0f, -1.0f);
    GL11.glTexCoord2f(b.getTextureCoordinates(BlockFace.Back).x() + Globals.TEXTURE_SIZE,
            b.getTextureCoordinates(BlockFace.Back).y() + Globals.TEXTURE_SIZE);
    GL11.glVertex3f(-1.0f, 1.0f, -1.0f);
    GL11.glTexCoord2f(b.getTextureCoordinates(BlockFace.Back).x(),
            b.getTextureCoordinates(BlockFace.Back).y() + Globals.TEXTURE_SIZE);
    GL11.glVertex3f(1.0f, 1.0f, -1.0f);

    // Left
    GL11.glTexCoord2f(b.getTextureCoordinates(BlockFace.Left).x(), b.getTextureCoordinates(BlockFace.Left).y());
    GL11.glVertex3f(-1.0f, 1.0f, 1.0f);
    GL11.glTexCoord2f(b.getTextureCoordinates(BlockFace.Left).x() + Globals.TEXTURE_SIZE,
            b.getTextureCoordinates(BlockFace.Left).y());
    GL11.glVertex3f(-1.0f, 1.0f, -1.0f);
    GL11.glTexCoord2f(b.getTextureCoordinates(BlockFace.Left).x() + Globals.TEXTURE_SIZE,
            b.getTextureCoordinates(BlockFace.Left).y() + Globals.TEXTURE_SIZE);
    GL11.glVertex3f(-1.0f, -1.0f, -1.0f);
    GL11.glTexCoord2f(b.getTextureCoordinates(BlockFace.Left).x(),
            b.getTextureCoordinates(BlockFace.Left).y() + Globals.TEXTURE_SIZE);
    GL11.glVertex3f(-1.0f, -1.0f, 1.0f);

    // Right.
    GL11.glTexCoord2f(b.getTextureCoordinates(BlockFace.Right).x(),
            b.getTextureCoordinates(BlockFace.Right).y());
    GL11.glVertex3f(1.0f, 1.0f, -1.0f);
    GL11.glTexCoord2f(b.getTextureCoordinates(BlockFace.Right).x() + Globals.TEXTURE_SIZE,
            b.getTextureCoordinates(BlockFace.Right).y());
    GL11.glVertex3f(1.0f, 1.0f, 1.0f);
    GL11.glTexCoord2f(b.getTextureCoordinates(BlockFace.Right).x() + Globals.TEXTURE_SIZE,
            b.getTextureCoordinates(BlockFace.Right).y() + Globals.TEXTURE_SIZE);
    GL11.glVertex3f(1.0f, -1.0f, 1.0f);
    GL11.glTexCoord2f(b.getTextureCoordinates(BlockFace.Right).x(),
            b.getTextureCoordinates(BlockFace.Right).y() + Globals.TEXTURE_SIZE);
    GL11.glVertex3f(1.0f, -1.0f, -1.0f);
    GL11.glEnd();
    GL11.glTranslatef(0f, 0f, 0f);
    GL11.glPopMatrix();
}

From source file:net.BiggerOnTheInside.Binder.BlockRenderer.java

License:Open Source License

public static void renderWireframeBlock(Block b, float x, float y, float z) {
    GL11.glTranslatef(x * 2f, y * 2f, z * 2f);
    GL11.glBegin(GL11.GL_LINE_LOOP);
    GL11.glColor3f(0.0f, 1.0f, 0.0f);/*from w ww .  j av  a 2s  .  c  o  m*/
    GL11.glVertex3f(1.0f, 1.0f, -1.0f);
    GL11.glVertex3f(-1.0f, 1.0f, -1.0f);
    GL11.glVertex3f(-1.0f, 1.0f, 1.0f);
    GL11.glVertex3f(1.0f, 1.0f, 1.0f);
    GL11.glColor3f(1.0f, 0.5f, 0.0f);
    GL11.glVertex3f(1.0f, -1.0f, 1.0f);
    GL11.glVertex3f(-1.0f, -1.0f, 1.0f);
    GL11.glVertex3f(-1.0f, -1.0f, -1.0f);
    GL11.glVertex3f(1.0f, -1.0f, -1.0f);
    GL11.glColor3f(1.0f, 0.0f, 0.0f);
    GL11.glVertex3f(1.0f, 1.0f, 1.0f);
    GL11.glVertex3f(-1.0f, 1.0f, 1.0f);
    GL11.glVertex3f(-1.0f, -1.0f, 1.0f);
    GL11.glVertex3f(1.0f, -1.0f, 1.0f);
    GL11.glColor3f(1.0f, 1.0f, 0.0f);
    GL11.glVertex3f(1.0f, -1.0f, -1.0f);
    GL11.glVertex3f(-1.0f, -1.0f, -1.0f);
    GL11.glVertex3f(-1.0f, 1.0f, -1.0f);
    GL11.glVertex3f(1.0f, 1.0f, -1.0f);
    GL11.glColor3f(0.0f, 0.0f, 1.0f);
    GL11.glVertex3f(-1.0f, 1.0f, 1.0f);
    GL11.glVertex3f(-1.0f, 1.0f, -1.0f);
    GL11.glVertex3f(-1.0f, -1.0f, -1.0f);
    GL11.glVertex3f(-1.0f, -1.0f, 1.0f);
    GL11.glColor3f(1.0f, 0.0f, 1.0f);
    GL11.glVertex3f(1.0f, 1.0f, -1.0f);
    GL11.glVertex3f(1.0f, 1.0f, 1.0f);
    GL11.glVertex3f(1.0f, -1.0f, 1.0f);
    GL11.glVertex3f(1.0f, -1.0f, -1.0f);
    GL11.glEnd();
    GL11.glTranslatef(0f, 0f, 0f);
}

From source file:net.BiggerOnTheInside.Binder.engine.BlockRenderer.java

License:Open Source License

public static void renderBlock(Block b, float x, float y, float z) {
    GL11.glTranslatef(x * 2f, y * 2f, z * 2f);

    GL11.glBegin(GL11.GL_QUADS);
    GL11.glColor3f(0.0f, 1.0f, 0.0f);// w  ww. jav  a2  s . c om
    GL11.glVertex3f(1.0f, 1.0f, -1.0f);
    GL11.glVertex3f(-1.0f, 1.0f, -1.0f);
    GL11.glVertex3f(-1.0f, 1.0f, 1.0f);
    GL11.glVertex3f(1.0f, 1.0f, 1.0f);
    GL11.glColor3f(1.0f, 0.5f, 0.0f);
    GL11.glVertex3f(1.0f, -1.0f, 1.0f);
    GL11.glVertex3f(-1.0f, -1.0f, 1.0f);
    GL11.glVertex3f(-1.0f, -1.0f, -1.0f);
    GL11.glVertex3f(1.0f, -1.0f, -1.0f);
    GL11.glColor3f(1.0f, 0.0f, 0.0f);
    GL11.glVertex3f(1.0f, 1.0f, 1.0f);
    GL11.glVertex3f(-1.0f, 1.0f, 1.0f);
    GL11.glVertex3f(-1.0f, -1.0f, 1.0f);
    GL11.glVertex3f(1.0f, -1.0f, 1.0f);
    GL11.glColor3f(1.0f, 1.0f, 0.0f);
    GL11.glVertex3f(1.0f, -1.0f, -1.0f);
    GL11.glVertex3f(-1.0f, -1.0f, -1.0f);
    GL11.glVertex3f(-1.0f, 1.0f, -1.0f);
    GL11.glVertex3f(1.0f, 1.0f, -1.0f);
    GL11.glColor3f(0.0f, 0.0f, 1.0f);
    GL11.glVertex3f(-1.0f, 1.0f, 1.0f);
    GL11.glVertex3f(-1.0f, 1.0f, -1.0f);
    GL11.glVertex3f(-1.0f, -1.0f, -1.0f);
    GL11.glVertex3f(-1.0f, -1.0f, 1.0f);
    GL11.glColor3f(1.0f, 0.0f, 1.0f);
    GL11.glVertex3f(1.0f, 1.0f, -1.0f);
    GL11.glVertex3f(1.0f, 1.0f, 1.0f);
    GL11.glVertex3f(1.0f, -1.0f, 1.0f);
    GL11.glVertex3f(1.0f, -1.0f, -1.0f);
    GL11.glEnd();

    GL11.glTranslatef(0f, 0f, 0f);
}

From source file:net.BiggerOnTheInside.Binder.engine.BlockRenderer.java

License:Open Source License

public static void renderWireframeBlock(Block b, float x, float y, float z) {
    GL11.glTranslatef(x * 2f, y * 2f, z * 2f);

    GL11.glBegin(GL11.GL_LINE_LOOP);
    GL11.glColor3f(0.0f, 1.0f, 0.0f);/*from ww w.j  a  v a  2 s .  co m*/
    GL11.glVertex3f(1.0f, 1.0f, -1.0f);
    GL11.glVertex3f(-1.0f, 1.0f, -1.0f);
    GL11.glVertex3f(-1.0f, 1.0f, 1.0f);
    GL11.glVertex3f(1.0f, 1.0f, 1.0f);
    GL11.glColor3f(1.0f, 0.5f, 0.0f);
    GL11.glVertex3f(1.0f, -1.0f, 1.0f);
    GL11.glVertex3f(-1.0f, -1.0f, 1.0f);
    GL11.glVertex3f(-1.0f, -1.0f, -1.0f);
    GL11.glVertex3f(1.0f, -1.0f, -1.0f);
    GL11.glColor3f(1.0f, 0.0f, 0.0f);
    GL11.glVertex3f(1.0f, 1.0f, 1.0f);
    GL11.glVertex3f(-1.0f, 1.0f, 1.0f);
    GL11.glVertex3f(-1.0f, -1.0f, 1.0f);
    GL11.glVertex3f(1.0f, -1.0f, 1.0f);
    GL11.glColor3f(1.0f, 1.0f, 0.0f);
    GL11.glVertex3f(1.0f, -1.0f, -1.0f);
    GL11.glVertex3f(-1.0f, -1.0f, -1.0f);
    GL11.glVertex3f(-1.0f, 1.0f, -1.0f);
    GL11.glVertex3f(1.0f, 1.0f, -1.0f);
    GL11.glColor3f(0.0f, 0.0f, 1.0f);
    GL11.glVertex3f(-1.0f, 1.0f, 1.0f);
    GL11.glVertex3f(-1.0f, 1.0f, -1.0f);
    GL11.glVertex3f(-1.0f, -1.0f, -1.0f);
    GL11.glVertex3f(-1.0f, -1.0f, 1.0f);
    GL11.glColor3f(1.0f, 0.0f, 1.0f);
    GL11.glVertex3f(1.0f, 1.0f, -1.0f);
    GL11.glVertex3f(1.0f, 1.0f, 1.0f);
    GL11.glVertex3f(1.0f, -1.0f, 1.0f);
    GL11.glVertex3f(1.0f, -1.0f, -1.0f);
    GL11.glEnd();

    GL11.glTranslatef(0f, 0f, 0f);
}

From source file:net.BiggerOnTheInside.Binder.engine.world.World.java

License:Open Source License

private void Render() {
    // GL11.glClear(GL11.GL_COLOR_BUFFER_BIT | GL11.GL_DEPTH_BUFFER_BIT);
    //GL11.glLoadIdentity();  

    GL11.glTranslatef(0f, 0.0f, -7f);//from  w  ww .  j a v  a  2s .  c o m
    // GL11.glRotatef(45f,0.0f,1.0f,0.0f);               
    GL11.glColor3f(0.5f, 0.5f, 1.0f);

    GL11.glBegin(GL11.GL_QUADS);
    GL11.glColor3f(1.0f, 1.0f, 0.0f);
    GL11.glVertex3f(1.0f, 1.0f, -1.0f);
    GL11.glVertex3f(-1.0f, 1.0f, -1.0f);
    GL11.glVertex3f(-1.0f, 1.0f, 1.0f);
    GL11.glVertex3f(1.0f, 1.0f, 1.0f);
    GL11.glColor3f(1.0f, 0.5f, 0.0f);
    GL11.glVertex3f(1.0f, -1.0f, 1.0f);
    GL11.glVertex3f(-1.0f, -1.0f, 1.0f);
    GL11.glVertex3f(-1.0f, -1.0f, -1.0f);
    GL11.glVertex3f(1.0f, -1.0f, -1.0f);
    GL11.glColor3f(1.0f, 0.0f, 0.0f);
    GL11.glVertex3f(1.0f, 1.0f, 1.0f);
    GL11.glVertex3f(-1.0f, 1.0f, 1.0f);
    GL11.glVertex3f(-1.0f, -1.0f, 1.0f);
    GL11.glVertex3f(1.0f, -1.0f, 1.0f);
    GL11.glColor3f(1.0f, 1.0f, 0.0f);
    GL11.glVertex3f(1.0f, -1.0f, -1.0f);
    GL11.glVertex3f(-1.0f, -1.0f, -1.0f);
    GL11.glVertex3f(-1.0f, 1.0f, -1.0f);
    GL11.glVertex3f(1.0f, 1.0f, -1.0f);
    GL11.glColor3f(0.0f, 0.0f, 1.0f);
    GL11.glVertex3f(-1.0f, 1.0f, 1.0f);
    GL11.glVertex3f(-1.0f, 1.0f, -1.0f);
    GL11.glVertex3f(-1.0f, -1.0f, -1.0f);
    GL11.glVertex3f(-1.0f, -1.0f, 1.0f);
    GL11.glColor3f(1.0f, 0.0f, 1.0f);
    GL11.glVertex3f(1.0f, 1.0f, -1.0f);
    GL11.glVertex3f(1.0f, 1.0f, 1.0f);
    GL11.glVertex3f(1.0f, -1.0f, 1.0f);
    GL11.glVertex3f(1.0f, -1.0f, -1.0f);
    GL11.glEnd();
    GL11.glTranslatef(0, 0, 0);
}

From source file:net.bryanbergen.lwjgl.test.Main.java

public static void main(String... args) {
    Dimension d = new Dimension(0, 0, 960, 600);
    Window.Builder builder = new Window.Builder(d);
    builder.setTitle("Test Window");
    builder.setFullscreen(false);/*  w w  w  .  j av a2s  .  c o m*/
    builder.setResizable(true);
    builder.setVisible(true);
    builder.setVsync(true);
    builder.setBackground(Color.BLUE);

    Window window = builder.build();
    window.addKeyListener(new KeyAdapter() {
        @Override
        public void KeyPressed(KeyEvent event) {
            if (event.getKeycode() == KeyCode.KEY_ESCAPE) {
                window.close();
            }
        }
    });
    window.addKeyListener(new ColorSwapper());
    window.addMouseListener(new ColorClicker(window));
    while (!window.shouldClose()) {
        window.clear();
        // immediate mode for testing only
        GL11.glColor3f((float) color.getRed(), (float) color.getGreen(), (float) color.getBlue());
        GL11.glBegin(GL_QUADS);
        GL11.glVertex2f(-.5f, -.5f);
        GL11.glVertex2f(-.5f, .5f);
        GL11.glVertex2f(.5f, .5f);
        GL11.glVertex2f(.5f, -.5f);
        GL11.glEnd();
        window.update();
    }
    window.dispose();
}