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:org.ode4j.drawstuff.internal.DrawStuffGL.java

License:Open Source License

@Override
public void dsDrawSphere(final float[] pos, final float[] R, float radius) {
    if (current_state != 2)
        dsError("drawing function called outside simulation loop");
    setupDrawingMode();//from ww  w  .  ja v a2 s.  com
    GL11.glEnable(GL11.GL_NORMALIZE);
    GL11.glShadeModel(GL11.GL_SMOOTH);
    setTransform(pos, R);
    GL11.glScaled(radius, radius, radius);
    drawSphere();
    GL11.glPopMatrix();
    GL11.glDisable(GL11.GL_NORMALIZE);

    // draw shadows
    if (use_shadows) {
        GL11.glDisable(GL11.GL_LIGHTING);
        if (use_textures) {
            ground_texture.bind(true);
            GL11.glEnable(GL11.GL_TEXTURE_2D);
            GL11.glDisable(GL11.GL_TEXTURE_GEN_S);
            GL11.glDisable(GL11.GL_TEXTURE_GEN_T);
            GL11.glColor3f(SHADOW_INTENSITY, SHADOW_INTENSITY, SHADOW_INTENSITY);
        } else {
            GL11.glDisable(GL11.GL_TEXTURE_2D);
            GL11.glColor3f(GROUND_R * SHADOW_INTENSITY, GROUND_G * SHADOW_INTENSITY,
                    GROUND_B * SHADOW_INTENSITY);
        }
        GL11.glShadeModel(GL11.GL_FLAT);
        GL11.glDepthRange(0, 0.9999);
        drawSphereShadow(pos[0], pos[1], pos[2], radius);
        GL11.glDepthRange(0, 1);
    }
}

From source file:org.ode4j.drawstuff.internal.DrawStuffGL.java

License:Open Source License

/** 
 * @see DrawStuffApi#dsDrawLine(float[], float[])
 *//*w  ww.j  a va 2s. c om*/
@Override
public void dsDrawLine(final float[] pos1, final float[] pos2) {
    setupDrawingMode();
    GL11.glColor3f(color[0], color[1], color[2]);
    GL11.glDisable(GL11.GL_LIGHTING);
    GL11.glLineWidth(2);
    GL11.glShadeModel(GL11.GL_FLAT);
    GL11.glBegin(GL11.GL_LINES);
    GL11.glVertex3f(pos1[0], pos1[1], pos1[2]);
    GL11.glVertex3f(pos2[0], pos2[1], pos2[2]);
    GL11.glEnd();
}

From source file:org.spoutcraft.client.gui.MCRenderDelegate.java

License:Open Source License

public void render(GenericScrollable gs) {
    int scrollTop = gs.getScrollPosition(Orientation.VERTICAL);
    int scrollLeft = gs.getScrollPosition(Orientation.HORIZONTAL);
    GL11.glTranslated(gs.getScreenX(), gs.getScreenY(), 0);
    GL11.glEnable(GL11.GL_SCISSOR_TEST);
    scissorWidget(gs);/*from ww  w  . j av  a  2s .c  om*/
    RenderUtil.drawRectangle(0, 0, (int) gs.getWidth(), (int) gs.getHeight(), gs.getBackgroundColor().toInt());
    GL11.glPushMatrix();
    GL11.glTranslated(-scrollLeft, -scrollTop, 0);
    GL11.glPushMatrix();

    // Render scrollarea contents
    gs.renderContents();

    GL11.glPopMatrix();
    GL11.glPopMatrix();
    GL11.glDisable(GL11.GL_SCISSOR_TEST);
    GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F);

    GL11.glDisable(2896 /*GL_LIGHTING*/);
    GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F);
    // Draw scrollbars
    if (gs.needsScrollBar(Orientation.HORIZONTAL)) {
        SpoutClient.getHandle().renderEngine.bindTexture("/gui/allitems.png");
        double scrollX = 0;
        double p = (double) scrollLeft / (double) gs.getMaximumScrollPosition(Orientation.HORIZONTAL);
        scrollX = 3 + p * (gs.getViewportSize(Orientation.HORIZONTAL) - 16.0 - 6);
        RenderUtil.drawGradientRectangle(0, (int) gs.getHeight() - 16, (int) gs.getWidth(),
                (int) gs.getHeight(), scrollBarColor.toInt(), scrollBarColor2.toInt());
        GL11.glColor3f(1.0f, 1.0f, 1.0f);
        RenderUtil.drawTexturedModalRectangle((int) scrollX, (int) (gs.getHeight() - 16), 232, 0, 12, 15, 0f);
    }
    if (gs.needsScrollBar(Orientation.VERTICAL)) {
        SpoutClient.getHandle().renderEngine.bindTexture("/gui/allitems.png");
        double scrollY = 0;
        double p = (double) scrollTop / (double) gs.getMaximumScrollPosition(Orientation.VERTICAL);
        scrollY = 3 + p * (gs.getViewportSize(Orientation.VERTICAL) - 16.0 - 6);
        RenderUtil.drawGradientRectangle((int) gs.getWidth() - 16, 0, (int) gs.getWidth(), (int) gs.getHeight(),
                scrollBarColor.toInt(), scrollBarColor2.toInt());
        GL11.glColor3f(1.0f, 1.0f, 1.0f);
        RenderUtil.drawTexturedModalRectangle((int) (gs.getWidth() - 16), (int) scrollY, 232, 0, 12, 15, 0f);
        RenderUtil.drawGradientRectangle(0, -1, (int) gs.getWidth(), 5,
                new Color(0.0F, 0.0F, 0.0F, 1.0F).toInt(), new Color(0.0F, 0.0F, 0.0F, 0.0F).toInt());
        RenderUtil.drawGradientRectangle(0, (int) gs.getHeight() - 5, (int) gs.getWidth() + 1,
                (int) gs.getHeight(), new Color(0.0F, 0.0F, 0.0F, 0.0F).toInt(),
                new Color(0.0F, 0.0F, 0.0F, 1.0F).toInt());
    }
}

From source file:org.spoutcraft.client.gui.minimap.MapRenderer.java

License:Open Source License

private void renderWaypoints() {
    double playerX = Minecraft.theMinecraft.thePlayer.posX;
    double playerZ = Minecraft.theMinecraft.thePlayer.posZ;
    for (Waypoint pt : MinimapConfig.getInstance().getWaypoints(MinimapUtils.getWorldName())) {
        if (pt.enabled) {
            double wayX = playerX - pt.x;
            double wayY = playerZ - pt.z;

            int circleX = MathHelper.floor_double(playerX);
            int circleY = MathHelper.floor_double(playerZ);

            boolean render = false;
            if (MinimapConfig.getInstance().isSquare()) {
                render = Math.abs(playerX - pt.x) < map.renderSize && Math.abs(playerZ - pt.z) < map.renderSize;
            } else {
                render = MinimapUtils.insideCircle(circleX, circleY, map.renderSize / 2, pt.x, pt.z);
            }//from w w w  .  j av  a 2 s  . c  o  m

            if (render) {
                GL11.glPushMatrix();

                GL11.glTranslatef(32.0f, -32.0F, 0.0F);
                GL11.glRotatef(-(this.direction + 90.0F), 0.0F, 0.0F, 1.0F);
                GL11.glTranslatef(-32.0F, -32.0F, 0.0F);

                GL11.glTranslatef(-33F, 29F, 0F);
                switch (MinimapConfig.getInstance().getZoom()) {
                case 0:
                    GL11.glTranslated(wayY, -wayX, 0F);
                    break;
                case 1:
                    GL11.glTranslated(wayY * 0.45F, -wayX * 0.45F, 0F);
                    break;
                case 2:
                    GL11.glTranslated(wayY * 0.25F, -wayX * 0.28F, 0F);
                    break;
                case 3:
                    GL11.glTranslated(wayY * 0.125F, -wayX * 0.125F, 0F);
                    break;
                }
                GL11.glScalef(0.25F, 0.25F, 1F);

                GL11.glPopMatrix();
            }
        }
    }
    GL11.glColor3f(1f, 1f, 1f);
}

From source file:org.terasology.rendering.gui.components.UIPieChart.java

License:Apache License

public void render() {
    super.render();

    if (_data.size() == 0)
        return;//from w  ww.  ja  v  a  2s  . c  o  m

    ArrayList<String> sortedKeys = new ArrayList<String>(_data.keySet());
    Collections.sort(sortedKeys);

    glPushMatrix();
    glTranslatef(getSize().x / 2, getSize().y / 2, 0.0f);
    GL11.glBegin(GL11.GL_TRIANGLE_FAN);

    GL11.glColor3f(1.0f, 1.0f, 1.0f);
    GL11.glVertex3f(0f, 0f, 0f);

    double stepSize = (Math.PI * 2.0) / SEGMENTS;

    int segment = 0;
    double prevValueSum = 0.0f;

    for (int i = 0; i <= SEGMENTS; i++) {
        double value = _data.get(sortedKeys.get(segment));

        if (((double) i / SEGMENTS) >= value + prevValueSum) {
            segment++;
            prevValueSum += value;

            Vector3f segmentColor = new Vector3f((segment * 0.1f) % 1.0f, (segment * 0.2f) % 1.0f,
                    (segment * 0.4f) % 1.0f);
            glColor3f(segmentColor.x, segmentColor.y, segmentColor.z);
        }

        GL11.glVertex2f((float) Math.sin(stepSize * i) * (getSize().x / 2),
                (float) Math.cos(stepSize * i) * (getSize().x / 2));
    }

    GL11.glEnd();
    glPopMatrix();
}

From source file:org.voxels.platform.LWJGLOpenGLAdapter.java

License:Open Source License

@Override
public void glColor3f(final int r, final int g, final int b) {
    GL11.glColor3f(r, g, b);
}

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;//www . j  av  a 2s.  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:Render.Polygons.java

public static void drawFPSBar(int fps) {

    int fpsMax = 100;
    float changePoint = (float) fps / (float) fpsMax * 0.15f - 0.95f;

    glBegin(GL11.GL_POLYGON);// w  ww  .  j a v a 2s  .com
    GL11.glColor3f(255, 0, 0);
    glVertex2f(-0.95f, 0.95f); //order: start top-left, go clockwise
    glVertex2f(changePoint, 0.95f);
    glVertex2f(changePoint, 0.9f);
    glVertex2f(-0.95f, 0.9f);
    glEnd();

    glBegin(GL11.GL_POLYGON);
    GL11.glColor3f(255, 255, 255);
    glVertex2f(changePoint, 0.95f); //order: start top-left, go clockwise
    glVertex2f(-0.8f, 0.95f);
    glVertex2f(-0.8f, 0.9f);
    glVertex2f(changePoint, 0.9f);
    glEnd();

}

From source file:Render.Polygons.java

public static void drawIsometricTile(long x, long y, long width, Color c) {
    float[] rgb = new float[] { c.getRed() / 255.0f, c.getGreen() / 255.0f, c.getBlue() / 255.0f };
    float w = 800.0f;
    float h = 600.0f;
    float[] xCoords = new float[] { (x / w), (x + width / 2) / w, (x / w), ((x - width / 2) / w) };
    float[] yCoords = new float[] { (y + width / 4) / h, (y) / h, (y - width / 4) / h, (y) / h };
    if (yCoords[0] > -1f && yCoords[2] < 1f && xCoords[3] < 1f && xCoords[1] > -1f) {
        glBegin(GL11.GL_POLYGON);/*from  ww  w  .  j a va  2 s  .  c o m*/
        GL11.glColor3f(rgb[0], rgb[1], rgb[2]);
        glVertex2f(xCoords[0], yCoords[0]);
        glVertex2f(xCoords[1], yCoords[1]);
        glVertex2f(xCoords[2], yCoords[2]);
        glVertex2f(xCoords[3], yCoords[3]);
        glEnd();
    }
}

From source file:rheel.ac.client.gui.GuiResearchInventory.java

License:Open Source License

@Override
protected void drawGuiContainerBackgroundLayer(float f, int i, int j) {
    GL11.glPushMatrix();//from  w ww.j a v  a 2  s.  c  o m
    GL11.glColor3f(0.5F, 0.5F, 0.5F);
    this.parent.draw(this.mc, this.guiLeft - 100, this.guiTop - 46, true, this.guiLeft, this.guiTop);
    GL11.glPopMatrix();

    this.zLevel += 99;
    this.mc.getTextureManager().bindTexture(TextureLoader.getGUITexture("Inventory.png"));
    GL11.glColor4f(1.0F, 1.0F, 1.0F, 1.0F);
    this.drawTexturedModalRect(this.guiLeft, this.guiTop, 0, 0, this.xSize, this.ySize);
    this.isMouseOverParent = this.isMouseOver(i - this.guiLeft, j - this.guiTop);
}