Example usage for org.lwjgl.opengl GL11 glColor3ub

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

Introduction

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

Prototype

public static native void glColor3ub(@NativeType("GLubyte") byte red, @NativeType("GLubyte") byte green,
        @NativeType("GLubyte") byte blue);

Source Link

Document

Unsigned version of #glColor3b Color3b

Usage

From source file:kuake2.render.lwjgl.Draw.java

License:Open Source License

protected void Draw_Fill(int x, int y, int w, int h, int colorIndex) {

    if (colorIndex > 255)
        Com.Error(Defines.ERR_FATAL, "Draw_Fill: bad color");

    GL11.glDisable(GL11.GL_TEXTURE_2D);//from   w w w. j a v  a 2 s .com

    int color = d_8to24table[colorIndex];

    GL11.glColor3ub((byte) ((color >> 0) & 0xff), // r
            (byte) ((color >> 8) & 0xff), // g
            (byte) ((color >> 16) & 0xff) // b
    );

    GL11.glBegin(GL11.GL_QUADS);

    GL11.glVertex2f(x, y);
    GL11.glVertex2f(x + w, y);
    GL11.glVertex2f(x + w, y + h);
    GL11.glVertex2f(x, y + h);

    GL11.glEnd();
    GL11.glColor3f(1, 1, 1);
    GL11.glEnable(GL11.GL_TEXTURE_2D);
}

From source file:launcher.Main.java

private void drawWorld() {
    final int widthFit = (SCREEN_WIDTH / world.getBlockWidth()) + 1;
    final int heightFit = (SCREEN_HEIGHT / world.getBlockWidth()) + 1;

    final int cX = Math.min(widthFit, world.getSizeX());
    final int cY = Math.min(heightFit, world.getSizeY());//assuming the world is not a jagged grid...
    // Clear the screen and depth buffer

    Point playerPoint = world.getPlayerLocationInGrid(player);

    final int startX = playerPoint.getX() - (int) Math.floor(widthFit / 2);
    final int startY = playerPoint.getY() - (int) Math.floor(heightFit / 2);

    final int w = world.getBlockWidth();
    final int maxDamage = 500;
    final double damageProportion = w * 0.5 / maxDamage;
    for (int i = 0; i < cX + 1; i++) {
        for (int j = 0; j < cY + 1; j++) {
            Block block = world.getBlock(i + startX, j + startY);
            byte[] c = block.getColor();
            GL11.glColor3ub(c[0], c[1], c[2]);

            int left = i * w - (w / 2);
            int top = j * w - (w / 2);
            int right = left + w;
            int bottom = top + w;
            // draw quad block thing
            GL11.glBegin(GL11.GL_QUADS);
            {//w w w.  ja v  a2  s  .c o m
                GL11.glVertex2f(left, top);
                GL11.glVertex2f(right, top);
                GL11.glVertex2f(right, bottom);
                GL11.glVertex2f(left, bottom);
            }
            GL11.glEnd();

            final int damage = block.getDamage();
            if (damage < maxDamage && !(block instanceof AirBlock)) {
                //wtf is dit?
                int tmp = (int) Math.ceil((maxDamage / (damage + 1)) * 0.1f) + 2;
                int centerX = (int) (left + w * 0.5);
                int centerY = (int) (top + w * 0.5);
                int visibleDamage = (int) Math.ceil(damage * damageProportion);
                //gray
                GL11.glColor3ub((byte) 80, (byte) 80, (byte) 80);

                GL11.glBegin(GL11.GL_QUADS);
                {
                    GL11.glVertex2f(left, top);
                    GL11.glVertex2f(left + tmp, top);
                    GL11.glVertex2f(centerX - visibleDamage, centerY - visibleDamage);
                    GL11.glVertex2f(left, top + tmp);
                }
                GL11.glEnd();

                GL11.glBegin(GL11.GL_QUADS);
                {
                    GL11.glVertex2f(right, top);
                    GL11.glVertex2f(right, top + tmp);
                    GL11.glVertex2f(centerX + visibleDamage, centerY - visibleDamage);
                    GL11.glVertex2f(right - tmp, top);
                }
                GL11.glEnd();

                GL11.glBegin(GL11.GL_QUADS);
                {
                    GL11.glVertex2f(right, bottom);
                    GL11.glVertex2f(right - tmp, bottom);
                    GL11.glVertex2f(centerX + visibleDamage, centerY + visibleDamage);
                    GL11.glVertex2f(right, bottom - tmp);
                }
                GL11.glEnd();

                GL11.glBegin(GL11.GL_QUADS);
                {
                    GL11.glVertex2f(left, bottom);
                    GL11.glVertex2f(left, bottom - tmp);
                    GL11.glVertex2f(centerX - visibleDamage, centerY + visibleDamage);
                    GL11.glVertex2f(left + tmp, bottom);
                }
                GL11.glEnd();
            }
        }
    }
}

From source file:launcher.Main.java

private void drawPlayer() {
    //orangered, why not?
    GL11.glColor3ub((byte) 255, (byte) 69, (byte) 0);

    final int w = player.getWidth() / 2;
    GL11.glBegin(GL11.GL_QUADS);/* w ww  .jav  a2 s.  com*/
    {
        GL11.glVertex2f(SCREEN_CENTER_X - w, SCREEN_CENTER_Y - w);
        GL11.glVertex2f(SCREEN_CENTER_X + w, SCREEN_CENTER_Y - w);
        GL11.glVertex2f(SCREEN_CENTER_X + w, SCREEN_CENTER_Y + w);
        GL11.glVertex2f(SCREEN_CENTER_X - w, SCREEN_CENTER_Y + w);
    }
    GL11.glEnd();

    //draw drill
    switch (player.getDirection()) {
    case IDLE:
        break;
    case LEFT:
        GL11.glBegin(GL11.GL_TRIANGLES); {
        GL11.glVertex2f(SCREEN_CENTER_X - w, SCREEN_CENTER_Y - w);
        GL11.glVertex2f(SCREEN_CENTER_X - w * 1.5f, SCREEN_CENTER_Y);
        GL11.glVertex2f(SCREEN_CENTER_X - w, SCREEN_CENTER_Y + w);
    }
        GL11.glEnd();
        break;
    case RIGHT:
        GL11.glBegin(GL11.GL_TRIANGLES); {
        GL11.glVertex2f(SCREEN_CENTER_X + w, SCREEN_CENTER_Y - w);
        GL11.glVertex2f(SCREEN_CENTER_X + w * 1.5f, SCREEN_CENTER_Y);
        GL11.glVertex2f(SCREEN_CENTER_X + w, SCREEN_CENTER_Y + w);
    }
        GL11.glEnd();
        break;
    case DOWN:
        GL11.glBegin(GL11.GL_TRIANGLES); {
        GL11.glVertex2f(SCREEN_CENTER_X - w, SCREEN_CENTER_Y + w);
        GL11.glVertex2f(SCREEN_CENTER_X, SCREEN_CENTER_Y + w * 1.5f);
        GL11.glVertex2f(SCREEN_CENTER_X + w, SCREEN_CENTER_Y + w);
    }
        GL11.glEnd();
        break;
    case UP:
        GL11.glBegin(GL11.GL_TRIANGLES); {
        GL11.glVertex2f(SCREEN_CENTER_X + w, SCREEN_CENTER_Y - w);
        GL11.glVertex2f(SCREEN_CENTER_X, SCREEN_CENTER_Y - w * 1.5f);
        GL11.glVertex2f(SCREEN_CENTER_X - w, SCREEN_CENTER_Y - w);
    }
        GL11.glEnd();
        break;
    default:
        break;
    }
}

From source file:makeo.gadomancy.client.renderers.entity.RenderGolemHelper.java

License:LGPL

public static void renderCarriedItemsFix(EntityGolemBase golem) {
    GL11.glPushMatrix();//from  w w w  .  j  a v a 2 s . c  om

    GL11.glScaled(0.4D, 0.4D, 0.4D);

    GL11.glTranslatef(-0.5F, 2.5F, -1.25F);
    GL11.glRotatef(180.0F, 1.0F, 0.0F, 0.0F);

    ItemStack item = golem.getCarriedForDisplay();

    int renderPass = 0;
    do {
        IIcon icon = item.getItem().getIcon(item, renderPass);
        if (icon != null) {
            Color color = new Color(item.getItem().getColorFromItemStack(item, renderPass));
            GL11.glColor3ub((byte) color.getRed(), (byte) color.getGreen(), (byte) color.getBlue());

            ItemRenderer.renderItemIn2D(Tessellator.instance, icon.getMaxU(), icon.getMinV(), icon.getMinU(),
                    icon.getMaxV(), icon.getIconWidth(), icon.getIconHeight(), 0.0625F);

            GL11.glColor3f(1.0F, 1.0F, 1.0F);
        }
        renderPass++;
    } while (renderPass < item.getItem().getRenderPasses(item.getItemDamage()));

    GL11.glPopMatrix();
}

From source file:name.martingeisse.stackd.client.gui.element.FillTexture.java

License:Open Source License

@Override
protected void draw() {
    GL11.glEnable(GL11.GL_TEXTURE_2D);//from   w w  w  . j ava 2  s. c  om
    GL11.glDisable(GL11.GL_BLEND);
    texture.glBindTexture();
    final int x = getAbsoluteX(), y = getAbsoluteY(), w = getWidth(), h = getHeight();
    final Gui gui = getGui();
    final float effectiveRepetitionLengthX = (repetitionLengthX < 1 ? gui.pixelsToUnitsInt(texture.getWidth())
            : repetitionLengthX);
    final float effectiveRepetitionLengthY = (repetitionLengthY < 1 ? gui.pixelsToUnitsInt(texture.getHeight())
            : repetitionLengthY);
    final float s = (w / effectiveRepetitionLengthX);
    final float t = (h / effectiveRepetitionLengthY);

    GL11.glColor3ub((byte) 255, (byte) 255, (byte) 255);
    GL11.glBegin(GL11.GL_TRIANGLE_FAN);
    GL11.glTexCoord2f(0.0f, 0.0f);
    GL11.glVertex2i(x, y);
    GL11.glTexCoord2f(s, 0.0f);
    GL11.glVertex2i(x + w, y);
    GL11.glTexCoord2f(s, t);
    GL11.glVertex2i(x + w, y + h);
    GL11.glTexCoord2f(0.0f, t);
    GL11.glVertex2i(x, y + h);
    GL11.glEnd();
}

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

License:Open Source License

protected void Draw_Fill(int x, int y, int w, int h, int colorIndex) {

    if (colorIndex > 255) {
        Com.Error(Defines.ERR_FATAL, "Draw_Fill: bad color");
    }//from ww  w  . j  a  v  a  2  s.  c om

    GL11.glDisable(GL11.GL_TEXTURE_2D);

    int color = d_8to24table[colorIndex];

    GL11.glColor3ub((byte) ((color) & 0xff), // r
            (byte) ((color >> 8) & 0xff), // g
            (byte) ((color >> 16) & 0xff) // b
    );

    GL11.glBegin(GL11.GL_QUADS);

    GL11.glVertex2f(x, y);
    GL11.glVertex2f(x + w, y);
    GL11.glVertex2f(x + w, y + h);
    GL11.glVertex2f(x, y + h);

    GL11.glEnd();
    GL11.glColor3f(1, 1, 1);
    GL11.glEnable(GL11.GL_TEXTURE_2D);
}

From source file:shadowmage.ancient_warfare.client.render.AWRenderHelper.java

License:Open Source License

public static void setTeamRenderColor(int teamNum) {
    int[] color = getRenderColorFor(teamNum);
    GL11.glColor3ub((byte) color[0], (byte) color[1], (byte) color[2]);
}

From source file:taiga.mcmods.buildguide.BlockMarker.java

private void createDisplayList() {
    //if neded create the list
    if (displaylist == -1)
        displaylist = GL11.glGenLists(1);

    GL11.glNewList(displaylist, GL11.GL_COMPILE_AND_EXECUTE);

    GL11.glDisable(GL11.GL_FOG);//w  w w  . j a  va2 s.  c om
    GL11.glDisable(GL11.GL_LIGHTING);
    GL11.glDisable(GL11.GL_BLEND);
    GL11.glDisable(GL11.GL_TEXTURE_2D);
    GL11.glEnable(GL11.GL_POINT_SMOOTH);

    GL11.glBegin(GL11.GL_POINTS);
    if (color != null)
        GL11.glColor3ub((byte) color.getRed(), (byte) color.getGreen(), (byte) color.getBlue());
    for (Point3D pt : points)
        GL11.glVertex3d(pt.getX(), pt.getY(), pt.getZ());
    GL11.glEnd();

    GL11.glEnable(GL11.GL_TEXTURE_2D);

    GL11.glEndList();

    regendisplist = false;
}

From source file:thaumic.tinkerer.client.gui.GuiEnchanting.java

License:Creative Commons License

private void drawAspectBar(Aspect aspect, int x, int y, int mx, int my) {
    int totalCost = enchanter.totalAspects.getAmount(aspect);
    int current = enchanter.currentAspects.getAmount(aspect);

    int size = totalCost == 0 ? 11 : 59;

    if (totalCost == 0) {
        drawTexturedModalRect(x, y - size, 200, 0, 10, 4);
        drawTexturedModalRect(x, y - size + 4, 200, 52, 10, 10);
    } else {//from  ww  w  .  j a va 2s  .  co  m
        int pixels = (int) (48D * ((double) current / (double) totalCost));
        Color color = new Color(aspect.getColor());
        GL11.glColor3ub((byte) color.getRed(), (byte) color.getGreen(), (byte) color.getBlue());
        drawTexturedModalRect(x + 1, y - size + 4 + 48 - pixels, 210, 48 - pixels, 8, pixels);
        GL11.glColor3f(1F, 1F, 1F);
        drawTexturedModalRect(x, y - size, 200, 0, 10, size);
    }

    if (mx > x && mx <= x + 10 && my > y - size && my <= y) {
        List<String> tooltip = new ArrayList();
        tooltip.add('\u00a7' + aspect.getChatcolor() + aspect.getName());
        tooltip.add(current + "/" + totalCost);
        this.tooltip = tooltip;
    }
}

From source file:thaumic.tinkerer.client.render.tile.RenderTileEnchanter.java

License:Creative Commons License

@Override
public void renderTileEntityAt(TileEntity tileentity, double d0, double d1, double d2, float partTicks) {
    TileEnchanter enchanter = (TileEnchanter) tileentity;

    GL11.glPushMatrix();/*from  w  w w  .  j  a  va 2  s.com*/
    GL11.glTranslated(d0, d1 + 0.75, d2);

    ItemStack item = enchanter.getStackInSlot(0);
    if (item != null) {
        GL11.glPushMatrix();
        GL11.glRotatef(90F, 1F, 0F, 0F);
        final float scale = 0.7F;
        GL11.glScalef(scale, scale, scale);
        GL11.glTranslatef(0.6F, -0.2F, 0F);
        GL11.glRotatef(30F, 0F, 0F, 1F);

        ClientHelper.minecraft().renderEngine.bindTexture(TextureMap.locationItemsTexture);

        int renderPass = 0;
        do {
            IIcon icon = item.getItem().getIcon(item, renderPass);
            if (icon != null) {
                Color color = new Color(item.getItem().getColorFromItemStack(item, renderPass));
                GL11.glColor3ub((byte) color.getRed(), (byte) color.getGreen(), (byte) color.getBlue());
                float f = icon.getMinU();
                float f1 = icon.getMaxU();
                float f2 = icon.getMinV();
                float f3 = icon.getMaxV();
                ItemRenderer.renderItemIn2D(Tessellator.instance, f1, f2, f, f3, icon.getIconWidth(),
                        icon.getIconHeight(), 1F / 16F);
                GL11.glColor3f(1F, 1F, 1F);
            }
            renderPass++;
        } while (renderPass < item.getItem().getRenderPasses(item.getItemDamage()));
        GL11.glPopMatrix();
    }

    item = enchanter.getStackInSlot(1);
    if (item != null) {
        GL11.glPushMatrix();
        GL11.glRotatef(90F, 1F, 0F, 0F);
        final float scale = 0.5F;
        GL11.glScalef(scale, scale, scale);
        GL11.glTranslatef(0.6F, 1.5F, -0.1F);
        GL11.glRotatef(-70F, 0F, 0F, 1F);
        long millis = System.currentTimeMillis();

        GL11.glTranslatef(0F, 0F, (float) (Math.cos((double) millis / 1000F) - 1.2F) / 10F);
        GL11.glTranslatef(0F, 0.325F, 0F);
        GL11.glRotatef((float) Math.cos((double) millis / 500F) * 5F, 1F, 0F, 0F);
        GL11.glTranslatef(0F, -0.325F, 0F);

        wandRenderer.renderItem(ItemRenderType.ENTITY, item, (Object[]) null);
        GL11.glPopMatrix();
    }

    GL11.glPopMatrix();
}