Attempt to allocate a 8-bit stencil buffer when creating Minecraft's display context. If that throws an error it will revert back to it's default values.

Also contains a method for modders to rereive how many bits the context was created with. Closes #552
This commit is contained in:
LexManos committed 2013-05-08 17:13:19 -07:00
1 parent 2b7cd66f9a
commit ec755e09d0
3 files changed
+45 -10

No files matched your search

@@ -4,8 +4,11 @@ import java.util.HashMap;
import java.util.Random;
import java.util.TreeSet;
import org.lwjgl.LWJGLException;
import org.lwjgl.opengl.Display;
import org.lwjgl.opengl.GL11;
import org.lwjgl.opengl.GL12;
import org.lwjgl.opengl.PixelFormat;
import cpw.mods.fml.client.FMLClientHandler;
@@ -284,4 +287,21 @@ public class ForgeHooksClient
ModelBiped modelbiped = itemStack.getItem().getArmorModel(entityLiving, itemStack, slotID);
return modelbiped == null ? _default : modelbiped;
}
static int stencilBits = 0;
public static void createDisplay() throws LWJGLException
{
PixelFormat format = new PixelFormat().withDepthBits(24);
try
{
//TODO: Figure out how to determine the max bits.
Display.create(format.withStencilBits(8));
stencilBits = 8;
}
catch(LWJGLException e)
{
Display.create(format);
stencilBits = 0;
}
}
}
@@ -56,4 +56,9 @@ public class MinecraftForgeClient
{
return ForgeHooksClient.renderPass;
}
public int getStencilBits()
{
return ForgeHooksClient.stencilBits;
}
}
@@ -1,9 +1,10 @@
--- ../src_base/minecraft/net/minecraft/client/Minecraft.java
+++ ../src_work/minecraft/net/minecraft/client/Minecraft.java
@@ -123,6 +123,13 @@
@@ -123,6 +123,14 @@
import com.google.common.collect.MapDifference;
+import net.minecraftforge.client.ForgeHooksClient;
+import net.minecraftforge.client.GuiIngameForge;
+import net.minecraftforge.common.ForgeHooks;
+import net.minecraftforge.common.MinecraftForge;
@@ -14,7 +15,16 @@
@SideOnly(Side.CLIENT)
public abstract class Minecraft implements Runnable, IPlayerUsage
{
@@ -450,7 +457,7 @@
@@ -372,7 +380,7 @@
try
{
- Display.create((new PixelFormat()).withDepthBits(24));
+ ForgeHooksClient.createDisplay();
}
catch (LWJGLException lwjglexception)
{
@@ -450,7 +458,7 @@
}
this.checkGLError("Post startup");
@@ -23,7 +33,7 @@
if (this.serverName != null)
{
@@ -1238,7 +1245,7 @@
@@ -1238,7 +1246,7 @@
if (this.thePlayer.canCurrentToolHarvestBlock(j, k, l))
{
@@ -32,7 +42,7 @@
this.thePlayer.swingItem();
}
}
@@ -1304,7 +1311,8 @@
@@ -1304,7 +1312,8 @@
{
int j1 = itemstack != null ? itemstack.stackSize : 0;
@@ -42,7 +52,7 @@
{
flag = false;
this.thePlayer.swingItem();
@@ -1330,7 +1338,8 @@
@@ -1330,7 +1339,8 @@
{
ItemStack itemstack1 = this.thePlayer.inventory.getCurrentItem();
@@ -52,7 +62,7 @@
{
this.entityRenderer.itemRenderer.resetEquippedProgress2();
}
@@ -2010,6 +2019,11 @@
@@ -2010,6 +2020,11 @@
{
this.statFileWriter.syncStats();
@@ -64,7 +74,7 @@
if (par1WorldClient == null)
{
NetClientHandler netclienthandler = this.getNetHandler();
@@ -2027,6 +2041,18 @@
@@ -2027,6 +2042,18 @@
if (this.theIntegratedServer != null)
{
this.theIntegratedServer.initiateShutdown();
@@ -83,7 +93,7 @@
}
this.theIntegratedServer = null;
@@ -2354,103 +2380,12 @@
@@ -2354,103 +2381,12 @@
if (this.objectMouseOver != null)
{
boolean flag = this.thePlayer.capabilities.isCreativeMode;
@@ -191,7 +201,7 @@
if (flag)
{
@@ -2539,11 +2474,18 @@
@@ -2539,11 +2475,18 @@
par1PlayerUsageSnooper.addData("gl_max_texture_size", Integer.valueOf(getGLMaximumTextureSize()));
}
@@ -210,7 +220,7 @@
for (int i = 16384; i > 0; i >>= 1)
{
GL11.glTexImage2D(GL11.GL_PROXY_TEXTURE_2D, 0, GL11.GL_RGBA, i, i, 0, GL11.GL_RGBA, GL11.GL_UNSIGNED_BYTE, (ByteBuffer)null);
@@ -2551,6 +2493,7 @@
@@ -2551,6 +2494,7 @@
if (j != 0)
{