Example usage for org.lwjgl.opengl GL11 glColor4f

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

Introduction

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

Prototype

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

Source Link

Document

Float version of #glColor4b Color4b

Usage

From source file:RobotDemo.java

private void loop() {
    GL11.glClearColor(1.0f, 1.0f, 1.0f, 1.0f);
    GL11.glColor4f(1.0f, 0.0f, 0.0f, 1.0f);

    while (GLFW.glfwWindowShouldClose(window) != GL11.GL_TRUE) {
        GL11.glClear(GL11.GL_COLOR_BUFFER_BIT | GL11.GL_DEPTH_BUFFER_BIT);
        GL11.glPushMatrix();//from  w w  w. ja  v a  2s . com
        for (Robot r : robots)
            r.draw();
        GL11.glPopMatrix();
        GLFW.glfwSwapBuffers(window);
        GLFW.glfwPollEvents();
    }
}

From source file:Robot.java

public void setColor(float r, float g, float b) {
    robotColor[0] = r;/*from  ww  w .j  a v a2s .  c  o m*/
    robotColor[1] = g;
    robotColor[2] = b;
    GL11.glColor4f(r, g, b, 1);
}

From source file:Robot.java

private void drawTorso() {
    GL11.glColor4f(robotColor[0], robotColor[1], robotColor[2], 1);
    if (selected.get("TORSO")) {
        DrawShapes.fillRectangle(-TORSO_WIDTH / 2, 0, TORSO_WIDTH, TORSO_HEIGHT);
    } else {//ww  w .  ja v  a2  s .  c o  m
        DrawShapes.strokeRectangle(-TORSO_WIDTH / 2, 0, TORSO_WIDTH, TORSO_HEIGHT);
    }
}

From source file:Robot.java

private void drawNeck() {
    GL11.glColor4f(robotColor[0], robotColor[1], robotColor[2], 1);
    if (selected.get("NECK")) {
        DrawShapes.fillRectangle(-NECK_WIDTH / 2, 0, NECK_WIDTH, NECK_HEIGHT);
    } else {//  w  ww .  ja  v  a  2s .  c om
        DrawShapes.strokeRectangle(-NECK_WIDTH / 2, 0, NECK_WIDTH, NECK_HEIGHT);
    }
}

From source file:Robot.java

private void drawHead() {
    GL11.glColor4f(robotColor[0], robotColor[1], robotColor[2], 1);
    float EYE_RADIUS = HEAD_RADIUS / 5;
    float MOUTH_WIDTH = HEAD_RADIUS * 0.7f;
    // the circular face
    if (selected.get("HEAD")) {
        DrawShapes.fillCircle(HEAD_RADIUS, HEAD_SIDES);
    } else {// w w  w.j a  v a2  s . c om
        DrawShapes.strokeCircle(HEAD_RADIUS, HEAD_SIDES);
    }
    // draw the right eye
    GL11.glPushMatrix();
    GL11.glTranslatef(HEAD_RADIUS / 2 - EYE_RADIUS / 2, HEAD_RADIUS * 0.1f, 0);
    if (selected.get("HEAD")) {
        GL11.glColor4f(1, 1, 0, 1);
        DrawShapes.strokeCircle(EYE_RADIUS, HEAD_SIDES);
        GL11.glColor4f(1, 1, 1, 1);
        DrawShapes.fillCircle(EYE_RADIUS * 0.8f, HEAD_SIDES);
        setColor(robotColor[0], robotColor[1], robotColor[2]);
    } else {
        DrawShapes.strokeCircle(EYE_RADIUS, HEAD_SIDES);
        DrawShapes.strokeCircle(EYE_RADIUS * 0.8f, HEAD_SIDES);
    }

    GL11.glPopMatrix();
    // draw the left eye
    GL11.glPushMatrix();
    GL11.glTranslatef(-HEAD_RADIUS / 2 + EYE_RADIUS / 2, HEAD_RADIUS * 0.1f, 0);
    if (selected.get("HEAD")) {
        GL11.glColor4f(1, 1, 0, 1);
        DrawShapes.strokeCircle(EYE_RADIUS, HEAD_SIDES);
        GL11.glColor4f(1, 1, 1, 1);
        DrawShapes.fillCircle(EYE_RADIUS * 0.8f, HEAD_SIDES);
        setColor(robotColor[0], robotColor[1], robotColor[2]);
    } else {
        DrawShapes.strokeCircle(EYE_RADIUS, HEAD_SIDES);
        DrawShapes.strokeCircle(EYE_RADIUS * 0.8f, HEAD_SIDES);
    }
    GL11.glPopMatrix();
    // draw the mouth
    GL11.glPushMatrix();
    GL11.glTranslatef(0, -HEAD_RADIUS / 2, 0);
    if (selected.get("HEAD")) {
        GL11.glColor4f(1, 1, 1, 1);
        DrawShapes.fillRectangle(-MOUTH_WIDTH * 0.5f, 0, MOUTH_WIDTH, MOUTH_WIDTH * 0.1f);
        setColor(robotColor[0], robotColor[1], robotColor[2]);
    } else {
        DrawShapes.strokeRectangle(-MOUTH_WIDTH * 0.5f, 0, MOUTH_WIDTH, MOUTH_WIDTH * 0.1f);
    }
    GL11.glPopMatrix();
}

From source file:Robot.java

private void drawUpperRightArm() {
    GL11.glColor4f(robotColor[0], robotColor[1], robotColor[2], 1);
    if (selected.get("UPPER_RIGHT_ARM")) {
        DrawShapes.fillRectangle(0, 0, UPPER_ARM_WIDTH, UPPER_ARM_HEIGHT);
    } else {/*from w  w  w . java2 s.  c  om*/
        DrawShapes.strokeRectangle(0, 0, UPPER_ARM_WIDTH, UPPER_ARM_HEIGHT);
    }
}

From source file:Robot.java

private void drawUpperLeftArm() {
    GL11.glColor4f(robotColor[0], robotColor[1], robotColor[2], 1);
    if (selected.get("UPPER_LEFT_ARM")) {
        DrawShapes.fillRectangle(0, 0, UPPER_ARM_WIDTH, UPPER_ARM_HEIGHT);
    } else {//w  w w.ja va  2s .c  om
        DrawShapes.strokeRectangle(0, 0, UPPER_ARM_WIDTH, UPPER_ARM_HEIGHT);
    }
}

From source file:Robot.java

private void drawLowerRightArm() {
    GL11.glColor4f(robotColor[0], robotColor[1], robotColor[2], 1);
    if (selected.get("LOWER_RIGHT_ARM")) {
        DrawShapes.fillRectangle(0, 0, LOWER_ARM_WIDTH, -LOWER_ARM_HEIGHT);
    } else {//  w  ww .j a  v  a  2s . c o m
        DrawShapes.strokeRectangle(0, 0, LOWER_ARM_WIDTH, -LOWER_ARM_HEIGHT);
    }
}

From source file:Robot.java

private void drawLowerLeftArm() {
    GL11.glColor4f(robotColor[0], robotColor[1], robotColor[2], 1);
    if (selected.get("LOWER_LEFT_ARM")) {
        DrawShapes.fillRectangle(0, 0, LOWER_ARM_WIDTH, -LOWER_ARM_HEIGHT);
    } else {//from  ww w  .  j  a  v a  2 s.  co  m
        DrawShapes.strokeRectangle(0, 0, LOWER_ARM_WIDTH, -LOWER_ARM_HEIGHT);
    }
}

From source file:Robot.java

private void drawRightThigh() {
    GL11.glColor4f(robotColor[0], robotColor[1], robotColor[2], 1);
    if (selected.get("RIGHT_THIGH")) {
        DrawShapes.fillRectangle(0, 0, THIGH_WIDTH, -THIGH_HEIGHT);
    } else {/*from  ww  w.j a v  a  2s. c om*/
        DrawShapes.strokeRectangle(0, 0, THIGH_WIDTH, -THIGH_HEIGHT);
    }
}