Example usage for org.lwjgl.opengl GL11 glColor3f

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

Introduction

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

Prototype

public static native void glColor3f(@NativeType("GLfloat") float red, @NativeType("GLfloat") float green,
        @NativeType("GLfloat") float blue);

Source Link

Document

Float version of #glColor3b Color3b

Usage

From source file:$.DrawSystem.java

License:Open Source License

private void drawSprite(Sprite sprite) {
        Vector pos = spriteProjector.project(sprite.getPosition());
        final IPlay play = sprite.getPlay();
        if (null != play) {
            GL11.glPushMatrix();//from  w ww. ja v  a2 s .c om
            GL11.glTranslatef(pos.x, pos.y, 0.0f);
            GL11.glRotatef(sprite.getRotate(), 0, 0, 1.0f);
            GL11.glScalef(sprite.getScale(), sprite.getScale(), 1);
            final IAnimationFrame frame = play.getCurrentFrame();
            final IAnimationImage image = frame.getImage();
            if (image.hasAlpha()) {
                GL11.glEnable(GL11.GL_BLEND);
            }
            GL11.glBindTexture(GL11.GL_TEXTURE_2D, (Integer) image.getId());

            final float u1, u2;
            if (sprite.isMirrorX()) {
                u1 = frame.getU2();
                u2 = frame.getU1();
            } else {
                u1 = frame.getU1();
                u2 = frame.getU2();
            }

            final float v1, v2;
            if (sprite.isMirrorY()) {
                v1 = frame.getV1();
                v2 = frame.getV2();
            } else {
                v1 = frame.getV2();
                v2 = frame.getV1();
            }
            GL11.glColor4f(sprite.getRed(), sprite.getGreen(), sprite.getBlue(), sprite.getAlpha());
            float x1 = -sprite.getWidth() / 2.0f;
            float x2 = sprite.getWidth() / 2.0f;
            float y1 = -sprite.getHeight() / 2.0f;
            float y2 = sprite.getHeight() / 2.0f;
            GL11.glBegin(GL11.GL_QUADS);
            GL11.glTexCoord2f(u1, v1);
            GL11.glVertex2f(x1, y2);
            GL11.glTexCoord2f(u2, v1);
            GL11.glVertex2f(x2, y2);
            GL11.glTexCoord2f(u2, v2);
            GL11.glVertex2f(x2, y1);
            GL11.glTexCoord2f(u1, v2);
            GL11.glVertex2f(x1, y1);
            GL11.glEnd();
            GL11.glColor3f(1f, 1f, 1f);
            if (image.hasAlpha()) {
                GL11.glDisable(GL11.GL_BLEND);
            }
            GL11.glPopMatrix();
        }
        if (null != sprite.getLabel()) {
            GL11.glPushMatrix();
            GL11.glTranslatef(pos.x, pos.y, 0.0f);
            GL11.glScalef(0.5f, -0.5f, 1f);
            GL11.glEnable(GL11.GL_BLEND);
            LwjglNuitFont font = (LwjglNuitFont) assets.getFont("");
            font.drawString(sprite.getLabel(), LwjglNuitFont.Align.CENTER);
            GL11.glDisable(GL11.GL_BLEND);
            GL11.glPopMatrix();
        }
    }

From source file:adrianton.gloptat.plotter.Box.java

License:Open Source License

static void assemble() {
    handle = GL11.glGenLists(1);//from w ww . ja v  a 2s.c o  m
    GL11.glNewList(handle, GL11.GL_COMPILE);

    GL11.glLineWidth(3);
    GL11.glColor3f(1f, 1f, 1f);

    GL11.glBegin(GL11.GL_LINES);

    GL11.glVertex3d(-1, -1, 1);
    GL11.glVertex3d(1, -1, 1);
    GL11.glVertex3d(1, -1, 1);
    GL11.glVertex3d(1, 1, 1);
    GL11.glVertex3d(1, 1, 1);
    GL11.glVertex3d(-1, 1, 1);
    GL11.glVertex3d(-1, 1, 1);
    GL11.glVertex3d(-1, -1, 1);

    GL11.glVertex3d(-1, -1, -1);
    GL11.glVertex3d(1, -1, -1);
    GL11.glVertex3d(1, -1, -1);
    GL11.glVertex3d(1, 1, -1);
    GL11.glVertex3d(1, 1, -1);
    GL11.glVertex3d(-1, 1, -1);
    GL11.glVertex3d(-1, 1, -1);
    GL11.glVertex3d(-1, -1, -1);

    GL11.glVertex3d(-1, -1, -1);
    GL11.glVertex3d(-1, -1, 1);
    GL11.glVertex3d(1, -1, -1);
    GL11.glVertex3d(1, -1, 1);
    GL11.glVertex3d(1, 1, -1);
    GL11.glVertex3d(1, 1, 1);
    GL11.glVertex3d(-1, 1, -1);
    GL11.glVertex3d(-1, 1, 1);

    GL11.glEnd();

    GL11.glEndList();
}

From source file:adrianton.gloptat.plotter.Pointer.java

License:Open Source License

static void assemble() {
    final float tmpm = 1;
    final float tmpm2 = 1 / 3;
    final float tmpm3 = 7;

    handle = GL11.glGenLists(1);/* ww w .j a  v a2s .co  m*/
    GL11.glNewList(handle, GL11.GL_COMPILE);

    GL11.glBegin(GL11.GL_TRIANGLES);
    GL11.glColor3f(1, 1, 1);

    GL11.glVertex3f(0, 0, tmpm2);
    GL11.glVertex3f(-tmpm, -tmpm, tmpm3);
    GL11.glVertex3f(-tmpm, tmpm, tmpm3);

    GL11.glVertex3f(0, 0, tmpm2);
    GL11.glVertex3f(-tmpm, tmpm, tmpm3);
    GL11.glVertex3f(tmpm, tmpm, tmpm3);

    GL11.glVertex3f(0, 0, tmpm2);
    GL11.glVertex3f(tmpm, tmpm, tmpm3);
    GL11.glVertex3f(tmpm, -tmpm, tmpm3);

    GL11.glVertex3f(0, 0, tmpm2);
    GL11.glVertex3f(tmpm, -tmpm, tmpm3);
    GL11.glVertex3f(-tmpm, -tmpm, tmpm3);
    GL11.glEnd();

    GL11.glBegin(GL11.GL_QUADS);
    GL11.glVertex3f(tmpm, tmpm, tmpm3);
    GL11.glVertex3f(tmpm, -tmpm, tmpm3);
    GL11.glVertex3f(-tmpm, -tmpm, tmpm3);
    GL11.glVertex3f(-tmpm, tmpm, tmpm3);
    GL11.glEnd();

    GL11.glEndList();
}

From source file:adrianton.gloptat.plotter.Surface.java

License:Open Source License

public static void assemble(Displayer outer) {
    int i, j;/*from  w ww  .  java2  s . co  m*/
    float px, py;
    float z1, z2, z3, z4;
    float tmp;

    Color col;

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

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

    GL11.glBegin(GL11.GL_QUADS);

    px = spx;
    for (i = 0; i < outer.rezx - 1; i++) {
        py = spy;
        for (j = 0; j < outer.rezy - 1; j++) {
            z1 = (float) outer.val[i][j];
            z2 = (float) outer.val[i + 1][j];
            z3 = (float) outer.val[i][j + 1];
            z4 = (float) outer.val[i + 1][j + 1];

            tmp = (float) (1 - ((outer.val[i][j] - outer.minc) / (outer.maxc - outer.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.glVertex3f(px, py, z1);

            tmp = (float) (1 - ((outer.val[i][j + 1] - outer.minc) / (outer.maxc - outer.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.glVertex3f(px, py + 1, z3);

            tmp = (float) (1 - ((outer.val[i + 1][j + 1] - outer.minc) / (outer.maxc - outer.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.glVertex3f(px + 1, py + 1, z4);

            tmp = (float) (1 - ((outer.val[i + 1][j] - outer.minc) / (outer.maxc - outer.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.glVertex3f(px + 1, py, z2);

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

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

From source file:allout58.mods.techtree.util.RenderingHelper.java

License:Open Source License

public static void draw2DLine(int x1, int y1, int x2, int y2, float width, int colorRGB) {
    float red = (float) (colorRGB >> 16 & 255) / 255.0F;
    float blue = (float) (colorRGB >> 8 & 255) / 255.0F;
    float green = (float) (colorRGB & 255) / 255.0F;

    GL11.glDisable(GL11.GL_TEXTURE_2D);//  w  w w  . j a  v  a 2s  .co  m
    GL11.glEnable(GL11.GL_BLEND);
    GL11.glEnable(GL11.GL_LINE_SMOOTH);
    GL11.glLineWidth(width);

    GL11.glPushMatrix();
    GL11.glColor3f(red, green, blue);
    GL11.glBegin(GL11.GL_LINE_STRIP);
    GL11.glVertex3d(x1, y1, 0.0D);
    GL11.glVertex3d(x2, y2, 0.0D);
    GL11.glEnd();
    GL11.glPopMatrix();

    GL11.glEnable(GL11.GL_TEXTURE_2D);
    GL11.glDisable(GL11.GL_BLEND);
    GL11.glDisable(GL11.GL_LINE_SMOOTH);
}

From source file:analog.clock.AnalogClock.java

private void drawCircle(double r, int n) {
    GL11.glColor3f(1.0f, 1.0f, 0.0f);
    double theta = 2 * Math.PI / n;
    GL11.glPushMatrix();/*from  w  w  w  . jav  a 2 s .  co m*/
    GL11.glBegin(GL11.GL_LINES);
    for (int i = 0; i < n;) {
        //GL11.glVertex3f(0, 0, 0);
        float x = (float) (r * Math.cos(theta * i));
        float y = (float) (r * Math.sin(theta * i));
        GL11.glVertex3f(x, y, 0);
        i++;
        x = (float) (r * Math.cos(theta * i));
        y = (float) (r * Math.sin(theta * i));
        GL11.glVertex3f(x, y, 0);
    }
    GL11.glEnd();
    GL11.glPopMatrix();
}

From source file:aphelion.client.graphics.screen.NiftyCameraImpl.java

License:Open Source License

@Override
public void renderCamera(@Nonnull Camera camera, boolean renderStars) {
    GL11.glColor3f(1, 1, 1);

    camera.setPosition(defaultCameraPosition);
    camera.clipPosition(0, 0, 1024 * 16, 1024 * 16);

    if (renderStars) {
        stars.render(camera);/*from w  ww .j  a  va 2s.c o  m*/
    }

    camera.renderEntities(mapEntities.animations(RENDER_LAYER.BACKGROUND, camera));
    camera.renderTiles(mapClassic, TileType.TILE_LAYER.PLAIN);
    // rendered in a seperate iteration so that we do not have to switch between textures as often
    // (tile set is one big texture)
    camera.renderTiles(mapClassic, TileType.TILE_LAYER.ANIMATED);
    camera.renderEntities(mapEntities.animations(RENDER_LAYER.AFTER_TILES, camera));
    camera.renderEntities(mapEntities.projectiles(false));
    camera.renderEntities(mapEntities.animations(RENDER_LAYER.AFTER_PROJECTILES, camera));
    camera.renderEntities(mapEntities.shipsNoLocal());
    camera.renderEntities(mapEntities.animations(RENDER_LAYER.AFTER_SHIPS, camera));
    camera.renderEntity(mapEntities.getLocalShip());
    camera.renderTiles(mapClassic, TileType.TILE_LAYER.PLAIN_OVER_SHIP);
    camera.renderEntities(mapEntities.animations(RENDER_LAYER.AFTER_LOCAL_SHIP, camera));
}

From source file:appeng.client.ClientHelper.java

License:Open Source License

@SubscribeEvent
public void postPlayerRender(final RenderLivingEvent.Pre p) {
    final PlayerColor player = TickHandler.INSTANCE.getPlayerColors().get(p.entity.getEntityId());
    if (player != null) {
        final AEColor col = player.myColor;

        final float r = 0xff & (col.mediumVariant >> 16);
        final float g = 0xff & (col.mediumVariant >> 8);
        final float b = 0xff & (col.mediumVariant);
        GL11.glColor3f(r / 255.0f, g / 255.0f, b / 255.0f);
    }/*from  w w  w .  j a  va  2 s.  c o m*/
}

From source file:appeng.client.gui.implementations.GuiVibrationChamber.java

License:Open Source License

@Override
public void drawFG(final int offsetX, final int offsetY, final int mouseX, final int mouseY) {
    this.fontRendererObj.drawString(this.getGuiDisplayName(GuiText.VibrationChamber.getLocal()), 8, 6, 4210752);
    this.fontRendererObj.drawString(GuiText.inventory.getLocal(), 8, this.ySize - 96 + 3, 4210752);

    this.pb.setFullMsg(this.cvc.getAePerTick() * this.cvc.getCurrentProgress() / 100 + " AE/t");

    if (this.cvc.getCurrentProgress() > 0) {
        final int i1 = this.cvc.getCurrentProgress();
        this.bindTexture("guis/vibchamber.png");
        GL11.glColor3f(1, 1, 1);
        final int l = -15;
        final int k = 25;
        this.drawTexturedModalRect(k + 56, l + 36 + 12 - i1, 176, 12 - i1, 14, i1 + 2);
    }//from   w  ww  .ja  v a2 s  .c  o m
}

From source file:appeng.client.render.items.ToolWirelessTerminalRender.java

License:Open Source License

@Override
public void renderItem(final ItemRenderType type, final ItemStack item, final Object... data) {
    Entity itemLocation = item.getItemFrame();
    if (itemLocation == null) {
        itemLocation = Minecraft.getMinecraft().thePlayer;
    }//from  w  w w  .  ja va 2s.c  o m

    final boolean displayAntenna = ((ToolWirelessTerminal) item.getItem()).getIsUsable(item, itemLocation);
    final boolean hasPower = ((ToolWirelessTerminal) item.getItem()).hasPower(null, 0.5, item);

    IIcon border;
    if (displayAntenna) {
        border = ExtraItemTextures.WirelessTerminal_Border.getIcon();
    } else {
        border = ExtraItemTextures.WirelessTerminal_Border_Inactive.getIcon();
    }
    final IIcon scrollBar = ExtraItemTextures.WirelessTerminal_ScrollBar.getIcon();
    final IIcon icons = ExtraItemTextures.WirelessTerminal_Icons.getIcon();
    IIcon screen = ExtraItemTextures.WirelessTerminal_Screen.getIcon();

    final AEColor color = ToolWirelessTerminal.getColor(item);
    if (color == null) {
        screen = item.getIconIndex();
    }

    final Tessellator tessellator = Tessellator.instance;
    GL11.glPushMatrix();
    GL11.glPushAttrib(GL11.GL_ALL_ATTRIB_BITS);

    //translate stuff for different item render types
    if (type != ItemRenderType.INVENTORY) {
        if (type == ItemRenderType.EQUIPPED_FIRST_PERSON) {
            GL11.glTranslatef(0.0F, 0.0F, 0.0F);
        } else if (type == ItemRenderType.EQUIPPED) {
            GL11.glTranslatef(0.0F, 0.0F, 0.0F);
        } else {
            GL11.glTranslatef(-0.5F, -0.3F, 0.01F);
        }
    } else {
        GL11.glColor4f(1, 1, 1, 1.0F);
        GL11.glScalef(16F, 16F, 10F);
        GL11.glTranslatef(0.0F, 1.0F, 0.0F);
        GL11.glRotatef(180F, 1.0F, 0.0F, 0.0F);
        GL11.glEnable(GL11.GL_ALPHA_TEST);
    }

    final float f12 = 0.0625F;

    //Border, which is uncolored
    subRenderItem(type, tessellator, border, f12);

    if (hasPower) {
        RenderHelper.disableStandardItemLighting();
    }

    //If a terminal isn't colored, use the default icon which doesn't require icons or scrollbar
    if (color != null) {
        //Icons, which are dark colored
        {
            final int blackColor = color.blackVariant;
            final float r = (blackColor >> 16) & 0xFF;
            final float g = (blackColor >> 8) & 0xFF;
            final float b = blackColor & 0xFF;
            GL11.glColor3f(r / 256.0f, g / 256.0f, b / 256.0f);

            subRenderItem(type, tessellator, icons, f12);
        }

        //Scrollbar, which is medium colored
        {
            final int medColor = color.mediumVariant;
            final float r = (medColor >> 16) & 0xFF;
            final float g = (medColor >> 8) & 0xFF;
            final float b = medColor & 0xFF;
            GL11.glColor3f(r / 256.0f, g / 256.0f, b / 256.0f);

            subRenderItem(type, tessellator, scrollBar, f12);
        }
    }

    //Screen, which is light colored
    {
        if (color != null) {
            final int whiteColor = color.whiteVariant;
            final float r = (whiteColor >> 16) & 0xFF;
            final float g = (whiteColor >> 8) & 0xFF;
            final float b = whiteColor & 0xFF;
            GL11.glColor3f(r / 256.0f, g / 256.0f, b / 256.0f);
        }

        subRenderItem(type, tessellator, screen, f12);
    }

    GL11.glPopAttrib();
    GL11.glPopMatrix();
}