From 1e6b8170b57c490bf241dccc7f71627041659291 Mon Sep 17 00:00:00 2001 From: LAX1DUDE Date: Wed, 3 Aug 2022 23:06:34 -0700 Subject: [PATCH] reformatted some classes --- .../eaglercraft/sp/IntegratedServer.java | 25 +- .../eaglercraft/WorkerNetworkManager.java | 2 - .../eaglercraft/glemu/EaglerAdapterGL30.java | 572 +++++++++++------- .../eaglercraft/glemu/EffectPipeline.java | 73 +-- .../eaglercraft/glemu/EffectPipelineFXAA.java | 89 +-- .../glemu/FixedFunctionShader.java | 45 +- .../eaglercraft/glemu/HighPolyMesh.java | 15 +- .../java/net/minecraft/client/Minecraft.java | 4 +- .../java/net/minecraft/src/GuiIngame.java | 3 +- .../net/minecraft/src/GuiSelectWorld.java | 1 - .../net/minecraft/src/NetClientHandler.java | 2 +- .../java/net/minecraft/src/ServerList.java | 6 +- .../adapter/EaglerAdapterImpl2.java | 5 +- 13 files changed, 366 insertions(+), 476 deletions(-) diff --git a/sp-server/src/main/java/net/lax1dude/eaglercraft/sp/IntegratedServer.java b/sp-server/src/main/java/net/lax1dude/eaglercraft/sp/IntegratedServer.java index fa5ef4c..5a13be8 100644 --- a/sp-server/src/main/java/net/lax1dude/eaglercraft/sp/IntegratedServer.java +++ b/sp-server/src/main/java/net/lax1dude/eaglercraft/sp/IntegratedServer.java @@ -18,30 +18,7 @@ import org.teavm.jso.JSObject; import org.teavm.jso.typedarrays.ArrayBuffer; import org.teavm.jso.typedarrays.Uint8Array; -import net.lax1dude.eaglercraft.sp.ipc.IPCPacket00StartServer; -import net.lax1dude.eaglercraft.sp.ipc.IPCPacket01StopServer; -import net.lax1dude.eaglercraft.sp.ipc.IPCPacket02InitWorld; -import net.lax1dude.eaglercraft.sp.ipc.IPCPacket03DeleteWorld; -import net.lax1dude.eaglercraft.sp.ipc.IPCPacket04RenameWorld; -import net.lax1dude.eaglercraft.sp.ipc.IPCPacket05RequestData; -import net.lax1dude.eaglercraft.sp.ipc.IPCPacket06RenameWorldNBT; -import net.lax1dude.eaglercraft.sp.ipc.IPCPacket07ImportWorld; -import net.lax1dude.eaglercraft.sp.ipc.IPCPacket09RequestResponse; -import net.lax1dude.eaglercraft.sp.ipc.IPCPacket0ASetWorldDifficulty; -import net.lax1dude.eaglercraft.sp.ipc.IPCPacket0BPause; -import net.lax1dude.eaglercraft.sp.ipc.IPCPacket0CPlayerChannel; -import net.lax1dude.eaglercraft.sp.ipc.IPCPacket0DProgressUpdate; -import net.lax1dude.eaglercraft.sp.ipc.IPCPacket0EListWorlds; -import net.lax1dude.eaglercraft.sp.ipc.IPCPacket0FListFiles; -import net.lax1dude.eaglercraft.sp.ipc.IPCPacket10FileRead; -import net.lax1dude.eaglercraft.sp.ipc.IPCPacket12FileWrite; -import net.lax1dude.eaglercraft.sp.ipc.IPCPacket13FileCopyMove; -import net.lax1dude.eaglercraft.sp.ipc.IPCPacket14StringList; -import net.lax1dude.eaglercraft.sp.ipc.IPCPacket15ThrowException; -import net.lax1dude.eaglercraft.sp.ipc.IPCPacket16NBTList; -import net.lax1dude.eaglercraft.sp.ipc.IPCPacketBase; -import net.lax1dude.eaglercraft.sp.ipc.IPCPacketFFProcessKeepAlive; -import net.lax1dude.eaglercraft.sp.ipc.IPCPacketManager; +import net.lax1dude.eaglercraft.sp.ipc.*; import net.minecraft.src.AchievementList; import net.minecraft.src.AchievementMap; import net.minecraft.src.ChunkCoordIntPair; diff --git a/src/main/java/net/lax1dude/eaglercraft/WorkerNetworkManager.java b/src/main/java/net/lax1dude/eaglercraft/WorkerNetworkManager.java index f6925ea..145c5fb 100644 --- a/src/main/java/net/lax1dude/eaglercraft/WorkerNetworkManager.java +++ b/src/main/java/net/lax1dude/eaglercraft/WorkerNetworkManager.java @@ -6,8 +6,6 @@ import java.io.DataInputStream; import java.io.DataOutputStream; import java.io.IOException; -import net.lax1dude.eaglercraft.sp.ipc.IPCInputStream; -import net.lax1dude.eaglercraft.sp.ipc.IPCOutputStream; import net.minecraft.src.INetworkManager; import net.minecraft.src.NetHandler; import net.minecraft.src.Packet; diff --git a/src/main/java/net/lax1dude/eaglercraft/glemu/EaglerAdapterGL30.java b/src/main/java/net/lax1dude/eaglercraft/glemu/EaglerAdapterGL30.java index dbdb91a..c9ec459 100644 --- a/src/main/java/net/lax1dude/eaglercraft/glemu/EaglerAdapterGL30.java +++ b/src/main/java/net/lax1dude/eaglercraft/glemu/EaglerAdapterGL30.java @@ -125,7 +125,7 @@ public class EaglerAdapterGL30 extends EaglerAdapterImpl2 { public static final int GL_LINEAR_MIPMAP_LINEAR = RealOpenGLEnums.GL_LINEAR_MIPMAP_LINEAR; public static final int GL_LINEAR_MIPMAP_NEAREST = RealOpenGLEnums.GL_LINEAR_MIPMAP_NEAREST; public static final int GL_NEAREST_MIPMAP_NEAREST = RealOpenGLEnums.GL_NEAREST_MIPMAP_NEAREST; - + public static final boolean isWebGL = _wisWebGL(); private static final GLObjectMap texObjects = new GLObjectMap(256); @@ -143,7 +143,7 @@ public class EaglerAdapterGL30 extends EaglerAdapterImpl2 { private static boolean enableNormalArray = false; private static boolean enableTex0Array = false; private static boolean enableTex1Array = false; - + private static boolean enableAnisotropicFix = false; private static float anisotropicFixX = 1024.0f; private static float anisotropicFixY = 1024.0f; @@ -152,7 +152,7 @@ public class EaglerAdapterGL30 extends EaglerAdapterImpl2 { private static float colorG = 1.0f; private static float colorB = 1.0f; private static float colorA = 1.0f; - + private static float normalX = 1.0f; private static float normalY = 0.0f; private static float normalZ = 0.0f; @@ -167,14 +167,14 @@ public class EaglerAdapterGL30 extends EaglerAdapterImpl2 { private static boolean enableAnisotropicPatch = false; private static boolean hintAnisotropicPatch = false; private static boolean swapRB = false; - + public static final void anisotropicPatch(boolean e) { enableAnisotropicPatch = e; } private static boolean enableTexGen = false; private static boolean enableColorMaterial = false; - + private static int texS_plane = 0; private static float texS_X = 0.0f; private static float texS_Y = 0.0f; @@ -213,45 +213,49 @@ public class EaglerAdapterGL30 extends EaglerAdapterImpl2 { private static int bytesUploaded = 0; private static int vertexDrawn = 0; private static int triangleDrawn = 0; - + private static int matrixMode = GL_MODELVIEW; static Matrix4f[] matModelV = new Matrix4f[32]; static int matModelPointer = 0; - + static Matrix4f[] matProjV = new Matrix4f[6]; static int matProjPointer = 0; - + static Matrix4f[] matTexV = new Matrix4f[16]; static int matTexPointer = 0; - + static { - for(int i = 0; i < matModelV.length; ++i) { + for (int i = 0; i < matModelV.length; ++i) { matModelV[i] = new Matrix4f(); } - for(int i = 0; i < matProjV.length; ++i) { + for (int i = 0; i < matProjV.length; ++i) { matProjV[i] = new Matrix4f(); } - for(int i = 0; i < matTexV.length; ++i) { + for (int i = 0; i < matTexV.length; ++i) { matTexV[i] = new Matrix4f(); } } - + public static void glClearStack() { - matModelV[0].load(matModelV[matModelPointer]); matModelPointer = 0; - matProjV[0].load(matProjV[matProjPointer]); matProjPointer = 0; - matTexV[0].load(matTexV[matTexPointer]); matTexPointer = 0; + matModelV[0].load(matModelV[matModelPointer]); + matModelPointer = 0; + matProjV[0].load(matProjV[matProjPointer]); + matProjPointer = 0; + matTexV[0].load(matTexV[matTexPointer]); + matTexPointer = 0; } - + private static BufferGL quadsToTrianglesBuffer = null; private static BufferArrayGL currentArray = null; - + private static class DisplayList { private final int id; private BufferArrayGL glarray; private BufferGL glbuffer; private int shaderMode; private int listLength; + private DisplayList(int id) { this.id = id; this.glarray = null; @@ -261,15 +265,15 @@ public class EaglerAdapterGL30 extends EaglerAdapterImpl2 { } } - private static final HashMap displayLists = new HashMap(); - private static final HashMap displayListsInitialized = new HashMap(); - + private static final HashMap displayLists = new HashMap(); + private static final HashMap displayListsInitialized = new HashMap(); + public static final int getDisplayListCount() { return displayListsInitialized.size(); } - + public static final void glEnable(int p1) { - switch(p1) { + switch (p1) { case GL_DEPTH_TEST: _wglEnable(_wGL_DEPTH_TEST); break; @@ -282,10 +286,10 @@ public class EaglerAdapterGL30 extends EaglerAdapterImpl2 { case GL_RESCALE_NORMAL: break; case GL_TEXTURE_2D: - if(selectedTex == 0) { + if (selectedTex == 0) { enableTexture2D = true; } - if(selectedTex == 1) { + if (selectedTex == 1) { enableTexture2D_1 = true; } break; @@ -317,33 +321,46 @@ public class EaglerAdapterGL30 extends EaglerAdapterImpl2 { break; } } + public static final void glShadeModel(int p1) { - + } + public static final void glClearDepth(float p1) { _wglClearDepth(-p1); } + public static final void glDepthFunc(int p1) { int f = _wGL_GEQUAL; - switch(p1) { - case GL_GREATER: f = _wGL_LESS; break; - case GL_LEQUAL: f = _wGL_GEQUAL; break; - case GL_EQUAL: f = _wGL_EQUAL; - default: break; + switch (p1) { + case GL_GREATER: + f = _wGL_LESS; + break; + case GL_LEQUAL: + f = _wGL_GEQUAL; + break; + case GL_EQUAL: + f = _wGL_EQUAL; + default: + break; } _wglDepthFunc(f); } + public static final void glAlphaFunc(int p1, float p2) { alphaThresh = p2; } + public static final void glCullFace(int p1) { _wglCullFace(p1); } + public static final void glMatrixMode(int p1) { matrixMode = p1; } + private static final Matrix4f getMatrix() { - switch(matrixMode) { + switch (matrixMode) { case GL_MODELVIEW: default: return matModelV[matModelPointer]; @@ -353,47 +370,55 @@ public class EaglerAdapterGL30 extends EaglerAdapterImpl2 { return matTexV[matTexPointer]; } } + public static final void glLoadIdentity() { getMatrix().setIdentity(); } + public static final void glViewport(int p1, int p2, int p3, int p4) { _wglViewport(p1, p2, p3, p4); } + public static final void glClear(int p1) { _wglClear(p1); } + public static final void glOrtho(float left, float right, float bottom, float top, float zNear, float zFar) { Matrix4f res = getMatrix(); res.m00 = 2.0f / (right - left); - res.m01 = 0.0f; - res.m02 = 0.0f; - res.m03 = 0.0f; - res.m10 = 0.0f; - res.m11 = 2.0f / (top - bottom); - res.m12 = 0.0f; - res.m13 = 0.0f; - res.m20 = 0.0f; - res.m21 = 0.0f; - res.m22 = 2.0f / (zFar - zNear); - res.m23 = 0.0f; - res.m30 = -(right + left) / (right - left); - res.m31 = -(top + bottom) / (top - bottom); - res.m32 = (zFar + zNear) / (zFar - zNear); - res.m33 = 1.0f; + res.m01 = 0.0f; + res.m02 = 0.0f; + res.m03 = 0.0f; + res.m10 = 0.0f; + res.m11 = 2.0f / (top - bottom); + res.m12 = 0.0f; + res.m13 = 0.0f; + res.m20 = 0.0f; + res.m21 = 0.0f; + res.m22 = 2.0f / (zFar - zNear); + res.m23 = 0.0f; + res.m30 = -(right + left) / (right - left); + res.m31 = -(top + bottom) / (top - bottom); + res.m32 = (zFar + zNear) / (zFar - zNear); + res.m33 = 1.0f; } + private static final Vector3f deevis = new Vector3f(); + public static final void glTranslatef(float p1, float p2, float p3) { deevis.set(p1, p2, p3); getMatrix().translate(deevis); - if(isCompilingDisplayList) { + if (isCompilingDisplayList) { System.err.println("matrix is not supported while recording display list use tessellator class instead"); } } + public static final void glClearColor(float p1, float p2, float p3, float p4) { _wglClearColor(p1, p2, p3, p4); } + public static final void glDisable(int p1) { - switch(p1) { + switch (p1) { case GL_DEPTH_TEST: _wglDisable(_wGL_DEPTH_TEST); break; @@ -406,10 +431,10 @@ public class EaglerAdapterGL30 extends EaglerAdapterImpl2 { case GL_RESCALE_NORMAL: break; case GL_TEXTURE_2D: - if(selectedTex == 0) { + if (selectedTex == 0) { enableTexture2D = false; } - if(selectedTex == 1) { + if (selectedTex == 1) { enableTexture2D_1 = false; } break; @@ -441,48 +466,62 @@ public class EaglerAdapterGL30 extends EaglerAdapterImpl2 { break; } } + public static final void glColor4f(float p1, float p2, float p3, float p4) { colorR = p1; colorG = p2; colorB = p3; colorA = p4; } + public static final int glGetError() { int err = _wglGetError(); - if(err == _wGL_CONTEXT_LOST_WEBGL) return GL_CONTEXT_LOST_WEBGL; + if (err == _wGL_CONTEXT_LOST_WEBGL) + return GL_CONTEXT_LOST_WEBGL; return err; } + public static final void glFlush() { EaglerAdapter._wglFlush(); } + public static final void glLineWidth(float p1) { - + } - public static final void glTexImage2D(int p1, int p2, int p3, int p4, int p5, int p6, int p7, int p8, ByteBuffer p9) { - if(p2 == 0 && selectedTex == 0 && boundTexture0 != null) { + + public static final void glTexImage2D(int p1, int p2, int p3, int p4, int p5, int p6, int p7, int p8, + ByteBuffer p9) { + if (p2 == 0 && selectedTex == 0 && boundTexture0 != null) { boundTexture0.w = p4; boundTexture0.h = p5; } _wglTexImage2D(_wGL_TEXTURE_2D, p2, _wGL_RGBA8, p4, p5, p6, _wGL_RGBA, _wGL_UNSIGNED_BYTE, p9); } + public static final void glLight(int p1, int p2, FloatBuffer p3) { - + } + public static final void glLightModel(int p1, FloatBuffer p2) { - + } + private static Vector4f lightPos0vec0 = new Vector4f(); private static Vector4f lightPos1vec0 = new Vector4f(); private static Vector4f lightPos0vec = new Vector4f(); private static Vector4f lightPos1vec = new Vector4f(); + public static final void copyModelToLightMatrix() { lightPos0vec0.set(lightPos0vec); lightPos1vec0.set(lightPos1vec); - lightPos0vec.set(0.2f, 1.0f, -0.7f, 0.0f); lightPos0vec.normalise(); - lightPos1vec.set(-0.2f, 1.0f, 0.7f, 0.0f); lightPos1vec.normalise(); + lightPos0vec.set(0.2f, 1.0f, -0.7f, 0.0f); + lightPos0vec.normalise(); + lightPos1vec.set(-0.2f, 1.0f, 0.7f, 0.0f); + lightPos1vec.normalise(); Matrix4f.transform(matModelV[matModelPointer], lightPos0vec, lightPos0vec).normalise(); Matrix4f.transform(matModelV[matModelPointer], lightPos1vec, lightPos1vec).normalise(); } + public static final void flipLightMatrix() { lightPos0vec.x = -lightPos0vec.x; lightPos1vec.x = -lightPos1vec.x; @@ -491,78 +530,85 @@ public class EaglerAdapterGL30 extends EaglerAdapterImpl2 { lightPos0vec.z = -lightPos0vec.z; lightPos1vec.z = -lightPos1vec.z; } + public static final void revertLightMatrix() { lightPos0vec.set(lightPos0vec0); lightPos1vec.set(lightPos1vec0); } + public static final void glPushMatrix() { - switch(matrixMode) { + switch (matrixMode) { case GL_MODELVIEW: default: - if(matModelPointer < matModelV.length - 1) { + if (matModelPointer < matModelV.length - 1) { ++matModelPointer; matModelV[matModelPointer].load(matModelV[matModelPointer - 1]); - }else { + } else { System.err.println("modelview matrix stack overflow"); } break; case GL_PROJECTION: - if(matProjPointer < matProjV.length - 1) { + if (matProjPointer < matProjV.length - 1) { ++matProjPointer; matProjV[matProjPointer].load(matProjV[matProjPointer - 1]); - }else { + } else { System.err.println("projection matrix stack overflow"); } break; case GL_TEXTURE: - if(matTexPointer < matTexV.length - 1) { + if (matTexPointer < matTexV.length - 1) { ++matTexPointer; matTexV[matTexPointer].load(matTexV[matTexPointer - 1]); - }else { + } else { System.err.println("texture matrix stack overflow"); } break; } } + private static final float toRad = 0.0174532925f; + public static final void glRotatef(float p1, float p2, float p3, float p4) { deevis.set(p2, p3, p4); getMatrix().rotate(p1 * toRad, deevis); - if(isCompilingDisplayList) { + if (isCompilingDisplayList) { System.err.println("matrix is not supported while recording display list use tessellator class instead"); } } + public static final void glPopMatrix() { - switch(matrixMode) { + switch (matrixMode) { case GL_MODELVIEW: default: - if(matModelPointer > 0) { + if (matModelPointer > 0) { --matModelPointer; - }else { + } else { System.err.println("modelview matrix stack underflow"); } break; case GL_PROJECTION: - if(matProjPointer > 0) { + if (matProjPointer > 0) { --matProjPointer; - }else { + } else { System.err.println("projection matrix stack underflow"); } break; case GL_TEXTURE: - if(matTexPointer > 0) { + if (matTexPointer > 0) { --matTexPointer; - }else { + } else { System.err.println("texture matrix stack underflow"); } break; } } + public static final void glColorMaterial(int p1, int p2) { - + } + public static final void glGetFloat(int p1, FloatBuffer p2) { - switch(p1) { + switch (p1) { case GL_MODELVIEW_MATRIX: default: matModelV[matModelPointer].store(p2); @@ -572,93 +618,111 @@ public class EaglerAdapterGL30 extends EaglerAdapterImpl2 { break; } } + public static final void glGetInteger(int p1, int[] p2) { - if(p1 == GL_VIEWPORT) { + if (p1 == GL_VIEWPORT) { _wglGetParameter(_wGL_VIEWPORT, 4, p2); } } + public static final void glScalef(float p1, float p2, float p3) { deevis.set(p1, p2, p3); getMatrix().scale(deevis); - if(isCompilingDisplayList) { + if (isCompilingDisplayList) { System.err.println("matrix is not supported while recording display list use tessellator class instead"); } } + private static final Matrix4f tmpMat = new Matrix4f(); + public static final void glMultMatrixf(Matrix4f mat) { getMatrix().load(Matrix4f.mul(getMatrix(), mat, tmpMat)); } + public static final void glBlendFunc(int p1, int p2) { fogPremultiply = (p1 == GL_ONE && p2 == GL_ONE_MINUS_SRC_ALPHA); _wglBlendFunc(p1, p2); } + public static final void glDepthMask(boolean p1) { _wglDepthMask(p1); } + public static final void glColorMask(boolean p1, boolean p2, boolean p3, boolean p4) { _wglColorMask(p1, p2, p3, p4); } + private static final void updateAnisotropicPatch() { - if(selectedTex == 0) { + if (selectedTex == 0) { enableAnisotropicFix = false; - if(enableAnisotropicPatch && boundTexture0 != null && boundTexture0.anisotropic && boundTexture0.nearest) { + if (enableAnisotropicPatch && boundTexture0 != null && boundTexture0.anisotropic && boundTexture0.nearest) { enableAnisotropicFix = true; anisotropicFixX = boundTexture0.w; anisotropicFixY = boundTexture0.h; } } } + public static final void glBindTexture(int p1, int p2) { TextureGL t = texObjects.get(p2); _wglBindTexture(_wGL_TEXTURE_2D, t); - if(selectedTex == 0) { + if (selectedTex == 0) { boundTexture0 = t; updateAnisotropicPatch(); } } + public static final void glCopyTexSubImage2D(int p1, int p2, int p3, int p4, int p5, int p6, int p7, int p8) { _wglCopyTexSubImage2D(_wGL_TEXTURE_2D, p2, p3, p4, p5, p6, p7, p8); } + public static final void glTexParameteri(int p1, int p2, int p3) { - if(selectedTex == 0 && boundTexture0 != null && p2 == GL_TEXTURE_MAG_FILTER) { + if (selectedTex == 0 && boundTexture0 != null && p2 == GL_TEXTURE_MAG_FILTER) { boundTexture0.nearest = p3 == GL_NEAREST; } _wglTexParameteri(p1, p2, p3); updateAnisotropicPatch(); } + public static final void glTexParameterf(int p1, int p2, float p3) { - if(selectedTex == 0 && boundTexture0 != null && p2 == GL_TEXTURE_MAX_ANISOTROPY) { + if (selectedTex == 0 && boundTexture0 != null && p2 == GL_TEXTURE_MAX_ANISOTROPY) { boundTexture0.anisotropic = p3 > 1.0f; } _wglTexParameterf(p1, p2 == GL_TEXTURE_MAX_ANISOTROPY ? _wGL_TEXTURE_MAX_ANISOTROPY : p2, p3); updateAnisotropicPatch(); } + public static final void glLogicOp(int p1) { - + } + public static final void glNormal3f(float p1, float p2, float p3) { float len = (float) Math.sqrt(p1 * p1 + p2 * p2 + p3 * p3); normalX = p1 / len; normalY = p2 / len; normalZ = p3 / len; } + public static final int glGenLists(int p1) { int base = displayListId + 1; - for(int i = 0; i < p1; i++) { + for (int i = 0; i < p1; i++) { int id = ++displayListId; displayLists.put(id, new DisplayList(id)); } return base; } + public static final void _wglBindVertexArray0(BufferArrayGL p1) { currentArray = p1; _wglBindVertexArray(p1); } + private static int displayListId = 0; + public static final void glCallList(int p1) { - if(!isCompilingDisplayList) { + if (!isCompilingDisplayList) { DisplayList d = displayListsInitialized.get(p1); - if(d != null && d.listLength > 0) { + if (d != null && d.listLength > 0) { bindTheShader(d.shaderMode | getShaderModeFlag1()); _wglBindVertexArray0(d.glarray); _wglDrawQuadArrays(0, d.listLength); @@ -668,23 +732,25 @@ public class EaglerAdapterGL30 extends EaglerAdapterImpl2 { } } } + public static final void glNewList(int p1, int p2) { - if(!isCompilingDisplayList) { + if (!isCompilingDisplayList) { compilingDisplayList = displayLists.get(p1); - if(compilingDisplayList != null) { + if (compilingDisplayList != null) { compilingDisplayList.shaderMode = -1; compilingDisplayList.listLength = 0; isCompilingDisplayList = true; } } } + public static final void glEndList() { - if(isCompilingDisplayList) { + if (isCompilingDisplayList) { isCompilingDisplayList = false; Object upload = _wGetLowLevelBuffersAppended(); int l = _wArrayByteLength(upload); - if(l > 0) { - if(compilingDisplayList.glbuffer == null) { + if (l > 0) { + if (compilingDisplayList.glbuffer == null) { displayListsInitialized.put(compilingDisplayList.id, compilingDisplayList); compilingDisplayList.glarray = _wglCreateVertexArray(); compilingDisplayList.glbuffer = _wglCreateBuffer(); @@ -699,26 +765,30 @@ public class EaglerAdapterGL30 extends EaglerAdapterImpl2 { } } } + public static final HighPolyMesh loadMesh(String path) { try { return HighPolyMesh.loadMeshData(EaglerAdapter.loadResourceBytes(path)); - }catch(IOException ex) { + } catch (IOException ex) { System.err.println("Could not load HighPolyMesh! " + ex.toString()); ex.printStackTrace(); return null; } } + public static final void glColor3f(float p1, float p2, float p3) { colorR = p1; colorG = p2; colorB = p3; colorA = 1.0f; } + public static final void glTexGeni(int p1, int p2, int p3) { - + } + public static final void glTexGen(int p1, int p2, FloatBuffer p3) { - switch(p1) { + switch (p1) { case GL_S: texS_plane = (p2 == GL_EYE_PLANE ? 1 : 0); texS_X = p3.get(); @@ -749,69 +819,68 @@ public class EaglerAdapterGL30 extends EaglerAdapterImpl2 { break; } } - public static final void glTexImage2D(int p1, int p2, int p3, int p4, int p5, int p6, int p7, int p8, IntBuffer p9) { + + public static final void glTexImage2D(int p1, int p2, int p3, int p4, int p5, int p6, int p7, int p8, + IntBuffer p9) { /* - int pp2 = 0; - switch(p3) { - default: - case GL_RGBA: pp2 = _wGL_RGBA; break; - case GL_BGRA: pp2 = _wGL_BGRA; break; - } - int pp3 = 0; - switch(p7) { - default: - case GL_RGBA: pp3 = _wGL_RGBA; break; - case GL_BGRA: pp3 = _wGL_BGRA; break; - } - */ - if(p2 == 0 && selectedTex == 0 && boundTexture0 != null) { + * int pp2 = 0; switch(p3) { default: case GL_RGBA: pp2 = _wGL_RGBA; break; case + * GL_BGRA: pp2 = _wGL_BGRA; break; } int pp3 = 0; switch(p7) { default: case + * GL_RGBA: pp3 = _wGL_RGBA; break; case GL_BGRA: pp3 = _wGL_BGRA; break; } + */ + if (p2 == 0 && selectedTex == 0 && boundTexture0 != null) { boundTexture0.w = p4; boundTexture0.h = p5; } - bytesUploaded += p9.remaining()*4; + bytesUploaded += p9.remaining() * 4; _wglTexImage2D(_wGL_TEXTURE_2D, p2, _wGL_RGBA8, p4, p5, p6, _wGL_RGBA, _wGL_UNSIGNED_BYTE, p9); updateAnisotropicPatch(); } - public static final void glTexImage2D_2(int p1, int p2, int p3, int p4, int p5, int p6, int p7, int p8, IntBuffer p9) { - if(p2 == 0 && selectedTex == 0 && boundTexture0 != null) { + + public static final void glTexImage2D_2(int p1, int p2, int p3, int p4, int p5, int p6, int p7, int p8, + IntBuffer p9) { + if (p2 == 0 && selectedTex == 0 && boundTexture0 != null) { boundTexture0.w = p4; boundTexture0.h = p5; } - bytesUploaded += p9.remaining()*4; + bytesUploaded += p9.remaining() * 4; _wglTexImage2D(_wGL_TEXTURE_2D, p2, _wGL_RGB8, p4, p5, p6, _wGL_RGB, _wGL_UNSIGNED_BYTE, p9); updateAnisotropicPatch(); } - public static final void glTexSubImage2D(int p1, int p2, int p3, int p4, int p5, int p6, int p7, int p8, IntBuffer p9) { + + public static final void glTexSubImage2D(int p1, int p2, int p3, int p4, int p5, int p6, int p7, int p8, + IntBuffer p9) { int pp1 = 0; - switch(p1) { + switch (p1) { default: - case GL_TEXTURE_2D: pp1 = _wGL_TEXTURE_2D; break; - //case GL_TEXTURE_3D: pp1 = _wGL_TEXTURE_3D; break; + case GL_TEXTURE_2D: + pp1 = _wGL_TEXTURE_2D; + break; + // case GL_TEXTURE_3D: pp1 = _wGL_TEXTURE_3D; break; } /* - int pp3 = 0; - switch(p7) { - default: - case GL_RGBA: pp3 = _wGL_RGBA; break; - case GL_BGRA: pp3 = _wGL_BGRA; break; - } - */ - bytesUploaded += p9.remaining()*4; + * int pp3 = 0; switch(p7) { default: case GL_RGBA: pp3 = _wGL_RGBA; break; case + * GL_BGRA: pp3 = _wGL_BGRA; break; } + */ + bytesUploaded += p9.remaining() * 4; _wglTexSubImage2D(pp1, p2, p3, p4, p5, p6, _wGL_RGBA, _wGL_UNSIGNED_BYTE, p9); } + public static final void glDeleteTextures(int p1) { _wglDeleteTextures(texObjects.free(p1)); } + public static final void glPolygonOffset(float p1, float p2) { _wglPolygonOffset(p1, p2); } + public static final void glCallLists(IntBuffer p1) { - while(p1.hasRemaining()) { + while (p1.hasRemaining()) { glCallList(p1.get()); } } + public static final void glEnableVertexAttrib(int p1) { - switch(p1) { + switch (p1) { case GL_COLOR_ARRAY: enableColorArray = true; break; @@ -819,7 +888,7 @@ public class EaglerAdapterGL30 extends EaglerAdapterImpl2 { enableNormalArray = true; break; case GL_TEXTURE_COORD_ARRAY: - switch(selectedClientTex) { + switch (selectedClientTex) { case 0: enableTex0Array = true; break; @@ -834,8 +903,9 @@ public class EaglerAdapterGL30 extends EaglerAdapterImpl2 { break; } } + public static final void glDisableVertexAttrib(int p1) { - switch(p1) { + switch (p1) { case GL_COLOR_ARRAY: enableColorArray = false; break; @@ -843,7 +913,7 @@ public class EaglerAdapterGL30 extends EaglerAdapterImpl2 { enableNormalArray = false; break; case GL_TEXTURE_COORD_ARRAY: - switch(selectedClientTex) { + switch (selectedClientTex) { case 0: enableTex0Array = false; break; @@ -858,9 +928,11 @@ public class EaglerAdapterGL30 extends EaglerAdapterImpl2 { break; } } + public static final void hintAnisotropicFix(boolean hint) { hintAnisotropicPatch = hint; } + private static final int getShaderModeFlag0() { int mode = 0; mode = (mode | (enableColorArray ? FixedFunctionShader.COLOR : 0)); @@ -869,6 +941,7 @@ public class EaglerAdapterGL30 extends EaglerAdapterImpl2 { mode = (mode | (enableTex1Array ? FixedFunctionShader.TEXTURE1 : 0)); return mode; } + private static final int getShaderModeFlag1() { int mode = 0; mode = (mode | (enableTexGen ? FixedFunctionShader.TEXGEN : 0)); @@ -877,10 +950,13 @@ public class EaglerAdapterGL30 extends EaglerAdapterImpl2 { mode = (mode | (enableAlphaTest ? FixedFunctionShader.ALPHATEST : 0)); mode = (mode | (enableTexture2D ? FixedFunctionShader.UNIT0 : 0)); mode = (mode | (enableTexture2D_1 ? FixedFunctionShader.UNIT1 : 0)); - mode = (mode | ((enableTexture2D && (enableAnisotropicFix || (hintAnisotropicPatch && enableAnisotropicPatch))) ? FixedFunctionShader.FIX_ANISOTROPIC : 0)); + mode = (mode | ((enableTexture2D && (enableAnisotropicFix || (hintAnisotropicPatch && enableAnisotropicPatch))) + ? FixedFunctionShader.FIX_ANISOTROPIC + : 0)); mode = (mode | (swapRB ? FixedFunctionShader.SWAP_RB : 0)); return mode; } + private static final int getShaderModeFlag() { int mode = 0; mode = (mode | (enableColorArray ? FixedFunctionShader.COLOR : 0)); @@ -893,22 +969,27 @@ public class EaglerAdapterGL30 extends EaglerAdapterImpl2 { mode = (mode | (enableAlphaTest ? FixedFunctionShader.ALPHATEST : 0)); mode = (mode | (enableTexture2D ? FixedFunctionShader.UNIT0 : 0)); mode = (mode | (enableTexture2D_1 ? FixedFunctionShader.UNIT1 : 0)); - mode = (mode | ((enableTexture2D && (enableAnisotropicFix || (hintAnisotropicPatch && enableAnisotropicPatch))) ? FixedFunctionShader.FIX_ANISOTROPIC : 0)); + mode = (mode | ((enableTexture2D && (enableAnisotropicFix || (hintAnisotropicPatch && enableAnisotropicPatch))) + ? FixedFunctionShader.FIX_ANISOTROPIC + : 0)); mode = (mode | (swapRB ? FixedFunctionShader.SWAP_RB : 0)); return mode; } + private static FixedFunctionShader shader = null; + private static final void bindTheShader() { bindTheShader(getShaderModeFlag()); } + private static final void bindTheShader(int mode) { FixedFunctionShader s = shader = FixedFunctionShader.instance(mode); s.useProgram(); - if(enableAlphaTest) { + if (enableAlphaTest) { s.setAlphaTest(alphaThresh); } s.setColor(colorR, colorG, colorB, colorA); - if(fogEnabled) { + if (fogEnabled) { s.setFogMode((fogPremultiply ? 2 : 0) + fogMode); s.setFogColor(fogColorR, fogColorG, fogColorB, fogColorA); s.setFogDensity(fogDensity); @@ -917,64 +998,68 @@ public class EaglerAdapterGL30 extends EaglerAdapterImpl2 { s.setModelMatrix(matModelV[matModelPointer]); s.setProjectionMatrix(matProjV[matProjPointer]); s.setTextureMatrix(matTexV[matTexPointer]); - if(enableColorMaterial && enableLighting) { + if (enableColorMaterial && enableLighting) { s.setNormal(normalX, normalY, normalZ); s.setLightPositions(lightPos0vec, lightPos1vec); } s.setTex0Coords(tex0X, tex0Y); s.setTex1Coords(tex1X, tex1Y); - if(enableTexGen) { + if (enableTexGen) { s.setTexGenS(texS_plane, texS_X, texS_Y, texS_Z, texS_W); s.setTexGenT(texT_plane, texT_X, texT_Y, texT_Z, texT_W); s.setTexGenR(texR_plane, texR_X, texR_Y, texR_Z, texR_W); s.setTexGenQ(texQ_plane, texQ_X, texQ_Y, texQ_Z, texQ_W); } - if(enableAnisotropicFix) { + if (enableAnisotropicFix) { s.setAnisotropicFix(anisotropicFixX, anisotropicFixY); } } + public static final void drawHighPoly(HighPolyMesh msh) { - bindTheShader((msh.hasTexture ? (FixedFunctionShader.NORMAL | FixedFunctionShader.TEXTURE0) : FixedFunctionShader.NORMAL) | getShaderModeFlag1()); + bindTheShader((msh.hasTexture ? (FixedFunctionShader.NORMAL | FixedFunctionShader.TEXTURE0) + : FixedFunctionShader.NORMAL) | getShaderModeFlag1()); _wglBindVertexArray(msh.vertexArray); _wglDrawElements(_wGL_TRIANGLES, msh.indexCount, _wGL_UNSIGNED_SHORT, 0); triangleDrawn += msh.indexCount / 3; shader.unuseProgram(); } + private static Object blankUploadArray = _wCreateLowLevelIntBuffer(525000); + public static final void glDrawArrays(int p1, int p2, int p3, Object buffer) { - if(isCompilingDisplayList) { - if(p1 == GL_QUADS) { - if(compilingDisplayList.shaderMode == -1) { + if (isCompilingDisplayList) { + if (p1 == GL_QUADS) { + if (compilingDisplayList.shaderMode == -1) { compilingDisplayList.shaderMode = getShaderModeFlag0(); - }else { - if(compilingDisplayList.shaderMode != getShaderModeFlag0()) { + } else { + if (compilingDisplayList.shaderMode != getShaderModeFlag0()) { System.err.println("vertex format inconsistent in display list"); } } compilingDisplayList.listLength += p3; _wAppendLowLevelBuffer(buffer); - }else { + } else { System.err.println("only GL_QUADS supported in a display list"); } - }else { + } else { bytesUploaded += _wArrayByteLength(buffer); vertexDrawn += p3; - + bindTheShader(); - + _wglBindVertexArray0(shader.genericArray); _wglBindBuffer(_wGL_ARRAY_BUFFER, shader.genericBuffer); - if(!shader.bufferIsInitialized) { + if (!shader.bufferIsInitialized) { shader.bufferIsInitialized = true; _wglBufferData(_wGL_ARRAY_BUFFER, blankUploadArray, _wGL_DYNAMIC_DRAW); } _wglBufferSubData(_wGL_ARRAY_BUFFER, 0, buffer); - - if(p1 == GL_QUADS) { + + if (p1 == GL_QUADS) { _wglDrawQuadArrays(p2, p3); triangleDrawn += p3 / 2; - }else { - switch(p1) { + } else { + switch (p1) { default: case GL_TRIANGLES: triangleDrawn += p3 / 3; @@ -994,16 +1079,17 @@ public class EaglerAdapterGL30 extends EaglerAdapterImpl2 { } _wglDrawArrays(p1, p2, p3); } - + shader.unuseProgram(); - + } } - + private static final void _wglDrawQuadArrays(int p2, int p3) { - if(quadsToTrianglesBuffer == null) { - IntBuffer upload = isWebGL ? IntBuffer.wrap(new int[98400 / 2]) : ByteBuffer.allocateDirect(98400 * 2).order(ByteOrder.nativeOrder()).asIntBuffer(); - for(int i = 0; i < 16384; ++i) { + if (quadsToTrianglesBuffer == null) { + IntBuffer upload = isWebGL ? IntBuffer.wrap(new int[98400 / 2]) + : ByteBuffer.allocateDirect(98400 * 2).order(ByteOrder.nativeOrder()).asIntBuffer(); + for (int i = 0; i < 16384; ++i) { int v1 = i * 4; int v2 = i * 4 + 1; int v3 = i * 4 + 2; @@ -1017,56 +1103,60 @@ public class EaglerAdapterGL30 extends EaglerAdapterImpl2 { _wglBindBuffer(_wGL_ELEMENT_ARRAY_BUFFER, quadsToTrianglesBuffer); _wglBufferData0(_wGL_ELEMENT_ARRAY_BUFFER, upload, _wGL_STATIC_DRAW); } - if(!currentArray.isQuadBufferBound) { + if (!currentArray.isQuadBufferBound) { currentArray.isQuadBufferBound = true; _wglBindBuffer(_wGL_ELEMENT_ARRAY_BUFFER, quadsToTrianglesBuffer); } _wglDrawElements(_wGL_TRIANGLES, p3 * 6 / 4, _wGL_UNSIGNED_SHORT, p2 * 6 / 4); } - private static BufferArrayGL occlusion_vao = null; private static BufferGL occlusion_vbo = null; private static ProgramGL occlusion_program = null; private static UniformGL occlusion_matrix_m = null; private static UniformGL occlusion_matrix_p = null; - + private static final void initializeOcclusionObjects() { occlusion_vao = _wglCreateVertexArray(); occlusion_vbo = _wglCreateBuffer(); - IntBuffer upload = (isWebGL ? IntBuffer.wrap(new int[108]) : ByteBuffer.allocateDirect(108 << 2).order(ByteOrder.nativeOrder()).asIntBuffer()); - float[] verts = new float[] { - 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 1.0f, 0.0f, 1.0f, 1.0f, 1.0f, 1.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 1.0f, 0.0f, 1.0f, 0.0f, 1.0f, 0.0f, 0.0f, 0.0f, 1.0f, 0.0f, 0.0f, 1.0f, 1.0f, 0.0f, 1.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, - 0.0f, 0.0f, 0.0f, 1.0f, 1.0f, 0.0f, 1.0f, 0.0f, 1.0f, 0.0f, 1.0f, 0.0f, 0.0f, 1.0f, 0.0f, 0.0f, 0.0f, 0.0f, 1.0f, 1.0f, 0.0f, 0.0f, 1.0f, 1.0f, 0.0f, 1.0f, 1.0f, 1.0f, 1.0f, 1.0f, 0.0f, 0.0f, 1.0f, 1.0f, 0.0f, 1.0f, 0.0f, - 0.0f, 1.0f, 1.0f, 1.0f, 1.0f, 0.0f, 1.0f, 1.0f, 1.0f, 1.0f, 1.0f, 1.0f, 0.0f, 0.0f, 1.0f, 0.0f, 1.0f, 1.0f, 1.0f, 0.0f, 1.0f, 0.0f, 0.0f, 1.0f, 1.0f, 1.0f, 1.0f, 1.0f, 0.0f, 1.0f, 1.0f, 1.0f, 0.0f, 1.0f - }; - for(int i = 0; i < verts.length; i++) { - upload.put(Float.floatToRawIntBits(verts[i])); - } + IntBuffer upload = (isWebGL ? IntBuffer.wrap(new int[108]) + : ByteBuffer.allocateDirect(108 << 2).order(ByteOrder.nativeOrder()).asIntBuffer()); + float[] verts = new float[] { 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 1.0f, 0.0f, 1.0f, 1.0f, 1.0f, 1.0f, 0.0f, 0.0f, + 0.0f, 0.0f, 0.0f, 1.0f, 0.0f, 1.0f, 0.0f, 1.0f, 0.0f, 0.0f, 0.0f, 1.0f, 0.0f, 0.0f, 1.0f, 1.0f, 0.0f, + 1.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 0.0f, 1.0f, 1.0f, 0.0f, 1.0f, 0.0f, 1.0f, 0.0f, + 1.0f, 0.0f, 0.0f, 1.0f, 0.0f, 0.0f, 0.0f, 0.0f, 1.0f, 1.0f, 0.0f, 0.0f, 1.0f, 1.0f, 0.0f, 1.0f, 1.0f, + 1.0f, 1.0f, 1.0f, 0.0f, 0.0f, 1.0f, 1.0f, 0.0f, 1.0f, 0.0f, 0.0f, 1.0f, 1.0f, 1.0f, 1.0f, 0.0f, 1.0f, + 1.0f, 1.0f, 1.0f, 1.0f, 1.0f, 0.0f, 0.0f, 1.0f, 0.0f, 1.0f, 1.0f, 1.0f, 0.0f, 1.0f, 0.0f, 0.0f, 1.0f, + 1.0f, 1.0f, 1.0f, 1.0f, 0.0f, 1.0f, 1.0f, 1.0f, 0.0f, 1.0f }; + for (int i = 0; i < verts.length; i++) { + upload.put(Float.floatToRawIntBits(verts[i])); + } upload.flip(); - + _wglBindVertexArray(occlusion_vao); _wglBindBuffer(_wGL_ARRAY_BUFFER, occlusion_vbo); _wglBufferData0(_wGL_ARRAY_BUFFER, upload, _wGL_STATIC_DRAW); _wglEnableVertexAttribArray(0); _wglVertexAttribPointer(0, 3, _wGL_FLOAT, false, 12, 0); - + ShaderGL vert = _wglCreateShader(_wGL_VERTEX_SHADER); ShaderGL frag = _wglCreateShader(_wGL_FRAGMENT_SHADER); - + String src = fileContents("/glsl/occl.glsl"); _wglShaderSource(vert, _wgetShaderHeader() + "\n#define CC_VERT\n" + src); _wglShaderSource(frag, _wgetShaderHeader() + "\n#define CC_FRAG\n" + src); _wglCompileShader(vert); - if (!_wglGetShaderCompiled(vert)) System.err.println(("\n" + _wglGetShaderInfoLog(vert)).replace("\n", "\n[/glsl/occl.glsl][VERT] ") + "\n"); - + if (!_wglGetShaderCompiled(vert)) + System.err.println(("\n" + _wglGetShaderInfoLog(vert)).replace("\n", "\n[/glsl/occl.glsl][VERT] ") + "\n"); + _wglCompileShader(frag); - if (!_wglGetShaderCompiled(frag)) System.err.println(("\n" + _wglGetShaderInfoLog(frag)).replace("\n", "\n[/glsl/occl.glsl][FRAG] ") + "\n"); - + if (!_wglGetShaderCompiled(frag)) + System.err.println(("\n" + _wglGetShaderInfoLog(frag)).replace("\n", "\n[/glsl/occl.glsl][FRAG] ") + "\n"); + occlusion_program = _wglCreateProgram(); - + _wglAttachShader(occlusion_program, vert); _wglAttachShader(occlusion_program, frag); _wglLinkProgram(occlusion_program); @@ -1074,15 +1164,17 @@ public class EaglerAdapterGL30 extends EaglerAdapterImpl2 { _wglDetachShader(occlusion_program, frag); _wglDeleteShader(vert); _wglDeleteShader(frag); - - if(!_wglGetProgramLinked(occlusion_program)) System.err.println(("\n\n"+_wglGetProgramInfoLog(occlusion_program)).replace("\n", "\n[/glsl/occl.glsl][LINKER] ")); - + + if (!_wglGetProgramLinked(occlusion_program)) + System.err.println( + ("\n\n" + _wglGetProgramInfoLog(occlusion_program)).replace("\n", "\n[/glsl/occl.glsl][LINKER] ")); + _wglUseProgram(occlusion_program); occlusion_matrix_m = _wglGetUniformLocation(occlusion_program, "matrix_m"); occlusion_matrix_p = _wglGetUniformLocation(occlusion_program, "matrix_p"); - + } - + private static final GLObjectMap queryObjs = new GLObjectMap(256); public static final int glCreateQuery() { @@ -1092,31 +1184,33 @@ public class EaglerAdapterGL30 extends EaglerAdapterImpl2 { public static final void glBeginQuery(int obj) { _wglBeginQuery(_wGL_ANY_SAMPLES_PASSED, queryObjs.get(obj)); } - + public static final void glDeleteQuery(int obj) { _wglDeleteQuery(queryObjs.free(obj)); } - + private static final Matrix4f cachedOcclusionP = (Matrix4f) (new Matrix4f()).setZero(); private static float[] occlusionModel = new float[16]; private static float[] occlusionProj = new float[16]; - + public static final void glBindOcclusionBB() { - if(occlusion_vao == null) initializeOcclusionObjects(); + if (occlusion_vao == null) + initializeOcclusionObjects(); _wglUseProgram(occlusion_program); _wglBindVertexArray(occlusion_vao); - if(!cachedOcclusionP.equals(matProjV[matProjPointer])) { + if (!cachedOcclusionP.equals(matProjV[matProjPointer])) { cachedOcclusionP.load(matProjV[matProjPointer]); cachedOcclusionP.store(occlusionProj); _wglUniformMat4fv(occlusion_matrix_p, occlusionProj); } } - + public static final void glEndOcclusionBB() { - + } - - public static final void glDrawOcclusionBB(float posX, float posY, float posZ, float sizeX, float sizeY, float sizeZ) { + + public static final void glDrawOcclusionBB(float posX, float posY, float posZ, float sizeX, float sizeY, + float sizeZ) { glPushMatrix(); glTranslatef(posX - sizeX * 0.01f, posY - sizeY * 0.01f, posZ - sizeZ * 0.01f); glScalef(sizeX * 1.02f, sizeY * 1.02f, sizeZ * 1.02f); @@ -1124,18 +1218,18 @@ public class EaglerAdapterGL30 extends EaglerAdapterImpl2 { _wglUniformMat4fv(occlusion_matrix_m, occlusionModel); _wglDrawArrays(_wGL_TRIANGLES, 0, 36); glPopMatrix(); - + } - + public static final void glEndQuery() { _wglEndQuery(_wGL_ANY_SAMPLES_PASSED); } - + public static final boolean glGetQueryResult(int obj) { QueryGL q = queryObjs.get(obj); return _wglGetQueryObjecti(q, _wGL_QUERY_RESULT) > 0; } - + public static final boolean glGetQueryResultAvailable(int obj) { QueryGL q = queryObjs.get(obj); return _wglGetQueryObjecti(q, _wGL_QUERY_RESULT_AVAILABLE) >= 0; @@ -1144,27 +1238,28 @@ public class EaglerAdapterGL30 extends EaglerAdapterImpl2 { public static final int glGenTextures() { return texObjects.register(_wglGenTextures()); } - public static final void glTexSubImage2D(int p1, int p2, int p3, int p4, int p5, int p6, int p7, int p8, ByteBuffer p9) { + + public static final void glTexSubImage2D(int p1, int p2, int p3, int p4, int p5, int p6, int p7, int p8, + ByteBuffer p9) { int pp1 = 0; - switch(p1) { + switch (p1) { default: - case GL_TEXTURE_2D: pp1 = _wGL_TEXTURE_2D; break; - //case GL_TEXTURE_3D: pp1 = _wGL_TEXTURE_3D; break; + case GL_TEXTURE_2D: + pp1 = _wGL_TEXTURE_2D; + break; + // case GL_TEXTURE_3D: pp1 = _wGL_TEXTURE_3D; break; } /* - int pp3 = 0; - switch(p7) { - default: - case GL_RGBA: pp3 = _wGL_RGBA; break; - case GL_BGRA: pp3 = _wGL_BGRA; break; - } - */ + * int pp3 = 0; switch(p7) { default: case GL_RGBA: pp3 = _wGL_RGBA; break; case + * GL_BGRA: pp3 = _wGL_BGRA; break; } + */ bytesUploaded += p9.remaining(); _wglTexSubImage2D(pp1, p2, p3, p4, p5, p6, _wGL_RGBA, _wGL_UNSIGNED_BYTE, p9); } + public static final void glFogi(int p1, int p2) { - if(p1 == GL_FOG_MODE) { - switch(p2) { + if (p1 == GL_FOG_MODE) { + switch (p2) { default: case GL_LINEAR: fogMode = 1; @@ -1175,8 +1270,9 @@ public class EaglerAdapterGL30 extends EaglerAdapterImpl2 { } } } + public static final void glFogf(int p1, float p2) { - switch(p1) { + switch (p1) { case GL_FOG_START: fogStart = p2; break; @@ -1190,26 +1286,29 @@ public class EaglerAdapterGL30 extends EaglerAdapterImpl2 { break; } } + public static final void glFog(int p1, FloatBuffer p2) { - if(p1 == GL_FOG_COLOR) { + if (p1 == GL_FOG_COLOR) { fogColorR = p2.get(); fogColorG = p2.get(); fogColorB = p2.get(); fogColorA = p2.get(); } } + public static final void glDeleteLists(int p1, int p2) { - for(int i = 0; i < p2; i++) { + for (int i = 0; i < p2; i++) { DisplayList d = displayListsInitialized.remove(p1 + i); - if(d != null) { + if (d != null) { _wglDeleteVertexArray(d.glarray); _wglDeleteBuffer(d.glbuffer); } displayLists.remove(p1 + i); } } + public static final void glActiveTexture(int p1) { - switch(p1) { + switch (p1) { case GL_TEXTURE0: selectedTex = 0; _wglActiveTexture(_wGL_TEXTURE0); @@ -1223,8 +1322,9 @@ public class EaglerAdapterGL30 extends EaglerAdapterImpl2 { break; } } + public static final void glClientActiveTexture(int p1) { - switch(p1) { + switch (p1) { case GL_TEXTURE0: selectedClientTex = 0; break; @@ -1236,8 +1336,9 @@ public class EaglerAdapterGL30 extends EaglerAdapterImpl2 { break; } } + public static final void glMultiTexCoord2f(int p1, float p2, float p3) { - switch(p1) { + switch (p1) { case GL_TEXTURE0: tex0X = p2; tex0Y = p3; @@ -1251,20 +1352,25 @@ public class EaglerAdapterGL30 extends EaglerAdapterImpl2 { break; } } + private static Matrix4f unprojA = new Matrix4f(); private static Matrix4f unprojB = new Matrix4f(); private static Vector4f unprojC = new Vector4f(); - public static final void gluUnProject(float p1, float p2, float p3, FloatBuffer p4, FloatBuffer p5, int[] p6, FloatBuffer p7) { + + public static final void gluUnProject(float p1, float p2, float p3, FloatBuffer p4, FloatBuffer p5, int[] p6, + FloatBuffer p7) { unprojA.load(p4); unprojB.load(p5); Matrix4f.mul(unprojA, unprojB, unprojB); unprojB.invert(); - unprojC.set(((p1 - (float)p6[0]) / (float)p6[2]) * 2f - 1f, ((p2 - (float)p6[1]) / (float)p6[3]) * 2f - 1f, p3, 1.0f); + unprojC.set(((p1 - (float) p6[0]) / (float) p6[2]) * 2f - 1f, ((p2 - (float) p6[1]) / (float) p6[3]) * 2f - 1f, + p3, 1.0f); Matrix4f.transform(unprojB, unprojC, unprojC); p7.put(unprojC.x / unprojC.w); p7.put(unprojC.y / unprojC.w); p7.put(unprojC.z / unprojC.w); } + public static final void gluPerspective(float fovy, float aspect, float zNear, float zFar) { Matrix4f res = getMatrix(); float cotangent = (float) Math.cos(fovy * toRad * 0.5f) / (float) Math.sin(fovy * toRad * 0.5f); @@ -1285,6 +1391,7 @@ public class EaglerAdapterGL30 extends EaglerAdapterImpl2 { res.m32 = 2.0f * zFar * zNear / (zFar - zNear); res.m33 = 0.0f; } + public static final void gluPerspectiveFlat(float fovy, float aspect, float zNear, float zFar) { Matrix4f res = getMatrix(); float cotangent = (float) Math.cos(fovy * toRad * 0.5f) / (float) Math.sin(fovy * toRad * 0.5f); @@ -1305,31 +1412,42 @@ public class EaglerAdapterGL30 extends EaglerAdapterImpl2 { res.m32 = 2.0f * zFar * zNear / (zFar - zNear); res.m33 = 0.0f; } + public static final String gluErrorString(int p1) { - switch(p1) { - case GL_INVALID_ENUM: return "GL_INVALID_ENUM"; - case GL_INVALID_VALUE: return "GL_INVALID_VALUE"; - case GL_INVALID_OPERATION: return "GL_INVALID_OPERATION"; - case GL_OUT_OF_MEMORY: return "GL_OUT_OF_MEMORY"; - case GL_CONTEXT_LOST_WEBGL: return "CONTEXT_LOST_WEBGL"; - default: return "Unknown Error"; + switch (p1) { + case GL_INVALID_ENUM: + return "GL_INVALID_ENUM"; + case GL_INVALID_VALUE: + return "GL_INVALID_VALUE"; + case GL_INVALID_OPERATION: + return "GL_INVALID_OPERATION"; + case GL_OUT_OF_MEMORY: + return "GL_OUT_OF_MEMORY"; + case GL_CONTEXT_LOST_WEBGL: + return "CONTEXT_LOST_WEBGL"; + default: + return "Unknown Error"; } } + private static long lastBandwidthReset = 0l; private static int lastBandwidth = 0; + public static final int getBitsPerSecond() { - if(System.currentTimeMillis() - lastBandwidthReset > 1000) { + if (System.currentTimeMillis() - lastBandwidthReset > 1000) { lastBandwidthReset = System.currentTimeMillis(); lastBandwidth = bytesUploaded * 8; bytesUploaded = 0; } return lastBandwidth; } + public static final int getVertexesPerSecond() { int ret = vertexDrawn; vertexDrawn = 0; return ret; } + public static final int getTrianglesPerSecond() { int ret = triangleDrawn; triangleDrawn = 0; diff --git a/src/main/java/net/lax1dude/eaglercraft/glemu/EffectPipeline.java b/src/main/java/net/lax1dude/eaglercraft/glemu/EffectPipeline.java index 3bd168d..511f59d 100644 --- a/src/main/java/net/lax1dude/eaglercraft/glemu/EffectPipeline.java +++ b/src/main/java/net/lax1dude/eaglercraft/glemu/EffectPipeline.java @@ -1,77 +1,6 @@ package net.lax1dude.eaglercraft.glemu; -import static net.lax1dude.eaglercraft.adapter.EaglerAdapterImpl2._wGL_ARRAY_BUFFER; -import static net.lax1dude.eaglercraft.adapter.EaglerAdapterImpl2._wGL_CLAMP; -import static net.lax1dude.eaglercraft.adapter.EaglerAdapterImpl2._wGL_COLOR_ATTACHMENT0; -import static net.lax1dude.eaglercraft.adapter.EaglerAdapterImpl2._wGL_CULL_FACE; -import static net.lax1dude.eaglercraft.adapter.EaglerAdapterImpl2._wGL_DEPTH24_STENCIL8; -import static net.lax1dude.eaglercraft.adapter.EaglerAdapterImpl2._wGL_DEPTH_STENCIL; -import static net.lax1dude.eaglercraft.adapter.EaglerAdapterImpl2._wGL_DEPTH_STENCIL_ATTACHMENT; -import static net.lax1dude.eaglercraft.adapter.EaglerAdapterImpl2._wGL_DEPTH_TEST; -import static net.lax1dude.eaglercraft.adapter.EaglerAdapterImpl2._wGL_FLOAT; -import static net.lax1dude.eaglercraft.adapter.EaglerAdapterImpl2._wGL_FRAGMENT_SHADER; -import static net.lax1dude.eaglercraft.adapter.EaglerAdapterImpl2._wGL_FRAMEBUFFER; -import static net.lax1dude.eaglercraft.adapter.EaglerAdapterImpl2._wGL_LINEAR; -import static net.lax1dude.eaglercraft.adapter.EaglerAdapterImpl2._wGL_NEAREST; -import static net.lax1dude.eaglercraft.adapter.EaglerAdapterImpl2._wGL_RGB; -import static net.lax1dude.eaglercraft.adapter.EaglerAdapterImpl2._wGL_STATIC_DRAW; -import static net.lax1dude.eaglercraft.adapter.EaglerAdapterImpl2._wGL_TEXTURE0; -import static net.lax1dude.eaglercraft.adapter.EaglerAdapterImpl2._wGL_TEXTURE1; -import static net.lax1dude.eaglercraft.adapter.EaglerAdapterImpl2._wGL_TEXTURE2; -import static net.lax1dude.eaglercraft.adapter.EaglerAdapterImpl2._wGL_TEXTURE_2D; -import static net.lax1dude.eaglercraft.adapter.EaglerAdapterImpl2._wGL_TEXTURE_MAG_FILTER; -import static net.lax1dude.eaglercraft.adapter.EaglerAdapterImpl2._wGL_TEXTURE_MIN_FILTER; -import static net.lax1dude.eaglercraft.adapter.EaglerAdapterImpl2._wGL_TEXTURE_WRAP_S; -import static net.lax1dude.eaglercraft.adapter.EaglerAdapterImpl2._wGL_TEXTURE_WRAP_T; -import static net.lax1dude.eaglercraft.adapter.EaglerAdapterImpl2._wGL_TRIANGLES; -import static net.lax1dude.eaglercraft.adapter.EaglerAdapterImpl2._wGL_UNSIGNED_BYTE; -import static net.lax1dude.eaglercraft.adapter.EaglerAdapterImpl2._wGL_UNSIGNED_INT_24_8; -import static net.lax1dude.eaglercraft.adapter.EaglerAdapterImpl2._wGL_VERTEX_SHADER; -import static net.lax1dude.eaglercraft.adapter.EaglerAdapterImpl2._wGL_VIEWPORT; -import static net.lax1dude.eaglercraft.adapter.EaglerAdapterImpl2._wgetShaderHeader; -import static net.lax1dude.eaglercraft.adapter.EaglerAdapterImpl2._wglActiveTexture; -import static net.lax1dude.eaglercraft.adapter.EaglerAdapterImpl2._wglAttachShader; -import static net.lax1dude.eaglercraft.adapter.EaglerAdapterImpl2._wglBindAttributeLocation; -import static net.lax1dude.eaglercraft.adapter.EaglerAdapterImpl2._wglBindBuffer; -import static net.lax1dude.eaglercraft.adapter.EaglerAdapterImpl2._wglBindFramebuffer; -import static net.lax1dude.eaglercraft.adapter.EaglerAdapterImpl2._wglBindTexture; -import static net.lax1dude.eaglercraft.adapter.EaglerAdapterImpl2._wglBindVertexArray; -import static net.lax1dude.eaglercraft.adapter.EaglerAdapterImpl2._wglBufferData0; -import static net.lax1dude.eaglercraft.adapter.EaglerAdapterImpl2._wglCompileShader; -import static net.lax1dude.eaglercraft.adapter.EaglerAdapterImpl2._wglCreateBuffer; -import static net.lax1dude.eaglercraft.adapter.EaglerAdapterImpl2._wglCreateFramebuffer; -import static net.lax1dude.eaglercraft.adapter.EaglerAdapterImpl2._wglCreateProgram; -import static net.lax1dude.eaglercraft.adapter.EaglerAdapterImpl2._wglCreateShader; -import static net.lax1dude.eaglercraft.adapter.EaglerAdapterImpl2._wglCreateVertexArray; -import static net.lax1dude.eaglercraft.adapter.EaglerAdapterImpl2._wglDeleteProgram; -import static net.lax1dude.eaglercraft.adapter.EaglerAdapterImpl2._wglDeleteShader; -import static net.lax1dude.eaglercraft.adapter.EaglerAdapterImpl2._wglDepthMask; -import static net.lax1dude.eaglercraft.adapter.EaglerAdapterImpl2._wglDetachShader; -import static net.lax1dude.eaglercraft.adapter.EaglerAdapterImpl2._wglDisable; -import static net.lax1dude.eaglercraft.adapter.EaglerAdapterImpl2._wglDrawArrays; -import static net.lax1dude.eaglercraft.adapter.EaglerAdapterImpl2._wglEnableVertexAttribArray; -import static net.lax1dude.eaglercraft.adapter.EaglerAdapterImpl2._wglFramebufferTexture2D; -import static net.lax1dude.eaglercraft.adapter.EaglerAdapterImpl2._wglGenTextures; -import static net.lax1dude.eaglercraft.adapter.EaglerAdapterImpl2._wglGetParameter; -import static net.lax1dude.eaglercraft.adapter.EaglerAdapterImpl2._wglGetProgramInfoLog; -import static net.lax1dude.eaglercraft.adapter.EaglerAdapterImpl2._wglGetProgramLinked; -import static net.lax1dude.eaglercraft.adapter.EaglerAdapterImpl2._wglGetShaderCompiled; -import static net.lax1dude.eaglercraft.adapter.EaglerAdapterImpl2._wglGetShaderInfoLog; -import static net.lax1dude.eaglercraft.adapter.EaglerAdapterImpl2._wglGetUniformLocation; -import static net.lax1dude.eaglercraft.adapter.EaglerAdapterImpl2._wglLinkProgram; -import static net.lax1dude.eaglercraft.adapter.EaglerAdapterImpl2._wglShaderSource; -import static net.lax1dude.eaglercraft.adapter.EaglerAdapterImpl2._wglTexImage2D; -import static net.lax1dude.eaglercraft.adapter.EaglerAdapterImpl2._wglTexParameteri; -import static net.lax1dude.eaglercraft.adapter.EaglerAdapterImpl2._wglUniform1f; -import static net.lax1dude.eaglercraft.adapter.EaglerAdapterImpl2._wglUniform1i; -import static net.lax1dude.eaglercraft.adapter.EaglerAdapterImpl2._wglUniform2f; -import static net.lax1dude.eaglercraft.adapter.EaglerAdapterImpl2._wglUniform2i; -import static net.lax1dude.eaglercraft.adapter.EaglerAdapterImpl2._wglUniform3f; -import static net.lax1dude.eaglercraft.adapter.EaglerAdapterImpl2._wglUniformMat4fv; -import static net.lax1dude.eaglercraft.adapter.EaglerAdapterImpl2._wglUseProgram; -import static net.lax1dude.eaglercraft.adapter.EaglerAdapterImpl2._wglVertexAttribPointer; -import static net.lax1dude.eaglercraft.adapter.EaglerAdapterImpl2._wglViewport; -import static net.lax1dude.eaglercraft.adapter.EaglerAdapterImpl2.fileContents; +import static net.lax1dude.eaglercraft.adapter.EaglerAdapterImpl2.*; import static net.lax1dude.eaglercraft.glemu.EaglerAdapterGL30.isWebGL; import static net.lax1dude.eaglercraft.glemu.EaglerAdapterGL30.matProjPointer; import static net.lax1dude.eaglercraft.glemu.EaglerAdapterGL30.matProjV; diff --git a/src/main/java/net/lax1dude/eaglercraft/glemu/EffectPipelineFXAA.java b/src/main/java/net/lax1dude/eaglercraft/glemu/EffectPipelineFXAA.java index 1d26c45..a0c5863 100644 --- a/src/main/java/net/lax1dude/eaglercraft/glemu/EffectPipelineFXAA.java +++ b/src/main/java/net/lax1dude/eaglercraft/glemu/EffectPipelineFXAA.java @@ -1,99 +1,12 @@ package net.lax1dude.eaglercraft.glemu; -import static net.lax1dude.eaglercraft.adapter.EaglerAdapterImpl2._wGL_ARRAY_BUFFER; -import static net.lax1dude.eaglercraft.adapter.EaglerAdapterImpl2._wGL_BACK; -import static net.lax1dude.eaglercraft.adapter.EaglerAdapterImpl2._wGL_CLAMP; -import static net.lax1dude.eaglercraft.adapter.EaglerAdapterImpl2._wGL_COLOR_ATTACHMENT0; -import static net.lax1dude.eaglercraft.adapter.EaglerAdapterImpl2._wGL_COLOR_BUFFER_BIT; -import static net.lax1dude.eaglercraft.adapter.EaglerAdapterImpl2._wGL_CULL_FACE; -import static net.lax1dude.eaglercraft.adapter.EaglerAdapterImpl2._wGL_DEPTH_ATTACHMENT; -import static net.lax1dude.eaglercraft.adapter.EaglerAdapterImpl2._wGL_DEPTH_BUFFER_BIT; -import static net.lax1dude.eaglercraft.adapter.EaglerAdapterImpl2._wGL_DEPTH_COMPONENT32F; -import static net.lax1dude.eaglercraft.adapter.EaglerAdapterImpl2._wGL_DEPTH_TEST; -import static net.lax1dude.eaglercraft.adapter.EaglerAdapterImpl2._wGL_DRAW_FRAMEBUFFER; -import static net.lax1dude.eaglercraft.adapter.EaglerAdapterImpl2._wGL_FLOAT; -import static net.lax1dude.eaglercraft.adapter.EaglerAdapterImpl2._wGL_FRAGMENT_SHADER; -import static net.lax1dude.eaglercraft.adapter.EaglerAdapterImpl2._wGL_FRAMEBUFFER; -import static net.lax1dude.eaglercraft.adapter.EaglerAdapterImpl2._wGL_LINE_SMOOTH; -import static net.lax1dude.eaglercraft.adapter.EaglerAdapterImpl2._wGL_MULTISAMPLE; -import static net.lax1dude.eaglercraft.adapter.EaglerAdapterImpl2._wGL_NEAREST; -import static net.lax1dude.eaglercraft.adapter.EaglerAdapterImpl2._wGL_READ_FRAMEBUFFER; -import static net.lax1dude.eaglercraft.adapter.EaglerAdapterImpl2._wGL_RGB; -import static net.lax1dude.eaglercraft.adapter.EaglerAdapterImpl2._wGL_RGB8; -import static net.lax1dude.eaglercraft.adapter.EaglerAdapterImpl2._wGL_STATIC_DRAW; -import static net.lax1dude.eaglercraft.adapter.EaglerAdapterImpl2._wGL_TEXTURE0; -import static net.lax1dude.eaglercraft.adapter.EaglerAdapterImpl2._wGL_TEXTURE_2D; -import static net.lax1dude.eaglercraft.adapter.EaglerAdapterImpl2._wGL_TEXTURE_MAG_FILTER; -import static net.lax1dude.eaglercraft.adapter.EaglerAdapterImpl2._wGL_TEXTURE_MIN_FILTER; -import static net.lax1dude.eaglercraft.adapter.EaglerAdapterImpl2._wGL_TEXTURE_WRAP_S; -import static net.lax1dude.eaglercraft.adapter.EaglerAdapterImpl2._wGL_TEXTURE_WRAP_T; -import static net.lax1dude.eaglercraft.adapter.EaglerAdapterImpl2._wGL_TRIANGLES; -import static net.lax1dude.eaglercraft.adapter.EaglerAdapterImpl2._wGL_UNSIGNED_BYTE; -import static net.lax1dude.eaglercraft.adapter.EaglerAdapterImpl2._wGL_VERTEX_SHADER; -import static net.lax1dude.eaglercraft.adapter.EaglerAdapterImpl2._wgetShaderHeader; -import static net.lax1dude.eaglercraft.adapter.EaglerAdapterImpl2._wglActiveTexture; -import static net.lax1dude.eaglercraft.adapter.EaglerAdapterImpl2._wglAttachShader; -import static net.lax1dude.eaglercraft.adapter.EaglerAdapterImpl2._wglBindBuffer; -import static net.lax1dude.eaglercraft.adapter.EaglerAdapterImpl2._wglBindFramebuffer; -import static net.lax1dude.eaglercraft.adapter.EaglerAdapterImpl2._wglBindRenderbuffer; -import static net.lax1dude.eaglercraft.adapter.EaglerAdapterImpl2._wglBindTexture; -import static net.lax1dude.eaglercraft.adapter.EaglerAdapterImpl2._wglBindVertexArray; -import static net.lax1dude.eaglercraft.adapter.EaglerAdapterImpl2._wglBlitFramebuffer; -import static net.lax1dude.eaglercraft.adapter.EaglerAdapterImpl2._wglBufferData0; -import static net.lax1dude.eaglercraft.adapter.EaglerAdapterImpl2._wglClear; -import static net.lax1dude.eaglercraft.adapter.EaglerAdapterImpl2._wglCompileShader; -import static net.lax1dude.eaglercraft.adapter.EaglerAdapterImpl2._wglCreateBuffer; -import static net.lax1dude.eaglercraft.adapter.EaglerAdapterImpl2._wglCreateFramebuffer; -import static net.lax1dude.eaglercraft.adapter.EaglerAdapterImpl2._wglCreateProgram; -import static net.lax1dude.eaglercraft.adapter.EaglerAdapterImpl2._wglCreateRenderBuffer; -import static net.lax1dude.eaglercraft.adapter.EaglerAdapterImpl2._wglCreateShader; -import static net.lax1dude.eaglercraft.adapter.EaglerAdapterImpl2._wglCreateVertexArray; -import static net.lax1dude.eaglercraft.adapter.EaglerAdapterImpl2._wglDeleteFramebuffer; -import static net.lax1dude.eaglercraft.adapter.EaglerAdapterImpl2._wglDeleteRenderbuffer; -import static net.lax1dude.eaglercraft.adapter.EaglerAdapterImpl2._wglDeleteShader; -import static net.lax1dude.eaglercraft.adapter.EaglerAdapterImpl2._wglDeleteTextures; -import static net.lax1dude.eaglercraft.adapter.EaglerAdapterImpl2._wglDepthMask; -import static net.lax1dude.eaglercraft.adapter.EaglerAdapterImpl2._wglDetachShader; -import static net.lax1dude.eaglercraft.adapter.EaglerAdapterImpl2._wglDisable; -import static net.lax1dude.eaglercraft.adapter.EaglerAdapterImpl2._wglDrawArrays; -import static net.lax1dude.eaglercraft.adapter.EaglerAdapterImpl2._wglDrawBuffer; -import static net.lax1dude.eaglercraft.adapter.EaglerAdapterImpl2._wglEnable; -import static net.lax1dude.eaglercraft.adapter.EaglerAdapterImpl2._wglEnableVertexAttribArray; -import static net.lax1dude.eaglercraft.adapter.EaglerAdapterImpl2._wglFramebufferRenderbuffer; -import static net.lax1dude.eaglercraft.adapter.EaglerAdapterImpl2._wglFramebufferTexture2D; -import static net.lax1dude.eaglercraft.adapter.EaglerAdapterImpl2._wglGenTextures; -import static net.lax1dude.eaglercraft.adapter.EaglerAdapterImpl2._wglGetProgramInfoLog; -import static net.lax1dude.eaglercraft.adapter.EaglerAdapterImpl2._wglGetProgramLinked; -import static net.lax1dude.eaglercraft.adapter.EaglerAdapterImpl2._wglGetShaderCompiled; -import static net.lax1dude.eaglercraft.adapter.EaglerAdapterImpl2._wglGetShaderInfoLog; -import static net.lax1dude.eaglercraft.adapter.EaglerAdapterImpl2._wglGetUniformLocation; -import static net.lax1dude.eaglercraft.adapter.EaglerAdapterImpl2._wglLinkProgram; -import static net.lax1dude.eaglercraft.adapter.EaglerAdapterImpl2._wglRenderbufferStorage; -import static net.lax1dude.eaglercraft.adapter.EaglerAdapterImpl2._wglRenderbufferStorageMultisample; -import static net.lax1dude.eaglercraft.adapter.EaglerAdapterImpl2._wglShaderSource; -import static net.lax1dude.eaglercraft.adapter.EaglerAdapterImpl2._wglTexImage2D; -import static net.lax1dude.eaglercraft.adapter.EaglerAdapterImpl2._wglTexParameteri; -import static net.lax1dude.eaglercraft.adapter.EaglerAdapterImpl2._wglUniform1i; -import static net.lax1dude.eaglercraft.adapter.EaglerAdapterImpl2._wglUniform2f; -import static net.lax1dude.eaglercraft.adapter.EaglerAdapterImpl2._wglUseProgram; -import static net.lax1dude.eaglercraft.adapter.EaglerAdapterImpl2._wglVertexAttribPointer; -import static net.lax1dude.eaglercraft.adapter.EaglerAdapterImpl2._wglViewport; -import static net.lax1dude.eaglercraft.adapter.EaglerAdapterImpl2.fileContents; -import static net.lax1dude.eaglercraft.glemu.EaglerAdapterGL30.isWebGL; +import static net.lax1dude.eaglercraft.EaglerAdapter.*; import java.nio.ByteBuffer; import java.nio.ByteOrder; import java.nio.IntBuffer; import net.lax1dude.eaglercraft.EaglerAdapter; -import net.lax1dude.eaglercraft.adapter.EaglerAdapterImpl2.BufferArrayGL; -import net.lax1dude.eaglercraft.adapter.EaglerAdapterImpl2.BufferGL; -import net.lax1dude.eaglercraft.adapter.EaglerAdapterImpl2.FramebufferGL; -import net.lax1dude.eaglercraft.adapter.EaglerAdapterImpl2.ProgramGL; -import net.lax1dude.eaglercraft.adapter.EaglerAdapterImpl2.RenderbufferGL; -import net.lax1dude.eaglercraft.adapter.EaglerAdapterImpl2.ShaderGL; -import net.lax1dude.eaglercraft.adapter.EaglerAdapterImpl2.TextureGL; -import net.lax1dude.eaglercraft.adapter.EaglerAdapterImpl2.UniformGL; import net.minecraft.client.Minecraft; public class EffectPipelineFXAA { diff --git a/src/main/java/net/lax1dude/eaglercraft/glemu/FixedFunctionShader.java b/src/main/java/net/lax1dude/eaglercraft/glemu/FixedFunctionShader.java index e5c5531..d97e647 100644 --- a/src/main/java/net/lax1dude/eaglercraft/glemu/FixedFunctionShader.java +++ b/src/main/java/net/lax1dude/eaglercraft/glemu/FixedFunctionShader.java @@ -1,40 +1,7 @@ package net.lax1dude.eaglercraft.glemu; -import static net.lax1dude.eaglercraft.adapter.EaglerAdapterImpl2._wGL_ARRAY_BUFFER; -import static net.lax1dude.eaglercraft.adapter.EaglerAdapterImpl2._wGL_FRAGMENT_SHADER; -import static net.lax1dude.eaglercraft.adapter.EaglerAdapterImpl2._wGL_VERTEX_SHADER; -import static net.lax1dude.eaglercraft.adapter.EaglerAdapterImpl2._wgetShaderHeader; -import static net.lax1dude.eaglercraft.adapter.EaglerAdapterImpl2._wglAttachShader; -import static net.lax1dude.eaglercraft.adapter.EaglerAdapterImpl2._wglBindAttributeLocation; -import static net.lax1dude.eaglercraft.adapter.EaglerAdapterImpl2._wglBindBuffer; -import static net.lax1dude.eaglercraft.adapter.EaglerAdapterImpl2._wglBindVertexArray; -import static net.lax1dude.eaglercraft.adapter.EaglerAdapterImpl2._wglCompileShader; -import static net.lax1dude.eaglercraft.adapter.EaglerAdapterImpl2._wglCreateBuffer; -import static net.lax1dude.eaglercraft.adapter.EaglerAdapterImpl2._wglCreateProgram; -import static net.lax1dude.eaglercraft.adapter.EaglerAdapterImpl2._wglCreateShader; -import static net.lax1dude.eaglercraft.adapter.EaglerAdapterImpl2._wglCreateVertexArray; -import static net.lax1dude.eaglercraft.adapter.EaglerAdapterImpl2._wglDeleteProgram; -import static net.lax1dude.eaglercraft.adapter.EaglerAdapterImpl2._wglDeleteShader; -import static net.lax1dude.eaglercraft.adapter.EaglerAdapterImpl2._wglDetachShader; -import static net.lax1dude.eaglercraft.adapter.EaglerAdapterImpl2._wglEnableVertexAttribArray; -import static net.lax1dude.eaglercraft.adapter.EaglerAdapterImpl2._wglGetProgramInfoLog; -import static net.lax1dude.eaglercraft.adapter.EaglerAdapterImpl2._wglGetProgramLinked; -import static net.lax1dude.eaglercraft.adapter.EaglerAdapterImpl2._wglGetShaderCompiled; -import static net.lax1dude.eaglercraft.adapter.EaglerAdapterImpl2._wglGetShaderInfoLog; -import static net.lax1dude.eaglercraft.adapter.EaglerAdapterImpl2._wglGetUniformLocation; -import static net.lax1dude.eaglercraft.adapter.EaglerAdapterImpl2._wglLinkProgram; -import static net.lax1dude.eaglercraft.adapter.EaglerAdapterImpl2._wglShaderSource; -import static net.lax1dude.eaglercraft.adapter.EaglerAdapterImpl2._wglUniform1f; -import static net.lax1dude.eaglercraft.adapter.EaglerAdapterImpl2._wglUniform1i; -import static net.lax1dude.eaglercraft.adapter.EaglerAdapterImpl2._wglUniform2f; -import static net.lax1dude.eaglercraft.adapter.EaglerAdapterImpl2._wglUniform3f; -import static net.lax1dude.eaglercraft.adapter.EaglerAdapterImpl2._wglUniform4f; -import static net.lax1dude.eaglercraft.adapter.EaglerAdapterImpl2._wglUniformMat4fv; -import static net.lax1dude.eaglercraft.adapter.EaglerAdapterImpl2._wglUseProgram; -import static net.lax1dude.eaglercraft.adapter.EaglerAdapterImpl2._wglVertexAttribPointer; -import static net.lax1dude.eaglercraft.adapter.EaglerAdapterImpl2.fileContents; +import static net.lax1dude.eaglercraft.EaglerAdapter.*; -import net.lax1dude.eaglercraft.EaglerAdapter; import net.lax1dude.eaglercraft.adapter.EaglerAdapterImpl2.BufferArrayGL; import net.lax1dude.eaglercraft.adapter.EaglerAdapterImpl2.BufferGL; import net.lax1dude.eaglercraft.adapter.EaglerAdapterImpl2.ProgramGL; @@ -352,22 +319,22 @@ public class FixedFunctionShader { public void setupArrayForProgram() { _wglEnableVertexAttribArray(a_position); - _wglVertexAttribPointer(a_position, 3, EaglerAdapter._wGL_FLOAT, false, 32, 0); + _wglVertexAttribPointer(a_position, 3, _wGL_FLOAT, false, 32, 0); if(enable_texture0) { _wglEnableVertexAttribArray(a_texture0); - _wglVertexAttribPointer(a_texture0, 2, EaglerAdapter._wGL_FLOAT, false, 32, 12); + _wglVertexAttribPointer(a_texture0, 2, _wGL_FLOAT, false, 32, 12); } if(enable_color) { _wglEnableVertexAttribArray(a_color); - _wglVertexAttribPointer(a_color, 4, EaglerAdapter._wGL_UNSIGNED_BYTE, true, 32, 20); + _wglVertexAttribPointer(a_color, 4, _wGL_UNSIGNED_BYTE, true, 32, 20); } if(enable_normal) { _wglEnableVertexAttribArray(a_normal); - _wglVertexAttribPointer(a_normal, 4, EaglerAdapter._wGL_UNSIGNED_BYTE, true, 32, 24); + _wglVertexAttribPointer(a_normal, 4, _wGL_UNSIGNED_BYTE, true, 32, 24); } if(enable_texture1) { _wglEnableVertexAttribArray(a_texture1); - _wglVertexAttribPointer(a_texture1, 2, EaglerAdapter._wGL_SHORT, false, 32, 28); + _wglVertexAttribPointer(a_texture1, 2, _wGL_SHORT, false, 32, 28); } } diff --git a/src/main/java/net/lax1dude/eaglercraft/glemu/HighPolyMesh.java b/src/main/java/net/lax1dude/eaglercraft/glemu/HighPolyMesh.java index 462c57c..1c32d9f 100644 --- a/src/main/java/net/lax1dude/eaglercraft/glemu/HighPolyMesh.java +++ b/src/main/java/net/lax1dude/eaglercraft/glemu/HighPolyMesh.java @@ -1,19 +1,6 @@ package net.lax1dude.eaglercraft.glemu; -import static net.lax1dude.eaglercraft.adapter.EaglerAdapterImpl2._wGL_ARRAY_BUFFER; -import static net.lax1dude.eaglercraft.adapter.EaglerAdapterImpl2._wGL_ELEMENT_ARRAY_BUFFER; -import static net.lax1dude.eaglercraft.adapter.EaglerAdapterImpl2._wGL_FLOAT; -import static net.lax1dude.eaglercraft.adapter.EaglerAdapterImpl2._wGL_STATIC_DRAW; -import static net.lax1dude.eaglercraft.adapter.EaglerAdapterImpl2._wGL_UNSIGNED_BYTE; -import static net.lax1dude.eaglercraft.adapter.EaglerAdapterImpl2._wglBindBuffer; -import static net.lax1dude.eaglercraft.adapter.EaglerAdapterImpl2._wglBindVertexArray; -import static net.lax1dude.eaglercraft.adapter.EaglerAdapterImpl2._wglBufferData0; -import static net.lax1dude.eaglercraft.adapter.EaglerAdapterImpl2._wglCreateBuffer; -import static net.lax1dude.eaglercraft.adapter.EaglerAdapterImpl2._wglCreateVertexArray; -import static net.lax1dude.eaglercraft.adapter.EaglerAdapterImpl2._wglDeleteBuffer; -import static net.lax1dude.eaglercraft.adapter.EaglerAdapterImpl2._wglDeleteVertexArray; -import static net.lax1dude.eaglercraft.adapter.EaglerAdapterImpl2._wglEnableVertexAttribArray; -import static net.lax1dude.eaglercraft.adapter.EaglerAdapterImpl2._wglVertexAttribPointer; +import static net.lax1dude.eaglercraft.adapter.EaglerAdapterImpl2.*; import java.io.ByteArrayInputStream; import java.io.DataInputStream; diff --git a/src/main/java/net/minecraft/client/Minecraft.java b/src/main/java/net/minecraft/client/Minecraft.java index addead9..4be3e07 100644 --- a/src/main/java/net/minecraft/client/Minecraft.java +++ b/src/main/java/net/minecraft/client/Minecraft.java @@ -8,11 +8,11 @@ import net.lax1dude.eaglercraft.DefaultSkinRenderer; import net.lax1dude.eaglercraft.EaglerAdapter; import net.lax1dude.eaglercraft.EaglerProfile; import net.lax1dude.eaglercraft.GuiScreenEditProfile; +import net.lax1dude.eaglercraft.GuiScreenLicense; import net.lax1dude.eaglercraft.GuiScreenSingleplayerConnecting; import net.lax1dude.eaglercraft.GuiScreenSingleplayerLoading; -import net.lax1dude.eaglercraft.IntegratedServer; -import net.lax1dude.eaglercraft.GuiScreenLicense; import net.lax1dude.eaglercraft.GuiVoiceOverlay; +import net.lax1dude.eaglercraft.IntegratedServer; import net.lax1dude.eaglercraft.LocalStorageManager; import net.lax1dude.eaglercraft.Voice; import net.lax1dude.eaglercraft.WorkerNetworkManager; diff --git a/src/main/java/net/minecraft/src/GuiIngame.java b/src/main/java/net/minecraft/src/GuiIngame.java index 30475db..20938c3 100644 --- a/src/main/java/net/minecraft/src/GuiIngame.java +++ b/src/main/java/net/minecraft/src/GuiIngame.java @@ -4,11 +4,10 @@ import java.util.Collection; import java.util.Iterator; import java.util.List; -import net.lax1dude.eaglercraft.ConfigConstants; import net.lax1dude.eaglercraft.EaglerAdapter; import net.lax1dude.eaglercraft.EaglercraftRandom; -import net.lax1dude.eaglercraft.IntegratedServer; import net.lax1dude.eaglercraft.EnumBrowser; +import net.lax1dude.eaglercraft.IntegratedServer; import net.lax1dude.eaglercraft.TextureLocation; import net.lax1dude.eaglercraft.adapter.Tessellator; import net.lax1dude.eaglercraft.glemu.EffectPipeline; diff --git a/src/main/java/net/minecraft/src/GuiSelectWorld.java b/src/main/java/net/minecraft/src/GuiSelectWorld.java index df580f4..4b68b9a 100644 --- a/src/main/java/net/minecraft/src/GuiSelectWorld.java +++ b/src/main/java/net/minecraft/src/GuiSelectWorld.java @@ -9,7 +9,6 @@ import java.util.List; import net.lax1dude.eaglercraft.GuiScreenBackupWorld; import net.lax1dude.eaglercraft.GuiScreenCreateWorldSelection; import net.lax1dude.eaglercraft.GuiScreenSingleplayerLoading; -import net.lax1dude.eaglercraft.GuiScreenSingleplayerNotImplemented; import net.lax1dude.eaglercraft.IntegratedServer; public class GuiSelectWorld extends GuiScreen { diff --git a/src/main/java/net/minecraft/src/NetClientHandler.java b/src/main/java/net/minecraft/src/NetClientHandler.java index 36aea32..0ad08fa 100644 --- a/src/main/java/net/minecraft/src/NetClientHandler.java +++ b/src/main/java/net/minecraft/src/NetClientHandler.java @@ -12,10 +12,10 @@ import java.util.function.Consumer; import net.lax1dude.eaglercraft.DefaultSkinRenderer; import net.lax1dude.eaglercraft.EaglerAdapter; -import net.lax1dude.eaglercraft.IntegratedServer; import net.lax1dude.eaglercraft.EaglercraftRandom; import net.lax1dude.eaglercraft.GuiScreenSingleplayerException; import net.lax1dude.eaglercraft.GuiScreenSingleplayerLoading; +import net.lax1dude.eaglercraft.IntegratedServer; import net.lax1dude.eaglercraft.Voice; import net.lax1dude.eaglercraft.WebsocketNetworkManager; import net.lax1dude.eaglercraft.WorkerNetworkManager; diff --git a/src/main/java/net/minecraft/src/ServerList.java b/src/main/java/net/minecraft/src/ServerList.java index d2c5ff2..374438a 100644 --- a/src/main/java/net/minecraft/src/ServerList.java +++ b/src/main/java/net/minecraft/src/ServerList.java @@ -2,7 +2,6 @@ package net.minecraft.src; import java.io.IOException; import java.util.ArrayList; -import java.util.Arrays; import java.util.HashSet; import java.util.Iterator; import java.util.List; @@ -11,7 +10,10 @@ import java.util.Set; import org.json.JSONArray; import org.json.JSONObject; -import net.lax1dude.eaglercraft.*; +import net.lax1dude.eaglercraft.Base64; +import net.lax1dude.eaglercraft.ConfigConstants; +import net.lax1dude.eaglercraft.EaglerAdapter; +import net.lax1dude.eaglercraft.LocalStorageManager; import net.lax1dude.eaglercraft.ServerQuery.QueryResponse; import net.lax1dude.eaglercraft.adapter.EaglerAdapterImpl2.RateLimit; import net.minecraft.client.Minecraft; diff --git a/src/teavm/java/net/lax1dude/eaglercraft/adapter/EaglerAdapterImpl2.java b/src/teavm/java/net/lax1dude/eaglercraft/adapter/EaglerAdapterImpl2.java index b26ff9d..3d9cec1 100644 --- a/src/teavm/java/net/lax1dude/eaglercraft/adapter/EaglerAdapterImpl2.java +++ b/src/teavm/java/net/lax1dude/eaglercraft/adapter/EaglerAdapterImpl2.java @@ -1,6 +1,7 @@ package net.lax1dude.eaglercraft.adapter; import static net.lax1dude.eaglercraft.adapter.teavm.WebGL2RenderingContext.*; +import static org.teavm.jso.webgl.WebGLRenderingContext.*; import java.io.ByteArrayInputStream; import java.io.ByteArrayOutputStream; @@ -24,6 +25,7 @@ import java.util.List; import java.util.Set; import java.util.function.Consumer; import java.util.stream.Collectors; + import org.json.JSONObject; import org.teavm.interop.Async; import org.teavm.interop.AsyncCallback; @@ -35,9 +37,9 @@ import org.teavm.jso.ajax.XMLHttpRequest; import org.teavm.jso.browser.Storage; import org.teavm.jso.browser.TimerHandler; import org.teavm.jso.browser.Window; -import org.teavm.jso.dom.events.ErrorEvent; import org.teavm.jso.canvas.CanvasRenderingContext2D; import org.teavm.jso.canvas.ImageData; +import org.teavm.jso.dom.events.ErrorEvent; import org.teavm.jso.dom.events.Event; import org.teavm.jso.dom.events.EventListener; import org.teavm.jso.dom.events.KeyboardEvent; @@ -96,7 +98,6 @@ import net.lax1dude.eaglercraft.adapter.teavm.SelfDefence; import net.lax1dude.eaglercraft.adapter.teavm.WebGL2RenderingContext; import net.lax1dude.eaglercraft.adapter.teavm.WebGLQuery; import net.lax1dude.eaglercraft.adapter.teavm.WebGLVertexArray; -import net.minecraft.client.Minecraft; import net.minecraft.src.MathHelper; public class EaglerAdapterImpl2 {