2222import me .zero .client .api .util .render .gl .GlUtils ;
2323import net .minecraft .client .renderer .GlStateManager ;
2424import net .minecraft .client .renderer .OpenGlHelper ;
25- import pw .knx .feather .tessellate .GrowingTess ;
26- import pw .knx .feather .tessellate .OffsetTess ;
25+ import pw .knx .feather .tessellate .Tessellator ;
2726
2827import java .util .ArrayList ;
2928import java .util .List ;
@@ -43,7 +42,7 @@ private RenderUtils() {}
4342 /**
4443 * Instance of the Tessellator
4544 */
46- public static final OffsetTess tessellator = new OffsetTess ( new GrowingTess ( 4 ) );
45+ public static final Tessellator tessellator = Tessellator . createExpanding ( 4 , 1 , 2 );
4746
4847 /**
4948 * Stores ClientState Gl Caps when setting up
@@ -142,7 +141,7 @@ public static void drawLine(float x, float y, float z, float x1, float y1, float
142141
143142 setupRender (true );
144143 setupClientState (GLClientState .VERTEX , true );
145- tessellator .vertex (x , y , z ).vertex (x1 , y1 , z1 ).draw (GL_LINE_STRIP );
144+ tessellator .addVertex (x , y , z ).addVertex (x1 , y1 , z1 ).draw (GL_LINE_STRIP );
146145 setupClientState (GLClientState .VERTEX , false );
147146 setupRender (false );
148147 }
@@ -159,10 +158,10 @@ public static void drawFlippedTexturedRect(float x1, float y1, float x2, float y
159158 setupClientState (GLClientState .TEXTURE , true );
160159
161160 tessellator
162- .vertex (x1 , y2 , 0 ).texture (0 , 0 )
163- .vertex (x2 , y2 , 0 ).texture (1 , 0 )
164- .vertex (x2 , y1 , 0 ).texture (1 , 1 )
165- .vertex (x1 , y1 , 0 ).texture (0 , 1 )
161+ .addVertex (x1 , y2 , 0 ).setTexture (0 , 0 )
162+ .addVertex (x2 , y2 , 0 ).setTexture (1 , 0 )
163+ .addVertex (x2 , y1 , 0 ).setTexture (1 , 1 )
164+ .addVertex (x1 , y1 , 0 ).setTexture (0 , 1 )
166165 .draw (GL_QUADS );
167166
168167 setupClientState (GLClientState .TEXTURE , false );
@@ -180,10 +179,10 @@ public static void drawReflectedTexturedRect(float x1, float y1, float x2, float
180179 setupClientState (GLClientState .TEXTURE , true );
181180
182181 tessellator
183- .vertex (x1 , y2 , 0 ).texture (1 , 0 )
184- .vertex (x2 , y2 , 0 ).texture (1 , 0 )
185- .vertex (x2 , y1 , 0 ).texture (0 , 1 )
186- .vertex (x1 , y1 , 0 ).texture (1 , 1 )
182+ .addVertex (x1 , y2 , 0 ).setTexture (1 , 0 )
183+ .addVertex (x2 , y2 , 0 ).setTexture (1 , 0 )
184+ .addVertex (x2 , y1 , 0 ).setTexture (0 , 1 )
185+ .addVertex (x1 , y1 , 0 ).setTexture (1 , 1 )
187186 .draw (GL_QUADS );
188187
189188 setupClientState (GLClientState .TEXTURE , false );
@@ -203,7 +202,7 @@ public static void rectangle(float x1, float y1, float x2, float y2, int color)
203202
204203 setupRender (true );
205204 setupClientState (GLClientState .VERTEX , true );
206- tessellator .vertex (x1 , y2 , 0 ).vertex (x2 , y2 , 0 ).vertex (x2 , y1 , 0 ).vertex (x1 , y1 , 0 ).draw (GL_QUADS );
205+ tessellator .addVertex (x1 , y2 , 0 ).addVertex (x2 , y2 , 0 ).addVertex (x2 , y1 , 0 ).addVertex (x1 , y1 , 0 ).draw (GL_QUADS );
207206 setupClientState (GLClientState .VERTEX , false );
208207 setupRender (false );
209208 }
@@ -232,30 +231,23 @@ private static void rectangleGradient(float x1, float y1, float x2, float y2, in
232231 if (color .length == 0 )
233232 throw new RuntimeException ("At least one set of colors should be supplied" );
234233
235- float [] r = new float [color .length ];
236- float [] g = new float [color .length ];
237- float [] b = new float [color .length ];
238- float [] a = new float [color .length ];
239- for (int i = 0 ; i < color .length ; i ++) {
240- float [] c = Colors .getColor (color [i ]);
241- r [i ] = c [0 ]; g [i ] = c [1 ]; b [i ] = c [2 ]; a [i ] = c [3 ];
242- }
234+ int c1 , c2 , c3 , c4 ;
243235
244236 if (color .length == 1 ) {
245- r = new float [] { r [ 0 ], r [ 0 ], r [ 0 ], r [ 0 ] } ;
246- g = new float [] { g [ 0 ], g [ 0 ], g [ 0 ], g [ 0 ] } ;
247- b = new float [] { b [ 0 ], b [ 0 ], b [ 0 ], b [ 0 ] } ;
248- a = new float [] { a [ 0 ], a [ 0 ], a [ 0 ], a [ 0 ] } ;
237+ c1 = color [ 0 ] ;
238+ c2 = color [ 1 ] ;
239+ c3 = color [ 2 ] ;
240+ c4 = color [ 3 ] ;
249241 } else if (color .length > 1 && color .length < 4 ) {
250- r = new float [] { r [ 0 ], r [ 0 ], r [ 1 ], r [ 1 ] } ;
251- g = new float [] { g [ 0 ], g [ 0 ], g [ 1 ], g [ 1 ] } ;
252- b = new float [] { b [ 0 ], b [ 0 ], b [ 1 ], b [ 1 ] } ;
253- a = new float [] { a [ 0 ], a [ 0 ], a [ 1 ], a [ 1 ] } ;
242+ c1 = color [ 0 ] ;
243+ c2 = color [ 0 ] ;
244+ c3 = color [ 1 ] ;
245+ c4 = color [ 2 ] ;
254246 } else {
255- r = new float [] { r [ 0 ], r [ 1 ], r [ 2 ], r [ 3 ] } ;
256- g = new float [] { g [ 0 ], g [ 1 ], g [ 2 ], g [ 3 ] } ;
257- b = new float [] { b [ 0 ], b [ 1 ], b [ 2 ], b [ 3 ] } ;
258- a = new float [] { a [ 0 ], a [ 1 ], a [ 2 ], a [ 3 ] } ;
247+ c1 = color [ 0 ] ;
248+ c2 = color [ 1 ] ;
249+ c3 = color [ 2 ] ;
250+ c4 = color [ 3 ] ;
259251 }
260252
261253 setupRender (true );
@@ -264,14 +256,13 @@ private static void rectangleGradient(float x1, float y1, float x2, float y2, in
264256 setupClientState (GLClientState .COLOR , true );
265257
266258 tessellator
267- .color ( r [ 0 ], g [ 0 ], b [ 0 ], a [ 0 ]). vertex (x1 , y2 , 0 )
268- .color ( r [ 1 ], g [ 1 ], b [ 1 ], a [ 1 ]). vertex (x2 , y2 , 0 )
269- .color ( r [ 2 ], g [ 2 ], b [ 2 ], a [ 2 ]). vertex (x2 , y1 , 0 )
270- .color ( r [ 3 ], g [ 3 ], b [ 3 ], a [ 3 ]). vertex (x1 , y1 , 0 )
259+ .setColor ( c1 ). addVertex (x1 , y2 , 0 )
260+ .setColor ( c2 ). addVertex (x2 , y2 , 0 )
261+ .setColor ( c3 ). addVertex (x2 , y1 , 0 )
262+ .setColor ( c4 ). addVertex (x1 , y1 , 0 )
271263 .draw (GL_QUADS );
272264
273265 setupClientState (GLClientState .COLOR , false );
274- GlStateManager .shadeModel (GL_FLAT );
275266 setupRender (false );
276267 }
277268
0 commit comments