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:im.bci.jnuit.lwjgl.sprite.SpriteBatcher.java

License:Open Source License

private void flush() {
    if (currentSpriteInBatch > 0) {
        boolean hasAlpha = true;
        if (hasAlpha) {
            GL11.glEnable(GL11.GL_BLEND);
        }/*from  w  ww .j  ava  2  s. c  o  m*/
        texCoords.flip();
        vertices.flip();
        GL11.glBindTexture(GL11.GL_TEXTURE_2D, (Integer) currentImage.getId());
        GL11.glTexCoordPointer(2, 0, texCoords);
        GL11.glVertexPointer(2, 0, vertices);
        GL11.glColor4ub(currentColor.getRedByte(), currentColor.getGreenByte(), currentColor.getBlueByte(),
                currentColor.getAlphaByte());
        GL11.glDrawArrays(GL11.GL_QUADS, 0, currentSpriteInBatch * 4);
        if (hasAlpha) {
            GL11.glDisable(GL11.GL_BLEND);
        }
        GL11.glColor3f(1f, 1f, 1f);
        texCoords.rewind();
        texCoords.limit(texCoords.capacity());
        vertices.rewind();
        vertices.limit(texCoords.capacity());

        currentSpriteInBatch = 0;
    }
}

From source file:io.github.javamatrix.randomtech.renderers.RenderSmithy.java

@Override
public void renderTileEntityAt(TileEntity te, double x, double y, double z, float f) {
    // Grab the cast-down entity.
    TileSmithy smithy = (TileSmithy) te;

    // First we'll render the metal.
    if (smithy.state == 1) {
        ResourceLocation texture = new ResourceLocation("This is just so Eclipse doesn't freak.");

        if (smithy.metalType == 1) {
            texture = new ResourceLocation("randomtech", "textures/blocks/oreCubeIron.png");
        } else if (smithy.metalType == 2) {
            texture = new ResourceLocation("randomtech", "textures/blocks/oreCubeGold.png");
        } else if (smithy.metalType == 3) {
            texture = new ResourceLocation("randomtech", "textures/blocks/oreCubeNullium.png");
        }/*ww  w  .  j  a v  a2s .c om*/

        ModelOreCube model = new ModelOreCube();

        boolean airAbove = smithy.getWorldObj().getBlock(smithy.xCoord, smithy.yCoord + 1, smithy.zCoord)
                .getMaterial() == Material.air;

        GL11.glPushMatrix();
        GL11.glTranslatef((float) x + 0.5F, (float) y + 1.5F, (float) z + 0.5F);
        Minecraft.getMinecraft().renderEngine.bindTexture(texture);
        GL11.glPushMatrix();

        GL11.glRotatef(180F, 0.0F, 0.0F, 1.0F);
        if (!airAbove) {
            GL11.glScalef(0.75f, 0.75f, 0.75f);
            GL11.glTranslatef(0.0f, 3.0f / 16.0f, 0.0f);
        }

        float maxProgress = 200.0f;

        if (smithy.metalType == 3) {
            // Nullium takes longer to melt.
            maxProgress = 600.0f;
        }

        float p = smithy.getProgress() / maxProgress;
        GL11.glColor3f(1, 1 - p / 1.5F, 1 - p);
        model.render((Entity) null, 0.0F, 0.0F, -0.1F, 0.0F, 0.0F, 0.0625F);
        GL11.glColor3f(1, 1, 1);
        GL11.glPopMatrix();
        GL11.glPopMatrix();
    } else if (smithy.state == 2) {
        GL11.glPushMatrix();
        float var10 = (float) (x - 0.5F);
        float var11 = (float) (y - 0.5F);
        float var12 = (float) (z - 0.5F);
        GL11.glTranslatef(var10, var11 + 0.05f, var12);
        renderItem(smithy, new ItemStack(RandomTechItems.moltenIngot));
        GL11.glPopMatrix();
    } else if (smithy.state == 3) {
        GL11.glPushMatrix();
        float var10 = (float) (x - 0.5F);
        float var11 = (float) (y - 0.5F);
        float var12 = (float) (z - 0.5F);
        GL11.glTranslatef(var10, var11 + 0.05f, var12);
        if (smithy.metalType == 1) {
            renderItem(smithy, new ItemStack(RandomTechItems.hardenedMetalIngot));
        } else if (smithy.metalType == 2) {
            renderItem(smithy, new ItemStack(RandomTechItems.hardenedMagicalIngot));
        }
        GL11.glPopMatrix();
    }
}

From source file:io.root.gfx.glutils.GL.java

License:Apache License

public static void glColor3f(float r, float g, float b) {
    GL11.glColor3f(r, g, b);
}

From source file:ivorius.ivtoolkit.models.ModelRenderer.java

License:Apache License

private static void renderNodePart(Tessellator tessellator, NodePart nodePart) {
    MeshPart meshPart = nodePart.meshPart;
    Material material = nodePart.material;
    Matrix4f[] bones = nodePart.bones;//from  w w w  . j a v  a  2 s .  c o m

    Mesh mesh = meshPart.mesh;
    IndexData indexData = mesh.getIndices();
    ShortBuffer indexBuf = indexData.getBuffer();

    VertexData vertexData = mesh.getVertices();
    FloatBuffer vertexBuf = vertexData.getBuffer();

    VertexAttributes vertexAttributes = vertexData.getAttributes();
    VertexAttribute posAttr = vertexAttributes.findByUsage(VertexAttributes.Usage.Position);
    int vertexLengthInFloats = vertexAttributes.vertexSize >> 2;

    VertexAttribute textureCoordAttr = null;

    float[] rgb = WHITE;
    Texture texture = null;
    float[] uvs = null;

    if (material.has(TextureAttribute.Diffuse)) {
        TextureAttribute textureAttr = material.get(TextureAttribute.class, TextureAttribute.Diffuse);
        texture = textureAttr.texture;

        textureCoordAttr = vertexAttributes.findByUsageAndUnit(VertexAttributes.Usage.TextureCoordinates, 0);
        if (textureCoordAttr == null)
            uvs = guessUVs(meshPart.primitiveType, texture, meshPart.numVertices);
    } else if (material.has(ColorAttribute.Diffuse)) {
        // Note that a texture replaces the color diffuse

        ColorAttribute diffuse = material.get(ColorAttribute.class, ColorAttribute.Diffuse);
        rgb = new float[] { diffuse.color.getRed() / 255.0f, diffuse.color.getGreen() / 255.0f,
                diffuse.color.getBlue() / 255.0f };
    }

    BlendingAttribute blend = material.get(BlendingAttribute.class, BlendingAttribute.Type);
    if (blend != null) {
        GL11.glEnable(GL11.GL_BLEND);
        GL11.glBlendFunc(blend.sourceFunction, blend.destFunction);

        GL11.glColor4f(rgb[0], rgb[1], rgb[2], blend.opacity);
    } else
        GL11.glColor3f(rgb[0], rgb[1], rgb[2]);

    if (texture != null)
        texture.bindTexture();
    else
        GL11.glDisable(GL11.GL_TEXTURE_2D);

    List<VertexAttribute> boneWeightAttributes = new ArrayList<>();
    for (VertexAttribute attribute : vertexAttributes) {
        if (attribute.usage == VertexAttributes.Usage.BoneWeight)
            boneWeightAttributes.add(attribute);
    }

    tessellator.startDrawing(meshPart.primitiveType);
    for (int i = meshPart.indexOffset; i < meshPart.numVertices + meshPart.indexOffset; i++) {
        int vertexIndex = indexBuf.get(i) * vertexLengthInFloats;

        if (texture != null) {
            if (textureCoordAttr != null) {
                int textureIndex = vertexIndex + (textureCoordAttr.offset >> 2);
                tessellator.setTextureUV(
                        MathUtils.mix(texture.minU(), texture.maxU(), vertexBuf.get(textureIndex)),
                        MathUtils.mix(texture.minV(), texture.maxV(), vertexBuf.get(textureIndex + 1)));
            } else if (uvs != null)
                tessellator.setTextureUV(uvs[i * 2], uvs[i * 2 + 1]);
        }

        int posIndex = vertexIndex + (posAttr.offset >> 2);
        float vertexX = vertexBuf.get(posIndex);
        float vertexY = vertexBuf.get(posIndex + 1);
        float vertexZ = vertexBuf.get(posIndex + 2);

        if (boneWeightAttributes.size() > 0) {
            buildMatrix(TEMP_MATRIX, boneWeightAttributes, vertexBuf, vertexIndex, bones);
            TEMP_VEC.set(vertexX, vertexY, vertexZ, 1.0f);
            Matrix4f.transform(TEMP_MATRIX, TEMP_VEC, TEMP_VEC);
            tessellator.addVertex(TEMP_VEC.x, TEMP_VEC.y, TEMP_VEC.z);
        } else
            tessellator.addVertex(vertexX, vertexY, vertexZ);
    }
    tessellator.draw();

    if (texture == null)
        GL11.glEnable(GL11.GL_TEXTURE_2D);

    if (blend != null)
        GL11.glDisable(GL11.GL_BLEND);
}

From source file:jake2.desktop.LWJGLAdapter.java

License:Open Source License

public void glColor3f(float r, float g, float b) {
    GL11.glColor3f(r, g, b);
}

From source file:kihira.minicreatures.client.render.RenderFox.java

License:Open Source License

@Override
protected int shouldRenderPass(EntityLivingBase par1EntityLivingBase, int par2, float par3) {
    EntityFox entityFox = (EntityFox) par1EntityLivingBase;
    if (par2 == 1 && entityFox.isTamed()) {
        this.bindTexture(this.foxCollarTexture);
        int j = entityFox.getCollarColor();
        GL11.glColor3f(EntitySheep.fleeceColorTable[j][0], EntitySheep.fleeceColorTable[j][1],
                EntitySheep.fleeceColorTable[j][2]);
        return 1;
    } else/*from w w w.  j ava2  s .co  m*/
        return -1;
}

From source file:kihira.minicreatures.client.render.RenderRedPanda.java

License:Open Source License

@Override
protected int shouldRenderPass(EntityLivingBase par1EntityLivingBase, int par2, float par3) {
    EntityRedPanda entityRedPanda = (EntityRedPanda) par1EntityLivingBase;
    if (par2 == 1 && entityRedPanda.isTamed()) {
        this.bindTexture(this.redPandaCollarTexture);
        int j = entityRedPanda.getCollarColor();
        GL11.glColor3f(EntitySheep.fleeceColorTable[j][0], EntitySheep.fleeceColorTable[j][1],
                EntitySheep.fleeceColorTable[j][2]);
        return 1;
    } else//w  w w .  jav  a2 s  .co m
        return -1;
}

From source file:kihira.playerbeacons.client.diary.pages.DiaryPageRecipe.java

License:Open Source License

@Override
public void drawScreen(GuiDiary diary, int width, int height, boolean isLeftPage) {
    //Calculate offset
    int leftOffset = (isLeftPage ? 0 : 128);
    int mainTextTopOffset = (StatCollector.canTranslate(this.getUnlocalisedTitle()) ? 15 : 0);
    FontRenderer fontRenderer = Minecraft.getMinecraft().fontRenderer;

    //Draw the page background
    Minecraft.getMinecraft().getTextureManager().bindTexture(GuiDiary.pageTexture);
    diary.drawTexturedModalRect(diary.getGuiLeft() + leftOffset, diary.getGuiTop(), leftOffset, 0,
            diary.guiWidth / 2, 173);//from   www  .j av  a 2 s .c  o  m

    //Title
    if (mainTextTopOffset != 0) {
        fontRenderer.setUnicodeFlag(false);
        String s = StatCollector.translateToLocal(this.getUnlocalisedTitle());
        fontRenderer.drawString(s,
                diary.getGuiLeft() + leftOffset + (isLeftPage ? 64 : 5) - (fontRenderer.getStringWidth(s) / 2),
                diary.getGuiTop() + 15, 1973019);
        fontRenderer.setUnicodeFlag(true);
    }

    //Recipe
    renderRecipe(diary.getGuiLeft() + leftOffset + 32, diary.getGuiTop() + 20, recipe);

    //Lower Text
    fontRenderer.drawSplitString(StatCollector.translateToLocal(this.pageName),
            diary.getGuiLeft() + leftOffset + (isLeftPage ? 17 : 5), diary.getGuiTop() + 12 + mainTextTopOffset,
            108, 1973019);
    GL11.glColor3f(1F, 1F, 1F);
}

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);//w w  w .  ja  va  2s .  c o  m

    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:kuake2.render.lwjgl.Light.java

License:Open Source License

/**
 * R_RenderDlight//from   ww  w  . j  a va2s.  c  om
 */
void R_RenderDlight(dlight_t light) {
    float rad = light.intensity * 0.35f;

    Math3D.VectorSubtract(light.origin, r_origin, v);

    GL11.glBegin(GL11.GL_TRIANGLE_FAN);
    GL11.glColor3f(light.color[0] * 0.2f, light.color[1] * 0.2f, light.color[2] * 0.2f);
    int i;
    for (i = 0; i < 3; i++)
        v[i] = light.origin[i] - vpn[i] * rad;

    GL11.glVertex3f(v[0], v[1], v[2]);
    GL11.glColor3f(0, 0, 0);

    int j;
    float a;
    for (i = 16; i >= 0; i--) {
        a = (float) (i / 16.0f * Math.PI * 2);
        for (j = 0; j < 3; j++)
            v[j] = (float) (light.origin[j] + vright[j] * Math.cos(a) * rad + vup[j] * Math.sin(a) * rad);
        GL11.glVertex3f(v[0], v[1], v[2]);
    }
    GL11.glEnd();
}