mirror of
https://github.com/MinecraftForge/MinecraftForge.git
synced 2026-11-20 12:20:11 +00:00
Add in a very simple stencil bit registry to try and arbitrate between mods wanting to use stencil bits in rendering
This commit is contained in:
1 parent
2a86167c98
commit
5ca854efa8
1 file changed
+37
@@ -5,6 +5,8 @@
|
||||
|
||||
package net.minecraftforge.client;
|
||||
|
||||
import java.util.BitSet;
|
||||
|
||||
import org.lwjgl.opengl.Display;
|
||||
|
||||
import net.minecraft.block.Block;
|
||||
@@ -61,4 +63,39 @@ public class MinecraftForgeClient
|
||||
{
|
||||
return ForgeHooksClient.stencilBits;
|
||||
}
|
||||
|
||||
|
||||
private static BitSet stencilBits = new BitSet(getStencilBits());
|
||||
static
|
||||
{
|
||||
stencilBits.set(0,getStencilBits());
|
||||
}
|
||||
|
||||
/**
|
||||
* Reserve a stencil bit for use in rendering
|
||||
*
|
||||
* @return A bit or -1 if no further stencil bits are available
|
||||
*/
|
||||
public static int reserveStencilBit()
|
||||
{
|
||||
int bit = stencilBits.nextSetBit(0);
|
||||
if (bit >= 0)
|
||||
{
|
||||
stencilBits.clear(bit);
|
||||
}
|
||||
return bit;
|
||||
}
|
||||
|
||||
/**
|
||||
* Release the stencil bit for other use
|
||||
*
|
||||
* @param bit The bit from {@link #reserveStencilBit()}
|
||||
*/
|
||||
public static void releaseStencilBit(int bit)
|
||||
{
|
||||
if (bit >= 0 && bit < getStencilBits())
|
||||
{
|
||||
stencilBits.set(bit);
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user