Merge branch 'GenuineSounds-patch-2' - fix the renderer for bad GL implementations
This commit is contained in:
commit
887ac8a216
|
@ -10,7 +10,7 @@
|
||||||
******************************************************************************/
|
******************************************************************************/
|
||||||
package cpw.mods.ironchest.client;
|
package cpw.mods.ironchest.client;
|
||||||
|
|
||||||
import static org.lwjgl.opengl.GL11.GL_COMPILE;
|
import static org.lwjgl.opengl.GL11.GL_COMPILE_AND_EXECUTE;
|
||||||
import static org.lwjgl.opengl.GL11.glColor4f;
|
import static org.lwjgl.opengl.GL11.glColor4f;
|
||||||
import static org.lwjgl.opengl.GL11.glDisable;
|
import static org.lwjgl.opengl.GL11.glDisable;
|
||||||
import static org.lwjgl.opengl.GL11.glEnable;
|
import static org.lwjgl.opengl.GL11.glEnable;
|
||||||
|
@ -45,11 +45,14 @@ import cpw.mods.ironchest.TileEntityIronChest;
|
||||||
|
|
||||||
public class TileEntityIronChestRenderer extends TileEntitySpecialRenderer {
|
public class TileEntityIronChestRenderer extends TileEntitySpecialRenderer {
|
||||||
private static Map<ItemStack, Integer> renderList = new HashMap<ItemStack, Integer>();
|
private static Map<ItemStack, Integer> renderList = new HashMap<ItemStack, Integer>();
|
||||||
|
|
||||||
private Random random;
|
private Random random;
|
||||||
|
|
||||||
private RenderBlocks renderBlocks;
|
private RenderBlocks renderBlocks;
|
||||||
|
|
||||||
private static float[][] shifts = { { 0.3F, 0.45F, 0.3F }, { 0.7F, 0.45F, 0.3F }, { 0.3F, 0.45F, 0.7F }, { 0.7F, 0.45F, 0.7F },
|
private static float[][] shifts = { { 0.3F, 0.45F, 0.3F }, { 0.7F, 0.45F, 0.3F }, { 0.3F, 0.45F, 0.7F }, { 0.7F, 0.45F, 0.7F }, { 0.3F, 0.1F, 0.3F }, { 0.7F, 0.1F, 0.3F }, { 0.3F, 0.1F, 0.7F }, { 0.7F, 0.1F, 0.7F }, { 0.5F, 0.32F, 0.5F }, };
|
||||||
{ 0.3F, 0.1F, 0.3F }, { 0.7F, 0.1F, 0.3F }, { 0.3F, 0.1F, 0.7F }, { 0.7F, 0.1F, 0.7F }, { 0.5F, 0.32F, 0.5F }, };
|
|
||||||
|
public static boolean CACHE_RENDER = true;
|
||||||
|
|
||||||
public TileEntityIronChestRenderer() {
|
public TileEntityIronChestRenderer() {
|
||||||
model = new ModelChest();
|
model = new ModelChest();
|
||||||
|
@ -70,7 +73,6 @@ public class TileEntityIronChestRenderer extends TileEntitySpecialRenderer {
|
||||||
type = IronChestType.values()[typ];
|
type = IronChestType.values()[typ];
|
||||||
}
|
}
|
||||||
bindTextureByName(type.getModelTexture());
|
bindTextureByName(type.getModelTexture());
|
||||||
|
|
||||||
glPushMatrix();
|
glPushMatrix();
|
||||||
glEnable(32826 /* GL_RESCALE_NORMAL_EXT */);
|
glEnable(32826 /* GL_RESCALE_NORMAL_EXT */);
|
||||||
glColor4f(1.0F, 1.0F, 1.0F, 1.0F);
|
glColor4f(1.0F, 1.0F, 1.0F, 1.0F);
|
||||||
|
@ -101,7 +103,6 @@ public class TileEntityIronChestRenderer extends TileEntitySpecialRenderer {
|
||||||
glDisable(32826 /* GL_RESCALE_NORMAL_EXT */);
|
glDisable(32826 /* GL_RESCALE_NORMAL_EXT */);
|
||||||
glPopMatrix();
|
glPopMatrix();
|
||||||
glColor4f(1.0F, 1.0F, 1.0F, 1.0F);
|
glColor4f(1.0F, 1.0F, 1.0F, 1.0F);
|
||||||
|
|
||||||
if (type.isTransparent()) {
|
if (type.isTransparent()) {
|
||||||
random.setSeed(254L);
|
random.setSeed(254L);
|
||||||
float shiftX;
|
float shiftX;
|
||||||
|
@ -153,11 +154,12 @@ public class TileEntityIronChestRenderer extends TileEntitySpecialRenderer {
|
||||||
float minishiftZ = ((random.nextFloat() * 2.0F - 1.0F) * spread) / localScale;
|
float minishiftZ = ((random.nextFloat() * 2.0F - 1.0F) * spread) / localScale;
|
||||||
glTranslatef(minishiftX, minishiftY, minishiftZ);
|
glTranslatef(minishiftX, minishiftY, minishiftZ);
|
||||||
}
|
}
|
||||||
|
if (renderList.get(item) == null || !CACHE_RENDER) { // Added support for using only old system.
|
||||||
if (renderList.get(item) == null) {
|
if (CACHE_RENDER) {
|
||||||
int render = glGenLists(1);
|
int render = glGenLists(1);
|
||||||
renderList.put(item, render);
|
renderList.put(item, render);
|
||||||
glNewList(render, GL_COMPILE);
|
glNewList(render, GL_COMPILE_AND_EXECUTE);
|
||||||
|
}
|
||||||
if (customRenderer != null) {
|
if (customRenderer != null) {
|
||||||
customitem.item = item;
|
customitem.item = item;
|
||||||
bindTextureByName("/terrain.png");
|
bindTextureByName("/terrain.png");
|
||||||
|
@ -200,10 +202,13 @@ public class TileEntityIronChestRenderer extends TileEntitySpecialRenderer {
|
||||||
tessellator.addVertexWithUV(0.0F - f14, 1.0F - f15, 0.0D, f5, f10);
|
tessellator.addVertexWithUV(0.0F - f14, 1.0F - f15, 0.0D, f5, f10);
|
||||||
tessellator.draw();
|
tessellator.draw();
|
||||||
}
|
}
|
||||||
} else {
|
if (CACHE_RENDER)
|
||||||
glCallList(renderList.get(item));
|
|
||||||
}
|
|
||||||
glEndList();
|
glEndList();
|
||||||
|
} else {
|
||||||
|
Integer integer = renderList.get(item);
|
||||||
|
if (integer != null) // Added null check for auto-unboxing JUST in case.
|
||||||
|
glCallList(integer.intValue());
|
||||||
|
}
|
||||||
glPopMatrix();
|
glPopMatrix();
|
||||||
}
|
}
|
||||||
glPopMatrix();
|
glPopMatrix();
|
||||||
|
|
Loading…
Reference in New Issue