aboutsummaryrefslogtreecommitdiff
path: root/src/main/java/at/hannibal2/skyhanni/utils/shader
diff options
context:
space:
mode:
authorWalker Selby <git@walkerselby.com>2023-11-22 11:50:00 +0000
committerGitHub <noreply@github.com>2023-11-22 12:50:00 +0100
commit4ff0a7de8109b748cdaa707e9714478140095171 (patch)
treed0321aeb182c1ace326c8c851dbf9a7e8861ff62 /src/main/java/at/hannibal2/skyhanni/utils/shader
parent5d1e9a07eabe3872c714b17b64b7a6e0a0073d73 (diff)
downloadskyhanni-4ff0a7de8109b748cdaa707e9714478140095171.tar.gz
skyhanni-4ff0a7de8109b748cdaa707e9714478140095171.tar.bz2
skyhanni-4ff0a7de8109b748cdaa707e9714478140095171.zip
Internal Change: Reformat Code to match .editorconfig (#628)
Code cleanup done everywhere #628
Diffstat (limited to 'src/main/java/at/hannibal2/skyhanni/utils/shader')
-rw-r--r--src/main/java/at/hannibal2/skyhanni/utils/shader/Shader.kt4
-rw-r--r--src/main/java/at/hannibal2/skyhanni/utils/shader/ShaderHelper.kt62
-rw-r--r--src/main/java/at/hannibal2/skyhanni/utils/shader/ShaderManager.kt12
-rw-r--r--src/main/java/at/hannibal2/skyhanni/utils/shader/Uniform.kt3
4 files changed, 55 insertions, 26 deletions
diff --git a/src/main/java/at/hannibal2/skyhanni/utils/shader/Shader.kt b/src/main/java/at/hannibal2/skyhanni/utils/shader/Shader.kt
index f198f7e7a..7fb13ab86 100644
--- a/src/main/java/at/hannibal2/skyhanni/utils/shader/Shader.kt
+++ b/src/main/java/at/hannibal2/skyhanni/utils/shader/Shader.kt
@@ -30,7 +30,7 @@ abstract class Shader(vertex: String, fragment: String) {
if (linkStatus == GL11.GL_FALSE) {
LorenzUtils.consoleLog(
"Error occurred when linking program with Vertex Shader: $vertex and Fragment Shader: $fragment : " +
- StringUtils.trim(ShaderHelper.glGetProgramInfoLog(shaderProgram, 1024))
+ StringUtils.trim(ShaderHelper.glGetProgramInfoLog(shaderProgram, 1024))
)
}
@@ -52,4 +52,4 @@ abstract class Shader(vertex: String, fragment: String) {
fun <T> registerUniform(uniformType: Uniform.UniformType<T>, name: String, uniformValuesSupplier: Supplier<T>) {
uniforms.add(Uniform(this, uniformType, name, uniformValuesSupplier))
}
-} \ No newline at end of file
+}
diff --git a/src/main/java/at/hannibal2/skyhanni/utils/shader/ShaderHelper.kt b/src/main/java/at/hannibal2/skyhanni/utils/shader/ShaderHelper.kt
index e554a4098..790550103 100644
--- a/src/main/java/at/hannibal2/skyhanni/utils/shader/ShaderHelper.kt
+++ b/src/main/java/at/hannibal2/skyhanni/utils/shader/ShaderHelper.kt
@@ -27,9 +27,9 @@ class ShaderHelper {
// Check OpenGL 2.0 Capabilities
val openGL20supported = capabilities.OpenGL20
SHADERS_SUPPORTED = openGL20supported ||
- capabilities.GL_ARB_vertex_shader &&
- capabilities.GL_ARB_fragment_shader &&
- capabilities.GL_ARB_shader_objects
+ capabilities.GL_ARB_vertex_shader &&
+ capabilities.GL_ARB_fragment_shader &&
+ capabilities.GL_ARB_shader_objects
var log = "Shaders are"
if (!SHADERS_SUPPORTED) log += " not"
@@ -67,12 +67,18 @@ class ShaderHelper {
if (USING_ARB_SHADERS) ARBShaderObjects.glLinkProgramARB(program) else GL20.glLinkProgram(program)
}
- fun glGetProgramInfoLog(program: Int, maxLength: Int) : String {
- return if (USING_ARB_SHADERS) ARBShaderObjects.glGetInfoLogARB(program, maxLength) else GL20.glGetProgramInfoLog(program, maxLength)
+ fun glGetProgramInfoLog(program: Int, maxLength: Int): String {
+ return if (USING_ARB_SHADERS) ARBShaderObjects.glGetInfoLogARB(
+ program,
+ maxLength
+ ) else GL20.glGetProgramInfoLog(program, maxLength)
}
- fun glGetProgrami(program: Int, pname: Int) : Int {
- return if (USING_ARB_SHADERS) ARBShaderObjects.glGetObjectParameteriARB(program, pname) else GL20.glGetProgrami(program, pname)
+ fun glGetProgrami(program: Int, pname: Int): Int {
+ return if (USING_ARB_SHADERS) ARBShaderObjects.glGetObjectParameteriARB(
+ program,
+ pname
+ ) else GL20.glGetProgrami(program, pname)
}
fun glUseProgram(program: Int) {
@@ -80,27 +86,39 @@ class ShaderHelper {
}
fun glAttachShader(program: Int, shaderIn: Int) {
- if (USING_ARB_SHADERS) ARBShaderObjects.glAttachObjectARB(program, shaderIn) else GL20.glAttachShader(program, shaderIn)
+ if (USING_ARB_SHADERS) ARBShaderObjects.glAttachObjectARB(program, shaderIn) else GL20.glAttachShader(
+ program,
+ shaderIn
+ )
}
- fun glCreateShader(type: Int) : Int {
+ fun glCreateShader(type: Int): Int {
return if (USING_ARB_SHADERS) ARBShaderObjects.glCreateShaderObjectARB(type) else GL20.glCreateShader(type)
}
fun glShaderSource(shader: Int, source: CharSequence) {
- if (USING_ARB_SHADERS) ARBShaderObjects.glShaderSourceARB(shader, source) else GL20.glShaderSource(shader, source)
+ if (USING_ARB_SHADERS) ARBShaderObjects.glShaderSourceARB(shader, source) else GL20.glShaderSource(
+ shader,
+ source
+ )
}
fun glCompileShader(shader: Int) {
if (USING_ARB_SHADERS) ARBShaderObjects.glCompileShaderARB(shader) else GL20.glCompileShader(shader)
}
- fun glGetShaderi(shader: Int, pname: Int) : Int {
- return if (USING_ARB_SHADERS) ARBShaderObjects.glGetObjectParameteriARB(shader, pname) else GL20.glGetShaderi(shader, pname)
+ fun glGetShaderi(shader: Int, pname: Int): Int {
+ return if (USING_ARB_SHADERS) ARBShaderObjects.glGetObjectParameteriARB(
+ shader,
+ pname
+ ) else GL20.glGetShaderi(shader, pname)
}
- fun glGetShaderInfoLog(shader: Int, maxLength: Int) : String {
- return if (USING_ARB_SHADERS) ARBShaderObjects.glGetInfoLogARB(shader, maxLength) else GL20.glGetShaderInfoLog(shader, maxLength)
+ fun glGetShaderInfoLog(shader: Int, maxLength: Int): String {
+ return if (USING_ARB_SHADERS) ARBShaderObjects.glGetInfoLogARB(
+ shader,
+ maxLength
+ ) else GL20.glGetShaderInfoLog(shader, maxLength)
}
fun glDeleteShader(shader: Int) {
@@ -112,13 +130,21 @@ class ShaderHelper {
}
fun glUniform3f(location: Int, v0: Float, v1: Float, v2: Float) {
- if (USING_ARB_SHADERS) ARBShaderObjects.glUniform3fARB(location, v0, v1, v2) else GL20.glUniform3f(location, v0, v1, v2)
+ if (USING_ARB_SHADERS) ARBShaderObjects.glUniform3fARB(location, v0, v1, v2) else GL20.glUniform3f(
+ location,
+ v0,
+ v1,
+ v2
+ )
}
- fun glGetUniformLocation(program: Int, name: CharSequence) : Int {
- return if (USING_ARB_SHADERS) ARBShaderObjects.glGetUniformLocationARB(program, name) else GL20.glGetUniformLocation(program, name)
+ fun glGetUniformLocation(program: Int, name: CharSequence): Int {
+ return if (USING_ARB_SHADERS) ARBShaderObjects.glGetUniformLocationARB(
+ program,
+ name
+ ) else GL20.glGetUniformLocation(program, name)
}
fun areShadersSupported() = SHADERS_SUPPORTED
}
-} \ No newline at end of file
+}
diff --git a/src/main/java/at/hannibal2/skyhanni/utils/shader/ShaderManager.kt b/src/main/java/at/hannibal2/skyhanni/utils/shader/ShaderManager.kt
index e7eb48f11..3dbec3c6e 100644
--- a/src/main/java/at/hannibal2/skyhanni/utils/shader/ShaderManager.kt
+++ b/src/main/java/at/hannibal2/skyhanni/utils/shader/ShaderManager.kt
@@ -21,7 +21,7 @@ object ShaderManager {
CHROMA(ChromaShader.INSTANCE);
companion object {
- fun getShaderInstance(shaderName: String) : Shader? = when (shaderName) {
+ fun getShaderInstance(shaderName: String): Shader? = when (shaderName) {
"chroma" -> CHROMA.shader
else -> {
null
@@ -58,7 +58,7 @@ object ShaderManager {
activeShader = null
}
- fun loadShader(type: ShaderType, fileName: String) : Int {
+ fun loadShader(type: ShaderType, fileName: String): Int {
val resourceLocation = ResourceLocation("skyhanni:shaders/$fileName${type.extension}")
val source = StringBuilder()
@@ -73,8 +73,10 @@ object ShaderManager {
ShaderHelper.glCompileShader(shaderID)
if (ShaderHelper.glGetShaderi(shaderID, ShaderHelper.GL_COMPILE_STATUS) == 0) {
- LorenzUtils.consoleLog("Error occurred when compiling shader $fileName${type.extension} : " +
- StringUtils.trim(ShaderHelper.glGetShaderInfoLog(shaderID, 1024)))
+ LorenzUtils.consoleLog(
+ "Error occurred when compiling shader $fileName${type.extension} : " +
+ StringUtils.trim(ShaderHelper.glGetShaderInfoLog(shaderID, 1024))
+ )
}
return shaderID
@@ -84,4 +86,4 @@ object ShaderManager {
enum class ShaderType(val extension: String, val shaderType: Int) {
VERTEX(".vsh", ShaderHelper.GL_VERTEX_SHADER),
FRAGMENT(".fsh", ShaderHelper.GL_FRAGMENT_SHADER)
-} \ No newline at end of file
+}
diff --git a/src/main/java/at/hannibal2/skyhanni/utils/shader/Uniform.kt b/src/main/java/at/hannibal2/skyhanni/utils/shader/Uniform.kt
index e87ea3b22..d57398ea4 100644
--- a/src/main/java/at/hannibal2/skyhanni/utils/shader/Uniform.kt
+++ b/src/main/java/at/hannibal2/skyhanni/utils/shader/Uniform.kt
@@ -37,9 +37,10 @@ class Uniform<T>(
val values = newUniformValue as FloatArray
ShaderHelper.glUniform3f(uniformID, values[0], values[1], values[2])
}
+
UniformType.BOOL -> ShaderHelper.glUniform1f(uniformID, if (newUniformValue as Boolean) 1f else 0f)
}
previousUniformValue = newUniformValue
}
}
-} \ No newline at end of file
+}