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.craftmania.blocks.CrossedBlockBrush.java

License:Apache License

@Override
public void create() {
    _callList = GL11.glGenLists(1);//from w  ww .  j a v a  2s .com

    GL11.glNewList(_callList, GL11.GL_COMPILE);
    GL11.glBegin(GL11.GL_QUADS);

    GL11.glTexCoord2f(_texturePosition.x(), _texturePosition.y());
    GL11.glVertex3f(-0.5f, 0.5f, -0.5f);
    GL11.glTexCoord2f(_texturePosition.x() + _textureSize.x(), _texturePosition.y());
    GL11.glVertex3f(0.5f, 0.5f, 0.5f);
    GL11.glTexCoord2f(_texturePosition.x() + _textureSize.x(), _texturePosition.y() + _textureSize.y());
    GL11.glVertex3f(0.5f, -0.5f, 0.5f);
    GL11.glTexCoord2f(_texturePosition.x(), _texturePosition.y() + _textureSize.y());
    GL11.glVertex3f(-0.5f, -0.5f, -0.5f);

    GL11.glTexCoord2f(_texturePosition.x(), _texturePosition.y());
    GL11.glVertex3f(0.5f, 0.5f, -0.5f);
    GL11.glTexCoord2f(_texturePosition.x() + _textureSize.x(), _texturePosition.y());
    GL11.glVertex3f(-0.5f, 0.5f, 0.5f);
    GL11.glTexCoord2f(_texturePosition.x() + _textureSize.x(), _texturePosition.y() + _textureSize.y());
    GL11.glVertex3f(-0.5f, -0.5f, 0.5f);
    GL11.glTexCoord2f(_texturePosition.x(), _texturePosition.y() + _textureSize.y());
    GL11.glVertex3f(0.5f, -0.5f, -0.5f);
    GL11.glEnd();
    GL11.glEndList();
}

From source file:org.craftmania.inventory.CraftingTableInventory.java

License:Apache License

@Override
public void renderInventory() {
    if (_inventoryDrawList == -1) {
        return;/*w ww  .j a v  a  2 s.  c o  m*/
    }

    Configuration conf = Game.getInstance().getConfiguration();

    GL11.glPushMatrix();
    GL11.glTranslatef(conf.getWidth() / 2.0f, conf.getHeight() / 2.0f, 0.0f);

    _tex.bind();

    GL11.glCallList(_inventoryDrawList);
    GL11.glPopMatrix();

    for (int i = 0; i < _raster.getCellCount(); ++i) {
        GL11.glPushMatrix();
        ReadablePoint r = _raster.getCenterOfCell(i);
        GL11.glTranslatef(r.getX(), r.getY(), 0);
        if (Mouse.getX() < r.getX() + 16 && Mouse.getX() > r.getX() - 16 && Mouse.getY() < r.getY() + 16
                && Mouse.getY() > r.getY() - 16) {
            GL11.glDisable(GL11.GL_TEXTURE_2D);
            GL11.glColor4f(1.0f, 1.0f, 1.0f, 0.2f);
            GL11.glBegin(GL11.GL_QUADS);
            GL11.glVertex2i(-16, -16);
            GL11.glVertex2i(+16, -16);
            GL11.glVertex2i(+16, +16);
            GL11.glVertex2i(-16, +16);
            GL11.glEnd();
            GL11.glColor4f(1.0f, 1.0f, 1.0f, 1.0f);

        }

        InventoryPlace place = getInventoryPlace(i);
        if (place != null) {
            place.render();
        }
        GL11.glPopMatrix();
    }

    /* Draggin item */
    if (_dragging && _draggingItem != null) {
        GL11.glPushMatrix();
        GL11.glTranslatef(Mouse.getX(), Mouse.getY(), 0);
        _draggingItem.render();
        GL11.glPopMatrix();
    }
}

From source file:org.craftmania.world.Sky.java

License:Apache License

private void drawShpere(float x, float y, float z) {
    GL11.glPushMatrix();// www  . j a v a 2s .  c  om
    GL11.glTranslatef(x, y, z);
    GL11.glColor3f(_color.x(), _color.y(), _color.z());
    if (_sphereCallList == 0) {
        _sphereCallList = GL11.glGenLists(1);
        GL11.glNewList(_sphereCallList, GL11.GL_COMPILE_AND_EXECUTE);
        GL11.glBegin(GL11.GL_TRIANGLE_FAN);
        GL11.glVertex3f(0, 0, 0);
        for (int i = 0; i <= _vertices; ++i) {
            float angle = MathHelper.f_2PI / _vertices * i;
            float xx = MathHelper.cos(angle) * _radius;
            float zz = MathHelper.sin(angle) * _radius;
            GL11.glVertex3f(xx, -_bend, zz);
        }
        GL11.glEnd();
        GL11.glEndList();
    } else {
        GL11.glCallList(_sphereCallList);
    }
    GL11.glPopMatrix();
}

From source file:org.craftmania.world.Sky.java

License:Apache License

private void drawClouds(float x, float y, float z) {
    GL11.glPushMatrix();//  ww  w.  ja  v  a 2s  .  com
    GL11.glTranslatef(x, y, z);
    if (_cloudsCallList == 0) {
        _cloudsCallList = GL11.glGenLists(1);
        GL11.glNewList(_cloudsCallList, GL11.GL_COMPILE_AND_EXECUTE);
        float hw = _cloudsTexWidth / 2.0f;
        float hh = _cloudsTexHeight / 2.0f;

        hw *= _cloudsScale;
        hh *= _cloudsScale;

        GL11.glBegin(GL11.GL_QUADS);

        GL11.glTexCoord2f(0, 0);
        GL11.glVertex3f(-hw, 0, -hh);

        GL11.glTexCoord2f(1, 0);
        GL11.glVertex3f(+hw, 0, -hh);

        GL11.glTexCoord2f(1, 1);
        GL11.glVertex3f(+hw, 0, +hh);

        GL11.glTexCoord2f(0, 1);
        GL11.glVertex3f(-hw, 0, +hh);

        GL11.glEnd();

        GL11.glEndList();
    } else {
        GL11.glCallList(_cloudsCallList);
    }
    GL11.glPopMatrix();
}

From source file:org.craftmania.world.World.java

License:Apache License

private void renderOverlay() {
    Configuration conf = Game.getInstance().getConfiguration();

    Game.getInstance().initOverlayRendering();

    GL11.glColor3f(1, 1, 1);/*from  w  w w.  j  a  va2s.c om*/

    if (Game.RENDER_INFORMATION_OVERLAY) {
        GLFont infoFont = FontStorage.getFont("Monospaced_20");

        /* Down Left Info */
        infoFont.print(4, 4, "CraftMania");
        infoFont.print(4, 30, _player.coordinatesToString());
        infoFont.print(4, 45, "Visible Chunks:      " + _visibleChunks.size());
        infoFont.print(4, 60, "Updading Blocks:     " + _updatingBlocks);
        infoFont.print(4, 75, "Total Chunks in RAM: " + _chunkManager.getTotalChunkCount());
        infoFont.print(4, 90, "Local Chunks:        " + _localChunks.size());
        infoFont.print(4, 105, "Total Local Blocks:  " + _localBlockCount);
        infoFont.print(4, 120, "Time:  " + _time);
        infoFont.print(4, 135, "Sunlight:  " + _sunlight);

    }
    /** RENDER **/
    if (_activatedInventory != null) {
        Game.getInstance().renderTransculentOverlayLayer();
        _activatedInventory.renderInventory();
    } else {
        int width = conf.getWidth();
        int height = conf.getHeight();
        // Center Cross
        GL11.glDisable(GL11.GL_TEXTURE_2D);
        if (CENTER_CROSS_CALL_LIST == 0) {
            CENTER_CROSS_CALL_LIST = GL11.glGenLists(1);
            GL11.glNewList(CENTER_CROSS_CALL_LIST, GL11.GL_COMPILE_AND_EXECUTE);

            int crossSize = 10;
            int crossHole = 5;

            GL11.glLineWidth(2.5f);

            GL11.glColor3f(0, 0, 0);
            GL11.glBegin(GL11.GL_LINES);
            GL11.glVertex3f(width / 2f - crossSize - crossHole, height / 2f, 0);
            GL11.glVertex3f(width / 2f - crossHole, height / 2f, 0);

            GL11.glVertex3f(width / 2f + crossSize + crossHole, height / 2f, 0);
            GL11.glVertex3f(width / 2f + crossHole, height / 2f, 0);

            GL11.glVertex3f(width / 2f, height / 2f - crossSize - crossHole, 0);
            GL11.glVertex3f(width / 2f, height / 2f - crossHole, 0);

            GL11.glVertex3f(width / 2f, height / 2f + crossSize + crossHole, 0);
            GL11.glVertex3f(width / 2f, height / 2f + crossHole, 0);

            GL11.glEnd();
            GL11.glEndList();
        } else {
            GL11.glCallList(CENTER_CROSS_CALL_LIST);
        }
        GL11.glEnable(GL11.GL_TEXTURE_2D);

        // Inventory bar
        GL11.glPushMatrix();
        Texture texGui = TextureStorage.getTexture("gui.gui");
        texGui.bind();
        float tileSize = 20.0f / texGui.getImageWidth();
        if (INVENTORY_BAR_CALL_LIST == 0) {
            INVENTORY_BAR_CALL_LIST = GL11.glGenLists(2);

            /* Bar */
            GL11.glNewList(INVENTORY_BAR_CALL_LIST, GL11.GL_COMPILE_AND_EXECUTE);

            GL11.glTranslatef(width / 2.0f - 9 * 20, 10, 0);
            GL11.glColor3f(1.0f, 1.0f, 1.0f);
            GL11.glBegin(GL11.GL_QUADS);

            GL11.glTexCoord2f(0, 0);
            GL11.glVertex2f(0, 40);

            GL11.glTexCoord2f(tileSize * 9, 0);
            GL11.glVertex2f(9 * 40, 40);

            GL11.glTexCoord2f(tileSize * 9, tileSize);
            GL11.glVertex2f(9 * 40, 0);

            GL11.glTexCoord2f(0, tileSize);
            GL11.glVertex2f(0, 0);

            GL11.glEnd();
            GL11.glEndList();

            /* Little frame around selected item */
            float frameTileSize = 24.0f / texGui.getImageWidth();
            float frameTileY = 22.0f / texGui.getImageHeight();

            GL11.glNewList(INVENTORY_BAR_CALL_LIST + 1, GL11.GL_COMPILE);
            GL11.glBegin(GL11.GL_QUADS);

            GL11.glTexCoord2f(0, frameTileY);
            GL11.glVertex2f(0, 48);

            GL11.glTexCoord2f(frameTileSize, frameTileY);
            GL11.glVertex2f(48, 48);

            GL11.glTexCoord2f(frameTileSize, frameTileY + frameTileSize);
            GL11.glVertex2f(48, 0);

            GL11.glTexCoord2f(0, frameTileY + frameTileSize);
            GL11.glVertex2f(0, 0);

            GL11.glEnd();
            GL11.glEndList();
        } else {
            GL11.glCallList(INVENTORY_BAR_CALL_LIST);
        }

        /* Content */
        GL11.glPushMatrix();
        GL11.glTranslatef(20, 20, 0);
        for (int i = 0; i < 9; ++i) {
            InventoryPlace place = getActivePlayer().getInventory().getInventoryPlace(i);
            if (place != null)
                place.render();
            GL11.glTranslatef(40, 0, 0);
        }
        texGui.bind();
        GL11.glPopMatrix();
        GL11.glTranslatef(getActivePlayer().getSelectedInventoryItemIndex() * 40.0f - 4, -4, 0);
        GL11.glCallList(INVENTORY_BAR_CALL_LIST + 1);

        GL11.glPopMatrix();
    }
}

From source file:org.eclipse.swt.opengl.examples.LWJGLExample.java

License:Open Source License

static void drawTorus(float r, float R, int nsides, int rings) {
    float ringDelta = 2.0f * (float) Math.PI / rings;
    float sideDelta = 2.0f * (float) Math.PI / nsides;
    float theta = 0.0f, cosTheta = 1.0f, sinTheta = 0.0f;
    for (int i = rings - 1; i >= 0; i--) {
        float theta1 = theta + ringDelta;
        float cosTheta1 = (float) Math.cos(theta1);
        float sinTheta1 = (float) Math.sin(theta1);
        GL11.glBegin(GL11.GL_QUAD_STRIP);
        float phi = 0.0f;
        for (int j = nsides; j >= 0; j--) {
            phi += sideDelta;//  w w  w  .  j a v a  2  s . c  o  m
            float cosPhi = (float) Math.cos(phi);
            float sinPhi = (float) Math.sin(phi);
            float dist = R + r * cosPhi;
            GL11.glNormal3f(cosTheta1 * cosPhi, -sinTheta1 * cosPhi, sinPhi);
            GL11.glVertex3f(cosTheta1 * dist, -sinTheta1 * dist, r * sinPhi);
            GL11.glNormal3f(cosTheta * cosPhi, -sinTheta * cosPhi, sinPhi);
            GL11.glVertex3f(cosTheta * dist, -sinTheta * dist, r * sinPhi);
        }
        GL11.glEnd();
        theta = theta1;
        cosTheta = cosTheta1;
        sinTheta = sinTheta1;
    }
}

From source file:org.free.jake2.render.lwjgl.Draw.java

License:Open Source License

protected void Draw_Char(int x, int y, int num) {

    num &= 255;/*w w w.  ja  v a  2 s.c  om*/

    if ((num & 127) == 32) {
        return; // space
    }
    if (y <= -8) {
        return; // totally off screen
    }
    int row = num >> 4;
    int col = num & 15;

    float frow = row * 0.0625f;
    float fcol = col * 0.0625f;
    float size = 0.0625f;

    GL_Bind(draw_chars.texnum);

    GL11.glBegin(GL11.GL_QUADS);
    GL11.glTexCoord2f(fcol, frow);
    GL11.glVertex2f(x, y);
    GL11.glTexCoord2f(fcol + size, frow);
    GL11.glVertex2f(x + 8, y);
    GL11.glTexCoord2f(fcol + size, frow + size);
    GL11.glVertex2f(x + 8, y + 8);
    GL11.glTexCoord2f(fcol, frow + size);
    GL11.glVertex2f(x, y + 8);
    GL11.glEnd();
}

From source file:org.free.jake2.render.lwjgl.Draw.java

License:Open Source License

protected void Draw_StretchPic(int x, int y, int w, int h, String pic) {

    image_t image;//from   w w w  .j ava2 s.com

    image = Draw_FindPic(pic);
    if (image == null) {
        VID.Printf(Defines.PRINT_ALL, "Can't find pic: " + pic + '\n');
        return;
    }

    if (scrap_dirty) {
        Scrap_Upload();
    }

    if (((gl_config.renderer == GL_RENDERER_MCD) || ((gl_config.renderer & GL_RENDERER_RENDITION) != 0))
            && !image.has_alpha) {
        GL11.glDisable(GL11.GL_ALPHA_TEST);
    }

    GL_Bind(image.texnum);
    GL11.glBegin(GL11.GL_QUADS);
    GL11.glTexCoord2f(image.sl, image.tl);
    GL11.glVertex2f(x, y);
    GL11.glTexCoord2f(image.sh, image.tl);
    GL11.glVertex2f(x + w, y);
    GL11.glTexCoord2f(image.sh, image.th);
    GL11.glVertex2f(x + w, y + h);
    GL11.glTexCoord2f(image.sl, image.th);
    GL11.glVertex2f(x, y + h);
    GL11.glEnd();

    if (((gl_config.renderer == GL_RENDERER_MCD) || ((gl_config.renderer & GL_RENDERER_RENDITION) != 0))
            && !image.has_alpha) {
        GL11.glEnable(GL11.GL_ALPHA_TEST);
    }
}

From source file:org.free.jake2.render.lwjgl.Draw.java

License:Open Source License

protected void Draw_Pic(int x, int y, String pic) {
    image_t image;/*from w  w  w.j  a  v a 2 s .  c  o  m*/

    image = Draw_FindPic(pic);
    if (image == null) {
        VID.Printf(Defines.PRINT_ALL, "Can't find pic: " + pic + '\n');
        return;
    }
    if (scrap_dirty) {
        Scrap_Upload();
    }

    if (((gl_config.renderer == GL_RENDERER_MCD) || ((gl_config.renderer & GL_RENDERER_RENDITION) != 0))
            && !image.has_alpha) {
        GL11.glDisable(GL11.GL_ALPHA_TEST);
    }

    GL_Bind(image.texnum);

    GL11.glBegin(GL11.GL_QUADS);
    GL11.glTexCoord2f(image.sl, image.tl);
    GL11.glVertex2f(x, y);
    GL11.glTexCoord2f(image.sh, image.tl);
    GL11.glVertex2f(x + image.width, y);
    GL11.glTexCoord2f(image.sh, image.th);
    GL11.glVertex2f(x + image.width, y + image.height);
    GL11.glTexCoord2f(image.sl, image.th);
    GL11.glVertex2f(x, y + image.height);
    GL11.glEnd();

    if (((gl_config.renderer == GL_RENDERER_MCD) || ((gl_config.renderer & GL_RENDERER_RENDITION) != 0))
            && !image.has_alpha) {
        GL11.glEnable(GL11.GL_ALPHA_TEST);
    }
}

From source file:org.free.jake2.render.lwjgl.Draw.java

License:Open Source License

protected void Draw_TileClear(int x, int y, int w, int h, String pic) {
    image_t image;//www  .j a va  2  s .  co  m

    image = Draw_FindPic(pic);
    if (image == null) {
        VID.Printf(Defines.PRINT_ALL, "Can't find pic: " + pic + '\n');
        return;
    }

    if (((gl_config.renderer == GL_RENDERER_MCD) || ((gl_config.renderer & GL_RENDERER_RENDITION) != 0))
            && !image.has_alpha) {
        GL11.glDisable(GL11.GL_ALPHA_TEST);
    }

    GL_Bind(image.texnum);
    GL11.glBegin(GL11.GL_QUADS);
    GL11.glTexCoord2f(x / 64.0f, y / 64.0f);
    GL11.glVertex2f(x, y);
    GL11.glTexCoord2f((x + w) / 64.0f, y / 64.0f);
    GL11.glVertex2f(x + w, y);
    GL11.glTexCoord2f((x + w) / 64.0f, (y + h) / 64.0f);
    GL11.glVertex2f(x + w, y + h);
    GL11.glTexCoord2f(x / 64.0f, (y + h) / 64.0f);
    GL11.glVertex2f(x, y + h);
    GL11.glEnd();

    if (((gl_config.renderer == GL_RENDERER_MCD) || ((gl_config.renderer & GL_RENDERER_RENDITION) != 0))
            && !image.has_alpha) {
        GL11.glEnable(GL11.GL_ALPHA_TEST);
    }
}