Java Code Examples for org.lwjgl.opengl.GL11#glColor4ub()

The following examples show how to use org.lwjgl.opengl.GL11#glColor4ub() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: RenderUtils.java    From PneumaticCraft with GNU General Public License v3.0 6 votes vote down vote up
public void renderLiquid(FluidTankInfo info, RenderInfo renderInfo, World worldObj){
    if(info.fluid.getFluid().getBlock() != null) {
        renderInfo.baseBlock = info.fluid.getFluid().getBlock();
    } else {
        renderInfo.baseBlock = Blocks.water;
    }
    renderInfo.texture = info.fluid.getFluid().getIcon(info.fluid);
    FMLClientHandler.instance().getClient().getTextureManager().bindTexture(TextureMap.locationBlocksTexture);
    // Tessellator.instance.setColorOpaque_I();
    int color = info.fluid.getFluid().getColor(info.fluid);
    int red = color >> 16 & 255;
    int green = color >> 8 & 255;
    int blue = color & 255;
    GL11.glColor4ub((byte)red, (byte)green, (byte)blue, (byte)255);
    RenderUtils.INSTANCE.renderBlock(renderInfo, worldObj, 0, 0, 0, false, true);
}
 
Example 2
Source File: GLUtils.java    From ehacks-pro with GNU General Public License v3.0 5 votes vote down vote up
public static void renderBlock(int x, int y, int z, XRayBlock block) {

        GL11.glColor4ub(((byte) block.r), ((byte) block.g), ((byte) block.b), ((byte) block.a));
        GL11.glVertex3f(x, y, z);
        GL11.glVertex3f((x + 1), y, z);
        GL11.glVertex3f((x + 1), y, z);
        GL11.glVertex3f((x + 1), y, (z + 1));
        GL11.glVertex3f(x, y, z);
        GL11.glVertex3f(x, y, (z + 1));
        GL11.glVertex3f(x, y, (z + 1));
        GL11.glVertex3f((x + 1), y, (z + 1));
        GL11.glVertex3f(x, (y + 1), z);
        GL11.glVertex3f((x + 1), (y + 1), z);
        GL11.glVertex3f((x + 1), (y + 1), z);
        GL11.glVertex3f((x + 1), (y + 1), (z + 1));
        GL11.glVertex3f(x, (y + 1), z);
        GL11.glVertex3f(x, (y + 1), (z + 1));
        GL11.glVertex3f(x, (y + 1), (z + 1));
        GL11.glVertex3f((x + 1), (y + 1), (z + 1));
        GL11.glVertex3f(x, y, z);
        GL11.glVertex3f(x, (y + 1), z);
        GL11.glVertex3f(x, y, (z + 1));
        GL11.glVertex3f(x, (y + 1), (z + 1));
        GL11.glVertex3f((x + 1), y, z);
        GL11.glVertex3f((x + 1), (y + 1), z);
        GL11.glVertex3f((x + 1), y, (z + 1));
        GL11.glVertex3f((x + 1), (y + 1), (z + 1));
    }
 
Example 3
Source File: RenderState.java    From OpenPeripheral-Addons with MIT License 5 votes vote down vote up
public void setColor(int rgb, float opacity) {
	final byte scaledOpacity = (byte)(opacity * 255);
	int newColor = rgb << 8 | (scaledOpacity & 0xFF);

	if (newColor != color) {
		final byte r = (byte)(rgb >> 16);
		final byte g = (byte)(rgb >> 8);
		final byte b = (byte)(rgb >> 0);

		GL11.glColor4ub(r, g, b, scaledOpacity);
		this.color = newColor;
	}
}