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:de.codesourcery.flocking.LWJGLRenderer.java

License:Apache License

private void renderWorld(World world) {
    final double modelMax = world.getSimulationParameters().modelMax;
    xInc = Display.getWidth() / modelMax;
    yInc = Display.getHeight() / modelMax;

    GL11.glEnable(GL11.GL_DEPTH_TEST);//  w w w  .j av a  2s . c  o  m
    GL11.glDepthMask(true);

    GL11.glClear(GL11.GL_COLOR_BUFFER_BIT | GL11.GL_DEPTH_BUFFER_BIT);

    GL11.glDisable(GL11.GL_DEPTH_TEST);
    GL11.glDepthMask(false);

    GL11.glColor3f(0.5f, 0.5f, 1.0f);

    GL11.glEnableClientState(GL11.GL_VERTEX_ARRAY);

    final int triangleCount = world.getPopulationCount();

    // setup vertex data       
    final int vertexArrayLen = triangleCount * 3 * 2; // one triangle = 3 vertices * 2 int's per vertex
    final MyIntBuffer vertexBuffer = getVertexBuffer(vertexArrayLen);

    final IntBuffer vertexIntBuffer = vertexBuffer.getBuffer();
    final IBoidVisitor visitor = new IBoidVisitor() {

        @Override
        public void visit(Boid boid) {
            drawBoid(boid, vertexIntBuffer);
        }
    };
    world.visitAllBoids(visitor);

    vertexBuffer.rewind();

    GL15.glBindBuffer(GL15.GL_ARRAY_BUFFER, vertexBuffer.getHandle());
    GL15.glBufferData(GL15.GL_ARRAY_BUFFER, vertexBuffer.getBuffer(), GL15.GL_DYNAMIC_DRAW);
    GL11.glVertexPointer(2, GL11.GL_INT, 0, 0);

    // setup index data
    MyIntBuffer indexBuffer = getIndexBuffer(triangleCount * 3);
    GL15.glBindBuffer(GL15.GL_ELEMENT_ARRAY_BUFFER, indexBuffer.getHandle());
    GL15.glBufferData(GL15.GL_ELEMENT_ARRAY_BUFFER, indexBuffer.getBuffer(), GL15.GL_STATIC_DRAW);

    GL11.glDrawElements(GL11.GL_TRIANGLES, triangleCount * 3, GL11.GL_UNSIGNED_INT, 0);

    GL15.glBindBuffer(GL15.GL_ARRAY_BUFFER, 0);
    GL15.glBindBuffer(GL15.GL_ELEMENT_ARRAY_BUFFER, 0);

    GL11.glDisableClientState(GL11.GL_VERTEX_ARRAY);

    GL11.glEnable(GL11.GL_DEPTH_TEST);
    GL11.glDepthMask(true);
}

From source file:de.sanandrew.core.manpack.mod.client.render.RenderSanPlayer.java

License:Creative Commons License

@Override
protected int shouldRenderPass(AbstractClientPlayer player, int renderPass, float partTicks) {
    this.myModel.skirt1.showModel = !(player.inventory.armorItemInSlot(1) != null
            && player.inventory.armorItemInSlot(1).getItem() instanceof ItemArmor);
    this.myModel.skirt2.showModel = this.myModel.skirt1.showModel;

    this.myModel.armRight2.showModel = !(player.inventory.armorItemInSlot(2) != null
            && player.inventory.armorItemInSlot(2).getItem() instanceof ItemArmor);
    this.myModel.armLeft2.showModel = this.myModel.armRight2.showModel;

    ItemStack stack = player.inventory.armorItemInSlot(3 - renderPass);

    if (renderPass == 0) {
        this.myModel.hideTails = false;
    }/*  w w w.j a  va  2 s  .  co m*/

    if (stack != null) {
        Item item = stack.getItem();
        this.myModelArmor.hatBase = null;

        if (item instanceof ItemArmor) {
            ItemArmor armorItem = (ItemArmor) item;
            String unlocName = stack.getUnlocalizedName().replace(':', '_');

            switch (renderPass) {
            case 0:
                this.bindTexture(tryLoadArmorPiece("Hat", unlocName, player, stack, renderPass));
                if (!this.hatRenderList.containsKey(unlocName)) {
                    CubeLoader cubes = CubeLoader.loadFromResource(unlocName);
                    cubes.initCubeInstances(this.myModelArmor);
                    hatRenderList.put(unlocName, cubes);
                }

                this.myModelArmor.hatBase = this.hatRenderList.get(unlocName).getCubeParent();
                this.myModel.hideTails = this.hatRenderList.get(unlocName).hideTails;
                break;
            case 1:
                this.bindTexture(tryLoadArmorPiece("Chest", unlocName, player, stack, renderPass));
                break;
            case 2:
                this.bindTexture(tryLoadArmorPiece("Leggings", unlocName, player, stack, renderPass));
                break;
            case 3:
                this.bindTexture(tryLoadArmorPiece("Boots", unlocName, player, stack, renderPass));
                break;
            }

            //                myModelArmor.hatBase.showModel = renderPass == 0;
            myModelArmor.body.showModel = renderPass == 1 || renderPass == 2;
            myModelArmor.bipedLeftArm.showModel = renderPass == 1;
            myModelArmor.armLeft2.showModel = renderPass == 1;
            myModelArmor.bipedRightArm.showModel = renderPass == 1;
            myModelArmor.armRight2.showModel = renderPass == 1;
            myModelArmor.skirt1.showModel = renderPass == 2;
            myModelArmor.skirt2.showModel = renderPass == 2;
            myModelArmor.legLeft.showModel = renderPass == 2 || renderPass == 3;
            myModelArmor.legRight.showModel = renderPass == 2 || renderPass == 3;
            this.setRenderPassModel(myModelArmor);
            myModelArmor.onGround = this.myModel.onGround;
            myModelArmor.isRiding = this.myModel.isRiding;
            myModelArmor.isChild = this.myModel.isChild;
            myModelArmor.isSneak = this.myModel.isSneak;
            myModelArmor.aimedBow = this.myModel.aimedBow;
            myModelArmor.heldItemLeft = this.myModel.heldItemLeft;
            myModelArmor.heldItemRight = this.myModel.heldItemRight;

            int armorColor = armorItem.getColor(stack);
            if (armorColor != -1) {
                float red = (armorColor >> 16 & 255) / 255.0F;
                float green = (armorColor >> 8 & 255) / 255.0F;
                float blue = (armorColor & 255) / 255.0F;
                GL11.glColor3f(red, green, blue);
            } else if (this.unknownTextureColorMap.containsKey(unlocName)) {
                RGBAValues rgba = this.unknownTextureColorMap.get(unlocName);
                GL11.glColor3f(rgba.getRed() / 255.0F, rgba.getGreen() / 255.0F, rgba.getBlue() / 255.0F);
            } else {
                GL11.glColor3f(1.0F, 1.0F, 1.0F);
            }

            if (stack.isItemEnchanted()) {
                return 15;
            }

            return 1;
        }
    }

    return -1;
}

From source file:de.sanandrew.core.manpack.mod.client.render.RenderSanPlayer.java

License:Creative Commons License

@Override
public void renderFirstPersonArm(EntityPlayer player) {
    GL11.glColor3f(1.0F, 1.0F, 1.0F);
    this.modelBipedMain.onGround = 0.0F;
    boolean isRidingPrev = this.modelBipedMain.isRiding;
    this.modelBipedMain.isRiding = false;
    this.modelBipedMain.setRotationAngles(0.0F, 0.0F, 0.0F, 0.0F, 0.0F, 0.0625F, player);
    this.modelBipedMain.isRiding = isRidingPrev;
    if (this.renderManager.renderEngine != null) {
        if (player.getCurrentArmor(2) != null) {
            this.bindTexture(this.getEntityTexture(player));
            this.myModel.bipedLeftArm.render(0.0625F);
            String armoredChest = player.getCurrentArmor(2).getUnlocalizedName().replace(':', '_');
            boolean prevArmR2Visible = this.myModel.armRight2.showModel;

            Minecraft.getMinecraft().getTextureManager().bindTexture(
                    tryLoadArmorPiece("Chest", armoredChest, player, player.getCurrentArmor(2), 1));

            this.myModel.bipedRightArm.render(0.0625F);
            GL11.glPushMatrix();//from w w  w  . j av a2 s .com
            GL11.glScalef(1.05F, 1.05F, 1.05F);
            GL11.glTranslatef(0.015F, 0.00F, 0.0F);
            int armorColor = ((ItemArmor) player.getCurrentArmor(2).getItem())
                    .getColor(player.getCurrentArmor(2));
            if (armorColor != -1) {
                float red = (armorColor >> 16 & 255) / 255.0F;
                float green = (armorColor >> 8 & 255) / 255.0F;
                float blue = (armorColor & 255) / 255.0F;
                GL11.glColor3f(red, green, blue);
            } else if (this.unknownTextureColorMap.containsKey(armoredChest)) {
                RGBAValues rgba = this.unknownTextureColorMap.get(armoredChest);
                GL11.glColor3f(rgba.getRed() / 255.0F, rgba.getGreen() / 255.0F, rgba.getBlue() / 255.0F);
            }

            this.myModel.armRight2.showModel = true;
            this.myModel.armRight2.render(0.0625F);
            this.myModel.armRight2.showModel = prevArmR2Visible;
            GL11.glColor3f(1.0F, 1.0F, 1.0F);
            GL11.glPopMatrix();
        } else {
            boolean prevArmR2Visible = this.myModel.armRight2.showModel;

            this.bindTexture(this.getEntityTexture(player));
            this.myModel.bipedRightArm.render(0.0625F);
            GL11.glPushMatrix();
            GL11.glScalef(1.05F, 1.05F, 1.05F);
            GL11.glTranslatef(0.015F, 0.00F, 0.0F);
            this.myModel.armRight2.showModel = true;
            this.myModel.armRight2.render(0.0625F);
            this.myModel.armRight2.showModel = prevArmR2Visible;
            GL11.glPopMatrix();
        }
    }
}

From source file:de.sanandrew.mods.claysoldiers.client.event.SoldierBodyRenderHandler.java

License:Creative Commons License

@SubscribeEvent
public void onSoldierLivingRender(SoldierRenderEvent.RenderLivingEvent event) {
    if (event.clayMan.hasUpgrade(SoldierUpgrades.UPG_IRON_INGOT)) {
        GL11.glScalef(1.19F, 1.19F, 1.19F);
    }//from w  w  w .  j  a  v a  2  s.com

    if (event.clayMan.hasUpgrade(SoldierUpgrades.UPG_ENDERPEARL)) {
        GL11.glColor3f(0.5F, 0.5F, 0.5F);
    }
}

From source file:de.sanandrew.mods.claysoldiers.client.event.SoldierModelRenderHandler.java

License:Creative Commons License

private void renderCrown(RenderClayMan clayManRender, float partTicks, boolean isSuper) {
    ModelBiped model = clayManRender.modelBipedMain;

    this.crown.rotateAngleX = model.bipedHead.rotateAngleX;
    this.crown.rotateAngleY = model.bipedHead.rotateAngleY;
    this.crown.rotateAngleZ = model.bipedHead.rotateAngleZ;

    clayManRender.bindTexture(Textures.CLAYMAN_CROWN);
    if (isSuper) {
        GL11.glColor3f(0.39F, 0.82F, 0.742F);
    } else {//from  w  w  w. j  a v a  2  s . c  o  m
        GL11.glColor3f(1.0F, 0.9F, 0.0F);
    }

    this.crown.render(partTicks);
    GL11.glColor3f(1.0F, 1.0F, 1.0F);
}

From source file:de.sanandrew.mods.claysoldiers.client.event.SoldierModelRenderHandler.java

License:Creative Commons License

private void renderHideArmor(EntityClayMan clayMan, RenderClayMan clayManRender, float partTicks,
        String armorUpgrade) {/*from  w  w w .j av  a 2  s . c  o  m*/
    ModelBiped model = clayManRender.modelBipedMain;

    this.armorBody.rotateAngleX = model.bipedBody.rotateAngleX;
    this.armorBody.rotateAngleY = model.bipedBody.rotateAngleY;
    this.armorBody.rotateAngleZ = model.bipedBody.rotateAngleZ;
    this.armorLeftArm.rotateAngleX = model.bipedLeftArm.rotateAngleX;
    this.armorLeftArm.rotateAngleY = model.bipedLeftArm.rotateAngleY;
    this.armorLeftArm.rotateAngleZ = model.bipedLeftArm.rotateAngleZ;
    this.armorRightArm.rotateAngleX = model.bipedRightArm.rotateAngleX;
    this.armorRightArm.rotateAngleY = model.bipedRightArm.rotateAngleY;
    this.armorRightArm.rotateAngleZ = model.bipedRightArm.rotateAngleZ;

    switch (armorUpgrade) {
    case SoldierUpgrades.UPG_LEATHER:
        clayManRender.bindTexture(Textures.CLAYMAN_LEATHER_ARMOR);
        break;
    case "not_implemented_rabbit_hide": //todo: implement rabbit hide texture when 1.8 arrives
        clayManRender.bindTexture(Textures.CLAYMAN_LEATHER_ARMOR);
        break;
    default:
        return;
    }

    GL11.glPushMatrix();
    GL11.glScalef(1.2F, 1.2F, 1.2F);
    this.armorBody.render(partTicks);
    this.armorLeftArm.render(partTicks);
    this.armorRightArm.render(partTicks);

    if (clayMan.hasUpgrade(SoldierUpgrades.UPG_IRON_INGOT)) {
        this.buffedBody.render(partTicks);
    }

    GL11.glPopMatrix();

    if (clayMan.hasUpgrade(SoldierUpgrades.UPG_WOOL)) {
        float[] color = getSplittedColor(clayMan.getMiscColor());

        clayManRender.bindTexture(Textures.CLAYMAN_PADDING);
        GL11.glPushMatrix();
        GL11.glScalef(1.1F, 1.1F, 1.1F);
        GL11.glColor3f(color[0], color[1], color[2]);
        this.armorBody.render(partTicks);
        this.armorLeftArm.render(partTicks);
        this.armorRightArm.render(partTicks);
        GL11.glPopMatrix();
    }
}

From source file:de.sanandrew.mods.claysoldiers.client.event.SoldierModelRenderHandler.java

License:Creative Commons License

private static void renderCape(EntityClayMan clayMan, RenderClayMan clayManRender, float partTicks,
        boolean isSuper) {
    GL11.glPushMatrix();//from ww w  .j  av a 2  s  . c om
    GL11.glTranslatef(0.0F, 0.0F, 0.175F);

    double swingProgX = calcSwingProgress(clayMan.cloakHelper.swingPosX, clayMan.cloakHelper.prevSwingPosX,
            clayMan.posX, clayMan.prevPosX, partTicks);
    double swingProgY = calcSwingProgress(clayMan.cloakHelper.swingPosY, clayMan.cloakHelper.prevSwingPosY,
            clayMan.posY, clayMan.prevPosY, partTicks) * 10.0F;
    double swingProgZ = calcSwingProgress(clayMan.cloakHelper.swingPosZ, clayMan.cloakHelper.prevSwingPosZ,
            clayMan.posZ, clayMan.prevPosZ, partTicks);
    float yawOffProg = clayMan.prevRenderYawOffset
            + (clayMan.renderYawOffset - clayMan.prevRenderYawOffset) * partTicks;
    double yawOffProgSin = MathHelper.sin(yawOffProg * (float) Math.PI / 180.0F);
    double yawOffProgNCos = -MathHelper.cos(yawOffProg * (float) Math.PI / 180.0F);

    if (swingProgY < -6.0F) {
        swingProgY = -6.0F;
    }

    if (swingProgY > 32.0F) {
        swingProgY = 32.0F;
    }

    float swingXZSin = (float) (swingProgX * yawOffProgSin + swingProgZ * yawOffProgNCos) * 100.0F;
    float swingXZNCos = (float) (swingProgX * yawOffProgNCos - swingProgZ * yawOffProgSin) * 100.0F;

    if (swingXZSin < 0.0F) {
        swingXZSin = 0.0F;
    }

    GL11.glRotatef(6.0F + swingXZSin / 2.0F + (float) swingProgY, 1.0F, 0.0F, 0.0F);
    GL11.glRotatef(swingXZNCos / 2.0F, 0.0F, 0.0F, 1.0F);
    GL11.glRotatef(-swingXZNCos / 2.0F, 0.0F, 1.0F, 0.0F);
    GL11.glRotatef(180.0F, 0.0F, 1.0F, 0.0F);

    if (isSuper) {
        clayManRender.bindTexture(Textures.CLAYMAN_CAPE_DIAMOND);
    } else {
        float[] color = getSplittedColor(clayMan.getMiscColor());
        GL11.glColor3f(color[0], color[1], color[2]);
        clayManRender.bindTexture(Textures.CLAYMAN_CAPE_BLANK);
    }

    clayManRender.modelBipedMain.bipedCloak.render(0.0625F);
    GL11.glColor3f(1.0F, 1.0F, 1.0F);
    GL11.glPopMatrix();
}

From source file:de.sanandrew.mods.claysoldiers.client.render.tileentity.RenderClayNexus.java

License:Creative Commons License

private void renderGlowmap(TileEntityClayNexus nexus) {
    float[] colors = new float[] { 1.0F, 1.0F, 1.0F };
    if (nexus.getStackInSlot(0) != null) {
        RGBAValues rgba = SAPUtils//from   w  ww.  j  av  a  2  s .  co m
                .getRgbaFromColorInt(ItemClayManDoll.getTeam(nexus.getStackInSlot(0)).getIconColor());
        colors[0] = rgba.getRed() / 255.0F;
        colors[1] = rgba.getGreen() / 255.0F;
        colors[2] = rgba.getBlue() / 255.0F;
    }

    GL11.glEnable(GL11.GL_BLEND);
    OpenGlHelper.glBlendFunc(GL11.GL_SRC_ALPHA, GL11.GL_ONE_MINUS_SRC_ALPHA, GL11.GL_ONE, GL11.GL_ZERO);
    GL11.glDisable(GL11.GL_ALPHA_TEST);
    float prevBrightX = OpenGlHelper.lastBrightnessX;
    float prevBrightY = OpenGlHelper.lastBrightnessY;
    if (nexus.isActive) {
        int brightness = 0xF0;
        int brightX = brightness % 65536;
        int brightY = brightness / 65536;
        OpenGlHelper.setLightmapTextureCoords(OpenGlHelper.lightmapTexUnit, brightX, brightY);
    }

    this.bindTexture(Textures.NEXUS_GLOWING);
    GL11.glColor3f(colors[0], colors[1], colors[2]);
    this.nexusModel.renderTileEntityGlowmap();
    GL11.glColor3f(1.0F, 1.0F, 1.0F);
    OpenGlHelper.setLightmapTextureCoords(OpenGlHelper.lightmapTexUnit, prevBrightX, prevBrightY);
    GL11.glEnable(GL11.GL_ALPHA_TEST);
    GL11.glDisable(GL11.GL_BLEND);
}

From source file:de.sanandrew.mods.claysoldiers.client.render.tileentity.RenderClayNexus.java

License:Creative Commons License

private static void renderSoldierItem(TileEntityClayNexus nexus, ItemStack stack, float partTicks) {
    float[] colors = new float[] { 1.0F, 1.0F, 1.0F };
    float itmAngle = nexus.prevSpinAngle + (nexus.spinAngle - nexus.prevSpinAngle) * partTicks - 45.0F;

    RGBAValues rgba = SAPUtils.getRgbaFromColorInt(ItemClayManDoll.getTeam(stack).getIconColor());
    colors[0] = rgba.getRed() / 255.0F;//from w  ww.ja  va  2s .c  o  m
    colors[1] = rgba.getGreen() / 255.0F;
    colors[2] = rgba.getBlue() / 255.0F;

    GL11.glPushMatrix();
    GL11.glTranslatef(0.0F, 1.225F, 0.0F);
    GL11.glRotatef(180.0F, 1.0F, 0.0F, 0.0F);
    GL11.glScalef(0.25F, 0.25F, 0.25F);
    GL11.glRotatef(itmAngle, 0.0F, 1.0F, 0.0F);
    GL11.glTranslatef(-0.5F, 0.0F, 0.0F);
    GL11.glColor3f(colors[0], colors[1], colors[2]);
    ItemRenderHelper.renderItemIn3D(stack);
    GL11.glColor3f(1.0F, 1.0F, 1.0F);
    GL11.glPopMatrix();
}

From source file:de.sanandrew.mods.claysoldiers.client.render.tileentity.RenderClayNexus.java

License:Creative Commons License

private static void renderThrowableItem(TileEntityClayNexus nexus, ItemStack stack, float partTicks) {
    float itmAngle = nexus.prevSpinAngle + (nexus.spinAngle - nexus.prevSpinAngle) * partTicks - 45.0F;
    ASoldierUpgrade upg = SoldierUpgrades.getUpgrade(stack);
    IThrowableUpgrade throwableUpg = upg instanceof IThrowableUpgrade ? (IThrowableUpgrade) upg : null;
    if (throwableUpg == null) {
        return;//from  w  ww  .  j  a  v  a2  s  . c om
    }

    GL11.glPushMatrix();
    GL11.glTranslatef(0.0F, 0.875F, 0.0F);
    GL11.glRotatef(180.0F, 1.0F, 0.0F, 0.0F);
    GL11.glScalef(0.25F, 0.25F, 0.25F);
    GL11.glRotatef(-itmAngle, 0.0F, 1.0F, 0.0F);
    GL11.glTranslatef(-0.5F, 0.0F, 0.0F);
    GL11.glColor3f(1.0F, 1.0F, 1.0F);
    throwableUpg.renderNexusThrowable(nexus, partTicks);
    GL11.glColor3f(1.0F, 1.0F, 1.0F);
    GL11.glPopMatrix();
}