974 lines
39 KiB
Java
974 lines
39 KiB
Java
package game.window;
|
|
|
|
import static org.lwjgl.glfw.GLFW.*;
|
|
import static org.lwjgl.glfw.Callbacks.*;
|
|
import static org.lwjgl.system.MemoryUtil.*;
|
|
import java.util.ArrayList;
|
|
import java.util.List;
|
|
import java.util.Map;
|
|
|
|
import org.lwjgl.BufferUtils;
|
|
import org.lwjgl.Version;
|
|
import org.lwjgl.glfw.GLFW;
|
|
import org.lwjgl.glfw.GLFWCharCallback;
|
|
import org.lwjgl.glfw.GLFWCursorPosCallback;
|
|
import org.lwjgl.glfw.GLFWErrorCallback;
|
|
import org.lwjgl.glfw.GLFWFramebufferSizeCallback;
|
|
import org.lwjgl.glfw.GLFWImage;
|
|
import org.lwjgl.glfw.GLFWKeyCallback;
|
|
import org.lwjgl.glfw.GLFWMouseButtonCallback;
|
|
import org.lwjgl.glfw.GLFWScrollCallback;
|
|
import org.lwjgl.glfw.GLFWVidMode;
|
|
import org.lwjgl.glfw.GLFWWindowCloseCallback;
|
|
import org.lwjgl.glfw.GLFWWindowFocusCallback;
|
|
import org.lwjgl.glfw.GLFWWindowPosCallback;
|
|
import org.lwjgl.glfw.GLFWWindowRefreshCallback;
|
|
import org.lwjgl.opengl.GL;
|
|
import org.lwjgl.opengl.GL11;
|
|
import org.lwjgl.opengl.GL13;
|
|
import org.lwjgl.opengl.GL14;
|
|
import org.lwjgl.opengl.GL15;
|
|
import org.lwjgl.system.APIUtil;
|
|
|
|
import game.log.Log;
|
|
|
|
public abstract class WCF {
|
|
public static final int GL_EXP = 0x800;
|
|
public static final int GL_LIGHT_MODEL_AMBIENT = 0xB53;
|
|
public static final int GL_COLOR_MATERIAL = 0xB57;
|
|
public static final int GL_FOG = 0xB60;
|
|
public static final int GL_FOG_DENSITY = 0xB62;
|
|
public static final int GL_FOG_START = 0xB63;
|
|
public static final int GL_FOG_END = 0xB64;
|
|
public static final int GL_FOG_MODE = 0xB65;
|
|
public static final int GL_FOG_COLOR = 0xB66;
|
|
public static final int GL_LIGHT0 = 0x4000;
|
|
public static final int GL_LIGHT1 = 0x4001;
|
|
public static final int GL_AMBIENT = 0x1200;
|
|
public static final int GL_DIFFUSE = 0x1201;
|
|
public static final int GL_SPECULAR = 0x1202;
|
|
public static final int GL_POSITION = 0x1203;
|
|
public static final int GL_COMPILE = 0x1300;
|
|
public static final int GL_AMBIENT_AND_DIFFUSE = 0x1602;
|
|
public static final int GL_MODELVIEW = 0x1700;
|
|
public static final int GL_PROJECTION = 0x1701;
|
|
public static final int GL_CLAMP = 0x2900;
|
|
public static final int GL_VERTEX_ARRAY = 0x8074;
|
|
public static final int GL_NORMAL_ARRAY = 0x8075;
|
|
public static final int GL_COLOR_ARRAY = 0x8076;
|
|
public static final int GL_TEXTURE_COORD_ARRAY = 0x8078;
|
|
|
|
public static final int GL_DEPTH_BUFFER_BIT = 0x00000100;
|
|
public static final int GL_STENCIL_BUFFER_BIT = 0x00000400;
|
|
public static final int GL_COLOR_BUFFER_BIT = 0x00004000;
|
|
public static final int GL_FALSE = 0;
|
|
public static final int GL_TRUE = 1;
|
|
public static final int GL_POINTS = 0x0000;
|
|
public static final int GL_LINES = 0x0001;
|
|
public static final int GL_LINE_LOOP = 0x0002;
|
|
public static final int GL_LINE_STRIP = 0x0003;
|
|
public static final int GL_TRIANGLES = 0x0004;
|
|
public static final int GL_TRIANGLE_STRIP = 0x0005;
|
|
public static final int GL_TRIANGLE_FAN = 0x0006;
|
|
public static final int GL_NEVER = 0x0200;
|
|
public static final int GL_LESS = 0x0201;
|
|
public static final int GL_EQUAL = 0x0202;
|
|
public static final int GL_LEQUAL = 0x0203;
|
|
public static final int GL_GREATER = 0x0204;
|
|
public static final int GL_NOTEQUAL = 0x0205;
|
|
public static final int GL_GEQUAL = 0x0206;
|
|
public static final int GL_ALWAYS = 0x0207;
|
|
public static final int GL_ZERO = 0;
|
|
public static final int GL_ONE = 1;
|
|
public static final int GL_SRC_COLOR = 0x0300;
|
|
public static final int GL_ONE_MINUS_SRC_COLOR = 0x0301;
|
|
public static final int GL_SRC_ALPHA = 0x0302;
|
|
public static final int GL_ONE_MINUS_SRC_ALPHA = 0x0303;
|
|
public static final int GL_DST_ALPHA = 0x0304;
|
|
public static final int GL_ONE_MINUS_DST_ALPHA = 0x0305;
|
|
public static final int GL_DST_COLOR = 0x0306;
|
|
public static final int GL_ONE_MINUS_DST_COLOR = 0x0307;
|
|
public static final int GL_SRC_ALPHA_SATURATE = 0x0308;
|
|
public static final int GL_NONE = 0;
|
|
public static final int GL_FRONT_LEFT = 0x0400;
|
|
public static final int GL_FRONT_RIGHT = 0x0401;
|
|
public static final int GL_BACK_LEFT = 0x0402;
|
|
public static final int GL_BACK_RIGHT = 0x0403;
|
|
public static final int GL_FRONT = 0x0404;
|
|
public static final int GL_BACK = 0x0405;
|
|
public static final int GL_LEFT = 0x0406;
|
|
public static final int GL_RIGHT = 0x0407;
|
|
public static final int GL_FRONT_AND_BACK = 0x0408;
|
|
public static final int GL_NO_ERROR = 0;
|
|
public static final int GL_INVALID_ENUM = 0x0500;
|
|
public static final int GL_INVALID_VALUE = 0x0501;
|
|
public static final int GL_INVALID_OPERATION = 0x0502;
|
|
public static final int GL_OUT_OF_MEMORY = 0x0505;
|
|
public static final int GL_CW = 0x0900;
|
|
public static final int GL_CCW = 0x0901;
|
|
public static final int GL_POINT_SIZE = 0x0B11;
|
|
public static final int GL_POINT_SIZE_RANGE = 0x0B12;
|
|
public static final int GL_POINT_SIZE_GRANULARITY = 0x0B13;
|
|
public static final int GL_LINE_SMOOTH = 0x0B20;
|
|
public static final int GL_LINE_WIDTH = 0x0B21;
|
|
public static final int GL_LINE_WIDTH_RANGE = 0x0B22;
|
|
public static final int GL_LINE_WIDTH_GRANULARITY = 0x0B23;
|
|
public static final int GL_POLYGON_MODE = 0x0B40;
|
|
public static final int GL_POLYGON_SMOOTH = 0x0B41;
|
|
public static final int GL_CULL_FACE = 0x0B44;
|
|
public static final int GL_CULL_FACE_MODE = 0x0B45;
|
|
public static final int GL_FRONT_FACE = 0x0B46;
|
|
public static final int GL_DEPTH_RANGE = 0x0B70;
|
|
public static final int GL_DEPTH_TEST = 0x0B71;
|
|
public static final int GL_DEPTH_WRITEMASK = 0x0B72;
|
|
public static final int GL_DEPTH_CLEAR_VALUE = 0x0B73;
|
|
public static final int GL_DEPTH_FUNC = 0x0B74;
|
|
public static final int GL_STENCIL_TEST = 0x0B90;
|
|
public static final int GL_STENCIL_CLEAR_VALUE = 0x0B91;
|
|
public static final int GL_STENCIL_FUNC = 0x0B92;
|
|
public static final int GL_STENCIL_VALUE_MASK = 0x0B93;
|
|
public static final int GL_STENCIL_FAIL = 0x0B94;
|
|
public static final int GL_STENCIL_PASS_DEPTH_FAIL = 0x0B95;
|
|
public static final int GL_STENCIL_PASS_DEPTH_PASS = 0x0B96;
|
|
public static final int GL_STENCIL_REF = 0x0B97;
|
|
public static final int GL_STENCIL_WRITEMASK = 0x0B98;
|
|
public static final int GL_VIEWPORT = 0x0BA2;
|
|
public static final int GL_DITHER = 0x0BD0;
|
|
public static final int GL_BLEND_DST = 0x0BE0;
|
|
public static final int GL_BLEND_SRC = 0x0BE1;
|
|
public static final int GL_BLEND = 0x0BE2;
|
|
public static final int GL_LOGIC_OP_MODE = 0x0BF0;
|
|
public static final int GL_DRAW_BUFFER = 0x0C01;
|
|
public static final int GL_READ_BUFFER = 0x0C02;
|
|
public static final int GL_SCISSOR_BOX = 0x0C10;
|
|
public static final int GL_SCISSOR_TEST = 0x0C11;
|
|
public static final int GL_COLOR_CLEAR_VALUE = 0x0C22;
|
|
public static final int GL_COLOR_WRITEMASK = 0x0C23;
|
|
public static final int GL_DOUBLEBUFFER = 0x0C32;
|
|
public static final int GL_STEREO = 0x0C33;
|
|
public static final int GL_LINE_SMOOTH_HINT = 0x0C52;
|
|
public static final int GL_POLYGON_SMOOTH_HINT = 0x0C53;
|
|
public static final int GL_UNPACK_SWAP_BYTES = 0x0CF0;
|
|
public static final int GL_UNPACK_LSB_FIRST = 0x0CF1;
|
|
public static final int GL_UNPACK_ROW_LENGTH = 0x0CF2;
|
|
public static final int GL_UNPACK_SKIP_ROWS = 0x0CF3;
|
|
public static final int GL_UNPACK_SKIP_PIXELS = 0x0CF4;
|
|
public static final int GL_UNPACK_ALIGNMENT = 0x0CF5;
|
|
public static final int GL_PACK_SWAP_BYTES = 0x0D00;
|
|
public static final int GL_PACK_LSB_FIRST = 0x0D01;
|
|
public static final int GL_PACK_ROW_LENGTH = 0x0D02;
|
|
public static final int GL_PACK_SKIP_ROWS = 0x0D03;
|
|
public static final int GL_PACK_SKIP_PIXELS = 0x0D04;
|
|
public static final int GL_PACK_ALIGNMENT = 0x0D05;
|
|
public static final int GL_MAX_TEXTURE_SIZE = 0x0D33;
|
|
public static final int GL_MAX_VIEWPORT_DIMS = 0x0D3A;
|
|
public static final int GL_SUBPIXEL_BITS = 0x0D50;
|
|
public static final int GL_TEXTURE_1D = 0x0DE0;
|
|
public static final int GL_TEXTURE_2D = 0x0DE1;
|
|
public static final int GL_TEXTURE_WIDTH = 0x1000;
|
|
public static final int GL_TEXTURE_HEIGHT = 0x1001;
|
|
public static final int GL_TEXTURE_BORDER_COLOR = 0x1004;
|
|
public static final int GL_DONT_CARE = 0x1100;
|
|
public static final int GL_FASTEST = 0x1101;
|
|
public static final int GL_NICEST = 0x1102;
|
|
public static final int GL_BYTE = 0x1400;
|
|
public static final int GL_UNSIGNED_BYTE = 0x1401;
|
|
public static final int GL_SHORT = 0x1402;
|
|
public static final int GL_UNSIGNED_SHORT = 0x1403;
|
|
public static final int GL_INT = 0x1404;
|
|
public static final int GL_UNSIGNED_INT = 0x1405;
|
|
public static final int GL_FLOAT = 0x1406;
|
|
public static final int GL_CLEAR = 0x1500;
|
|
public static final int GL_AND = 0x1501;
|
|
public static final int GL_AND_REVERSE = 0x1502;
|
|
public static final int GL_COPY = 0x1503;
|
|
public static final int GL_AND_INVERTED = 0x1504;
|
|
public static final int GL_NOOP = 0x1505;
|
|
public static final int GL_XOR = 0x1506;
|
|
public static final int GL_OR = 0x1507;
|
|
public static final int GL_NOR = 0x1508;
|
|
public static final int GL_EQUIV = 0x1509;
|
|
public static final int GL_INVERT = 0x150A;
|
|
public static final int GL_OR_REVERSE = 0x150B;
|
|
public static final int GL_COPY_INVERTED = 0x150C;
|
|
public static final int GL_OR_INVERTED = 0x150D;
|
|
public static final int GL_NAND = 0x150E;
|
|
public static final int GL_SET = 0x150F;
|
|
public static final int GL_TEXTURE = 0x1702;
|
|
public static final int GL_COLOR = 0x1800;
|
|
public static final int GL_DEPTH = 0x1801;
|
|
public static final int GL_STENCIL = 0x1802;
|
|
public static final int GL_STENCIL_INDEX = 0x1901;
|
|
public static final int GL_DEPTH_COMPONENT = 0x1902;
|
|
public static final int GL_RED = 0x1903;
|
|
public static final int GL_GREEN = 0x1904;
|
|
public static final int GL_BLUE = 0x1905;
|
|
public static final int GL_ALPHA = 0x1906;
|
|
public static final int GL_RGB = 0x1907;
|
|
public static final int GL_RGBA = 0x1908;
|
|
public static final int GL_POINT = 0x1B00;
|
|
public static final int GL_LINE = 0x1B01;
|
|
public static final int GL_FILL = 0x1B02;
|
|
public static final int GL_KEEP = 0x1E00;
|
|
public static final int GL_REPLACE = 0x1E01;
|
|
public static final int GL_INCR = 0x1E02;
|
|
public static final int GL_DECR = 0x1E03;
|
|
public static final int GL_VENDOR = 0x1F00;
|
|
public static final int GL_RENDERER = 0x1F01;
|
|
public static final int GL_VERSION = 0x1F02;
|
|
public static final int GL_EXTENSIONS = 0x1F03;
|
|
public static final int GL_NEAREST = 0x2600;
|
|
public static final int GL_LINEAR = 0x2601;
|
|
public static final int GL_NEAREST_MIPMAP_NEAREST = 0x2700;
|
|
public static final int GL_LINEAR_MIPMAP_NEAREST = 0x2701;
|
|
public static final int GL_NEAREST_MIPMAP_LINEAR = 0x2702;
|
|
public static final int GL_LINEAR_MIPMAP_LINEAR = 0x2703;
|
|
public static final int GL_TEXTURE_MAG_FILTER = 0x2800;
|
|
public static final int GL_TEXTURE_MIN_FILTER = 0x2801;
|
|
public static final int GL_TEXTURE_WRAP_S = 0x2802;
|
|
public static final int GL_TEXTURE_WRAP_T = 0x2803;
|
|
public static final int GL_REPEAT = 0x2901;
|
|
public static final int GL_COLOR_LOGIC_OP = 0x0BF2;
|
|
public static final int GL_POLYGON_OFFSET_UNITS = 0x2A00;
|
|
public static final int GL_POLYGON_OFFSET_POINT = 0x2A01;
|
|
public static final int GL_POLYGON_OFFSET_LINE = 0x2A02;
|
|
public static final int GL_POLYGON_OFFSET_FILL = 0x8037;
|
|
public static final int GL_POLYGON_OFFSET_FACTOR = 0x8038;
|
|
public static final int GL_TEXTURE_BINDING_1D = 0x8068;
|
|
public static final int GL_TEXTURE_BINDING_2D = 0x8069;
|
|
public static final int GL_TEXTURE_INTERNAL_FORMAT = 0x1003;
|
|
public static final int GL_TEXTURE_RED_SIZE = 0x805C;
|
|
public static final int GL_TEXTURE_GREEN_SIZE = 0x805D;
|
|
public static final int GL_TEXTURE_BLUE_SIZE = 0x805E;
|
|
public static final int GL_TEXTURE_ALPHA_SIZE = 0x805F;
|
|
public static final int GL_DOUBLE = 0x140A;
|
|
public static final int GL_PROXY_TEXTURE_1D = 0x8063;
|
|
public static final int GL_PROXY_TEXTURE_2D = 0x8064;
|
|
public static final int GL_R3_G3_B2 = 0x2A10;
|
|
public static final int GL_RGB4 = 0x804F;
|
|
public static final int GL_RGB5 = 0x8050;
|
|
public static final int GL_RGB8 = 0x8051;
|
|
public static final int GL_RGB10 = 0x8052;
|
|
public static final int GL_RGB12 = 0x8053;
|
|
public static final int GL_RGB16 = 0x8054;
|
|
public static final int GL_RGBA2 = 0x8055;
|
|
public static final int GL_RGBA4 = 0x8056;
|
|
public static final int GL_RGB5_A1 = 0x8057;
|
|
public static final int GL_RGBA8 = 0x8058;
|
|
public static final int GL_RGB10_A2 = 0x8059;
|
|
public static final int GL_RGBA12 = 0x805A;
|
|
public static final int GL_RGBA16 = 0x805B;
|
|
public static final int GL_UNSIGNED_BYTE_3_3_2 = 0x8032;
|
|
public static final int GL_UNSIGNED_SHORT_4_4_4_4 = 0x8033;
|
|
public static final int GL_UNSIGNED_SHORT_5_5_5_1 = 0x8034;
|
|
public static final int GL_UNSIGNED_INT_8_8_8_8 = 0x8035;
|
|
public static final int GL_UNSIGNED_INT_10_10_10_2 = 0x8036;
|
|
public static final int GL_TEXTURE_BINDING_3D = 0x806A;
|
|
public static final int GL_PACK_SKIP_IMAGES = 0x806B;
|
|
public static final int GL_PACK_IMAGE_HEIGHT = 0x806C;
|
|
public static final int GL_UNPACK_SKIP_IMAGES = 0x806D;
|
|
public static final int GL_UNPACK_IMAGE_HEIGHT = 0x806E;
|
|
public static final int GL_TEXTURE_3D = 0x806F;
|
|
public static final int GL_PROXY_TEXTURE_3D = 0x8070;
|
|
public static final int GL_TEXTURE_DEPTH = 0x8071;
|
|
public static final int GL_TEXTURE_WRAP_R = 0x8072;
|
|
public static final int GL_MAX_3D_TEXTURE_SIZE = 0x8073;
|
|
public static final int GL_UNSIGNED_BYTE_2_3_3_REV = 0x8362;
|
|
public static final int GL_UNSIGNED_SHORT_5_6_5 = 0x8363;
|
|
public static final int GL_UNSIGNED_SHORT_5_6_5_REV = 0x8364;
|
|
public static final int GL_UNSIGNED_SHORT_4_4_4_4_REV = 0x8365;
|
|
public static final int GL_UNSIGNED_SHORT_1_5_5_5_REV = 0x8366;
|
|
public static final int GL_UNSIGNED_INT_8_8_8_8_REV = 0x8367;
|
|
public static final int GL_UNSIGNED_INT_2_10_10_10_REV = 0x8368;
|
|
public static final int GL_BGR = 0x80E0;
|
|
public static final int GL_BGRA = 0x80E1;
|
|
public static final int GL_MAX_ELEMENTS_VERTICES = 0x80E8;
|
|
public static final int GL_MAX_ELEMENTS_INDICES = 0x80E9;
|
|
public static final int GL_CLAMP_TO_EDGE = 0x812F;
|
|
public static final int GL_TEXTURE_MIN_LOD = 0x813A;
|
|
public static final int GL_TEXTURE_MAX_LOD = 0x813B;
|
|
public static final int GL_TEXTURE_BASE_LEVEL = 0x813C;
|
|
public static final int GL_TEXTURE_MAX_LEVEL = 0x813D;
|
|
public static final int GL_SMOOTH_POINT_SIZE_RANGE = 0x0B12;
|
|
public static final int GL_SMOOTH_POINT_SIZE_GRANULARITY = 0x0B13;
|
|
public static final int GL_SMOOTH_LINE_WIDTH_RANGE = 0x0B22;
|
|
public static final int GL_SMOOTH_LINE_WIDTH_GRANULARITY = 0x0B23;
|
|
public static final int GL_ALIASED_LINE_WIDTH_RANGE = 0x846E;
|
|
public static final int GL_TEXTURE0 = 0x84C0;
|
|
public static final int GL_TEXTURE1 = 0x84C1;
|
|
public static final int GL_TEXTURE2 = 0x84C2;
|
|
public static final int GL_TEXTURE3 = 0x84C3;
|
|
public static final int GL_TEXTURE4 = 0x84C4;
|
|
public static final int GL_TEXTURE5 = 0x84C5;
|
|
public static final int GL_TEXTURE6 = 0x84C6;
|
|
public static final int GL_TEXTURE7 = 0x84C7;
|
|
public static final int GL_TEXTURE8 = 0x84C8;
|
|
public static final int GL_TEXTURE9 = 0x84C9;
|
|
public static final int GL_TEXTURE10 = 0x84CA;
|
|
public static final int GL_TEXTURE11 = 0x84CB;
|
|
public static final int GL_TEXTURE12 = 0x84CC;
|
|
public static final int GL_TEXTURE13 = 0x84CD;
|
|
public static final int GL_TEXTURE14 = 0x84CE;
|
|
public static final int GL_TEXTURE15 = 0x84CF;
|
|
public static final int GL_TEXTURE16 = 0x84D0;
|
|
public static final int GL_TEXTURE17 = 0x84D1;
|
|
public static final int GL_TEXTURE18 = 0x84D2;
|
|
public static final int GL_TEXTURE19 = 0x84D3;
|
|
public static final int GL_TEXTURE20 = 0x84D4;
|
|
public static final int GL_TEXTURE21 = 0x84D5;
|
|
public static final int GL_TEXTURE22 = 0x84D6;
|
|
public static final int GL_TEXTURE23 = 0x84D7;
|
|
public static final int GL_TEXTURE24 = 0x84D8;
|
|
public static final int GL_TEXTURE25 = 0x84D9;
|
|
public static final int GL_TEXTURE26 = 0x84DA;
|
|
public static final int GL_TEXTURE27 = 0x84DB;
|
|
public static final int GL_TEXTURE28 = 0x84DC;
|
|
public static final int GL_TEXTURE29 = 0x84DD;
|
|
public static final int GL_TEXTURE30 = 0x84DE;
|
|
public static final int GL_TEXTURE31 = 0x84DF;
|
|
public static final int GL_ACTIVE_TEXTURE = 0x84E0;
|
|
public static final int GL_MULTISAMPLE = 0x809D;
|
|
public static final int GL_SAMPLE_ALPHA_TO_COVERAGE = 0x809E;
|
|
public static final int GL_SAMPLE_ALPHA_TO_ONE = 0x809F;
|
|
public static final int GL_SAMPLE_COVERAGE = 0x80A0;
|
|
public static final int GL_SAMPLE_BUFFERS = 0x80A8;
|
|
public static final int GL_SAMPLES = 0x80A9;
|
|
public static final int GL_SAMPLE_COVERAGE_VALUE = 0x80AA;
|
|
public static final int GL_SAMPLE_COVERAGE_INVERT = 0x80AB;
|
|
public static final int GL_TEXTURE_CUBE_MAP = 0x8513;
|
|
public static final int GL_TEXTURE_BINDING_CUBE_MAP = 0x8514;
|
|
public static final int GL_TEXTURE_CUBE_MAP_POSITIVE_X = 0x8515;
|
|
public static final int GL_TEXTURE_CUBE_MAP_NEGATIVE_X = 0x8516;
|
|
public static final int GL_TEXTURE_CUBE_MAP_POSITIVE_Y = 0x8517;
|
|
public static final int GL_TEXTURE_CUBE_MAP_NEGATIVE_Y = 0x8518;
|
|
public static final int GL_TEXTURE_CUBE_MAP_POSITIVE_Z = 0x8519;
|
|
public static final int GL_TEXTURE_CUBE_MAP_NEGATIVE_Z = 0x851A;
|
|
public static final int GL_PROXY_TEXTURE_CUBE_MAP = 0x851B;
|
|
public static final int GL_MAX_CUBE_MAP_TEXTURE_SIZE = 0x851C;
|
|
public static final int GL_COMPRESSED_RGB = 0x84ED;
|
|
public static final int GL_COMPRESSED_RGBA = 0x84EE;
|
|
public static final int GL_TEXTURE_COMPRESSION_HINT = 0x84EF;
|
|
public static final int GL_TEXTURE_COMPRESSED_IMAGE_SIZE = 0x86A0;
|
|
public static final int GL_TEXTURE_COMPRESSED = 0x86A1;
|
|
public static final int GL_NUM_COMPRESSED_TEXTURE_FORMATS = 0x86A2;
|
|
public static final int GL_COMPRESSED_TEXTURE_FORMATS = 0x86A3;
|
|
public static final int GL_CLAMP_TO_BORDER = 0x812D;
|
|
public static final int GL_BLEND_DST_RGB = 0x80C8;
|
|
public static final int GL_BLEND_SRC_RGB = 0x80C9;
|
|
public static final int GL_BLEND_DST_ALPHA = 0x80CA;
|
|
public static final int GL_BLEND_SRC_ALPHA = 0x80CB;
|
|
public static final int GL_POINT_FADE_THRESHOLD_SIZE = 0x8128;
|
|
public static final int GL_DEPTH_COMPONENT16 = 0x81A5;
|
|
public static final int GL_DEPTH_COMPONENT24 = 0x81A6;
|
|
public static final int GL_DEPTH_COMPONENT32 = 0x81A7;
|
|
public static final int GL_MIRRORED_REPEAT = 0x8370;
|
|
public static final int GL_MAX_TEXTURE_LOD_BIAS = 0x84FD;
|
|
public static final int GL_TEXTURE_LOD_BIAS = 0x8501;
|
|
public static final int GL_INCR_WRAP = 0x8507;
|
|
public static final int GL_DECR_WRAP = 0x8508;
|
|
public static final int GL_TEXTURE_DEPTH_SIZE = 0x884A;
|
|
public static final int GL_TEXTURE_COMPARE_MODE = 0x884C;
|
|
public static final int GL_TEXTURE_COMPARE_FUNC = 0x884D;
|
|
public static final int GL_BLEND_COLOR = 0x8005;
|
|
public static final int GL_BLEND_EQUATION = 0x8009;
|
|
public static final int GL_CONSTANT_COLOR = 0x8001;
|
|
public static final int GL_ONE_MINUS_CONSTANT_COLOR = 0x8002;
|
|
public static final int GL_CONSTANT_ALPHA = 0x8003;
|
|
public static final int GL_ONE_MINUS_CONSTANT_ALPHA = 0x8004;
|
|
public static final int GL_FUNC_ADD = 0x8006;
|
|
public static final int GL_FUNC_REVERSE_SUBTRACT = 0x800B;
|
|
public static final int GL_FUNC_SUBTRACT = 0x800A;
|
|
public static final int GL_MIN = 0x8007;
|
|
public static final int GL_MAX = 0x8008;
|
|
public static final int GL_BUFFER_SIZE = 0x8764;
|
|
public static final int GL_BUFFER_USAGE = 0x8765;
|
|
public static final int GL_QUERY_COUNTER_BITS = 0x8864;
|
|
public static final int GL_CURRENT_QUERY = 0x8865;
|
|
public static final int GL_QUERY_RESULT = 0x8866;
|
|
public static final int GL_QUERY_RESULT_AVAILABLE = 0x8867;
|
|
public static final int GL_ARRAY_BUFFER = 0x8892;
|
|
public static final int GL_STATIC_DRAW = 0x88E4;
|
|
|
|
public static void glAlphaFunc(int func, float ref) {
|
|
GL11.glAlphaFunc(func, ref);
|
|
}
|
|
public static void glBindTexture(int texture) {
|
|
GL11.glBindTexture(GL_TEXTURE_2D, texture);
|
|
}
|
|
public static void glBlendFunc(int sfactor, int dfactor) {
|
|
GL11.glBlendFunc(sfactor, dfactor);
|
|
}
|
|
public static void glCallList(int list) {
|
|
GL11.glCallList(list);
|
|
}
|
|
public static void glClear(int mask) {
|
|
GL11.glClear(mask);
|
|
}
|
|
public static void glClearColor(float red, float green, float blue, float alpha) {
|
|
GL11.glClearColor(red, green, blue, alpha);
|
|
}
|
|
public static void glClearDepth(double depth) {
|
|
GL11.glClearDepth(depth);
|
|
}
|
|
public static void glColor4f(float red, float green, float blue, float alpha) {
|
|
GL11.glColor4f(red, green, blue, alpha);
|
|
}
|
|
public static void glColorMask(boolean red, boolean green, boolean blue, boolean alpha) {
|
|
GL11.glColorMask(red, green, blue, alpha);
|
|
}
|
|
public static void glColorMaterial(int face, int mode) {
|
|
GL11.glColorMaterial(face, mode);
|
|
}
|
|
public static void glColorPointer(int size, int type, int stride, long pointer) {
|
|
GL11.nglColorPointer(size, type, stride, pointer);
|
|
}
|
|
public static void glCullFace(int mode) {
|
|
GL11.glCullFace(mode);
|
|
}
|
|
public static void glDeleteLists(int list, int range) {
|
|
GL11.glDeleteLists(list, range);
|
|
}
|
|
public static void glDeleteTextures(int texture) {
|
|
GL11.glDeleteTextures(texture);
|
|
}
|
|
public static void glDepthFunc(int func) {
|
|
GL11.glDepthFunc(func);
|
|
}
|
|
public static void glDepthMask(boolean flag) {
|
|
GL11.glDepthMask(flag);
|
|
}
|
|
public static void glDisable(int cap) {
|
|
GL11.glDisable(cap);
|
|
}
|
|
public static void glDisableClientState(int cap) {
|
|
GL11.glDisableClientState(cap);
|
|
}
|
|
public static void glDrawArrays(int mode, int first, int count) {
|
|
GL11.glDrawArrays(mode, first, count);
|
|
}
|
|
public static void glEnable(int cap) {
|
|
GL11.glEnable(cap);
|
|
}
|
|
public static void glEnableClientState(int cap) {
|
|
GL11.glEnableClientState(cap);
|
|
}
|
|
public static void glEndList() {
|
|
GL11.glEndList();
|
|
}
|
|
public static void glFogf(int pname, float param) {
|
|
GL11.glFogf(pname, param);
|
|
}
|
|
public static void glFogi(int pname, int param) {
|
|
GL11.glFogi(pname, param);
|
|
}
|
|
public static int glGenLists(int range) {
|
|
return GL11.glGenLists(range);
|
|
}
|
|
public static int glGenTextures() {
|
|
return GL11.glGenTextures();
|
|
}
|
|
public static void glLineWidth(float width) {
|
|
GL11.glLineWidth(width);
|
|
}
|
|
public static void glLoadIdentity() {
|
|
GL11.glLoadIdentity();
|
|
}
|
|
public static void glMatrixMode(int mode) {
|
|
GL11.glMatrixMode(mode);
|
|
}
|
|
public static void glNewList(int list, int mode) {
|
|
GL11.glNewList(list, mode);
|
|
}
|
|
public static void glNormal3f(float nx, float ny, float nz) {
|
|
GL11.glNormal3f(nx, ny, nz);
|
|
}
|
|
public static void glPolygonOffset(float factor, float units) {
|
|
GL11.glPolygonOffset(factor, units);
|
|
}
|
|
public static void glPopMatrix() {
|
|
GL11.glPopMatrix();
|
|
}
|
|
public static void glPushMatrix() {
|
|
GL11.glPushMatrix();
|
|
}
|
|
public static void glRotatef(float angle, float x, float y, float z) {
|
|
GL11.glRotatef(angle, x, y, z);
|
|
}
|
|
public static void glScalef(float x, float y, float z) {
|
|
GL11.glScalef(x, y, z);
|
|
}
|
|
public static void glShadeModel(int mode) {
|
|
GL11.glShadeModel(mode);
|
|
}
|
|
public static void glTexCoordPointer(int size, int type, int stride, long pointer) {
|
|
GL11.glTexCoordPointer(size, type, stride, pointer);
|
|
}
|
|
public static void glTexImage2D(int width, int height) {
|
|
GL11.nglTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, width, height, 0, GL_BGRA, GL_UNSIGNED_INT_8_8_8_8_REV, NULL);
|
|
}
|
|
public static void glTexParameteri(int pname, int param) {
|
|
GL11.glTexParameteri(GL_TEXTURE_2D, pname, param);
|
|
}
|
|
public static void glTranslatef(float x, float y, float z) {
|
|
GL11.glTranslatef(x, y, z);
|
|
}
|
|
public static void glVertexPointer(int size, int type, int stride, long pointer) {
|
|
GL11.nglVertexPointer(size, type, stride, pointer);
|
|
}
|
|
public static void glOrtho(double left, double right, double bottom, double top, double near, double far) {
|
|
GL11.glOrtho(left, right, bottom, top, near, far);
|
|
}
|
|
public static String glGetString(int id) {
|
|
return GL11.glGetString(id);
|
|
}
|
|
public static void glScissor(int x, int y, int w, int h) {
|
|
GL11.glScissor(x, y, w, h);
|
|
}
|
|
public static void glViewport(int x, int y, int w, int h) {
|
|
GL11.glViewport(x, y, w, h);
|
|
}
|
|
public static void glPolygonMode(boolean line) {
|
|
GL11.glPolygonMode(GL_FRONT_AND_BACK, line ? GL_LINE : GL_FILL);
|
|
}
|
|
public static void glFlush() {
|
|
GL11.glFlush();
|
|
}
|
|
public static void glColorPointer(int size, int type, int stride, java.nio.ByteBuffer pointer) {
|
|
GL11.glColorPointer(size, type, stride, pointer);
|
|
}
|
|
public static void glFog(int pname, java.nio.FloatBuffer params) {
|
|
GL11.glFogfv(pname, params);
|
|
}
|
|
public static void glGetFloat(int pname, java.nio.FloatBuffer params) {
|
|
GL11.glGetFloatv(pname, params);
|
|
}
|
|
public static void glGetInteger(java.nio.IntBuffer params) {
|
|
GL11.glGetIntegerv(GL_VIEWPORT, params);
|
|
}
|
|
public static void glLight(int light, int pname, java.nio.FloatBuffer params) {
|
|
GL11.glLightfv(light, pname, params);
|
|
}
|
|
public static void glLightModel(int pname, java.nio.FloatBuffer params) {
|
|
GL11.glLightModelfv(pname, params);
|
|
}
|
|
public static void glMultMatrix(java.nio.FloatBuffer m) {
|
|
GL11.glMultMatrixf(m);
|
|
}
|
|
public static void glNormalPointer(int type, int stride, java.nio.ByteBuffer pointer) {
|
|
GL11.glNormalPointer(type, stride, pointer);
|
|
}
|
|
public static void glTexCoordPointer(int size, int type, int stride, java.nio.ByteBuffer pointer) {
|
|
GL11.glTexCoordPointer(size, type, stride, pointer);
|
|
}
|
|
public static void glTexSubImage2D(int xoffset, int yoffset, int width, int height, java.nio.IntBuffer pixels) {
|
|
GL11.glTexSubImage2D(GL_TEXTURE_2D, 0, xoffset, yoffset, width, height, GL_BGRA, GL_UNSIGNED_INT_8_8_8_8_REV, pixels);
|
|
}
|
|
public static void glVertexPointer(int size, int type, int stride, java.nio.ByteBuffer pointer) {
|
|
GL11.glVertexPointer(size, type, stride, pointer);
|
|
}
|
|
public static void glReadPixels(int x, int y, java.nio.ByteBuffer data) {
|
|
GL11.glReadPixels(0, 0, x, y, GL_RGB, GL_UNSIGNED_BYTE, data);
|
|
}
|
|
|
|
public static void glActiveTexture(int texture) {
|
|
GL13.glActiveTexture(texture);
|
|
}
|
|
public static void glClientActiveTexture(int texture) {
|
|
GL13.glClientActiveTexture(texture);
|
|
}
|
|
public static void glMultiTexCoord2f(int target, float s, float t) {
|
|
GL13.glMultiTexCoord2f(target, s, t);
|
|
}
|
|
|
|
public static void glBlendFuncSeparate(int sfactorRGB, int dfactorRGB, int sfactorAlpha, int dfactorAlpha) {
|
|
GL14.glBlendFuncSeparate(sfactorRGB, dfactorRGB, sfactorAlpha, dfactorAlpha);
|
|
}
|
|
|
|
public static void glBindBuffer(int buffer) {
|
|
GL15.glBindBuffer(GL_ARRAY_BUFFER, buffer);
|
|
}
|
|
public static void glDeleteBuffers(int buffer) {
|
|
GL15.glDeleteBuffers(buffer);
|
|
}
|
|
public static int glGenBuffers() {
|
|
return GL15.glGenBuffers();
|
|
}
|
|
public static void glBufferData(java.nio.ByteBuffer data) {
|
|
GL15.glBufferData(GL_ARRAY_BUFFER, data, GL_STATIC_DRAW);
|
|
}
|
|
|
|
public static long getTime() {
|
|
return glfwGetTimerValue() / (glfwGetTimerFrequency() / 1000000L);
|
|
}
|
|
public static void setWindowed(int xpos, int ypos, int xsize, int ysize) {
|
|
if(window != NULL)
|
|
glfwSetWindowMonitor(window, NULL, xpos, ypos, xsize, ysize, GLFW_DONT_CARE);
|
|
}
|
|
public static void setFullscreen(int width, int height, int refresh) {
|
|
if(window != NULL) {
|
|
long monitor = glfwGetPrimaryMonitor();
|
|
if(monitor != NULL)
|
|
glfwSetWindowMonitor(window, monitor, 0, 0, width, height, refresh);
|
|
}
|
|
}
|
|
public static boolean getKey(Keysym code) {
|
|
return window != NULL && glfwGetKey(window, CODES[code.ordinal()]) == GLFW_PRESS;
|
|
}
|
|
public static void setTitle(String title) {
|
|
if(window != NULL)
|
|
glfwSetWindowTitle(window, title);
|
|
}
|
|
public static void setIcon(byte[] icon, int w, int h) {
|
|
if(window != NULL) {
|
|
GLFWImage img = GLFWImage.create();
|
|
img.width(w);
|
|
img.height(h);
|
|
// java.nio.ByteBuffer pbuf = ;
|
|
img.pixels(BufferUtils.createByteBuffer(icon.length).put(icon));
|
|
// img.pixels(icon.length / 4);
|
|
GLFWImage.Buffer buf = GLFWImage.create(1).put(img);
|
|
glfwSetWindowIcon(window, buf);
|
|
}
|
|
}
|
|
public static String getClipboard() {
|
|
return window == NULL ? null : glfwGetClipboardString(window);
|
|
}
|
|
public static void setClipboard(String text) {
|
|
if(window != NULL)
|
|
glfwSetClipboardString(window, text);
|
|
}
|
|
public static void swapBuffers() {
|
|
if(window != NULL)
|
|
glfwSwapBuffers(window);
|
|
}
|
|
public static void grabCursor(boolean grab) {
|
|
if(window != NULL)
|
|
glfwSetInputMode(window, GLFW_CURSOR, grab ? GLFW_CURSOR_DISABLED : GLFW_CURSOR_NORMAL);
|
|
}
|
|
public static void setVSync(boolean sync) {
|
|
if(window != NULL)
|
|
glfwSwapInterval(sync ? 1 : 0);
|
|
}
|
|
|
|
private static final int[] CODES = new int[Keysym.values().length];
|
|
private static final Keysym[] KEYS = new Keysym[GLFW_KEY_LAST];
|
|
private static final List<WindowEvent> EVENTS = new ArrayList<WindowEvent>();
|
|
|
|
private static long window;
|
|
|
|
private static void addKey(Keysym key, int code) {
|
|
CODES[key.ordinal()] = code;
|
|
KEYS[code - 1] = key;
|
|
}
|
|
|
|
static {
|
|
addKey(Keysym.N0, GLFW_KEY_0);
|
|
addKey(Keysym.N1, GLFW_KEY_1);
|
|
addKey(Keysym.N2, GLFW_KEY_2);
|
|
addKey(Keysym.N3, GLFW_KEY_3);
|
|
addKey(Keysym.N4, GLFW_KEY_4);
|
|
addKey(Keysym.N5, GLFW_KEY_5);
|
|
addKey(Keysym.N6, GLFW_KEY_6);
|
|
addKey(Keysym.N7, GLFW_KEY_7);
|
|
addKey(Keysym.N8, GLFW_KEY_8);
|
|
addKey(Keysym.N9, GLFW_KEY_9);
|
|
|
|
addKey(Keysym.A, GLFW_KEY_A);
|
|
addKey(Keysym.B, GLFW_KEY_B);
|
|
addKey(Keysym.C, GLFW_KEY_C);
|
|
addKey(Keysym.D, GLFW_KEY_D);
|
|
addKey(Keysym.E, GLFW_KEY_E);
|
|
addKey(Keysym.F, GLFW_KEY_F);
|
|
addKey(Keysym.G, GLFW_KEY_G);
|
|
addKey(Keysym.H, GLFW_KEY_H);
|
|
addKey(Keysym.I, GLFW_KEY_I);
|
|
addKey(Keysym.J, GLFW_KEY_J);
|
|
addKey(Keysym.K, GLFW_KEY_K);
|
|
addKey(Keysym.L, GLFW_KEY_L);
|
|
addKey(Keysym.M, GLFW_KEY_M);
|
|
addKey(Keysym.N, GLFW_KEY_N);
|
|
addKey(Keysym.O, GLFW_KEY_O);
|
|
addKey(Keysym.P, GLFW_KEY_P);
|
|
addKey(Keysym.Q, GLFW_KEY_Q);
|
|
addKey(Keysym.R, GLFW_KEY_R);
|
|
addKey(Keysym.S, GLFW_KEY_S);
|
|
addKey(Keysym.T, GLFW_KEY_T);
|
|
addKey(Keysym.U, GLFW_KEY_U);
|
|
addKey(Keysym.V, GLFW_KEY_V);
|
|
addKey(Keysym.W, GLFW_KEY_W);
|
|
addKey(Keysym.X, GLFW_KEY_X);
|
|
addKey(Keysym.Y, GLFW_KEY_Z);
|
|
addKey(Keysym.Z, GLFW_KEY_Y);
|
|
|
|
addKey(Keysym.F1, GLFW_KEY_F1);
|
|
addKey(Keysym.F2, GLFW_KEY_F2);
|
|
addKey(Keysym.F3, GLFW_KEY_F3);
|
|
addKey(Keysym.F4, GLFW_KEY_F4);
|
|
addKey(Keysym.F5, GLFW_KEY_F5);
|
|
addKey(Keysym.F6, GLFW_KEY_F6);
|
|
addKey(Keysym.F7, GLFW_KEY_F7);
|
|
addKey(Keysym.F8, GLFW_KEY_F8);
|
|
addKey(Keysym.F9, GLFW_KEY_F9);
|
|
addKey(Keysym.F10, GLFW_KEY_F10);
|
|
addKey(Keysym.F11, GLFW_KEY_F11);
|
|
addKey(Keysym.F12, GLFW_KEY_F12);
|
|
|
|
addKey(Keysym.KP_0, GLFW_KEY_KP_0);
|
|
addKey(Keysym.KP_1, GLFW_KEY_KP_1);
|
|
addKey(Keysym.KP_2, GLFW_KEY_KP_2);
|
|
addKey(Keysym.KP_3, GLFW_KEY_KP_3);
|
|
addKey(Keysym.KP_4, GLFW_KEY_KP_4);
|
|
addKey(Keysym.KP_5, GLFW_KEY_KP_5);
|
|
addKey(Keysym.KP_6, GLFW_KEY_KP_6);
|
|
addKey(Keysym.KP_7, GLFW_KEY_KP_7);
|
|
addKey(Keysym.KP_8, GLFW_KEY_KP_8);
|
|
addKey(Keysym.KP_9, GLFW_KEY_KP_9);
|
|
|
|
addKey(Keysym.SPACE, GLFW_KEY_SPACE);
|
|
addKey(Keysym.CIRCUMFLEX, GLFW_KEY_GRAVE_ACCENT);
|
|
addKey(Keysym.SHARP_S, GLFW_KEY_MINUS);
|
|
addKey(Keysym.ACUTE, GLFW_KEY_EQUAL);
|
|
addKey(Keysym.UE, GLFW_KEY_LEFT_BRACKET);
|
|
addKey(Keysym.PLUS, GLFW_KEY_RIGHT_BRACKET);
|
|
addKey(Keysym.OE, GLFW_KEY_SEMICOLON);
|
|
addKey(Keysym.AE, GLFW_KEY_APOSTROPHE);
|
|
addKey(Keysym.NUMBER_SIGN, GLFW_KEY_BACKSLASH);
|
|
addKey(Keysym.LESS_THAN, GLFW_KEY_WORLD_1);
|
|
addKey(Keysym.COMMA, GLFW_KEY_COMMA);
|
|
addKey(Keysym.PERIOD, GLFW_KEY_PERIOD);
|
|
addKey(Keysym.HYPHEN, GLFW_KEY_SLASH);
|
|
|
|
addKey(Keysym.KP_DECIMAL, GLFW_KEY_KP_DECIMAL);
|
|
addKey(Keysym.KP_DIVIDE, GLFW_KEY_KP_DIVIDE);
|
|
addKey(Keysym.KP_MULTIPLY, GLFW_KEY_KP_MULTIPLY);
|
|
addKey(Keysym.KP_SUBTRACT, GLFW_KEY_KP_SUBTRACT);
|
|
addKey(Keysym.KP_ADD, GLFW_KEY_KP_ADD);
|
|
addKey(Keysym.KP_ENTER, GLFW_KEY_KP_ENTER);
|
|
addKey(Keysym.KP_EQUAL, GLFW_KEY_KP_EQUAL);
|
|
|
|
addKey(Keysym.CAPS_LOCK, GLFW_KEY_CAPS_LOCK);
|
|
addKey(Keysym.SCROLL_LOCK, GLFW_KEY_SCROLL_LOCK);
|
|
addKey(Keysym.NUM_LOCK, GLFW_KEY_NUM_LOCK);
|
|
|
|
addKey(Keysym.ESCAPE, GLFW_KEY_ESCAPE);
|
|
addKey(Keysym.RETURN, GLFW_KEY_ENTER);
|
|
addKey(Keysym.TAB, GLFW_KEY_TAB);
|
|
addKey(Keysym.BACKSPACE, GLFW_KEY_BACKSPACE);
|
|
addKey(Keysym.INSERT, GLFW_KEY_INSERT);
|
|
addKey(Keysym.DELETE, GLFW_KEY_DELETE);
|
|
addKey(Keysym.RIGHT, GLFW_KEY_RIGHT);
|
|
addKey(Keysym.LEFT, GLFW_KEY_LEFT);
|
|
addKey(Keysym.DOWN, GLFW_KEY_DOWN);
|
|
addKey(Keysym.UP, GLFW_KEY_UP);
|
|
addKey(Keysym.PAGE_UP, GLFW_KEY_PAGE_UP);
|
|
addKey(Keysym.PAGE_DOWN, GLFW_KEY_PAGE_DOWN);
|
|
addKey(Keysym.HOME, GLFW_KEY_HOME);
|
|
addKey(Keysym.END, GLFW_KEY_END);
|
|
addKey(Keysym.PRINT_SCREEN, GLFW_KEY_PRINT_SCREEN);
|
|
addKey(Keysym.PAUSE, GLFW_KEY_PAUSE);
|
|
addKey(Keysym.LEFT_SHIFT, GLFW_KEY_LEFT_SHIFT);
|
|
addKey(Keysym.LEFT_CONTROL, GLFW_KEY_LEFT_CONTROL);
|
|
addKey(Keysym.ALT, GLFW_KEY_LEFT_ALT);
|
|
addKey(Keysym.LEFT_LINUX, GLFW_KEY_LEFT_SUPER);
|
|
addKey(Keysym.RIGHT_SHIFT, GLFW_KEY_RIGHT_SHIFT);
|
|
addKey(Keysym.RIGHT_CONTROL, GLFW_KEY_RIGHT_CONTROL);
|
|
addKey(Keysym.ALT_GRAPH, GLFW_KEY_RIGHT_ALT);
|
|
addKey(Keysym.RIGHT_LINUX, GLFW_KEY_RIGHT_SUPER);
|
|
addKey(Keysym.MENU, GLFW_KEY_MENU);
|
|
}
|
|
|
|
public static boolean createWindow(String id, boolean gldebug) {
|
|
glfwDefaultWindowHints();
|
|
glfwWindowHint(GLFW_VISIBLE, GLFW_FALSE);
|
|
glfwWindowHint(GLFW_RESIZABLE, GLFW_TRUE);
|
|
glfwWindowHint(GLFW_CONTEXT_DEBUG, gldebug ? GLFW_TRUE : GLFW_FALSE);
|
|
window = glfwCreateWindow(100, 100, id, NULL, NULL);
|
|
if(window == NULL) {
|
|
Log.SYSTEM.error("Konnte kein Fenster für das Programm erstellen");
|
|
}
|
|
else {
|
|
glfwSetMouseButtonCallback(window, new GLFWMouseButtonCallback() {
|
|
public void invoke(long window, int button, int action, int mods) {
|
|
if(action != GLFW_REPEAT && button >= 0 && button < Button.values().length)
|
|
EVENTS.add(new WindowEvent(WindowAction.BUTTON, button, action == GLFW_PRESS ? 1 : 0));
|
|
}
|
|
});
|
|
glfwSetCharCallback(window, new GLFWCharCallback() {
|
|
public void invoke(long window, int codepoint) {
|
|
EVENTS.add(new WindowEvent(WindowAction.CHARACTER, codepoint, 0));
|
|
}
|
|
});
|
|
glfwSetCursorPosCallback(window, new GLFWCursorPosCallback() {
|
|
public void invoke(long window, double xpos, double ypos) {
|
|
EVENTS.add(new WindowEvent(WindowAction.CURSOR, (int)xpos, (int)ypos));
|
|
}
|
|
});
|
|
glfwSetFramebufferSizeCallback(window, new GLFWFramebufferSizeCallback() {
|
|
public void invoke(long window, int width, int height) {
|
|
EVENTS.add(new WindowEvent(WindowAction.RESIZE, width, height));
|
|
}
|
|
});
|
|
glfwSetKeyCallback(window, new GLFWKeyCallback() {
|
|
public void invoke(long window, int key, int scancode, int action, int mods) {
|
|
Keysym code = key > 0 && key <= KEYS.length ? KEYS[key - 1] : null;
|
|
if(code != null)
|
|
EVENTS.add(new WindowEvent(WindowAction.KEY, code.ordinal(),
|
|
(action == GLFW_PRESS ? KeyEvent.PRESS : (action == GLFW_RELEASE ? KeyEvent.RELEASE : KeyEvent.REPEAT)).ordinal()));
|
|
}
|
|
});
|
|
glfwSetScrollCallback(window, new GLFWScrollCallback() {
|
|
public void invoke(long window, double xoffset, double yoffset) {
|
|
EVENTS.add(new WindowEvent(WindowAction.SCROLL, (int)xoffset, (int)yoffset));
|
|
}
|
|
});
|
|
glfwSetWindowCloseCallback(window, new GLFWWindowCloseCallback() {
|
|
public void invoke(long window) {
|
|
EVENTS.add(new WindowEvent(WindowAction.CLOSED, 0, 0));
|
|
}
|
|
});
|
|
glfwSetWindowFocusCallback(window, new GLFWWindowFocusCallback() {
|
|
public void invoke(long window, boolean focused) {
|
|
EVENTS.add(new WindowEvent(WindowAction.FOCUS, focused ? 1 : 0, 0));
|
|
}
|
|
});
|
|
// glfwSetWindowSizeCallback(window, new GLFWWindowSizeCallback() {
|
|
// public void invoke(long window, int width, int height) {
|
|
// EVENTS.add(new WindowEvent(WindowAction.RESIZE, width, height));
|
|
// }
|
|
// });
|
|
glfwSetWindowPosCallback(window, new GLFWWindowPosCallback() {
|
|
public void invoke(long window, int xpos, int ypos) {
|
|
EVENTS.add(new WindowEvent(WindowAction.POSITION, xpos, ypos));
|
|
}
|
|
});
|
|
glfwSetWindowRefreshCallback(window, new GLFWWindowRefreshCallback() {
|
|
public void invoke(long window) {
|
|
EVENTS.add(new WindowEvent(WindowAction.REDRAW, 0, 0));
|
|
}
|
|
});
|
|
glfwMakeContextCurrent(window);
|
|
GL.createCapabilities();
|
|
}
|
|
return window != NULL;
|
|
}
|
|
public static void destroyWindow() {
|
|
if(window != NULL) {
|
|
glfwFreeCallbacks(window);
|
|
glfwDestroyWindow(window);
|
|
window = NULL;
|
|
}
|
|
}
|
|
public static void initWindow(int sx, int sy, int wx, int wy) {
|
|
if(window == NULL)
|
|
return;
|
|
long monitor = glfwGetPrimaryMonitor();
|
|
GLFWVidMode mode = monitor == NULL ? null : glfwGetVideoMode(monitor);
|
|
int[] x = new int[1];
|
|
int[] y = new int[1];
|
|
if(monitor != NULL)
|
|
glfwGetMonitorPos(monitor, x, y);
|
|
int xsize = (mode != null && wx > mode.width()) ? mode.width() : wx;
|
|
int ysize = (mode != null && wy > mode.height()) ? mode.height() : wy;
|
|
int xpos = x[0] + (mode != null ? mode.width() / 2 - xsize / 2 : 0);
|
|
int ypos = y[0] + (mode != null ? mode.height() / 2 - ysize / 2 : 0);
|
|
xsize = xsize < 1 ? 1 : xsize;
|
|
ysize = ysize < 1 ? 1 : ysize;
|
|
if(sx != 0x80000000 && sy != 0x80000000) {
|
|
xpos = sx;
|
|
ypos = sy;
|
|
}
|
|
if(wx != 0 && wy != 0) {
|
|
xsize = wx;
|
|
ysize = wy;
|
|
}
|
|
glfwSetWindowSize(window, xsize, ysize);
|
|
glfwSetWindowPos(window, xpos, ypos);
|
|
// wcf_windowed(win, xpos, ypos, xsize, ysize);
|
|
// wcf_fullscreen does not move while hidden ...
|
|
// wcf_setpos(win, xpos, ypos);
|
|
glfwShowWindow(window);
|
|
// wcf_show(win, 1);
|
|
// wcf_limits(win, 1, 1, -1, -1);
|
|
}
|
|
|
|
public static WindowEvent[] poll() {
|
|
glfwPollEvents();
|
|
// int[] data = pollEvents();
|
|
// WindowEvent[] events = new WindowEvent[data.length / 3];
|
|
// for(int z = 0; z < events.length; z++) {
|
|
// events[z] = new WindowEvent(WindowAction.values()[data[z * 3 + 0]], data[z * 3 + 1], data[z * 3 + 2]);
|
|
// }
|
|
WindowEvent[] events = EVENTS.toArray(new WindowEvent[EVENTS.size()]);
|
|
EVENTS.clear();
|
|
return events;
|
|
}
|
|
public static DisplayMode[] getDisplayModes() {
|
|
long monitor = glfwGetPrimaryMonitor();
|
|
GLFWVidMode.Buffer data = monitor == NULL ? null : glfwGetVideoModes(monitor);
|
|
// int[] data = getModes();
|
|
if(data == null)
|
|
return null;
|
|
// modes.forEach(new Consumer<GLFWVidMode>() {
|
|
// public void accept(GLFWVidMode t) {
|
|
// // TODO Auto-generated method stub
|
|
//
|
|
// }
|
|
// });
|
|
DisplayMode[] modes = new DisplayMode[data.limit()];
|
|
for(int z = 0; z < data.limit(); z++) {
|
|
GLFWVidMode mode = data.get(z);
|
|
modes[z] = new DisplayMode(mode.width(), mode.height(), mode.refreshRate());
|
|
}
|
|
return modes;
|
|
}
|
|
public static DisplayMode getDisplayMode() {
|
|
long monitor = glfwGetPrimaryMonitor();
|
|
GLFWVidMode mode = monitor == NULL ? null : glfwGetVideoMode(monitor);
|
|
// int[] data = getMode();
|
|
if(mode == null)
|
|
return null;
|
|
return new DisplayMode(mode.width(), mode.height(), mode.refreshRate());
|
|
}
|
|
public static void init() {
|
|
GLFWErrorCallback.create(new GLFWErrorCallback() {
|
|
private Map<Integer, String> codes = APIUtil.apiClassTokens((field, value) -> 0x10000 < value && value < 0x20000, null, GLFW.class);
|
|
|
|
public void invoke(int error, long description) {
|
|
Log.SYSTEM.error("LWJGL-Fehler %s: %s", this.codes.get(error), getDescription(description));
|
|
}
|
|
}).set();
|
|
if(!glfwInit())
|
|
throw new IllegalStateException("Kann GLFW nicht initialisieren");
|
|
if(glfwGetTimerFrequency() < 1000000L)
|
|
throw new IllegalStateException("Timer unterstützt keine Mikrosekunden-Präzision");
|
|
Log.SYSTEM.info("LWJGL " + Version.getVersion());
|
|
/*
|
|
System.setProperty("java.library.path", "lib");
|
|
try {
|
|
java.lang.reflect.Field paths = ClassLoader.class.getDeclaredField("sys_paths");
|
|
paths.setAccessible(true);
|
|
paths.set(null, null);
|
|
paths.setAccessible(false);
|
|
}
|
|
catch(NoSuchFieldException | IllegalArgumentException | IllegalAccessException e) {
|
|
throw new RuntimeException(e);
|
|
}
|
|
java.io.File dir = new java.io.File("lib");
|
|
dir.mkdirs();
|
|
java.io.InputStream in = WCF.class.getResourceAsStream("/libwcf.so");
|
|
if(in == null)
|
|
throw new RuntimeException(new java.io.FileNotFoundException("libwcf.so"));
|
|
try {
|
|
java.nio.file.Files.copy(in, new java.io.File(dir, "libwcf.so").toPath(), java.nio.file.StandardCopyOption.REPLACE_EXISTING);
|
|
}
|
|
catch(java.io.IOException e) {
|
|
throw new RuntimeException(e);
|
|
}
|
|
System.loadLibrary("wcf");
|
|
*/
|
|
}
|
|
public static void end() {
|
|
glfwTerminate();
|
|
glfwSetErrorCallback(null).free();
|
|
}
|
|
}
|