diff options
Diffstat (limited to 'src/main/java/at/hannibal2/skyhanni/features/chroma')
5 files changed, 65 insertions, 9 deletions
diff --git a/src/main/java/at/hannibal2/skyhanni/features/chroma/ChromaFontRenderer.kt b/src/main/java/at/hannibal2/skyhanni/features/chroma/ChromaFontRenderer.kt index 26dc45969..4e3a4d37f 100644 --- a/src/main/java/at/hannibal2/skyhanni/features/chroma/ChromaFontRenderer.kt +++ b/src/main/java/at/hannibal2/skyhanni/features/chroma/ChromaFontRenderer.kt @@ -36,7 +36,7 @@ class ChromaFontRenderer(private val baseColor: Int) { fun newChromaEnv(): ChromaFontRenderer { if (ShaderHelper.areShadersSupported()) { - ChromaShaderManager.begin() + ChromaShaderManager.begin(ChromaType.TEXTURED) GlStateManager.shadeModel(GL11.GL_SMOOTH) } return this diff --git a/src/main/java/at/hannibal2/skyhanni/features/chroma/ChromaShader.kt b/src/main/java/at/hannibal2/skyhanni/features/chroma/ChromaShader.kt index 61e69a67b..96b6d24b7 100644 --- a/src/main/java/at/hannibal2/skyhanni/features/chroma/ChromaShader.kt +++ b/src/main/java/at/hannibal2/skyhanni/features/chroma/ChromaShader.kt @@ -14,11 +14,8 @@ import net.minecraft.client.Minecraft * Credit: [ChromaShader.java](https://github.com/BiscuitDevelopment/SkyblockAddons/blob/main/src/main/java/codes/biscuit/skyblockaddons/shader/chroma/ChromaShader.java) */ -object ChromaShader : Shader("chroma", "chroma") { - +abstract class ChromaShader(vertex: String, fragment: String) : Shader(vertex, fragment) { val config get() = SkyHanniMod.feature.chroma - val INSTANCE: ChromaShader - get() = this override fun registerUniforms() { registerUniform(Uniform.UniformType.FLOAT, "chromaSize") { diff --git a/src/main/java/at/hannibal2/skyhanni/features/chroma/ChromaShaderManager.kt b/src/main/java/at/hannibal2/skyhanni/features/chroma/ChromaShaderManager.kt index ccf0ec21e..98e1daa71 100644 --- a/src/main/java/at/hannibal2/skyhanni/features/chroma/ChromaShaderManager.kt +++ b/src/main/java/at/hannibal2/skyhanni/features/chroma/ChromaShaderManager.kt @@ -13,19 +13,27 @@ object ChromaShaderManager { private var chromaEnabled = false - fun begin() { + /** + * Enables the type of chroma shader passed in + * + * @param chromaType A type of chroma shader from [ChromaType] + */ + fun begin(chromaType: ChromaType) { disable() - enable() + enable(chromaType) } + /** + * Disables the currently active chroma shader + */ fun end() { disable() } - private fun enable() { + private fun enable(chromaType: ChromaType) { if (!chromaEnabled) { chromaEnabled = true - ShaderManager.enableShader("chroma") + ShaderManager.enableShader(chromaType.shaderName) } } @@ -35,4 +43,15 @@ object ChromaShaderManager { ShaderManager.disableShader() } } +} + +enum class ChromaType(val shaderName: String) { + /** + * See [StandardChromaShader] + */ + STANDARD("standard_chroma"), + /** + * See [TexturedChromaShader] + */ + TEXTURED("textured_chroma") }
\ No newline at end of file diff --git a/src/main/java/at/hannibal2/skyhanni/features/chroma/StandardChromaShader.kt b/src/main/java/at/hannibal2/skyhanni/features/chroma/StandardChromaShader.kt new file mode 100644 index 000000000..268b37b4c --- /dev/null +++ b/src/main/java/at/hannibal2/skyhanni/features/chroma/StandardChromaShader.kt @@ -0,0 +1,20 @@ +package at.hannibal2.skyhanni.features.chroma + +/** + * A type of chroma shader generally used for standard GUI elements using Gui.drawRect and + * other GUI element drawing functions. + * + * Explicitly those that do not depend on a texture. + * + * **Usage:** + * + * ``` + * ChromaShaderManager.begin(ChromaType.STANDARD) + * // draw GUI element here + * ChromaShaderManager.end() + * ``` + */ +object StandardChromaShader : ChromaShader("standard_chroma", "standard_chroma") { + val INSTANCE: StandardChromaShader + get() = this +}
\ No newline at end of file diff --git a/src/main/java/at/hannibal2/skyhanni/features/chroma/TexturedChromaShader.kt b/src/main/java/at/hannibal2/skyhanni/features/chroma/TexturedChromaShader.kt new file mode 100644 index 000000000..544d10184 --- /dev/null +++ b/src/main/java/at/hannibal2/skyhanni/features/chroma/TexturedChromaShader.kt @@ -0,0 +1,20 @@ +package at.hannibal2.skyhanni.features.chroma + +/** + * This chroma type is used for GUI elements with textures, that includes text, + * any assets from Minecraft or from the mod, etc... + * + * **Usage:** + * + * If you want to use chroma for text see [FontRendererHook][at.hannibal2.skyhanni.mixins.hooks.FontRendererHook.setupChromaFont] + * + * ``` + * ChromaShaderManager.begin(ChromaType.TEXTURE) + * // draw GUI element here + * ChromaShaderManager.end() + * ``` + */ +object TexturedChromaShader : ChromaShader("textured_chroma", "textured_chroma") { + val INSTANCE: TexturedChromaShader + get() = this +}
\ No newline at end of file |