From 259f93ccd5899e6a5bd3ee8c5a766474346f3242 Mon Sep 17 00:00:00 2001 From: LAX1DUDE Date: Wed, 30 Mar 2022 17:14:38 -0700 Subject: [PATCH] FIXED RAINBOW GLITCH!!! --- .../adapter/EaglerAdapterImpl2.java | 4 ++ .../lax1dude/eaglercraft/EarlyLoadScreen.java | 2 +- .../eaglercraft/glemu/EffectPipeline.java | 2 +- .../glemu/FixedFunctionShader.java | 63 ++++++++++--------- 4 files changed, 38 insertions(+), 33 deletions(-) diff --git a/src/lwjgl/java/net/lax1dude/eaglercraft/adapter/EaglerAdapterImpl2.java b/src/lwjgl/java/net/lax1dude/eaglercraft/adapter/EaglerAdapterImpl2.java index 8affed0..0e1cecf 100644 --- a/src/lwjgl/java/net/lax1dude/eaglercraft/adapter/EaglerAdapterImpl2.java +++ b/src/lwjgl/java/net/lax1dude/eaglercraft/adapter/EaglerAdapterImpl2.java @@ -60,6 +60,7 @@ import de.cuina.fireandfuel.CodecJLayerMP3; import net.lax1dude.eaglercraft.AssetRepository; import net.lax1dude.eaglercraft.EarlyLoadScreen; import net.lax1dude.eaglercraft.ServerQuery; +import net.lax1dude.eaglercraft.adapter.EaglerAdapterImpl2.ProgramGL; import net.lax1dude.eaglercraft.adapter.lwjgl.GameWindowListener; import net.minecraft.src.MathHelper; import paulscode.sound.SoundSystem; @@ -593,6 +594,9 @@ public class EaglerAdapterImpl2 { public static final float _wglGetTexParameterf(int p1) { return GL11.glGetTexParameterf(GL11.GL_TEXTURE_2D, p1); } + public static final int _wglGetAttribLocation(ProgramGL p1, String p2) { + return GL20.glGetAttribLocation(p1.obj, p2); + } // ======================================================================================= diff --git a/src/main/java/net/lax1dude/eaglercraft/EarlyLoadScreen.java b/src/main/java/net/lax1dude/eaglercraft/EarlyLoadScreen.java index 29af664..9471bcc 100644 --- a/src/main/java/net/lax1dude/eaglercraft/EarlyLoadScreen.java +++ b/src/main/java/net/lax1dude/eaglercraft/EarlyLoadScreen.java @@ -55,6 +55,7 @@ public class EarlyLoadScreen { _wglAttachShader(program, vert); _wglAttachShader(program, frag); + _wglBindAttributeLocation(program, 0, "a_pos"); _wglLinkProgram(program); _wglDetachShader(program, vert); _wglDetachShader(program, frag); @@ -68,7 +69,6 @@ public class EarlyLoadScreen { } _wglUseProgram(program); - _wglBindAttributeLocation(program, 0, "a_pos"); _wglUniform1i(_wglGetUniformLocation(program, "tex"), 0); int width = getCanvasWidth(); diff --git a/src/main/java/net/lax1dude/eaglercraft/glemu/EffectPipeline.java b/src/main/java/net/lax1dude/eaglercraft/glemu/EffectPipeline.java index 7c61d64..4c3b955 100644 --- a/src/main/java/net/lax1dude/eaglercraft/glemu/EffectPipeline.java +++ b/src/main/java/net/lax1dude/eaglercraft/glemu/EffectPipeline.java @@ -426,6 +426,7 @@ public class EffectPipeline { _wglAttachShader(prog, pvert_shader); _wglAttachShader(prog, f); + _wglBindAttributeLocation(prog, 0, "a_pos"); _wglLinkProgram(prog); _wglDetachShader(prog, pvert_shader); _wglDetachShader(prog, f); @@ -444,7 +445,6 @@ public class EffectPipeline { UniformGL d = _wglGetUniformLocation(prog, "f_depth"); if(d != null) _wglUniform1i(d, 1); - _wglBindAttributeLocation(prog, 0, "a_pos"); if(_wglGetUniformLocation(prog, "ssao_kernel[0]") != null) { EaglercraftRandom r = new EaglercraftRandom("eeeaglerrENOPHILEr".hashCode()); diff --git a/src/main/java/net/lax1dude/eaglercraft/glemu/FixedFunctionShader.java b/src/main/java/net/lax1dude/eaglercraft/glemu/FixedFunctionShader.java index 1e94454..b357b59 100644 --- a/src/main/java/net/lax1dude/eaglercraft/glemu/FixedFunctionShader.java +++ b/src/main/java/net/lax1dude/eaglercraft/glemu/FixedFunctionShader.java @@ -200,6 +200,38 @@ public class FixedFunctionShader { globject = _wglCreateProgram(); _wglAttachShader(globject, v); _wglAttachShader(globject, f); + + int i = 0; + a_position = i++; + _wglBindAttributeLocation(globject, a_position, "a_position"); + + if(enable_texture0) { + a_texture0 = i++; + _wglBindAttributeLocation(globject, a_texture0, "a_texture0"); + }else { + a_texture0 = -1; + } + if(enable_color) { + a_color = i++; + _wglBindAttributeLocation(globject, a_color, "a_color"); + }else { + a_color = -1; + } + if(enable_normal) { + a_normal = i++; + _wglBindAttributeLocation(globject, a_normal, "a_normal"); + }else { + a_normal = -1; + } + if(enable_texture1) { + a_texture1 = i++; + _wglBindAttributeLocation(globject, a_texture1, "a_texture1"); + }else { + a_texture1 = -1; + } + + attributeIndexesToEnable = i; + _wglLinkProgram(globject); _wglDetachShader(globject, v); @@ -263,37 +295,6 @@ public class FixedFunctionShader { u_texCoordV0 = _wglGetUniformLocation(globject, "texCoordV0"); u_texCoordV1 = _wglGetUniformLocation(globject, "texCoordV1"); - int i = 0; - a_position = i++; - _wglBindAttributeLocation(globject, a_position, "a_position"); - - if(enable_texture0) { - a_texture0 = i++; - _wglBindAttributeLocation(globject, a_texture0, "a_texture0"); - }else { - a_texture0 = -1; - } - if(enable_color) { - a_color = i++; - _wglBindAttributeLocation(globject, a_color, "a_color"); - }else { - a_color = -1; - } - if(enable_normal) { - a_normal = i++; - _wglBindAttributeLocation(globject, a_normal, "a_normal"); - }else { - a_normal = -1; - } - if(enable_texture1) { - a_texture1 = i++; - _wglBindAttributeLocation(globject, a_texture1, "a_texture1"); - }else { - a_texture1 = -1; - } - - attributeIndexesToEnable = i; - genericArray = _wglCreateVertexArray(); genericBuffer = _wglCreateBuffer(); _wglBindVertexArray(genericArray);