107 lines
2.0 KiB
Java
107 lines
2.0 KiB
Java
package shootergame.util.gl;
|
|
|
|
import static org.lwjgl.opengl.GL33.*;
|
|
|
|
import shootergame.Main;
|
|
|
|
public class GlHelpers
|
|
{
|
|
private static int MATRIX_COUNT = 0;
|
|
|
|
public static void checkMatrixCount() {
|
|
if(MATRIX_COUNT != 0) {
|
|
MATRIX_COUNT = 0;
|
|
System.err.println("Matrix count is unbalanced!");
|
|
}
|
|
}
|
|
|
|
public static void begin() {
|
|
glBegin(GL_QUADS);
|
|
}
|
|
|
|
public static void end() {
|
|
glEnd();
|
|
}
|
|
|
|
public static void vertex3(double x, double y, double z) {
|
|
glVertex3d(x/10, y/10, z/10);
|
|
}
|
|
|
|
public static void vertex2(double x, double y) {
|
|
int w = Main.window.getWidth();
|
|
int h = Main.window.getHeight();
|
|
double aspect_ratio = ((double)w) / ((double)h);
|
|
glVertex2d(x/10/aspect_ratio, y/10);
|
|
}
|
|
|
|
public static void color3(double r, double g, double b) {
|
|
glColor3d(r, g, b);
|
|
}
|
|
|
|
public static void color4(double r, double g, double b, double a) {
|
|
glColor4d(r, g, b, a);
|
|
}
|
|
|
|
public static void rotate(double a, double x, double y, double z) {
|
|
glRotated(a, x, y, z);
|
|
}
|
|
|
|
public static void translate3(double x, double y, double z) {
|
|
glTranslated(x/10, y/10, z/10);
|
|
}
|
|
|
|
public static void translate2(double x, double y) {
|
|
glTranslated(x/10, y/10, 0);
|
|
}
|
|
|
|
public static void disableCullFace() {
|
|
glDisable(GL_CULL_FACE);
|
|
}
|
|
|
|
public static void enableCullFace() {
|
|
glEnable(GL_CULL_FACE);
|
|
}
|
|
|
|
public static void disableDepthTest() {
|
|
glDisable(GL_DEPTH_TEST);
|
|
}
|
|
|
|
public static void enableDepthTest() {
|
|
glEnable(GL_DEPTH_TEST);
|
|
}
|
|
|
|
public static void disableTexture2d() {
|
|
glDisable(GL_TEXTURE_2D);
|
|
}
|
|
|
|
public static void enableTexture2d() {
|
|
glEnable(GL_TEXTURE_2D);
|
|
}
|
|
|
|
public static void disableAlpha() {
|
|
glDisable(GL_ALPHA);
|
|
}
|
|
|
|
public static void enableAlpha() {
|
|
glEnable(GL_ALPHA);
|
|
}
|
|
|
|
public static void disableBlend() {
|
|
glDisable(GL_BLEND);
|
|
}
|
|
|
|
public static void enableBlend() {
|
|
glEnable(GL_BLEND);
|
|
}
|
|
|
|
public static void popMatrix() {
|
|
glPopMatrix();
|
|
MATRIX_COUNT += 1;
|
|
}
|
|
|
|
public static void pushMatrix() {
|
|
glPushMatrix();
|
|
MATRIX_COUNT -= 1;
|
|
}
|
|
}
|