Example usage for org.lwjgl.opengl GL11 glNewList

List of usage examples for org.lwjgl.opengl GL11 glNewList

Introduction

In this page you can find the example usage for org.lwjgl.opengl GL11 glNewList.

Prototype

public static native void glNewList(@NativeType("GLuint") int n, @NativeType("GLenum") int mode);

Source Link

Document

Begins the definition of a display list.

Usage

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);//  w w w.  j av  a  2 s . c  o  m

    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.fenggui.binding.render.lwjgl.LWJGLOpenGL.java

License:Open Source License

public void startList(int list) {
    GL11.glNewList(list, GL11.GL_COMPILE);
}

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

License:Apache License

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

    Game.getInstance().initOverlayRendering();

    GL11.glColor3f(1, 1, 1);//from   ww  w.ja va 2  s .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 (currentGui != null) {
        Game.getInstance().renderTransculentOverlayLayer();
        currentGui.render();
    } 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) {
            Inventory.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.ode4j.drawstuff.internal.DrawStuffGL.java

License:Open Source License

private void drawSphere() {
    // icosahedron data for an icosahedron of radius 1.0
    //      # define ICX 0.525731112119133606f
    //      # define ICZ 0.850650808352039932f
    if (listnum == 0) {
        listnum = GL11.glGenLists(1);/*w w w.j a  va 2 s . c  o  m*/
        GL11.glNewList(listnum, GL11.GL_COMPILE);
        GL11.glBegin(GL11.GL_TRIANGLES);
        for (int i = 0; i < 20; i++) {
            //            drawPatch (&idata[index[i][2]][0],&idata[index[i][1]][0],
            //                  &idata[index[i][0]][0],sphere_quality);
            drawPatch(idata[index[i][2]], idata[index[i][1]], idata[index[i][0]], sphere_quality);
        }
        GL11.glEnd();
        GL11.glEndList();
    }
    GL11.glCallList(listnum);
}

From source file:org.spout.engine.renderer.GL11BatchVertexRenderer.java

License:Open Source License

@Override
protected void doFlush() {
    GL11.glNewList(displayList, GL11.GL_COMPILE);
    FloatBuffer vBuffer = BufferUtils.createFloatBuffer(vertexBuffer.size());

    vBuffer.clear();/*ww w .j a v a  2s . c o  m*/
    vBuffer.put(vertexBuffer.toArray());
    vBuffer.flip();

    GL11.glEnableClientState(GL11.GL_VERTEX_ARRAY);
    GL11.glVertexPointer(4, 0, vBuffer);

    /*if (useColors) {
       vBuffer.clear();
       vBuffer.put(colorBuffer.toArray());
       vBuffer.flip();
               
       GL11.glEnableClientState(GL11.GL_COLOR_ARRAY);
       GL11.glColorPointer(4, 0, vBuffer);
    }*/

    if (useNormals) {
        vBuffer.clear();
        vBuffer.put(normalBuffer.toArray());
        vBuffer.flip();

        GL11.glEnableClientState(GL11.GL_NORMAL_ARRAY);
        GL11.glNormalPointer(0, vBuffer);
    }

    if (useTextures) {
        FloatBuffer temp = BufferUtils.createFloatBuffer(uvBuffer.size());
        temp.put(uvBuffer.toArray());
        temp.flip();

        GL11.glEnableClientState(GL11.GL_TEXTURE_COORD_ARRAY);
        GL11.glTexCoordPointer(2, 0, temp);
    }

    GL11.glDrawArrays(renderMode, 0, numVertices);

    GL11.glEndList();
}

From source file:pso.Surface.java

License:Open Source License

public static void assemble(float[][] val, float minc, float maxc, int rezx, int rezy) {
    int i, j;/*ww  w.  j a v a 2 s. c o m*/
    float px, py;
    float tmp;

    Color col;

    float spx = -rezx / 2;
    float spy = -rezy / 2;

    handle = GL11.glGenLists(1);
    GL11.glNewList(handle, GL11.GL_COMPILE);

    GL11.glBegin(GL11.GL_QUADS);

    px = spx;
    for (i = 0; i < rezx - 1; i++) {
        py = spy;
        for (j = 0; j < rezy - 1; j++) {
            tmp = (float) (1 - ((val[i][j] - minc) / (maxc - minc)));
            tmp = tmp * 66 / 100 + 34 / 100;
            col = new Color(Color.HSBtoRGB(tmp, 0.7f, 0.85f));
            GL11.glColor3f((float) (col.getRed() / 255f), (float) (col.getGreen() / 255f),
                    (float) (col.getBlue() / 255f));

            GL11.glVertex2f(px, py);

            tmp = (float) (1 - ((val[i][j + 1] - minc) / (maxc - minc)));
            tmp = tmp * 66 / 100 + 34 / 100;
            col = new Color(Color.HSBtoRGB(tmp, 0.7f, 0.85f));
            GL11.glColor3f((float) (col.getRed() / 255f), (float) (col.getGreen() / 255f),
                    (float) (col.getBlue() / 255f));

            GL11.glVertex2f(px, py + 1);

            tmp = (float) (1 - ((val[i + 1][j + 1] - minc) / (maxc - minc)));
            tmp = tmp * 66 / 100 + 34 / 100;
            col = new Color(Color.HSBtoRGB(tmp, 0.7f, 0.85f));
            GL11.glColor3f((float) (col.getRed() / 255f), (float) (col.getGreen() / 255f),
                    (float) (col.getBlue() / 255f));

            GL11.glVertex2f(px + 1, py + 1);

            tmp = (float) (1 - ((val[i + 1][j] - minc) / (maxc - minc)));
            tmp = tmp * 66 / 100 + 34 / 100;
            col = new Color(Color.HSBtoRGB(tmp, 0.7f, 0.85f));
            GL11.glColor3f((float) (col.getRed() / 255f), (float) (col.getGreen() / 255f),
                    (float) (col.getBlue() / 255f));

            GL11.glVertex2f(px + 1, py);

            py += 1;
        }
        px += 1;
    }

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

From source file:RediscoveredMod.MD3Renderer.java

License:Open Source License

public final void render(int var1, int var2, float var3) {
    if ((this.displayList == 0) || (this.useAnimation)) {
        if (!this.useAnimation) {
            this.displayList = GL11.glGenLists(1);
        }// ww w . j  a v a2  s. co  m

        GL11.glEnableClientState(32884);
        GL11.glEnableClientState(32888);
        GL11.glEnableClientState(32885);
        if (!this.useAnimation) {
            GL11.glNewList(this.displayList, 4864);
        }

        for (int i = 0; i < this.model.surfaces.length; i++) {
            MD3Surface surface = this.model.surfaces[i];
            if (this.useAnimation)
                surface.setFrame(var1, var2, var3);
            else {
                surface.setFrame(0, 0, 0.0F);
            }

            surface.triangles.position(0);

            surface.d.position(0);
            GL11.glVertexPointer(3, 0, surface.vertices);
            GL11.glNormalPointer(0, surface.normals);
            GL11.glTexCoordPointer(2, 0, surface.d);
            GL11.glDrawElements(4, surface.triangles);
        }

        if (!this.useAnimation) {
            GL11.glEndList();
        }
        GL11.glDisableClientState(32884);
        GL11.glDisableClientState(32888);
        GL11.glDisableClientState(32885);
    }

    if (!this.useAnimation)
        GL11.glCallList(this.displayList);
}

From source file:rheel.ac.client.renderer.model.ModelSAPC.java

License:Open Source License

private int setupRenderer() {
    final int id = GL11.glGenLists(1);
    GL11.glNewList(id, GL11.GL_COMPILE);
    this.bottom.render(1);
    this.bottomRight1.render(1);
    this.bottomRight2.render(1);
    this.bottomRight3.render(1);
    this.right.render(1);
    this.topRight1.render(1);
    this.topRight2.render(1);
    this.topRight3.render(1);
    this.top.render(1);
    this.topLeft1.render(1);
    this.topleft2.render(1);
    this.topLeft3.render(1);
    this.left.render(1);
    this.bottomLeft1.render(1);
    this.bottomLeft2.render(1);
    this.bottomLeft3.render(1);
    GL11.glEndList();//from  w  w w.  ja  v a 2 s .c o  m
    return id;
}

From source file:shadowmage.ancient_framework.client.gui.elements.GuiScrollBarSimple.java

License:Open Source License

@Override
public void drawElement(int mouseX, int mouseY) {
    if (!this.hidden) {
        String tex = Statics.TEXTURE_PATH + "gui/guiButtons.png";
        if (height <= 128)//do simple render
        {/*  w  w  w  .  j  a va 2  s .  co  m*/
            this.drawQuadedTexture(renderPosX + guiLeft, renderPosY + guiTop, width, height, 40, 128, tex, 80,
                    120);
            this.drawQuadedTexture(renderPosX + guiLeft + buffer, renderPosY + guiTop + buffer + handleTop,
                    width - buffer * 2, handleHeight, 32, 128, tex, 120, 120);
            return;
        } else if (displayListNum > 0) {
            AWTextureManager.bindTexture(tex);
            GL11.glCallList(displayListNum);
            return;
        }

        displayListNum = GL11.glGenLists(1);
        AWTextureManager.bindTexture(tex);
        GL11.glNewList(displayListNum, GL11.GL_COMPILE_AND_EXECUTE);
        GL11.glColor4f(1.f, 1.f, 1.f, 1.f);
        float texPixPercent = 1.f / 256.f;
        float x, y, u, v, uw, uh, width, height;
        x = renderPosX + guiLeft;
        y = renderPosY + guiTop;
        uw = 40;
        uh = 128;
        u = 80;
        v = 120;
        width = this.width;
        height = this.height;
        float x1, y1, x2, y2, x3, y3, x4, y4;
        float u1, v1, u2, v2, u3, v3, u4, v4;
        /**
         * setup render bounds
         */

        /**
         * render the top-left bit
         */
        x1 = x;//top-left
        y1 = y;//top-left
        x2 = x1;//bottom-left
        y2 = y1 + 8;//bottom-left
        x3 = x2 + (width / 2);//bottom-right
        y3 = y2;//bottom-right
        x4 = x3;//top-right
        y4 = y3 - 8;//top-right    
        u1 = u * texPixPercent;
        v1 = v * texPixPercent;
        u2 = u1;
        v2 = v1 + 8 * texPixPercent;
        u3 = u2 + (width / 2) * texPixPercent;
        v3 = v2;
        u4 = u3;
        v4 = v3 - 8 * texPixPercent;
        renderQuad(x1, y1, x2, y2, x3, y3, x4, y4, u1, v1, u2, v2, u3, v3, u4, v4);

        /**
         * render the top-right bit
         */
        x1 = x + (width / 2);//top-left
        y1 = y;//top-left
        x2 = x1;//bottom-left
        y2 = y1 + 8;//bottom-left
        x3 = x2 + (width / 2);//bottom-right
        y3 = y2;//bottom-right
        x4 = x3;//top-right
        y4 = y3 - 8;//top-right
        u1 = u * texPixPercent + (uw - (width / 2)) * texPixPercent;
        v1 = v * texPixPercent;
        u2 = u1;
        v2 = v1 + 8 * texPixPercent;
        u3 = u2 + (width / 2) * texPixPercent;
        v3 = v2;
        u4 = u3;
        v4 = v3 - 8 * texPixPercent;
        renderQuad(x1, y1, x2, y2, x3, y3, x4, y4, u1, v1, u2, v2, u3, v3, u4, v4);

        /**
         * render bottom-left bit
         */
        x1 = x;
        y1 = y + height - 8;
        x2 = x1;
        y2 = y1 + 8;
        x3 = x2 + (width / 2);
        y3 = y2;
        x4 = x3;
        y4 = y3 - 8;
        u1 = u * texPixPercent;
        v1 = v * texPixPercent + ((uh - 8) * texPixPercent);
        u2 = u1;
        v2 = v1 + 8 * texPixPercent;
        u3 = u2 + (width / 2) * texPixPercent;
        v3 = v2;
        u4 = u3;
        v4 = v3 - 8 * texPixPercent;
        renderQuad(x1, y1, x2, y2, x3, y3, x4, y4, u1, v1, u2, v2, u3, v3, u4, v4);

        x1 = x + (width / 2);//top-left
        y1 = y + height - 8;//top-left
        x2 = x1;//bottom-left
        y2 = y1 + 8;//bottom-left
        x3 = x2 + (width / 2);//bottom-right
        y3 = y2;//bottom-right
        x4 = x3;//top-right
        y4 = y3 - 8;//top-right
        u1 = u * texPixPercent + (uw - (width / 2)) * texPixPercent;
        v1 = v * texPixPercent + ((uh - 8) * texPixPercent);
        u2 = u1;
        v2 = v1 + 8 * texPixPercent;
        u3 = u2 + (width / 2) * texPixPercent;
        v3 = v2;
        u4 = u3;
        v4 = v3 - 8 * texPixPercent;
        renderQuad(x1, y1, x2, y2, x3, y3, x4, y4, u1, v1, u2, v2, u3, v3, u4, v4);

        float remainingHeight = height - 16;
        float nextY = y + 8;
        float usedHeight;
        while (remainingHeight > 0) {
            usedHeight = remainingHeight > 40 ? 40 : remainingHeight;
            remainingHeight -= usedHeight;

            /**
             * render left bit
             */
            x1 = x;//top-left
            y1 = nextY;//top-left
            x2 = x1;//bottom-left
            y2 = y1 + usedHeight;//bottom-left
            x3 = x2 + (width / 2);//bottom-right
            y3 = y2;//bottom-right
            x4 = x3;//top-right
            y4 = y3 - usedHeight;//top-right

            u1 = u * texPixPercent;
            v1 = v * texPixPercent + (8 * texPixPercent);
            u2 = u1;
            v2 = v1 + usedHeight * texPixPercent;
            u3 = u2 + (width / 2) * texPixPercent;
            v3 = v2;
            u4 = u3;
            v4 = v3 - usedHeight * texPixPercent;
            renderQuad(x1, y1, x2, y2, x3, y3, x4, y4, u1, v1, u2, v2, u3, v3, u4, v4);

            /**
             * render right bit
             */
            x1 = x + (width / 2);//top-left
            y1 = nextY;//top-left
            x2 = x1;//bottom-left
            y2 = y1 + usedHeight;//bottom-left
            x3 = x2 + (width / 2);//bottom-right
            y3 = y2;//bottom-right
            x4 = x3;//top-right
            y4 = y3 - usedHeight;//top-right

            u1 = u * texPixPercent + (uw - (width / 2)) * texPixPercent;
            v1 = v * texPixPercent + (8 * texPixPercent);
            u2 = u1;
            v2 = v1 + usedHeight * texPixPercent;
            u3 = u2 + (width / 2) * texPixPercent;
            v3 = v2;
            u4 = u3;
            v4 = v3 - usedHeight * texPixPercent;
            renderQuad(x1, y1, x2, y2, x3, y3, x4, y4, u1, v1, u2, v2, u3, v3, u4, v4);

            nextY += usedHeight;
        }

        x = renderPosX + guiLeft + buffer;
        y = renderPosY + guiTop + buffer + handleTop;
        u = 120;//uw = 32
        v = 120;//uh = 128 
        uw = 32;
        uh = 128;
        width = this.width - (buffer * 2);
        height = this.handleHeight;

        /**
         * render the top-left bit
         */
        x1 = x;//top-left
        y1 = y;//top-left
        x2 = x1;//bottom-left
        y2 = y1 + 8;//bottom-left
        x3 = x2 + (width / 2);//bottom-right
        y3 = y2;//bottom-right
        x4 = x3;//top-right
        y4 = y3 - 8;//top-right    
        u1 = u * texPixPercent;
        v1 = v * texPixPercent;
        u2 = u1;
        v2 = v1 + 8 * texPixPercent;
        u3 = u2 + (width / 2) * texPixPercent;
        v3 = v2;
        u4 = u3;
        v4 = v3 - 8 * texPixPercent;
        renderQuad(x1, y1, x2, y2, x3, y3, x4, y4, u1, v1, u2, v2, u3, v3, u4, v4);

        /**
         * render the top-right bit
         */
        x1 = x + (width / 2);//top-left
        y1 = y;//top-left
        x2 = x1;//bottom-left
        y2 = y1 + 8;//bottom-left
        x3 = x2 + (width / 2);//bottom-right
        y3 = y2;//bottom-right
        x4 = x3;//top-right
        y4 = y3 - 8;//top-right
        u1 = u * texPixPercent + (uw - (width / 2)) * texPixPercent;
        v1 = v * texPixPercent;
        u2 = u1;
        v2 = v1 + 8 * texPixPercent;
        u3 = u2 + (width / 2) * texPixPercent;
        v3 = v2;
        u4 = u3;
        v4 = v3 - 8 * texPixPercent;
        renderQuad(x1, y1, x2, y2, x3, y3, x4, y4, u1, v1, u2, v2, u3, v3, u4, v4);

        /**
         * render bottom-left bit
         */
        x1 = x;
        y1 = y + height - 8;
        x2 = x1;
        y2 = y1 + 8;
        x3 = x2 + (width / 2);
        y3 = y2;
        x4 = x3;
        y4 = y3 - 8;
        u1 = u * texPixPercent;
        v1 = v * texPixPercent + ((uh - 8) * texPixPercent);
        u2 = u1;
        v2 = v1 + 8 * texPixPercent;
        u3 = u2 + (width / 2) * texPixPercent;
        v3 = v2;
        u4 = u3;
        v4 = v3 - 8 * texPixPercent;
        renderQuad(x1, y1, x2, y2, x3, y3, x4, y4, u1, v1, u2, v2, u3, v3, u4, v4);

        /**
         * render bottom-right bit
         */
        x1 = x + (width / 2);//top-left
        y1 = y + height - 8;//top-left
        x2 = x1;//bottom-left
        y2 = y1 + 8;//bottom-left
        x3 = x2 + (width / 2);//bottom-right
        y3 = y2;//bottom-right
        x4 = x3;//top-right
        y4 = y3 - 8;//top-right
        u1 = u * texPixPercent + (uw - (width / 2)) * texPixPercent;
        v1 = v * texPixPercent + ((uh - 8) * texPixPercent);
        u2 = u1;
        v2 = v1 + 8 * texPixPercent;
        u3 = u2 + (width / 2) * texPixPercent;
        v3 = v2;
        u4 = u3;
        v4 = v3 - 8 * texPixPercent;
        renderQuad(x1, y1, x2, y2, x3, y3, x4, y4, u1, v1, u2, v2, u3, v3, u4, v4);

        remainingHeight = height - 16;
        nextY = y + 8;
        while (remainingHeight > 0) {
            usedHeight = remainingHeight > 40 ? 40 : remainingHeight;
            remainingHeight -= usedHeight;

            /**
             * render left bit
             */
            x1 = x;//top-left
            y1 = nextY;//top-left
            x2 = x1;//bottom-left
            y2 = y1 + usedHeight;//bottom-left
            x3 = x2 + (width / 2);//bottom-right
            y3 = y2;//bottom-right
            x4 = x3;//top-right
            y4 = y3 - usedHeight;//top-right

            u1 = u * texPixPercent;
            v1 = v * texPixPercent + (8 * texPixPercent);
            u2 = u1;
            v2 = v1 + usedHeight * texPixPercent;
            u3 = u2 + (width / 2) * texPixPercent;
            v3 = v2;
            u4 = u3;
            v4 = v3 - usedHeight * texPixPercent;
            renderQuad(x1, y1, x2, y2, x3, y3, x4, y4, u1, v1, u2, v2, u3, v3, u4, v4);

            /**
             * render right bit
             */
            x1 = x + (width / 2);//top-left
            y1 = nextY;//top-left
            x2 = x1;//bottom-left
            y2 = y1 + usedHeight;//bottom-left
            x3 = x2 + (width / 2);//bottom-right
            y3 = y2;//bottom-right
            x4 = x3;//top-right
            y4 = y3 - usedHeight;//top-right

            u1 = u * texPixPercent + (uw - (width / 2)) * texPixPercent;
            v1 = v * texPixPercent + (8 * texPixPercent);
            u2 = u1;
            v2 = v1 + usedHeight * texPixPercent;
            u3 = u2 + (width / 2) * texPixPercent;
            v3 = v2;
            u4 = u3;
            v4 = v3 - usedHeight * texPixPercent;
            renderQuad(x1, y1, x2, y2, x3, y3, x4, y4, u1, v1, u2, v2, u3, v3, u4, v4);

            nextY += usedHeight;
        }
    }

    GL11.glEndList();
}

From source file:shadowmage.ancient_framework.client.model.Primitive.java

License:Open Source License

public void buildDisplayList() {
    if (this.displayListNumber < 0) {
        this.displayListNumber = GL11.glGenLists(1);
    }//from   www . j ava  2  s.  c o  m
    GL11.glNewList(displayListNumber, GL11.GL_COMPILE);
    if (x != 0 || y != 0 || z != 0) {
        GL11.glTranslatef(x, y, z);
    }
    if (rx != 0) {
        GL11.glRotatef(rx, 1, 0, 0);
    }
    if (ry != 0) {
        GL11.glRotatef(ry, 0, 1, 0);
    }
    if (rz != 0) {
        GL11.glRotatef(rz, 0, 0, 1);
    }
    renderForDisplayList();
    if (x != 0 || y != 0 || z != 0) {
        GL11.glTranslatef(-x, -y, -z);
    }
    if (rx != 0) {
        GL11.glRotatef(-rx, 1, 0, 0);
    }
    if (ry != 0) {
        GL11.glRotatef(-ry, 0, 1, 0);
    }
    if (rz != 0) {
        GL11.glRotatef(-rz, 0, 0, 1);
    }
    GL11.glEndList();
    setCompiled(true);
}