Skip to content

Commit

Permalink
Add in a very simple stencil bit registry to try and arbitrate betwee…
Browse files Browse the repository at this point in the history
…n mods wanting to use stencil bits in rendering
  • Loading branch information
cpw committed May 16, 2013
1 parent 2a86167 commit 5ca854e
Showing 1 changed file with 37 additions and 0 deletions.
37 changes: 37 additions & 0 deletions client/net/minecraftforge/client/MinecraftForgeClient.java
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@

package net.minecraftforge.client;

import java.util.BitSet;

import org.lwjgl.opengl.Display;

import net.minecraft.block.Block;
Expand Down Expand Up @@ -61,4 +63,39 @@ public static int getStencilBits()
{
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);
}
}
}

0 comments on commit 5ca854e

Please sign in to comment.