com.github.mathiewz.slick.util.MaskUtil Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of modernized-slick Show documentation
Show all versions of modernized-slick Show documentation
The main purpose of this libraryis to modernize and maintain the slick2D library.
The newest version!
package com.github.mathiewz.slick.util;
import org.lwjgl.opengl.GL11;
import com.github.mathiewz.slick.opengl.renderer.Renderer;
import com.github.mathiewz.slick.opengl.renderer.SGL;
/**
* A utility to provide full screen masking
*
* @author kevin
*/
public class MaskUtil {
/** The renderer to use for all GL operations */
protected static SGL GL = Renderer.get();
/**
* Start defining the screen mask. After calling this use graphics functions to
* mask out the area
*/
public static void defineMask() {
GL.glDepthMask(true);
GL.glClearDepth(1);
GL.glClear(GL11.GL_DEPTH_BUFFER_BIT);
GL.glDepthFunc(GL11.GL_ALWAYS);
GL.glEnable(GL11.GL_DEPTH_TEST);
GL.glDepthMask(true);
GL.glColorMask(false, false, false, false);
}
/**
* Finish defining the screen mask
*/
public static void finishDefineMask() {
GL.glDepthMask(false);
GL.glColorMask(true, true, true, true);
}
/**
* Start drawing only on the masked area
*/
public static void drawOnMask() {
GL.glDepthFunc(GL11.GL_EQUAL);
}
/**
* Start drawing only off the masked area
*/
public static void drawOffMask() {
GL.glDepthFunc(GL11.GL_NOTEQUAL);
}
/**
* Reset the masked area - should be done after you've finished rendering
*/
public static void resetMask() {
GL.glDepthMask(true);
GL.glClearDepth(0);
GL.glClear(GL11.GL_DEPTH_BUFFER_BIT);
GL.glDepthMask(false);
GL.glDisable(GL11.GL_DEPTH_TEST);
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy