Rendering cleanup

Replaces the reflexive instantiation of the Renderes with a factory
method.

Some optimizations to the renderers to no longer push the whole OpenGL state to the stack.

General cleanup of duplicate code, etc
This commit is contained in:
yueh
2015-09-16 18:03:07 +02:00
parent 824ec1eccb
commit d5dfc31210
69 changed files with 435 additions and 343 deletions
@@ -55,6 +55,7 @@ public class SpatialSkyRender extends IRenderHandler
public void render( final float partialTicks, final WorldClient world, final Minecraft mc )
{
final long now = System.currentTimeMillis();
if( now - this.cycle > 2000 )
{
this.cycle = now;
@@ -67,42 +68,37 @@ public class SpatialSkyRender extends IRenderHandler
fade /= 1000;
fade = 0.15f * ( 1.0f - Math.abs( ( fade - 1.0f ) * ( fade - 1.0f ) ) );
GL11.glPushAttrib( GL11.GL_ALL_ATTRIB_BITS );
GL11.glDisable( GL11.GL_FOG );
GL11.glDisable( GL11.GL_ALPHA_TEST );
GL11.glDisable( GL11.GL_BLEND );
GL11.glDepthMask( false );
GL11.glColor4f( 0.0f, 0.0f, 0.0f, 1.0f );
final Tessellator tessellator = Tessellator.instance;
for( int i = 0; i < 6; ++i )
{
GL11.glPushMatrix();
if( i == 1 )
switch( i )
{
GL11.glRotatef( 90.0F, 1.0F, 0.0F, 0.0F );
}
if( i == 2 )
{
GL11.glRotatef( -90.0F, 1.0F, 0.0F, 0.0F );
}
if( i == 3 )
{
GL11.glRotatef( 180.0F, 1.0F, 0.0F, 0.0F );
}
if( i == 4 )
{
GL11.glRotatef( 90.0F, 0.0F, 0.0F, 1.0F );
}
if( i == 5 )
{
GL11.glRotatef( -90.0F, 0.0F, 0.0F, 1.0F );
case 1:
GL11.glRotatef( 90.0F, 1.0F, 0.0F, 0.0F );
break;
case 2:
GL11.glRotatef( -90.0F, 1.0F, 0.0F, 0.0F );
break;
case 3:
GL11.glRotatef( 180.0F, 1.0F, 0.0F, 0.0F );
break;
case 4:
GL11.glRotatef( 90.0F, 0.0F, 0.0F, 1.0F );
break;
case 5:
GL11.glRotatef( -90.0F, 0.0F, 0.0F, 1.0F );
break;
default:
break;
}
tessellator.startDrawingQuads();
@@ -112,30 +108,29 @@ public class SpatialSkyRender extends IRenderHandler
tessellator.addVertexWithUV( 100.0D, -100.0D, 100.0D, 16.0D, 16.0D );
tessellator.addVertexWithUV( 100.0D, -100.0D, -100.0D, 16.0D, 0.0D );
tessellator.draw();
GL11.glPopMatrix();
}
GL11.glDepthMask( true );
if( fade > 0.0f )
{
GL11.glDisable( GL11.GL_FOG );
GL11.glDisable( GL11.GL_ALPHA_TEST );
GL11.glEnable( GL11.GL_BLEND );
GL11.glDepthMask( false );
GL11.glEnable( GL11.GL_FOG );
GL11.glDisable( GL11.GL_FOG );
GL11.glDisable( GL11.GL_ALPHA_TEST );
GL11.glDisable( GL11.GL_TEXTURE_2D );
OpenGlHelper.glBlendFunc( 770, 771, 1, 0 );
RenderHelper.disableStandardItemLighting();
GL11.glDepthMask( false );
GL11.glEnable( GL11.GL_TEXTURE_2D );
GL11.glColor4f( fade, fade, fade, 1.0f );
GL11.glCallList( this.dspList );
RenderHelper.enableStandardItemLighting();
}
GL11.glPopAttrib();
GL11.glEnable( GL11.GL_FOG );
GL11.glEnable( GL11.GL_ALPHA_TEST );
GL11.glEnable( GL11.GL_BLEND );
GL11.glDepthMask( true );
GL11.glColor4f( 1.0f, 1.0f, 1.0f, 1.0f );
}
@@ -159,6 +154,7 @@ public class SpatialSkyRender extends IRenderHandler
iX *= dist;
iY *= dist;
iZ *= dist;
final double x = iX * 100.0D;
final double y = iY * 100.0D;
final double z = iZ * 100.0D;
@@ -183,6 +179,7 @@ public class SpatialSkyRender extends IRenderHandler
final double d23 = d17 * d12 - d20 * d13;
final double d24 = d23 * d9 - d21 * d10;
final double d25 = d21 * d9 + d23 * d10;
tessellator.addVertex( x + d24, y + d22, z + d25 );
}
}