Created
June 20, 2021 09:02
-
-
Save tumen102/c612d5068dac6abdaa4f3dd83fa4787b to your computer and use it in GitHub Desktop.
Set openGL color with 0xff112233 type value.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public static float[] hexToFloat(int colourToConvert) { | |
float red = (float) (colourToConvert >> 16 & 255) / 255.0F; | |
float green = (float) (colourToConvert >> 8 & 255) / 255.0F; | |
float blue = (float) (colourToConvert & 255) / 255.0F; | |
return new float[] {red, green, blue}; | |
} | |
public static void glColorInt(int hexColour) { | |
float[] rgbValues = hexToFloat(hexColour); | |
GL11.glColor3f(rgbValues[0], rgbValues[1], rgbValues[2]); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment