@@ -210,10 +210,9 @@ protected Binding(RenderState state, boolean wait) {
210210 GL32 .glVertexAttribPointer (i , 3 , GL32 .GL_FLOAT , false , stride , (long ) vbInfo .vertexOffset * Float .BYTES );
211211 }
212212 case NORMAL -> {
213- if (vbInfo .hasNormals ) {
214- GL32 .glEnableVertexAttribArray (i );
215- GL32 .glVertexAttribPointer (i , 3 , GL32 .GL_FLOAT , true , stride , (long ) vbInfo .normalOffset * Float .BYTES );
216- }
213+ if (!vbInfo .hasNormals ) continue ;
214+ GL32 .glEnableVertexAttribArray (i );
215+ GL32 .glVertexAttribPointer (i , 3 , GL32 .GL_FLOAT , true , stride , (long ) vbInfo .normalOffset * Float .BYTES );
217216 }
218217 case COLOR -> {
219218 GL32 .glEnableVertexAttribArray (i );
@@ -222,21 +221,26 @@ protected Binding(RenderState state, boolean wait) {
222221 case UV -> {
223222 for (Map .Entry <String , VertexFormatElement > entry : shader .getVertexFormat ().getElementMapping ().entrySet ()) {
224223 if (entry .getValue () == element ) {
225- if (entry .getKey ().equals ("UV0" )) {
226- GL32 .glEnableVertexAttribArray (i );
227- GL32 .glVertexAttribPointer (i , 2 , GL32 .GL_FLOAT , false , stride , (long ) vbInfo .textureOffset * Float .BYTES );
228- } else if (entry .getKey ().equals ("UV1" )) {
229- GL32 .glDisableVertexAttribArray (i );
230- GL32 .glVertexAttribI2i (i , 0 , 10 );
231- } else if (entry .getKey ().equals ("UV2" )) {
232- GL32 .glDisableVertexAttribArray (i );
233- int x = 240 ;
234- int y = 240 ;
235- if (state .lightmap != null ) {
236- x = (int ) (state .lightmap [0 ] * 240 );
237- y = (int ) (state .lightmap [1 ] * 240 );
224+ switch (entry .getKey ()) {
225+ case "UV0" -> {
226+ GL32 .glEnableVertexAttribArray (i );
227+ GL32 .glVertexAttribPointer (i , 2 , GL32 .GL_FLOAT , false , stride , (long ) vbInfo .textureOffset * Float .BYTES );
228+ }
229+ case "UV1" -> {
230+ GL32 .glDisableVertexAttribArray (i );
231+ GL32 .glVertexAttribI2i (i , 0 , 10 );
232+ }
233+ case "UV2" -> {
234+ GL32 .glDisableVertexAttribArray (i );
235+ //240 means full bright
236+ int x = RenderContext .FULL_BRIGHT ;
237+ int y = RenderContext .FULL_BRIGHT ;
238+ if (state .lightmap != null ) {
239+ x = (int ) (state .lightmap [0 ] * RenderContext .FULL_BRIGHT );
240+ y = (int ) (state .lightmap [1 ] * RenderContext .FULL_BRIGHT );
241+ }
242+ GL32 .glVertexAttribI2i (i , x , y );
238243 }
239- GL32 .glVertexAttribI2i (i , x , y );
240244 }
241245 }
242246 }
@@ -245,7 +249,7 @@ protected Binding(RenderState state, boolean wait) {
245249 }
246250 RenderContext .checkError ();
247251
248- this .restore = RenderContext .apply (state , true ).and (() -> {
252+ this .restore = RenderContext .apply (state ).and (() -> {
249253 RenderContext .checkError ();
250254 shader .getVertexFormat ().clearBufferState ();
251255
@@ -270,7 +274,7 @@ protected With push(Consumer<RenderState> mod) {
270274 }
271275 RenderState state = this .state .clone ();
272276 mod .accept (state );
273- return RenderContext .apply (state , true );
277+ return RenderContext .apply (state );
274278 }
275279
276280 /**
0 commit comments