inline OpenGL functions to lwjgl GLxx
This commit is contained in:
parent
783adb350b
commit
a2ffb2991d
90 changed files with 1008 additions and 1204 deletions
|
@ -136,6 +136,6 @@ public enum Keysym implements Input {
|
|||
}
|
||||
|
||||
public boolean read() {
|
||||
return WCF.getKey(this); // .ordinal() + 1
|
||||
return Window.getKey(this); // .ordinal() + 1
|
||||
}
|
||||
}
|
||||
|
|
|
@ -25,224 +25,11 @@ 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.GL12;
|
||||
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 void glAlphaFunc(int func, float ref) {
|
||||
GL11.glAlphaFunc(func, ref);
|
||||
}
|
||||
public static void glBindTexture(int texture) {
|
||||
GL11.glBindTexture(GL11.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(GL11.GL_TEXTURE_2D, 0, GL11.GL_RGBA, width, height, 0, GL12.GL_BGRA, GL12.GL_UNSIGNED_INT_8_8_8_8_REV, NULL);
|
||||
}
|
||||
public static void glTexParameteri(int pname, int param) {
|
||||
GL11.glTexParameteri(GL11.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(GL11.GL_FRONT_AND_BACK, line ? GL11.GL_LINE : GL11.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(GL11.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(GL11.GL_TEXTURE_2D, 0, xoffset, yoffset, width, height, GL12.GL_BGRA, GL12.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, GL11.GL_RGB, GL11.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(GL15.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(GL15.GL_ARRAY_BUFFER, data, GL15.GL_STATIC_DRAW);
|
||||
}
|
||||
|
||||
public abstract class Window {
|
||||
public static long getTime() {
|
||||
return glfwGetTimerValue() / (glfwGetTimerFrequency() / 1000000L);
|
||||
}
|
||||
|
@ -539,11 +326,6 @@ public abstract class WCF {
|
|||
|
||||
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;
|
||||
|
@ -551,15 +333,8 @@ public abstract class WCF {
|
|||
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);
|
||||
|
@ -570,7 +345,6 @@ public abstract class WCF {
|
|||
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());
|
||||
|
@ -588,30 +362,6 @@ public abstract class WCF {
|
|||
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();
|
Loading…
Add table
Add a link
Reference in a new issue