From 58f318e627a2b704fcde708dc56ebc61333186cb Mon Sep 17 00:00:00 2001 From: PeytonPlayz595 <106421860+PeytonPlayz595@users.noreply.github.com> Date: Mon, 29 Jul 2024 17:15:00 -0400 Subject: [PATCH] Update EaglerAdapter --- src/net/PeytonPlayz585/Client.java | 299 + .../awt/image/BufferedImage.java | 81 + src/net/PeytonPlayz585/awt/image/ImageIO.java | 29 + src/net/PeytonPlayz585/fileutils/File.java | 112 + .../PeytonPlayz585/fileutils/FileEntry.java | 24 + .../fileutils/FilesystemUtils.java | 22 + .../fileutils}/IDBObjectStorePatched.java | 156 +- .../fileutils}/IndexedDBFilesystem.java | 816 +- .../glemu/FixedFunctionShader.java | 1046 ++- src/net/PeytonPlayz585/glemu/GLObjectMap.java | 55 - .../glemu/GameOverlayFramebuffer.java | 3 +- src/net/PeytonPlayz585/glemu/ModeBuffer.java | 58 - .../PeytonPlayz585/glemu/StreamBuffer.java | 2 +- .../PeytonPlayz585/glemu/vector/Matrix.java | 130 - .../PeytonPlayz585/glemu/vector/Matrix2f.java | 418 - .../PeytonPlayz585/glemu/vector/Matrix3f.java | 529 -- .../glemu/vector/Quaternion.java | 506 - .../glemu/vector/ReadableVector.java | 57 - .../glemu/vector/ReadableVector2f.java | 47 - .../glemu/vector/ReadableVector3f.java | 42 - .../glemu/vector/ReadableVector4f.java | 44 - .../PeytonPlayz585/glemu/vector/Vector.java | 110 - .../PeytonPlayz585/glemu/vector/Vector2f.java | 319 - .../PeytonPlayz585/glemu/vector/Vector3f.java | 376 - .../PeytonPlayz585/glemu/vector/Vector4f.java | 377 - .../glemu/vector/WritableVector2f.java | 64 - .../glemu/vector/WritableVector3f.java | 58 - .../glemu/vector/WritableVector4f.java | 59 - src/net/PeytonPlayz585/input/Keyboard.java | 15 - src/net/PeytonPlayz585/input/Mouse.java | 55 - .../json}/JSONArray.java | 4 +- .../json}/JSONException.java | 4 +- .../json}/JSONObject.java | 6 +- .../json}/JSONPointer.java | 4 +- .../json}/JSONPointerException.java | 4 +- .../json}/JSONPropertyIgnore.java | 4 +- .../json}/JSONPropertyName.java | 4 +- .../json}/JSONString.java | 4 +- src/net/PeytonPlayz585/json/JSONStringer.java | 79 + .../json}/JSONTokener.java | 4 +- .../json}/JSONWriter.java | 4 +- .../opengl/EaglerAdapterGL30.java | 1321 --- src/net/PeytonPlayz585/opengl/GL11.java | 9 - src/net/PeytonPlayz585/opengl/GL12.java | 5 - .../opengl/RealOpenGLEnums.java | 2417 ----- src/net/PeytonPlayz585/profile/Profile.java | 9 +- src/net/PeytonPlayz585/socket/Socket.java | 16 +- .../storage/LocalStorageManager.java | 80 - src/net/PeytonPlayz585/util/glu/GLU.java | 7 - src/net/PeytonPlayz595/nbt/NBTBase.java | 130 - src/net/PeytonPlayz595/nbt/NBTTagByte.java | 31 - .../PeytonPlayz595/nbt/NBTTagByteArray.java | 34 - .../PeytonPlayz595/nbt/NBTTagCompound.java | 194 - src/net/PeytonPlayz595/nbt/NBTTagDouble.java | 31 - src/net/PeytonPlayz595/nbt/NBTTagEnd.java | 23 - src/net/PeytonPlayz595/nbt/NBTTagFloat.java | 31 - src/net/PeytonPlayz595/nbt/NBTTagInt.java | 31 - src/net/PeytonPlayz595/nbt/NBTTagList.java | 63 - src/net/PeytonPlayz595/nbt/NBTTagLong.java | 31 - src/net/PeytonPlayz595/nbt/NBTTagShort.java | 31 - src/net/PeytonPlayz595/nbt/NBTTagString.java | 36 - .../lax1dude/eaglercraft/AssetRepository.java | 55 - src/net/lax1dude/eaglercraft/Base64.java | 857 -- src/net/lax1dude/eaglercraft/BaseNCodec.java | 694 -- .../lax1dude/eaglercraft/BufferedImage.java | 96 - src/net/lax1dude/eaglercraft/Client.java | 133 - .../lax1dude/eaglercraft/EarlyLoadScreen.java | 117 - .../lax1dude/eaglercraft/GLAllocation.java | 60 - .../lax1dude/eaglercraft/GeneralDigest.java | 108 - src/net/lax1dude/eaglercraft/ImageIO.java | 21 - src/net/lax1dude/eaglercraft/SHA1Digest.java | 213 - .../adapter/EaglerAdapterImpl2.java | 2113 ----- .../adapter/FileChooserResult.java | 26 - .../adapter/teavm/BufferConverter.java | 34 - .../adapter/teavm/WebGL2RenderingContext.java | 42 - .../eaglercraft/adapter/teavm/WebGLQuery.java | 6 - .../adapter/teavm/WebGLVertexArray.java | 6 - src/net/minecraft/client/Minecraft.java | 32 +- src/net/minecraft/src/ChunkLoader.java | 16 +- src/net/minecraft/src/EaglerSaveFormat.java | 15 +- src/net/minecraft/src/EaglerSaveHandler.java | 8 +- src/net/minecraft/src/EntityRenderer.java | 3 +- src/net/minecraft/src/FilesystemUtils.java | 15 +- src/net/minecraft/src/FontRenderer.java | 4 +- src/net/minecraft/src/GLAllocation.java | 6 +- src/net/minecraft/src/GameSettings.java | 9 +- src/net/minecraft/src/GuiIngame.java | 6 +- src/net/minecraft/src/IsoImageBuffer.java | 2 +- .../minecraft/src/LoadingScreenRenderer.java | 4 +- src/net/minecraft/src/MapItemRenderer.java | 2 +- src/net/minecraft/src/MapStorage.java | 14 +- src/net/minecraft/src/MouseHelper.java | 2 +- src/net/minecraft/src/NetClientHandler.java | 5 +- src/net/minecraft/src/RenderEngine.java | 5 +- src/net/minecraft/src/RenderHelper.java | 3 +- src/net/minecraft/src/SoundManager.java | 30 +- src/net/minecraft/src/StatFileWriter.java | 11 +- src/net/minecraft/src/StatsSyncher.java | 24 +- .../minecraft/src/TerrainTextureManager.java | 4 +- src/net/minecraft/src/Tessellator.java | 4 +- src/net/minecraft/src/TextureCompassFX.java | 4 +- .../src/ThreadStatSyncherReceive.java | 4 +- src/org/lwjgl/BufferUtils.java | 161 + src/org/lwjgl/LWJGLException.java | 21 + src/org/lwjgl/PointerBuffer.java | 314 + src/org/lwjgl/PointerWrapper.java | 5 + src/org/lwjgl/input/Keyboard.java | 43 +- src/org/lwjgl/input/Mouse.java | 58 +- src/org/lwjgl/opengl/Display.java | 58 + src/org/lwjgl/opengl/GL11.java | 8230 ++++++++++++++++- src/org/lwjgl/opengl/GL12.java | 2 +- src/org/lwjgl/opengl/GL13.java | 5 + src/org/lwjgl/util/glu/GLU.java | 18 +- src/org/lwjgl/util/vector/Matrix.java | 31 + .../lwjgl/util}/vector/Matrix4f.java | 1531 ++- src/org/lwjgl/util/vector/ReadableVector.java | 9 + .../lwjgl/util/vector/ReadableVector2f.java | 6 + .../lwjgl/util/vector/ReadableVector3f.java | 5 + .../lwjgl/util/vector/ReadableVector4f.java | 7 + src/org/lwjgl/util/vector/Vector.java | 37 + src/org/lwjgl/util/vector/Vector2f.java | 161 + src/org/lwjgl/util/vector/Vector3f.java | 202 + src/org/lwjgl/util/vector/Vector4f.java | 196 + .../lwjgl/util/vector/WritableVector2f.java | 11 + .../lwjgl/util/vector/WritableVector3f.java | 9 + .../lwjgl/util/vector/WritableVector4f.java | 9 + 126 files changed, 12111 insertions(+), 14391 deletions(-) create mode 100644 src/net/PeytonPlayz585/Client.java create mode 100644 src/net/PeytonPlayz585/awt/image/BufferedImage.java create mode 100644 src/net/PeytonPlayz585/awt/image/ImageIO.java create mode 100644 src/net/PeytonPlayz585/fileutils/File.java create mode 100644 src/net/PeytonPlayz585/fileutils/FileEntry.java create mode 100644 src/net/PeytonPlayz585/fileutils/FilesystemUtils.java rename src/net/{lax1dude/eaglercraft/adapter/teavm => PeytonPlayz585/fileutils}/IDBObjectStorePatched.java (95%) rename src/net/{lax1dude/eaglercraft/adapter/teavm => PeytonPlayz585/fileutils}/IndexedDBFilesystem.java (94%) delete mode 100644 src/net/PeytonPlayz585/glemu/GLObjectMap.java delete mode 100644 src/net/PeytonPlayz585/glemu/ModeBuffer.java delete mode 100644 src/net/PeytonPlayz585/glemu/vector/Matrix.java delete mode 100644 src/net/PeytonPlayz585/glemu/vector/Matrix2f.java delete mode 100644 src/net/PeytonPlayz585/glemu/vector/Matrix3f.java delete mode 100644 src/net/PeytonPlayz585/glemu/vector/Quaternion.java delete mode 100644 src/net/PeytonPlayz585/glemu/vector/ReadableVector.java delete mode 100644 src/net/PeytonPlayz585/glemu/vector/ReadableVector2f.java delete mode 100644 src/net/PeytonPlayz585/glemu/vector/ReadableVector3f.java delete mode 100644 src/net/PeytonPlayz585/glemu/vector/ReadableVector4f.java delete mode 100644 src/net/PeytonPlayz585/glemu/vector/Vector.java delete mode 100644 src/net/PeytonPlayz585/glemu/vector/Vector2f.java delete mode 100644 src/net/PeytonPlayz585/glemu/vector/Vector3f.java delete mode 100644 src/net/PeytonPlayz585/glemu/vector/Vector4f.java delete mode 100644 src/net/PeytonPlayz585/glemu/vector/WritableVector2f.java delete mode 100644 src/net/PeytonPlayz585/glemu/vector/WritableVector3f.java delete mode 100644 src/net/PeytonPlayz585/glemu/vector/WritableVector4f.java delete mode 100644 src/net/PeytonPlayz585/input/Keyboard.java delete mode 100644 src/net/PeytonPlayz585/input/Mouse.java rename src/net/{lax1dude/eaglercraft => PeytonPlayz585/json}/JSONArray.java (97%) rename src/net/{lax1dude/eaglercraft => PeytonPlayz585/json}/JSONException.java (95%) rename src/net/{lax1dude/eaglercraft => PeytonPlayz585/json}/JSONObject.java (97%) rename src/net/{lax1dude/eaglercraft => PeytonPlayz585/json}/JSONPointer.java (97%) rename src/net/{lax1dude/eaglercraft => PeytonPlayz585/json}/JSONPointerException.java (95%) rename src/net/{lax1dude/eaglercraft => PeytonPlayz585/json}/JSONPropertyIgnore.java (93%) rename src/net/{lax1dude/eaglercraft => PeytonPlayz585/json}/JSONPropertyName.java (95%) rename src/net/{lax1dude/eaglercraft => PeytonPlayz585/json}/JSONString.java (95%) create mode 100644 src/net/PeytonPlayz585/json/JSONStringer.java rename src/net/{lax1dude/eaglercraft => PeytonPlayz585/json}/JSONTokener.java (96%) rename src/net/{lax1dude/eaglercraft => PeytonPlayz585/json}/JSONWriter.java (97%) delete mode 100644 src/net/PeytonPlayz585/opengl/EaglerAdapterGL30.java delete mode 100644 src/net/PeytonPlayz585/opengl/GL11.java delete mode 100644 src/net/PeytonPlayz585/opengl/GL12.java delete mode 100644 src/net/PeytonPlayz585/opengl/RealOpenGLEnums.java delete mode 100644 src/net/PeytonPlayz585/storage/LocalStorageManager.java delete mode 100644 src/net/PeytonPlayz585/util/glu/GLU.java delete mode 100644 src/net/PeytonPlayz595/nbt/NBTBase.java delete mode 100644 src/net/PeytonPlayz595/nbt/NBTTagByte.java delete mode 100644 src/net/PeytonPlayz595/nbt/NBTTagByteArray.java delete mode 100644 src/net/PeytonPlayz595/nbt/NBTTagCompound.java delete mode 100644 src/net/PeytonPlayz595/nbt/NBTTagDouble.java delete mode 100644 src/net/PeytonPlayz595/nbt/NBTTagEnd.java delete mode 100644 src/net/PeytonPlayz595/nbt/NBTTagFloat.java delete mode 100644 src/net/PeytonPlayz595/nbt/NBTTagInt.java delete mode 100644 src/net/PeytonPlayz595/nbt/NBTTagList.java delete mode 100644 src/net/PeytonPlayz595/nbt/NBTTagLong.java delete mode 100644 src/net/PeytonPlayz595/nbt/NBTTagShort.java delete mode 100644 src/net/PeytonPlayz595/nbt/NBTTagString.java delete mode 100644 src/net/lax1dude/eaglercraft/AssetRepository.java delete mode 100644 src/net/lax1dude/eaglercraft/Base64.java delete mode 100644 src/net/lax1dude/eaglercraft/BaseNCodec.java delete mode 100644 src/net/lax1dude/eaglercraft/BufferedImage.java delete mode 100644 src/net/lax1dude/eaglercraft/Client.java delete mode 100644 src/net/lax1dude/eaglercraft/EarlyLoadScreen.java delete mode 100644 src/net/lax1dude/eaglercraft/GLAllocation.java delete mode 100644 src/net/lax1dude/eaglercraft/GeneralDigest.java delete mode 100644 src/net/lax1dude/eaglercraft/ImageIO.java delete mode 100644 src/net/lax1dude/eaglercraft/SHA1Digest.java delete mode 100644 src/net/lax1dude/eaglercraft/adapter/EaglerAdapterImpl2.java delete mode 100644 src/net/lax1dude/eaglercraft/adapter/FileChooserResult.java delete mode 100644 src/net/lax1dude/eaglercraft/adapter/teavm/BufferConverter.java delete mode 100644 src/net/lax1dude/eaglercraft/adapter/teavm/WebGL2RenderingContext.java delete mode 100644 src/net/lax1dude/eaglercraft/adapter/teavm/WebGLQuery.java delete mode 100644 src/net/lax1dude/eaglercraft/adapter/teavm/WebGLVertexArray.java create mode 100644 src/org/lwjgl/BufferUtils.java create mode 100644 src/org/lwjgl/LWJGLException.java create mode 100644 src/org/lwjgl/PointerBuffer.java create mode 100644 src/org/lwjgl/PointerWrapper.java create mode 100644 src/org/lwjgl/opengl/Display.java create mode 100644 src/org/lwjgl/opengl/GL13.java create mode 100644 src/org/lwjgl/util/vector/Matrix.java rename src/{net/PeytonPlayz585/glemu => org/lwjgl/util}/vector/Matrix4f.java (52%) create mode 100644 src/org/lwjgl/util/vector/ReadableVector.java create mode 100644 src/org/lwjgl/util/vector/ReadableVector2f.java create mode 100644 src/org/lwjgl/util/vector/ReadableVector3f.java create mode 100644 src/org/lwjgl/util/vector/ReadableVector4f.java create mode 100644 src/org/lwjgl/util/vector/Vector.java create mode 100644 src/org/lwjgl/util/vector/Vector2f.java create mode 100644 src/org/lwjgl/util/vector/Vector3f.java create mode 100644 src/org/lwjgl/util/vector/Vector4f.java create mode 100644 src/org/lwjgl/util/vector/WritableVector2f.java create mode 100644 src/org/lwjgl/util/vector/WritableVector3f.java create mode 100644 src/org/lwjgl/util/vector/WritableVector4f.java diff --git a/src/net/PeytonPlayz585/Client.java b/src/net/PeytonPlayz585/Client.java new file mode 100644 index 0000000..f8991b0 --- /dev/null +++ b/src/net/PeytonPlayz585/Client.java @@ -0,0 +1,299 @@ +package net.PeytonPlayz585; + +import static org.lwjgl.opengl.GL11.EaglerAdapterImpl2.*; + +import java.io.StringWriter; + +import org.lwjgl.opengl.GL11; +import org.lwjgl.opengl.GL11.DetectAnisotropicGlitch; +import org.lwjgl.opengl.GL11.WebGL2RenderingContext; +import org.teavm.jso.JSBody; +import org.teavm.jso.JSFunctor; +import org.teavm.jso.JSObject; +import org.teavm.jso.browser.Window; +import org.teavm.jso.core.JSError; +import org.teavm.jso.dom.html.HTMLCanvasElement; +import org.teavm.jso.dom.html.HTMLDocument; +import org.teavm.jso.dom.html.HTMLElement; +import org.teavm.jso.webgl.WebGLRenderingContext; + +import net.PeytonPlayz585.json.JSONObject; +import net.minecraft.client.Minecraft; +import net.minecraft.src.Session; + +public class Client { + + private static final String crashImage = "data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAATEAAABxCAYAAAC9SpSwAAAQtnpUWHRSYXcgcHJvZmlsZSB0eXBlIGV4aWYAAHjarZlrkly7jYT/cxVeAt8gl0OAZMTsYJY/H1jdsqQrh+2Y2yXV4/QpPoBEZoIdzv/+zw3/4KemFkNtMvrsPfJTZ5158WbEz896zynW9/x+Svp6l369HuTrTcxcKn7n5+Pon9f0ff37vq/XtHjXfhpo2Ncv9NdfzPo1/vhtoPLTyjJv9tdA82ugkj+/SF8DrM+2Yp9Dft6Cns/r1/c/YeB/8Kcib+wfg/z+uQrR242LJedTUok851I/Cyj+P4eyeJN45hfZ39V35fM8v1ZCQP4Up/jTqsLvWfnx7restPPnpJT+uSNw4ddg9h+vf7wOZP4Y/PBC/DNO7Otd/vX6rfH8vp3v//fuEe49n92t2glp/9rU9xbfO25UQl7e1zoP4X/jvbzH5DEC6DWys6NF5WFppkxabqppp5VuOu/VkrHEmk8WXnO2XN61USTPbCWGlyce6WYps+wyyJ+R3sLV/GMt6c0733SWBhPvxJ05MVj6pD//PY9/OdC9DvmUPJikPr38pOxAZRmeOX/mLhKS7jeO2gvw9+P3H89rIYPthXmwwRX1M4S29IUtx1F5iS7c2Hj9lEWS/TUAIWLuxmJSIQOxp9JST1FylpSI4yA/i4GG14aSgtRa3qwy11I6yRnZ5+Y7kt69ueXPZTiLRLTSi5CaWRa5qhAb+JE6wNBqpdXWWm/SRptt9dJrb7136U5+S4pUadJFZMiUNcqoo40+ZIww5lgzzwI5ttmnzDHnXItJFyMvvr24YS3NWrRq066iQ6cuAz5WrVk3sRFs2tp5lw1P7L5ljz33OukApVNPO/3IGWeedYHaLbfedvuVO+6860fWUvik9S+P/zxr6Ttr+WXKb5QfWeOrIt9DJKeT5jkjYxnFIGOeAQCdP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ICAgICAgICAgICAgICAgICAgICAKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIAogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgCiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIAogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgCiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIAogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgCiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIAogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgCiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIAogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgCiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIAogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgCiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAKICAgICAgICAgICAgICAgICAgICAgICAgICAgCjw/eHBhY2tldCBlbmQ9InciPz61xwk6AAAABmJLR0QAnQCdAJ2roJyEAAAACXBIWXMAAAsTAAALEwEAmpwYAAAAB3RJTUUH5gEYFgQKOBb3JwAAIABJREFUeNrtvXl0lFWePv7UvlelKvu+koSQRQiyBJGISEB0hFYZwW1sp4/2csaZ1jlz5sz80cc5c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2YNNmzahpaUFCoUiIrEIW8uE6/MUTqdDWUmVSoU1a9ZgzZo1mDt3LhISErisgoOTGMf0YHBwEE1NTTh+/Di+/fZb1NTUAAgtuZgM4QibzpHyurCwEPfccw8qKiqQl5eHhISEsIe6cnBwEuO4JVCt48jICLq7u9HW1oabN29iYGAAFosFPT09zK0cK8mQyWRQqVSse0RcXBzrypqamsoOI53pk9Y5ODiJcYQ09aN+ZG63m50BQL2XhK+nDhl0QpGwa4awMy4HBycxju+N2ML9HPLAvoOimYODkxgHBwfHHQqed+fg4OAkxsHBwcFJjIODg4OTGAcHBycxDg4ODk5iHBwcHJzEODg4ODiJcXBwcBLj4ODg4CTGwcHBwUmMg4ODg5MYBwcHJzEODg4OTmIcHBwcnMQ4ODg4iXFwcHBwEuPg4ODgJMbBwcHBSYyDg+MvCv8foPuErXNuO3cAAAAASUVORK5CYII="; + + public static HTMLElement rootElement = null; + public static void main(String args[]) { + rootElement = Window.current().getDocument().getBody(); + + registerErrorHandler(); + + try { + JSONObject e = new JSONObject(getOpts()); + initializeContext(e.getString("assetsLocation")); + }catch(Throwable ex2) { + StringWriter s = new StringWriter(); + ex2.printStackTrace(new java.io.PrintWriter(s)); + return; + } + + //Launch Minecraft + //try { + System.out.println(" -------- starting minecraft -------- "); + canvas.focus(); + Minecraft mc = new Minecraft(); + mc.session = new Session("Player094", "mcpass"); + mc.run(); + //} catch(Exception e) { + //rip + //} + } + + @JSBody(params = { }, script = "return JSON.stringify(window.config);") + public static native String getOpts(); + + private static String crashImageWrapper() { + return crashImage.substring(0); + } + + private static String addWebGLToCrash() { + StringBuilder ret = new StringBuilder(); + + WebGLRenderingContext ctx = webgl; + + if(ctx == null) { + HTMLCanvasElement cvs = (HTMLCanvasElement) Window.current().getDocument().createElement("canvas"); + + cvs.setWidth(64); + cvs.setHeight(64); + + ctx = (WebGLRenderingContext)cvs.getContext("webgl"); + } + + if(ctx != null) { + if(webgl != null) { + ret.append("webgl.version = ").append(ctx.getParameterString(WebGL2RenderingContext.VERSION)).append('\n'); + } + if(ctx.getExtension("WEBGL_debug_renderer_info") != null) { + ret.append("webgl.renderer = ").append(ctx.getParameterString(/* UNMASKED_RENDERER_WEBGL */ 0x9246)).append('\n'); + ret.append("webgl.vendor = ").append(ctx.getParameterString(/* UNMASKED_VENDOR_WEBGL */ 0x9245)).append('\n'); + }else { + ret.append("webgl.renderer = ").append("" + ctx.getParameterString(WebGL2RenderingContext.RENDERER) + " [masked]").append('\n'); + ret.append("webgl.vendor = ").append("" + ctx.getParameterString(WebGL2RenderingContext.VENDOR) + " [masked]").append('\n'); + } + ret.append("\nwebgl.anisotropicGlitch = ").append(DetectAnisotropicGlitch.hasGlitch()).append('\n'); + }else { + ret.append("Failed to query GPU info!\n"); + } + + return ret.toString(); + } + + public static void registerErrorHandler() { + setWindowErrorHandler(new WindowErrorHandler() { + + @Override + public void call(String message, String file, int line, int col, JSError error) { + StringBuilder str = new StringBuilder(); + + str.append("Exception Thrown\n"); + str.append("----------------------------------\n"); + str.append(" Line: ").append((file == null ? "unknown" : file) + ":" + line + ":" + col).append('\n'); + str.append(" Type: ").append(error == null ? "generic" : error.getName()).append('\n'); + + if(error != null) { + str.append(" Desc: ").append(error.getMessage() == null ? "null" : error.getMessage()).append('\n'); + } + + if(message != null) { + if(error == null || error.getMessage() == null || !message.endsWith(error.getMessage())) { + str.append(" Desc: ").append(message).append('\n'); + } + } + + str.append("----------------------------------\n\n"); + str.append(error.getStack() == null ? "No stack trace is available????" : error.getStack()).append('\n'); + + showCrashScreen(str.toString()); + } + + }); + } + + @JSFunctor + private static interface WindowErrorHandler extends JSObject { + void call(String message, String file, int line, int col, JSError error); + } + + @JSBody(params = { "handler" }, script = "window.addEventListener(\"error\", function(e) { handler(" + + "(typeof e.message === \"string\") ? e.message : null," + + "(typeof e.filename === \"string\") ? e.filename : null," + + "(typeof e.lineno === \"number\") ? e.lineno : 0," + + "(typeof e.colno === \"number\") ? e.colno : 0," + + "(typeof e.error === \"undefined\") ? null : e.error); });") + public static native void setWindowErrorHandler(WindowErrorHandler handler); + + private static boolean isCrashed = false; + + private static void showCrashScreen(String t) { + if(!isCrashed) { + isCrashed = true; + + StringBuilder str = new StringBuilder(); + str.append("Minecraft has crashed!").append('\n'); + str.append("If this has happened more than once then please copy the text on this screen and publish it in the issues feed of this fork's GitHub repository.\n\nThe URL to this fork's GitHub repository is: " + "https://github.com/PeytonPlayz595/1.2.5" + "\n\n"); + str.append(t); + str.append('\n').append('\n'); + str.append("minecraft.version = \"1.2.5\"\n"); + str.append("minecraft.author = \"PeytonPlayz585\"\n"); + str.append("minecraft.brand = \"eaglercraft\"\n"); + str.append('\n'); + str.append(addWebGLToCrash()); + str.append('\n'); + str.append('\n'); + addDebugNav(str, "userAgent"); + addDebugNav(str, "vendor"); + addDebugNav(str, "language"); + addDebugNav(str, "hardwareConcurrency"); + addDebugNav(str, "deviceMemory"); + addDebugNav(str, "platform"); + addDebugNav(str, "product"); + str.append('\n'); + str.append("rootElement.clientWidth = ").append(rootElement.getClientWidth()).append('\n'); + str.append("rootElement.clientHeight = ").append(rootElement.getClientHeight()).append('\n'); + addDebug(str, "innerWidth"); + addDebug(str, "innerHeight"); + addDebug(str, "outerWidth"); + addDebug(str, "outerHeight"); + addDebug(str, "devicePixelRatio"); + addDebugScreen(str, "availWidth"); + addDebugScreen(str, "availHeight"); + addDebugScreen(str, "colorDepth"); + addDebugScreen(str, "pixelDepth"); + str.append('\n'); + addDebugLocation(str, "href"); + addDebug(str, "minecraftServer"); + + String s = rootElement.getAttribute("style"); + rootElement.setAttribute("style", (s == null ? "" : s) + "position:relative;"); + HTMLDocument doc = Window.current().getDocument(); + HTMLElement img = doc.createElement("img"); + HTMLElement div = doc.createElement("div"); + img.setAttribute("style", "z-index:100;position:absolute;top:10px;left:calc(50% - 151px);"); + img.setAttribute("src", crashImageWrapper()); + div.setAttribute("style", "z-index:100;position:absolute;top:135px;left:10%;right:10%;bottom:30px;background-color:white;border:1px solid #cccccc;overflow-x:hidden;overflow-y:scroll;overflow-wrap:break-word;white-space:pre-wrap;font: 14px monospace;padding:10px;"); + rootElement.appendChild(img); + rootElement.appendChild(div); + div.appendChild(doc.createTextNode(str.toString())); + + removeEventHandlers(); + + } + } + + public static void showIncompatibleScreen(String t) { + if(!isCrashed) { + isCrashed = true; + + String s = rootElement.getAttribute("style"); + rootElement.setAttribute("style", (s == null ? "" : s) + "position:relative;"); + HTMLDocument doc = Window.current().getDocument(); + HTMLElement img = doc.createElement("img"); + HTMLElement div = doc.createElement("div"); + img.setAttribute("style", "z-index:100;position:absolute;top:10px;left:calc(50% - 151px);"); + img.setAttribute("src", crashImageWrapper()); + div.setAttribute("style", "z-index:100;position:absolute;top:135px;left:10%;right:10%;bottom:30px;background-color:white;border:1px solid #cccccc;overflow-x:hidden;overflow-y:scroll;font:18px sans-serif;padding:40px;"); + rootElement.appendChild(img); + rootElement.appendChild(div); + div.setInnerHTML("

+ This device is incompatible with Eaglercraft :(

" + + "
" + + "

Issue:

" + + "

" + + "

" + + "


Things you can try:

" + + "
    " + + "
  1. Just try using Eaglercraft on a different device, it isn't a bug it's common sense
  2. " + + "
  3. If you are on a mobile device, please try a proper desktop or a laptop computer
  4. " + + "
  5. If you are using a device with no mouse cursor, please use a device with a mouse cursor
  6. " + + "
  7. If you are not using Chrome/Edge, try installing the latest Google Chrome
  8. " + + "
  9. If your browser is out of date, please update it to the latest version
  10. " + + "
  11. If you are using an old OS such as Windows 7, please try Windows 10 or 11
  12. " + + "
  13. If you have a GPU launched before 2009, WebGL 2.0 support may be impossible
  14. " + + "
" + + "
"); + + div.querySelector("#crashReason").appendChild(doc.createTextNode(t)); + div.querySelector("#crashUserAgent").appendChild(doc.createTextNode(getStringNav("userAgent"))); + + removeEventHandlers(); + + String webGLRenderer = "No GL_RENDERER string could be queried"; + + try { + HTMLCanvasElement cvs = (HTMLCanvasElement) Window.current().getDocument().createElement("canvas"); + + cvs.setWidth(64); + cvs.setHeight(64); + + WebGLRenderingContext ctx = (WebGLRenderingContext)cvs.getContext("webgl"); + + if(ctx != null) { + String r; + if(ctx.getExtension("WEBGL_debug_renderer_info") != null) { + r = ctx.getParameterString(/* UNMASKED_RENDERER_WEBGL */ 0x9246); + }else { + r = ctx.getParameterString(WebGL2RenderingContext.RENDERER); + if(r != null) { + r += " [masked]"; + } + } + if(r != null) { + webGLRenderer = r; + } + } + }catch(Throwable tt) { + } + + div.querySelector("#crashWebGL").appendChild(doc.createTextNode(webGLRenderer)); + + } + } + + private static void addDebug(StringBuilder str, String var) { + str.append("window.").append(var).append(" = ").append(getString(var)).append('\n'); + } + + private static void addDebugNav(StringBuilder str, String var) { + str.append("window.navigator.").append(var).append(" = ").append(getStringNav(var)).append('\n'); + } + + private static void addDebugScreen(StringBuilder str, String var) { + str.append("window.screen.").append(var).append(" = ").append(getStringScreen(var)).append('\n'); + } + + private static void addDebugLocation(StringBuilder str, String var) { + str.append("window.location.").append(var).append(" = ").append(getStringLocation(var)).append('\n'); + } + + private static void addArray(StringBuilder str, String var) { + str.append("window.").append(var).append(" = ").append(getArray(var)).append('\n'); + } + + @JSBody(params = { "v" }, script = "try { return (typeof window[v] !== \"undefined\") ? JSON.stringify(window[v]) : \"[\\\"\\\"]\"; } catch(e) { return \"[\\\"\\\"]\"; }") + private static native String getArray(String var); + + @JSBody(params = { "v" }, script = "try { return \"\"+window.screen[v]; } catch(e) { return \"\"; }") + private static native String getStringScreen(String var); + + @JSBody(params = { "v" }, script = "try { return \"\"+window.location[v]; } catch(e) { return \"\"; }") + private static native String getStringLocation(String var); + + @JSBody(params = { "v" }, script = "try { return \"\"+window[v]; } catch(e) { return \"\"; }") + private static native String getString(String var); + + @JSBody(params = { "v" }, script = "try { return \"\"+window.navigator[v]; } catch(e) { return \"\"; }") + private static native String getStringNav(String var); + } \ No newline at end of file diff --git a/src/net/PeytonPlayz585/awt/image/BufferedImage.java b/src/net/PeytonPlayz585/awt/image/BufferedImage.java new file mode 100644 index 0000000..c56c865 --- /dev/null +++ b/src/net/PeytonPlayz585/awt/image/BufferedImage.java @@ -0,0 +1,81 @@ +package net.PeytonPlayz585.awt.image; + +public class BufferedImage { + + private final int[] pixels; + private final int width; + private final int height; + private final boolean isAlphaPremultiplied; + + public BufferedImage(int[] pixels, int width, int height, boolean alpha) { + if(pixels.length != width*height) { + throw new IllegalArgumentException("array size does not equal image size"); + } + + this.width = width; + this.height = height; + this.pixels = pixels; + this.isAlphaPremultiplied = alpha; + } + + public BufferedImage(int width, int height, int[] pixels, boolean alpha) { + if(pixels.length != width*height) { + throw new IllegalArgumentException("array size does not equal image size"); + } + + this.width = width; + this.height = height; + this.pixels = pixels; + this.isAlphaPremultiplied = alpha; + } + + public BufferedImage(int width, int height, boolean alpha) { + this.width = width; + this.height = height; + this.pixels = new int[width * height]; + this.isAlphaPremultiplied = alpha; + } + + public BufferedImage(int w, int h, int k) { + this.width = w; + this.height = h; + this.isAlphaPremultiplied = true; + this.pixels = new int[w * h]; + } + + public BufferedImage getSubImage(int x, int y, int pw, int ph) { + int[] img = new int[pw * ph]; + for(int i = 0; i < ph; ++i) { + System.arraycopy(pixels, (i + y) * this.width + x, img, i * pw, pw); + } + return new BufferedImage(pw, ph, img, isAlphaPremultiplied); + } + + public void getRGB(int startX, int startY, int w, int h, int[] rgbArray, int offset, int scansize) { + for (int y = 0; y < h; ++y) { + System.arraycopy(pixels, offset + (y + startY) * scansize + startX, rgbArray, y * w, w); + } + } + + public void setRGB(int startX, int startY, int w, int h, int[] rgbArray, int offset, int scansize) { + for (int y = 0; y < h; ++y) { + System.arraycopy(rgbArray, offset + (y + startY) * scansize + startX, pixels, y * w, w); + } + } + + public boolean isAlphaPremultiplied() { + return isAlphaPremultiplied; + } + + public int[] getData() { + return pixels; + } + + public int getWidth() { + return width; + } + + public int getHeight() { + return height; + } +} \ No newline at end of file diff --git a/src/net/PeytonPlayz585/awt/image/ImageIO.java b/src/net/PeytonPlayz585/awt/image/ImageIO.java new file mode 100644 index 0000000..e575712 --- /dev/null +++ b/src/net/PeytonPlayz585/awt/image/ImageIO.java @@ -0,0 +1,29 @@ +package net.PeytonPlayz585.awt.image; + +import java.io.ByteArrayInputStream; +import java.io.InputStream; + +import org.lwjgl.opengl.GL11; + +public class ImageIO { + + public static BufferedImage read(InputStream var1) { + ByteArrayInputStream bais = (ByteArrayInputStream)var1; + byte[] data = bais.readAllBytes(); + + return GL11.EaglerAdapterImpl2.loadPNG(data); + } + + public static BufferedImage read(BufferedImage resource) { + return resource; + } + + public static InputStream getResourceAsStream(String var1) { + return GL11.EaglerAdapterImpl2.loadResource(var1); + } + + public static BufferedImage getResource(String string) { + return GL11.EaglerAdapterImpl2.loadPNG(GL11.EaglerAdapterImpl2.loadResourceBytes(string)); + } + +} \ No newline at end of file diff --git a/src/net/PeytonPlayz585/fileutils/File.java b/src/net/PeytonPlayz585/fileutils/File.java new file mode 100644 index 0000000..259c758 --- /dev/null +++ b/src/net/PeytonPlayz585/fileutils/File.java @@ -0,0 +1,112 @@ +package net.PeytonPlayz585.fileutils; + +import java.util.Collection; + +import net.PeytonPlayz585.Client; +import net.PeytonPlayz585.fileutils.IndexedDBFilesystem.OpenState; + +public class File { + + public static final boolean fileExists(String path) { + return IndexedDBFilesystem.fileExists(path); + } + + public static final boolean directoryExists(String path) { + return IndexedDBFilesystem.directoryExists(path); + } + + public static final boolean pathExists(String path) { + return IndexedDBFilesystem.pathExists(path); + } + + public static final boolean exists(String path) { + return readFile(path) != null; + } + + public static final void mkdir(String path) { + String[] parts = path.split("/"); + String dir = parts[parts.length - 1]; + + if(path.endsWith("/")) { + String file = "placeholder.txt"; + path = path.replace(dir + "/", ""); + if(!path.endsWith("/")) { + path = path + "/"; + } + writeFile(path + dir + "/" + file, "UwU".getBytes()); + } else { + String file = "placeholder.txt"; + path = path.replace(dir, ""); + if(!path.endsWith("/")) { + path = path + "/"; + } + writeFile(path + dir + "/" + file, "UwU".getBytes()); + } + } + + public static final void writeFile(String path, byte[] data) { + IndexedDBFilesystem.writeFile(path, data); + } + + public static final byte[] readFile(String path) { + return IndexedDBFilesystem.readFile(path); + } + + public static final long getLastModified(String path) { + return IndexedDBFilesystem.getLastModified(path); + } + + public static final int getFileSize(String path) { + return IndexedDBFilesystem.getFileSize(path); + } + + public static final void renameFile(String oldPath, String newPath) { + IndexedDBFilesystem.renameFile(oldPath, newPath); + } + + public static final void copyFile(String oldPath, String newPath) { + IndexedDBFilesystem.copyFile(oldPath, newPath); + } + + public static final void deleteFile(String path) { + IndexedDBFilesystem.deleteFile(path); + } + + public static final Collection listFiles(String path, boolean listDirs, boolean recursiveDirs) { + return IndexedDBFilesystem.listFiles(path, listDirs, recursiveDirs); + } + + public static final Collection listFilesAndDirectories(String path) { + return listFiles(path, true, false); + } + + public static final Collection listFilesRecursive(String path) { + return listFiles(path, false, true); + } + + public static final FileEntry[] listFiles(String path) { + Collection entries = IndexedDBFilesystem.listFiles(path, true, false); + FileEntry[] entryArray = new FileEntry[entries.size()]; + + int i = 0; + for(FileEntry entry : entries) { + entryArray[i] = entry; + i = i + 1; + } + return entryArray; + } + + public static boolean isCompressed(byte[] b) { + if(b == null || b.length < 2) { + return false; + } + return (b[0] == (byte) 0x1F) && (b[1] == (byte) 0x8B); + } + + static { + if(IndexedDBFilesystem.initialize() != OpenState.OPENED) { + Client.showIncompatibleScreen("IndexedDB failed to initialize!"); + } + } + +} diff --git a/src/net/PeytonPlayz585/fileutils/FileEntry.java b/src/net/PeytonPlayz585/fileutils/FileEntry.java new file mode 100644 index 0000000..30b327b --- /dev/null +++ b/src/net/PeytonPlayz585/fileutils/FileEntry.java @@ -0,0 +1,24 @@ +package net.PeytonPlayz585.fileutils; + +public class FileEntry { + + public final String path; + public final boolean isDirectory; + public final long lastModified; + + public FileEntry(String path, boolean isDirectory, long lastModified) { + this.path = path; + this.isDirectory = isDirectory; + this.lastModified = lastModified; + } + + public String getName() { + int i = path.indexOf('/'); + if(i >= 0) { + return path.substring(i + 1); + }else { + return path; + } + } + +} \ No newline at end of file diff --git a/src/net/PeytonPlayz585/fileutils/FilesystemUtils.java b/src/net/PeytonPlayz585/fileutils/FilesystemUtils.java new file mode 100644 index 0000000..ea7b456 --- /dev/null +++ b/src/net/PeytonPlayz585/fileutils/FilesystemUtils.java @@ -0,0 +1,22 @@ +package net.PeytonPlayz585.fileutils; + +import java.util.Collection; + +public class FilesystemUtils { + + public static void recursiveDeleteDirectory(String dir) { + Collection lst = File.listFiles(dir, true, true); + for(FileEntry t : lst) { + if(!t.isDirectory) { + File.deleteFile(t.path); + } + } + for(FileEntry t : lst) { + if(t.isDirectory) { + File.deleteFile(t.path); + } + } + File.deleteFile(dir); + } + +} \ No newline at end of file diff --git a/src/net/lax1dude/eaglercraft/adapter/teavm/IDBObjectStorePatched.java b/src/net/PeytonPlayz585/fileutils/IDBObjectStorePatched.java similarity index 95% rename from src/net/lax1dude/eaglercraft/adapter/teavm/IDBObjectStorePatched.java rename to src/net/PeytonPlayz585/fileutils/IDBObjectStorePatched.java index d4e8403..c7fec6f 100644 --- a/src/net/lax1dude/eaglercraft/adapter/teavm/IDBObjectStorePatched.java +++ b/src/net/PeytonPlayz585/fileutils/IDBObjectStorePatched.java @@ -1,79 +1,79 @@ -package net.lax1dude.eaglercraft.adapter.teavm; - -import org.teavm.jso.JSBody; -import org.teavm.jso.JSObject; -import org.teavm.jso.JSProperty; -import org.teavm.jso.core.JSString; -import org.teavm.jso.indexeddb.IDBCountRequest; -import org.teavm.jso.indexeddb.IDBCursorRequest; -import org.teavm.jso.indexeddb.IDBCursorSource; -import org.teavm.jso.indexeddb.IDBDatabase; -import org.teavm.jso.indexeddb.IDBGetRequest; -import org.teavm.jso.indexeddb.IDBIndex; -import org.teavm.jso.indexeddb.IDBKeyRange; -import org.teavm.jso.indexeddb.IDBObjectStoreParameters; -import org.teavm.jso.indexeddb.IDBRequest; -import org.teavm.jso.indexeddb.IDBTransaction; - -public abstract class IDBObjectStorePatched implements JSObject, IDBCursorSource { - - @JSBody(params = { "db", "name", "optionalParameters" }, script = "return db.createObjectStore(name, optionalParameters);") - public static native IDBObjectStorePatched createObjectStorePatch(IDBDatabase db, String name, IDBObjectStoreParameters optionalParameters); - - @JSBody(params = { "tx", "name" }, script = "return tx.objectStore(name);") - public static native IDBObjectStorePatched objectStorePatch(IDBTransaction tx, String name); - - @JSProperty - public abstract String getName(); - - @JSProperty("keyPath") - abstract JSObject getKeyPathImpl(); - - public final String[] getKeyPath() { - JSObject result = getKeyPathImpl(); - if (JSString.isInstance(result)) { - return new String[] { result.cast().stringValue() }; - } else { - return unwrapStringArray(result); - } - } - - @JSBody(params = { "obj" }, script = "return this;") - private static native String[] unwrapStringArray(JSObject obj); - - @JSProperty - public abstract String[] getIndexNames(); - - @JSProperty - public abstract boolean isAutoIncrement(); - - public abstract IDBRequest put(JSObject value, JSObject key); - - public abstract IDBRequest put(JSObject value); - - public abstract IDBRequest add(JSObject value, JSObject key); - - public abstract IDBRequest add(JSObject value); - - public abstract IDBRequest delete(JSObject key); - - public abstract IDBGetRequest get(JSObject key); - - public abstract IDBRequest clear(); - - public abstract IDBCursorRequest openCursor(); - - public abstract IDBCursorRequest openCursor(IDBKeyRange range); - - public abstract IDBIndex createIndex(String name, String key); - - public abstract IDBIndex createIndex(String name, String[] keys); - - public abstract IDBIndex index(String name); - - public abstract void deleteIndex(String name); - - public abstract IDBCountRequest count(); - - public abstract IDBCountRequest count(JSObject key); +package net.PeytonPlayz585.fileutils; + +import org.teavm.jso.JSBody; +import org.teavm.jso.JSObject; +import org.teavm.jso.JSProperty; +import org.teavm.jso.core.JSString; +import org.teavm.jso.indexeddb.IDBCountRequest; +import org.teavm.jso.indexeddb.IDBCursorRequest; +import org.teavm.jso.indexeddb.IDBCursorSource; +import org.teavm.jso.indexeddb.IDBDatabase; +import org.teavm.jso.indexeddb.IDBGetRequest; +import org.teavm.jso.indexeddb.IDBIndex; +import org.teavm.jso.indexeddb.IDBKeyRange; +import org.teavm.jso.indexeddb.IDBObjectStoreParameters; +import org.teavm.jso.indexeddb.IDBRequest; +import org.teavm.jso.indexeddb.IDBTransaction; + +public abstract class IDBObjectStorePatched implements JSObject, IDBCursorSource { + + @JSBody(params = { "db", "name", "optionalParameters" }, script = "return db.createObjectStore(name, optionalParameters);") + public static native IDBObjectStorePatched createObjectStorePatch(IDBDatabase db, String name, IDBObjectStoreParameters optionalParameters); + + @JSBody(params = { "tx", "name" }, script = "return tx.objectStore(name);") + public static native IDBObjectStorePatched objectStorePatch(IDBTransaction tx, String name); + + @JSProperty + public abstract String getName(); + + @JSProperty("keyPath") + abstract JSObject getKeyPathImpl(); + + public final String[] getKeyPath() { + JSObject result = getKeyPathImpl(); + if (JSString.isInstance(result)) { + return new String[] { result.cast().stringValue() }; + } else { + return unwrapStringArray(result); + } + } + + @JSBody(params = { "obj" }, script = "return this;") + private static native String[] unwrapStringArray(JSObject obj); + + @JSProperty + public abstract String[] getIndexNames(); + + @JSProperty + public abstract boolean isAutoIncrement(); + + public abstract IDBRequest put(JSObject value, JSObject key); + + public abstract IDBRequest put(JSObject value); + + public abstract IDBRequest add(JSObject value, JSObject key); + + public abstract IDBRequest add(JSObject value); + + public abstract IDBRequest delete(JSObject key); + + public abstract IDBGetRequest get(JSObject key); + + public abstract IDBRequest clear(); + + public abstract IDBCursorRequest openCursor(); + + public abstract IDBCursorRequest openCursor(IDBKeyRange range); + + public abstract IDBIndex createIndex(String name, String key); + + public abstract IDBIndex createIndex(String name, String[] keys); + + public abstract IDBIndex index(String name); + + public abstract void deleteIndex(String name); + + public abstract IDBCountRequest count(); + + public abstract IDBCountRequest count(JSObject key); } \ No newline at end of file diff --git a/src/net/lax1dude/eaglercraft/adapter/teavm/IndexedDBFilesystem.java b/src/net/PeytonPlayz585/fileutils/IndexedDBFilesystem.java similarity index 94% rename from src/net/lax1dude/eaglercraft/adapter/teavm/IndexedDBFilesystem.java rename to src/net/PeytonPlayz585/fileutils/IndexedDBFilesystem.java index 928273d..d3735a0 100644 --- a/src/net/lax1dude/eaglercraft/adapter/teavm/IndexedDBFilesystem.java +++ b/src/net/PeytonPlayz585/fileutils/IndexedDBFilesystem.java @@ -1,414 +1,404 @@ -package net.lax1dude.eaglercraft.adapter.teavm; - -import java.util.Collection; -import java.util.LinkedList; - -import org.teavm.interop.Async; -import org.teavm.interop.AsyncCallback; -import org.teavm.jso.JSBody; -import org.teavm.jso.JSObject; -import org.teavm.jso.dom.events.EventListener; -import org.teavm.jso.indexeddb.EventHandler; -import org.teavm.jso.indexeddb.IDBCountRequest; -import org.teavm.jso.indexeddb.IDBCursor; -import org.teavm.jso.indexeddb.IDBCursorRequest; -import org.teavm.jso.indexeddb.IDBDatabase; -import org.teavm.jso.indexeddb.IDBFactory; -import org.teavm.jso.indexeddb.IDBGetRequest; -import org.teavm.jso.indexeddb.IDBObjectStoreParameters; -import org.teavm.jso.indexeddb.IDBOpenDBRequest; -import org.teavm.jso.indexeddb.IDBRequest; -import org.teavm.jso.indexeddb.IDBTransaction; -import org.teavm.jso.indexeddb.IDBVersionChangeEvent; -import org.teavm.jso.typedarrays.ArrayBuffer; -import org.teavm.jso.typedarrays.Uint8Array; - -import net.PeytonPlayz585.opengl.GL11; -import net.lax1dude.eaglercraft.adapter.EaglerAdapterImpl2; -import net.lax1dude.eaglercraft.adapter.EaglerAdapterImpl2.FileEntry; - -public class IndexedDBFilesystem { - - public static enum OpenState { - OPENED, LOCKED, ERROR - } - - private static String err = ""; - private static IDBDatabase db = null; - - public static final OpenState initialize() { - DatabaseOpen dbo; - if(GL11.dataBaseName != null) { - System.out.println("Setting custom database name to " + GL11.dataBaseName); - dbo = AsyncHandlers.openDB(GL11.dataBaseName); - } else { - dbo = AsyncHandlers.openDB("_net_PeytonPlayz585_eaglercraft_beta_IndexedDBFilesystem_1_7_3"); - } - if(dbo == null) { - err = "Unknown Error"; - return OpenState.ERROR; - } - if(dbo.failedLocked) { - return OpenState.LOCKED; - } - if(dbo.failedInit || dbo.database == null) { - err = dbo.failedError == null ? "Initialization Failed" : dbo.failedError; - return OpenState.ERROR; - } - db = dbo.database; - return OpenState.OPENED; - } - - public static final String errorDetail() { - return err; - } - - public static final boolean fileExists(String path) { - return AsyncHandlers.fileGetType(db, path) == FileExists.FILE; - } - - public static final boolean directoryExists(String path) { - return AsyncHandlers.fileGetType(db, path) == FileExists.DIRECTORY; - } - - public static final boolean pathExists(String path) { - return AsyncHandlers.fileExists(db, path).bool; - } - - private static final void mkdir(String dir) { - if(directoryExists(dir)) { - return; - } - int i = dir.lastIndexOf('/'); - if(i > 0) { - mkdir(dir.substring(0, i)); - } - AsyncHandlers.writeWholeFile(db, dir, true, ArrayBuffer.create(0)); - } - - public static final void writeFile(String path, byte[] data) { - int i = path.lastIndexOf('/'); - if(i > 0) { - mkdir(path.substring(0, i)); - } - Uint8Array arr = Uint8Array.create(data.length); - arr.set(data); - AsyncHandlers.writeWholeFile(db, path, false, arr.getBuffer()); - } - - public static final byte[] readFile(String path) { - ArrayBuffer arr = AsyncHandlers.readWholeFile(db, path); - if(arr == null) { - return null; - } - byte[] data = new byte[arr.getByteLength()]; - Uint8Array arrr = Uint8Array.create(arr); - for(int i = 0; i < data.length; ++i) { - data[i] = (byte) arrr.get(i); - } - return data; - } - - public static final long getLastModified(String path) { - int lm = AsyncHandlers.fileGetLastModified(db, path); - return lm == -1 ? -1l : AsyncHandlers.eaglercraftEpoch + lm; - } - - public static final int getFileSize(String path) { - ArrayBuffer arr = AsyncHandlers.readWholeFile(db, path); - if(arr == null) { - return -1; - }else { - return arr.getByteLength(); - } - } - - public static final void renameFile(String oldPath, String newPath) { - copyFile(oldPath, newPath); - AsyncHandlers.deleteFile(db, oldPath); - } - - public static final void copyFile(String oldPath, String newPath) { - ArrayBuffer arr = AsyncHandlers.readWholeFile(db, oldPath); - int i = newPath.lastIndexOf('/'); - if(i > 0) { - mkdir(newPath.substring(0, i)); - } - AsyncHandlers.writeWholeFile(db, newPath, false, arr); - } - - public static final void deleteFile(String path) { - AsyncHandlers.deleteFile(db, path); - } - - public static final Collection listFiles(String path, boolean listDirs, boolean recursiveDirs) { - LinkedList lst = new LinkedList(); - AsyncHandlers.iterateFiles(db, path, listDirs, recursiveDirs, lst); - return lst; - } - - protected static class BooleanResult { - - protected static final BooleanResult TRUE = new BooleanResult(true); - protected static final BooleanResult FALSE = new BooleanResult(false); - - protected final boolean bool; - - private BooleanResult(boolean b) { - bool = b; - } - - protected static BooleanResult _new(boolean b) { - return b ? TRUE : FALSE; - } - - } - - protected static class DatabaseOpen { - - protected final boolean failedInit; - protected final boolean failedLocked; - protected final String failedError; - - protected final IDBDatabase database; - - protected DatabaseOpen(boolean init, boolean locked, String error, IDBDatabase db) { - failedInit = init; - failedLocked = locked; - failedError = error; - database = db; - } - - } - - protected static enum FileExists { - FILE, DIRECTORY, FALSE - } - - @JSBody(script = "return ((typeof indexedDB) !== 'undefined') ? indexedDB : null;") - protected static native IDBFactory createIDBFactory(); - - protected static class AsyncHandlers { - - protected static final long eaglercraftEpoch = 1645568542000l; - - @Async - protected static native DatabaseOpen openDB(String name); - - private static void openDB(String name, final AsyncCallback cb) { - IDBFactory i = createIDBFactory(); - if(i == null) { - cb.complete(new DatabaseOpen(false, false, "window.indexedDB was null or undefined", null)); - return; - } - final IDBOpenDBRequest f = i.open(name, 1); - f.setOnBlocked(new EventHandler() { - public void handleEvent() { - cb.complete(new DatabaseOpen(false, true, null, null)); - } - }); - f.setOnSuccess(new EventHandler() { - public void handleEvent() { - cb.complete(new DatabaseOpen(false, false, null, f.getResult())); - } - }); - f.setOnError(new EventHandler() { - public void handleEvent() { - cb.complete(new DatabaseOpen(true, false, "open error", null)); - } - }); - f.setOnUpgradeNeeded(new EventListener() { - public void handleEvent(IDBVersionChangeEvent evt) { - IDBObjectStorePatched.createObjectStorePatch(f.getResult(), "filesystem", IDBObjectStoreParameters.create().keyPath("path")); - } - }); - } - - @Async - protected static native BooleanResult deleteFile(IDBDatabase db, String name); - - private static void deleteFile(IDBDatabase db, String name, final AsyncCallback cb) { - IDBTransaction tx = db.transaction("filesystem", "readwrite"); - final IDBRequest r = IDBObjectStorePatched.objectStorePatch(tx, "filesystem").delete(makeTheFuckingKeyWork(name)); - - r.setOnSuccess(new EventHandler() { - public void handleEvent() { - cb.complete(BooleanResult._new(true)); - } - }); - r.setOnError(new EventHandler() { - public void handleEvent() { - cb.complete(BooleanResult._new(false)); - } - }); - } - - @JSBody(params = { "obj" }, script = "return (typeof obj === 'undefined') ? null : ((typeof obj.data === 'undefined') ? null : obj.data);") - protected static native ArrayBuffer readRow(JSObject obj); - - @JSBody(params = { "obj" }, script = "return (typeof obj === 'undefined') ? false : ((typeof obj.directory === 'undefined') ? false : obj.directory);") - protected static native boolean isRowDirectory(JSObject obj); - - @JSBody(params = { "obj" }, script = "return (typeof obj === 'undefined') ? -1 : ((typeof obj.lastModified === 'undefined') ? -1 : obj.lastModified);") - protected static native int readLastModified(JSObject obj); - - @JSBody(params = { "obj" }, script = "return [obj];") - private static native JSObject makeTheFuckingKeyWork(String k); - - @Async - protected static native ArrayBuffer readWholeFile(IDBDatabase db, String name); - - private static void readWholeFile(IDBDatabase db, String name, final AsyncCallback cb) { - IDBTransaction tx = db.transaction("filesystem", "readonly"); - final IDBGetRequest r = IDBObjectStorePatched.objectStorePatch(tx, "filesystem").get(makeTheFuckingKeyWork(name)); - r.setOnSuccess(new EventHandler() { - public void handleEvent() { - cb.complete(isRowDirectory(r.getResult()) ? null : readRow(r.getResult())); - } - }); - r.setOnError(new EventHandler() { - public void handleEvent() { - cb.complete(null); - } - }); - - } - - @Async - protected static native Integer readLastModified(IDBDatabase db, String name); - - private static void readLastModified(IDBDatabase db, String name, final AsyncCallback cb) { - IDBTransaction tx = db.transaction("filesystem", "readonly"); - final IDBGetRequest r = IDBObjectStorePatched.objectStorePatch(tx, "filesystem").get(makeTheFuckingKeyWork(name)); - r.setOnSuccess(new EventHandler() { - public void handleEvent() { - cb.complete(readLastModified(r.getResult())); - } - }); - r.setOnError(new EventHandler() { - public void handleEvent() { - cb.complete(-1); - } - }); - - } - - @JSBody(params = { "k" }, script = "return ((typeof k) === \"string\") ? k : (((typeof k) === \"undefined\") ? null : (((typeof k[0]) === \"string\") ? k[0] : null));") - private static native String readKey(JSObject k); - - @Async - protected static native Integer iterateFiles(IDBDatabase db, final String prefix, final boolean listDirs, final boolean recursiveDirs, final Collection lst); - - private static void iterateFiles(IDBDatabase db, final String prefix, final boolean listDirs, final boolean recursiveDirs, final Collection lst, final AsyncCallback cb) { - IDBTransaction tx = db.transaction("filesystem", "readonly"); - final IDBCursorRequest r = IDBObjectStorePatched.objectStorePatch(tx, "filesystem").openCursor(); - final int[] res = new int[1]; - r.setOnSuccess(new EventHandler() { - public void handleEvent() { - IDBCursor c = r.getResult(); - if(c == null || c.getKey() == null || c.getValue() == null) { - cb.complete(res[0]); - return; - } - String k = readKey(c.getKey()); - if(k != null) { - if(k.startsWith(prefix)) { - if(recursiveDirs || k.indexOf('/', prefix.length() + 1) == -1) { - boolean dir = isRowDirectory(c.getValue()); - if(dir) { - if(listDirs) { - lst.add(new EaglerAdapterImpl2.FileEntry(k, true, -1)); - } - }else { - lst.add(new EaglerAdapterImpl2.FileEntry(k, false, eaglercraftEpoch + readLastModified(c.getValue()))); - } - } - } - } - c.doContinue(); - } - }); - r.setOnError(new EventHandler() { - public void handleEvent() { - cb.complete(res[0] > 0 ? res[0] : -1); - } - }); - } - - @Async - protected static native BooleanResult fileExists(IDBDatabase db, String name); - - private static void fileExists(IDBDatabase db, String name, final AsyncCallback cb) { - IDBTransaction tx = db.transaction("filesystem", "readonly"); - final IDBCountRequest r = IDBObjectStorePatched.objectStorePatch(tx, "filesystem").count(makeTheFuckingKeyWork(name)); - r.setOnSuccess(new EventHandler() { - public void handleEvent() { - cb.complete(BooleanResult._new(r.getResult() > 0)); - } - }); - r.setOnError(new EventHandler() { - public void handleEvent() { - cb.complete(BooleanResult._new(false)); - } - }); - } - - @Async - protected static native Integer fileGetLastModified(IDBDatabase db, String name); - - private static void fileGetLastModified(IDBDatabase db, String name, final AsyncCallback cb) { - IDBTransaction tx = db.transaction("filesystem", "readonly"); - final IDBGetRequest r = IDBObjectStorePatched.objectStorePatch(tx, "filesystem").get(makeTheFuckingKeyWork(name)); - r.setOnSuccess(new EventHandler() { - public void handleEvent() { - cb.complete(readLastModified(r.getResult())); - } - }); - r.setOnError(new EventHandler() { - public void handleEvent() { - cb.complete(-1); - } - }); - } - - @Async - protected static native FileExists fileGetType(IDBDatabase db, String name); - - private static void fileGetType(IDBDatabase db, String name, final AsyncCallback cb) { - IDBTransaction tx = db.transaction("filesystem", "readonly"); - final IDBGetRequest r = IDBObjectStorePatched.objectStorePatch(tx, "filesystem").get(makeTheFuckingKeyWork(name)); - r.setOnSuccess(new EventHandler() { - public void handleEvent() { - cb.complete(r.getResult() == null ? FileExists.FALSE : (isRowDirectory(r.getResult()) ? FileExists.DIRECTORY : FileExists.FILE)); - } - }); - r.setOnError(new EventHandler() { - public void handleEvent() { - cb.complete(FileExists.FALSE); - } - }); - } - - @JSBody(params = { "pat", "dir", "lm", "dat" }, script = "return { path: pat, directory: dir, lastModified: lm, data: dat };") - protected static native JSObject writeRow(String name, boolean directory, int lm, ArrayBuffer data); - - @Async - protected static native BooleanResult writeWholeFile(IDBDatabase db, String name, boolean directory, ArrayBuffer data); - - private static void writeWholeFile(IDBDatabase db, String name, boolean directory, ArrayBuffer data, final AsyncCallback cb) { - IDBTransaction tx = db.transaction("filesystem", "readwrite"); - final IDBRequest r = IDBObjectStorePatched.objectStorePatch(tx, "filesystem").put(writeRow(name, directory, (int)(System.currentTimeMillis() - eaglercraftEpoch), data)); - r.setOnSuccess(new EventHandler() { - public void handleEvent() { - cb.complete(BooleanResult._new(true)); - } - }); - r.setOnError(new EventHandler() { - public void handleEvent() { - cb.complete(BooleanResult._new(false)); - } - }); - } - } - +package net.PeytonPlayz585.fileutils; + +import java.util.Collection; +import java.util.LinkedList; + +import org.teavm.interop.Async; +import org.teavm.interop.AsyncCallback; +import org.teavm.jso.JSBody; +import org.teavm.jso.JSObject; +import org.teavm.jso.dom.events.EventListener; +import org.teavm.jso.indexeddb.EventHandler; +import org.teavm.jso.indexeddb.IDBCountRequest; +import org.teavm.jso.indexeddb.IDBCursor; +import org.teavm.jso.indexeddb.IDBCursorRequest; +import org.teavm.jso.indexeddb.IDBDatabase; +import org.teavm.jso.indexeddb.IDBFactory; +import org.teavm.jso.indexeddb.IDBGetRequest; +import org.teavm.jso.indexeddb.IDBObjectStoreParameters; +import org.teavm.jso.indexeddb.IDBOpenDBRequest; +import org.teavm.jso.indexeddb.IDBRequest; +import org.teavm.jso.indexeddb.IDBTransaction; +import org.teavm.jso.indexeddb.IDBVersionChangeEvent; +import org.teavm.jso.typedarrays.ArrayBuffer; +import org.teavm.jso.typedarrays.Uint8Array; + +public class IndexedDBFilesystem { + + public static enum OpenState { + OPENED, LOCKED, ERROR + } + + private static String err = ""; + private static IDBDatabase db = null; + + public static final OpenState initialize() { + DatabaseOpen dbo = AsyncHandlers.openDB("_net_PeytonPlayz585_eaglercraft_beta_IndexedDBFilesystem_1_7_3"); + if(dbo == null) { + err = "Unknown Error"; + return OpenState.ERROR; + } + if(dbo.failedLocked) { + return OpenState.LOCKED; + } + if(dbo.failedInit || dbo.database == null) { + err = dbo.failedError == null ? "Initialization Failed" : dbo.failedError; + return OpenState.ERROR; + } + db = dbo.database; + return OpenState.OPENED; + } + + public static final String errorDetail() { + return err; + } + + public static final boolean fileExists(String path) { + return AsyncHandlers.fileGetType(db, path) == FileExists.FILE; + } + + public static final boolean directoryExists(String path) { + return AsyncHandlers.fileGetType(db, path) == FileExists.DIRECTORY; + } + + public static final boolean pathExists(String path) { + return AsyncHandlers.fileExists(db, path).bool; + } + + private static final void mkdir(String dir) { + if(directoryExists(dir)) { + return; + } + int i = dir.lastIndexOf('/'); + if(i > 0) { + mkdir(dir.substring(0, i)); + } + AsyncHandlers.writeWholeFile(db, dir, true, ArrayBuffer.create(0)); + } + + public static final void writeFile(String path, byte[] data) { + int i = path.lastIndexOf('/'); + if(i > 0) { + mkdir(path.substring(0, i)); + } + Uint8Array arr = Uint8Array.create(data.length); + arr.set(data); + AsyncHandlers.writeWholeFile(db, path, false, arr.getBuffer()); + } + + public static final byte[] readFile(String path) { + ArrayBuffer arr = AsyncHandlers.readWholeFile(db, path); + if(arr == null) { + return null; + } + byte[] data = new byte[arr.getByteLength()]; + Uint8Array arrr = Uint8Array.create(arr); + for(int i = 0; i < data.length; ++i) { + data[i] = (byte) arrr.get(i); + } + return data; + } + + public static final long getLastModified(String path) { + int lm = AsyncHandlers.fileGetLastModified(db, path); + return lm == -1 ? -1l : AsyncHandlers.eaglercraftEpoch + lm; + } + + public static final int getFileSize(String path) { + ArrayBuffer arr = AsyncHandlers.readWholeFile(db, path); + if(arr == null) { + return -1; + }else { + return arr.getByteLength(); + } + } + + public static final void renameFile(String oldPath, String newPath) { + copyFile(oldPath, newPath); + AsyncHandlers.deleteFile(db, oldPath); + } + + public static final void copyFile(String oldPath, String newPath) { + ArrayBuffer arr = AsyncHandlers.readWholeFile(db, oldPath); + int i = newPath.lastIndexOf('/'); + if(i > 0) { + mkdir(newPath.substring(0, i)); + } + AsyncHandlers.writeWholeFile(db, newPath, false, arr); + } + + public static final void deleteFile(String path) { + AsyncHandlers.deleteFile(db, path); + } + + public static final Collection listFiles(String path, boolean listDirs, boolean recursiveDirs) { + LinkedList lst = new LinkedList(); + AsyncHandlers.iterateFiles(db, path, listDirs, recursiveDirs, lst); + return lst; + } + + protected static class BooleanResult { + + protected static final BooleanResult TRUE = new BooleanResult(true); + protected static final BooleanResult FALSE = new BooleanResult(false); + + protected final boolean bool; + + private BooleanResult(boolean b) { + bool = b; + } + + protected static BooleanResult _new(boolean b) { + return b ? TRUE : FALSE; + } + + } + + protected static class DatabaseOpen { + + protected final boolean failedInit; + protected final boolean failedLocked; + protected final String failedError; + + protected final IDBDatabase database; + + protected DatabaseOpen(boolean init, boolean locked, String error, IDBDatabase db) { + failedInit = init; + failedLocked = locked; + failedError = error; + database = db; + } + + } + + protected static enum FileExists { + FILE, DIRECTORY, FALSE + } + + @JSBody(script = "return ((typeof indexedDB) !== 'undefined') ? indexedDB : null;") + protected static native IDBFactory createIDBFactory(); + + protected static class AsyncHandlers { + + protected static final long eaglercraftEpoch = 1645568542000l; + + @Async + protected static native DatabaseOpen openDB(String name); + + private static void openDB(String name, final AsyncCallback cb) { + IDBFactory i = createIDBFactory(); + if(i == null) { + cb.complete(new DatabaseOpen(false, false, "window.indexedDB was null or undefined", null)); + return; + } + final IDBOpenDBRequest f = i.open(name, 1); + f.setOnBlocked(new EventHandler() { + public void handleEvent() { + cb.complete(new DatabaseOpen(false, true, null, null)); + } + }); + f.setOnSuccess(new EventHandler() { + public void handleEvent() { + cb.complete(new DatabaseOpen(false, false, null, f.getResult())); + } + }); + f.setOnError(new EventHandler() { + public void handleEvent() { + cb.complete(new DatabaseOpen(true, false, "open error", null)); + } + }); + f.setOnUpgradeNeeded(new EventListener() { + public void handleEvent(IDBVersionChangeEvent evt) { + IDBObjectStorePatched.createObjectStorePatch(f.getResult(), "filesystem", IDBObjectStoreParameters.create().keyPath("path")); + } + }); + } + + @Async + protected static native BooleanResult deleteFile(IDBDatabase db, String name); + + private static void deleteFile(IDBDatabase db, String name, final AsyncCallback cb) { + IDBTransaction tx = db.transaction("filesystem", "readwrite"); + final IDBRequest r = IDBObjectStorePatched.objectStorePatch(tx, "filesystem").delete(makeTheFuckingKeyWork(name)); + + r.setOnSuccess(new EventHandler() { + public void handleEvent() { + cb.complete(BooleanResult._new(true)); + } + }); + r.setOnError(new EventHandler() { + public void handleEvent() { + cb.complete(BooleanResult._new(false)); + } + }); + } + + @JSBody(params = { "obj" }, script = "return (typeof obj === 'undefined') ? null : ((typeof obj.data === 'undefined') ? null : obj.data);") + protected static native ArrayBuffer readRow(JSObject obj); + + @JSBody(params = { "obj" }, script = "return (typeof obj === 'undefined') ? false : ((typeof obj.directory === 'undefined') ? false : obj.directory);") + protected static native boolean isRowDirectory(JSObject obj); + + @JSBody(params = { "obj" }, script = "return (typeof obj === 'undefined') ? -1 : ((typeof obj.lastModified === 'undefined') ? -1 : obj.lastModified);") + protected static native int readLastModified(JSObject obj); + + @JSBody(params = { "obj" }, script = "return [obj];") + private static native JSObject makeTheFuckingKeyWork(String k); + + @Async + protected static native ArrayBuffer readWholeFile(IDBDatabase db, String name); + + private static void readWholeFile(IDBDatabase db, String name, final AsyncCallback cb) { + IDBTransaction tx = db.transaction("filesystem", "readonly"); + final IDBGetRequest r = IDBObjectStorePatched.objectStorePatch(tx, "filesystem").get(makeTheFuckingKeyWork(name)); + r.setOnSuccess(new EventHandler() { + public void handleEvent() { + cb.complete(isRowDirectory(r.getResult()) ? null : readRow(r.getResult())); + } + }); + r.setOnError(new EventHandler() { + public void handleEvent() { + cb.complete(null); + } + }); + + } + + @Async + protected static native Integer readLastModified(IDBDatabase db, String name); + + private static void readLastModified(IDBDatabase db, String name, final AsyncCallback cb) { + IDBTransaction tx = db.transaction("filesystem", "readonly"); + final IDBGetRequest r = IDBObjectStorePatched.objectStorePatch(tx, "filesystem").get(makeTheFuckingKeyWork(name)); + r.setOnSuccess(new EventHandler() { + public void handleEvent() { + cb.complete(readLastModified(r.getResult())); + } + }); + r.setOnError(new EventHandler() { + public void handleEvent() { + cb.complete(-1); + } + }); + + } + + @JSBody(params = { "k" }, script = "return ((typeof k) === \"string\") ? k : (((typeof k) === \"undefined\") ? null : (((typeof k[0]) === \"string\") ? k[0] : null));") + private static native String readKey(JSObject k); + + @Async + protected static native Integer iterateFiles(IDBDatabase db, final String prefix, final boolean listDirs, final boolean recursiveDirs, final Collection lst); + + private static void iterateFiles(IDBDatabase db, final String prefix, final boolean listDirs, final boolean recursiveDirs, final Collection lst, final AsyncCallback cb) { + IDBTransaction tx = db.transaction("filesystem", "readonly"); + final IDBCursorRequest r = IDBObjectStorePatched.objectStorePatch(tx, "filesystem").openCursor(); + final int[] res = new int[1]; + r.setOnSuccess(new EventHandler() { + public void handleEvent() { + IDBCursor c = r.getResult(); + if(c == null || c.getKey() == null || c.getValue() == null) { + cb.complete(res[0]); + return; + } + String k = readKey(c.getKey()); + if(k != null) { + if(k.startsWith(prefix)) { + if(recursiveDirs || k.indexOf('/', prefix.length() + 1) == -1) { + boolean dir = isRowDirectory(c.getValue()); + if(dir) { + if(listDirs) { + lst.add(new FileEntry(k, true, -1)); + } + }else { + lst.add(new FileEntry(k, false, eaglercraftEpoch + readLastModified(c.getValue()))); + } + } + } + } + c.doContinue(); + } + }); + r.setOnError(new EventHandler() { + public void handleEvent() { + cb.complete(res[0] > 0 ? res[0] : -1); + } + }); + } + + @Async + protected static native BooleanResult fileExists(IDBDatabase db, String name); + + private static void fileExists(IDBDatabase db, String name, final AsyncCallback cb) { + IDBTransaction tx = db.transaction("filesystem", "readonly"); + final IDBCountRequest r = IDBObjectStorePatched.objectStorePatch(tx, "filesystem").count(makeTheFuckingKeyWork(name)); + r.setOnSuccess(new EventHandler() { + public void handleEvent() { + cb.complete(BooleanResult._new(r.getResult() > 0)); + } + }); + r.setOnError(new EventHandler() { + public void handleEvent() { + cb.complete(BooleanResult._new(false)); + } + }); + } + + @Async + protected static native Integer fileGetLastModified(IDBDatabase db, String name); + + private static void fileGetLastModified(IDBDatabase db, String name, final AsyncCallback cb) { + IDBTransaction tx = db.transaction("filesystem", "readonly"); + final IDBGetRequest r = IDBObjectStorePatched.objectStorePatch(tx, "filesystem").get(makeTheFuckingKeyWork(name)); + r.setOnSuccess(new EventHandler() { + public void handleEvent() { + cb.complete(readLastModified(r.getResult())); + } + }); + r.setOnError(new EventHandler() { + public void handleEvent() { + cb.complete(-1); + } + }); + } + + @Async + protected static native FileExists fileGetType(IDBDatabase db, String name); + + private static void fileGetType(IDBDatabase db, String name, final AsyncCallback cb) { + IDBTransaction tx = db.transaction("filesystem", "readonly"); + final IDBGetRequest r = IDBObjectStorePatched.objectStorePatch(tx, "filesystem").get(makeTheFuckingKeyWork(name)); + r.setOnSuccess(new EventHandler() { + public void handleEvent() { + cb.complete(r.getResult() == null ? FileExists.FALSE : (isRowDirectory(r.getResult()) ? FileExists.DIRECTORY : FileExists.FILE)); + } + }); + r.setOnError(new EventHandler() { + public void handleEvent() { + cb.complete(FileExists.FALSE); + } + }); + } + + @JSBody(params = { "pat", "dir", "lm", "dat" }, script = "return { path: pat, directory: dir, lastModified: lm, data: dat };") + protected static native JSObject writeRow(String name, boolean directory, int lm, ArrayBuffer data); + + @Async + protected static native BooleanResult writeWholeFile(IDBDatabase db, String name, boolean directory, ArrayBuffer data); + + private static void writeWholeFile(IDBDatabase db, String name, boolean directory, ArrayBuffer data, final AsyncCallback cb) { + IDBTransaction tx = db.transaction("filesystem", "readwrite"); + final IDBRequest r = IDBObjectStorePatched.objectStorePatch(tx, "filesystem").put(writeRow(name, directory, (int)(System.currentTimeMillis() - eaglercraftEpoch), data)); + r.setOnSuccess(new EventHandler() { + public void handleEvent() { + cb.complete(BooleanResult._new(true)); + } + }); + r.setOnError(new EventHandler() { + public void handleEvent() { + cb.complete(BooleanResult._new(false)); + } + }); + } + } + } \ No newline at end of file diff --git a/src/net/PeytonPlayz585/glemu/FixedFunctionShader.java b/src/net/PeytonPlayz585/glemu/FixedFunctionShader.java index ae39a12..e1d948f 100644 --- a/src/net/PeytonPlayz585/glemu/FixedFunctionShader.java +++ b/src/net/PeytonPlayz585/glemu/FixedFunctionShader.java @@ -1,408 +1,638 @@ -package net.PeytonPlayz585.glemu; - -import static net.PeytonPlayz585.opengl.GL11.*; - -import java.util.ArrayList; -import java.util.List; - -import net.PeytonPlayz585.glemu.vector.*; - -public class FixedFunctionShader { - - private static final FixedFunctionShader[] instances = new FixedFunctionShader[128]; - private static final List instanceList = new ArrayList(); - - public static void refreshCoreGL() { - for (int i = 0; i < instances.length; ++i) { - if (instances[i] != null) { - _wglDeleteProgram(instances[i].globject); - instances[i] = null; - } - } - instanceList.clear(); - shaderSource = null; - } - - public static final int COLOR = 1; - public static final int NORMAL = 2; - public static final int TEXTURE0 = 4; - public static final int LIGHTING = 8; - public static final int FOG = 16; - public static final int ALPHATEST = 32; - public static final int UNIT0 = 64; - - public static FixedFunctionShader instance(int i) { - FixedFunctionShader s = instances[i]; - if (s == null) { - boolean CC_a_color = false; - boolean CC_a_normal = false; - boolean CC_a_texture0 = false; - boolean CC_lighting = false; - boolean CC_fog = false; - boolean CC_alphatest = false; - boolean CC_unit0 = false; - if ((i & COLOR) == COLOR) { - CC_a_color = true; - } - if ((i & NORMAL) == NORMAL) { - CC_a_normal = true; - } - if ((i & TEXTURE0) == TEXTURE0) { - CC_a_texture0 = true; - } - if ((i & LIGHTING) == LIGHTING) { - CC_lighting = true; - } - if ((i & FOG) == FOG) { - CC_fog = true; - } - if ((i & ALPHATEST) == ALPHATEST) { - CC_alphatest = true; - } - if ((i & UNIT0) == UNIT0) { - CC_unit0 = true; - } - s = new FixedFunctionShader(i, CC_a_color, CC_a_normal, CC_a_texture0, CC_lighting, CC_fog, CC_alphatest, CC_unit0); - instances[i] = s; - instanceList.add(s); - } - return s; - } - - private static String shaderSource = null; - - private final boolean enable_color; - private final boolean enable_normal; - private final boolean enable_texture0; - private final boolean enable_lighting; - private final boolean enable_fog; - private final boolean enable_alphatest; - private final boolean enable_unit0; - private final ProgramGL globject; - - private UniformGL u_matrix_m = null; - private UniformGL u_matrix_p = null; - private UniformGL u_matrix_t = null; - - private UniformGL u_fogColor = null; - private UniformGL u_fogMode = null; - private UniformGL u_fogStart = null; - private UniformGL u_fogEnd = null; - private UniformGL u_fogDensity = null; - private UniformGL u_fogPremultiply = null; - - private UniformGL u_colorUniform = null; - private UniformGL u_normalUniform = null; - - private UniformGL u_alphaTestF = null; - - private UniformGL u_texCoordV0 = null; - - private UniformGL u_light0Pos = null; - private UniformGL u_light1Pos = null; - - private final int a_position; - private final int a_texture0; - private final int a_color; - private final int a_normal; - - private final int attributeIndexesToEnable; - - public final StreamBuffer streamBuffer; - public boolean bufferIsInitialized = false; - - private FixedFunctionShader(int j, boolean CC_a_color, boolean CC_a_normal, boolean CC_a_texture0, - boolean CC_lighting, boolean CC_fog, boolean CC_alphatest, boolean CC_unit0) { - enable_color = CC_a_color; - enable_normal = CC_a_normal; - enable_texture0 = CC_a_texture0; - enable_lighting = CC_lighting; - enable_fog = CC_fog; - enable_alphatest = CC_alphatest; - enable_unit0 = CC_unit0; - - if (shaderSource == null) { - shaderSource = fileContents("/glsl/core.glsl"); - } - - String source = ""; - if (enable_color) - source += "\n#define CC_a_color\n"; - if (enable_normal) - source += "#define CC_a_normal\n"; - if (enable_texture0) - source += "#define CC_a_texture0\n"; - if (enable_lighting) - source += "#define CC_lighting\n"; - if (enable_fog) - source += "#define CC_fog\n"; - if (enable_alphatest) - source += "#define CC_alphatest\n"; - if (enable_unit0) - source += "#define CC_unit0\n"; - source += shaderSource; - - ShaderGL v = _wglCreateShader(_wGL_VERTEX_SHADER); - _wglShaderSource(v, _wgetShaderHeader() + "\n#define CC_VERT\n" + source); - _wglCompileShader(v); - - if (!_wglGetShaderCompiled(v)) { - System.err.println(("\n\n" + _wglGetShaderInfoLog(v)).replace("\n", "\n[/glsl/core.glsl][CC_VERT] ")); - throw new RuntimeException("broken shader file"); - } - - ShaderGL f = _wglCreateShader(_wGL_FRAGMENT_SHADER); - _wglShaderSource(f, _wgetShaderHeader() + "\n#define CC_FRAG\n" + source); - _wglCompileShader(f); - - if (!_wglGetShaderCompiled(f)) { - System.err.println(("\n\n" + _wglGetShaderInfoLog(f)).replace("\n", "\n[/glsl/core.glsl][CC_FRAG] ")); - throw new RuntimeException("broken shader file"); - } - - globject = _wglCreateProgram(); - _wglAttachShader(globject, v); - _wglAttachShader(globject, f); - - int i = 0; - a_position = i++; - _wglBindAttributeLocation(globject, a_position, "a_position"); - - if (enable_texture0) { - a_texture0 = i++; - _wglBindAttributeLocation(globject, a_texture0, "a_texture0"); - } else { - a_texture0 = -1; - } - if (enable_color) { - a_color = i++; - _wglBindAttributeLocation(globject, a_color, "a_color"); - } else { - a_color = -1; - } - if (enable_normal) { - a_normal = i++; - _wglBindAttributeLocation(globject, a_normal, "a_normal"); - } else { - a_normal = -1; - } - - attributeIndexesToEnable = i; - - _wglLinkProgram(globject); - - _wglDetachShader(globject, v); - _wglDetachShader(globject, f); - _wglDeleteShader(v); - _wglDeleteShader(f); - - if (!_wglGetProgramLinked(globject)) { - System.err.println(("\n\n" + _wglGetProgramInfoLog(globject)).replace("\n", "\n[LINKER] ")); - throw new RuntimeException("broken shader file"); - } - - _wglUseProgram(globject); - - u_matrix_m = _wglGetUniformLocation(globject, "matrix_m"); - u_matrix_p = _wglGetUniformLocation(globject, "matrix_p"); - u_matrix_t = _wglGetUniformLocation(globject, "matrix_t"); - - u_colorUniform = _wglGetUniformLocation(globject, "colorUniform"); - - if (enable_lighting) { - u_normalUniform = _wglGetUniformLocation(globject, "normalUniform"); - u_light0Pos = _wglGetUniformLocation(globject, "light0Pos"); - u_light1Pos = _wglGetUniformLocation(globject, "light1Pos"); - } - - if (enable_fog) { - u_fogColor = _wglGetUniformLocation(globject, "fogColor"); - u_fogMode = _wglGetUniformLocation(globject, "fogMode"); - u_fogStart = _wglGetUniformLocation(globject, "fogStart"); - u_fogEnd = _wglGetUniformLocation(globject, "fogEnd"); - u_fogDensity = _wglGetUniformLocation(globject, "fogDensity"); - u_fogPremultiply = _wglGetUniformLocation(globject, "fogPremultiply"); - } - - if (enable_alphatest) { - u_alphaTestF = _wglGetUniformLocation(globject, "alphaTestF"); - } - - _wglUniform1i(_wglGetUniformLocation(globject, "tex0"), 0); - u_texCoordV0 = _wglGetUniformLocation(globject, "texCoordV0"); - - streamBuffer = new StreamBuffer(0x8000, 3, 8, (vertexArray, vertexBuffer) -> { - _wglBindVertexArray0(vertexArray); - _wglBindBuffer(_wGL_ARRAY_BUFFER, vertexBuffer); - setupArrayForProgram(); - }); - - } - - public void setupArrayForProgram() { - _wglEnableVertexAttribArray(a_position); - _wglVertexAttribPointer(a_position, 3, _wGL_FLOAT, false, 28, 0); - if (enable_texture0) { - _wglEnableVertexAttribArray(a_texture0); - _wglVertexAttribPointer(a_texture0, 2, _wGL_FLOAT, false, 28, 12); - } - if (enable_color) { - _wglEnableVertexAttribArray(a_color); - _wglVertexAttribPointer(a_color, 4, _wGL_UNSIGNED_BYTE, true, 28, 20); - } - if (enable_normal) { - _wglEnableVertexAttribArray(a_normal); - _wglVertexAttribPointer(a_normal, 4, _wGL_UNSIGNED_BYTE, true, 28, 24); - } - } - - public void useProgram() { - _wglUseProgram(globject); - } - - public void unuseProgram() { - - } - - public static void optimize() { - FixedFunctionShader pp; - for(int i = 0, l = instanceList.size(); i < l; ++i) { - instanceList.get(i).streamBuffer.optimize(); - } - } - - private float[] modelBuffer = new float[16]; - private float[] projectionBuffer = new float[16]; - private float[] textureBuffer = new float[16]; - - private Matrix4f modelMatrix = (Matrix4f) new Matrix4f().setZero(); - private Matrix4f projectionMatrix = (Matrix4f) new Matrix4f().setZero(); - private Matrix4f textureMatrix = (Matrix4f) new Matrix4f().setZero(); - private Vector4f light0Pos = new Vector4f(); - private Vector4f light1Pos = new Vector4f(); - - public void setModelMatrix(Matrix4f mat) { - if (!mat.equals(modelMatrix)) { - modelMatrix.load(mat).store(modelBuffer); - _wglUniformMat4fv(u_matrix_m, modelBuffer); - } - } - - public void setProjectionMatrix(Matrix4f mat) { - if (!mat.equals(projectionMatrix)) { - projectionMatrix.load(mat).store(projectionBuffer); - _wglUniformMat4fv(u_matrix_p, projectionBuffer); - } - } - - public void setTextureMatrix(Matrix4f mat) { - if (!mat.equals(textureMatrix)) { - textureMatrix.load(mat).store(textureBuffer); - _wglUniformMat4fv(u_matrix_t, textureBuffer); - } - } - - public void setLightPositions(Vector4f pos0, Vector4f pos1) { - if (!pos0.equals(light0Pos) || !pos1.equals(light1Pos)) { - light0Pos.set(pos0); - light1Pos.set(pos1); - _wglUniform3f(u_light0Pos, light0Pos.x, light0Pos.y, light0Pos.z); - _wglUniform3f(u_light1Pos, light1Pos.x, light1Pos.y, light1Pos.z); - } - } - - private int fogMode = 0; - - public void setFogMode(int mode) { - if (fogMode != mode) { - fogMode = mode; - _wglUniform1i(u_fogMode, mode % 2); - _wglUniform1f(u_fogPremultiply, mode / 2); - } - } - - private float fogColorR = 0.0f; - private float fogColorG = 0.0f; - private float fogColorB = 0.0f; - private float fogColorA = 0.0f; - - public void setFogColor(float r, float g, float b, float a) { - if (fogColorR != r || fogColorG != g || fogColorB != b || fogColorA != a) { - fogColorR = r; - fogColorG = g; - fogColorB = b; - fogColorA = a; - _wglUniform4f(u_fogColor, fogColorR, fogColorG, fogColorB, fogColorA); - } - } - - private float fogStart = 0.0f; - private float fogEnd = 0.0f; - - public void setFogStartEnd(float s, float e) { - if (fogStart != s || fogEnd != e) { - fogStart = s; - fogEnd = e; - _wglUniform1f(u_fogStart, fogStart); - _wglUniform1f(u_fogEnd, fogEnd); - } - } - - private float fogDensity = 0.0f; - - public void setFogDensity(float d) { - if (fogDensity != d) { - fogDensity = d; - _wglUniform1f(u_fogDensity, fogDensity); - } - } - - private float alphaTestValue = 0.0f; - - public void setAlphaTest(float limit) { - if (alphaTestValue != limit) { - alphaTestValue = limit; - _wglUniform1f(u_alphaTestF, alphaTestValue); - } - } - - private float tex0x = 0.0f; - private float tex0y = 0.0f; - - public void setTex0Coords(float x, float y) { - if (tex0x != x || tex0y != y) { - tex0x = x; - tex0y = y; - _wglUniform2f(u_texCoordV0, tex0x, tex0y); - } - } - - private float colorUniformR = 0.0f; - private float colorUniformG = 0.0f; - private float colorUniformB = 0.0f; - private float colorUniformA = 0.0f; - - public void setColor(float r, float g, float b, float a) { - if (colorUniformR != r || colorUniformG != g || colorUniformB != b || colorUniformA != a) { - colorUniformR = r; - colorUniformG = g; - colorUniformB = b; - colorUniformA = a; - _wglUniform4f(u_colorUniform, colorUniformR, colorUniformG, colorUniformB, colorUniformA); - } - } - - private float normalUniformX = 0.0f; - private float normalUniformY = 0.0f; - private float normalUniformZ = 0.0f; - - public void setNormal(float x, float y, float z) { - if (normalUniformX != x || normalUniformY != y || normalUniformZ != z) { - normalUniformX = x; - normalUniformY = y; - normalUniformZ = z; - _wglUniform3f(u_normalUniform, normalUniformX, normalUniformY, normalUniformZ); - } - } - -} \ No newline at end of file +package net.PeytonPlayz585.glemu; + +import static org.lwjgl.opengl.GL11.EaglerAdapterImpl2.*; +import static org.lwjgl.opengl.GL11.*; + +import java.util.ArrayList; +import java.util.List; + +import org.lwjgl.opengl.GL11; +import org.lwjgl.opengl.GL11.EaglerAdapterImpl2.ProgramGL; +import org.lwjgl.opengl.GL11.EaglerAdapterImpl2.ShaderGL; +import org.lwjgl.opengl.GL11.EaglerAdapterImpl2.UniformGL; +import org.lwjgl.util.vector.Vector2f; +import org.lwjgl.util.vector.Vector4f; + +public class FixedFunctionShader { + + private static final FixedFunctionShader[] instances = new FixedFunctionShader[4096]; //lol + private static final List instanceList = new ArrayList(); + + public static void refreshCoreGL() { + for(int i = 0; i < instances.length; ++i) { + if(instances[i] != null) { + _wglDeleteProgram(instances[i].globject); + instances[i] = null; + } + } + instanceList.clear(); + shaderSource = null; + } + + public static final int COLOR = 1; + public static final int NORMAL = 2; + public static final int TEXTURE0 = 4; + public static final int TEXTURE1 = 8; + public static final int TEXGEN = 16; + public static final int LIGHTING = 32; + public static final int FOG = 64; + public static final int ALPHATEST = 128; + public static final int UNIT0 = 256; + public static final int UNIT1 = 512; + public static final int FIX_ANISOTROPIC = 1024; + public static final int SWAP_RB = 2048; + + public static FixedFunctionShader instance(int i) { + FixedFunctionShader s = instances[i]; + if(s == null) { + boolean CC_a_color = false; + boolean CC_a_normal = false; + boolean CC_a_texture0 = false; + boolean CC_a_texture1 = false; + boolean CC_TEX_GEN_STRQ = false; + boolean CC_lighting = false; + boolean CC_fog = false; + boolean CC_alphatest = false; + boolean CC_unit0 = false; + boolean CC_unit1 = false; + boolean CC_anisotropic = false; + boolean CC_swap_rb = false; + if((i & COLOR) == COLOR) { + CC_a_color = true; + } + if((i & NORMAL) == NORMAL) { + CC_a_normal = true; + } + if((i & TEXTURE0) == TEXTURE0) { + CC_a_texture0 = true; + } + if((i & TEXTURE1) == TEXTURE1) { + CC_a_texture1 = true; + } + if((i & TEXGEN) == TEXGEN) { + CC_TEX_GEN_STRQ = true; + } + if((i & LIGHTING) == LIGHTING) { + CC_lighting = true; + } + if((i & FOG) == FOG) { + CC_fog = true; + } + if((i & ALPHATEST) == ALPHATEST) { + CC_alphatest = true; + } + if((i & UNIT0) == UNIT0) { + CC_unit0 = true; + } + if((i & UNIT1) == UNIT1) { + CC_unit1 = true; + } + if((i & FIX_ANISOTROPIC) == FIX_ANISOTROPIC) { + CC_anisotropic = true; + } + if((i & SWAP_RB) == SWAP_RB) { + CC_swap_rb = true; + } + s = new FixedFunctionShader(i, CC_a_color, CC_a_normal, CC_a_texture0, CC_a_texture1, CC_TEX_GEN_STRQ, CC_lighting, + CC_fog, CC_alphatest, CC_unit0, CC_unit1, CC_anisotropic, CC_swap_rb); + instances[i] = s; + instanceList.add(s); + } + return s; + } + + private static String shaderSource = null; + + private final boolean enable_color; + private final boolean enable_normal; + private final boolean enable_texture0; + private final boolean enable_texture1; + private final boolean enable_TEX_GEN_STRQ; + private final boolean enable_lighting; + private final boolean enable_fog; + private final boolean enable_alphatest; + private final boolean enable_unit0; + private final boolean enable_unit1; + private final boolean enable_anisotropic_fix; + private final boolean enable_swap_rb; + private final ProgramGL globject; + + private UniformGL u_matrix_m = null; + private UniformGL u_matrix_p = null; + private UniformGL u_matrix_t = null; + + private UniformGL u_fogColor = null; + //private UniformGL u_fogMode = null; + //private UniformGL u_fogStart = null; + //private UniformGL u_fogEnd = null; + //private UniformGL u_fogDensity = null; + private UniformGL u_fogParam = null; + + private UniformGL u_colorUniform = null; + private UniformGL u_normalUniform = null; + + private UniformGL u_alphaTestF = null; + + //private UniformGL u_textureGenS_M = null; + //private UniformGL u_textureGenT_M = null; + //private UniformGL u_textureGenR_M = null; + //private UniformGL u_textureGenQ_M = null; + private UniformGL u_textureGen_M = null; + private UniformGL u_textureGenS_V = null; + private UniformGL u_textureGenT_V = null; + private UniformGL u_textureGenR_V = null; + private UniformGL u_textureGenQ_V = null; + + private UniformGL u_texCoordV0 = null; + private UniformGL u_texCoordV1 = null; + + private UniformGL u_light0Pos = null; + private UniformGL u_light1Pos = null; + //private UniformGL u_invertNormals = null; + + private UniformGL u_anisotropic_fix = null; + + private final int a_position; + private final int a_texture0; + private final int a_color; + private final int a_normal; + private final int a_texture1; + + private final int attributeIndexesToEnable; + + public final StreamBuffer streamBuffer; + public boolean bufferIsInitialized = false; + + private FixedFunctionShader(int j, boolean CC_a_color, boolean CC_a_normal, boolean CC_a_texture0, boolean CC_a_texture1, boolean CC_TEX_GEN_STRQ, boolean CC_lighting, + boolean CC_fog, boolean CC_alphatest, boolean CC_unit0, boolean CC_unit1, boolean CC_anisotropic_fix, boolean CC_swap_rb) { + enable_color = CC_a_color; + enable_normal = CC_a_normal; + enable_texture0 = CC_a_texture0; + enable_texture1 = CC_a_texture1; + enable_TEX_GEN_STRQ = CC_TEX_GEN_STRQ; + enable_lighting = CC_lighting; + enable_fog = CC_fog; + enable_alphatest = CC_alphatest; + enable_unit0 = CC_unit0; + enable_unit1 = CC_unit1; + enable_anisotropic_fix = CC_anisotropic_fix; + enable_swap_rb = CC_swap_rb; + + if(shaderSource == null) { + shaderSource = fileContents("/glsl/core.glsl"); + } + + String source = ""; + if(enable_color) source += "\n#define CC_a_color\n"; + if(enable_normal) source += "#define CC_a_normal\n"; + if(enable_texture0) source += "#define CC_a_texture0\n"; + if(enable_texture1) source += "#define CC_a_texture1\n"; + if(enable_TEX_GEN_STRQ) source += "#define CC_TEX_GEN_STRQ\n"; + if(enable_lighting) source += "#define CC_lighting\n"; + if(enable_fog) source += "#define CC_fog\n"; + if(enable_alphatest) source += "#define CC_alphatest\n"; + if(enable_unit0) source += "#define CC_unit0\n"; + if(enable_unit1) source += "#define CC_unit1\n"; + if(enable_anisotropic_fix) source += "#define CC_patch_anisotropic\n"; + if(enable_swap_rb) source += "#define CC_swap_rb\n"; + source += shaderSource; + + ShaderGL v = _wglCreateShader(_wGL_VERTEX_SHADER); + _wglShaderSource(v, _wgetShaderHeader()+"\n#define CC_VERT\n"+source); + _wglCompileShader(v); + + if(!_wglGetShaderCompiled(v)) { + System.err.println(("\n\n"+_wglGetShaderInfoLog(v)).replace("\n", "\n[/glsl/core.glsl][CC_VERT] ")); + throw new RuntimeException("broken shader file"); + } + + ShaderGL f = _wglCreateShader(_wGL_FRAGMENT_SHADER); + _wglShaderSource(f, _wgetShaderHeader()+"\n#define CC_FRAG\n"+source); + _wglCompileShader(f); + + if(!_wglGetShaderCompiled(f)) { + System.err.println(("\n\n"+_wglGetShaderInfoLog(f)).replace("\n", "\n[/glsl/core.glsl][CC_FRAG] ")); + throw new RuntimeException("broken shader file"); + } + + globject = _wglCreateProgram(); + _wglAttachShader(globject, v); + _wglAttachShader(globject, f); + + int i = 0; + a_position = i++; + _wglBindAttributeLocation(globject, a_position, "a_position"); + + if(enable_texture0) { + a_texture0 = i++; + _wglBindAttributeLocation(globject, a_texture0, "a_texture0"); + }else { + a_texture0 = -1; + } + if(enable_color) { + a_color = i++; + _wglBindAttributeLocation(globject, a_color, "a_color"); + }else { + a_color = -1; + } + if(enable_normal) { + a_normal = i++; + _wglBindAttributeLocation(globject, a_normal, "a_normal"); + }else { + a_normal = -1; + } + if(enable_texture1) { + a_texture1 = i++; + _wglBindAttributeLocation(globject, a_texture1, "a_texture1"); + }else { + a_texture1 = -1; + } + + attributeIndexesToEnable = i; + + _wglLinkProgram(globject); + + _wglDetachShader(globject, v); + _wglDetachShader(globject, f); + _wglDeleteShader(v); + _wglDeleteShader(f); + + if(!_wglGetProgramLinked(globject)) { + System.err.println(("\n\n"+_wglGetProgramInfoLog(globject)).replace("\n", "\n[LINKER] ")); + throw new RuntimeException("broken shader file"); + } + + _wglUseProgram(globject); + + u_matrix_m = _wglGetUniformLocation(globject, "matrix_m"); + u_matrix_p = _wglGetUniformLocation(globject, "matrix_p"); + u_matrix_t = _wglGetUniformLocation(globject, "matrix_t"); + + u_colorUniform = _wglGetUniformLocation(globject, "colorUniform"); + + if(enable_lighting) { + u_normalUniform = _wglGetUniformLocation(globject, "normalUniform"); + //u_invertNormals = _wglGetUniformLocation(globject, "invertNormals"); + u_light0Pos = _wglGetUniformLocation(globject, "light0Pos"); + u_light1Pos = _wglGetUniformLocation(globject, "light1Pos"); + } + + if(enable_fog) { + u_fogColor = _wglGetUniformLocation(globject, "fogColor"); + //u_fogMode = _wglGetUniformLocation(globject, "fogMode"); + //u_fogStart = _wglGetUniformLocation(globject, "fogStart"); + //u_fogEnd = _wglGetUniformLocation(globject, "fogEnd"); + //u_fogDensity = _wglGetUniformLocation(globject, "fogDensity"); + u_fogParam = _wglGetUniformLocation(globject, "fogParam"); + } + + if(enable_alphatest) { + u_alphaTestF = _wglGetUniformLocation(globject, "alphaTestF"); + } + + if(enable_TEX_GEN_STRQ) { + //u_textureGenS_M = _wglGetUniformLocation(globject, "textureGenS_M"); + //u_textureGenT_M = _wglGetUniformLocation(globject, "textureGenT_M"); + //u_textureGenR_M = _wglGetUniformLocation(globject, "textureGenR_M"); + //u_textureGenQ_M = _wglGetUniformLocation(globject, "textureGenQ_M"); + u_textureGen_M = _wglGetUniformLocation(globject, "textureGen_M"); + u_textureGenS_V = _wglGetUniformLocation(globject, "textureGenS_V"); + u_textureGenT_V = _wglGetUniformLocation(globject, "textureGenT_V"); + u_textureGenR_V = _wglGetUniformLocation(globject, "textureGenR_V"); + u_textureGenQ_V = _wglGetUniformLocation(globject, "textureGenQ_V"); + } + + if(enable_anisotropic_fix) { + u_anisotropic_fix = _wglGetUniformLocation(globject, "anisotropic_fix"); + _wglUniform2f(u_anisotropic_fix, 1024.0f * 63.0f / 64.0f, 1024.0f * 63.0f / 64.0f); + } + + _wglUniform1i(_wglGetUniformLocation(globject, "tex0"), 0); + _wglUniform1i(_wglGetUniformLocation(globject, "tex1"), 1); + + u_texCoordV0 = _wglGetUniformLocation(globject, "texCoordV0"); + u_texCoordV1 = _wglGetUniformLocation(globject, "texCoordV1"); + + streamBuffer = new StreamBuffer(0x8000, 3, 8, (vertexArray, vertexBuffer) -> { + _wglBindVertexArray0(vertexArray); + _wglBindBuffer(_wGL_ARRAY_BUFFER, vertexBuffer); + setupArrayForProgram(); + }); + + } + + public void setupArrayForProgram() { + _wglEnableVertexAttribArray(a_position); + _wglVertexAttribPointer(a_position, 3, _wGL_FLOAT, false, 32, 0); + if(enable_texture0) { + _wglEnableVertexAttribArray(a_texture0); + _wglVertexAttribPointer(a_texture0, 2, _wGL_FLOAT, false, 32, 12); + } + if(enable_color) { + _wglEnableVertexAttribArray(a_color); + _wglVertexAttribPointer(a_color, 4, _wGL_UNSIGNED_BYTE, true, 32, 20); + } + if(enable_normal) { + _wglEnableVertexAttribArray(a_normal); + _wglVertexAttribPointer(a_normal, 4, _wGL_UNSIGNED_BYTE, true, 32, 24); + } + if(enable_texture1) { + _wglEnableVertexAttribArray(a_texture1); + _wglVertexAttribPointer(a_texture1, 2, _wGL_SHORT, false, 32, 28); + } + } + + public void useProgram() { + _wglUseProgram(globject); + } + + public void unuseProgram() { + + } + + public static void optimize() { + FixedFunctionShader pp; + for(int i = 0, l = instanceList.size(); i < l; ++i) { + instanceList.get(i).streamBuffer.optimize(); + } + } + + private float[] matBuffer = new float[16]; + + private Vector4f light0Pos = new Vector4f(); + private Vector4f light1Pos = new Vector4f(); + private Vector2f anisotropicFix = new Vector2f(0.0f, 0.0f); + + private int fogMode = 0; + + private float fogColorR = 0.0f; + private float fogColorG = 0.0f; + private float fogColorB = 0.0f; + private float fogColorA = 0.0f; + + private float fogStart = 0.0f; + private float fogEnd = 0.0f; + + private float fogDensity = 0.0f; + + private float alphaTestValue = 0.0f; + + private float tex0x = 0.0f; + private float tex0y = 0.0f; + + private float tex1x = 0.0f; + private float tex1y = 0.0f; + + private float colorUniformR = 0.0f; + private float colorUniformG = 0.0f; + private float colorUniformB = 0.0f; + private float colorUniformA = 0.0f; + + private float normalUniformX = 0.0f; + private float normalUniformY = 0.0f; + private float normalUniformZ = 0.0f; + + private int anisotropicFixSerial = -1; + private int colorSerial = -1; + private int normalSerial = -1; + private int tex0Serial = -1; + private int tex1Serial = -1; + private int texPlaneSerial = -1; + private int texSSerial = -1; + private int texTSerial = -1; + private int texRSerial = -1; + private int texQSerial = -1; + private int fogColorSerial = -1; + private int fogCfgSerial = -1; + private int matModelSerialCounter = -1; + private int matProjSerialCounter = -1; + private int matTexSerialCounter = -1; + private int lightPos0Serial = -1; + private int lightPos1Serial = -1; + + private int texS_plane = -1; + private float texS_X = -999.0f; + private float texS_Y = -999.0f; + private float texS_Z = -999.0f; + private float texS_W = -999.0f; + + private int texT_plane = -1; + private float texT_X = -999.0f; + private float texT_Y = -999.0f; + private float texT_Z = -999.0f; + private float texT_W = -999.0f; + + private int texR_plane = -1; + private float texR_X = -999.0f; + private float texR_Y = -999.0f; + private float texR_Z = -999.0f; + private float texR_W = -999.0f; + + private int texQ_plane = -1; + private float texQ_X = -999.0f; + private float texQ_Y = -999.0f; + private float texQ_Z = -999.0f; + private float texQ_W = -999.0f; + + public void update() { + if(anisotropicFixSerial != GL11.anisotropicFixSerial) { + float x = GL11.anisotropicFixX; + float y = GL11.anisotropicFixY; + anisotropicFixSerial = GL11.anisotropicFixSerial; + if(anisotropicFix.x != x || anisotropicFix.y != y) { + anisotropicFix.x = x; + anisotropicFix.y = y; + _wglUniform2f(u_anisotropic_fix, x, y); + } + } + if(colorSerial != GL11.colorSerial) { + float r = GL11.colorR; + float g = GL11.colorG; + float b = GL11.colorB; + float a = GL11.colorA; + colorSerial = GL11.colorSerial; + if(colorUniformR != r || colorUniformG != g || colorUniformB != b || colorUniformA != a) { + colorUniformR = r; + colorUniformG = g; + colorUniformB = b; + colorUniformA = a; + _wglUniform4f(u_colorUniform, r, g, b, a); + } + } + if(normalSerial != GL11.normalSerial) { + float x = GL11.normalX; + float y = GL11.normalY; + float z = GL11.normalZ; + normalSerial = GL11.normalSerial; + if(normalUniformX != x || normalUniformY != y || normalUniformZ != z) { + normalUniformX = x; + normalUniformY = y; + normalUniformZ = z; + _wglUniform3f(u_normalUniform, x, y, z); + } + } + if(tex0Serial != GL11.tex0Serial) { + float x = GL11.tex0X; + float y = GL11.tex0Y; + tex0Serial = GL11.tex0Serial; + if(tex0x != x || tex0y != y) { + tex0x = x; + tex0y = y; + _wglUniform2f(u_texCoordV0, x, y); + } + } + if(tex1Serial != GL11.tex1Serial) { + float x = GL11.tex1X; + float y = GL11.tex1Y; + tex1Serial = GL11.tex1Serial; + if(tex1x != x || tex1y != y) { + tex1x = x; + tex1y = y; + _wglUniform2f(u_texCoordV1, x, y); + } + } + if(texPlaneSerial != GL11.texPlaneSerial) { + int s = GL11.texS_plane; + int t = GL11.texT_plane; + int r = GL11.texR_plane; + int q = GL11.texQ_plane; + texPlaneSerial = GL11.texPlaneSerial; + if(texS_plane != s || texT_plane != t || texR_plane != r || texQ_plane != q) { + texS_plane = s; + texT_plane = t; + texR_plane = r; + texQ_plane = q; + _wglUniform4i(u_textureGen_M, s, t, r, q); + } + } + if(texSSerial != GL11.texSSerial) { + float x = GL11.texS_X; + float y = GL11.texS_Y; + float z = GL11.texS_Z; + float w = GL11.texS_W; + texSSerial = GL11.texSSerial; + if(texS_X != x || texS_Y != y || texS_Z != z || texS_W != w) { + texS_X = x; + texS_Y = y; + texS_Z = z; + texS_W = w; + _wglUniform4f(u_textureGenS_V, x, y, z, w); + } + } + if(texTSerial != GL11.texTSerial) { + float x = GL11.texT_X; + float y = GL11.texT_Y; + float z = GL11.texT_Z; + float w = GL11.texT_W; + texTSerial = GL11.texTSerial; + if(texT_X != x || texT_Y != y || texT_Z != z || texT_W != w) { + texT_X = x; + texT_Y = y; + texT_Z = z; + texT_W = w; + _wglUniform4f(u_textureGenT_V, x, y, z, w); + } + } + if(texRSerial != GL11.texRSerial) { + float x = GL11.texR_X; + float y = GL11.texR_Y; + float z = GL11.texR_Z; + float w = GL11.texR_W; + texRSerial = GL11.texRSerial; + if(texR_X != x || texR_Y != y || texR_Z != z || texR_W != w) { + texR_X = x; + texR_Y = y; + texR_Z = z; + texR_W = w; + _wglUniform4f(u_textureGenR_V, x, y, z, w); + } + } + if(texQSerial != GL11.texQSerial) { + float x = GL11.texQ_X; + float y = GL11.texQ_Y; + float z = GL11.texQ_Z; + float w = GL11.texQ_W; + texQSerial = GL11.texQSerial; + if(texQ_X != x || texQ_Y != y || texQ_Z != z || texQ_W != w) { + texQ_X = x; + texQ_Y = y; + texQ_Z = z; + texQ_W = w; + _wglUniform4f(u_textureGenQ_V, x, y, z, w); + } + } + if(fogColorSerial != GL11.fogColorSerial) { + float r = GL11.fogColorR; + float g = GL11.fogColorG; + float b = GL11.fogColorB; + float a = GL11.fogColorA; + fogColorSerial = GL11.fogColorSerial; + if(fogColorR != r || fogColorG != g || fogColorB != b || fogColorA != a) { + fogColorR = r; + fogColorG = g; + fogColorB = b; + fogColorA = a; + _wglUniform4f(u_fogColor, r, g, b, a); + } + } + if(fogCfgSerial != GL11.fogCfgSerial) { + int fogModex = GL11.fogMode; + float fogStarty = GL11.fogStart; + float fogEndz = GL11.fogEnd - fogStarty; + float fogDensityw = GL11.fogDensity; + fogCfgSerial = GL11.fogCfgSerial; + if(fogMode != fogModex || fogStart != fogStarty || + fogEnd != fogEndz || fogDensity != fogDensityw) { + fogMode = fogModex; + fogStart = fogStarty; + fogEnd = fogEndz; + fogDensity = fogDensityw; + _wglUniform4f(u_fogParam, fogModex, fogStarty, fogEndz, fogDensityw); + } + } + float limit = GL11.alphaThresh; + if(alphaTestValue != limit) { + alphaTestValue = limit; + _wglUniform1f(u_alphaTestF, limit); + } + float[] matCopyBuffer = matBuffer; + int i = GL11.matModelPointer; + int j = GL11.matModelVSerial[i]; + if(matModelSerialCounter != j) { + matModelSerialCounter = j; + GL11.matModelV[i].store(matCopyBuffer); + _wglUniformMat4fv(u_matrix_m, matCopyBuffer); + } + i = GL11.matProjPointer; + j = GL11.matProjVSerial[i]; + if(matProjSerialCounter != j) { + matProjSerialCounter = j; + GL11.matProjV[i].store(matCopyBuffer); + _wglUniformMat4fv(u_matrix_p, matCopyBuffer); + } + i = GL11.matTexPointer; + j = GL11.matTexVSerial[i]; + if(matTexSerialCounter != j) { + matTexSerialCounter = j; + GL11.matTexV[i].store(matCopyBuffer); + _wglUniformMat4fv(u_matrix_t, matCopyBuffer); + } + if(lightPos0Serial != GL11.lightPos0Serial) { + lightPos0Serial = GL11.lightPos0Serial; + Vector4f pos = GL11.lightPos0vec; + if(!pos.equals(light0Pos)) { + light0Pos.set(pos); + _wglUniform3f(u_light0Pos, pos.x, pos.y, pos.z); + } + } + if(lightPos1Serial != GL11.lightPos1Serial) { + lightPos1Serial = GL11.lightPos1Serial; + Vector4f pos = GL11.lightPos1vec; + if(!pos.equals(light1Pos)) { + light1Pos.set(pos); + _wglUniform3f(u_light1Pos, pos.x, pos.y, pos.z); + } + } + } + +} diff --git a/src/net/PeytonPlayz585/glemu/GLObjectMap.java b/src/net/PeytonPlayz585/glemu/GLObjectMap.java deleted file mode 100644 index 409d52a..0000000 --- a/src/net/PeytonPlayz585/glemu/GLObjectMap.java +++ /dev/null @@ -1,55 +0,0 @@ -package net.PeytonPlayz585.glemu; - -public class GLObjectMap { - private Object[] values; - private int size; - private int insertIndex; - public int allocatedObjects; - - public GLObjectMap(int initialSize) { - this.values = new Object[initialSize]; - this.size = initialSize; - this.insertIndex = 0; - this.allocatedObjects = 0; - } - - public int register(T obj) { - int start = insertIndex; - do { - ++insertIndex; - if (insertIndex >= size) { - insertIndex = 0; - } - if (insertIndex == start) { - resize(); - return register(obj); - } - } while (values[insertIndex] != null); - values[insertIndex] = obj; - ++allocatedObjects; - return insertIndex; - } - - public T free(int obj) { - if (obj >= size || obj < 0) - return null; - Object ret = values[obj]; - values[obj] = null; - --allocatedObjects; - return (T) ret; - } - - public T get(int obj) { - if (obj >= size || obj < 0) - return null; - return (T) values[obj]; - } - - private void resize() { - int oldSize = size; - size += size / 2; - Object[] oldValues = values; - values = new Object[size]; - System.arraycopy(oldValues, 0, values, 0, oldSize); - } -} \ No newline at end of file diff --git a/src/net/PeytonPlayz585/glemu/GameOverlayFramebuffer.java b/src/net/PeytonPlayz585/glemu/GameOverlayFramebuffer.java index ca53d15..d47dd5e 100644 --- a/src/net/PeytonPlayz585/glemu/GameOverlayFramebuffer.java +++ b/src/net/PeytonPlayz585/glemu/GameOverlayFramebuffer.java @@ -1,6 +1,7 @@ package net.PeytonPlayz585.glemu; -import static net.PeytonPlayz585.opengl.GL11.*; +import static org.lwjgl.opengl.GL11.EaglerAdapterImpl2.*; +import static org.lwjgl.opengl.GL11.*; import java.nio.ByteBuffer; diff --git a/src/net/PeytonPlayz585/glemu/ModeBuffer.java b/src/net/PeytonPlayz585/glemu/ModeBuffer.java deleted file mode 100644 index f6aaee7..0000000 --- a/src/net/PeytonPlayz585/glemu/ModeBuffer.java +++ /dev/null @@ -1,58 +0,0 @@ -package net.PeytonPlayz585.glemu; - -import java.nio.FloatBuffer; - -import net.lax1dude.eaglercraft.GLAllocation; - -/** - * Utility class that emulates immediate mode vertex data submission. - * Can be used to create VBO data. - */ -public final class ModeBuffer { - - private FloatBuffer buffer; - - public ModeBuffer(final int startSize) { - this.buffer = GLAllocation.createDirectFloatBuffer(startSize); - } - - private void checkSize(final int count) { - while ( buffer.remaining() < count ) { - final FloatBuffer newBuffer = GLAllocation.createDirectFloatBuffer(buffer.capacity() << 1); - buffer.flip(); - newBuffer.put(buffer); - buffer = newBuffer; - } - } - - public FloatBuffer getBuffer() { - buffer.flip(); - return buffer; - } - - public void glVertex2f(final float x, final float y) { - checkSize(2); - buffer.put(x).put(y); - } - - public void glVertex3f(final float x, final float y, final float z) { - checkSize(3); - buffer.put(x).put(y).put(z); - } - - public void glVertex4f(final float x, final float y, final float z, final float w) { - checkSize(4); - buffer.put(x).put(y).put(z).put(w); - } - - public void glNormal3f(final float x, final float y, final float z) { - checkSize(3); - buffer.put(x).put(y).put(z); - } - - public void glTexCoord2f(final float s, final float t) { - checkSize(2); - buffer.put(s).put(t); - } - -} \ No newline at end of file diff --git a/src/net/PeytonPlayz585/glemu/StreamBuffer.java b/src/net/PeytonPlayz585/glemu/StreamBuffer.java index f2858cd..6055dfb 100644 --- a/src/net/PeytonPlayz585/glemu/StreamBuffer.java +++ b/src/net/PeytonPlayz585/glemu/StreamBuffer.java @@ -1,6 +1,6 @@ package net.PeytonPlayz585.glemu; -import static net.PeytonPlayz585.opengl.GL11.*; +import static org.lwjgl.opengl.GL11.EaglerAdapterImpl2.*; public class StreamBuffer { diff --git a/src/net/PeytonPlayz585/glemu/vector/Matrix.java b/src/net/PeytonPlayz585/glemu/vector/Matrix.java deleted file mode 100644 index d3e962d..0000000 --- a/src/net/PeytonPlayz585/glemu/vector/Matrix.java +++ /dev/null @@ -1,130 +0,0 @@ -/* - * Copyright (c) 2002-2008 LWJGL Project - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are - * met: - * - * * Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * - * * Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * - * * Neither the name of 'LWJGL' nor the names of - * its contributors may be used to endorse or promote products derived - * from this software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS - * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED - * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR - * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR - * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, - * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, - * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR - * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF - * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING - * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS - * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - */ -package net.PeytonPlayz585.glemu.vector; - -import java.io.Serializable; -import java.nio.FloatBuffer; - -/** - * - * Base class for matrices. When a matrix is constructed it will be the identity - * matrix unless otherwise stated. - * - * @author cix_foo - * @version $Revision$ $Id$ - */ -public abstract class Matrix implements Serializable { - - /** - * Constructor for Matrix. - */ - protected Matrix() { - super(); - } - - /** - * Set this matrix to be the identity matrix. - * - * @return this - */ - public abstract Matrix setIdentity(); - - /** - * Invert this matrix - * - * @return this - */ - public abstract Matrix invert(); - - /** - * Load from a float buffer. The buffer stores the matrix in column major - * (OpenGL) order. - * - * @param buf A float buffer to read from - * @return this - */ - public abstract Matrix load(FloatBuffer buf); - - /** - * Load from a float buffer. The buffer stores the matrix in row major - * (mathematical) order. - * - * @param buf A float buffer to read from - * @return this - */ - public abstract Matrix loadTranspose(FloatBuffer buf); - - /** - * Negate this matrix - * - * @return this - */ - public abstract Matrix negate(); - - /** - * Store this matrix in a float buffer. The matrix is stored in column major - * (openGL) order. - * - * @param buf The buffer to store this matrix in - * @return this - */ - public abstract Matrix store(FloatBuffer buf); - - /** - * Store this matrix in a float buffer. The matrix is stored in row major - * (maths) order. - * - * @param buf The buffer to store this matrix in - * @return this - */ - public abstract Matrix storeTranspose(FloatBuffer buf); - - /** - * Transpose this matrix - * - * @return this - */ - public abstract Matrix transpose(); - - /** - * Set this matrix to 0. - * - * @return this - */ - public abstract Matrix setZero(); - - /** - * @return the determinant of the matrix - */ - public abstract float determinant(); - -} diff --git a/src/net/PeytonPlayz585/glemu/vector/Matrix2f.java b/src/net/PeytonPlayz585/glemu/vector/Matrix2f.java deleted file mode 100644 index e48997e..0000000 --- a/src/net/PeytonPlayz585/glemu/vector/Matrix2f.java +++ /dev/null @@ -1,418 +0,0 @@ -/* - * Copyright (c) 2002-2008 LWJGL Project - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are - * met: - * - * * Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * - * * Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * - * * Neither the name of 'LWJGL' nor the names of - * its contributors may be used to endorse or promote products derived - * from this software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS - * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED - * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR - * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR - * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, - * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, - * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR - * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF - * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING - * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS - * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - */ -package net.PeytonPlayz585.glemu.vector; - -import java.io.Serializable; -import java.nio.FloatBuffer; - -/** - * - * Holds a 2x2 matrix - * - * @author cix_foo - * @version $Revision$ $Id$ - */ - -public class Matrix2f extends Matrix implements Serializable { - - private static final long serialVersionUID = 1L; - - public float m00, m01, m10, m11; - - /** - * Constructor for Matrix2f. The matrix is initialised to the identity. - */ - public Matrix2f() { - setIdentity(); - } - - /** - * Constructor - */ - public Matrix2f(Matrix2f src) { - load(src); - } - - /** - * Load from another matrix - * - * @param src The source matrix - * @return this - */ - public Matrix2f load(Matrix2f src) { - return load(src, this); - } - - /** - * Copy the source matrix to the destination matrix. - * - * @param src The source matrix - * @param dest The destination matrix, or null if a new one should be created. - * @return The copied matrix - */ - public static Matrix2f load(Matrix2f src, Matrix2f dest) { - if (dest == null) - dest = new Matrix2f(); - - dest.m00 = src.m00; - dest.m01 = src.m01; - dest.m10 = src.m10; - dest.m11 = src.m11; - - return dest; - } - - /** - * Load from a float buffer. The buffer stores the matrix in column major - * (OpenGL) order. - * - * @param buf A float buffer to read from - * @return this - */ - public Matrix load(FloatBuffer buf) { - - m00 = buf.get(); - m01 = buf.get(); - m10 = buf.get(); - m11 = buf.get(); - - return this; - } - - /** - * Load from a float buffer. The buffer stores the matrix in row major - * (mathematical) order. - * - * @param buf A float buffer to read from - * @return this - */ - public Matrix loadTranspose(FloatBuffer buf) { - - m00 = buf.get(); - m10 = buf.get(); - m01 = buf.get(); - m11 = buf.get(); - - return this; - } - - /** - * Store this matrix in a float buffer. The matrix is stored in column major - * (openGL) order. - * - * @param buf The buffer to store this matrix in - */ - public Matrix store(FloatBuffer buf) { - buf.put(m00); - buf.put(m01); - buf.put(m10); - buf.put(m11); - return this; - } - - /** - * Store this matrix in a float buffer. The matrix is stored in row major - * (maths) order. - * - * @param buf The buffer to store this matrix in - */ - public Matrix storeTranspose(FloatBuffer buf) { - buf.put(m00); - buf.put(m10); - buf.put(m01); - buf.put(m11); - return this; - } - - /** - * Add two matrices together and place the result in a third matrix. - * - * @param left The left source matrix - * @param right The right source matrix - * @param dest The destination matrix, or null if a new one is to be created - * @return the destination matrix - */ - public static Matrix2f add(Matrix2f left, Matrix2f right, Matrix2f dest) { - if (dest == null) - dest = new Matrix2f(); - - dest.m00 = left.m00 + right.m00; - dest.m01 = left.m01 + right.m01; - dest.m10 = left.m10 + right.m10; - dest.m11 = left.m11 + right.m11; - - return dest; - } - - /** - * Subtract the right matrix from the left and place the result in a third - * matrix. - * - * @param left The left source matrix - * @param right The right source matrix - * @param dest The destination matrix, or null if a new one is to be created - * @return the destination matrix - */ - public static Matrix2f sub(Matrix2f left, Matrix2f right, Matrix2f dest) { - if (dest == null) - dest = new Matrix2f(); - - dest.m00 = left.m00 - right.m00; - dest.m01 = left.m01 - right.m01; - dest.m10 = left.m10 - right.m10; - dest.m11 = left.m11 - right.m11; - - return dest; - } - - /** - * Multiply the right matrix by the left and place the result in a third matrix. - * - * @param left The left source matrix - * @param right The right source matrix - * @param dest The destination matrix, or null if a new one is to be created - * @return the destination matrix - */ - public static Matrix2f mul(Matrix2f left, Matrix2f right, Matrix2f dest) { - if (dest == null) - dest = new Matrix2f(); - - float m00 = left.m00 * right.m00 + left.m10 * right.m01; - float m01 = left.m01 * right.m00 + left.m11 * right.m01; - float m10 = left.m00 * right.m10 + left.m10 * right.m11; - float m11 = left.m01 * right.m10 + left.m11 * right.m11; - - dest.m00 = m00; - dest.m01 = m01; - dest.m10 = m10; - dest.m11 = m11; - - return dest; - } - - /** - * Transform a Vector by a matrix and return the result in a destination vector. - * - * @param left The left matrix - * @param right The right vector - * @param dest The destination vector, or null if a new one is to be created - * @return the destination vector - */ - public static Vector2f transform(Matrix2f left, Vector2f right, Vector2f dest) { - if (dest == null) - dest = new Vector2f(); - - float x = left.m00 * right.x + left.m10 * right.y; - float y = left.m01 * right.x + left.m11 * right.y; - - dest.x = x; - dest.y = y; - - return dest; - } - - /** - * Transpose this matrix - * - * @return this - */ - public Matrix transpose() { - return transpose(this); - } - - /** - * Transpose this matrix and place the result in another matrix. - * - * @param dest The destination matrix or null if a new matrix is to be created - * @return the transposed matrix - */ - public Matrix2f transpose(Matrix2f dest) { - return transpose(this, dest); - } - - /** - * Transpose the source matrix and place the result in the destination matrix. - * - * @param src The source matrix or null if a new matrix is to be created - * @param dest The destination matrix or null if a new matrix is to be created - * @return the transposed matrix - */ - public static Matrix2f transpose(Matrix2f src, Matrix2f dest) { - if (dest == null) - dest = new Matrix2f(); - - float m01 = src.m10; - float m10 = src.m01; - - dest.m01 = m01; - dest.m10 = m10; - - return dest; - } - - /** - * Invert this matrix - * - * @return this if successful, null otherwise - */ - public Matrix invert() { - return invert(this, this); - } - - /** - * Invert the source matrix and place the result in the destination matrix. - * - * @param src The source matrix to be inverted - * @param dest The destination matrix or null if a new matrix is to be created - * @return The inverted matrix, or null if source can't be reverted. - */ - public static Matrix2f invert(Matrix2f src, Matrix2f dest) { - /* - * inv(A) = 1/det(A) * adj(A); - */ - - float determinant = src.determinant(); - if (determinant != 0) { - if (dest == null) - dest = new Matrix2f(); - float determinant_inv = 1f / determinant; - float t00 = src.m11 * determinant_inv; - float t01 = -src.m01 * determinant_inv; - float t11 = src.m00 * determinant_inv; - float t10 = -src.m10 * determinant_inv; - - dest.m00 = t00; - dest.m01 = t01; - dest.m10 = t10; - dest.m11 = t11; - return dest; - } else - return null; - } - - /** - * Returns a string representation of this matrix - */ - public String toString() { - StringBuilder buf = new StringBuilder(); - buf.append(m00).append(' ').append(m10).append(' ').append('\n'); - buf.append(m01).append(' ').append(m11).append(' ').append('\n'); - return buf.toString(); - } - - /** - * Negate this matrix - * - * @return this - */ - public Matrix negate() { - return negate(this); - } - - /** - * Negate this matrix and stash the result in another matrix. - * - * @param dest The destination matrix, or null if a new matrix is to be created - * @return the negated matrix - */ - public Matrix2f negate(Matrix2f dest) { - return negate(this, dest); - } - - /** - * Negate the source matrix and stash the result in the destination matrix. - * - * @param src The source matrix to be negated - * @param dest The destination matrix, or null if a new matrix is to be created - * @return the negated matrix - */ - public static Matrix2f negate(Matrix2f src, Matrix2f dest) { - if (dest == null) - dest = new Matrix2f(); - - dest.m00 = -src.m00; - dest.m01 = -src.m01; - dest.m10 = -src.m10; - dest.m11 = -src.m11; - - return dest; - } - - /** - * Set this matrix to be the identity matrix. - * - * @return this - */ - public Matrix setIdentity() { - return setIdentity(this); - } - - /** - * Set the source matrix to be the identity matrix. - * - * @param src The matrix to set to the identity. - * @return The source matrix - */ - public static Matrix2f setIdentity(Matrix2f src) { - src.m00 = 1.0f; - src.m01 = 0.0f; - src.m10 = 0.0f; - src.m11 = 1.0f; - return src; - } - - /** - * Set this matrix to 0. - * - * @return this - */ - public Matrix setZero() { - return setZero(this); - } - - public static Matrix2f setZero(Matrix2f src) { - src.m00 = 0.0f; - src.m01 = 0.0f; - src.m10 = 0.0f; - src.m11 = 0.0f; - return src; - } - - /* - * (non-Javadoc) - * - * @see org.lwjgl.vector.Matrix#determinant() - */ - public float determinant() { - return m00 * m11 - m01 * m10; - } -} diff --git a/src/net/PeytonPlayz585/glemu/vector/Matrix3f.java b/src/net/PeytonPlayz585/glemu/vector/Matrix3f.java deleted file mode 100644 index 06ccf59..0000000 --- a/src/net/PeytonPlayz585/glemu/vector/Matrix3f.java +++ /dev/null @@ -1,529 +0,0 @@ -/* - * Copyright (c) 2002-2008 LWJGL Project - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are - * met: - * - * * Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * - * * Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * - * * Neither the name of 'LWJGL' nor the names of - * its contributors may be used to endorse or promote products derived - * from this software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS - * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED - * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR - * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR - * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, - * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, - * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR - * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF - * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING - * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS - * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - */ -package net.PeytonPlayz585.glemu.vector; - -import java.io.Serializable; -import java.nio.FloatBuffer; - -/** - * - * Holds a 3x3 matrix. - * - * @author cix_foo - * @version $Revision$ $Id$ - */ - -public class Matrix3f extends Matrix implements Serializable { - - private static final long serialVersionUID = 1L; - - public float m00, m01, m02, m10, m11, m12, m20, m21, m22; - - /** - * Constructor for Matrix3f. Matrix is initialised to the identity. - */ - public Matrix3f() { - super(); - setIdentity(); - } - - /** - * Load from another matrix - * - * @param src The source matrix - * @return this - */ - public Matrix3f load(Matrix3f src) { - return load(src, this); - } - - /** - * Copy source matrix to destination matrix - * - * @param src The source matrix - * @param dest The destination matrix, or null of a new matrix is to be created - * @return The copied matrix - */ - public static Matrix3f load(Matrix3f src, Matrix3f dest) { - if (dest == null) - dest = new Matrix3f(); - - dest.m00 = src.m00; - dest.m10 = src.m10; - dest.m20 = src.m20; - dest.m01 = src.m01; - dest.m11 = src.m11; - dest.m21 = src.m21; - dest.m02 = src.m02; - dest.m12 = src.m12; - dest.m22 = src.m22; - - return dest; - } - - /** - * Load from a float buffer. The buffer stores the matrix in column major - * (OpenGL) order. - * - * @param buf A float buffer to read from - * @return this - */ - public Matrix load(FloatBuffer buf) { - - m00 = buf.get(); - m01 = buf.get(); - m02 = buf.get(); - m10 = buf.get(); - m11 = buf.get(); - m12 = buf.get(); - m20 = buf.get(); - m21 = buf.get(); - m22 = buf.get(); - - return this; - } - - /** - * Load from a float buffer. The buffer stores the matrix in row major (maths) - * order. - * - * @param buf A float buffer to read from - * @return this - */ - public Matrix loadTranspose(FloatBuffer buf) { - - m00 = buf.get(); - m10 = buf.get(); - m20 = buf.get(); - m01 = buf.get(); - m11 = buf.get(); - m21 = buf.get(); - m02 = buf.get(); - m12 = buf.get(); - m22 = buf.get(); - - return this; - } - - /** - * Store this matrix in a float buffer. The matrix is stored in column major - * (openGL) order. - * - * @param buf The buffer to store this matrix in - */ - public Matrix store(FloatBuffer buf) { - buf.put(m00); - buf.put(m01); - buf.put(m02); - buf.put(m10); - buf.put(m11); - buf.put(m12); - buf.put(m20); - buf.put(m21); - buf.put(m22); - return this; - } - - public Matrix store(float[] buf) { - buf[0] = m00; - buf[1] = m01; - buf[2] = m02; - buf[3] = m10; - buf[4] = m11; - buf[5] = m12; - buf[6] = m20; - buf[7] = m21; - buf[8] = m22; - return this; - } - - /** - * Store this matrix in a float buffer. The matrix is stored in row major - * (maths) order. - * - * @param buf The buffer to store this matrix in - */ - public Matrix storeTranspose(FloatBuffer buf) { - buf.put(m00); - buf.put(m10); - buf.put(m20); - buf.put(m01); - buf.put(m11); - buf.put(m21); - buf.put(m02); - buf.put(m12); - buf.put(m22); - return this; - } - - /** - * Add two matrices together and place the result in a third matrix. - * - * @param left The left source matrix - * @param right The right source matrix - * @param dest The destination matrix, or null if a new one is to be created - * @return the destination matrix - */ - public static Matrix3f add(Matrix3f left, Matrix3f right, Matrix3f dest) { - if (dest == null) - dest = new Matrix3f(); - - dest.m00 = left.m00 + right.m00; - dest.m01 = left.m01 + right.m01; - dest.m02 = left.m02 + right.m02; - dest.m10 = left.m10 + right.m10; - dest.m11 = left.m11 + right.m11; - dest.m12 = left.m12 + right.m12; - dest.m20 = left.m20 + right.m20; - dest.m21 = left.m21 + right.m21; - dest.m22 = left.m22 + right.m22; - - return dest; - } - - /** - * Subtract the right matrix from the left and place the result in a third - * matrix. - * - * @param left The left source matrix - * @param right The right source matrix - * @param dest The destination matrix, or null if a new one is to be created - * @return the destination matrix - */ - public static Matrix3f sub(Matrix3f left, Matrix3f right, Matrix3f dest) { - if (dest == null) - dest = new Matrix3f(); - - dest.m00 = left.m00 - right.m00; - dest.m01 = left.m01 - right.m01; - dest.m02 = left.m02 - right.m02; - dest.m10 = left.m10 - right.m10; - dest.m11 = left.m11 - right.m11; - dest.m12 = left.m12 - right.m12; - dest.m20 = left.m20 - right.m20; - dest.m21 = left.m21 - right.m21; - dest.m22 = left.m22 - right.m22; - - return dest; - } - - /** - * Multiply the right matrix by the left and place the result in a third matrix. - * - * @param left The left source matrix - * @param right The right source matrix - * @param dest The destination matrix, or null if a new one is to be created - * @return the destination matrix - */ - public static Matrix3f mul(Matrix3f left, Matrix3f right, Matrix3f dest) { - if (dest == null) - dest = new Matrix3f(); - - float m00 = left.m00 * right.m00 + left.m10 * right.m01 + left.m20 * right.m02; - float m01 = left.m01 * right.m00 + left.m11 * right.m01 + left.m21 * right.m02; - float m02 = left.m02 * right.m00 + left.m12 * right.m01 + left.m22 * right.m02; - float m10 = left.m00 * right.m10 + left.m10 * right.m11 + left.m20 * right.m12; - float m11 = left.m01 * right.m10 + left.m11 * right.m11 + left.m21 * right.m12; - float m12 = left.m02 * right.m10 + left.m12 * right.m11 + left.m22 * right.m12; - float m20 = left.m00 * right.m20 + left.m10 * right.m21 + left.m20 * right.m22; - float m21 = left.m01 * right.m20 + left.m11 * right.m21 + left.m21 * right.m22; - float m22 = left.m02 * right.m20 + left.m12 * right.m21 + left.m22 * right.m22; - - dest.m00 = m00; - dest.m01 = m01; - dest.m02 = m02; - dest.m10 = m10; - dest.m11 = m11; - dest.m12 = m12; - dest.m20 = m20; - dest.m21 = m21; - dest.m22 = m22; - - return dest; - } - - /** - * Transform a Vector by a matrix and return the result in a destination vector. - * - * @param left The left matrix - * @param right The right vector - * @param dest The destination vector, or null if a new one is to be created - * @return the destination vector - */ - public static Vector3f transform(Matrix3f left, Vector3f right, Vector3f dest) { - if (dest == null) - dest = new Vector3f(); - - float x = left.m00 * right.x + left.m10 * right.y + left.m20 * right.z; - float y = left.m01 * right.x + left.m11 * right.y + left.m21 * right.z; - float z = left.m02 * right.x + left.m12 * right.y + left.m22 * right.z; - - dest.x = x; - dest.y = y; - dest.z = z; - - return dest; - } - - /** - * Transpose this matrix - * - * @return this - */ - public Matrix transpose() { - return transpose(this, this); - } - - /** - * Transpose this matrix and place the result in another matrix - * - * @param dest The destination matrix or null if a new matrix is to be created - * @return the transposed matrix - */ - public Matrix3f transpose(Matrix3f dest) { - return transpose(this, dest); - } - - /** - * Transpose the source matrix and place the result into the destination matrix - * - * @param src The source matrix to be transposed - * @param dest The destination matrix or null if a new matrix is to be created - * @return the transposed matrix - */ - public static Matrix3f transpose(Matrix3f src, Matrix3f dest) { - if (dest == null) - dest = new Matrix3f(); - float m00 = src.m00; - float m01 = src.m10; - float m02 = src.m20; - float m10 = src.m01; - float m11 = src.m11; - float m12 = src.m21; - float m20 = src.m02; - float m21 = src.m12; - float m22 = src.m22; - - dest.m00 = m00; - dest.m01 = m01; - dest.m02 = m02; - dest.m10 = m10; - dest.m11 = m11; - dest.m12 = m12; - dest.m20 = m20; - dest.m21 = m21; - dest.m22 = m22; - return dest; - } - - /** - * @return the determinant of the matrix - */ - public float determinant() { - float f = m00 * (m11 * m22 - m12 * m21) + m01 * (m12 * m20 - m10 * m22) + m02 * (m10 * m21 - m11 * m20); - return f; - } - - /** - * Returns a string representation of this matrix - */ - public String toString() { - StringBuilder buf = new StringBuilder(); - buf.append(m00).append(' ').append(m10).append(' ').append(m20).append(' ').append('\n'); - buf.append(m01).append(' ').append(m11).append(' ').append(m21).append(' ').append('\n'); - buf.append(m02).append(' ').append(m12).append(' ').append(m22).append(' ').append('\n'); - return buf.toString(); - } - - /** - * Invert this matrix - * - * @return this if successful, null otherwise - */ - public Matrix invert() { - return invert(this, this); - } - - /** - * Invert the source matrix and put the result into the destination matrix - * - * @param src The source matrix to be inverted - * @param dest The destination matrix, or null if a new one is to be created - * @return The inverted matrix if successful, null otherwise - */ - public static Matrix3f invert(Matrix3f src, Matrix3f dest) { - float determinant = src.determinant(); - - if (determinant != 0) { - if (dest == null) - dest = new Matrix3f(); - /* - * do it the ordinary way - * - * inv(A) = 1/det(A) * adj(T), where adj(T) = transpose(Conjugate Matrix) - * - * m00 m01 m02 m10 m11 m12 m20 m21 m22 - */ - float determinant_inv = 1f / determinant; - - // get the conjugate matrix - float t00 = src.m11 * src.m22 - src.m12 * src.m21; - float t01 = -src.m10 * src.m22 + src.m12 * src.m20; - float t02 = src.m10 * src.m21 - src.m11 * src.m20; - float t10 = -src.m01 * src.m22 + src.m02 * src.m21; - float t11 = src.m00 * src.m22 - src.m02 * src.m20; - float t12 = -src.m00 * src.m21 + src.m01 * src.m20; - float t20 = src.m01 * src.m12 - src.m02 * src.m11; - float t21 = -src.m00 * src.m12 + src.m02 * src.m10; - float t22 = src.m00 * src.m11 - src.m01 * src.m10; - - dest.m00 = t00 * determinant_inv; - dest.m11 = t11 * determinant_inv; - dest.m22 = t22 * determinant_inv; - dest.m01 = t10 * determinant_inv; - dest.m10 = t01 * determinant_inv; - dest.m20 = t02 * determinant_inv; - dest.m02 = t20 * determinant_inv; - dest.m12 = t21 * determinant_inv; - dest.m21 = t12 * determinant_inv; - return dest; - } else - return null; - } - - /** - * Negate this matrix - * - * @return this - */ - public Matrix negate() { - return negate(this); - } - - /** - * Negate this matrix and place the result in a destination matrix. - * - * @param dest The destination matrix, or null if a new matrix is to be created - * @return the negated matrix - */ - public Matrix3f negate(Matrix3f dest) { - return negate(this, dest); - } - - /** - * Negate the source matrix and place the result in the destination matrix. - * - * @param src The source matrix - * @param dest The destination matrix, or null if a new matrix is to be created - * @return the negated matrix - */ - public static Matrix3f negate(Matrix3f src, Matrix3f dest) { - if (dest == null) - dest = new Matrix3f(); - - dest.m00 = -src.m00; - dest.m01 = -src.m02; - dest.m02 = -src.m01; - dest.m10 = -src.m10; - dest.m11 = -src.m12; - dest.m12 = -src.m11; - dest.m20 = -src.m20; - dest.m21 = -src.m22; - dest.m22 = -src.m21; - return dest; - } - - /** - * Set this matrix to be the identity matrix. - * - * @return this - */ - public Matrix setIdentity() { - return setIdentity(this); - } - - /** - * Set the matrix to be the identity matrix. - * - * @param m The matrix to be set to the identity - * @return m - */ - public static Matrix3f setIdentity(Matrix3f m) { - m.m00 = 1.0f; - m.m01 = 0.0f; - m.m02 = 0.0f; - m.m10 = 0.0f; - m.m11 = 1.0f; - m.m12 = 0.0f; - m.m20 = 0.0f; - m.m21 = 0.0f; - m.m22 = 1.0f; - return m; - } - - /** - * Set this matrix to 0. - * - * @return this - */ - public Matrix setZero() { - return setZero(this); - } - - /** - * Set the matrix matrix to 0. - * - * @param m The matrix to be set to 0 - * @return m - */ - public static Matrix3f setZero(Matrix3f m) { - m.m00 = 0.0f; - m.m01 = 0.0f; - m.m02 = 0.0f; - m.m10 = 0.0f; - m.m11 = 0.0f; - m.m12 = 0.0f; - m.m20 = 0.0f; - m.m21 = 0.0f; - m.m22 = 0.0f; - return m; - } - - public boolean equals(Object m) { - return (m instanceof Matrix3f) && equal(this, (Matrix3f) m); - } - - public static boolean equal(Matrix3f a, Matrix3f b) { - return a.m00 == b.m00 && a.m01 == b.m01 && a.m02 == b.m02 && a.m10 == b.m10 && a.m11 == b.m11 && a.m12 == b.m12 - && a.m20 == b.m20 && a.m21 == b.m21 && a.m22 == b.m22; - } -} diff --git a/src/net/PeytonPlayz585/glemu/vector/Quaternion.java b/src/net/PeytonPlayz585/glemu/vector/Quaternion.java deleted file mode 100644 index 663448f..0000000 --- a/src/net/PeytonPlayz585/glemu/vector/Quaternion.java +++ /dev/null @@ -1,506 +0,0 @@ -/* - * Copyright (c) 2002-2008 LWJGL Project - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are - * met: - * - * * Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * - * * Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * - * * Neither the name of 'LWJGL' nor the names of - * its contributors may be used to endorse or promote products derived - * from this software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS - * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED - * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR - * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR - * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, - * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, - * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR - * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF - * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING - * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS - * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - */ -package net.PeytonPlayz585.glemu.vector; - -/** - * - * Quaternions for LWJGL! - * - * @author fbi - * @version $Revision$ - * $Id$ - */ - -import java.nio.FloatBuffer; - -public class Quaternion extends Vector implements ReadableVector4f { - private static final long serialVersionUID = 1L; - - public float x, y, z, w; - - /** - * C'tor. The quaternion will be initialized to the identity. - */ - public Quaternion() { - super(); - setIdentity(); - } - - /** - * C'tor - * - * @param src - */ - public Quaternion(ReadableVector4f src) { - set(src); - } - - /** - * C'tor - * - */ - public Quaternion(float x, float y, float z, float w) { - set(x, y, z, w); - } - - /* - * (non-Javadoc) - * - * @see org.lwjgl.util.vector.WritableVector2f#set(float, float) - */ - public void set(float x, float y) { - this.x = x; - this.y = y; - } - - /* - * (non-Javadoc) - * - * @see org.lwjgl.util.vector.WritableVector3f#set(float, float, float) - */ - public void set(float x, float y, float z) { - this.x = x; - this.y = y; - this.z = z; - } - - /* - * (non-Javadoc) - * - * @see org.lwjgl.util.vector.WritableVector4f#set(float, float, float, float) - */ - public void set(float x, float y, float z, float w) { - this.x = x; - this.y = y; - this.z = z; - this.w = w; - } - - /** - * Load from another Vector4f - * - * @param src The source vector - * @return this - */ - public Quaternion set(ReadableVector4f src) { - x = src.getX(); - y = src.getY(); - z = src.getZ(); - w = src.getW(); - return this; - } - - /** - * Set this quaternion to the multiplication identity. - * - * @return this - */ - public Quaternion setIdentity() { - return setIdentity(this); - } - - /** - * Set the given quaternion to the multiplication identity. - * - * @param q The quaternion - * @return q - */ - public static Quaternion setIdentity(Quaternion q) { - q.x = 0; - q.y = 0; - q.z = 0; - q.w = 1; - return q; - } - - /** - * @return the length squared of the quaternion - */ - public float lengthSquared() { - return x * x + y * y + z * z + w * w; - } - - /** - * Normalise the source quaternion and place the result in another quaternion. - * - * @param src The source quaternion - * @param dest The destination quaternion, or null if a new quaternion is to be - * created - * @return The normalised quaternion - */ - public static Quaternion normalise(Quaternion src, Quaternion dest) { - float inv_l = 1f / src.length(); - - if (dest == null) - dest = new Quaternion(); - - dest.set(src.x * inv_l, src.y * inv_l, src.z * inv_l, src.w * inv_l); - - return dest; - } - - /** - * Normalise this quaternion and place the result in another quaternion. - * - * @param dest The destination quaternion, or null if a new quaternion is to be - * created - * @return the normalised quaternion - */ - public Quaternion normalise(Quaternion dest) { - return normalise(this, dest); - } - - /** - * The dot product of two quaternions - * - * @param left The LHS quat - * @param right The RHS quat - * @return left dot right - */ - public static float dot(Quaternion left, Quaternion right) { - return left.x * right.x + left.y * right.y + left.z * right.z + left.w * right.w; - } - - /** - * Calculate the conjugate of this quaternion and put it into the given one - * - * @param dest The quaternion which should be set to the conjugate of this - * quaternion - */ - public Quaternion negate(Quaternion dest) { - return negate(this, dest); - } - - /** - * Calculate the conjugate of this quaternion and put it into the given one - * - * @param src The source quaternion - * @param dest The quaternion which should be set to the conjugate of this - * quaternion - */ - public static Quaternion negate(Quaternion src, Quaternion dest) { - if (dest == null) - dest = new Quaternion(); - - dest.x = -src.x; - dest.y = -src.y; - dest.z = -src.z; - dest.w = src.w; - - return dest; - } - - /** - * Calculate the conjugate of this quaternion - */ - public Vector negate() { - return negate(this, this); - } - - /* - * (non-Javadoc) - * - * @see org.lwjgl.util.vector.Vector#load(java.nio.FloatBuffer) - */ - public Vector load(FloatBuffer buf) { - x = buf.get(); - y = buf.get(); - z = buf.get(); - w = buf.get(); - return this; - } - - /* - * (non-Javadoc) - * - * @see org.lwjgl.vector.Vector#scale(float) - */ - public Vector scale(float scale) { - return scale(scale, this, this); - } - - /** - * Scale the source quaternion by scale and put the result in the destination - * - * @param scale The amount to scale by - * @param src The source quaternion - * @param dest The destination quaternion, or null if a new quaternion is to be - * created - * @return The scaled quaternion - */ - public static Quaternion scale(float scale, Quaternion src, Quaternion dest) { - if (dest == null) - dest = new Quaternion(); - dest.x = src.x * scale; - dest.y = src.y * scale; - dest.z = src.z * scale; - dest.w = src.w * scale; - return dest; - } - - /* - * (non-Javadoc) - * - * @see org.lwjgl.util.vector.ReadableVector#store(java.nio.FloatBuffer) - */ - public Vector store(FloatBuffer buf) { - buf.put(x); - buf.put(y); - buf.put(z); - buf.put(w); - - return this; - } - - /** - * @return x - */ - public final float getX() { - return x; - } - - /** - * @return y - */ - public final float getY() { - return y; - } - - /** - * Set X - * - * @param x - */ - public final void setX(float x) { - this.x = x; - } - - /** - * Set Y - * - * @param y - */ - public final void setY(float y) { - this.y = y; - } - - /** - * Set Z - * - * @param z - */ - public void setZ(float z) { - this.z = z; - } - - /* - * (Overrides) - * - * @see org.lwjgl.vector.ReadableVector3f#getZ() - */ - public float getZ() { - return z; - } - - /** - * Set W - * - * @param w - */ - public void setW(float w) { - this.w = w; - } - - /* - * (Overrides) - * - * @see org.lwjgl.vector.ReadableVector3f#getW() - */ - public float getW() { - return w; - } - - public String toString() { - return "Quaternion: " + x + " " + y + " " + z + " " + w; - } - - /** - * Sets the value of this quaternion to the quaternion product of quaternions - * left and right (this = left * right). Note that this is safe for aliasing - * (e.g. this can be left or right). - * - * @param left the first quaternion - * @param right the second quaternion - */ - public static Quaternion mul(Quaternion left, Quaternion right, Quaternion dest) { - if (dest == null) - dest = new Quaternion(); - dest.set(left.x * right.w + left.w * right.x + left.y * right.z - left.z * right.y, - left.y * right.w + left.w * right.y + left.z * right.x - left.x * right.z, - left.z * right.w + left.w * right.z + left.x * right.y - left.y * right.x, - left.w * right.w - left.x * right.x - left.y * right.y - left.z * right.z); - return dest; - } - - /** - * - * Multiplies quaternion left by the inverse of quaternion right and places the - * value into this quaternion. The value of both argument quaternions is - * preservered (this = left * right^-1). - * - * @param left the left quaternion - * @param right the right quaternion - */ - public static Quaternion mulInverse(Quaternion left, Quaternion right, Quaternion dest) { - float n = right.lengthSquared(); - // zero-div may occur. - n = (n == 0.0 ? n : 1 / n); - // store on stack once for aliasing-safty - if (dest == null) - dest = new Quaternion(); - dest.set((left.x * right.w - left.w * right.x - left.y * right.z + left.z * right.y) * n, - (left.y * right.w - left.w * right.y - left.z * right.x + left.x * right.z) * n, - (left.z * right.w - left.w * right.z - left.x * right.y + left.y * right.x) * n, - (left.w * right.w + left.x * right.x + left.y * right.y + left.z * right.z) * n); - - return dest; - } - - /** - * Sets the value of this quaternion to the equivalent rotation of the - * Axis-Angle argument. - * - * @param a1 the axis-angle: (x,y,z) is the axis and w is the angle - */ - public final void setFromAxisAngle(Vector4f a1) { - x = a1.x; - y = a1.y; - z = a1.z; - float n = (float) Math.sqrt(x * x + y * y + z * z); - // zero-div may occur. - float s = (float) (Math.sin(0.5 * a1.w) / n); - x *= s; - y *= s; - z *= s; - w = (float) Math.cos(0.5 * a1.w); - } - - /** - * Sets the value of this quaternion using the rotational component of the - * passed matrix. - * - * @param m The matrix - * @return this - */ - public final Quaternion setFromMatrix(Matrix4f m) { - return setFromMatrix(m, this); - } - - /** - * Sets the value of the source quaternion using the rotational component of the - * passed matrix. - * - * @param m The source matrix - * @param q The destination quaternion, or null if a new quaternion is to be - * created - * @return q - */ - public static Quaternion setFromMatrix(Matrix4f m, Quaternion q) { - return q.setFromMat(m.m00, m.m01, m.m02, m.m10, m.m11, m.m12, m.m20, m.m21, m.m22); - } - - /** - * Sets the value of this quaternion using the rotational component of the - * passed matrix. - * - * @param m The source matrix - */ - public final Quaternion setFromMatrix(Matrix3f m) { - return setFromMatrix(m, this); - } - - /** - * Sets the value of the source quaternion using the rotational component of the - * passed matrix. - * - * @param m The source matrix - * @param q The destination quaternion, or null if a new quaternion is to be - * created - * @return q - */ - public static Quaternion setFromMatrix(Matrix3f m, Quaternion q) { - return q.setFromMat(m.m00, m.m01, m.m02, m.m10, m.m11, m.m12, m.m20, m.m21, m.m22); - } - - /** - * Private method to perform the matrix-to-quaternion conversion - */ - private Quaternion setFromMat(float m00, float m01, float m02, float m10, float m11, float m12, float m20, - float m21, float m22) { - - float s; - float tr = m00 + m11 + m22; - if (tr >= 0.0) { - s = (float) Math.sqrt(tr + 1.0); - w = s * 0.5f; - s = 0.5f / s; - x = (m21 - m12) * s; - y = (m02 - m20) * s; - z = (m10 - m01) * s; - } else { - float max = Math.max(Math.max(m00, m11), m22); - if (max == m00) { - s = (float) Math.sqrt(m00 - (m11 + m22) + 1.0); - x = s * 0.5f; - s = 0.5f / s; - y = (m01 + m10) * s; - z = (m20 + m02) * s; - w = (m21 - m12) * s; - } else if (max == m11) { - s = (float) Math.sqrt(m11 - (m22 + m00) + 1.0); - y = s * 0.5f; - s = 0.5f / s; - z = (m12 + m21) * s; - x = (m01 + m10) * s; - w = (m02 - m20) * s; - } else { - s = (float) Math.sqrt(m22 - (m00 + m11) + 1.0); - z = s * 0.5f; - s = 0.5f / s; - x = (m20 + m02) * s; - y = (m12 + m21) * s; - w = (m10 - m01) * s; - } - } - return this; - } -} diff --git a/src/net/PeytonPlayz585/glemu/vector/ReadableVector.java b/src/net/PeytonPlayz585/glemu/vector/ReadableVector.java deleted file mode 100644 index e72d312..0000000 --- a/src/net/PeytonPlayz585/glemu/vector/ReadableVector.java +++ /dev/null @@ -1,57 +0,0 @@ -/* - * Copyright (c) 2002-2008 LWJGL Project - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are - * met: - * - * * Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * - * * Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * - * * Neither the name of 'LWJGL' nor the names of - * its contributors may be used to endorse or promote products derived - * from this software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS - * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED - * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR - * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR - * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, - * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, - * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR - * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF - * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING - * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS - * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - */ -package net.PeytonPlayz585.glemu.vector; - -import java.nio.FloatBuffer; - -/** - * @author foo - */ -public interface ReadableVector { - /** - * @return the length of the vector - */ - float length(); - - /** - * @return the length squared of the vector - */ - float lengthSquared(); - - /** - * Store this vector in a FloatBuffer - * - * @param buf The buffer to store it in, at the current position - * @return this - */ - Vector store(FloatBuffer buf); -} \ No newline at end of file diff --git a/src/net/PeytonPlayz585/glemu/vector/ReadableVector2f.java b/src/net/PeytonPlayz585/glemu/vector/ReadableVector2f.java deleted file mode 100644 index f857c6f..0000000 --- a/src/net/PeytonPlayz585/glemu/vector/ReadableVector2f.java +++ /dev/null @@ -1,47 +0,0 @@ -/* - * Copyright (c) 2002-2008 LWJGL Project - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are - * met: - * - * * Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * - * * Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * - * * Neither the name of 'LWJGL' nor the names of - * its contributors may be used to endorse or promote products derived - * from this software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS - * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED - * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR - * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR - * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, - * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, - * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR - * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF - * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING - * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS - * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - */ -package net.PeytonPlayz585.glemu.vector; - -/** - * @author foo - */ -public interface ReadableVector2f extends ReadableVector { - /** - * @return x - */ - float getX(); - - /** - * @return y - */ - float getY(); -} \ No newline at end of file diff --git a/src/net/PeytonPlayz585/glemu/vector/ReadableVector3f.java b/src/net/PeytonPlayz585/glemu/vector/ReadableVector3f.java deleted file mode 100644 index 6eae2ec..0000000 --- a/src/net/PeytonPlayz585/glemu/vector/ReadableVector3f.java +++ /dev/null @@ -1,42 +0,0 @@ -/* - * Copyright (c) 2002-2008 LWJGL Project - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are - * met: - * - * * Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * - * * Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * - * * Neither the name of 'LWJGL' nor the names of - * its contributors may be used to endorse or promote products derived - * from this software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS - * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED - * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR - * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR - * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, - * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, - * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR - * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF - * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING - * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS - * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - */ -package net.PeytonPlayz585.glemu.vector; - -/** - * @author foo - */ -public interface ReadableVector3f extends ReadableVector2f { - /** - * @return z - */ - float getZ(); -} \ No newline at end of file diff --git a/src/net/PeytonPlayz585/glemu/vector/ReadableVector4f.java b/src/net/PeytonPlayz585/glemu/vector/ReadableVector4f.java deleted file mode 100644 index feedc20..0000000 --- a/src/net/PeytonPlayz585/glemu/vector/ReadableVector4f.java +++ /dev/null @@ -1,44 +0,0 @@ -/* - * Copyright (c) 2002-2008 LWJGL Project - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are - * met: - * - * * Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * - * * Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * - * * Neither the name of 'LWJGL' nor the names of - * its contributors may be used to endorse or promote products derived - * from this software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS - * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED - * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR - * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR - * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, - * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, - * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR - * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF - * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING - * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS - * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - */ -package net.PeytonPlayz585.glemu.vector; - -/** - * @author foo - */ -public interface ReadableVector4f extends ReadableVector3f { - - /** - * @return w - */ - float getW(); - -} diff --git a/src/net/PeytonPlayz585/glemu/vector/Vector.java b/src/net/PeytonPlayz585/glemu/vector/Vector.java deleted file mode 100644 index 61dfb43..0000000 --- a/src/net/PeytonPlayz585/glemu/vector/Vector.java +++ /dev/null @@ -1,110 +0,0 @@ -/* - * Copyright (c) 2002-2008 LWJGL Project - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are - * met: - * - * * Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * - * * Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * - * * Neither the name of 'LWJGL' nor the names of - * its contributors may be used to endorse or promote products derived - * from this software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS - * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED - * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR - * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR - * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, - * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, - * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR - * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF - * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING - * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS - * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - */ -package net.PeytonPlayz585.glemu.vector; - -import java.io.Serializable; -import java.nio.FloatBuffer; - -/** - * - * Base class for vectors. - * - * @author cix_foo - * @version $Revision$ $Id$ - */ -public abstract class Vector implements Serializable, ReadableVector { - - /** - * Constructor for Vector. - */ - protected Vector() { - super(); - } - - /** - * @return the length of the vector - */ - public final float length() { - return (float) Math.sqrt(lengthSquared()); - } - - /** - * @return the length squared of the vector - */ - public abstract float lengthSquared(); - - /** - * Load this vector from a FloatBuffer - * - * @param buf The buffer to load it from, at the current position - * @return this - */ - public abstract Vector load(FloatBuffer buf); - - /** - * Negate a vector - * - * @return this - */ - public abstract Vector negate(); - - /** - * Normalise this vector - * - * @return this - */ - public final Vector normalise() { - float len = length(); - if (len != 0.0f) { - float l = 1.0f / len; - return scale(l); - } else - throw new IllegalStateException("Zero length vector"); - } - - /** - * Store this vector in a FloatBuffer - * - * @param buf The buffer to store it in, at the current position - * @return this - */ - public abstract Vector store(FloatBuffer buf); - - /** - * Scale this vector - * - * @param scale The scale factor - * @return this - */ - public abstract Vector scale(float scale); - -} diff --git a/src/net/PeytonPlayz585/glemu/vector/Vector2f.java b/src/net/PeytonPlayz585/glemu/vector/Vector2f.java deleted file mode 100644 index 4201c7a..0000000 --- a/src/net/PeytonPlayz585/glemu/vector/Vector2f.java +++ /dev/null @@ -1,319 +0,0 @@ -/* - * Copyright (c) 2002-2008 LWJGL Project - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are - * met: - * - * * Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * - * * Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * - * * Neither the name of 'LWJGL' nor the names of - * its contributors may be used to endorse or promote products derived - * from this software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS - * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED - * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR - * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR - * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, - * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, - * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR - * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF - * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING - * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS - * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - */ -package net.PeytonPlayz585.glemu.vector; - -import java.io.Serializable; -import java.nio.FloatBuffer; - -/** - * - * Holds a 2-tuple vector. - * - * @author cix_foo - * @version $Revision$ $Id$ - */ - -public class Vector2f extends Vector implements Serializable, ReadableVector2f, WritableVector2f { - - private static final long serialVersionUID = 1L; - - public float x, y; - - /** - * Constructor for Vector2f. - */ - public Vector2f() { - super(); - } - - /** - * Constructor. - */ - public Vector2f(ReadableVector2f src) { - set(src); - } - - /** - * Constructor. - */ - public Vector2f(float x, float y) { - set(x, y); - } - - /* - * (non-Javadoc) - * - * @see org.lwjgl.util.vector.WritableVector2f#set(float, float) - */ - public void set(float x, float y) { - this.x = x; - this.y = y; - } - - /** - * Load from another Vector2f - * - * @param src The source vector - * @return this - */ - public Vector2f set(ReadableVector2f src) { - x = src.getX(); - y = src.getY(); - return this; - } - - /** - * @return the length squared of the vector - */ - public float lengthSquared() { - return x * x + y * y; - } - - /** - * Translate a vector - * - * @param x The translation in x - * @param y the translation in y - * @return this - */ - public Vector2f translate(float x, float y) { - this.x += x; - this.y += y; - return this; - } - - /** - * Negate a vector - * - * @return this - */ - public Vector negate() { - x = -x; - y = -y; - return this; - } - - /** - * Negate a vector and place the result in a destination vector. - * - * @param dest The destination vector or null if a new vector is to be created - * @return the negated vector - */ - public Vector2f negate(Vector2f dest) { - if (dest == null) - dest = new Vector2f(); - dest.x = -x; - dest.y = -y; - return dest; - } - - /** - * Normalise this vector and place the result in another vector. - * - * @param dest The destination vector, or null if a new vector is to be created - * @return the normalised vector - */ - public Vector2f normalise(Vector2f dest) { - float l = length(); - - if (dest == null) - dest = new Vector2f(x / l, y / l); - else - dest.set(x / l, y / l); - - return dest; - } - - /** - * The dot product of two vectors is calculated as v1.x * v2.x + v1.y * v2.y + - * v1.z * v2.z - * - * @param left The LHS vector - * @param right The RHS vector - * @return left dot right - */ - public static float dot(Vector2f left, Vector2f right) { - return left.x * right.x + left.y * right.y; - } - - /** - * Calculate the angle between two vectors, in radians - * - * @param a A vector - * @param b The other vector - * @return the angle between the two vectors, in radians - */ - public static float angle(Vector2f a, Vector2f b) { - float dls = dot(a, b) / (a.length() * b.length()); - if (dls < -1f) - dls = -1f; - else if (dls > 1.0f) - dls = 1.0f; - return (float) Math.acos(dls); - } - - /** - * Add a vector to another vector and place the result in a destination vector. - * - * @param left The LHS vector - * @param right The RHS vector - * @param dest The destination vector, or null if a new vector is to be created - * @return the sum of left and right in dest - */ - public static Vector2f add(Vector2f left, Vector2f right, Vector2f dest) { - if (dest == null) - return new Vector2f(left.x + right.x, left.y + right.y); - else { - dest.set(left.x + right.x, left.y + right.y); - return dest; - } - } - - /** - * Subtract a vector from another vector and place the result in a destination - * vector. - * - * @param left The LHS vector - * @param right The RHS vector - * @param dest The destination vector, or null if a new vector is to be created - * @return left minus right in dest - */ - public static Vector2f sub(Vector2f left, Vector2f right, Vector2f dest) { - if (dest == null) - return new Vector2f(left.x - right.x, left.y - right.y); - else { - dest.set(left.x - right.x, left.y - right.y); - return dest; - } - } - - /** - * Store this vector in a FloatBuffer - * - * @param buf The buffer to store it in, at the current position - * @return this - */ - public Vector store(FloatBuffer buf) { - buf.put(x); - buf.put(y); - return this; - } - - /** - * Load this vector from a FloatBuffer - * - * @param buf The buffer to load it from, at the current position - * @return this - */ - public Vector load(FloatBuffer buf) { - x = buf.get(); - y = buf.get(); - return this; - } - - /* - * (non-Javadoc) - * - * @see org.lwjgl.vector.Vector#scale(float) - */ - public Vector scale(float scale) { - - x *= scale; - y *= scale; - - return this; - } - - /* - * (non-Javadoc) - * - * @see java.lang.Object#toString() - */ - public String toString() { - StringBuilder sb = new StringBuilder(64); - - sb.append("Vector2f["); - sb.append(x); - sb.append(", "); - sb.append(y); - sb.append(']'); - return sb.toString(); - } - - /** - * @return x - */ - public final float getX() { - return x; - } - - /** - * @return y - */ - public final float getY() { - return y; - } - - /** - * Set X - * - * @param x - */ - public final void setX(float x) { - this.x = x; - } - - /** - * Set Y - * - * @param y - */ - public final void setY(float y) { - this.y = y; - } - - public boolean equals(Object obj) { - if (this == obj) - return true; - if (obj == null) - return false; - if (getClass() != obj.getClass()) - return false; - Vector2f other = (Vector2f) obj; - - if (x == other.x && y == other.y) - return true; - - return false; - } - -} diff --git a/src/net/PeytonPlayz585/glemu/vector/Vector3f.java b/src/net/PeytonPlayz585/glemu/vector/Vector3f.java deleted file mode 100644 index 282170f..0000000 --- a/src/net/PeytonPlayz585/glemu/vector/Vector3f.java +++ /dev/null @@ -1,376 +0,0 @@ -/* - * Copyright (c) 2002-2008 LWJGL Project - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are - * met: - * - * * Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * - * * Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * - * * Neither the name of 'LWJGL' nor the names of - * its contributors may be used to endorse or promote products derived - * from this software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS - * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED - * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR - * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR - * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, - * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, - * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR - * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF - * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING - * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS - * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - */ -package net.PeytonPlayz585.glemu.vector; - -import java.io.Serializable; -import java.nio.FloatBuffer; - -/** - * - * Holds a 3-tuple vector. - * - * @author cix_foo - * @version $Revision$ $Id$ - */ - -public class Vector3f extends Vector implements Serializable, ReadableVector3f, WritableVector3f { - - private static final long serialVersionUID = 1L; - - public float x, y, z; - - /** - * Constructor for Vector3f. - */ - public Vector3f() { - super(); - } - - /** - * Constructor - */ - public Vector3f(ReadableVector3f src) { - set(src); - } - - /** - * Constructor - */ - public Vector3f(float x, float y, float z) { - set(x, y, z); - } - - /* - * (non-Javadoc) - * - * @see org.lwjgl.util.vector.WritableVector2f#set(float, float) - */ - public void set(float x, float y) { - this.x = x; - this.y = y; - } - - /* - * (non-Javadoc) - * - * @see org.lwjgl.util.vector.WritableVector3f#set(float, float, float) - */ - public void set(float x, float y, float z) { - this.x = x; - this.y = y; - this.z = z; - } - - /** - * Load from another Vector3f - * - * @param src The source vector - * @return this - */ - public Vector3f set(ReadableVector3f src) { - x = src.getX(); - y = src.getY(); - z = src.getZ(); - return this; - } - - /** - * @return the length squared of the vector - */ - public float lengthSquared() { - return x * x + y * y + z * z; - } - - /** - * Translate a vector - * - * @param x The translation in x - * @param y the translation in y - * @return this - */ - public Vector3f translate(float x, float y, float z) { - this.x += x; - this.y += y; - this.z += z; - return this; - } - - /** - * Add a vector to another vector and place the result in a destination vector. - * - * @param left The LHS vector - * @param right The RHS vector - * @param dest The destination vector, or null if a new vector is to be created - * @return the sum of left and right in dest - */ - public static Vector3f add(Vector3f left, Vector3f right, Vector3f dest) { - if (dest == null) - return new Vector3f(left.x + right.x, left.y + right.y, left.z + right.z); - else { - dest.set(left.x + right.x, left.y + right.y, left.z + right.z); - return dest; - } - } - - /** - * Subtract a vector from another vector and place the result in a destination - * vector. - * - * @param left The LHS vector - * @param right The RHS vector - * @param dest The destination vector, or null if a new vector is to be created - * @return left minus right in dest - */ - public static Vector3f sub(Vector3f left, Vector3f right, Vector3f dest) { - if (dest == null) - return new Vector3f(left.x - right.x, left.y - right.y, left.z - right.z); - else { - dest.set(left.x - right.x, left.y - right.y, left.z - right.z); - return dest; - } - } - - /** - * The cross product of two vectors. - * - * @param left The LHS vector - * @param right The RHS vector - * @param dest The destination result, or null if a new vector is to be created - * @return left cross right - */ - public static Vector3f cross(Vector3f left, Vector3f right, Vector3f dest) { - - if (dest == null) - dest = new Vector3f(); - - dest.set(left.y * right.z - left.z * right.y, right.x * left.z - right.z * left.x, - left.x * right.y - left.y * right.x); - - return dest; - } - - /** - * Negate a vector - * - * @return this - */ - public Vector negate() { - x = -x; - y = -y; - z = -z; - return this; - } - - /** - * Negate a vector and place the result in a destination vector. - * - * @param dest The destination vector or null if a new vector is to be created - * @return the negated vector - */ - public Vector3f negate(Vector3f dest) { - if (dest == null) - dest = new Vector3f(); - dest.x = -x; - dest.y = -y; - dest.z = -z; - return dest; - } - - /** - * Normalise this vector and place the result in another vector. - * - * @param dest The destination vector, or null if a new vector is to be created - * @return the normalised vector - */ - public Vector3f normalise(Vector3f dest) { - float l = length(); - - if (dest == null) - dest = new Vector3f(x / l, y / l, z / l); - else - dest.set(x / l, y / l, z / l); - - return dest; - } - - /** - * The dot product of two vectors is calculated as v1.x * v2.x + v1.y * v2.y + - * v1.z * v2.z - * - * @param left The LHS vector - * @param right The RHS vector - * @return left dot right - */ - public static float dot(Vector3f left, Vector3f right) { - return left.x * right.x + left.y * right.y + left.z * right.z; - } - - /** - * Calculate the angle between two vectors, in radians - * - * @param a A vector - * @param b The other vector - * @return the angle between the two vectors, in radians - */ - public static float angle(Vector3f a, Vector3f b) { - float dls = dot(a, b) / (a.length() * b.length()); - if (dls < -1f) - dls = -1f; - else if (dls > 1.0f) - dls = 1.0f; - return (float) Math.acos(dls); - } - - /* - * (non-Javadoc) - * - * @see org.lwjgl.vector.Vector#load(FloatBuffer) - */ - public Vector load(FloatBuffer buf) { - x = buf.get(); - y = buf.get(); - z = buf.get(); - return this; - } - - /* - * (non-Javadoc) - * - * @see org.lwjgl.vector.Vector#scale(float) - */ - public Vector scale(float scale) { - - x *= scale; - y *= scale; - z *= scale; - - return this; - - } - - /* - * (non-Javadoc) - * - * @see org.lwjgl.vector.Vector#store(FloatBuffer) - */ - public Vector store(FloatBuffer buf) { - - buf.put(x); - buf.put(y); - buf.put(z); - - return this; - } - - /* - * (non-Javadoc) - * - * @see java.lang.Object#toString() - */ - public String toString() { - StringBuilder sb = new StringBuilder(64); - - sb.append("Vector3f["); - sb.append(x); - sb.append(", "); - sb.append(y); - sb.append(", "); - sb.append(z); - sb.append(']'); - return sb.toString(); - } - - /** - * @return x - */ - public final float getX() { - return x; - } - - /** - * @return y - */ - public final float getY() { - return y; - } - - /** - * Set X - * - * @param x - */ - public final void setX(float x) { - this.x = x; - } - - /** - * Set Y - * - * @param y - */ - public final void setY(float y) { - this.y = y; - } - - /** - * Set Z - * - * @param z - */ - public void setZ(float z) { - this.z = z; - } - - /* - * (Overrides) - * - * @see org.lwjgl.vector.ReadableVector3f#getZ() - */ - public float getZ() { - return z; - } - - public boolean equals(Object obj) { - if (this == obj) - return true; - if (obj == null) - return false; - if (getClass() != obj.getClass()) - return false; - Vector3f other = (Vector3f) obj; - - if (x == other.x && y == other.y && z == other.z) - return true; - - return false; - } -} diff --git a/src/net/PeytonPlayz585/glemu/vector/Vector4f.java b/src/net/PeytonPlayz585/glemu/vector/Vector4f.java deleted file mode 100644 index 7582396..0000000 --- a/src/net/PeytonPlayz585/glemu/vector/Vector4f.java +++ /dev/null @@ -1,377 +0,0 @@ -/* - * Copyright (c) 2002-2008 LWJGL Project - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are - * met: - * - * * Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * - * * Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * - * * Neither the name of 'LWJGL' nor the names of - * its contributors may be used to endorse or promote products derived - * from this software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS - * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED - * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR - * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR - * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, - * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, - * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR - * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF - * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING - * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS - * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - */ -package net.PeytonPlayz585.glemu.vector; - -import java.io.Serializable; -import java.nio.FloatBuffer; - -/** - * - * Holds a 4-tuple vector. - * - * @author cix_foo - * @version $Revision$ $Id$ - */ - -public class Vector4f extends Vector implements Serializable, ReadableVector4f, WritableVector4f { - - private static final long serialVersionUID = 1L; - - public float x, y, z, w; - - /** - * Constructor for Vector4f. - */ - public Vector4f() { - super(); - } - - /** - * Constructor - */ - public Vector4f(ReadableVector4f src) { - set(src); - } - - /** - * Constructor - */ - public Vector4f(float x, float y, float z, float w) { - set(x, y, z, w); - } - - /* - * (non-Javadoc) - * - * @see org.lwjgl.util.vector.WritableVector2f#set(float, float) - */ - public void set(float x, float y) { - this.x = x; - this.y = y; - } - - /* - * (non-Javadoc) - * - * @see org.lwjgl.util.vector.WritableVector3f#set(float, float, float) - */ - public void set(float x, float y, float z) { - this.x = x; - this.y = y; - this.z = z; - } - - /* - * (non-Javadoc) - * - * @see org.lwjgl.util.vector.WritableVector4f#set(float, float, float, float) - */ - public void set(float x, float y, float z, float w) { - this.x = x; - this.y = y; - this.z = z; - this.w = w; - } - - /** - * Load from another Vector4f - * - * @param src The source vector - * @return this - */ - public Vector4f set(ReadableVector4f src) { - x = src.getX(); - y = src.getY(); - z = src.getZ(); - w = src.getW(); - return this; - } - - /** - * @return the length squared of the vector - */ - public float lengthSquared() { - return x * x + y * y + z * z + w * w; - } - - /** - * Translate a vector - * - * @param x The translation in x - * @param y the translation in y - * @return this - */ - public Vector4f translate(float x, float y, float z, float w) { - this.x += x; - this.y += y; - this.z += z; - this.w += w; - return this; - } - - /** - * Add a vector to another vector and place the result in a destination vector. - * - * @param left The LHS vector - * @param right The RHS vector - * @param dest The destination vector, or null if a new vector is to be created - * @return the sum of left and right in dest - */ - public static Vector4f add(Vector4f left, Vector4f right, Vector4f dest) { - if (dest == null) - return new Vector4f(left.x + right.x, left.y + right.y, left.z + right.z, left.w + right.w); - else { - dest.set(left.x + right.x, left.y + right.y, left.z + right.z, left.w + right.w); - return dest; - } - } - - /** - * Subtract a vector from another vector and place the result in a destination - * vector. - * - * @param left The LHS vector - * @param right The RHS vector - * @param dest The destination vector, or null if a new vector is to be created - * @return left minus right in dest - */ - public static Vector4f sub(Vector4f left, Vector4f right, Vector4f dest) { - if (dest == null) - return new Vector4f(left.x - right.x, left.y - right.y, left.z - right.z, left.w - right.w); - else { - dest.set(left.x - right.x, left.y - right.y, left.z - right.z, left.w - right.w); - return dest; - } - } - - /** - * Negate a vector - * - * @return this - */ - public Vector negate() { - x = -x; - y = -y; - z = -z; - w = -w; - return this; - } - - /** - * Negate a vector and place the result in a destination vector. - * - * @param dest The destination vector or null if a new vector is to be created - * @return the negated vector - */ - public Vector4f negate(Vector4f dest) { - if (dest == null) - dest = new Vector4f(); - dest.x = -x; - dest.y = -y; - dest.z = -z; - dest.w = -w; - return dest; - } - - /** - * Normalise this vector and place the result in another vector. - * - * @param dest The destination vector, or null if a new vector is to be created - * @return the normalised vector - */ - public Vector4f normalise(Vector4f dest) { - float l = length(); - - if (dest == null) - dest = new Vector4f(x / l, y / l, z / l, w / l); - else - dest.set(x / l, y / l, z / l, w / l); - - return dest; - } - - /** - * The dot product of two vectors is calculated as v1.x * v2.x + v1.y * v2.y + - * v1.z * v2.z + v1.w * v2.w - * - * @param left The LHS vector - * @param right The RHS vector - * @return left dot right - */ - public static float dot(Vector4f left, Vector4f right) { - return left.x * right.x + left.y * right.y + left.z * right.z + left.w * right.w; - } - - /** - * Calculate the angle between two vectors, in radians - * - * @param a A vector - * @param b The other vector - * @return the angle between the two vectors, in radians - */ - public static float angle(Vector4f a, Vector4f b) { - float dls = dot(a, b) / (a.length() * b.length()); - if (dls < -1f) - dls = -1f; - else if (dls > 1.0f) - dls = 1.0f; - return (float) Math.acos(dls); - } - - /* - * (non-Javadoc) - * - * @see org.lwjgl.vector.Vector#load(FloatBuffer) - */ - public Vector load(FloatBuffer buf) { - x = buf.get(); - y = buf.get(); - z = buf.get(); - w = buf.get(); - return this; - } - - /* - * (non-Javadoc) - * - * @see org.lwjgl.vector.Vector#scale(float) - */ - public Vector scale(float scale) { - x *= scale; - y *= scale; - z *= scale; - w *= scale; - return this; - } - - /* - * (non-Javadoc) - * - * @see org.lwjgl.vector.Vector#store(FloatBuffer) - */ - public Vector store(FloatBuffer buf) { - - buf.put(x); - buf.put(y); - buf.put(z); - buf.put(w); - - return this; - } - - public String toString() { - return "Vector4f: " + x + " " + y + " " + z + " " + w; - } - - /** - * @return x - */ - public final float getX() { - return x; - } - - /** - * @return y - */ - public final float getY() { - return y; - } - - /** - * Set X - * - * @param x - */ - public final void setX(float x) { - this.x = x; - } - - /** - * Set Y - * - * @param y - */ - public final void setY(float y) { - this.y = y; - } - - /** - * Set Z - * - * @param z - */ - public void setZ(float z) { - this.z = z; - } - - /* - * (Overrides) - * - * @see org.lwjgl.vector.ReadableVector3f#getZ() - */ - public float getZ() { - return z; - } - - /** - * Set W - * - * @param w - */ - public void setW(float w) { - this.w = w; - } - - /* - * (Overrides) - * - * @see org.lwjgl.vector.ReadableVector3f#getZ() - */ - public float getW() { - return w; - } - - public boolean equals(Object obj) { - if (this == obj) - return true; - if (obj == null) - return false; - if (getClass() != obj.getClass()) - return false; - Vector4f other = (Vector4f) obj; - - if (x == other.x && y == other.y && z == other.z && w == other.w) - return true; - - return false; - } -} diff --git a/src/net/PeytonPlayz585/glemu/vector/WritableVector2f.java b/src/net/PeytonPlayz585/glemu/vector/WritableVector2f.java deleted file mode 100644 index faa6c71..0000000 --- a/src/net/PeytonPlayz585/glemu/vector/WritableVector2f.java +++ /dev/null @@ -1,64 +0,0 @@ -/* - * Copyright (c) 2002-2008 LWJGL Project - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are - * met: - * - * * Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * - * * Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * - * * Neither the name of 'LWJGL' nor the names of - * its contributors may be used to endorse or promote products derived - * from this software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS - * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED - * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR - * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR - * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, - * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, - * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR - * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF - * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING - * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS - * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - */ -package net.PeytonPlayz585.glemu.vector; - -/** - * Writable interface to Vector2fs - * - * @author $author$ - * @version $revision$ $Id$ - */ -public interface WritableVector2f { - - /** - * Set the X value - * - * @param x - */ - void setX(float x); - - /** - * Set the Y value - * - * @param y - */ - void setY(float y); - - /** - * Set the X,Y values - * - * @param x - * @param y - */ - void set(float x, float y); - -} \ No newline at end of file diff --git a/src/net/PeytonPlayz585/glemu/vector/WritableVector3f.java b/src/net/PeytonPlayz585/glemu/vector/WritableVector3f.java deleted file mode 100644 index 6c6e004..0000000 --- a/src/net/PeytonPlayz585/glemu/vector/WritableVector3f.java +++ /dev/null @@ -1,58 +0,0 @@ -/* - * Copyright (c) 2002-2008 LWJGL Project - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are - * met: - * - * * Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * - * * Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * - * * Neither the name of 'LWJGL' nor the names of - * its contributors may be used to endorse or promote products derived - * from this software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS - * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED - * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR - * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR - * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, - * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, - * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR - * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF - * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING - * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS - * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - */ -package net.PeytonPlayz585.glemu.vector; - -/** - * Writable interface to Vector3fs - * - * @author $author$ - * @version $revision$ $Id$ - */ -public interface WritableVector3f extends WritableVector2f { - - /** - * Set the Z value - * - * @param z - */ - void setZ(float z); - - /** - * Set the X,Y,Z values - * - * @param x - * @param y - * @param z - */ - void set(float x, float y, float z); - -} \ No newline at end of file diff --git a/src/net/PeytonPlayz585/glemu/vector/WritableVector4f.java b/src/net/PeytonPlayz585/glemu/vector/WritableVector4f.java deleted file mode 100644 index 9870654..0000000 --- a/src/net/PeytonPlayz585/glemu/vector/WritableVector4f.java +++ /dev/null @@ -1,59 +0,0 @@ -/* - * Copyright (c) 2002-2008 LWJGL Project - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are - * met: - * - * * Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * - * * Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * - * * Neither the name of 'LWJGL' nor the names of - * its contributors may be used to endorse or promote products derived - * from this software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS - * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED - * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR - * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR - * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, - * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, - * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR - * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF - * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING - * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS - * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - */ -package net.PeytonPlayz585.glemu.vector; - -/** - * Writable interface to Vector4fs - * - * @author $author$ - * @version $revision$ $Id$ - */ -public interface WritableVector4f extends WritableVector3f { - - /** - * Set the W value - * - * @param w - */ - void setW(float w); - - /** - * Set the X,Y,Z,W values - * - * @param x - * @param y - * @param z - * @param w - */ - void set(float x, float y, float z, float w); - -} \ No newline at end of file diff --git a/src/net/PeytonPlayz585/input/Keyboard.java b/src/net/PeytonPlayz585/input/Keyboard.java deleted file mode 100644 index 422c762..0000000 --- a/src/net/PeytonPlayz585/input/Keyboard.java +++ /dev/null @@ -1,15 +0,0 @@ -package net.PeytonPlayz585.input; - -import net.PeytonPlayz585.opengl.GL11; - -public class Keyboard extends GL11 { - - public static boolean next() { - return keysNext(); - } - - public static char getEventCharacter() { - return getEventChar(); - } - -} diff --git a/src/net/PeytonPlayz585/input/Mouse.java b/src/net/PeytonPlayz585/input/Mouse.java deleted file mode 100644 index 2fa0c85..0000000 --- a/src/net/PeytonPlayz585/input/Mouse.java +++ /dev/null @@ -1,55 +0,0 @@ -package net.PeytonPlayz585.input; - -import net.PeytonPlayz585.opengl.GL11; - -public class Mouse extends GL11 { - - public static int getX() { - return mouseGetX(); - } - - public static int getY() { - return mouseGetY(); - } - - public static boolean next() { - return mouseNext(); - } - - public static boolean getEventButtonState() { - return mouseGetEventButtonState(); - } - - public static int getEventX() { - return mouseGetEventX(); - } - - - public static int getEventY() { - return mouseGetEventY(); - } - - public static int getEventButton() { - return mouseGetEventButton(); - } - - public static int getDX() { - return mouseGetDX(); - } - - public static int getDY() { - return mouseGetDY(); - } - - public static void setGrabbed(boolean b) { - mouseSetGrabbed(b); - } - - public static boolean isButtonDown(int i) { - return mouseIsButtonDown(i); - } - - public static int getEventDWheel() { - return mouseGetEventDWheel(); - } -} diff --git a/src/net/lax1dude/eaglercraft/JSONArray.java b/src/net/PeytonPlayz585/json/JSONArray.java similarity index 97% rename from src/net/lax1dude/eaglercraft/JSONArray.java rename to src/net/PeytonPlayz585/json/JSONArray.java index 8aebfbf..706204f 100644 --- a/src/net/lax1dude/eaglercraft/JSONArray.java +++ b/src/net/PeytonPlayz585/json/JSONArray.java @@ -1,4 +1,4 @@ -package net.lax1dude.eaglercraft; +package net.PeytonPlayz585.json; /* Copyright (c) 2002 JSON.org @@ -1713,4 +1713,4 @@ public class JSONArray implements Iterable { , cause); } -} \ No newline at end of file +} diff --git a/src/net/lax1dude/eaglercraft/JSONException.java b/src/net/PeytonPlayz585/json/JSONException.java similarity index 95% rename from src/net/lax1dude/eaglercraft/JSONException.java rename to src/net/PeytonPlayz585/json/JSONException.java index c2766bf..782d70f 100644 --- a/src/net/lax1dude/eaglercraft/JSONException.java +++ b/src/net/PeytonPlayz585/json/JSONException.java @@ -1,4 +1,4 @@ -package net.lax1dude.eaglercraft; +package net.PeytonPlayz585.json; /* Copyright (c) 2002 JSON.org @@ -66,4 +66,4 @@ public class JSONException extends RuntimeException { super(cause.getMessage(), cause); } -} \ No newline at end of file +} diff --git a/src/net/lax1dude/eaglercraft/JSONObject.java b/src/net/PeytonPlayz585/json/JSONObject.java similarity index 97% rename from src/net/lax1dude/eaglercraft/JSONObject.java rename to src/net/PeytonPlayz585/json/JSONObject.java index cc5b07c..cc4af89 100644 --- a/src/net/lax1dude/eaglercraft/JSONObject.java +++ b/src/net/PeytonPlayz585/json/JSONObject.java @@ -1,4 +1,4 @@ -package net.lax1dude.eaglercraft; +package net.PeytonPlayz585.json; import java.io.Closeable; @@ -2233,7 +2233,7 @@ public class JSONObject { try { BigDecimal bd = new BigDecimal(val); if(initial == '-' && BigDecimal.ZERO.compareTo(bd)==0) { - return Double.valueOf(0D); + return Double.valueOf(-0.0); } return bd; } catch (NumberFormatException retryAsDouble) { @@ -2729,4 +2729,4 @@ public class JSONObject { "JavaBean object contains recursively defined member variable of key " + quote(key) ); } -} \ No newline at end of file +} diff --git a/src/net/lax1dude/eaglercraft/JSONPointer.java b/src/net/PeytonPlayz585/json/JSONPointer.java similarity index 97% rename from src/net/lax1dude/eaglercraft/JSONPointer.java rename to src/net/PeytonPlayz585/json/JSONPointer.java index 5e3c658..74b6b55 100644 --- a/src/net/lax1dude/eaglercraft/JSONPointer.java +++ b/src/net/PeytonPlayz585/json/JSONPointer.java @@ -1,4 +1,4 @@ -package net.lax1dude.eaglercraft; +package net.PeytonPlayz585.json; import static java.lang.String.format; @@ -292,4 +292,4 @@ public class JSONPointer { } } -} \ No newline at end of file +} diff --git a/src/net/lax1dude/eaglercraft/JSONPointerException.java b/src/net/PeytonPlayz585/json/JSONPointerException.java similarity index 95% rename from src/net/lax1dude/eaglercraft/JSONPointerException.java rename to src/net/PeytonPlayz585/json/JSONPointerException.java index 66a2b29..0aa2550 100644 --- a/src/net/lax1dude/eaglercraft/JSONPointerException.java +++ b/src/net/PeytonPlayz585/json/JSONPointerException.java @@ -1,4 +1,4 @@ -package net.lax1dude.eaglercraft; +package net.PeytonPlayz585.json; /* Copyright (c) 2002 JSON.org @@ -42,4 +42,4 @@ public class JSONPointerException extends JSONException { super(message, cause); } -} \ No newline at end of file +} diff --git a/src/net/lax1dude/eaglercraft/JSONPropertyIgnore.java b/src/net/PeytonPlayz585/json/JSONPropertyIgnore.java similarity index 93% rename from src/net/lax1dude/eaglercraft/JSONPropertyIgnore.java rename to src/net/PeytonPlayz585/json/JSONPropertyIgnore.java index 0eb1350..307672e 100644 --- a/src/net/lax1dude/eaglercraft/JSONPropertyIgnore.java +++ b/src/net/PeytonPlayz585/json/JSONPropertyIgnore.java @@ -1,4 +1,4 @@ -package net.lax1dude.eaglercraft; +package net.PeytonPlayz585.json; /* Copyright (c) 2018 JSON.org @@ -40,4 +40,4 @@ import java.lang.annotation.Target; * present at any level in the class hierarchy, then the method will * not be serialized from the bean into the JSONObject. */ -public @interface JSONPropertyIgnore { } \ No newline at end of file +public @interface JSONPropertyIgnore { } diff --git a/src/net/lax1dude/eaglercraft/JSONPropertyName.java b/src/net/PeytonPlayz585/json/JSONPropertyName.java similarity index 95% rename from src/net/lax1dude/eaglercraft/JSONPropertyName.java rename to src/net/PeytonPlayz585/json/JSONPropertyName.java index 94338e7..8162b57 100644 --- a/src/net/lax1dude/eaglercraft/JSONPropertyName.java +++ b/src/net/PeytonPlayz585/json/JSONPropertyName.java @@ -1,4 +1,4 @@ -package net.lax1dude.eaglercraft; +package net.PeytonPlayz585.json; /* Copyright (c) 2018 JSON.org @@ -44,4 +44,4 @@ public @interface JSONPropertyName { * @return The name of the property as to be used in the JSON Object. */ String value(); -} \ No newline at end of file +} diff --git a/src/net/lax1dude/eaglercraft/JSONString.java b/src/net/PeytonPlayz585/json/JSONString.java similarity index 95% rename from src/net/lax1dude/eaglercraft/JSONString.java rename to src/net/PeytonPlayz585/json/JSONString.java index 85fa355..f6083c3 100644 --- a/src/net/lax1dude/eaglercraft/JSONString.java +++ b/src/net/PeytonPlayz585/json/JSONString.java @@ -1,4 +1,4 @@ -package net.lax1dude.eaglercraft; +package net.PeytonPlayz585.json; /* Copyright (c) 2002 JSON.org @@ -40,4 +40,4 @@ public interface JSONString { * @return A strictly syntactically correct JSON text. */ public String toJSONString(); -} \ No newline at end of file +} diff --git a/src/net/PeytonPlayz585/json/JSONStringer.java b/src/net/PeytonPlayz585/json/JSONStringer.java new file mode 100644 index 0000000..95c616a --- /dev/null +++ b/src/net/PeytonPlayz585/json/JSONStringer.java @@ -0,0 +1,79 @@ +package net.PeytonPlayz585.json; + +/* +Copyright (c) 2006 JSON.org + +Permission is hereby granted, free of charge, to any person obtaining a copy +of this software and associated documentation files (the "Software"), to deal +in the Software without restriction, including without limitation the rights +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +copies of the Software, and to permit persons to whom the Software is +furnished to do so, subject to the following conditions: + +The above copyright notice and this permission notice shall be included in all +copies or substantial portions of the Software. + +The Software shall be used for Good, not Evil. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE +SOFTWARE. +*/ + +import java.io.StringWriter; + +/** + * JSONStringer provides a quick and convenient way of producing JSON text. + * The texts produced strictly conform to JSON syntax rules. No whitespace is + * added, so the results are ready for transmission or storage. Each instance of + * JSONStringer can produce one JSON text. + *

+ * A JSONStringer instance provides a value method for appending + * values to the + * text, and a key + * method for adding keys before values in objects. There are array + * and endArray methods that make and bound array values, and + * object and endObject methods which make and bound + * object values. All of these methods return the JSONWriter instance, + * permitting cascade style. For example,

+ * myString = new JSONStringer()
+ *     .object()
+ *         .key("JSON")
+ *         .value("Hello, World!")
+ *     .endObject()
+ *     .toString();
which produces the string
+ * {"JSON":"Hello, World!"}
+ *

+ * The first method called must be array or object. + * There are no methods for adding commas or colons. JSONStringer adds them for + * you. Objects and arrays can be nested up to 200 levels deep. + *

+ * This can sometimes be easier than using a JSONObject to build a string. + * @author JSON.org + * @version 2015-12-09 + */ +public class JSONStringer extends JSONWriter { + /** + * Make a fresh JSONStringer. It can be used to build one JSON text. + */ + public JSONStringer() { + super(new StringWriter()); + } + + /** + * Return the JSON text. This method is used to obtain the product of the + * JSONStringer instance. It will return null if there was a + * problem in the construction of the JSON text (such as the calls to + * array were not properly balanced with calls to + * endArray). + * @return The JSON text. + */ + @Override + public String toString() { + return this.mode == 'd' ? this.writer.toString() : null; + } +} diff --git a/src/net/lax1dude/eaglercraft/JSONTokener.java b/src/net/PeytonPlayz585/json/JSONTokener.java similarity index 96% rename from src/net/lax1dude/eaglercraft/JSONTokener.java rename to src/net/PeytonPlayz585/json/JSONTokener.java index 534c3f4..2770437 100644 --- a/src/net/lax1dude/eaglercraft/JSONTokener.java +++ b/src/net/PeytonPlayz585/json/JSONTokener.java @@ -1,4 +1,4 @@ -package net.lax1dude.eaglercraft; +package net.PeytonPlayz585.json; import java.io.BufferedReader; import java.io.IOException; @@ -542,4 +542,4 @@ public class JSONTokener { return " at " + this.index + " [character " + this.character + " line " + this.line + "]"; } -} \ No newline at end of file +} diff --git a/src/net/lax1dude/eaglercraft/JSONWriter.java b/src/net/PeytonPlayz585/json/JSONWriter.java similarity index 97% rename from src/net/lax1dude/eaglercraft/JSONWriter.java rename to src/net/PeytonPlayz585/json/JSONWriter.java index d24d31b..5abf201 100644 --- a/src/net/lax1dude/eaglercraft/JSONWriter.java +++ b/src/net/PeytonPlayz585/json/JSONWriter.java @@ -1,4 +1,4 @@ -package net.lax1dude.eaglercraft; +package net.PeytonPlayz585.json; import java.io.IOException; import java.util.Collection; @@ -411,4 +411,4 @@ public class JSONWriter { public JSONWriter value(Object object) throws JSONException { return this.append(valueToString(object)); } -} \ No newline at end of file +} diff --git a/src/net/PeytonPlayz585/opengl/EaglerAdapterGL30.java b/src/net/PeytonPlayz585/opengl/EaglerAdapterGL30.java deleted file mode 100644 index 61f2b37..0000000 --- a/src/net/PeytonPlayz585/opengl/EaglerAdapterGL30.java +++ /dev/null @@ -1,1321 +0,0 @@ -package net.PeytonPlayz585.opengl; - -import java.nio.ByteBuffer; -import java.nio.ByteOrder; -import java.nio.FloatBuffer; -import java.nio.IntBuffer; -import java.util.ArrayList; -import java.util.HashMap; -import java.util.List; - -import net.PeytonPlayz585.glemu.FixedFunctionShader; -import net.PeytonPlayz585.glemu.GLObjectMap; - -import net.lax1dude.eaglercraft.adapter.EaglerAdapterImpl2; -import net.PeytonPlayz585.glemu.vector.*; - -import static net.PeytonPlayz585.glemu.StreamBuffer.StreamBufferInstance; - -public class EaglerAdapterGL30 extends EaglerAdapterImpl2 { - - public static final int GL_ZERO = RealOpenGLEnums.GL_ZERO; - public static final int GL_ONE = RealOpenGLEnums.GL_ONE; - public static final int GL_TEXTURE_2D = RealOpenGLEnums.GL_TEXTURE_2D; - public static final int GL_SMOOTH = RealOpenGLEnums.GL_SMOOTH; - public static final int GL_DEPTH_TEST = RealOpenGLEnums.GL_DEPTH_TEST; - public static final int GL_LEQUAL = RealOpenGLEnums.GL_LEQUAL; - public static final int GL_ALPHA_TEST = RealOpenGLEnums.GL_ALPHA_TEST; - public static final int GL_GREATER = RealOpenGLEnums.GL_GREATER; - public static final int GL_BACK = RealOpenGLEnums.GL_BACK; - public static final int GL_PROJECTION = RealOpenGLEnums.GL_PROJECTION; - public static final int GL_MODELVIEW = RealOpenGLEnums.GL_MODELVIEW; - public static final int GL_COLOR_BUFFER_BIT = RealOpenGLEnums.GL_COLOR_BUFFER_BIT; - public static final int GL_DEPTH_BUFFER_BIT = RealOpenGLEnums.GL_DEPTH_BUFFER_BIT; - public static final int GL_LIGHTING = RealOpenGLEnums.GL_LIGHTING; - public static final int GL_FOG = RealOpenGLEnums.GL_FOG; - public static final int GL_COLOR_MATERIAL = RealOpenGLEnums.GL_COLOR_MATERIAL; - public static final int GL_BLEND = RealOpenGLEnums.GL_BLEND; - public static final int GL_RGBA = RealOpenGLEnums.GL_RGBA; - public static final int GL_UNSIGNED_BYTE = RealOpenGLEnums.GL_UNSIGNED_BYTE; - public static final int GL_TEXTURE_WIDTH = RealOpenGLEnums.GL_TEXTURE_WIDTH; - public static final int GL_LIGHT0 = RealOpenGLEnums.GL_LIGHT0; - public static final int GL_LIGHT1 = RealOpenGLEnums.GL_LIGHT1; - public static final int GL_POSITION = RealOpenGLEnums.GL_POSITION; - public static final int GL_DIFFUSE = RealOpenGLEnums.GL_DIFFUSE; - public static final int GL_SPECULAR = RealOpenGLEnums.GL_SPECULAR; - public static final int GL_AMBIENT = RealOpenGLEnums.GL_AMBIENT; - public static final int GL_FLAT = RealOpenGLEnums.GL_FLAT; - public static final int GL_LIGHT_MODEL_AMBIENT = RealOpenGLEnums.GL_LIGHT_MODEL_AMBIENT; - public static final int GL_FRONT_AND_BACK = RealOpenGLEnums.GL_FRONT_AND_BACK; - public static final int GL_AMBIENT_AND_DIFFUSE = RealOpenGLEnums.GL_AMBIENT_AND_DIFFUSE; - public static final int GL_MODELVIEW_MATRIX = RealOpenGLEnums.GL_MODELVIEW_MATRIX; - public static final int GL_PROJECTION_MATRIX = RealOpenGLEnums.GL_PROJECTION_MATRIX; - public static final int GL_VIEWPORT = RealOpenGLEnums.GL_VIEWPORT; - public static final int GL_RESCALE_NORMAL = RealOpenGLEnums.GL_RESCALE_NORMAL; - public static final int GL_SRC_ALPHA = RealOpenGLEnums.GL_SRC_ALPHA; - public static final int GL_ONE_MINUS_SRC_ALPHA = RealOpenGLEnums.GL_ONE_MINUS_SRC_ALPHA; - public static final int GL_ONE_MINUS_DST_COLOR = RealOpenGLEnums.GL_ONE_MINUS_DST_COLOR; - public static final int GL_ONE_MINUS_SRC_COLOR = RealOpenGLEnums.GL_ONE_MINUS_SRC_COLOR; - public static final int GL_CULL_FACE = RealOpenGLEnums.GL_CULL_FACE; - public static final int GL_TEXTURE_MIN_FILTER = RealOpenGLEnums.GL_TEXTURE_MIN_FILTER; - public static final int GL_TEXTURE_MAG_FILTER = RealOpenGLEnums.GL_TEXTURE_MAG_FILTER; - public static final int GL_LINEAR = RealOpenGLEnums.GL_LINEAR; - public static final int GL_COLOR_LOGIC_OP = RealOpenGLEnums.GL_COLOR_LOGIC_OP; - public static final int GL_OR_REVERSE = RealOpenGLEnums.GL_OR_REVERSE; - public static final int GL_EQUAL = RealOpenGLEnums.GL_EQUAL; - public static final int GL_SRC_COLOR = RealOpenGLEnums.GL_SRC_COLOR; - public static final int GL_TEXTURE = RealOpenGLEnums.GL_TEXTURE; - public static final int GL_FRONT = RealOpenGLEnums.GL_FRONT; - public static final int GL_COMPILE = RealOpenGLEnums.GL_COMPILE; - public static final int GL_NEAREST = RealOpenGLEnums.GL_NEAREST; - public static final int GL_CLAMP = RealOpenGLEnums.GL_CLAMP_TO_EDGE; - public static final int GL_TEXTURE_WRAP_S = RealOpenGLEnums.GL_TEXTURE_WRAP_S; - public static final int GL_TEXTURE_WRAP_T = RealOpenGLEnums.GL_TEXTURE_WRAP_T; - public static final int GL_REPEAT = RealOpenGLEnums.GL_REPEAT; - public static final int GL_BGRA = RealOpenGLEnums.GL_BGRA; - public static final int GL_UNSIGNED_INT_8_8_8_8_REV = RealOpenGLEnums.GL_UNSIGNED_INT_8_8_8_8_REV; - public static final int GL_DST_COLOR = RealOpenGLEnums.GL_DST_COLOR; - public static final int GL_POLYGON_OFFSET_FILL = RealOpenGLEnums.GL_POLYGON_OFFSET_FILL; - public static final int GL_NORMALIZE = RealOpenGLEnums.GL_NORMALIZE; - public static final int GL_DST_ALPHA = RealOpenGLEnums.GL_DST_ALPHA; - public static final int GL_FLOAT = RealOpenGLEnums.GL_FLOAT; - public static final int GL_TEXTURE_COORD_ARRAY = RealOpenGLEnums.GL_TEXTURE_COORD_ARRAY; - public static final int GL_SHORT = RealOpenGLEnums.GL_SHORT; - public static final int GL_COLOR_ARRAY = RealOpenGLEnums.GL_COLOR_ARRAY; - public static final int GL_VERTEX_ARRAY = RealOpenGLEnums.GL_VERTEX_ARRAY; - public static final int GL_TRIANGLES = RealOpenGLEnums.GL_TRIANGLES; - public static final int GL_NORMAL_ARRAY = RealOpenGLEnums.GL_NORMAL_ARRAY; - public static final int GL_TEXTURE_3D = RealOpenGLEnums.GL_TEXTURE_3D; - public static final int GL_FOG_MODE = RealOpenGLEnums.GL_FOG_MODE; - public static final int GL_EXP = RealOpenGLEnums.GL_EXP; - public static final int GL_FOG_DENSITY = RealOpenGLEnums.GL_FOG_DENSITY; - public static final int GL_FOG_START = RealOpenGLEnums.GL_FOG_START; - public static final int GL_FOG_END = RealOpenGLEnums.GL_FOG_END; - public static final int GL_FOG_COLOR = RealOpenGLEnums.GL_FOG_COLOR; - public static final int GL_TRIANGLE_STRIP = RealOpenGLEnums.GL_TRIANGLE_STRIP; - public static final int GL_PACK_ALIGNMENT = RealOpenGLEnums.GL_PACK_ALIGNMENT; - public static final int GL_UNPACK_ALIGNMENT = RealOpenGLEnums.GL_UNPACK_ALIGNMENT; - public static final int GL_QUADS = RealOpenGLEnums.GL_QUADS; - public static final int GL_INVALID_ENUM = RealOpenGLEnums.GL_INVALID_ENUM; - public static final int GL_INVALID_VALUE = RealOpenGLEnums.GL_INVALID_VALUE; - public static final int GL_INVALID_OPERATION = RealOpenGLEnums.GL_INVALID_OPERATION; - public static final int GL_OUT_OF_MEMORY = RealOpenGLEnums.GL_OUT_OF_MEMORY; - public static final int GL_CONTEXT_LOST_WEBGL = -144; - public static final int GL_TRIANGLE_FAN = RealOpenGLEnums.GL_TRIANGLE_FAN; - public static final int GL_LINE_STRIP = RealOpenGLEnums.GL_LINE_STRIP; - public static final int GL_LINES = RealOpenGLEnums.GL_LINES; - public static final int GL_NEAREST_MIPMAP_LINEAR = RealOpenGLEnums.GL_NEAREST_MIPMAP_LINEAR; - public static final int GL_TEXTURE_MAX_ANISOTROPY = -150; - public static final int GL_TEXTURE_MAX_LEVEL = RealOpenGLEnums.GL_TEXTURE_MAX_LEVEL; - 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); - - private static boolean enableTexture2D = false; - private static boolean enableLighting = false; - private static boolean enableAlphaTest = false; - private static float alphaThresh = 0.1f; - - private static boolean isCompilingDisplayList = false; - private static DisplayList compilingDisplayList = null; - - private static boolean enableColorArray = false; - private static boolean enableNormalArray = false; - private static boolean enableTex0Array = false; - - private static float colorR = 1.0f; - 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; - - private static float tex0X = 0; - private static float tex0Y = 0; - - private static boolean enableColorMaterial = false; - - private static float fogColorR = 1.0f; - private static float fogColorG = 1.0f; - private static float fogColorB = 1.0f; - private static float fogColorA = 1.0f; - private static int fogMode = 1; - private static boolean fogEnabled = false; - //private static boolean fogPremultiply = false; - private static float fogStart = 1.0f; - private static float fogEnd = 1.0f; - private static float fogDensity = 1.0f; - - 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) { - matModelV[i] = new Matrix4f(); - } - for (int i = 0; i < matProjV.length; ++i) { - matProjV[i] = new Matrix4f(); - } - 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; - } - - 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 List translate = new ArrayList(); - - private DisplayList(int id) { - this.id = id; - this.glarray = null; - this.glbuffer = null; - this.shaderMode = -1; - this.listLength = 0; - } - } - - private static class Translate { - private float f, f1, f2; - - private Translate(float f, float f1, float f2) { - this.f = f; - this.f1 = f1; - this.f2 = f2; - } - } - - 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) { - case GL_DEPTH_TEST: - _wglEnable(_wGL_DEPTH_TEST); - break; - case GL_CULL_FACE: - _wglEnable(_wGL_CULL_FACE); - break; - case GL_BLEND: - _wglEnable(_wGL_BLEND); - break; - case GL_RESCALE_NORMAL: - break; - case GL_TEXTURE_2D: - enableTexture2D = true; - break; - case GL_LIGHTING: - enableLighting = true; - break; - case GL_ALPHA_TEST: - enableAlphaTest = true; - break; - case GL_FOG: - fogEnabled = true; - break; - case GL_COLOR_MATERIAL: - enableColorMaterial = true; - break; - case GL_POLYGON_OFFSET_FILL: - _wglEnable(_wGL_POLYGON_OFFSET_FILL); - default: - break; - } - } - - static float clearDepth = -999.0f; - public static final void glClearDepth(float p1) { - p1 = 1.0f - p1; - if(p1 != clearDepth) { - _wglClearDepth(p1); - clearDepth = p1; - } - } - - public static final int GL_GEQUAL = RealOpenGLEnums.GL_GEQUAL; - public static final int GL_LESS = RealOpenGLEnums.GL_LESS; - static int stateDepthFunc = -1; - public static final void glDepthFunc(int p1) { - int rev = p1; - switch(p1) { - case GL_GREATER: - rev = _wGL_LESS; - break; - case GL_GEQUAL: - rev = _wGL_LEQUAL; - break; - case GL_EQUAL: - rev = _wGL_EQUAL; - break; - case GL_LEQUAL: - rev = _wGL_GEQUAL; - break; - case GL_LESS: - rev = _wGL_GREATER; - break; - } - if(rev != stateDepthFunc) { - _wglDepthFunc(rev); - stateDepthFunc = rev; - } - } - - public static final void glAlphaFunc(int p1, float p2) { - alphaThresh = p2; - } - - private static int stateCullFace = -1; - public static final void glCullFace(int p1) { - if(p1 != stateCullFace) { - stateCullFace = p1; - _wglCullFace(p1); - } - } - - public static final void glMatrixMode(int p1) { - matrixMode = p1; - } - - private static final Matrix4f getMatrix() { - switch (matrixMode) { - case GL_MODELVIEW: - default: - return matModelV[matModelPointer]; - case GL_PROJECTION: - return matProjV[matProjPointer]; - case GL_TEXTURE: - 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(double left, double right, double bottom, double top, double zNear, double zFar) { - Matrix4f res = getMatrix(); - res.m00 = (float) (2.0f / (right - left)); - res.m01 = 0.0f; - res.m02 = 0.0f; - res.m03 = 0.0f; - res.m10 = 0.0f; - res.m11 = (float) (2.0f / (top - bottom)); - res.m12 = 0.0f; - res.m13 = 0.0f; - res.m20 = 0.0f; - res.m21 = 0.0f; - res.m22 = (float) (2.0f / (zFar - zNear)); - res.m23 = 0.0f; - res.m30 = (float) (-(right + left) / (right - left)); - res.m31 = (float) (-(top + bottom) / (top - bottom)); - res.m32 = (float) ((zFar + zNear) / (zFar - zNear)); - res.m33 = 1.0f; - } - - 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; - } - - 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) { - compilingDisplayList.translate.add(new Translate(p1, p2, p3)); - //throw new IllegalArgumentException("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) { - case GL_DEPTH_TEST: - _wglDisable(_wGL_DEPTH_TEST); - break; - case GL_CULL_FACE: - _wglDisable(_wGL_CULL_FACE); - break; - case GL_BLEND: - _wglDisable(_wGL_BLEND); - break; - case GL_RESCALE_NORMAL: - break; - case GL_TEXTURE_2D: - enableTexture2D = false; - break; - case GL_LIGHTING: - enableLighting = false; - break; - case GL_ALPHA_TEST: - enableAlphaTest = false; - break; - case GL_FOG: - fogEnabled = false; - break; - case GL_COLOR_MATERIAL: - enableColorMaterial = false; - break; - case GL_POLYGON_OFFSET_FILL: - _wglDisable(_wGL_POLYGON_OFFSET_FILL); - default: - 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; - return err; - } - - public static final void glFlush() { - _wglFlush(); - } - - public static final void glLineWidth(float p1) { - webgl.lineWidth(p1); - } - - public static final void glTexImage2D(int p1, int p2, int p3, int p4, int p5, int p6, int p7, int p8, - ByteBuffer p9) { - _wglTexImage2D(_wGL_TEXTURE_2D, p2, _wGL_RGBA8, p4, p5, p6, _wGL_RGBA, _wGL_UNSIGNED_BYTE, p9); - } - - 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(); - Matrix4f.transform(matModelV[matModelPointer], lightPos0vec, lightPos0vec).normalise(); - Matrix4f.transform(matModelV[matModelPointer], lightPos1vec, lightPos1vec).normalise(); - lightPos0vec.x = -lightPos0vec.x; - lightPos1vec.x = -lightPos1vec.x; - lightPos0vec.y = -lightPos0vec.y; - lightPos1vec.y = -lightPos1vec.y; - 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) { - case GL_MODELVIEW: - default: - if (matModelPointer < matModelV.length - 1) { - ++matModelPointer; - matModelV[matModelPointer].load(matModelV[matModelPointer - 1]); - } else { - System.err.println("modelview matrix stack overflow"); - } - break; - case GL_PROJECTION: - if (matProjPointer < matProjV.length - 1) { - ++matProjPointer; - matProjV[matProjPointer].load(matProjV[matProjPointer - 1]); - } else { - System.err.println("projection matrix stack overflow"); - } - break; - case GL_TEXTURE: - if (matTexPointer < matTexV.length - 1) { - ++matTexPointer; - matTexV[matTexPointer].load(matTexV[matTexPointer - 1]); - } 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) { - throw new IllegalArgumentException("matrix is not supported while recording display list use tessellator class instead"); - } - } - - public static final void glPopMatrix() { - switch (matrixMode) { - case GL_MODELVIEW: - default: - if (matModelPointer > 0) { - --matModelPointer; - } else { - System.err.println("modelview matrix stack underflow"); - } - break; - case GL_PROJECTION: - if (matProjPointer > 0) { - --matProjPointer; - } else { - System.err.println("projection matrix stack underflow"); - } - break; - case GL_TEXTURE: - if (matTexPointer > 0) { - --matTexPointer; - } 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) { - case GL_MODELVIEW_MATRIX: - default: - matModelV[matModelPointer].store(p2); - break; - case GL_PROJECTION_MATRIX: - matProjV[matProjPointer].store(p2); - break; - } - } - - public static final void glGetInteger(int p1, int[] p2) { - 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) { - throw new IllegalArgumentException("matrix is not supported while recording display list use tessellator class instead"); - } - } - - public static final void glScaled(double p1, double p2, double p3) { - deevis.set((float)p1, (float)p2, (float)p3); - getMatrix().scale(deevis); - if (isCompilingDisplayList) { - throw new IllegalArgumentException("matrix is not supported while recording display list use tessellator class instead"); - } - } - - static int stateBlendSRC = -1; - static int stateBlendDST = -1; - public static final void glBlendFunc(int p1, int p2) { -// fogPremultiply = (p1 == GL_ONE && p2 == GL_ONE_MINUS_SRC_ALPHA); -// if(overlayFBOBlending) { -// _wglBlendFuncSeparate(p1, p2, GL_ONE, GL_ONE_MINUS_SRC_ALPHA); -// }else { -// _wglBlendFunc(p1, p2); -// } - if(overlayFBOBlending) { - glBlendFuncSeparate(p1, p2, 0, 1); - return; - } - int srcBits = (p1 | (p1 << 16)); - int dstBits = (p2 | (p2 << 16)); - if(srcBits != stateBlendSRC || dstBits != stateBlendDST) { - _wglBlendFunc(p1, p2); - stateBlendSRC = srcBits; - stateBlendDST = dstBits; - } - } - - private static boolean overlayFBOBlending = false; - - public static final void enableOverlayFramebufferBlending(boolean en) { - overlayFBOBlending = en; - } - - public static final void glBlendFuncSeparate(int p1, int p2, int p3, int p4) { -// fogPremultiply = (p3 == GL_ONE && p4 == GL_ONE_MINUS_SRC_ALPHA); -// _wglBlendFuncSeparate(p1, p2, p3, p4); - if(overlayFBOBlending) { // game overlay framebuffer in EntityRenderer.java - p3 = GL_ONE; - p4 = GL_ONE_MINUS_SRC_ALPHA; - } - int srcBits = (p1 | (p3 << 16)); - int dstBits = (p2 | (p4 << 16)); - if(srcBits != stateBlendSRC || dstBits != stateBlendDST) { - _wglBlendFuncSeparate(p1, p2, p3, p4); - stateBlendSRC = srcBits; - stateBlendDST = dstBits; - } - } - - private static boolean stateDepthMask = true; - public static final void glDepthMask(boolean p1) { - if(p1 != stateDepthMask) { - stateDepthMask = p1; - _wglDepthMask(p1); - } - } - - public static final void glColorMask(boolean p1, boolean p2, boolean p3, boolean p4) { - _wglColorMask(p1, p2, p3, p4); - } - - public static final void glBindTexture(int p1, int p2) { - TextureGL t = texObjects.get(p2); - _wglBindTexture(_wGL_TEXTURE_2D, t); - } - - public static final void glBindTexture(int p2) { - TextureGL t = texObjects.get(p2); - _wglBindTexture(_wGL_TEXTURE_2D, t); - } - - public static final void glBindTexture(int p1, TextureGL p2) { - _wglBindTexture(_wGL_TEXTURE_2D, p2); - } - - 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(p3 == RealOpenGLEnums.GL_CLAMP_TO_EDGE || p3 == 10496) { - p3 = _wGL_CLAMP; - } - _wglTexParameteri(p1, p2, p3); - } - - public static final void glTexParameterf(int p1, int p2, float p3) { - int pp1 = 0; - switch (p1) { - default: - case GL_TEXTURE_2D: - pp1 = _wGL_TEXTURE_2D; - break; - // case GL_TEXTURE_3D: pp1 = _wGL_TEXTURE_3D; break; - } - int pp2 = 0; - switch (p2) { - default: - case GL_TEXTURE_MAX_ANISOTROPY: - pp2 = _wGL_TEXTURE_MAX_ANISOTROPY; - break; - } - _wglTexParameterf(pp1, pp2, p3); - } - - 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++) { - 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) { - DisplayList d = displayListsInitialized.get(p1); - if (d != null && d.listLength > 0) { - bindTheShader(d.shaderMode | getShaderModeFlag1()); - _wglBindVertexArray0(d.glarray); - - //glTranslate support for display lists - for(Translate t : d.translate) { - deevis.set(t.f, t.f1, t.f2); - getMatrix().translate(deevis); - } - - _wglDrawQuadArrays(0, d.listLength); - - shader.unuseProgram(); - vertexDrawn += d.listLength * 6 / 4; - triangleDrawn += d.listLength / 2; - } - } - } - - public static final void glNewList(int p1, int p2) { - if (!isCompilingDisplayList) { - compilingDisplayList = displayLists.get(p1); - if (compilingDisplayList != null) { - compilingDisplayList.shaderMode = -1; - compilingDisplayList.listLength = 0; - isCompilingDisplayList = true; - } - } - } - - public static final void glEndList() { - if (isCompilingDisplayList) { - isCompilingDisplayList = false; - Object upload = _wGetLowLevelBuffersAppended(); - int l = _wArrayByteLength(upload); - if (l > 0) { - if (compilingDisplayList.glbuffer == null) { - displayListsInitialized.put(compilingDisplayList.id, compilingDisplayList); - compilingDisplayList.glarray = _wglCreateVertexArray(); - compilingDisplayList.glbuffer = _wglCreateBuffer(); - FixedFunctionShader f = FixedFunctionShader.instance(compilingDisplayList.shaderMode); - _wglBindVertexArray0(compilingDisplayList.glarray); - _wglBindBuffer(_wGL_ARRAY_BUFFER, compilingDisplayList.glbuffer); - f.setupArrayForProgram(); - } - _wglBindBuffer(_wGL_ARRAY_BUFFER, compilingDisplayList.glbuffer); - _wglBufferData(_wGL_ARRAY_BUFFER, upload, _wGL_STATIC_DRAW); - bytesUploaded += l; - } - } - } - - public static final void flushDisplayList(int p1) { - DisplayList d = displayListsInitialized.get(p1); - if (d != null) { - if (d.glbuffer != null) { - _wglDeleteBuffer(d.glbuffer); - _wglDeleteVertexArray(d.glarray); - d.glbuffer = null; - d.glarray = 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 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; } - */ - bytesUploaded += p9.remaining() * 4; - _wglTexImage2D(_wGL_TEXTURE_2D, p2, _wGL_RGBA8, p4, p5, p6, _wGL_RGBA, _wGL_UNSIGNED_BYTE, p9); - } - - public static final void glTexImage2D_2(int p1, int p2, int p3, int p4, int p5, int p6, int p7, int p8, - IntBuffer p9) { - bytesUploaded += p9.remaining() * 4; - _wglTexImage2D(_wGL_TEXTURE_2D, p2, _wGL_RGB8, p4, p5, p6, _wGL_RGB, _wGL_UNSIGNED_BYTE, 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) { - default: - 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; - _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()) { - glCallList(p1.get()); - } - } - - public static final void glEnableVertexAttrib(int p1) { - switch (p1) { - case GL_COLOR_ARRAY: - enableColorArray = true; - break; - case GL_NORMAL_ARRAY: - enableNormalArray = true; - break; - case GL_TEXTURE_COORD_ARRAY: - enableTex0Array = true; - break; - default: - break; - } - } - - public static final void glDisableVertexAttrib(int p1) { - switch (p1) { - case GL_COLOR_ARRAY: - enableColorArray = false; - break; - case GL_NORMAL_ARRAY: - enableNormalArray = false; - break; - case GL_TEXTURE_COORD_ARRAY: - enableTex0Array = false; - break; - default: - break; - } - } - - private static final int getShaderModeFlag0() { - int mode = 0; - mode = (mode | (enableColorArray ? FixedFunctionShader.COLOR : 0)); - mode = (mode | (enableNormalArray ? FixedFunctionShader.NORMAL : 0)); - mode = (mode | (enableTex0Array ? FixedFunctionShader.TEXTURE0 : 0)); - return mode; - } - - private static final int getShaderModeFlag1() { - int mode = 0; - mode = (mode | ((enableColorMaterial && enableLighting) ? FixedFunctionShader.LIGHTING : 0)); - mode = (mode | (fogEnabled ? FixedFunctionShader.FOG : 0)); - mode = (mode | (enableAlphaTest ? FixedFunctionShader.ALPHATEST : 0)); - mode = (mode | (enableTexture2D ? FixedFunctionShader.UNIT0 : 0)); - return mode; - } - - private static final int getShaderModeFlag() { - int mode = 0; - mode = (mode | (enableColorArray ? FixedFunctionShader.COLOR : 0)); - mode = (mode | (enableNormalArray ? FixedFunctionShader.NORMAL : 0)); - mode = (mode | (enableTex0Array ? FixedFunctionShader.TEXTURE0 : 0)); - mode = (mode | ((enableColorMaterial && enableLighting) ? FixedFunctionShader.LIGHTING : 0)); - mode = (mode | (fogEnabled ? FixedFunctionShader.FOG : 0)); - mode = (mode | (enableAlphaTest ? FixedFunctionShader.ALPHATEST : 0)); - mode = (mode | (enableTexture2D ? FixedFunctionShader.UNIT0 : 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) { - s.setAlphaTest(alphaThresh); - } - s.setColor(colorR, colorG, colorB, colorA); - if (fogEnabled) { - s.setFogMode(fogMode); - s.setFogColor(fogColorR, fogColorG, fogColorB, fogColorA); - s.setFogDensity(fogDensity); - s.setFogStartEnd(fogStart, fogEnd); - } - s.setModelMatrix(matModelV[matModelPointer]); - s.setProjectionMatrix(matProjV[matProjPointer]); - s.setTextureMatrix(matTexV[matTexPointer]); - if (enableColorMaterial && enableLighting) { - s.setNormal(normalX, normalY, normalZ); - s.setLightPositions(lightPos0vec, lightPos1vec); - } - s.setTex0Coords(tex0X, tex0Y); - } - - 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) { - compilingDisplayList.shaderMode = getShaderModeFlag0(); - } else { - if (compilingDisplayList.shaderMode != getShaderModeFlag0()) { - System.err.println("vertex format inconsistent in display list"); - } - } - compilingDisplayList.listLength += p3; - _wAppendLowLevelBuffer(buffer); - } else { - System.err.println("only GL_QUADS supported in a display list"); - } - } else { - int bl = _wArrayByteLength(buffer); - bytesUploaded += bl; - vertexDrawn += p3; - - bindTheShader(); - - StreamBufferInstance sb = shader.streamBuffer.getBuffer(bl); - _wglBindVertexArray0(sb.vertexArray); - _wglBindBuffer(_wGL_ARRAY_BUFFER, sb.vertexBuffer); - if (!shader.bufferIsInitialized) { - shader.bufferIsInitialized = true; - _wglBufferData(_wGL_ARRAY_BUFFER, blankUploadArray, _wGL_DYNAMIC_DRAW); - } - _wglBufferSubData(_wGL_ARRAY_BUFFER, 0, buffer); - - if (p1 == GL_QUADS) { - _wglDrawQuadArrays(p2, p3); - triangleDrawn += p3 / 2; - } else { - int drawMode = 0; - switch (p1) { - default: - case GL_TRIANGLES: - drawMode = _wGL_TRIANGLES; - triangleDrawn += p3 / 3; - break; - case GL_TRIANGLE_STRIP: - drawMode = _wGL_TRIANGLE_STRIP; - triangleDrawn += p3 - 2; - break; - case GL_TRIANGLE_FAN: - drawMode = _wGL_TRIANGLE_FAN; - triangleDrawn += p3 - 2; - break; - case GL_LINE_STRIP: - drawMode = _wGL_LINE_STRIP; - triangleDrawn += p3 - 1; - break; - case GL_LINES: - drawMode = _wGL_LINES; - triangleDrawn += p3 / 2; - break; - } - _wglDrawArrays(drawMode, 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) { - int v1 = i * 4; - int v2 = i * 4 + 1; - int v3 = i * 4 + 2; - int v4 = i * 4 + 3; - upload.put(v1 | (v2 << 16)); - upload.put(v4 | (v2 << 16)); - upload.put(v3 | (v4 << 16)); - } - upload.flip(); - quadsToTrianglesBuffer = _wglCreateBuffer(); - _wglBindBuffer(_wGL_ELEMENT_ARRAY_BUFFER, quadsToTrianglesBuffer); - _wglBufferData0(_wGL_ELEMENT_ARRAY_BUFFER, upload, _wGL_STATIC_DRAW); - } - 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])); - } - 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"); - - _wglCompileShader(frag); - 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); - _wglDetachShader(occlusion_program, vert); - _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] ")); - - _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() { - return queryObjs.register(_wglCreateQuery()); - } - - 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(); - _wglUseProgram(occlusion_program); - _wglBindVertexArray(occlusion_vao); - 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) { - glPushMatrix(); - glTranslatef(posX - sizeX * 0.01f, posY - sizeY * 0.01f, posZ - sizeZ * 0.01f); - glScalef(sizeX * 1.02f, sizeY * 1.02f, sizeZ * 1.02f); - matModelV[matModelPointer].store(occlusionModel); - _wglUniformMat4fv(occlusion_matrix_m, occlusionModel); - _wglDrawArrays(_wGL_TRIANGLES, 0, 36); - glPopMatrix(); - - } - - public static final void glEndQuery() { - _wglEndQuery(_wGL_ANY_SAMPLES_PASSED); - } - - 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) { - int pp1 = 0; - switch (p1) { - default: - 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(); - _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) { - default: - case GL_LINEAR: - fogMode = 1; - break; - case GL_EXP: - fogMode = 2; - break; - } - } - } - - public static final void glFogf(int p1, float p2) { - switch (p1) { - case GL_FOG_START: - fogStart = p2; - break; - case GL_FOG_END: - fogEnd = p2; - break; - case GL_FOG_DENSITY: - fogDensity = p2; - break; - default: - break; - } - } - - public static final void glFog(int p1, FloatBuffer p2) { - 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++) { - DisplayList d = displayListsInitialized.remove(p1 + i); - if (d != null) { - _wglDeleteVertexArray(d.glarray); - _wglDeleteBuffer(d.glbuffer); - } - displayLists.remove(p1 + i); - } - } - - public static final void glMultiTexCoord2f(int p1, float p2, float p3) { - tex0X = p2; - tex0Y = p3; - } - - 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) { - 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); - 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); - res.m00 = cotangent / aspect; - res.m01 = 0.0f; - res.m02 = 0.0f; - res.m03 = 0.0f; - res.m10 = 0.0f; - res.m11 = cotangent; - res.m12 = 0.0f; - res.m13 = 0.0f; - res.m20 = 0.0f; - res.m21 = 0.0f; - res.m22 = (zFar + zNear) / (zFar - zNear); - res.m23 = -1.0f; - res.m30 = 0.0f; - res.m31 = 0.0f; - 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); - res.m00 = cotangent / aspect; - res.m01 = 0.0f; - res.m02 = 0.0f; - res.m03 = 0.0f; - res.m10 = 0.0f; - res.m11 = cotangent; - res.m12 = 0.0f; - res.m13 = 0.0f; - res.m20 = 0.0f; - res.m21 = 0.0f; - res.m22 = ((zFar + zNear) / (zFar - zNear)) * 0.001f; - res.m23 = -1.0f; - res.m30 = 0.0f; - res.m31 = 0.0f; - 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"; - } - } - - public static final void optimize() { - FixedFunctionShader.optimize(); - } - - private static long lastBandwidthReset = 0l; - private static int lastBandwidth = 0; - - public static final int getBitsPerSecond() { - 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; - return ret; - } - -} \ No newline at end of file diff --git a/src/net/PeytonPlayz585/opengl/GL11.java b/src/net/PeytonPlayz585/opengl/GL11.java deleted file mode 100644 index a8fa83a..0000000 --- a/src/net/PeytonPlayz585/opengl/GL11.java +++ /dev/null @@ -1,9 +0,0 @@ -package net.PeytonPlayz585.opengl; - -public class GL11 extends EaglerAdapterGL30 { - - public static void glPixelStorei(int glUnpackAlignment, int i) { - _wglPixelStorei(glUnpackAlignment, i); - } - -} diff --git a/src/net/PeytonPlayz585/opengl/GL12.java b/src/net/PeytonPlayz585/opengl/GL12.java deleted file mode 100644 index 097e82f..0000000 --- a/src/net/PeytonPlayz585/opengl/GL12.java +++ /dev/null @@ -1,5 +0,0 @@ -package net.PeytonPlayz585.opengl; - -public class GL12 extends GL11 { - -} diff --git a/src/net/PeytonPlayz585/opengl/RealOpenGLEnums.java b/src/net/PeytonPlayz585/opengl/RealOpenGLEnums.java deleted file mode 100644 index c29118b..0000000 --- a/src/net/PeytonPlayz585/opengl/RealOpenGLEnums.java +++ /dev/null @@ -1,2417 +0,0 @@ -package net.PeytonPlayz585.opengl; - -public class RealOpenGLEnums { - - // Field descriptor #544 I - public static final int GL_ACCUM = 256; - - // Field descriptor #544 I - public static final int GL_LOAD = 257; - - // Field descriptor #544 I - public static final int GL_RETURN = 258; - - // Field descriptor #544 I - public static final int GL_MULT = 259; - - // Field descriptor #544 I - public static final int GL_ADD = 260; - - // Field descriptor #544 I - public static final int GL_NEVER = 512; - - // Field descriptor #544 I - public static final int GL_LESS = 513; - - // Field descriptor #544 I - public static final int GL_EQUAL = 514; - - // Field descriptor #544 I - public static final int GL_LEQUAL = 515; - - // Field descriptor #544 I - public static final int GL_GREATER = 516; - - // Field descriptor #544 I - public static final int GL_NOTEQUAL = 517; - - // Field descriptor #544 I - public static final int GL_GEQUAL = 518; - - // Field descriptor #544 I - public static final int GL_ALWAYS = 519; - - // Field descriptor #544 I - public static final int GL_CURRENT_BIT = 1; - - // Field descriptor #544 I - public static final int GL_POINT_BIT = 2; - - // Field descriptor #544 I - public static final int GL_LINE_BIT = 4; - - // Field descriptor #544 I - public static final int GL_POLYGON_BIT = 8; - - // Field descriptor #544 I - public static final int GL_POLYGON_STIPPLE_BIT = 16; - - // Field descriptor #544 I - public static final int GL_PIXEL_MODE_BIT = 32; - - // Field descriptor #544 I - public static final int GL_LIGHTING_BIT = 64; - - // Field descriptor #544 I - public static final int GL_FOG_BIT = 128; - - // Field descriptor #544 I - public static final int GL_DEPTH_BUFFER_BIT = 256; - - // Field descriptor #544 I - public static final int GL_ACCUM_BUFFER_BIT = 512; - - // Field descriptor #544 I - public static final int GL_STENCIL_BUFFER_BIT = 1024; - - // Field descriptor #544 I - public static final int GL_VIEWPORT_BIT = 2048; - - // Field descriptor #544 I - public static final int GL_TRANSFORM_BIT = 4096; - - // Field descriptor #544 I - public static final int GL_ENABLE_BIT = 8192; - - // Field descriptor #544 I - public static final int GL_COLOR_BUFFER_BIT = 16384; - - // Field descriptor #544 I - public static final int GL_HINT_BIT = 32768; - - // Field descriptor #544 I - public static final int GL_EVAL_BIT = 65536; - - // Field descriptor #544 I - public static final int GL_LIST_BIT = 131072; - - // Field descriptor #544 I - public static final int GL_TEXTURE_BIT = 262144; - - // Field descriptor #544 I - public static final int GL_SCISSOR_BIT = 524288; - - // Field descriptor #544 I - public static final int GL_ALL_ATTRIB_BITS = 1048575; - - // Field descriptor #544 I - public static final int GL_POINTS = 0; - - // Field descriptor #544 I - public static final int GL_LINES = 1; - - // Field descriptor #544 I - public static final int GL_LINE_LOOP = 2; - - // Field descriptor #544 I - public static final int GL_LINE_STRIP = 3; - - // Field descriptor #544 I - public static final int GL_TRIANGLES = 4; - - // Field descriptor #544 I - public static final int GL_TRIANGLE_STRIP = 5; - - // Field descriptor #544 I - public static final int GL_TRIANGLE_FAN = 6; - - // Field descriptor #544 I - public static final int GL_QUADS = 7; - - // Field descriptor #544 I - public static final int GL_QUAD_STRIP = 8; - - // Field descriptor #544 I - public static final int GL_POLYGON = 9; - - // Field descriptor #544 I - public static final int GL_ZERO = 0; - - // Field descriptor #544 I - public static final int GL_ONE = 1; - - // Field descriptor #544 I - public static final int GL_SRC_COLOR = 768; - - // Field descriptor #544 I - public static final int GL_ONE_MINUS_SRC_COLOR = 769; - - // Field descriptor #544 I - public static final int GL_SRC_ALPHA = 770; - - // Field descriptor #544 I - public static final int GL_ONE_MINUS_SRC_ALPHA = 771; - - // Field descriptor #544 I - public static final int GL_DST_ALPHA = 772; - - // Field descriptor #544 I - public static final int GL_ONE_MINUS_DST_ALPHA = 773; - - // Field descriptor #544 I - public static final int GL_DST_COLOR = 774; - - // Field descriptor #544 I - public static final int GL_ONE_MINUS_DST_COLOR = 775; - - // Field descriptor #544 I - public static final int GL_SRC_ALPHA_SATURATE = 776; - - // Field descriptor #544 I - public static final int GL_CONSTANT_COLOR = 32769; - - // Field descriptor #544 I - public static final int GL_ONE_MINUS_CONSTANT_COLOR = 32770; - - // Field descriptor #544 I - public static final int GL_CONSTANT_ALPHA = 32771; - - // Field descriptor #544 I - public static final int GL_ONE_MINUS_CONSTANT_ALPHA = 32772; - - // Field descriptor #544 I - public static final int GL_TRUE = 1; - - // Field descriptor #544 I - public static final int GL_FALSE = 0; - - // Field descriptor #544 I - public static final int GL_CLIP_PLANE0 = 12288; - - // Field descriptor #544 I - public static final int GL_CLIP_PLANE1 = 12289; - - // Field descriptor #544 I - public static final int GL_CLIP_PLANE2 = 12290; - - // Field descriptor #544 I - public static final int GL_CLIP_PLANE3 = 12291; - - // Field descriptor #544 I - public static final int GL_CLIP_PLANE4 = 12292; - - // Field descriptor #544 I - public static final int GL_CLIP_PLANE5 = 12293; - - // Field descriptor #544 I - public static final int GL_BYTE = 5120; - - // Field descriptor #544 I - public static final int GL_UNSIGNED_BYTE = 5121; - - // Field descriptor #544 I - public static final int GL_SHORT = 5122; - - // Field descriptor #544 I - public static final int GL_UNSIGNED_SHORT = 5123; - - // Field descriptor #544 I - public static final int GL_INT = 5124; - - // Field descriptor #544 I - public static final int GL_UNSIGNED_INT = 5125; - - // Field descriptor #544 I - public static final int GL_FLOAT = 5126; - - // Field descriptor #544 I - public static final int GL_2_BYTES = 5127; - - // Field descriptor #544 I - public static final int GL_3_BYTES = 5128; - - // Field descriptor #544 I - public static final int GL_4_BYTES = 5129; - - // Field descriptor #544 I - public static final int GL_DOUBLE = 5130; - - // Field descriptor #544 I - public static final int GL_NONE = 0; - - // Field descriptor #544 I - public static final int GL_FRONT_LEFT = 1024; - - // Field descriptor #544 I - public static final int GL_FRONT_RIGHT = 1025; - - // Field descriptor #544 I - public static final int GL_BACK_LEFT = 1026; - - // Field descriptor #544 I - public static final int GL_BACK_RIGHT = 1027; - - // Field descriptor #544 I - public static final int GL_FRONT = 1028; - - // Field descriptor #544 I - public static final int GL_BACK = 1029; - - // Field descriptor #544 I - public static final int GL_LEFT = 1030; - - // Field descriptor #544 I - public static final int GL_RIGHT = 1031; - - // Field descriptor #544 I - public static final int GL_FRONT_AND_BACK = 1032; - - // Field descriptor #544 I - public static final int GL_AUX0 = 1033; - - // Field descriptor #544 I - public static final int GL_AUX1 = 1034; - - // Field descriptor #544 I - public static final int GL_AUX2 = 1035; - - // Field descriptor #544 I - public static final int GL_AUX3 = 1036; - - // Field descriptor #544 I - public static final int GL_NO_ERROR = 0; - - // Field descriptor #544 I - public static final int GL_INVALID_ENUM = 1280; - - // Field descriptor #544 I - public static final int GL_INVALID_VALUE = 1281; - - // Field descriptor #544 I - public static final int GL_INVALID_OPERATION = 1282; - - // Field descriptor #544 I - public static final int GL_STACK_OVERFLOW = 1283; - - // Field descriptor #544 I - public static final int GL_STACK_UNDERFLOW = 1284; - - // Field descriptor #544 I - public static final int GL_OUT_OF_MEMORY = 1285; - - // Field descriptor #544 I - public static final int GL_2D = 1536; - - // Field descriptor #544 I - public static final int GL_3D = 1537; - - // Field descriptor #544 I - public static final int GL_3D_COLOR = 1538; - - // Field descriptor #544 I - public static final int GL_3D_COLOR_TEXTURE = 1539; - - // Field descriptor #544 I - public static final int GL_4D_COLOR_TEXTURE = 1540; - - // Field descriptor #544 I - public static final int GL_PASS_THROUGH_TOKEN = 1792; - - // Field descriptor #544 I - public static final int GL_POINT_TOKEN = 1793; - - // Field descriptor #544 I - public static final int GL_LINE_TOKEN = 1794; - - // Field descriptor #544 I - public static final int GL_POLYGON_TOKEN = 1795; - - // Field descriptor #544 I - public static final int GL_BITMAP_TOKEN = 1796; - - // Field descriptor #544 I - public static final int GL_DRAW_PIXEL_TOKEN = 1797; - - // Field descriptor #544 I - public static final int GL_COPY_PIXEL_TOKEN = 1798; - - // Field descriptor #544 I - public static final int GL_LINE_RESET_TOKEN = 1799; - - // Field descriptor #544 I - public static final int GL_EXP = 2048; - - // Field descriptor #544 I - public static final int GL_EXP2 = 2049; - - // Field descriptor #544 I - public static final int GL_CW = 2304; - - // Field descriptor #544 I - public static final int GL_CCW = 2305; - - // Field descriptor #544 I - public static final int GL_COEFF = 2560; - - // Field descriptor #544 I - public static final int GL_ORDER = 2561; - - // Field descriptor #544 I - public static final int GL_DOMAIN = 2562; - - // Field descriptor #544 I - public static final int GL_CURRENT_COLOR = 2816; - - // Field descriptor #544 I - public static final int GL_CURRENT_INDEX = 2817; - - // Field descriptor #544 I - public static final int GL_CURRENT_NORMAL = 2818; - - // Field descriptor #544 I - public static final int GL_CURRENT_TEXTURE_COORDS = 2819; - - // Field descriptor #544 I - public static final int GL_CURRENT_RASTER_COLOR = 2820; - - // Field descriptor #544 I - public static final int GL_CURRENT_RASTER_INDEX = 2821; - - // Field descriptor #544 I - public static final int GL_CURRENT_RASTER_TEXTURE_COORDS = 2822; - - // Field descriptor #544 I - public static final int GL_CURRENT_RASTER_POSITION = 2823; - - // Field descriptor #544 I - public static final int GL_CURRENT_RASTER_POSITION_VALID = 2824; - - // Field descriptor #544 I - public static final int GL_CURRENT_RASTER_DISTANCE = 2825; - - // Field descriptor #544 I - public static final int GL_POINT_SMOOTH = 2832; - - // Field descriptor #544 I - public static final int GL_POINT_SIZE = 2833; - - // Field descriptor #544 I - public static final int GL_POINT_SIZE_RANGE = 2834; - - // Field descriptor #544 I - public static final int GL_POINT_SIZE_GRANULARITY = 2835; - - // Field descriptor #544 I - public static final int GL_LINE_SMOOTH = 2848; - - // Field descriptor #544 I - public static final int GL_LINE_WIDTH = 2849; - - // Field descriptor #544 I - public static final int GL_LINE_WIDTH_RANGE = 2850; - - // Field descriptor #544 I - public static final int GL_LINE_WIDTH_GRANULARITY = 2851; - - // Field descriptor #544 I - public static final int GL_LINE_STIPPLE = 2852; - - // Field descriptor #544 I - public static final int GL_LINE_STIPPLE_PATTERN = 2853; - - // Field descriptor #544 I - public static final int GL_LINE_STIPPLE_REPEAT = 2854; - - // Field descriptor #544 I - public static final int GL_LIST_MODE = 2864; - - // Field descriptor #544 I - public static final int GL_MAX_LIST_NESTING = 2865; - - // Field descriptor #544 I - public static final int GL_LIST_BASE = 2866; - - // Field descriptor #544 I - public static final int GL_LIST_INDEX = 2867; - - // Field descriptor #544 I - public static final int GL_POLYGON_MODE = 2880; - - // Field descriptor #544 I - public static final int GL_POLYGON_SMOOTH = 2881; - - // Field descriptor #544 I - public static final int GL_POLYGON_STIPPLE = 2882; - - // Field descriptor #544 I - public static final int GL_EDGE_FLAG = 2883; - - // Field descriptor #544 I - public static final int GL_CULL_FACE = 2884; - - // Field descriptor #544 I - public static final int GL_CULL_FACE_MODE = 2885; - - // Field descriptor #544 I - public static final int GL_FRONT_FACE = 2886; - - // Field descriptor #544 I - public static final int GL_LIGHTING = 2896; - - // Field descriptor #544 I - public static final int GL_LIGHT_MODEL_LOCAL_VIEWER = 2897; - - // Field descriptor #544 I - public static final int GL_LIGHT_MODEL_TWO_SIDE = 2898; - - // Field descriptor #544 I - public static final int GL_LIGHT_MODEL_AMBIENT = 2899; - - // Field descriptor #544 I - public static final int GL_SHADE_MODEL = 2900; - - // Field descriptor #544 I - public static final int GL_COLOR_MATERIAL_FACE = 2901; - - // Field descriptor #544 I - public static final int GL_COLOR_MATERIAL_PARAMETER = 2902; - - // Field descriptor #544 I - public static final int GL_COLOR_MATERIAL = 2903; - - // Field descriptor #544 I - public static final int GL_FOG = 2912; - - // Field descriptor #544 I - public static final int GL_FOG_INDEX = 2913; - - // Field descriptor #544 I - public static final int GL_FOG_DENSITY = 2914; - - // Field descriptor #544 I - public static final int GL_FOG_START = 2915; - - // Field descriptor #544 I - public static final int GL_FOG_END = 2916; - - // Field descriptor #544 I - public static final int GL_FOG_MODE = 2917; - - // Field descriptor #544 I - public static final int GL_FOG_COLOR = 2918; - - // Field descriptor #544 I - public static final int GL_DEPTH_RANGE = 2928; - - // Field descriptor #544 I - public static final int GL_DEPTH_TEST = 2929; - - // Field descriptor #544 I - public static final int GL_DEPTH_WRITEMASK = 2930; - - // Field descriptor #544 I - public static final int GL_DEPTH_CLEAR_VALUE = 2931; - - // Field descriptor #544 I - public static final int GL_DEPTH_FUNC = 2932; - - // Field descriptor #544 I - public static final int GL_ACCUM_CLEAR_VALUE = 2944; - - // Field descriptor #544 I - public static final int GL_STENCIL_TEST = 2960; - - // Field descriptor #544 I - public static final int GL_STENCIL_CLEAR_VALUE = 2961; - - // Field descriptor #544 I - public static final int GL_STENCIL_FUNC = 2962; - - // Field descriptor #544 I - public static final int GL_STENCIL_VALUE_MASK = 2963; - - // Field descriptor #544 I - public static final int GL_STENCIL_FAIL = 2964; - - // Field descriptor #544 I - public static final int GL_STENCIL_PASS_DEPTH_FAIL = 2965; - - // Field descriptor #544 I - public static final int GL_STENCIL_PASS_DEPTH_PASS = 2966; - - // Field descriptor #544 I - public static final int GL_STENCIL_REF = 2967; - - // Field descriptor #544 I - public static final int GL_STENCIL_WRITEMASK = 2968; - - // Field descriptor #544 I - public static final int GL_MATRIX_MODE = 2976; - - // Field descriptor #544 I - public static final int GL_NORMALIZE = 2977; - - // Field descriptor #544 I - public static final int GL_VIEWPORT = 2978; - - // Field descriptor #544 I - public static final int GL_MODELVIEW_STACK_DEPTH = 2979; - - // Field descriptor #544 I - public static final int GL_PROJECTION_STACK_DEPTH = 2980; - - // Field descriptor #544 I - public static final int GL_TEXTURE_STACK_DEPTH = 2981; - - // Field descriptor #544 I - public static final int GL_MODELVIEW_MATRIX = 2982; - - // Field descriptor #544 I - public static final int GL_PROJECTION_MATRIX = 2983; - - // Field descriptor #544 I - public static final int GL_TEXTURE_MATRIX = 2984; - - // Field descriptor #544 I - public static final int GL_ATTRIB_STACK_DEPTH = 2992; - - // Field descriptor #544 I - public static final int GL_CLIENT_ATTRIB_STACK_DEPTH = 2993; - - // Field descriptor #544 I - public static final int GL_ALPHA_TEST = 3008; - - // Field descriptor #544 I - public static final int GL_ALPHA_TEST_FUNC = 3009; - - // Field descriptor #544 I - public static final int GL_ALPHA_TEST_REF = 3010; - - // Field descriptor #544 I - public static final int GL_DITHER = 3024; - - // Field descriptor #544 I - public static final int GL_BLEND_DST = 3040; - - // Field descriptor #544 I - public static final int GL_BLEND_SRC = 3041; - - // Field descriptor #544 I - public static final int GL_BLEND = 3042; - - // Field descriptor #544 I - public static final int GL_LOGIC_OP_MODE = 3056; - - // Field descriptor #544 I - public static final int GL_INDEX_LOGIC_OP = 3057; - - // Field descriptor #544 I - public static final int GL_COLOR_LOGIC_OP = 3058; - - // Field descriptor #544 I - public static final int GL_AUX_BUFFERS = 3072; - - // Field descriptor #544 I - public static final int GL_DRAW_BUFFER = 3073; - - // Field descriptor #544 I - public static final int GL_READ_BUFFER = 3074; - - // Field descriptor #544 I - public static final int GL_SCISSOR_BOX = 3088; - - // Field descriptor #544 I - public static final int GL_SCISSOR_TEST = 3089; - - // Field descriptor #544 I - public static final int GL_INDEX_CLEAR_VALUE = 3104; - - // Field descriptor #544 I - public static final int GL_INDEX_WRITEMASK = 3105; - - // Field descriptor #544 I - public static final int GL_COLOR_CLEAR_VALUE = 3106; - - // Field descriptor #544 I - public static final int GL_COLOR_WRITEMASK = 3107; - - // Field descriptor #544 I - public static final int GL_INDEX_MODE = 3120; - - // Field descriptor #544 I - public static final int GL_RGBA_MODE = 3121; - - // Field descriptor #544 I - public static final int GL_DOUBLEBUFFER = 3122; - - // Field descriptor #544 I - public static final int GL_STEREO = 3123; - - // Field descriptor #544 I - public static final int GL_RENDER_MODE = 3136; - - // Field descriptor #544 I - public static final int GL_PERSPECTIVE_CORRECTION_HINT = 3152; - - // Field descriptor #544 I - public static final int GL_POINT_SMOOTH_HINT = 3153; - - // Field descriptor #544 I - public static final int GL_LINE_SMOOTH_HINT = 3154; - - // Field descriptor #544 I - public static final int GL_POLYGON_SMOOTH_HINT = 3155; - - // Field descriptor #544 I - public static final int GL_FOG_HINT = 3156; - - // Field descriptor #544 I - public static final int GL_TEXTURE_GEN_S = 3168; - - // Field descriptor #544 I - public static final int GL_TEXTURE_GEN_T = 3169; - - // Field descriptor #544 I - public static final int GL_TEXTURE_GEN_R = 3170; - - // Field descriptor #544 I - public static final int GL_TEXTURE_GEN_Q = 3171; - - // Field descriptor #544 I - public static final int GL_PIXEL_MAP_I_TO_I = 3184; - - // Field descriptor #544 I - public static final int GL_PIXEL_MAP_S_TO_S = 3185; - - // Field descriptor #544 I - public static final int GL_PIXEL_MAP_I_TO_R = 3186; - - // Field descriptor #544 I - public static final int GL_PIXEL_MAP_I_TO_G = 3187; - - // Field descriptor #544 I - public static final int GL_PIXEL_MAP_I_TO_B = 3188; - - // Field descriptor #544 I - public static final int GL_PIXEL_MAP_I_TO_A = 3189; - - // Field descriptor #544 I - public static final int GL_PIXEL_MAP_R_TO_R = 3190; - - // Field descriptor #544 I - public static final int GL_PIXEL_MAP_G_TO_G = 3191; - - // Field descriptor #544 I - public static final int GL_PIXEL_MAP_B_TO_B = 3192; - - // Field descriptor #544 I - public static final int GL_PIXEL_MAP_A_TO_A = 3193; - - // Field descriptor #544 I - public static final int GL_PIXEL_MAP_I_TO_I_SIZE = 3248; - - // Field descriptor #544 I - public static final int GL_PIXEL_MAP_S_TO_S_SIZE = 3249; - - // Field descriptor #544 I - public static final int GL_PIXEL_MAP_I_TO_R_SIZE = 3250; - - // Field descriptor #544 I - public static final int GL_PIXEL_MAP_I_TO_G_SIZE = 3251; - - // Field descriptor #544 I - public static final int GL_PIXEL_MAP_I_TO_B_SIZE = 3252; - - // Field descriptor #544 I - public static final int GL_PIXEL_MAP_I_TO_A_SIZE = 3253; - - // Field descriptor #544 I - public static final int GL_PIXEL_MAP_R_TO_R_SIZE = 3254; - - // Field descriptor #544 I - public static final int GL_PIXEL_MAP_G_TO_G_SIZE = 3255; - - // Field descriptor #544 I - public static final int GL_PIXEL_MAP_B_TO_B_SIZE = 3256; - - // Field descriptor #544 I - public static final int GL_PIXEL_MAP_A_TO_A_SIZE = 3257; - - // Field descriptor #544 I - public static final int GL_UNPACK_SWAP_BYTES = 3312; - - // Field descriptor #544 I - public static final int GL_UNPACK_LSB_FIRST = 3313; - - // Field descriptor #544 I - public static final int GL_UNPACK_ROW_LENGTH = 3314; - - // Field descriptor #544 I - public static final int GL_UNPACK_SKIP_ROWS = 3315; - - // Field descriptor #544 I - public static final int GL_UNPACK_SKIP_PIXELS = 3316; - - // Field descriptor #544 I - public static final int GL_UNPACK_ALIGNMENT = 3317; - - // Field descriptor #544 I - public static final int GL_PACK_SWAP_BYTES = 3328; - - // Field descriptor #544 I - public static final int GL_PACK_LSB_FIRST = 3329; - - // Field descriptor #544 I - public static final int GL_PACK_ROW_LENGTH = 3330; - - // Field descriptor #544 I - public static final int GL_PACK_SKIP_ROWS = 3331; - - // Field descriptor #544 I - public static final int GL_PACK_SKIP_PIXELS = 3332; - - // Field descriptor #544 I - public static final int GL_PACK_ALIGNMENT = 3333; - - // Field descriptor #544 I - public static final int GL_MAP_COLOR = 3344; - - // Field descriptor #544 I - public static final int GL_MAP_STENCIL = 3345; - - // Field descriptor #544 I - public static final int GL_INDEX_SHIFT = 3346; - - // Field descriptor #544 I - public static final int GL_INDEX_OFFSET = 3347; - - // Field descriptor #544 I - public static final int GL_RED_SCALE = 3348; - - // Field descriptor #544 I - public static final int GL_RED_BIAS = 3349; - - // Field descriptor #544 I - public static final int GL_ZOOM_X = 3350; - - // Field descriptor #544 I - public static final int GL_ZOOM_Y = 3351; - - // Field descriptor #544 I - public static final int GL_GREEN_SCALE = 3352; - - // Field descriptor #544 I - public static final int GL_GREEN_BIAS = 3353; - - // Field descriptor #544 I - public static final int GL_BLUE_SCALE = 3354; - - // Field descriptor #544 I - public static final int GL_BLUE_BIAS = 3355; - - // Field descriptor #544 I - public static final int GL_ALPHA_SCALE = 3356; - - // Field descriptor #544 I - public static final int GL_ALPHA_BIAS = 3357; - - // Field descriptor #544 I - public static final int GL_DEPTH_SCALE = 3358; - - // Field descriptor #544 I - public static final int GL_DEPTH_BIAS = 3359; - - // Field descriptor #544 I - public static final int GL_MAX_EVAL_ORDER = 3376; - - // Field descriptor #544 I - public static final int GL_MAX_LIGHTS = 3377; - - // Field descriptor #544 I - public static final int GL_MAX_CLIP_PLANES = 3378; - - // Field descriptor #544 I - public static final int GL_MAX_TEXTURE_SIZE = 3379; - - // Field descriptor #544 I - public static final int GL_MAX_PIXEL_MAP_TABLE = 3380; - - // Field descriptor #544 I - public static final int GL_MAX_ATTRIB_STACK_DEPTH = 3381; - - // Field descriptor #544 I - public static final int GL_MAX_MODELVIEW_STACK_DEPTH = 3382; - - // Field descriptor #544 I - public static final int GL_MAX_NAME_STACK_DEPTH = 3383; - - // Field descriptor #544 I - public static final int GL_MAX_PROJECTION_STACK_DEPTH = 3384; - - // Field descriptor #544 I - public static final int GL_MAX_TEXTURE_STACK_DEPTH = 3385; - - // Field descriptor #544 I - public static final int GL_MAX_VIEWPORT_DIMS = 3386; - - // Field descriptor #544 I - public static final int GL_MAX_CLIENT_ATTRIB_STACK_DEPTH = 3387; - - // Field descriptor #544 I - public static final int GL_SUBPIXEL_BITS = 3408; - - // Field descriptor #544 I - public static final int GL_INDEX_BITS = 3409; - - // Field descriptor #544 I - public static final int GL_RED_BITS = 3410; - - // Field descriptor #544 I - public static final int GL_GREEN_BITS = 3411; - - // Field descriptor #544 I - public static final int GL_BLUE_BITS = 3412; - - // Field descriptor #544 I - public static final int GL_ALPHA_BITS = 3413; - - // Field descriptor #544 I - public static final int GL_DEPTH_BITS = 3414; - - // Field descriptor #544 I - public static final int GL_STENCIL_BITS = 3415; - - // Field descriptor #544 I - public static final int GL_ACCUM_RED_BITS = 3416; - - // Field descriptor #544 I - public static final int GL_ACCUM_GREEN_BITS = 3417; - - // Field descriptor #544 I - public static final int GL_ACCUM_BLUE_BITS = 3418; - - // Field descriptor #544 I - public static final int GL_ACCUM_ALPHA_BITS = 3419; - - // Field descriptor #544 I - public static final int GL_NAME_STACK_DEPTH = 3440; - - // Field descriptor #544 I - public static final int GL_AUTO_NORMAL = 3456; - - // Field descriptor #544 I - public static final int GL_MAP1_COLOR_4 = 3472; - - // Field descriptor #544 I - public static final int GL_MAP1_INDEX = 3473; - - // Field descriptor #544 I - public static final int GL_MAP1_NORMAL = 3474; - - // Field descriptor #544 I - public static final int GL_MAP1_TEXTURE_COORD_1 = 3475; - - // Field descriptor #544 I - public static final int GL_MAP1_TEXTURE_COORD_2 = 3476; - - // Field descriptor #544 I - public static final int GL_MAP1_TEXTURE_COORD_3 = 3477; - - // Field descriptor #544 I - public static final int GL_MAP1_TEXTURE_COORD_4 = 3478; - - // Field descriptor #544 I - public static final int GL_MAP1_VERTEX_3 = 3479; - - // Field descriptor #544 I - public static final int GL_MAP1_VERTEX_4 = 3480; - - // Field descriptor #544 I - public static final int GL_MAP2_COLOR_4 = 3504; - - // Field descriptor #544 I - public static final int GL_MAP2_INDEX = 3505; - - // Field descriptor #544 I - public static final int GL_MAP2_NORMAL = 3506; - - // Field descriptor #544 I - public static final int GL_MAP2_TEXTURE_COORD_1 = 3507; - - // Field descriptor #544 I - public static final int GL_MAP2_TEXTURE_COORD_2 = 3508; - - // Field descriptor #544 I - public static final int GL_MAP2_TEXTURE_COORD_3 = 3509; - - // Field descriptor #544 I - public static final int GL_MAP2_TEXTURE_COORD_4 = 3510; - - // Field descriptor #544 I - public static final int GL_MAP2_VERTEX_3 = 3511; - - // Field descriptor #544 I - public static final int GL_MAP2_VERTEX_4 = 3512; - - // Field descriptor #544 I - public static final int GL_MAP1_GRID_DOMAIN = 3536; - - // Field descriptor #544 I - public static final int GL_MAP1_GRID_SEGMENTS = 3537; - - // Field descriptor #544 I - public static final int GL_MAP2_GRID_DOMAIN = 3538; - - // Field descriptor #544 I - public static final int GL_MAP2_GRID_SEGMENTS = 3539; - - // Field descriptor #544 I - public static final int GL_TEXTURE_1D = 3552; - - // Field descriptor #544 I - public static final int GL_TEXTURE_2D = 3553; - - // Field descriptor #544 I - public static final int GL_FEEDBACK_BUFFER_POINTER = 3568; - - // Field descriptor #544 I - public static final int GL_FEEDBACK_BUFFER_SIZE = 3569; - - // Field descriptor #544 I - public static final int GL_FEEDBACK_BUFFER_TYPE = 3570; - - // Field descriptor #544 I - public static final int GL_SELECTION_BUFFER_POINTER = 3571; - - // Field descriptor #544 I - public static final int GL_SELECTION_BUFFER_SIZE = 3572; - - // Field descriptor #544 I - public static final int GL_TEXTURE_WIDTH = 4096; - - // Field descriptor #544 I - public static final int GL_TEXTURE_HEIGHT = 4097; - - // Field descriptor #544 I - public static final int GL_TEXTURE_INTERNAL_FORMAT = 4099; - - // Field descriptor #544 I - public static final int GL_TEXTURE_BORDER_COLOR = 4100; - - // Field descriptor #544 I - public static final int GL_TEXTURE_BORDER = 4101; - - // Field descriptor #544 I - public static final int GL_DONT_CARE = 4352; - - // Field descriptor #544 I - public static final int GL_FASTEST = 4353; - - // Field descriptor #544 I - public static final int GL_NICEST = 4354; - - // Field descriptor #544 I - public static final int GL_LIGHT0 = 16384; - - // Field descriptor #544 I - public static final int GL_LIGHT1 = 16385; - - // Field descriptor #544 I - public static final int GL_LIGHT2 = 16386; - - // Field descriptor #544 I - public static final int GL_LIGHT3 = 16387; - - // Field descriptor #544 I - public static final int GL_LIGHT4 = 16388; - - // Field descriptor #544 I - public static final int GL_LIGHT5 = 16389; - - // Field descriptor #544 I - public static final int GL_LIGHT6 = 16390; - - // Field descriptor #544 I - public static final int GL_LIGHT7 = 16391; - - // Field descriptor #544 I - public static final int GL_AMBIENT = 4608; - - // Field descriptor #544 I - public static final int GL_DIFFUSE = 4609; - - // Field descriptor #544 I - public static final int GL_SPECULAR = 4610; - - // Field descriptor #544 I - public static final int GL_POSITION = 4611; - - // Field descriptor #544 I - public static final int GL_SPOT_DIRECTION = 4612; - - // Field descriptor #544 I - public static final int GL_SPOT_EXPONENT = 4613; - - // Field descriptor #544 I - public static final int GL_SPOT_CUTOFF = 4614; - - // Field descriptor #544 I - public static final int GL_CONSTANT_ATTENUATION = 4615; - - // Field descriptor #544 I - public static final int GL_LINEAR_ATTENUATION = 4616; - - // Field descriptor #544 I - public static final int GL_QUADRATIC_ATTENUATION = 4617; - - // Field descriptor #544 I - public static final int GL_COMPILE = 4864; - - // Field descriptor #544 I - public static final int GL_COMPILE_AND_EXECUTE = 4865; - - // Field descriptor #544 I - public static final int GL_CLEAR = 5376; - - // Field descriptor #544 I - public static final int GL_AND = 5377; - - // Field descriptor #544 I - public static final int GL_AND_REVERSE = 5378; - - // Field descriptor #544 I - public static final int GL_COPY = 5379; - - // Field descriptor #544 I - public static final int GL_AND_INVERTED = 5380; - - // Field descriptor #544 I - public static final int GL_NOOP = 5381; - - // Field descriptor #544 I - public static final int GL_XOR = 5382; - - // Field descriptor #544 I - public static final int GL_OR = 5383; - - // Field descriptor #544 I - public static final int GL_NOR = 5384; - - // Field descriptor #544 I - public static final int GL_EQUIV = 5385; - - // Field descriptor #544 I - public static final int GL_INVERT = 5386; - - // Field descriptor #544 I - public static final int GL_OR_REVERSE = 5387; - - // Field descriptor #544 I - public static final int GL_COPY_INVERTED = 5388; - - // Field descriptor #544 I - public static final int GL_OR_INVERTED = 5389; - - // Field descriptor #544 I - public static final int GL_NAND = 5390; - - // Field descriptor #544 I - public static final int GL_SET = 5391; - - // Field descriptor #544 I - public static final int GL_EMISSION = 5632; - - // Field descriptor #544 I - public static final int GL_SHININESS = 5633; - - // Field descriptor #544 I - public static final int GL_AMBIENT_AND_DIFFUSE = 5634; - - // Field descriptor #544 I - public static final int GL_COLOR_INDEXES = 5635; - - // Field descriptor #544 I - public static final int GL_MODELVIEW = 5888; - - // Field descriptor #544 I - public static final int GL_PROJECTION = 5889; - - // Field descriptor #544 I - public static final int GL_TEXTURE = 5890; - - // Field descriptor #544 I - public static final int GL_COLOR = 6144; - - // Field descriptor #544 I - public static final int GL_DEPTH = 6145; - - // Field descriptor #544 I - public static final int GL_STENCIL = 6146; - - // Field descriptor #544 I - public static final int GL_COLOR_INDEX = 6400; - - // Field descriptor #544 I - public static final int GL_STENCIL_INDEX = 6401; - - // Field descriptor #544 I - public static final int GL_DEPTH_COMPONENT = 6402; - - // Field descriptor #544 I - public static final int GL_RED = 6403; - - // Field descriptor #544 I - public static final int GL_GREEN = 6404; - - // Field descriptor #544 I - public static final int GL_BLUE = 6405; - - // Field descriptor #544 I - public static final int GL_ALPHA = 6406; - - // Field descriptor #544 I - public static final int GL_RGB = 6407; - - // Field descriptor #544 I - public static final int GL_RGBA = 6408; - - // Field descriptor #544 I - public static final int GL_LUMINANCE = 6409; - - // Field descriptor #544 I - public static final int GL_LUMINANCE_ALPHA = 6410; - - // Field descriptor #544 I - public static final int GL_BITMAP = 6656; - - // Field descriptor #544 I - public static final int GL_POINT = 6912; - - // Field descriptor #544 I - public static final int GL_LINE = 6913; - - // Field descriptor #544 I - public static final int GL_FILL = 6914; - - // Field descriptor #544 I - public static final int GL_RENDER = 7168; - - // Field descriptor #544 I - public static final int GL_FEEDBACK = 7169; - - // Field descriptor #544 I - public static final int GL_SELECT = 7170; - - // Field descriptor #544 I - public static final int GL_FLAT = 7424; - - // Field descriptor #544 I - public static final int GL_SMOOTH = 7425; - - // Field descriptor #544 I - public static final int GL_KEEP = 7680; - - // Field descriptor #544 I - public static final int GL_REPLACE = 7681; - - // Field descriptor #544 I - public static final int GL_INCR = 7682; - - // Field descriptor #544 I - public static final int GL_DECR = 7683; - - // Field descriptor #544 I - public static final int GL_VENDOR = 7936; - - // Field descriptor #544 I - public static final int GL_RENDERER = 7937; - - // Field descriptor #544 I - public static final int GL_VERSION = 7938; - - // Field descriptor #544 I - public static final int GL_EXTENSIONS = 7939; - - // Field descriptor #544 I - public static final int GL_S = 8192; - - // Field descriptor #544 I - public static final int GL_T = 8193; - - // Field descriptor #544 I - public static final int GL_R = 8194; - - // Field descriptor #544 I - public static final int GL_Q = 8195; - - // Field descriptor #544 I - public static final int GL_MODULATE = 8448; - - // Field descriptor #544 I - public static final int GL_DECAL = 8449; - - // Field descriptor #544 I - public static final int GL_TEXTURE_ENV_MODE = 8704; - - // Field descriptor #544 I - public static final int GL_TEXTURE_ENV_COLOR = 8705; - - // Field descriptor #544 I - public static final int GL_TEXTURE_ENV = 8960; - - // Field descriptor #544 I - public static final int GL_EYE_LINEAR = 9216; - - // Field descriptor #544 I - public static final int GL_OBJECT_LINEAR = 9217; - - // Field descriptor #544 I - public static final int GL_SPHERE_MAP = 9218; - - // Field descriptor #544 I - public static final int GL_TEXTURE_GEN_MODE = 9472; - - // Field descriptor #544 I - public static final int GL_OBJECT_PLANE = 9473; - - // Field descriptor #544 I - public static final int GL_EYE_PLANE = 9474; - - // Field descriptor #544 I - public static final int GL_NEAREST = 9728; - - // Field descriptor #544 I - public static final int GL_LINEAR = 9729; - - // Field descriptor #544 I - public static final int GL_NEAREST_MIPMAP_NEAREST = 9984; - - // Field descriptor #544 I - public static final int GL_LINEAR_MIPMAP_NEAREST = 9985; - - // Field descriptor #544 I - public static final int GL_NEAREST_MIPMAP_LINEAR = 9986; - - // Field descriptor #544 I - public static final int GL_LINEAR_MIPMAP_LINEAR = 9987; - - // Field descriptor #544 I - public static final int GL_TEXTURE_MAG_FILTER = 10240; - - // Field descriptor #544 I - public static final int GL_TEXTURE_MIN_FILTER = 10241; - - // Field descriptor #544 I - public static final int GL_TEXTURE_WRAP_S = 10242; - - // Field descriptor #544 I - public static final int GL_TEXTURE_WRAP_T = 10243; - - // Field descriptor #544 I - public static final int GL_CLAMP = 10496; - - // Field descriptor #544 I - public static final int GL_REPEAT = 10497; - - // Field descriptor #544 I - public static final int GL_CLIENT_PIXEL_STORE_BIT = 1; - - // Field descriptor #544 I - public static final int GL_CLIENT_VERTEX_ARRAY_BIT = 2; - - // Field descriptor #544 I - public static final int GL_ALL_CLIENT_ATTRIB_BITS = -1; - - // Field descriptor #544 I - public static final int GL_POLYGON_OFFSET_FACTOR = 32824; - - // Field descriptor #544 I - public static final int GL_POLYGON_OFFSET_UNITS = 10752; - - // Field descriptor #544 I - public static final int GL_POLYGON_OFFSET_POINT = 10753; - - // Field descriptor #544 I - public static final int GL_POLYGON_OFFSET_LINE = 10754; - - // Field descriptor #544 I - public static final int GL_POLYGON_OFFSET_FILL = 32823; - - // Field descriptor #544 I - public static final int GL_ALPHA4 = 32827; - - // Field descriptor #544 I - public static final int GL_ALPHA8 = 32828; - - // Field descriptor #544 I - public static final int GL_ALPHA12 = 32829; - - // Field descriptor #544 I - public static final int GL_ALPHA16 = 32830; - - // Field descriptor #544 I - public static final int GL_LUMINANCE4 = 32831; - - // Field descriptor #544 I - public static final int GL_LUMINANCE8 = 32832; - - // Field descriptor #544 I - public static final int GL_LUMINANCE12 = 32833; - - // Field descriptor #544 I - public static final int GL_LUMINANCE16 = 32834; - - // Field descriptor #544 I - public static final int GL_LUMINANCE4_ALPHA4 = 32835; - - // Field descriptor #544 I - public static final int GL_LUMINANCE6_ALPHA2 = 32836; - - // Field descriptor #544 I - public static final int GL_LUMINANCE8_ALPHA8 = 32837; - - // Field descriptor #544 I - public static final int GL_LUMINANCE12_ALPHA4 = 32838; - - // Field descriptor #544 I - public static final int GL_LUMINANCE12_ALPHA12 = 32839; - - // Field descriptor #544 I - public static final int GL_LUMINANCE16_ALPHA16 = 32840; - - // Field descriptor #544 I - public static final int GL_INTENSITY = 32841; - - // Field descriptor #544 I - public static final int GL_INTENSITY4 = 32842; - - // Field descriptor #544 I - public static final int GL_INTENSITY8 = 32843; - - // Field descriptor #544 I - public static final int GL_INTENSITY12 = 32844; - - // Field descriptor #544 I - public static final int GL_INTENSITY16 = 32845; - - // Field descriptor #544 I - public static final int GL_R3_G3_B2 = 10768; - - // Field descriptor #544 I - public static final int GL_RGB4 = 32847; - - // Field descriptor #544 I - public static final int GL_RGB5 = 32848; - - // Field descriptor #544 I - public static final int GL_RGB8 = 32849; - - // Field descriptor #544 I - public static final int GL_RGB10 = 32850; - - // Field descriptor #544 I - public static final int GL_RGB12 = 32851; - - // Field descriptor #544 I - public static final int GL_RGB16 = 32852; - - // Field descriptor #544 I - public static final int GL_RGBA2 = 32853; - - // Field descriptor #544 I - public static final int GL_RGBA4 = 32854; - - // Field descriptor #544 I - public static final int GL_RGB5_A1 = 32855; - - // Field descriptor #544 I - public static final int GL_RGBA8 = 32856; - - // Field descriptor #544 I - public static final int GL_RGB10_A2 = 32857; - - // Field descriptor #544 I - public static final int GL_RGBA12 = 32858; - - // Field descriptor #544 I - public static final int GL_RGBA16 = 32859; - - // Field descriptor #544 I - public static final int GL_TEXTURE_RED_SIZE = 32860; - - // Field descriptor #544 I - public static final int GL_TEXTURE_GREEN_SIZE = 32861; - - // Field descriptor #544 I - public static final int GL_TEXTURE_BLUE_SIZE = 32862; - - // Field descriptor #544 I - public static final int GL_TEXTURE_ALPHA_SIZE = 32863; - - // Field descriptor #544 I - public static final int GL_TEXTURE_LUMINANCE_SIZE = 32864; - - // Field descriptor #544 I - public static final int GL_TEXTURE_INTENSITY_SIZE = 32865; - - // Field descriptor #544 I - public static final int GL_PROXY_TEXTURE_1D = 32867; - - // Field descriptor #544 I - public static final int GL_PROXY_TEXTURE_2D = 32868; - - // Field descriptor #544 I - public static final int GL_TEXTURE_PRIORITY = 32870; - - // Field descriptor #544 I - public static final int GL_TEXTURE_RESIDENT = 32871; - - // Field descriptor #544 I - public static final int GL_TEXTURE_BINDING_1D = 32872; - - // Field descriptor #544 I - public static final int GL_TEXTURE_BINDING_2D = 32873; - - // Field descriptor #544 I - public static final int GL_VERTEX_ARRAY = 32884; - - // Field descriptor #544 I - public static final int GL_NORMAL_ARRAY = 32885; - - // Field descriptor #544 I - public static final int GL_COLOR_ARRAY = 32886; - - // Field descriptor #544 I - public static final int GL_INDEX_ARRAY = 32887; - - // Field descriptor #544 I - public static final int GL_TEXTURE_COORD_ARRAY = 32888; - - // Field descriptor #544 I - public static final int GL_EDGE_FLAG_ARRAY = 32889; - - // Field descriptor #544 I - public static final int GL_VERTEX_ARRAY_SIZE = 32890; - - // Field descriptor #544 I - public static final int GL_VERTEX_ARRAY_TYPE = 32891; - - // Field descriptor #544 I - public static final int GL_VERTEX_ARRAY_STRIDE = 32892; - - // Field descriptor #544 I - public static final int GL_NORMAL_ARRAY_TYPE = 32894; - - // Field descriptor #544 I - public static final int GL_NORMAL_ARRAY_STRIDE = 32895; - - // Field descriptor #544 I - public static final int GL_COLOR_ARRAY_SIZE = 32897; - - // Field descriptor #544 I - public static final int GL_COLOR_ARRAY_TYPE = 32898; - - // Field descriptor #544 I - public static final int GL_COLOR_ARRAY_STRIDE = 32899; - - // Field descriptor #544 I - public static final int GL_INDEX_ARRAY_TYPE = 32901; - - // Field descriptor #544 I - public static final int GL_INDEX_ARRAY_STRIDE = 32902; - - // Field descriptor #544 I - public static final int GL_TEXTURE_COORD_ARRAY_SIZE = 32904; - - // Field descriptor #544 I - public static final int GL_TEXTURE_COORD_ARRAY_TYPE = 32905; - - // Field descriptor #544 I - public static final int GL_TEXTURE_COORD_ARRAY_STRIDE = 32906; - - // Field descriptor #544 I - public static final int GL_EDGE_FLAG_ARRAY_STRIDE = 32908; - - // Field descriptor #544 I - public static final int GL_VERTEX_ARRAY_POINTER = 32910; - - // Field descriptor #544 I - public static final int GL_NORMAL_ARRAY_POINTER = 32911; - - // Field descriptor #544 I - public static final int GL_COLOR_ARRAY_POINTER = 32912; - - // Field descriptor #544 I - public static final int GL_INDEX_ARRAY_POINTER = 32913; - - // Field descriptor #544 I - public static final int GL_TEXTURE_COORD_ARRAY_POINTER = 32914; - - // Field descriptor #544 I - public static final int GL_EDGE_FLAG_ARRAY_POINTER = 32915; - - // Field descriptor #544 I - public static final int GL_V2F = 10784; - - // Field descriptor #544 I - public static final int GL_V3F = 10785; - - // Field descriptor #544 I - public static final int GL_C4UB_V2F = 10786; - - // Field descriptor #544 I - public static final int GL_C4UB_V3F = 10787; - - // Field descriptor #544 I - public static final int GL_C3F_V3F = 10788; - - // Field descriptor #544 I - public static final int GL_N3F_V3F = 10789; - - // Field descriptor #544 I - public static final int GL_C4F_N3F_V3F = 10790; - - // Field descriptor #544 I - public static final int GL_T2F_V3F = 10791; - - // Field descriptor #544 I - public static final int GL_T4F_V4F = 10792; - - // Field descriptor #544 I - public static final int GL_T2F_C4UB_V3F = 10793; - - // Field descriptor #544 I - public static final int GL_T2F_C3F_V3F = 10794; - - // Field descriptor #544 I - public static final int GL_T2F_N3F_V3F = 10795; - - // Field descriptor #544 I - public static final int GL_T2F_C4F_N3F_V3F = 10796; - - // Field descriptor #544 I - public static final int GL_T4F_C4F_N3F_V4F = 10797; - - // Field descriptor #544 I - public static final int GL_LOGIC_OP = 3057; - - // Field descriptor #544 I - public static final int GL_TEXTURE_COMPONENTS = 4099; - - // Field descriptor #45 I - public static final int GL_TEXTURE_BINDING_3D = 32874; - - // Field descriptor #45 I - public static final int GL_PACK_SKIP_IMAGES = 32875; - - // Field descriptor #45 I - public static final int GL_PACK_IMAGE_HEIGHT = 32876; - - // Field descriptor #45 I - public static final int GL_UNPACK_SKIP_IMAGES = 32877; - - // Field descriptor #45 I - public static final int GL_UNPACK_IMAGE_HEIGHT = 32878; - - // Field descriptor #45 I - public static final int GL_TEXTURE_3D = 32879; - - // Field descriptor #45 I - public static final int GL_PROXY_TEXTURE_3D = 32880; - - // Field descriptor #45 I - public static final int GL_TEXTURE_DEPTH = 32881; - - // Field descriptor #45 I - public static final int GL_TEXTURE_WRAP_R = 32882; - - // Field descriptor #45 I - public static final int GL_MAX_3D_TEXTURE_SIZE = 32883; - - // Field descriptor #45 I - public static final int GL_BGR = 32992; - - // Field descriptor #45 I - public static final int GL_BGRA = 32993; - - // Field descriptor #45 I - public static final int GL_UNSIGNED_BYTE_3_3_2 = 32818; - - // Field descriptor #45 I - public static final int GL_UNSIGNED_BYTE_2_3_3_REV = 33634; - - // Field descriptor #45 I - public static final int GL_UNSIGNED_SHORT_5_6_5 = 33635; - - // Field descriptor #45 I - public static final int GL_UNSIGNED_SHORT_5_6_5_REV = 33636; - - // Field descriptor #45 I - public static final int GL_UNSIGNED_SHORT_4_4_4_4 = 32819; - - // Field descriptor #45 I - public static final int GL_UNSIGNED_SHORT_4_4_4_4_REV = 33637; - - // Field descriptor #45 I - public static final int GL_UNSIGNED_SHORT_5_5_5_1 = 32820; - - // Field descriptor #45 I - public static final int GL_UNSIGNED_SHORT_1_5_5_5_REV = 33638; - - // Field descriptor #45 I - public static final int GL_UNSIGNED_INT_8_8_8_8 = 32821; - - // Field descriptor #45 I - public static final int GL_UNSIGNED_INT_8_8_8_8_REV = 33639; - - // Field descriptor #45 I - public static final int GL_UNSIGNED_INT_10_10_10_2 = 32822; - - // Field descriptor #45 I - public static final int GL_UNSIGNED_INT_2_10_10_10_REV = 33640; - - // Field descriptor #45 I - public static final int GL_RESCALE_NORMAL = 32826; - - // Field descriptor #45 I - public static final int GL_LIGHT_MODEL_COLOR_CONTROL = 33272; - - // Field descriptor #45 I - public static final int GL_SINGLE_COLOR = 33273; - - // Field descriptor #45 I - public static final int GL_SEPARATE_SPECULAR_COLOR = 33274; - - // Field descriptor #45 I - public static final int GL_CLAMP_TO_EDGE = 33071; - - // Field descriptor #45 I - public static final int GL_TEXTURE_MIN_LOD = 33082; - - // Field descriptor #45 I - public static final int GL_TEXTURE_MAX_LOD = 33083; - - // Field descriptor #45 I - public static final int GL_TEXTURE_BASE_LEVEL = 33084; - - // Field descriptor #45 I - public static final int GL_TEXTURE_MAX_LEVEL = 33085; - - // Field descriptor #45 I - public static final int GL_MAX_ELEMENTS_VERTICES = 33000; - - // Field descriptor #45 I - public static final int GL_MAX_ELEMENTS_INDICES = 33001; - - // Field descriptor #45 I - public static final int GL_ALIASED_POINT_SIZE_RANGE = 33901; - - // Field descriptor #45 I - public static final int GL_ALIASED_LINE_WIDTH_RANGE = 33902; - - // Field descriptor #45 I - public static final int GL_SMOOTH_POINT_SIZE_RANGE = 2834; - - // Field descriptor #45 I - public static final int GL_SMOOTH_POINT_SIZE_GRANULARITY = 2835; - - // Field descriptor #45 I - public static final int GL_SMOOTH_LINE_WIDTH_RANGE = 2850; - - // Field descriptor #45 I - public static final int GL_SMOOTH_LINE_WIDTH_GRANULARITY = 2851; - - // Field descriptor #76 I - public static final int GL_TEXTURE0 = 33984; - - // Field descriptor #76 I - public static final int GL_TEXTURE1 = 33985; - - // Field descriptor #76 I - public static final int GL_TEXTURE2 = 33986; - - // Field descriptor #76 I - public static final int GL_TEXTURE3 = 33987; - - // Field descriptor #76 I - public static final int GL_TEXTURE4 = 33988; - - // Field descriptor #76 I - public static final int GL_TEXTURE5 = 33989; - - // Field descriptor #76 I - public static final int GL_TEXTURE6 = 33990; - - // Field descriptor #76 I - public static final int GL_TEXTURE7 = 33991; - - // Field descriptor #76 I - public static final int GL_TEXTURE8 = 33992; - - // Field descriptor #76 I - public static final int GL_TEXTURE9 = 33993; - - // Field descriptor #76 I - public static final int GL_TEXTURE10 = 33994; - - // Field descriptor #76 I - public static final int GL_TEXTURE11 = 33995; - - // Field descriptor #76 I - public static final int GL_TEXTURE12 = 33996; - - // Field descriptor #76 I - public static final int GL_TEXTURE13 = 33997; - - // Field descriptor #76 I - public static final int GL_TEXTURE14 = 33998; - - // Field descriptor #76 I - public static final int GL_TEXTURE15 = 33999; - - // Field descriptor #76 I - public static final int GL_TEXTURE16 = 34000; - - // Field descriptor #76 I - public static final int GL_TEXTURE17 = 34001; - - // Field descriptor #76 I - public static final int GL_TEXTURE18 = 34002; - - // Field descriptor #76 I - public static final int GL_TEXTURE19 = 34003; - - // Field descriptor #76 I - public static final int GL_TEXTURE20 = 34004; - - // Field descriptor #76 I - public static final int GL_TEXTURE21 = 34005; - - // Field descriptor #76 I - public static final int GL_TEXTURE22 = 34006; - - // Field descriptor #76 I - public static final int GL_TEXTURE23 = 34007; - - // Field descriptor #76 I - public static final int GL_TEXTURE24 = 34008; - - // Field descriptor #76 I - public static final int GL_TEXTURE25 = 34009; - - // Field descriptor #76 I - public static final int GL_TEXTURE26 = 34010; - - // Field descriptor #76 I - public static final int GL_TEXTURE27 = 34011; - - // Field descriptor #76 I - public static final int GL_TEXTURE28 = 34012; - - // Field descriptor #76 I - public static final int GL_TEXTURE29 = 34013; - - // Field descriptor #76 I - public static final int GL_TEXTURE30 = 34014; - - // Field descriptor #76 I - public static final int GL_TEXTURE31 = 34015; - - // Field descriptor #76 I - public static final int GL_ACTIVE_TEXTURE = 34016; - - // Field descriptor #76 I - public static final int GL_CLIENT_ACTIVE_TEXTURE = 34017; - - // Field descriptor #76 I - public static final int GL_MAX_TEXTURE_UNITS = 34018; - - // Field descriptor #76 I - public static final int GL_NORMAL_MAP = 34065; - - // Field descriptor #76 I - public static final int GL_REFLECTION_MAP = 34066; - - // Field descriptor #76 I - public static final int GL_TEXTURE_CUBE_MAP = 34067; - - // Field descriptor #76 I - public static final int GL_TEXTURE_BINDING_CUBE_MAP = 34068; - - // Field descriptor #76 I - public static final int GL_TEXTURE_CUBE_MAP_POSITIVE_X = 34069; - - // Field descriptor #76 I - public static final int GL_TEXTURE_CUBE_MAP_NEGATIVE_X = 34070; - - // Field descriptor #76 I - public static final int GL_TEXTURE_CUBE_MAP_POSITIVE_Y = 34071; - - // Field descriptor #76 I - public static final int GL_TEXTURE_CUBE_MAP_NEGATIVE_Y = 34072; - - // Field descriptor #76 I - public static final int GL_TEXTURE_CUBE_MAP_POSITIVE_Z = 34073; - - // Field descriptor #76 I - public static final int GL_TEXTURE_CUBE_MAP_NEGATIVE_Z = 34074; - - // Field descriptor #76 I - public static final int GL_PROXY_TEXTURE_CUBE_MAP = 34075; - - // Field descriptor #76 I - public static final int GL_MAX_CUBE_MAP_TEXTURE_SIZE = 34076; - - // Field descriptor #76 I - public static final int GL_COMPRESSED_ALPHA = 34025; - - // Field descriptor #76 I - public static final int GL_COMPRESSED_LUMINANCE = 34026; - - // Field descriptor #76 I - public static final int GL_COMPRESSED_LUMINANCE_ALPHA = 34027; - - // Field descriptor #76 I - public static final int GL_COMPRESSED_INTENSITY = 34028; - - // Field descriptor #76 I - public static final int GL_COMPRESSED_RGB = 34029; - - // Field descriptor #76 I - public static final int GL_COMPRESSED_RGBA = 34030; - - // Field descriptor #76 I - public static final int GL_TEXTURE_COMPRESSION_HINT = 34031; - - // Field descriptor #76 I - public static final int GL_TEXTURE_COMPRESSED_IMAGE_SIZE = 34464; - - // Field descriptor #76 I - public static final int GL_TEXTURE_COMPRESSED = 34465; - - // Field descriptor #76 I - public static final int GL_NUM_COMPRESSED_TEXTURE_FORMATS = 34466; - - // Field descriptor #76 I - public static final int GL_COMPRESSED_TEXTURE_FORMATS = 34467; - - // Field descriptor #76 I - public static final int GL_MULTISAMPLE = 32925; - - // Field descriptor #76 I - public static final int GL_SAMPLE_ALPHA_TO_COVERAGE = 32926; - - // Field descriptor #76 I - public static final int GL_SAMPLE_ALPHA_TO_ONE = 32927; - - // Field descriptor #76 I - public static final int GL_SAMPLE_COVERAGE = 32928; - - // Field descriptor #76 I - public static final int GL_SAMPLE_BUFFERS = 32936; - - // Field descriptor #76 I - public static final int GL_SAMPLES = 32937; - - // Field descriptor #76 I - public static final int GL_SAMPLE_COVERAGE_VALUE = 32938; - - // Field descriptor #76 I - public static final int GL_SAMPLE_COVERAGE_INVERT = 32939; - - // Field descriptor #76 I - public static final int GL_MULTISAMPLE_BIT = 536870912; - - // Field descriptor #76 I - public static final int GL_TRANSPOSE_MODELVIEW_MATRIX = 34019; - - // Field descriptor #76 I - public static final int GL_TRANSPOSE_PROJECTION_MATRIX = 34020; - - // Field descriptor #76 I - public static final int GL_TRANSPOSE_TEXTURE_MATRIX = 34021; - - // Field descriptor #76 I - public static final int GL_TRANSPOSE_COLOR_MATRIX = 34022; - - // Field descriptor #76 I - public static final int GL_COMBINE = 34160; - - // Field descriptor #76 I - public static final int GL_COMBINE_RGB = 34161; - - // Field descriptor #76 I - public static final int GL_COMBINE_ALPHA = 34162; - - // Field descriptor #76 I - public static final int GL_SOURCE0_RGB = 34176; - - // Field descriptor #76 I - public static final int GL_SOURCE1_RGB = 34177; - - // Field descriptor #76 I - public static final int GL_SOURCE2_RGB = 34178; - - // Field descriptor #76 I - public static final int GL_SOURCE0_ALPHA = 34184; - - // Field descriptor #76 I - public static final int GL_SOURCE1_ALPHA = 34185; - - // Field descriptor #76 I - public static final int GL_SOURCE2_ALPHA = 34186; - - // Field descriptor #76 I - public static final int GL_OPERAND0_RGB = 34192; - - // Field descriptor #76 I - public static final int GL_OPERAND1_RGB = 34193; - - // Field descriptor #76 I - public static final int GL_OPERAND2_RGB = 34194; - - // Field descriptor #76 I - public static final int GL_OPERAND0_ALPHA = 34200; - - // Field descriptor #76 I - public static final int GL_OPERAND1_ALPHA = 34201; - - // Field descriptor #76 I - public static final int GL_OPERAND2_ALPHA = 34202; - - // Field descriptor #76 I - public static final int GL_RGB_SCALE = 34163; - - // Field descriptor #76 I - public static final int GL_ADD_SIGNED = 34164; - - // Field descriptor #76 I - public static final int GL_INTERPOLATE = 34165; - - // Field descriptor #76 I - public static final int GL_SUBTRACT = 34023; - - // Field descriptor #76 I - public static final int GL_CONSTANT = 34166; - - // Field descriptor #76 I - public static final int GL_PRIMARY_COLOR = 34167; - - // Field descriptor #76 I - public static final int GL_PREVIOUS = 34168; - - // Field descriptor #76 I - public static final int GL_DOT3_RGB = 34478; - - // Field descriptor #76 I - public static final int GL_DOT3_RGBA = 34479; - - // Field descriptor #76 I - public static final int GL_CLAMP_TO_BORDER = 33069; - - // Field descriptor #71 I - public static final int GL_ARRAY_BUFFER = 34962; - - // Field descriptor #71 I - public static final int GL_ELEMENT_ARRAY_BUFFER = 34963; - - // Field descriptor #71 I - public static final int GL_ARRAY_BUFFER_BINDING = 34964; - - // Field descriptor #71 I - public static final int GL_ELEMENT_ARRAY_BUFFER_BINDING = 34965; - - // Field descriptor #71 I - public static final int GL_VERTEX_ARRAY_BUFFER_BINDING = 34966; - - // Field descriptor #71 I - public static final int GL_NORMAL_ARRAY_BUFFER_BINDING = 34967; - - // Field descriptor #71 I - public static final int GL_COLOR_ARRAY_BUFFER_BINDING = 34968; - - // Field descriptor #71 I - public static final int GL_INDEX_ARRAY_BUFFER_BINDING = 34969; - - // Field descriptor #71 I - public static final int GL_TEXTURE_COORD_ARRAY_BUFFER_BINDING = 34970; - - // Field descriptor #71 I - public static final int GL_EDGE_FLAG_ARRAY_BUFFER_BINDING = 34971; - - // Field descriptor #71 I - public static final int GL_SECONDARY_COLOR_ARRAY_BUFFER_BINDING = 34972; - - // Field descriptor #71 I - public static final int GL_FOG_COORDINATE_ARRAY_BUFFER_BINDING = 34973; - - // Field descriptor #71 I - public static final int GL_WEIGHT_ARRAY_BUFFER_BINDING = 34974; - - // Field descriptor #71 I - public static final int GL_VERTEX_ATTRIB_ARRAY_BUFFER_BINDING = 34975; - - // Field descriptor #71 I - public static final int GL_STREAM_DRAW = 35040; - - // Field descriptor #71 I - public static final int GL_STREAM_READ = 35041; - - // Field descriptor #71 I - public static final int GL_STREAM_COPY = 35042; - - // Field descriptor #71 I - public static final int GL_STATIC_DRAW = 35044; - - // Field descriptor #71 I - public static final int GL_STATIC_READ = 35045; - - // Field descriptor #71 I - public static final int GL_STATIC_COPY = 35046; - - // Field descriptor #71 I - public static final int GL_DYNAMIC_DRAW = 35048; - - // Field descriptor #71 I - public static final int GL_DYNAMIC_READ = 35049; - - // Field descriptor #71 I - public static final int GL_DYNAMIC_COPY = 35050; - - // Field descriptor #71 I - public static final int GL_READ_ONLY = 35000; - - // Field descriptor #71 I - public static final int GL_WRITE_ONLY = 35001; - - // Field descriptor #71 I - public static final int GL_READ_WRITE = 35002; - - // Field descriptor #71 I - public static final int GL_BUFFER_SIZE = 34660; - - // Field descriptor #71 I - public static final int GL_BUFFER_USAGE = 34661; - - // Field descriptor #71 I - public static final int GL_BUFFER_ACCESS = 35003; - - // Field descriptor #71 I - public static final int GL_BUFFER_MAPPED = 35004; - - // Field descriptor #71 I - public static final int GL_BUFFER_MAP_POINTER = 35005; - - // Field descriptor #71 I - public static final int GL_FOG_COORD_SRC = 33872; - - // Field descriptor #71 I - public static final int GL_FOG_COORD = 33873; - - // Field descriptor #71 I - public static final int GL_CURRENT_FOG_COORD = 33875; - - // Field descriptor #71 I - public static final int GL_FOG_COORD_ARRAY_TYPE = 33876; - - // Field descriptor #71 I - public static final int GL_FOG_COORD_ARRAY_STRIDE = 33877; - - // Field descriptor #71 I - public static final int GL_FOG_COORD_ARRAY_POINTER = 33878; - - // Field descriptor #71 I - public static final int GL_FOG_COORD_ARRAY = 33879; - - // Field descriptor #71 I - public static final int GL_FOG_COORD_ARRAY_BUFFER_BINDING = 34973; - - // Field descriptor #71 I - public static final int GL_SRC0_RGB = 34176; - - // Field descriptor #71 I - public static final int GL_SRC1_RGB = 34177; - - // Field descriptor #71 I - public static final int GL_SRC2_RGB = 34178; - - // Field descriptor #71 I - public static final int GL_SRC0_ALPHA = 34184; - - // Field descriptor #71 I - public static final int GL_SRC1_ALPHA = 34185; - - // Field descriptor #71 I - public static final int GL_SRC2_ALPHA = 34186; - - // Field descriptor #71 I - public static final int GL_SAMPLES_PASSED = 35092; - - // Field descriptor #71 I - public static final int GL_QUERY_COUNTER_BITS = 34916; - - // Field descriptor #71 I - public static final int GL_CURRENT_QUERY = 34917; - - // Field descriptor #71 I - public static final int GL_QUERY_RESULT = 34918; - - // Field descriptor #71 I - public static final int GL_QUERY_RESULT_AVAILABLE = 34919; - - // Field descriptor #194 I - public static final int GL_SHADING_LANGUAGE_VERSION = 35724; - - // Field descriptor #194 I - public static final int GL_CURRENT_PROGRAM = 35725; - - // Field descriptor #194 I - public static final int GL_SHADER_TYPE = 35663; - - // Field descriptor #194 I - public static final int GL_DELETE_STATUS = 35712; - - // Field descriptor #194 I - public static final int GL_COMPILE_STATUS = 35713; - - // Field descriptor #194 I - public static final int GL_LINK_STATUS = 35714; - - // Field descriptor #194 I - public static final int GL_VALIDATE_STATUS = 35715; - - // Field descriptor #194 I - public static final int GL_INFO_LOG_LENGTH = 35716; - - // Field descriptor #194 I - public static final int GL_ATTACHED_SHADERS = 35717; - - // Field descriptor #194 I - public static final int GL_ACTIVE_UNIFORMS = 35718; - - // Field descriptor #194 I - public static final int GL_ACTIVE_UNIFORM_MAX_LENGTH = 35719; - - // Field descriptor #194 I - public static final int GL_ACTIVE_ATTRIBUTES = 35721; - - // Field descriptor #194 I - public static final int GL_ACTIVE_ATTRIBUTE_MAX_LENGTH = 35722; - - // Field descriptor #194 I - public static final int GL_SHADER_SOURCE_LENGTH = 35720; - - // Field descriptor #194 I - public static final int GL_SHADER_OBJECT = 35656; - - // Field descriptor #194 I - public static final int GL_FLOAT_VEC2 = 35664; - - // Field descriptor #194 I - public static final int GL_FLOAT_VEC3 = 35665; - - // Field descriptor #194 I - public static final int GL_FLOAT_VEC4 = 35666; - - // Field descriptor #194 I - public static final int GL_INT_VEC2 = 35667; - - // Field descriptor #194 I - public static final int GL_INT_VEC3 = 35668; - - // Field descriptor #194 I - public static final int GL_INT_VEC4 = 35669; - - // Field descriptor #194 I - public static final int GL_BOOL = 35670; - - // Field descriptor #194 I - public static final int GL_BOOL_VEC2 = 35671; - - // Field descriptor #194 I - public static final int GL_BOOL_VEC3 = 35672; - - // Field descriptor #194 I - public static final int GL_BOOL_VEC4 = 35673; - - // Field descriptor #194 I - public static final int GL_FLOAT_MAT2 = 35674; - - // Field descriptor #194 I - public static final int GL_FLOAT_MAT3 = 35675; - - // Field descriptor #194 I - public static final int GL_FLOAT_MAT4 = 35676; - - // Field descriptor #194 I - public static final int GL_SAMPLER_1D = 35677; - - // Field descriptor #194 I - public static final int GL_SAMPLER_2D = 35678; - - // Field descriptor #194 I - public static final int GL_SAMPLER_3D = 35679; - - // Field descriptor #194 I - public static final int GL_SAMPLER_CUBE = 35680; - - // Field descriptor #194 I - public static final int GL_SAMPLER_1D_SHADOW = 35681; - - // Field descriptor #194 I - public static final int GL_SAMPLER_2D_SHADOW = 35682; - - // Field descriptor #194 I - public static final int GL_VERTEX_SHADER = 35633; - - // Field descriptor #194 I - public static final int GL_MAX_VERTEX_UNIFORM_COMPONENTS = 35658; - - // Field descriptor #194 I - public static final int GL_MAX_VARYING_FLOATS = 35659; - - // Field descriptor #194 I - public static final int GL_MAX_VERTEX_ATTRIBS = 34921; - - // Field descriptor #194 I - public static final int GL_MAX_TEXTURE_IMAGE_UNITS = 34930; - - // Field descriptor #194 I - public static final int GL_MAX_VERTEX_TEXTURE_IMAGE_UNITS = 35660; - - // Field descriptor #194 I - public static final int GL_MAX_COMBINED_TEXTURE_IMAGE_UNITS = 35661; - - // Field descriptor #194 I - public static final int GL_MAX_TEXTURE_COORDS = 34929; - - // Field descriptor #194 I - public static final int GL_VERTEX_PROGRAM_POINT_SIZE = 34370; - - // Field descriptor #194 I - public static final int GL_VERTEX_PROGRAM_TWO_SIDE = 34371; - - // Field descriptor #194 I - public static final int GL_VERTEX_ATTRIB_ARRAY_ENABLED = 34338; - - // Field descriptor #194 I - public static final int GL_VERTEX_ATTRIB_ARRAY_SIZE = 34339; - - // Field descriptor #194 I - public static final int GL_VERTEX_ATTRIB_ARRAY_STRIDE = 34340; - - // Field descriptor #194 I - public static final int GL_VERTEX_ATTRIB_ARRAY_TYPE = 34341; - - // Field descriptor #194 I - public static final int GL_VERTEX_ATTRIB_ARRAY_NORMALIZED = 34922; - - // Field descriptor #194 I - public static final int GL_CURRENT_VERTEX_ATTRIB = 34342; - - // Field descriptor #194 I - public static final int GL_VERTEX_ATTRIB_ARRAY_POINTER = 34373; - - // Field descriptor #194 I - public static final int GL_FRAGMENT_SHADER = 35632; - - // Field descriptor #194 I - public static final int GL_MAX_FRAGMENT_UNIFORM_COMPONENTS = 35657; - - // Field descriptor #194 I - public static final int GL_FRAGMENT_SHADER_DERIVATIVE_HINT = 35723; - - // Field descriptor #194 I - public static final int GL_MAX_DRAW_BUFFERS = 34852; - - // Field descriptor #194 I - public static final int GL_DRAW_BUFFER0 = 34853; - - // Field descriptor #194 I - public static final int GL_DRAW_BUFFER1 = 34854; - - // Field descriptor #194 I - public static final int GL_DRAW_BUFFER2 = 34855; - - // Field descriptor #194 I - public static final int GL_DRAW_BUFFER3 = 34856; - - // Field descriptor #194 I - public static final int GL_DRAW_BUFFER4 = 34857; - - // Field descriptor #194 I - public static final int GL_DRAW_BUFFER5 = 34858; - - // Field descriptor #194 I - public static final int GL_DRAW_BUFFER6 = 34859; - - // Field descriptor #194 I - public static final int GL_DRAW_BUFFER7 = 34860; - - // Field descriptor #194 I - public static final int GL_DRAW_BUFFER8 = 34861; - - // Field descriptor #194 I - public static final int GL_DRAW_BUFFER9 = 34862; - - // Field descriptor #194 I - public static final int GL_DRAW_BUFFER10 = 34863; - - // Field descriptor #194 I - public static final int GL_DRAW_BUFFER11 = 34864; - - // Field descriptor #194 I - public static final int GL_DRAW_BUFFER12 = 34865; - - // Field descriptor #194 I - public static final int GL_DRAW_BUFFER13 = 34866; - - // Field descriptor #194 I - public static final int GL_DRAW_BUFFER14 = 34867; - - // Field descriptor #194 I - public static final int GL_DRAW_BUFFER15 = 34868; - - // Field descriptor #194 I - public static final int GL_POINT_SPRITE = 34913; - - // Field descriptor #194 I - public static final int GL_COORD_REPLACE = 34914; - - // Field descriptor #194 I - public static final int GL_POINT_SPRITE_COORD_ORIGIN = 36000; - - // Field descriptor #194 I - public static final int GL_LOWER_LEFT = 36001; - - // Field descriptor #194 I - public static final int GL_UPPER_LEFT = 36002; - - // Field descriptor #194 I - public static final int GL_STENCIL_BACK_FUNC = 34816; - - // Field descriptor #194 I - public static final int GL_STENCIL_BACK_FAIL = 34817; - - // Field descriptor #194 I - public static final int GL_STENCIL_BACK_PASS_DEPTH_FAIL = 34818; - - // Field descriptor #194 I - public static final int GL_STENCIL_BACK_PASS_DEPTH_PASS = 34819; - - // Field descriptor #194 I - public static final int GL_STENCIL_BACK_REF = 36003; - - // Field descriptor #194 I - public static final int GL_STENCIL_BACK_VALUE_MASK = 36004; - - // Field descriptor #194 I - public static final int GL_STENCIL_BACK_WRITEMASK = 36005; - - // Field descriptor #194 I - public static final int GL_BLEND_EQUATION_RGB = 32777; - - // Field descriptor #194 I - public static final int GL_BLEND_EQUATION_ALPHA = 34877; - -} \ No newline at end of file diff --git a/src/net/PeytonPlayz585/profile/Profile.java b/src/net/PeytonPlayz585/profile/Profile.java index 474288f..923eb6c 100644 --- a/src/net/PeytonPlayz585/profile/Profile.java +++ b/src/net/PeytonPlayz585/profile/Profile.java @@ -4,7 +4,8 @@ import java.io.ByteArrayInputStream; import java.io.ByteArrayOutputStream; import java.io.IOException; -import net.lax1dude.eaglercraft.adapter.EaglerAdapterImpl2; +import org.lwjgl.opengl.GL11; + import net.minecraft.client.Minecraft; import net.minecraft.src.CompressedStreamTools; import net.minecraft.src.NBTTagCompound; @@ -26,7 +27,7 @@ public class Profile { } public static void read() { - read(EaglerAdapterImpl2.loadLocalStorage("P")); + read(GL11.EaglerAdapterImpl2.loadLocalStorage("P")); } public static void read(byte[] profileStorage) { @@ -67,7 +68,7 @@ public class Profile { public static void save() { byte[] b = write(); if(b != null) { - EaglerAdapterImpl2.saveLocalStorage("P", b); + GL11.EaglerAdapterImpl2.saveLocalStorage("P", b); } } @@ -75,4 +76,4 @@ public class Profile { read(); } -} +} \ No newline at end of file diff --git a/src/net/PeytonPlayz585/socket/Socket.java b/src/net/PeytonPlayz585/socket/Socket.java index b2727dc..ac0dccb 100644 --- a/src/net/PeytonPlayz585/socket/Socket.java +++ b/src/net/PeytonPlayz585/socket/Socket.java @@ -2,12 +2,12 @@ package net.PeytonPlayz585.socket; import java.io.IOException; -import net.lax1dude.eaglercraft.adapter.EaglerAdapterImpl2; +import org.lwjgl.opengl.GL11; public class Socket { public Socket(String hostName, int port) throws IOException { - if(!EaglerAdapterImpl2.startConnection(hostName + ":" + port)) { + if(!GL11.EaglerAdapterImpl2.startConnection(hostName + ":" + port)) { IOException e = new IOException("Connection failed: " + hostName + ":" + port); e.printStackTrace(); throw e; @@ -15,7 +15,7 @@ public class Socket { } public Socket(String hostName) throws IOException { - if(!EaglerAdapterImpl2.startConnection(hostName)) { + if(!GL11.EaglerAdapterImpl2.startConnection(hostName)) { IOException e = new IOException("Connection failed: " + hostName); e.printStackTrace(); throw e; @@ -24,13 +24,13 @@ public class Socket { public void write(byte[] data) { if(socketOpen()) { - EaglerAdapterImpl2.writePacket(data); + GL11.EaglerAdapterImpl2.writePacket(data); } } public byte[] read() { if(socketOpen()) { - return EaglerAdapterImpl2.readPacket(); + return GL11.EaglerAdapterImpl2.readPacket(); } else { return null; } @@ -38,12 +38,12 @@ public class Socket { public void close() { if(socketOpen()) { - EaglerAdapterImpl2.endConnection(); + GL11.EaglerAdapterImpl2.endConnection(); } } public boolean socketOpen() { - return EaglerAdapterImpl2.connectionOpen(); + return GL11.EaglerAdapterImpl2.connectionOpen(); } -} +} \ No newline at end of file diff --git a/src/net/PeytonPlayz585/storage/LocalStorageManager.java b/src/net/PeytonPlayz585/storage/LocalStorageManager.java deleted file mode 100644 index d9c5b7b..0000000 --- a/src/net/PeytonPlayz585/storage/LocalStorageManager.java +++ /dev/null @@ -1,80 +0,0 @@ -package net.PeytonPlayz585.storage; - -import java.io.ByteArrayInputStream; -import java.io.ByteArrayOutputStream; -import java.io.DataInputStream; -import java.io.DataOutputStream; -import java.io.IOException; - -import net.PeytonPlayz585.opengl.GL11; -import net.PeytonPlayz595.nbt.NBTBase; -import net.PeytonPlayz595.nbt.NBTTagCompound; -import net.lax1dude.eaglercraft.Base64; - -public class LocalStorageManager { - - public static NBTTagCompound gameSettingsStorage = null; - public static NBTTagCompound levelSettingsStorage = null; - - public static void loadStorage() { - byte[] g = GL11.loadLocalStorage("g"); - byte[] p = GL11.loadLocalStorage("p"); - - if(g != null) { - try { - NBTBase t = NBTBase.readTag(new DataInputStream(new ByteArrayInputStream(g))); - if(t != null && t instanceof NBTTagCompound) { - gameSettingsStorage = (NBTTagCompound)t; - } - }catch(IOException e) { - ; - } - } - - if(p != null) { - try { - NBTBase t = NBTBase.readTag(new DataInputStream(new ByteArrayInputStream(p))); - if(t != null && t instanceof NBTTagCompound) { - levelSettingsStorage = (NBTTagCompound)t; - } - }catch(IOException e) { - ; - } - } - - if(gameSettingsStorage == null) gameSettingsStorage = new NBTTagCompound(); - if(levelSettingsStorage == null) levelSettingsStorage = new NBTTagCompound(); - - } - - public static void saveStorageG() { - try { - ByteArrayOutputStream s = new ByteArrayOutputStream(); - NBTBase.writeTag(gameSettingsStorage, new DataOutputStream(s)); - GL11.saveLocalStorage("g", s.toByteArray()); - } catch (IOException e) { - ; - } - } - - public static void saveStorageP() { - try { - ByteArrayOutputStream s = new ByteArrayOutputStream(); - NBTBase.writeTag(levelSettingsStorage, new DataOutputStream(s)); - GL11.saveLocalStorage("p", s.toByteArray()); - } catch (IOException e) { - ; - } - } - - public static String dumpConfiguration() { - try { - ByteArrayOutputStream s = new ByteArrayOutputStream(); - NBTBase.writeTag(gameSettingsStorage, new DataOutputStream(s)); - return Base64.encodeBase64String(s.toByteArray()); - } catch(Throwable e) { - return ""; - } - } - -} \ No newline at end of file diff --git a/src/net/PeytonPlayz585/util/glu/GLU.java b/src/net/PeytonPlayz585/util/glu/GLU.java deleted file mode 100644 index e369197..0000000 --- a/src/net/PeytonPlayz585/util/glu/GLU.java +++ /dev/null @@ -1,7 +0,0 @@ -package net.PeytonPlayz585.util.glu; - -import net.PeytonPlayz585.opengl.GL11; - -public class GLU extends GL11 { - -} diff --git a/src/net/PeytonPlayz595/nbt/NBTBase.java b/src/net/PeytonPlayz595/nbt/NBTBase.java deleted file mode 100644 index a9bb352..0000000 --- a/src/net/PeytonPlayz595/nbt/NBTBase.java +++ /dev/null @@ -1,130 +0,0 @@ -package net.PeytonPlayz595.nbt; - -import java.io.*; - -public abstract class NBTBase { - - public NBTBase() { - key = null; - } - - abstract void writeTagContents(DataOutput dataoutput) throws IOException; - - abstract void readTagContents(DataInput datainput) throws IOException; - - public abstract byte getType(); - - public String getKey() { - if (key == null) { - return ""; - } else { - return key; - } - } - - public NBTBase setKey(String s) { - key = s; - return this; - } - - public static NBTBase readTag(DataInput datainput) throws IOException { - byte byte0 = datainput.readByte(); - if (byte0 == 0) { - return new NBTTagEnd(); - } else { - NBTBase nbtbase = createTagOfType(byte0); - nbtbase.key = datainput.readUTF(); - nbtbase.readTagContents(datainput); - return nbtbase; - } - } - - public static void writeTag(NBTBase nbtbase, DataOutput dataoutput) throws IOException { - dataoutput.writeByte(nbtbase.getType()); - if (nbtbase.getType() == 0) { - return; - } else { - dataoutput.writeUTF(nbtbase.getKey()); - nbtbase.writeTagContents(dataoutput); - return; - } - } - - public static NBTBase createTagOfType(byte byte0) { - switch (byte0) { - case 0: // '\0' - return new NBTTagEnd(); - - case 1: // '\001' - return new NBTTagByte(); - - case 2: // '\002' - return new NBTTagShort(); - - case 3: // '\003' - return new NBTTagInt(); - - case 4: // '\004' - return new NBTTagLong(); - - case 5: // '\005' - return new NBTTagFloat(); - - case 6: // '\006' - return new NBTTagDouble(); - - case 7: // '\007' - return new NBTTagByteArray(); - - case 8: // '\b' - return new NBTTagString(); - - case 9: // '\t' - return new NBTTagList(); - - case 10: // '\n' - return new NBTTagCompound(); - } - return null; - } - - public static String getTagName(byte byte0) { - switch (byte0) { - case 0: // '\0' - return "TAG_End"; - - case 1: // '\001' - return "TAG_Byte"; - - case 2: // '\002' - return "TAG_Short"; - - case 3: // '\003' - return "TAG_Int"; - - case 4: // '\004' - return "TAG_Long"; - - case 5: // '\005' - return "TAG_Float"; - - case 6: // '\006' - return "TAG_Double"; - - case 7: // '\007' - return "TAG_Byte_Array"; - - case 8: // '\b' - return "TAG_String"; - - case 9: // '\t' - return "TAG_List"; - - case 10: // '\n' - return "TAG_Compound"; - } - return "UNKNOWN"; - } - - private String key; -} \ No newline at end of file diff --git a/src/net/PeytonPlayz595/nbt/NBTTagByte.java b/src/net/PeytonPlayz595/nbt/NBTTagByte.java deleted file mode 100644 index 22fcab6..0000000 --- a/src/net/PeytonPlayz595/nbt/NBTTagByte.java +++ /dev/null @@ -1,31 +0,0 @@ -package net.PeytonPlayz595.nbt; - -import java.io.*; - -public class NBTTagByte extends NBTBase { - - public NBTTagByte() { - } - - public NBTTagByte(byte byte0) { - byteValue = byte0; - } - - void writeTagContents(DataOutput dataoutput) throws IOException { - dataoutput.writeByte(byteValue); - } - - void readTagContents(DataInput datainput) throws IOException { - byteValue = datainput.readByte(); - } - - public byte getType() { - return 1; - } - - public String toString() { - return (new StringBuilder()).append("").append(byteValue).toString(); - } - - public byte byteValue; -} \ No newline at end of file diff --git a/src/net/PeytonPlayz595/nbt/NBTTagByteArray.java b/src/net/PeytonPlayz595/nbt/NBTTagByteArray.java deleted file mode 100644 index 0cd9af0..0000000 --- a/src/net/PeytonPlayz595/nbt/NBTTagByteArray.java +++ /dev/null @@ -1,34 +0,0 @@ -package net.PeytonPlayz595.nbt; - -import java.io.*; - -public class NBTTagByteArray extends NBTBase { - - public NBTTagByteArray() { - } - - public NBTTagByteArray(byte abyte0[]) { - byteArray = abyte0; - } - - void writeTagContents(DataOutput dataoutput) throws IOException { - dataoutput.writeInt(byteArray.length); - dataoutput.write(byteArray); - } - - void readTagContents(DataInput datainput) throws IOException { - int i = datainput.readInt(); - byteArray = new byte[i]; - datainput.readFully(byteArray); - } - - public byte getType() { - return 7; - } - - public String toString() { - return (new StringBuilder()).append("[").append(byteArray.length).append(" bytes]").toString(); - } - - public byte byteArray[]; -} \ No newline at end of file diff --git a/src/net/PeytonPlayz595/nbt/NBTTagCompound.java b/src/net/PeytonPlayz595/nbt/NBTTagCompound.java deleted file mode 100644 index 8f71b26..0000000 --- a/src/net/PeytonPlayz595/nbt/NBTTagCompound.java +++ /dev/null @@ -1,194 +0,0 @@ -package net.PeytonPlayz595.nbt; - -import java.io.*; -import java.util.*; - -public class NBTTagCompound extends NBTBase { - - public NBTTagCompound() { - tagMap = new HashMap(); - } - - void writeTagContents(DataOutput dataoutput) throws IOException { - NBTBase nbtbase; - for (Iterator iterator = tagMap.values().iterator(); iterator.hasNext(); NBTBase.writeTag(nbtbase, - dataoutput)) { - nbtbase = (NBTBase) iterator.next(); - } - - dataoutput.writeByte(0); - } - - void readTagContents(DataInput datainput) throws IOException { - tagMap.clear(); - NBTBase nbtbase; - for (; (nbtbase = NBTBase.readTag(datainput)).getType() != 0; tagMap.put(nbtbase.getKey(), nbtbase)) { - } - } - - public byte getType() { - return 10; - } - - public void setTag(String s, NBTBase nbtbase) { - tagMap.put(s, nbtbase.setKey(s)); - } - - public void setByte(String s, byte byte0) { - tagMap.put(s, (new NBTTagByte(byte0)).setKey(s)); - } - - public void setShort(String s, short word0) { - tagMap.put(s, (new NBTTagShort(word0)).setKey(s)); - } - - public void setInteger(String s, int i) { - tagMap.put(s, (new NBTTagInt(i)).setKey(s)); - } - - public void setLong(String s, long l) { - tagMap.put(s, (new NBTTagLong(l)).setKey(s)); - } - - public void setFloat(String s, float f) { - tagMap.put(s, (new NBTTagFloat(f)).setKey(s)); - } - - public void setDouble(String s, double d) { - tagMap.put(s, (new NBTTagDouble(d)).setKey(s)); - } - - public void setString(String s, String s1) { - tagMap.put(s, (new NBTTagString(s1)).setKey(s)); - } - - public void setByteArray(String s, byte abyte0[]) { - tagMap.put(s, (new NBTTagByteArray(abyte0)).setKey(s)); - } - - public void setObject(String s, Object obj) { - tagMap.put(s, obj); - } - - public void setCompoundTag(String s, NBTTagCompound nbttagcompound) { - tagMap.put(s, nbttagcompound.setKey(s)); - } - - public void setBoolean(String s, boolean flag) { - setByte(s, ((byte) (flag ? 1 : 0))); - } - - public boolean hasKey(String s) { - return tagMap.containsKey(s); - } - - public byte getByte(String s) { - if (!tagMap.containsKey(s)) { - return 0; - } else { - return ((NBTTagByte) tagMap.get(s)).byteValue; - } - } - - public short getShort(String s) { - if (!tagMap.containsKey(s)) { - return 0; - } else { - return ((NBTTagShort) tagMap.get(s)).shortValue; - } - } - - public int getInteger(String s) { - if (!tagMap.containsKey(s)) { - return 0; - } else { - return ((NBTTagInt) tagMap.get(s)).intValue; - } - } - - public long getLong(String s) { - if (!tagMap.containsKey(s)) { - return 0L; - } else { - return ((NBTTagLong) tagMap.get(s)).longValue; - } - } - - public float getFloat(String s) { - if (!tagMap.containsKey(s)) { - return 0.0F; - } else { - return ((NBTTagFloat) tagMap.get(s)).floatValue; - } - } - - public double getDouble(String s) { - if (!tagMap.containsKey(s)) { - return 0.0D; - } else { - return ((NBTTagDouble) tagMap.get(s)).doubleValue; - } - } - - public String getString(String s) { - if (!tagMap.containsKey(s)) { - return ""; - } else { - return ((NBTTagString) tagMap.get(s)).stringValue; - } - } - - public byte[] getByteArray(String s) { - if (!tagMap.containsKey(s)) { - return new byte[0]; - } else { - return ((NBTTagByteArray) tagMap.get(s)).byteArray; - } - } - - public NBTTagCompound getCompoundTag(String s) { - if (!tagMap.containsKey(s)) { - return new NBTTagCompound(); - } else { - return (NBTTagCompound) tagMap.get(s); - } - } - - public NBTTagList getTagList(String s) { - if (!tagMap.containsKey(s)) { - return new NBTTagList(); - } else { - return (NBTTagList) tagMap.get(s); - } - } - - public boolean getBoolean(String s) { - return getByte(s) != 0; - } - - public Object getObject(String s) { - if(!tagMap.containsKey(s)) { - return null; - } else { - return tagMap.get(s); - } - } - - public String toString() { - return (new StringBuilder()).append("").append(tagMap.size()).append(" entries").toString(); - } - - public boolean hasNoTags() { - return tagMap.size() == 0; - } - - public Map tagMap; - - public NBTBase getTag(String s) { - return (NBTBase) tagMap.get(s); - } - - public static Map getTagMap(NBTTagCompound nb) { - return nb.tagMap; - } -} \ No newline at end of file diff --git a/src/net/PeytonPlayz595/nbt/NBTTagDouble.java b/src/net/PeytonPlayz595/nbt/NBTTagDouble.java deleted file mode 100644 index 3c07cc9..0000000 --- a/src/net/PeytonPlayz595/nbt/NBTTagDouble.java +++ /dev/null @@ -1,31 +0,0 @@ -package net.PeytonPlayz595.nbt; - -import java.io.*; - -public class NBTTagDouble extends NBTBase { - - public NBTTagDouble() { - } - - public NBTTagDouble(double d) { - doubleValue = d; - } - - void writeTagContents(DataOutput dataoutput) throws IOException { - dataoutput.writeDouble(doubleValue); - } - - void readTagContents(DataInput datainput) throws IOException { - doubleValue = datainput.readDouble(); - } - - public byte getType() { - return 6; - } - - public String toString() { - return (new StringBuilder()).append("").append(doubleValue).toString(); - } - - public double doubleValue; -} \ No newline at end of file diff --git a/src/net/PeytonPlayz595/nbt/NBTTagEnd.java b/src/net/PeytonPlayz595/nbt/NBTTagEnd.java deleted file mode 100644 index 8310773..0000000 --- a/src/net/PeytonPlayz595/nbt/NBTTagEnd.java +++ /dev/null @@ -1,23 +0,0 @@ -package net.PeytonPlayz595.nbt; - -import java.io.*; - -public class NBTTagEnd extends NBTBase { - - public NBTTagEnd() { - } - - void readTagContents(DataInput datainput) throws IOException { - } - - void writeTagContents(DataOutput dataoutput) throws IOException { - } - - public byte getType() { - return 0; - } - - public String toString() { - return "END"; - } -} \ No newline at end of file diff --git a/src/net/PeytonPlayz595/nbt/NBTTagFloat.java b/src/net/PeytonPlayz595/nbt/NBTTagFloat.java deleted file mode 100644 index c547134..0000000 --- a/src/net/PeytonPlayz595/nbt/NBTTagFloat.java +++ /dev/null @@ -1,31 +0,0 @@ -package net.PeytonPlayz595.nbt; - -import java.io.*; - -public class NBTTagFloat extends NBTBase { - - public NBTTagFloat() { - } - - public NBTTagFloat(float f) { - floatValue = f; - } - - void writeTagContents(DataOutput dataoutput) throws IOException { - dataoutput.writeFloat(floatValue); - } - - void readTagContents(DataInput datainput) throws IOException { - floatValue = datainput.readFloat(); - } - - public byte getType() { - return 5; - } - - public String toString() { - return (new StringBuilder()).append("").append(floatValue).toString(); - } - - public float floatValue; -} \ No newline at end of file diff --git a/src/net/PeytonPlayz595/nbt/NBTTagInt.java b/src/net/PeytonPlayz595/nbt/NBTTagInt.java deleted file mode 100644 index 2f5996c..0000000 --- a/src/net/PeytonPlayz595/nbt/NBTTagInt.java +++ /dev/null @@ -1,31 +0,0 @@ -package net.PeytonPlayz595.nbt; - -import java.io.*; - -public class NBTTagInt extends NBTBase { - - public NBTTagInt() { - } - - public NBTTagInt(int i) { - intValue = i; - } - - void writeTagContents(DataOutput dataoutput) throws IOException { - dataoutput.writeInt(intValue); - } - - void readTagContents(DataInput datainput) throws IOException { - intValue = datainput.readInt(); - } - - public byte getType() { - return 3; - } - - public String toString() { - return (new StringBuilder()).append("").append(intValue).toString(); - } - - public int intValue; -} \ No newline at end of file diff --git a/src/net/PeytonPlayz595/nbt/NBTTagList.java b/src/net/PeytonPlayz595/nbt/NBTTagList.java deleted file mode 100644 index d1fac48..0000000 --- a/src/net/PeytonPlayz595/nbt/NBTTagList.java +++ /dev/null @@ -1,63 +0,0 @@ -package net.PeytonPlayz595.nbt; - -import java.io.*; -import java.util.ArrayList; -import java.util.List; - -public class NBTTagList extends NBTBase { - - public NBTTagList() { - tagList = new ArrayList(); - } - - void writeTagContents(DataOutput dataoutput) throws IOException { - if (tagList.size() > 0) { - tagType = ((NBTBase) tagList.get(0)).getType(); - } else { - tagType = 1; - } - dataoutput.writeByte(tagType); - dataoutput.writeInt(tagList.size()); - for (int i = 0; i < tagList.size(); i++) { - ((NBTBase) tagList.get(i)).writeTagContents(dataoutput); - } - - } - - void readTagContents(DataInput datainput) throws IOException { - tagType = datainput.readByte(); - int i = datainput.readInt(); - tagList = new ArrayList(); - for (int j = 0; j < i; j++) { - NBTBase nbtbase = NBTBase.createTagOfType(tagType); - nbtbase.readTagContents(datainput); - tagList.add(nbtbase); - } - - } - - public byte getType() { - return 9; - } - - public String toString() { - return (new StringBuilder()).append("").append(tagList.size()).append(" entries of type ") - .append(NBTBase.getTagName(tagType)).toString(); - } - - public void setTag(NBTBase nbtbase) { - tagType = nbtbase.getType(); - tagList.add(nbtbase); - } - - public NBTBase tagAt(int i) { - return (NBTBase) tagList.get(i); - } - - public int tagCount() { - return tagList.size(); - } - - private List tagList; - private byte tagType; -} \ No newline at end of file diff --git a/src/net/PeytonPlayz595/nbt/NBTTagLong.java b/src/net/PeytonPlayz595/nbt/NBTTagLong.java deleted file mode 100644 index 252515a..0000000 --- a/src/net/PeytonPlayz595/nbt/NBTTagLong.java +++ /dev/null @@ -1,31 +0,0 @@ -package net.PeytonPlayz595.nbt; - -import java.io.*; - -public class NBTTagLong extends NBTBase { - - public NBTTagLong() { - } - - public NBTTagLong(long l) { - longValue = l; - } - - void writeTagContents(DataOutput dataoutput) throws IOException { - dataoutput.writeLong(longValue); - } - - void readTagContents(DataInput datainput) throws IOException { - longValue = datainput.readLong(); - } - - public byte getType() { - return 4; - } - - public String toString() { - return (new StringBuilder()).append("").append(longValue).toString(); - } - - public long longValue; -} \ No newline at end of file diff --git a/src/net/PeytonPlayz595/nbt/NBTTagShort.java b/src/net/PeytonPlayz595/nbt/NBTTagShort.java deleted file mode 100644 index 481557d..0000000 --- a/src/net/PeytonPlayz595/nbt/NBTTagShort.java +++ /dev/null @@ -1,31 +0,0 @@ -package net.PeytonPlayz595.nbt; - -import java.io.*; - -public class NBTTagShort extends NBTBase { - - public NBTTagShort() { - } - - public NBTTagShort(short word0) { - shortValue = word0; - } - - void writeTagContents(DataOutput dataoutput) throws IOException { - dataoutput.writeShort(shortValue); - } - - void readTagContents(DataInput datainput) throws IOException { - shortValue = datainput.readShort(); - } - - public byte getType() { - return 2; - } - - public String toString() { - return (new StringBuilder()).append("").append(shortValue).toString(); - } - - public short shortValue; -} \ No newline at end of file diff --git a/src/net/PeytonPlayz595/nbt/NBTTagString.java b/src/net/PeytonPlayz595/nbt/NBTTagString.java deleted file mode 100644 index 307bf26..0000000 --- a/src/net/PeytonPlayz595/nbt/NBTTagString.java +++ /dev/null @@ -1,36 +0,0 @@ -package net.PeytonPlayz595.nbt; - -import java.io.*; - -public class NBTTagString extends NBTBase { - - public NBTTagString() { - } - - public NBTTagString(String s) { - stringValue = s; - if (s == null) { - throw new IllegalArgumentException("Empty string not allowed"); - } else { - return; - } - } - - void writeTagContents(DataOutput dataoutput) throws IOException { - dataoutput.writeUTF(stringValue); - } - - void readTagContents(DataInput datainput) throws IOException { - stringValue = datainput.readUTF(); - } - - public byte getType() { - return 8; - } - - public String toString() { - return (new StringBuilder()).append("").append(stringValue).toString(); - } - - public String stringValue; -} \ No newline at end of file diff --git a/src/net/lax1dude/eaglercraft/AssetRepository.java b/src/net/lax1dude/eaglercraft/AssetRepository.java deleted file mode 100644 index f952b08..0000000 --- a/src/net/lax1dude/eaglercraft/AssetRepository.java +++ /dev/null @@ -1,55 +0,0 @@ -package net.lax1dude.eaglercraft; - -import java.io.ByteArrayInputStream; -import java.io.DataInputStream; -import java.io.IOException; -import java.nio.charset.Charset; -import java.util.Arrays; -import java.util.HashMap; - -import com.jcraft.jzlib.InflaterInputStream; - -public class AssetRepository { - - private static final HashMap filePool = new HashMap(); - - public static final void install(byte[] pkg) throws IOException { - ByteArrayInputStream in2 = new ByteArrayInputStream(pkg); - DataInputStream in = new DataInputStream(in2); - byte[] header = new byte[8]; - in.read(header); - if (!"EAGPKG!!".equals(new String(header, Charset.forName("UTF-8")))) - throw new IOException("invalid epk file"); - in.readUTF(); - in = new DataInputStream(new InflaterInputStream(in2)); - String s = null; - SHA1Digest dg = new SHA1Digest(); - while ("".equals(s = in.readUTF())) { - String path = in.readUTF(); - byte[] digest = new byte[20]; - byte[] digest2 = new byte[20]; - in.read(digest); - int len = in.readInt(); - byte[] file = new byte[len]; - in.read(file); - if (filePool.containsKey(path)) - continue; - dg.update(file, 0, len); - dg.doFinal(digest2, 0); - if (!Arrays.equals(digest, digest2)) - throw new IOException("invalid file hash for " + path); - filePool.put(path, file); - if (!"".equals(in.readUTF())) - throw new IOException("invalid epk file"); - } - if (in.available() > 0 || !" end".equals(s)) - throw new IOException("invalid epk file"); - } - - public static final byte[] getResource(String path) { - if (path.startsWith("/")) - path = path.substring(1); - return filePool.get(path); - } - -} \ No newline at end of file diff --git a/src/net/lax1dude/eaglercraft/Base64.java b/src/net/lax1dude/eaglercraft/Base64.java deleted file mode 100644 index c8b3f69..0000000 --- a/src/net/lax1dude/eaglercraft/Base64.java +++ /dev/null @@ -1,857 +0,0 @@ -/* - * Licensed to the Apache Software Foundation (ASF) under one or more - * contributor license agreements. See the NOTICE file distributed with - * this work for additional information regarding copyright ownership. - * The ASF licenses this file to You under the Apache License, Version 2.0 - * (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package net.lax1dude.eaglercraft; - -import java.math.BigInteger; -import java.nio.charset.Charset; - -/** - * Provides Base64 encoding and decoding as defined by - * RFC 2045. - * - *

- * This class implements section 6.8. Base64 - * Content-Transfer-Encoding from RFC 2045 Multipurpose Internet - * Mail Extensions (MIME) Part One: Format of Internet Message Bodies by - * Freed and Borenstein. - *

- *

- * The class can be parameterized in the following manner with various - * constructors: - *

- *
    - *
  • URL-safe mode: Default off.
  • - *
  • Line length: Default 76. Line length that aren't multiples of 4 will - * still essentially end up being multiples of 4 in the encoded data. - *
  • Line separator: Default is CRLF ("\r\n")
  • - *
- *

- * The URL-safe parameter is only applied to encode operations. Decoding - * seamlessly handles both modes. - *

- *

- * Since this class operates directly on byte streams, and not character - * streams, it is hard-coded to only encode/decode character encodings which are - * compatible with the lower 127 ASCII chart (ISO-8859-1, Windows-1252, UTF-8, - * etc). - *

- *

- * This class is thread-safe. - *

- * - * @see RFC 2045 - * @since 1.0 - */ -public class Base64 extends BaseNCodec { - - /** - * BASE32 characters are 6 bits in length. They are formed by taking a block of - * 3 octets to form a 24-bit string, which is converted into 4 BASE64 - * characters. - */ - private static final int BITS_PER_ENCODED_BYTE = 6; - private static final int BYTES_PER_UNENCODED_BLOCK = 3; - private static final int BYTES_PER_ENCODED_BLOCK = 4; - - /** - * This array is a lookup table that translates 6-bit positive integer index - * values into their "Base64 Alphabet" equivalents as specified in Table 1 of - * RFC 2045. - * - * Thanks to "commons" project in ws.apache.org for this code. - * http://svn.apache.org/repos/asf/webservices/commons/trunk/modules/util/ - */ - private static final byte[] STANDARD_ENCODE_TABLE = { 'A', 'B', 'C', 'D', 'E', 'F', 'G', 'H', 'I', 'J', 'K', 'L', - 'M', 'N', 'O', 'P', 'Q', 'R', 'S', 'T', 'U', 'V', 'W', 'X', 'Y', 'Z', 'a', 'b', 'c', 'd', 'e', 'f', 'g', - 'h', 'i', 'j', 'k', 'l', 'm', 'n', 'o', 'p', 'q', 'r', 's', 't', 'u', 'v', 'w', 'x', 'y', 'z', '0', '1', - '2', '3', '4', '5', '6', '7', '8', '9', '+', '/' }; - - /** - * This is a copy of the STANDARD_ENCODE_TABLE above, but with + and / changed - * to - and _ to make the encoded Base64 results more URL-SAFE. This table is - * only used when the Base64's mode is set to URL-SAFE. - */ - private static final byte[] URL_SAFE_ENCODE_TABLE = { 'A', 'B', 'C', 'D', 'E', 'F', 'G', 'H', 'I', 'J', 'K', 'L', - 'M', 'N', 'O', 'P', 'Q', 'R', 'S', 'T', 'U', 'V', 'W', 'X', 'Y', 'Z', 'a', 'b', 'c', 'd', 'e', 'f', 'g', - 'h', 'i', 'j', 'k', 'l', 'm', 'n', 'o', 'p', 'q', 'r', 's', 't', 'u', 'v', 'w', 'x', 'y', 'z', '0', '1', - '2', '3', '4', '5', '6', '7', '8', '9', '-', '_' }; - - /** - * This array is a lookup table that translates Unicode characters drawn from - * the "Base64 Alphabet" (as specified in Table 1 of RFC 2045) into their 6-bit - * positive integer equivalents. Characters that are not in the Base64 alphabet - * but fall within the bounds of the array are translated to -1. - * - * Note: '+' and '-' both decode to 62. '/' and '_' both decode to 63. This - * means decoder seamlessly handles both URL_SAFE and STANDARD base64. (The - * encoder, on the other hand, needs to know ahead of time what to emit). - * - * Thanks to "commons" project in ws.apache.org for this code. - * http://svn.apache.org/repos/asf/webservices/commons/trunk/modules/util/ - */ - private static final byte[] DECODE_TABLE = { - // 0 1 2 3 4 5 6 7 8 9 A B C D E F - -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, // 00-0f - -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, // 10-1f - -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 62, -1, 62, -1, 63, // 20-2f + - / - 52, 53, 54, 55, 56, 57, 58, 59, 60, 61, -1, -1, -1, -1, -1, -1, // 30-3f 0-9 - -1, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, // 40-4f A-O - 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, -1, -1, -1, -1, 63, // 50-5f P-Z _ - -1, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, // 60-6f a-o - 41, 42, 43, 44, 45, 46, 47, 48, 49, 50, 51 // 70-7a p-z - }; - - /** - * Base64 uses 6-bit fields. - */ - /** Mask used to extract 6 bits, used when encoding */ - private static final int MASK_6BITS = 0x3f; - /** Mask used to extract 4 bits, used when decoding final trailing character. */ - private static final int MASK_4BITS = 0xf; - /** Mask used to extract 2 bits, used when decoding final trailing character. */ - private static final int MASK_2BITS = 0x3; - - // The static final fields above are used for the original static byte[] methods - // on Base64. - // The private member fields below are used with the new streaming approach, - // which requires - // some state be preserved between calls of encode() and decode(). - - /** - * Decodes Base64 data into octets. - *

- * Note: this method seamlessly handles data encoded in URL-safe or - * normal mode. - *

- * - * @param base64Data Byte array containing Base64 data - * @return Array containing decoded data. - */ - public static byte[] decodeBase64(final byte[] base64Data) { - return new Base64().decode(base64Data); - } - - /** - * Decodes a Base64 String into octets. - *

- * Note: this method seamlessly handles data encoded in URL-safe or - * normal mode. - *

- * - * @param base64String String containing Base64 data - * @return Array containing decoded data. - * @since 1.4 - */ - public static byte[] decodeBase64(final String base64String) { - return new Base64().decode(base64String); - } - - // Implementation of integer encoding used for crypto - /** - * Decodes a byte64-encoded integer according to crypto standards such as W3C's - * XML-Signature. - * - * @param pArray a byte array containing base64 character data - * @return A BigInteger - * @since 1.4 - */ - public static BigInteger decodeInteger(final byte[] pArray) { - return new BigInteger(1, decodeBase64(pArray)); - } - - /** - * Encodes binary data using the base64 algorithm but does not chunk the output. - * - * @param binaryData binary data to encode - * @return byte[] containing Base64 characters in their UTF-8 representation. - */ - public static byte[] encodeBase64(final byte[] binaryData) { - return encodeBase64(binaryData, false); - } - - /** - * Encodes binary data using the base64 algorithm, optionally chunking the - * output into 76 character blocks. - * - * @param binaryData Array containing binary data to encode. - * @param isChunked if {@code true} this encoder will chunk the base64 output - * into 76 character blocks - * @return Base64-encoded data. - * @throws IllegalArgumentException Thrown when the input array needs an output - * array bigger than {@link Integer#MAX_VALUE} - */ - public static byte[] encodeBase64(final byte[] binaryData, final boolean isChunked) { - return encodeBase64(binaryData, isChunked, false); - } - - /** - * Encodes binary data using the base64 algorithm, optionally chunking the - * output into 76 character blocks. - * - * @param binaryData Array containing binary data to encode. - * @param isChunked if {@code true} this encoder will chunk the base64 output - * into 76 character blocks - * @param urlSafe if {@code true} this encoder will emit - and _ instead of - * the usual + and / characters. Note: no padding is added - * when encoding using the URL-safe alphabet. - * @return Base64-encoded data. - * @throws IllegalArgumentException Thrown when the input array needs an output - * array bigger than {@link Integer#MAX_VALUE} - * @since 1.4 - */ - public static byte[] encodeBase64(final byte[] binaryData, final boolean isChunked, final boolean urlSafe) { - return encodeBase64(binaryData, isChunked, urlSafe, Integer.MAX_VALUE); - } - - /** - * Encodes binary data using the base64 algorithm, optionally chunking the - * output into 76 character blocks. - * - * @param binaryData Array containing binary data to encode. - * @param isChunked if {@code true} this encoder will chunk the base64 - * output into 76 character blocks - * @param urlSafe if {@code true} this encoder will emit - and _ instead - * of the usual + and / characters. Note: no padding is - * added when encoding using the URL-safe alphabet. - * @param maxResultSize The maximum result size to accept. - * @return Base64-encoded data. - * @throws IllegalArgumentException Thrown when the input array needs an output - * array bigger than maxResultSize - * @since 1.4 - */ - public static byte[] encodeBase64(final byte[] binaryData, final boolean isChunked, final boolean urlSafe, - final int maxResultSize) { - if (binaryData == null || binaryData.length == 0) { - return binaryData; - } - - // Create this so can use the super-class method - // Also ensures that the same roundings are performed by the ctor and the code - final Base64 b64 = isChunked ? new Base64(urlSafe) : new Base64(0, CHUNK_SEPARATOR, urlSafe); - final long len = b64.getEncodedLength(binaryData); - if (len > maxResultSize) { - throw new IllegalArgumentException("Input array too big, the output array would be bigger (" + len - + ") than the specified maximum size of " + maxResultSize); - } - - return b64.encode(binaryData); - } - - /** - * Encodes binary data using the base64 algorithm and chunks the encoded output - * into 76 character blocks - * - * @param binaryData binary data to encode - * @return Base64 characters chunked in 76 character blocks - */ - public static byte[] encodeBase64Chunked(final byte[] binaryData) { - return encodeBase64(binaryData, true); - } - - /** - * Encodes binary data using the base64 algorithm but does not chunk the output. - * - * NOTE: We changed the behavior of this method from multi-line chunking - * (commons-codec-1.4) to single-line non-chunking (commons-codec-1.5). - * - * @param binaryData binary data to encode - * @return String containing Base64 characters. - * @since 1.4 (NOTE: 1.4 chunked the output, whereas 1.5 does not). - */ - public static String encodeBase64String(final byte[] binaryData) { - return new String(encodeBase64(binaryData, false), Charset.forName("UTF-8")); - } - - /** - * Encodes binary data using a URL-safe variation of the base64 algorithm but - * does not chunk the output. The url-safe variation emits - and _ instead of + - * and / characters. Note: no padding is added. - * - * @param binaryData binary data to encode - * @return byte[] containing Base64 characters in their UTF-8 representation. - * @since 1.4 - */ - public static byte[] encodeBase64URLSafe(final byte[] binaryData) { - return encodeBase64(binaryData, false, true); - } - - /** - * Encodes binary data using a URL-safe variation of the base64 algorithm but - * does not chunk the output. The url-safe variation emits - and _ instead of + - * and / characters. Note: no padding is added. - * - * @param binaryData binary data to encode - * @return String containing Base64 characters - * @since 1.4 - */ - public static String encodeBase64URLSafeString(final byte[] binaryData) { - return new String(encodeBase64(binaryData, false, true), Charset.forName("UTF-8")); - } - - /** - * Encodes to a byte64-encoded integer according to crypto standards such as - * W3C's XML-Signature. - * - * @param bigInteger a BigInteger - * @return A byte array containing base64 character data - * @throws NullPointerException if null is passed in - * @since 1.4 - */ - public static byte[] encodeInteger(final BigInteger bigInteger) { - return encodeBase64(toIntegerBytes(bigInteger), false); - } - - /** - * Tests a given byte array to see if it contains only valid characters within - * the Base64 alphabet. Currently the method treats whitespace as valid. - * - * @param arrayOctet byte array to test - * @return {@code true} if all bytes are valid characters in the Base64 alphabet - * or if the byte array is empty; {@code false}, otherwise - * @deprecated 1.5 Use {@link #isBase64(byte[])}, will be removed in 2.0. - */ - @Deprecated - public static boolean isArrayByteBase64(final byte[] arrayOctet) { - return isBase64(arrayOctet); - } - - /** - * Returns whether or not the {@code octet} is in the base 64 alphabet. - * - * @param octet The value to test - * @return {@code true} if the value is defined in the the base 64 alphabet, - * {@code false} otherwise. - * @since 1.4 - */ - public static boolean isBase64(final byte octet) { - return octet == PAD_DEFAULT || (octet >= 0 && octet < DECODE_TABLE.length && DECODE_TABLE[octet] != -1); - } - - /** - * Tests a given byte array to see if it contains only valid characters within - * the Base64 alphabet. Currently the method treats whitespace as valid. - * - * @param arrayOctet byte array to test - * @return {@code true} if all bytes are valid characters in the Base64 alphabet - * or if the byte array is empty; {@code false}, otherwise - * @since 1.5 - */ - public static boolean isBase64(final byte[] arrayOctet) { - for (int i = 0; i < arrayOctet.length; i++) { - if (!isBase64(arrayOctet[i]) && !isWhiteSpace(arrayOctet[i])) { - return false; - } - } - return true; - } - - /** - * Tests a given String to see if it contains only valid characters within the - * Base64 alphabet. Currently the method treats whitespace as valid. - * - * @param base64 String to test - * @return {@code true} if all characters in the String are valid characters in - * the Base64 alphabet or if the String is empty; {@code false}, - * otherwise - * @since 1.5 - */ - public static boolean isBase64(final String base64) { - return isBase64(base64.getBytes(Charset.forName("UTF-8"))); - } - - /** - * Returns a byte-array representation of a {@code BigInteger} without sign bit. - * - * @param bigInt {@code BigInteger} to be converted - * @return a byte array representation of the BigInteger parameter - */ - static byte[] toIntegerBytes(final BigInteger bigInt) { - int bitlen = bigInt.bitLength(); - // round bitlen - bitlen = ((bitlen + 7) >> 3) << 3; - final byte[] bigBytes = bigInt.toByteArray(); - - if (((bigInt.bitLength() % 8) != 0) && (((bigInt.bitLength() / 8) + 1) == (bitlen / 8))) { - return bigBytes; - } - // set up params for copying everything but sign bit - int startSrc = 0; - int len = bigBytes.length; - - // if bigInt is exactly byte-aligned, just skip signbit in copy - if ((bigInt.bitLength() % 8) == 0) { - startSrc = 1; - len--; - } - final int startDst = bitlen / 8 - len; // to pad w/ nulls as per spec - final byte[] resizedBytes = new byte[bitlen / 8]; - System.arraycopy(bigBytes, startSrc, resizedBytes, startDst, len); - return resizedBytes; - } - - /** - * Encode table to use: either STANDARD or URL_SAFE. Note: the DECODE_TABLE - * above remains static because it is able to decode both STANDARD and URL_SAFE - * streams, but the encodeTable must be a member variable so we can switch - * between the two modes. - */ - private final byte[] encodeTable; - - // Only one decode table currently; keep for consistency with Base32 code - private final byte[] decodeTable = DECODE_TABLE; - - /** - * Line separator for encoding. Not used when decoding. Only used if lineLength - * > 0. - */ - private final byte[] lineSeparator; - - /** - * Convenience variable to help us determine when our buffer is going to run out - * of room and needs resizing. {@code decodeSize = 3 + lineSeparator.length;} - */ - private final int decodeSize; - - /** - * Convenience variable to help us determine when our buffer is going to run out - * of room and needs resizing. {@code encodeSize = 4 + lineSeparator.length;} - */ - private final int encodeSize; - - /** - * Creates a Base64 codec used for decoding (all modes) and encoding in - * URL-unsafe mode. - *

- * When encoding the line length is 0 (no chunking), and the encoding table is - * STANDARD_ENCODE_TABLE. - *

- * - *

- * When decoding all variants are supported. - *

- */ - public Base64() { - this(0); - } - - /** - * Creates a Base64 codec used for decoding (all modes) and encoding in the - * given URL-safe mode. - *

- * When encoding the line length is 76, the line separator is CRLF, and the - * encoding table is STANDARD_ENCODE_TABLE. - *

- * - *

- * When decoding all variants are supported. - *

- * - * @param urlSafe if {@code true}, URL-safe encoding is used. In most cases this - * should be set to {@code false}. - * @since 1.4 - */ - public Base64(final boolean urlSafe) { - this(MIME_CHUNK_SIZE, CHUNK_SEPARATOR, urlSafe); - } - - /** - * Creates a Base64 codec used for decoding (all modes) and encoding in - * URL-unsafe mode. - *

- * When encoding the line length is given in the constructor, the line separator - * is CRLF, and the encoding table is STANDARD_ENCODE_TABLE. - *

- *

- * Line lengths that aren't multiples of 4 will still essentially end up being - * multiples of 4 in the encoded data. - *

- *

- * When decoding all variants are supported. - *

- * - * @param lineLength Each line of encoded data will be at most of the given - * length (rounded down to nearest multiple of 4). If - * lineLength <= 0, then the output will not be divided - * into lines (chunks). Ignored when decoding. - * @since 1.4 - */ - public Base64(final int lineLength) { - this(lineLength, CHUNK_SEPARATOR); - } - - /** - * Creates a Base64 codec used for decoding (all modes) and encoding in - * URL-unsafe mode. - *

- * When encoding the line length and line separator are given in the - * constructor, and the encoding table is STANDARD_ENCODE_TABLE. - *

- *

- * Line lengths that aren't multiples of 4 will still essentially end up being - * multiples of 4 in the encoded data. - *

- *

- * When decoding all variants are supported. - *

- * - * @param lineLength Each line of encoded data will be at most of the given - * length (rounded down to nearest multiple of 4). If - * lineLength <= 0, then the output will not be divided - * into lines (chunks). Ignored when decoding. - * @param lineSeparator Each line of encoded data will end with this sequence of - * bytes. - * @throws IllegalArgumentException Thrown when the provided lineSeparator - * included some base64 characters. - * @since 1.4 - */ - public Base64(final int lineLength, final byte[] lineSeparator) { - this(lineLength, lineSeparator, false); - } - - /** - * Creates a Base64 codec used for decoding (all modes) and encoding in - * URL-unsafe mode. - *

- * When encoding the line length and line separator are given in the - * constructor, and the encoding table is STANDARD_ENCODE_TABLE. - *

- *

- * Line lengths that aren't multiples of 4 will still essentially end up being - * multiples of 4 in the encoded data. - *

- *

- * When decoding all variants are supported. - *

- * - * @param lineLength Each line of encoded data will be at most of the given - * length (rounded down to nearest multiple of 4). If - * lineLength <= 0, then the output will not be divided - * into lines (chunks). Ignored when decoding. - * @param lineSeparator Each line of encoded data will end with this sequence of - * bytes. - * @param urlSafe Instead of emitting '+' and '/' we emit '-' and '_' - * respectively. urlSafe is only applied to encode - * operations. Decoding seamlessly handles both modes. - * Note: no padding is added when using the URL-safe - * alphabet. - * @throws IllegalArgumentException Thrown when the {@code lineSeparator} - * contains Base64 characters. - * @since 1.4 - */ - public Base64(final int lineLength, final byte[] lineSeparator, final boolean urlSafe) { - this(lineLength, lineSeparator, urlSafe, CodecPolicy.LENIANT); - } - - /** - * Creates a Base64 codec used for decoding (all modes) and encoding in - * URL-unsafe mode. - *

- * When encoding the line length and line separator are given in the - * constructor, and the encoding table is STANDARD_ENCODE_TABLE. - *

- *

- * Line lengths that aren't multiples of 4 will still essentially end up being - * multiples of 4 in the encoded data. - *

- *

- * When decoding all variants are supported. - *

- * - * @param lineLength Each line of encoded data will be at most of the given - * length (rounded down to nearest multiple of 4). If - * lineLength <= 0, then the output will not be divided - * into lines (chunks). Ignored when decoding. - * @param lineSeparator Each line of encoded data will end with this sequence - * of bytes. - * @param urlSafe Instead of emitting '+' and '/' we emit '-' and '_' - * respectively. urlSafe is only applied to encode - * operations. Decoding seamlessly handles both modes. - * Note: no padding is added when using the URL-safe - * alphabet. - * @param decodingPolicy The decoding policy. - * @throws IllegalArgumentException Thrown when the {@code lineSeparator} - * contains Base64 characters. - * @since 1.15 - */ - public Base64(final int lineLength, final byte[] lineSeparator, final boolean urlSafe, - final CodecPolicy decodingPolicy) { - super(BYTES_PER_UNENCODED_BLOCK, BYTES_PER_ENCODED_BLOCK, lineLength, - lineSeparator == null ? 0 : lineSeparator.length, PAD_DEFAULT, decodingPolicy); - // TODO could be simplified if there is no requirement to reject invalid line - // sep when length <=0 - // @see test case Base64Test.testConstructors() - if (lineSeparator != null) { - if (containsAlphabetOrPad(lineSeparator)) { - final String sep = new String(lineSeparator, Charset.forName("UTF-8")); - throw new IllegalArgumentException("lineSeparator must not contain base64 characters: [" + sep + "]"); - } - if (lineLength > 0) { // null line-sep forces no chunking rather than throwing IAE - this.encodeSize = BYTES_PER_ENCODED_BLOCK + lineSeparator.length; - this.lineSeparator = new byte[lineSeparator.length]; - System.arraycopy(lineSeparator, 0, this.lineSeparator, 0, lineSeparator.length); - } else { - this.encodeSize = BYTES_PER_ENCODED_BLOCK; - this.lineSeparator = null; - } - } else { - this.encodeSize = BYTES_PER_ENCODED_BLOCK; - this.lineSeparator = null; - } - this.decodeSize = this.encodeSize - 1; - this.encodeTable = urlSafe ? URL_SAFE_ENCODE_TABLE : STANDARD_ENCODE_TABLE; - } - - // Implementation of the Encoder Interface - - /** - *

- * Decodes all of the provided data, starting at inPos, for inAvail bytes. - * Should be called at least twice: once with the data to decode, and once with - * inAvail set to "-1" to alert decoder that EOF has been reached. The "-1" call - * is not necessary when decoding, but it doesn't hurt, either. - *

- *

- * Ignores all non-base64 characters. This is how chunked (e.g. 76 character) - * data is handled, since CR and LF are silently ignored, but has implications - * for other bytes, too. This method subscribes to the garbage-in, garbage-out - * philosophy: it will not check the provided data for validity. - *

- *

- * Thanks to "commons" project in ws.apache.org for the bitwise operations, and - * general approach. - * http://svn.apache.org/repos/asf/webservices/commons/trunk/modules/util/ - *

- * - * @param in byte[] array of ascii data to base64 decode. - * @param inPos Position to start reading data from. - * @param inAvail Amount of bytes available from input for decoding. - * @param context the context to be used - */ - @Override - void decode(final byte[] in, int inPos, final int inAvail, final Context context) { - if (context.eof) { - return; - } - if (inAvail < 0) { - context.eof = true; - } - for (int i = 0; i < inAvail; i++) { - final byte[] buffer = ensureBufferSize(decodeSize, context); - final byte b = in[inPos++]; - if (b == pad) { - // We're done. - context.eof = true; - break; - } - if (b >= 0 && b < DECODE_TABLE.length) { - final int result = DECODE_TABLE[b]; - if (result >= 0) { - context.modulus = (context.modulus + 1) % BYTES_PER_ENCODED_BLOCK; - context.ibitWorkArea = (context.ibitWorkArea << BITS_PER_ENCODED_BYTE) + result; - if (context.modulus == 0) { - buffer[context.pos++] = (byte) ((context.ibitWorkArea >> 16) & MASK_8BITS); - buffer[context.pos++] = (byte) ((context.ibitWorkArea >> 8) & MASK_8BITS); - buffer[context.pos++] = (byte) (context.ibitWorkArea & MASK_8BITS); - } - } - } - } - - // Two forms of EOF as far as base64 decoder is concerned: actual - // EOF (-1) and first time '=' character is encountered in stream. - // This approach makes the '=' padding characters completely optional. - if (context.eof && context.modulus != 0) { - final byte[] buffer = ensureBufferSize(decodeSize, context); - - // We have some spare bits remaining - // Output all whole multiples of 8 bits and ignore the rest - switch (context.modulus) { -// case 0 : // impossible, as excluded above - case 1: // 6 bits - either ignore entirely, or raise an exception - validateTrailingCharacter(); - break; - case 2: // 12 bits = 8 + 4 - validateCharacter(MASK_4BITS, context); - context.ibitWorkArea = context.ibitWorkArea >> 4; // dump the extra 4 bits - buffer[context.pos++] = (byte) ((context.ibitWorkArea) & MASK_8BITS); - break; - case 3: // 18 bits = 8 + 8 + 2 - validateCharacter(MASK_2BITS, context); - context.ibitWorkArea = context.ibitWorkArea >> 2; // dump 2 bits - buffer[context.pos++] = (byte) ((context.ibitWorkArea >> 8) & MASK_8BITS); - buffer[context.pos++] = (byte) ((context.ibitWorkArea) & MASK_8BITS); - break; - default: - throw new IllegalStateException("Impossible modulus " + context.modulus); - } - } - } - - /** - *

- * Encodes all of the provided data, starting at inPos, for inAvail bytes. Must - * be called at least twice: once with the data to encode, and once with inAvail - * set to "-1" to alert encoder that EOF has been reached, to flush last - * remaining bytes (if not multiple of 3). - *

- *

- * Note: no padding is added when encoding using the URL-safe alphabet. - *

- *

- * Thanks to "commons" project in ws.apache.org for the bitwise operations, and - * general approach. - * http://svn.apache.org/repos/asf/webservices/commons/trunk/modules/util/ - *

- * - * @param in byte[] array of binary data to base64 encode. - * @param inPos Position to start reading data from. - * @param inAvail Amount of bytes available from input for encoding. - * @param context the context to be used - */ - @Override - void encode(final byte[] in, int inPos, final int inAvail, final Context context) { - if (context.eof) { - return; - } - // inAvail < 0 is how we're informed of EOF in the underlying data we're - // encoding. - if (inAvail < 0) { - context.eof = true; - if (0 == context.modulus && lineLength == 0) { - return; // no leftovers to process and not using chunking - } - final byte[] buffer = ensureBufferSize(encodeSize, context); - final int savedPos = context.pos; - switch (context.modulus) { // 0-2 - case 0: // nothing to do here - break; - case 1: // 8 bits = 6 + 2 - // top 6 bits: - buffer[context.pos++] = encodeTable[(context.ibitWorkArea >> 2) & MASK_6BITS]; - // remaining 2: - buffer[context.pos++] = encodeTable[(context.ibitWorkArea << 4) & MASK_6BITS]; - // URL-SAFE skips the padding to further reduce size. - if (encodeTable == STANDARD_ENCODE_TABLE) { - buffer[context.pos++] = pad; - buffer[context.pos++] = pad; - } - break; - - case 2: // 16 bits = 6 + 6 + 4 - buffer[context.pos++] = encodeTable[(context.ibitWorkArea >> 10) & MASK_6BITS]; - buffer[context.pos++] = encodeTable[(context.ibitWorkArea >> 4) & MASK_6BITS]; - buffer[context.pos++] = encodeTable[(context.ibitWorkArea << 2) & MASK_6BITS]; - // URL-SAFE skips the padding to further reduce size. - if (encodeTable == STANDARD_ENCODE_TABLE) { - buffer[context.pos++] = pad; - } - break; - default: - throw new IllegalStateException("Impossible modulus " + context.modulus); - } - context.currentLinePos += context.pos - savedPos; // keep track of current line position - // if currentPos == 0 we are at the start of a line, so don't add CRLF - if (lineLength > 0 && context.currentLinePos > 0) { - System.arraycopy(lineSeparator, 0, buffer, context.pos, lineSeparator.length); - context.pos += lineSeparator.length; - } - } else { - for (int i = 0; i < inAvail; i++) { - final byte[] buffer = ensureBufferSize(encodeSize, context); - context.modulus = (context.modulus + 1) % BYTES_PER_UNENCODED_BLOCK; - int b = in[inPos++]; - if (b < 0) { - b += 256; - } - context.ibitWorkArea = (context.ibitWorkArea << 8) + b; // BITS_PER_BYTE - if (0 == context.modulus) { // 3 bytes = 24 bits = 4 * 6 bits to extract - buffer[context.pos++] = encodeTable[(context.ibitWorkArea >> 18) & MASK_6BITS]; - buffer[context.pos++] = encodeTable[(context.ibitWorkArea >> 12) & MASK_6BITS]; - buffer[context.pos++] = encodeTable[(context.ibitWorkArea >> 6) & MASK_6BITS]; - buffer[context.pos++] = encodeTable[context.ibitWorkArea & MASK_6BITS]; - context.currentLinePos += BYTES_PER_ENCODED_BLOCK; - if (lineLength > 0 && lineLength <= context.currentLinePos) { - System.arraycopy(lineSeparator, 0, buffer, context.pos, lineSeparator.length); - context.pos += lineSeparator.length; - context.currentLinePos = 0; - } - } - } - } - } - - /** - * Returns whether or not the {@code octet} is in the Base64 alphabet. - * - * @param octet The value to test - * @return {@code true} if the value is defined in the the Base64 alphabet - * {@code false} otherwise. - */ - @Override - protected boolean isInAlphabet(final byte octet) { - return octet >= 0 && octet < decodeTable.length && decodeTable[octet] != -1; - } - - /** - * Returns our current encode mode. True if we're URL-SAFE, false otherwise. - * - * @return true if we're in URL-SAFE mode, false otherwise. - * @since 1.4 - */ - public boolean isUrlSafe() { - return this.encodeTable == URL_SAFE_ENCODE_TABLE; - } - - /** - * Validates whether decoding the final trailing character is possible in the - * context of the set of possible base 64 values. - * - *

- * The character is valid if the lower bits within the provided mask are zero. - * This is used to test the final trailing base-64 digit is zero in the bits - * that will be discarded. - * - * @param emptyBitsMask The mask of the lower bits that should be empty - * @param context the context to be used - * - * @throws IllegalArgumentException if the bits being checked contain any - * non-zero value - */ - private void validateCharacter(final int emptyBitsMask, final Context context) { - if (isStrictDecoding() && (context.ibitWorkArea & emptyBitsMask) != 0) { - throw new IllegalArgumentException( - "Strict decoding: Last encoded character (before the paddings if any) is a valid base 64 alphabet but not a possible encoding. " - + "Expected the discarded bits from the character to be zero."); - } - } - - /** - * Validates whether decoding allows an entire final trailing character that - * cannot be used for a complete byte. - * - * @throws IllegalArgumentException if strict decoding is enabled - */ - private void validateTrailingCharacter() { - if (isStrictDecoding()) { - throw new IllegalArgumentException( - "Strict decoding: Last encoded character (before the paddings if any) is a valid base 64 alphabet but not a possible encoding. " - + "Decoding requires at least two trailing 6-bit characters to create bytes."); - } - } - -} \ No newline at end of file diff --git a/src/net/lax1dude/eaglercraft/BaseNCodec.java b/src/net/lax1dude/eaglercraft/BaseNCodec.java deleted file mode 100644 index 9ab019c..0000000 --- a/src/net/lax1dude/eaglercraft/BaseNCodec.java +++ /dev/null @@ -1,694 +0,0 @@ -package net.lax1dude.eaglercraft; - -import java.nio.charset.Charset; -import java.util.Arrays; - -import net.lax1dude.eaglercraft.BaseNCodec.CodecPolicy; - -public abstract class BaseNCodec { - - static enum CodecPolicy { - STRICT, LENIANT; - } - - /** - * Holds thread context so classes can be thread-safe. - * - * This class is not itself thread-safe; each thread must allocate its own copy. - * - * @since 1.7 - */ - static class Context { - - /** - * Place holder for the bytes we're dealing with for our based logic. Bitwise - * operations store and extract the encoding or decoding from this variable. - */ - int ibitWorkArea; - - /** - * Place holder for the bytes we're dealing with for our based logic. Bitwise - * operations store and extract the encoding or decoding from this variable. - */ - long lbitWorkArea; - - /** - * Buffer for streaming. - */ - byte[] buffer; - - /** - * Position where next character should be written in the buffer. - */ - int pos; - - /** - * Position where next character should be read from the buffer. - */ - int readPos; - - /** - * Boolean flag to indicate the EOF has been reached. Once EOF has been reached, - * this object becomes useless, and must be thrown away. - */ - boolean eof; - - /** - * Variable tracks how many characters have been written to the current line. - * Only used when encoding. We use it to make sure each encoded line never goes - * beyond lineLength (if lineLength > 0). - */ - int currentLinePos; - - /** - * Writes to the buffer only occur after every 3/5 reads when encoding, and - * every 4/8 reads when decoding. This variable helps track that. - */ - int modulus; - - Context() { - } - - /** - * Returns a String useful for debugging (especially within a debugger.) - * - * @return a String useful for debugging. - */ - @SuppressWarnings("boxing") // OK to ignore boxing here - @Override - public String toString() { - return String.format( - "%s[buffer=%s, currentLinePos=%s, eof=%s, ibitWorkArea=%s, lbitWorkArea=%s, " - + "modulus=%s, pos=%s, readPos=%s]", - this.getClass().getSimpleName(), Arrays.toString(buffer), currentLinePos, eof, ibitWorkArea, - lbitWorkArea, modulus, pos, readPos); - } - } - - /** - * EOF - * - * @since 1.7 - */ - static final int EOF = -1; - - /** - * MIME chunk size per RFC 2045 section 6.8. - * - *

- * The {@value} character limit does not count the trailing CRLF, but counts all - * other characters, including any equal signs. - *

- * - * @see RFC 2045 section 6.8 - */ - public static final int MIME_CHUNK_SIZE = 76; - - /** - * PEM chunk size per RFC 1421 section 4.3.2.4. - * - *

- * The {@value} character limit does not count the trailing CRLF, but counts all - * other characters, including any equal signs. - *

- * - * @see RFC 1421 section - * 4.3.2.4 - */ - public static final int PEM_CHUNK_SIZE = 64; - - private static final int DEFAULT_BUFFER_RESIZE_FACTOR = 2; - - /** - * Defines the default buffer size - currently {@value} - must be large enough - * for at least one encoded block+separator - */ - private static final int DEFAULT_BUFFER_SIZE = 8192; - - /** - * The maximum size buffer to allocate. - * - *

- * This is set to the same size used in the JDK {@code java.util.ArrayList}: - *

- *
Some VMs reserve some header words in an array. Attempts to - * allocate larger arrays may result in OutOfMemoryError: Requested array size - * exceeds VM limit.
- */ - private static final int MAX_BUFFER_SIZE = Integer.MAX_VALUE - 8; - - /** Mask used to extract 8 bits, used in decoding bytes */ - protected static final int MASK_8BITS = 0xff; - - /** - * Byte used to pad output. - */ - protected static final byte PAD_DEFAULT = '='; // Allow static access to default - - /** - * Chunk separator per RFC 2045 section 2.1. - * - * @see RFC 2045 section 2.1 - */ - static final byte[] CHUNK_SEPARATOR = { '\r', '\n' }; - - /** - * Compares two {@code int} values numerically treating the values as unsigned. - * Taken from JDK 1.8. - * - *

- * TODO: Replace with JDK 1.8 Integer::compareUnsigned(int, int). - *

- * - * @param x the first {@code int} to compare - * @param y the second {@code int} to compare - * @return the value {@code 0} if {@code x == y}; a value less than {@code 0} if - * {@code x < y} as unsigned values; and a value greater than {@code 0} - * if {@code x > y} as unsigned values - */ - private static int compareUnsigned(final int xx, final int yy) { - int x = xx + Integer.MIN_VALUE; - int y = yy + Integer.MIN_VALUE; - return (x < y) ? -1 : ((x == y) ? 0 : 1); - } - - /** - * Create a positive capacity at least as large the minimum required capacity. - * If the minimum capacity is negative then this throws an OutOfMemoryError as - * no array can be allocated. - * - * @param minCapacity the minimum capacity - * @return the capacity - * @throws OutOfMemoryError if the {@code minCapacity} is negative - */ - private static int createPositiveCapacity(final int minCapacity) { - if (minCapacity < 0) { - // overflow - throw new OutOfMemoryError("Unable to allocate array size: " + (minCapacity & 0xffffffffL)); - } - // This is called when we require buffer expansion to a very big array. - // Use the conservative maximum buffer size if possible, otherwise the biggest - // required. - // - // Note: In this situation JDK 1.8 java.util.ArrayList returns - // Integer.MAX_VALUE. - // This excludes some VMs that can exceed MAX_BUFFER_SIZE but not allocate a - // full - // Integer.MAX_VALUE length array. - // The result is that we may have to allocate an array of this size more than - // once if - // the capacity must be expanded again. - return (minCapacity > MAX_BUFFER_SIZE) ? minCapacity : MAX_BUFFER_SIZE; - } - - /** - * Gets a copy of the chunk separator per RFC 2045 section 2.1. - * - * @return the chunk separator - * @see RFC 2045 section 2.1 - * @since 1.15 - */ - public static byte[] getChunkSeparator() { - return CHUNK_SEPARATOR.clone(); - } - - /** - * Checks if a byte value is whitespace or not. Whitespace is taken to mean: - * space, tab, CR, LF - * - * @param byteToCheck the byte to check - * @return true if byte is whitespace, false otherwise - */ - protected static boolean isWhiteSpace(final byte byteToCheck) { - switch (byteToCheck) { - case ' ': - case '\n': - case '\r': - case '\t': - return true; - default: - return false; - } - } - - /** - * Increases our buffer by the {@link #DEFAULT_BUFFER_RESIZE_FACTOR}. - * - * @param context the context to be used - * @param minCapacity the minimum required capacity - * @return the resized byte[] buffer - * @throws OutOfMemoryError if the {@code minCapacity} is negative - */ - private static byte[] resizeBuffer(final Context context, final int minCapacity) { - // Overflow-conscious code treats the min and new capacity as unsigned. - final int oldCapacity = context.buffer.length; - int newCapacity = oldCapacity * DEFAULT_BUFFER_RESIZE_FACTOR; - if (compareUnsigned(newCapacity, minCapacity) < 0) { - newCapacity = minCapacity; - } - if (compareUnsigned(newCapacity, MAX_BUFFER_SIZE) > 0) { - newCapacity = createPositiveCapacity(minCapacity); - } - - final byte[] b = new byte[newCapacity]; - System.arraycopy(context.buffer, 0, b, 0, context.buffer.length); - context.buffer = b; - return b; - } - - /** - * @deprecated Use {@link #pad}. Will be removed in 2.0. - */ - @Deprecated - protected final byte PAD = PAD_DEFAULT; // instance variable just in case it needs to vary later - - protected final byte pad; // instance variable just in case it needs to vary later - - /** - * Number of bytes in each full block of unencoded data, e.g. 4 for Base64 and 5 - * for Base32 - */ - private final int unencodedBlockSize; - - /** - * Number of bytes in each full block of encoded data, e.g. 3 for Base64 and 8 - * for Base32 - */ - private final int encodedBlockSize; - - /** - * Chunksize for encoding. Not used when decoding. A value of zero or less - * implies no chunking of the encoded data. Rounded down to nearest multiple of - * encodedBlockSize. - */ - protected final int lineLength; - - /** - * Size of chunk separator. Not used unless {@link #lineLength} > 0. - */ - private final int chunkSeparatorLength; - - /** - * Defines the decoding behavior when the input bytes contain leftover trailing - * bits that cannot be created by a valid encoding. These can be bits that are - * unused from the final character or entire characters. The default mode is - * lenient decoding. Set this to {@code true} to enable strict decoding. - *
    - *
  • Lenient: Any trailing bits are composed into 8-bit bytes where possible. - * The remainder are discarded. - *
  • Strict: The decoding will raise an {@link IllegalArgumentException} if - * trailing bits are not part of a valid encoding. Any unused bits from the - * final character must be zero. Impossible counts of entire final characters - * are not allowed. - *
- * - *

- * When strict decoding is enabled it is expected that the decoded bytes will be - * re-encoded to a byte array that matches the original, i.e. no changes occur - * on the final character. This requires that the input bytes use the same - * padding and alphabet as the encoder. - */ - private final CodecPolicy decodingPolicy; - - /** - * Note {@code lineLength} is rounded down to the nearest multiple of the - * encoded block size. If {@code chunkSeparatorLength} is zero, then chunking is - * disabled. - * - * @param unencodedBlockSize the size of an unencoded block (e.g. Base64 = 3) - * @param encodedBlockSize the size of an encoded block (e.g. Base64 = 4) - * @param lineLength if > 0, use chunking with a length - * {@code lineLength} - * @param chunkSeparatorLength the chunk separator length, if relevant - */ - protected BaseNCodec(final int unencodedBlockSize, final int encodedBlockSize, final int lineLength, - final int chunkSeparatorLength) { - this(unencodedBlockSize, encodedBlockSize, lineLength, chunkSeparatorLength, PAD_DEFAULT); - } - - /** - * Note {@code lineLength} is rounded down to the nearest multiple of the - * encoded block size. If {@code chunkSeparatorLength} is zero, then chunking is - * disabled. - * - * @param unencodedBlockSize the size of an unencoded block (e.g. Base64 = 3) - * @param encodedBlockSize the size of an encoded block (e.g. Base64 = 4) - * @param lineLength if > 0, use chunking with a length - * {@code lineLength} - * @param chunkSeparatorLength the chunk separator length, if relevant - * @param pad byte used as padding byte. - */ - protected BaseNCodec(final int unencodedBlockSize, final int encodedBlockSize, final int lineLength, - final int chunkSeparatorLength, final byte pad) { - this(unencodedBlockSize, encodedBlockSize, lineLength, chunkSeparatorLength, pad, CodecPolicy.LENIANT); - } - - /** - * Note {@code lineLength} is rounded down to the nearest multiple of the - * encoded block size. If {@code chunkSeparatorLength} is zero, then chunking is - * disabled. - * - * @param unencodedBlockSize the size of an unencoded block (e.g. Base64 = 3) - * @param encodedBlockSize the size of an encoded block (e.g. Base64 = 4) - * @param lineLength if > 0, use chunking with a length - * {@code lineLength} - * @param chunkSeparatorLength the chunk separator length, if relevant - * @param pad byte used as padding byte. - * @param decodingPolicy Decoding policy. - * @since 1.15 - */ - protected BaseNCodec(final int unencodedBlockSize, final int encodedBlockSize, final int lineLength, - final int chunkSeparatorLength, final byte pad, final CodecPolicy decodingPolicy) { - this.unencodedBlockSize = unencodedBlockSize; - this.encodedBlockSize = encodedBlockSize; - final boolean useChunking = lineLength > 0 && chunkSeparatorLength > 0; - this.lineLength = useChunking ? (lineLength / encodedBlockSize) * encodedBlockSize : 0; - this.chunkSeparatorLength = chunkSeparatorLength; - this.pad = pad; - this.decodingPolicy = decodingPolicy; - } - - /** - * Returns the amount of buffered data available for reading. - * - * @param context the context to be used - * @return The amount of buffered data available for reading. - */ - int available(final Context context) { // package protected for access from I/O streams - return context.buffer != null ? context.pos - context.readPos : 0; - } - - /** - * Tests a given byte array to see if it contains any characters within the - * alphabet or PAD. - * - * Intended for use in checking line-ending arrays - * - * @param arrayOctet byte array to test - * @return {@code true} if any byte is a valid character in the alphabet or PAD; - * {@code false} otherwise - */ - protected boolean containsAlphabetOrPad(final byte[] arrayOctet) { - if (arrayOctet == null) { - return false; - } - for (final byte element : arrayOctet) { - if (pad == element || isInAlphabet(element)) { - return true; - } - } - return false; - } - - /** - * Decodes a byte[] containing characters in the Base-N alphabet. - * - * @param pArray A byte array containing Base-N character data - * @return a byte array containing binary data - */ - public byte[] decode(final byte[] pArray) { - if (pArray == null || pArray.length == 0) { - return pArray; - } - final Context context = new Context(); - decode(pArray, 0, pArray.length, context); - decode(pArray, 0, EOF, context); // Notify decoder of EOF. - final byte[] result = new byte[context.pos]; - readResults(result, 0, result.length, context); - return result; - } - - // package protected for access from I/O streams - abstract void decode(byte[] pArray, int i, int length, Context context); - - /** - * Decodes an Object using the Base-N algorithm. This method is provided in - * order to satisfy the requirements of the Decoder interface, and will throw a - * DecoderException if the supplied object is not of type byte[] or String. - * - * @param obj Object to decode - * @return An object (of type byte[]) containing the binary data which - * corresponds to the byte[] or String supplied. - * @throws DecoderException if the parameter supplied is not of type byte[] - */ - public Object decode(final Object obj) { - if (obj instanceof byte[]) { - return decode((byte[]) obj); - } else if (obj instanceof String) { - return decode((String) obj); - } else { - return null; - } - } - - /** - * Decodes a String containing characters in the Base-N alphabet. - * - * @param pArray A String containing Base-N character data - * @return a byte array containing binary data - */ - public byte[] decode(final String pArray) { - return decode(pArray.getBytes(Charset.forName("UTF-8"))); - } - - /** - * Encodes a byte[] containing binary data, into a byte[] containing characters - * in the alphabet. - * - * @param pArray a byte array containing binary data - * @return A byte array containing only the base N alphabetic character data - */ - public byte[] encode(final byte[] pArray) { - if (pArray == null || pArray.length == 0) { - return pArray; - } - return encode(pArray, 0, pArray.length); - } - - /** - * Encodes a byte[] containing binary data, into a byte[] containing characters - * in the alphabet. - * - * @param pArray a byte array containing binary data - * @param offset initial offset of the subarray. - * @param length length of the subarray. - * @return A byte array containing only the base N alphabetic character data - * @since 1.11 - */ - public byte[] encode(final byte[] pArray, final int offset, final int length) { - if (pArray == null || pArray.length == 0) { - return pArray; - } - final Context context = new Context(); - encode(pArray, offset, length, context); - encode(pArray, offset, EOF, context); // Notify encoder of EOF. - final byte[] buf = new byte[context.pos - context.readPos]; - readResults(buf, 0, buf.length, context); - return buf; - } - - // package protected for access from I/O streams - abstract void encode(byte[] pArray, int i, int length, Context context); - - /** - * Encodes an Object using the Base-N algorithm. This method is provided in - * order to satisfy the requirements of the Encoder interface, and will throw an - * EncoderException if the supplied object is not of type byte[]. - * - * @param obj Object to encode - * @return An object (of type byte[]) containing the Base-N encoded data which - * corresponds to the byte[] supplied. - * @throws EncoderException if the parameter supplied is not of type byte[] - */ - public Object encode(final Object obj) { - return encode((byte[]) obj); - } - - /** - * Encodes a byte[] containing binary data, into a String containing characters - * in the appropriate alphabet. Uses UTF8 encoding. - * - * @param pArray a byte array containing binary data - * @return String containing only character data in the appropriate alphabet. - * @since 1.5 This is a duplicate of {@link #encodeToString(byte[])}; it was - * merged during refactoring. - */ - public String encodeAsString(final byte[] pArray) { - return new String(encode(pArray), Charset.forName("UTF-8")); - } - - /** - * Encodes a byte[] containing binary data, into a String containing characters - * in the Base-N alphabet. Uses UTF8 encoding. - * - * @param pArray a byte array containing binary data - * @return A String containing only Base-N character data - */ - public String encodeToString(final byte[] pArray) { - return new String(encode(pArray), Charset.forName("UTF-8")); - } - - /** - * Ensure that the buffer has room for {@code size} bytes - * - * @param size minimum spare space required - * @param context the context to be used - * @return the buffer - */ - protected byte[] ensureBufferSize(final int size, final Context context) { - if (context.buffer == null) { - context.buffer = new byte[Math.max(size, getDefaultBufferSize())]; - context.pos = 0; - context.readPos = 0; - - // Overflow-conscious: - // x + y > z == x + y - z > 0 - } else if (context.pos + size - context.buffer.length > 0) { - return resizeBuffer(context, context.pos + size); - } - return context.buffer; - } - - /** - * Returns the decoding behavior policy. - * - *

- * The default is lenient. If the decoding policy is strict, then decoding will - * raise an {@link IllegalArgumentException} if trailing bits are not part of a - * valid encoding. Decoding will compose trailing bits into 8-bit bytes and - * discard the remainder. - *

- * - * @return true if using strict decoding - * @since 1.15 - */ - public CodecPolicy getCodecPolicy() { - return decodingPolicy; - } - - /** - * Get the default buffer size. Can be overridden. - * - * @return the default buffer size. - */ - protected int getDefaultBufferSize() { - return DEFAULT_BUFFER_SIZE; - } - - /** - * Calculates the amount of space needed to encode the supplied array. - * - * @param pArray byte[] array which will later be encoded - * - * @return amount of space needed to encoded the supplied array. Returns a long - * since a max-len array will require > Integer.MAX_VALUE - */ - public long getEncodedLength(final byte[] pArray) { - // Calculate non-chunked size - rounded up to allow for padding - // cast to long is needed to avoid possibility of overflow - long len = ((pArray.length + unencodedBlockSize - 1) / unencodedBlockSize) * (long) encodedBlockSize; - if (lineLength > 0) { // We're using chunking - // Round up to nearest multiple - len += ((len + lineLength - 1) / lineLength) * chunkSeparatorLength; - } - return len; - } - - /** - * Returns true if this object has buffered data for reading. - * - * @param context the context to be used - * @return true if there is data still available for reading. - */ - boolean hasData(final Context context) { // package protected for access from I/O streams - return context.buffer != null; - } - - /** - * Returns whether or not the {@code octet} is in the current alphabet. Does not - * allow whitespace or pad. - * - * @param value The value to test - * - * @return {@code true} if the value is defined in the current alphabet, - * {@code false} otherwise. - */ - protected abstract boolean isInAlphabet(byte value); - - /** - * Tests a given byte array to see if it contains only valid characters within - * the alphabet. The method optionally treats whitespace and pad as valid. - * - * @param arrayOctet byte array to test - * @param allowWSPad if {@code true}, then whitespace and PAD are also allowed - * - * @return {@code true} if all bytes are valid characters in the alphabet or if - * the byte array is empty; {@code false}, otherwise - */ - public boolean isInAlphabet(final byte[] arrayOctet, final boolean allowWSPad) { - for (final byte octet : arrayOctet) { - if (!isInAlphabet(octet) && (!allowWSPad || (octet != pad) && !isWhiteSpace(octet))) { - return false; - } - } - return true; - } - - /** - * Tests a given String to see if it contains only valid characters within the - * alphabet. The method treats whitespace and PAD as valid. - * - * @param basen String to test - * @return {@code true} if all characters in the String are valid characters in - * the alphabet or if the String is empty; {@code false}, otherwise - * @see #isInAlphabet(byte[], boolean) - */ - public boolean isInAlphabet(final String basen) { - return isInAlphabet(basen.getBytes(Charset.forName("UTF-8")), true); - } - - /** - * Returns true if decoding behavior is strict. Decoding will raise an - * {@link IllegalArgumentException} if trailing bits are not part of a valid - * encoding. - * - *

- * The default is false for lenient decoding. Decoding will compose trailing - * bits into 8-bit bytes and discard the remainder. - *

- * - * @return true if using strict decoding - * @since 1.15 - */ - public boolean isStrictDecoding() { - return decodingPolicy == CodecPolicy.STRICT; - } - - /** - * Extracts buffered data into the provided byte[] array, starting at position - * bPos, up to a maximum of bAvail bytes. Returns how many bytes were actually - * extracted. - *

- * Package protected for access from I/O streams. - * - * @param b byte[] array to extract the buffered data into. - * @param bPos position in byte[] array to start extraction at. - * @param bAvail amount of bytes we're allowed to extract. We may extract fewer - * (if fewer are available). - * @param context the context to be used - * @return The number of bytes successfully extracted into the provided byte[] - * array. - */ - int readResults(final byte[] b, final int bPos, final int bAvail, final Context context) { - if (context.buffer != null) { - final int len = Math.min(available(context), bAvail); - System.arraycopy(context.buffer, context.readPos, b, bPos, len); - context.readPos += len; - if (context.readPos >= context.pos) { - context.buffer = null; // so hasData() will return false, and this method can return -1 - } - return len; - } - return context.eof ? EOF : 0; - } -} \ No newline at end of file diff --git a/src/net/lax1dude/eaglercraft/BufferedImage.java b/src/net/lax1dude/eaglercraft/BufferedImage.java deleted file mode 100644 index 9e99db3..0000000 --- a/src/net/lax1dude/eaglercraft/BufferedImage.java +++ /dev/null @@ -1,96 +0,0 @@ -package net.lax1dude.eaglercraft; - -public class BufferedImage { - - private final int[] data; - public final int w; - public final int h; - private final boolean alpha; - - public BufferedImage(int width, int height, int[] pixels, boolean alpha) { - this.w = width; - this.h = height; - this.data = pixels; - this.alpha = alpha; - } - - public BufferedImage(int width, int height, boolean alpha) { - this.w = width; - this.h = height; - this.data = new int[width * height]; - this.alpha = alpha; - } - - public BufferedImage(int w, int h, int k) { - this.w = w; - this.h = h; - this.alpha = true; - this.data = new int[w * h]; - } - - public BufferedImage getSubImage(int x, int y, int pw, int ph) { - int[] img = new int[pw * ph]; - for(int i = 0; i < ph; ++i) { - System.arraycopy(data, (i + y) * this.w + x, img, i * pw, pw); - } - return new BufferedImage(pw, ph, img, alpha); - } - - public int[] getRGB(int startX, int startY, int w, int h, int[] rgbArray, int offset, int scansize) { - if (startX < 0 || startY < 0 || w <= 0 || h <= 0 || - startX + w > this.w || startY + h > this.h || - rgbArray.length < offset + w * h) { - throw new IllegalArgumentException("Invalid input parameters"); - } - - for (int y = startY; y < startY + h; y++) { - for (int x = startX; x < startX + w; x++) { - int imageDataIndex = y * this.w + x; - int argb = data[imageDataIndex]; - int alpha = (argb >> 24) & 0xff; - int red = (argb >> 16) & 0xff; - int green = (argb >> 8) & 0xff; - int blue = argb & 0xff; - int rgb = (alpha << 24) | (red << 16) | (green << 8) | blue; - - rgbArray[offset + (y - startY) * scansize + (x - startX)] = rgb; - } - } - - return rgbArray; - } - - public void setRGB(int startX, int startY, int w, int h, int[] rgbArray, int offset, int scansize) { - if (startX < 0 || startY < 0 || w <= 0 || h <= 0 || - startX + w > this.w || startY + h > this.h || - rgbArray.length < offset + w * h) { - throw new IllegalArgumentException("Invalid input parameters"); - } - - for (int y = startY; y < startY + h; y++) { - for (int x = startX; x < startX + w; x++) { - int imageDataIndex = y * this.w + x; - int rgb = rgbArray[offset + (y - startY) * scansize + (x - startX)]; - int alpha = (rgb >> 24) & 0xff; - int red = (rgb >> 16) & 0xff; - int green = (rgb >> 8) & 0xff; - int blue = rgb & 0xff; - int argb = (alpha << 24) | (red << 16) | (green << 8) | blue; - - data[imageDataIndex] = argb; - } - } - } - - public int getWidth() { - return w; - } - - public int getHeight() { - return h; - } - - public int[] getData() { - return data; - } -} \ No newline at end of file diff --git a/src/net/lax1dude/eaglercraft/Client.java b/src/net/lax1dude/eaglercraft/Client.java deleted file mode 100644 index 9e6423b..0000000 --- a/src/net/lax1dude/eaglercraft/Client.java +++ /dev/null @@ -1,133 +0,0 @@ -package net.lax1dude.eaglercraft; - -import java.io.IOException; -import java.io.PrintWriter; -import java.io.StringWriter; - -import org.teavm.jso.JSBody; -import org.teavm.jso.browser.Window; -import org.teavm.jso.core.JSError; -import org.teavm.jso.dom.html.HTMLDocument; -import org.teavm.jso.dom.html.HTMLElement; - -import net.PeytonPlayz585.opengl.GL11; -import net.PeytonPlayz585.storage.LocalStorageManager; -import net.lax1dude.eaglercraft.adapter.EaglerAdapterImpl2; -import net.minecraft.client.Minecraft; -import net.minecraft.src.Session; - -public class Client { - private static final String crashImage = "data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAATEAAABxCAYAAAC9SpSwAAAQtnpUWHRSYXcgcHJvZmlsZSB0eXBlIGV4aWYAAHjarZlrkly7jYT/cxVeAt8gl0OAZMTsYJY/H1jdsqQrh+2Y2yXV4/QpPoBEZoIdzv/+zw3/4KemFkNtMvrsPfJTZ5158WbEz896zynW9/x+Svp6l369HuTrTcxcKn7n5+Pon9f0ff37vq/XtHjXfhpo2Ncv9NdfzPo1/vhtoPLTyjJv9tdA82ugkj+/SF8DrM+2Yp9Dft6Cns/r1/c/YeB/8Kcib+wfg/z+uQrR242LJedTUok851I/Cyj+P4eyeJN45hfZ39V35fM8v1ZCQP4Up/jTqsLvWfnx7restPPnpJT+uSNw4ddg9h+vf7wOZP4Y/PBC/DNO7Otd/vX6rfH8vp3v//fuEe49n92t2glp/9rU9xbfO25UQl7e1zoP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ppbnN0YW5jZUlEPSJ4bXAuaWlkOjJkY2U5N2M4LTBkZjItNGQzNi1iMzE1LWE0YjdmMmUyMjJiNSIKICAgICAgc3RFdnQ6c29mdHdhcmVBZ2VudD0iR2ltcCAyLjEwIChXaW5kb3dzKSIKICAgICAgc3RFdnQ6d2hlbj0iMjAyMi0wMS0yNFQxNDowNDoxMCIvPgogICAgPC9yZGY6U2VxPgogICA8L3htcE1NOkhpc3Rvcnk+CiAgPC9yZGY6RGVzY3JpcHRpb24+CiA8L3JkZjpSREY+CjwveDp4bXBtZXRhPgogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgCiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIAogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgCiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIAogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgCiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIAogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgCiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIAogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgCiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIAogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgCiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIAogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgCiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAKICAgICAgICAgICAgICAgICAgICAgICAgICAgCjw/eHBhY2tldCBlbmQ9InciPz61xwk6AAAABmJLR0QAnQCdAJ2roJyEAAAACXBIWXMAAAsTAAALEwEAmpwYAAAAB3RJTUUH5gEYFgQKOBb3JwAAIABJREFUeNrtvXl0lFWePv7UvlelKvu+koSQRQiyBJGISEB0hFYZwW1sp4/2csaZ1jlz5sz80cc5c7rnaI8zju2o09qiIrKowEGURXYI+5IASQjZl0plT2rff3/073O/byVVlUQSRPs+5+QkkMpbb9333ud+lufzuaJgMBgEBwcHxw8UYj4EHBwcnMQ4ODg4OIlxcHBwcBLj4ODgJMbBwcHBSYyDg4ODkxgHBwcHJzEODg5OYhwcHBycxDg4ODg4iXFw/GWAqgHHfv+ufyv8+q7XvVMh4rWTHBwc3BLj4ODg4CTGwcHBwUmMg4ODkxgHBwcHJzEODg4OTmIcHBwcnMQ4ODg4iXFwcHBwEuPg4ODgJMbBwcHBSYyDg+NHBCkfAo6/ZAiLov1+P3w+H/x+P/x+P4LBIDQaDWQyGR+oSYyjSCSK+G9OYhwctwiHw4Guri44HA54vV74fD72FQgE4Pf74Xa74XA44Ha74Xa7EQgEsGrVKqSnp9+2BTlT5EJETT+PJZxgMAixWMx+FwgEIBb/2VGjn4W/o78P9/qxPSXo2pFez0mMg2MSC7mrqwt/+MMfYDabYbfb4XQ64XQ64XA42HeHw4HBwUFIJBJIJBLExMRg4cKFSEtL+0GSmJAwxsLn80EqlSIQCIRY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O4PjLcjHHumnkQgoJayzJjH09ySfIgpvobE+y7sIduUbXFXaiDXfPnMTuINTX1+PmzZvj0vukXp7Ok37sdvu4wL5EIkF6evqMtkjm+GEQmpBEwv0uHMZ2WJ2MFRbNWruVEiPuTn5P6OjoCNtmRqVS4caNG+jr65uWXlpOpxOdnZ24ceNGyAQymUyszzkHx48N3BK7DYh05qZCocA333yD2bNnQywWIzExESqVakKdmdCS83g8cLlcsNvtaG1txbFjx0LiYSKRCA8++CAqKyu/19OdODg4if2AQQcpUJmHkGD8fj/+4z/+AzU1NVi0aBGSkpKg0+mYkFTYOYDiB1SsTp0bzGYz6urqcPr0aSbdoKDqk08+iQ0bNkxr3I2D445ylbnYdeZhtVqxadMmvPPOO7DZbGGtLLfbjdHRUbhcLqSlpSE3NxdGo3Fc5UIgEIDVakV3dzfq6upYsa5arWYF5S6XC4mJiXj22WexZs2aKQloOTg4iXGERVdXF/bs2YNNmzahpaUFCoUiIrEIW8uE6/MUTqdDWUmVSoU1a9ZgzZo1mDt3LhISErisgoOTGMf0YHBwEE1NTTh+/Di+/fZb1NTUAAgtuZgM4QibzpHyurCwEPfccw8qKiqQl5eHhISEsIe6cnBwEuO4JVCt48jICLq7u9HW1oabN29iYGAAFosFPT09zK0cK8mQyWRQqVSse0RcXBzrypqamsoOI53pk9Y5ODiJcYQ09aN+ZG63m50BQL2XhK+nDhl0QpGwa4awMy4HBycxju+N2ML9HPLAvoOimYODkxgHBwfHHQqed+fg4OAkxsHBwcFJjIODg4OTGAcHBycxDg4ODk5iHBwcHJzEODg4ODiJcXBwcBLj4ODg4CTGwcHBwUmMg4ODg5MYBwcHJzEODg4OTmIcHBwcnMQ4ODg4iXFwcHBwEuPg4ODgJMbBwcHBSYyDg+MvCv8foPuErXNuO3cAAAAASUVORK5CYII="; - - public static class AbortedLaunchException extends RuntimeException { - // yee - } - - public static HTMLElement rootElement = null; - public static Minecraft instance = null; - public static void main(String[] args) { - registerErrorHandler(); - try { - JSONObject e = new JSONObject(getOpts()); - EaglerAdapterImpl2.initializeContext(rootElement = Window.current().getDocument().getElementById(e.getString("gameContainer")), e.getString("assetsLocation"), e); - }catch(Throwable ex2) { - StringWriter s = new StringWriter(); - ex2.printStackTrace(new PrintWriter(s)); - return; - } - run0(); - } - - private static void run0() { - System.out.println(" -------- starting minecraft -------- "); - instance = new Minecraft(); - Session session = new Session("Player094", "mcpass"); - instance.session = session; - LocalStorageManager.loadStorage(); - run1(); - } - - private static void run1() { - GL11.canvas.focus(); - instance.run(); - } - - @JSBody(params = { }, script = "return JSON.stringify(window.config);") - public static native String getOpts(); - - @JSBody(params = { }, script = "window.minecraftError = null; window.onerror = function(message, file, line, column, errorObj) { if(errorObj) { window.minecraftError = errorObj; window.minecraftErrorL = \"\"+line+\":\"+column; javaMethods.get(\"net.lax1dude.eaglercraft.Client.handleNativeError()V\").invoke(); } else { alert(\"a native browser exception was thrown but your browser does not support fith argument in onerror\"); } };") - public static native void registerErrorHandler(); - - @JSBody(params = { }, script = "return window.minecraftError;") - public static native JSError getWindowError(); - - @JSBody(params = { }, script = "return window.minecraftErrorL;") - public static native String getWindowErrorL(); - - public static void handleNativeError() { - JSError e = getWindowError(); - StringBuilder str = new StringBuilder(); - str.append("Native Browser Exception\n"); - str.append("----------------------------------\n"); - str.append(" Line: ").append(getWindowErrorL()).append('\n'); - str.append(" Type: ").append(e.getName()).append('\n'); - str.append(" Message: ").append(e.getMessage()).append('\n'); - str.append("----------------------------------\n\n"); - str.append(e.getStack()).append('\n'); - } - - private static boolean isCrashed = false; - - public static void showDatabaseLockedScreen(String msg) { - String s = rootElement.getAttribute("style"); - rootElement.setAttribute("style", (s == null ? "" : s) + "position:relative;"); - HTMLDocument doc = Window.current().getDocument(); - HTMLElement img = doc.createElement("img"); - HTMLElement div = doc.createElement("div"); - img.setAttribute("style", "z-index:100;position:absolute;top:10px;left:calc(50% - 151px);"); - img.setAttribute("src", crashImage); - div.setAttribute("style", "z-index:100;position:absolute;top:135px;left:10%;right:10%;bottom:30px;background-color:white;border:1px solid #cccccc;overflow-x:hidden;overflow-y:scroll;overflow-wrap:break-word;white-space:pre-wrap;font: 24px sans-serif;padding:10px;"); - rootElement.appendChild(img); - rootElement.appendChild(div); - div.appendChild(doc.createTextNode(msg)); - } - - @JSBody(params = { "v" }, script = "try { return \"\"+window[v]; } catch(e) { return \"\"; }") - private static native String getString(String var); - - @JSBody(params = { "v" }, script = "try { return \"\"+window.navigator[v]; } catch(e) { return \"\"; }") - private static native String getStringNav(String var); - - @JSBody(params = { "v" }, script = "try { return \"\"+window.screen[v]; } catch(e) { return \"\"; }") - private static native String getStringScreen(String var); - - @JSBody(params = { "v" }, script = "try { return \"\"+window.location[v]; } catch(e) { return \"\"; }") - private static native String getStringLocation(String var); - - @JSBody(params = { }, script = "for(var i = 0; i < window.minecraftOpts.length; ++i) { if(window.minecraftOpts[i].length > 2048) window.minecraftOpts[i] = \"[\" + Math.floor(window.minecraftOpts[i].length * 0.001) + \"k characters]\"; }") - private static native void shortenMinecraftOpts(); - - private static void addDebug(StringBuilder str, String var) { - str.append("window.").append(var).append(" = ").append(getString(var)).append('\n'); - } - - private static void addDebugNav(StringBuilder str, String var) { - str.append("window.navigator.").append(var).append(" = ").append(getStringNav(var)).append('\n'); - } - - private static void addDebugScreen(StringBuilder str, String var) { - str.append("window.screen.").append(var).append(" = ").append(getStringScreen(var)).append('\n'); - } - - private static void addDebugLocation(StringBuilder str, String var) { - str.append("window.location.").append(var).append(" = ").append(getStringLocation(var)).append('\n'); - } - - private static void addArray(StringBuilder str, String var) { - str.append("window.").append(var).append(" = ").append(getArray(var)).append('\n'); - } - - @JSBody(params = { "v" }, script = "try { return (typeof window[v] !== \"undefined\") ? JSON.stringify(window[v]) : \"[\\\"\\\"]\"; } catch(e) { return \"[\\\"\\\"]\"; }") - private static native String getArray(String v); - -} diff --git a/src/net/lax1dude/eaglercraft/EarlyLoadScreen.java b/src/net/lax1dude/eaglercraft/EarlyLoadScreen.java deleted file mode 100644 index 9bdf3c6..0000000 --- a/src/net/lax1dude/eaglercraft/EarlyLoadScreen.java +++ /dev/null @@ -1,117 +0,0 @@ -package net.lax1dude.eaglercraft; - -import static net.lax1dude.eaglercraft.adapter.EaglerAdapterImpl2.*; - -import java.nio.IntBuffer; - -import net.lax1dude.eaglercraft.adapter.EaglerAdapterImpl2.BufferArrayGL; -import net.minecraft.src.GLAllocation; - -public class EarlyLoadScreen { - - public static final String loadScreen = "iVBORw0KGgoAAAANSUhEUgAAAMAAAADACAYAAABS3GwHAAAWonpUWHRSYXcgcHJvZmlsZSB0eXBlIGV4aWYAAHja7ZpZjmO3lkX/OYoaAnseDoctUDOo4dfaVGRUOm0Dfnh+QH04w5YUiite8jS7IeXO//z3df/Fv9KruVya1V6r51/uucfBC/Off+M9Bp/f4/u3vv7E7795333/IfJW4jl9frX6df2P98P3AJ+nwavy00D2NVKYv/1Dz1/j2y8Dfd0oaUaRF/troP41UIqfP4SvAcZnWb52az8vYZ7P8/6xEvv87/SQ2hv7e5Bff8+N6O3CmynGk0LyPMaUPxNI+j+4NPhDfI+NC3nkdUz1Pf6ICQH5ozj5n2blfs3K96vwJ+//kpRUP+873vhtMOv38x++H8ofB9+9EP9057S+7/yb9/0J9dfl/Pj/3m3u3vNZ3ciVkNavRX1HRy+4cBLy9D5W+Wn8X3jd3k/nxxzVu8jOpmQnPyv0EEnLDTnsMMIN5z2vsJhijieSkhjjIlF6z0hRjyt5R56yfsKNLfW0k5GtRXoT78bvuYR33/5ut4Jx4x24MgYGU9aj08Pf8fOnA92rkg/B23esmFdUoTINZU6PXEVCwv1RR+UF+MfPr/+U10QGywuzscDh52eIWcJXbamO0kt04sLC86ctQttfAxAi7l2YTEhkwNeQSqjBtxhbCMTRyM9gIKNp4iQFoZS4mWXMKVWSY1H35jMtvGtjiZ+3wSwSUWijRmp6GuQqA2zUT8tGDY2SSi6l1NKKlV5GTTXXUmttVeA3Wmq5lVZba9Z6G5YsW7FqzcxZt9FjT4AjiNlbt977GNx0MPLg04MLx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UDpWZXJzaW9uPSIyLjEwLjI0IgogICB0aWZmOk9yaWVudGF0aW9uPSIxIgogICB4bXA6Q3JlYXRvclRvb2w9IkdJTVAgMi4xMCI+CiAgIDx4bXBNTTpIaXN0b3J5PgogICAgPHJkZjpTZXE+CiAgICAgPHJkZjpsaQogICAgICBzdEV2dDphY3Rpb249InNhdmVkIgogICAgICBzdEV2dDpjaGFuZ2VkPSIvIgogICAgICBzdEV2dDppbnN0YW5jZUlEPSJ4bXAuaWlkOjYxMDQ5ZjkxLTE0N2ItNDJjNy1hYzRhLWMyNmU0ZDIzZmEwNSIKICAgICAgc3RFdnQ6c29mdHdhcmVBZ2VudD0iR2ltcCAyLjEwIChXaW5kb3dzKSIKICAgICAgc3RFdnQ6d2hlbj0iMjAyMS0xMi0xN1QxNzoyNjoyMCIvPgogICAgPC9yZGY6U2VxPgogICA8L3htcE1NOkhpc3Rvcnk+CiAgPC9yZGY6RGVzY3JpcHRpb24+CiA8L3JkZjpSREY+CjwveDp4bXBtZXRhPgogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgCiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIAogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgCiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIAogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgCiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIAogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgCiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIAogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgCiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIAogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgCiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAKICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgIAogICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgCiAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAgICAKICAgICAgICAgICAgICAgICAgICAgICAgICAgCjw/eHBhY2tldCBlbmQ9InciPz4gG/WSAAAABmJLR0QAnQCdAJ2roJyEAAAACXBIWXMAAAsTAAALEwEAmpwYAAAAB3RJTUUH5QwSARoUHogWFQAAB8dJREFUeNrt3Wtu4yAUQGG36hadRbqLzPxixDCAwYbESb4jVWqbGGPMubz8+Lrf7/cF+FC+FQEIABAAIABAAIAAAAEAAgAEAAgAEAAgAEAAgAAAAQACAAQACAAQACAAQACAAAABAAIABAAIABAAIABAAIAAAAEAAgAEAAgAEAAgAEAAgAAAAQACAAQACAAQACAAQACAAAABAAIABAAIABAAIAAIABAAIABAAIAAAAEAAgAEAAgAEAAgAEAAgADAa/OjCN6L39/f4v/WdV3WdVVIBHjfyn+73arfIYAu0FujghPgoyv/tm3L/X4ngi7Q47sfcf9bf7tcTr3lkpYrAV5kAEqAf/n6+vr7+/1+7x7XhPIcWa66QJMqP9plONrKEoAAHzfGGd2qEkDlfxjbtmV/bxnYzxLgZ1Zl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AEAAgAAAAQACAAQACAAQACAAQACAAAABAAIABAAIABAAIABAAIAAAAGAZVn+ANVuB8euXCQKAAAAAElFTkSuQmCC"; - - private static BufferGL vbo = null; - private static ProgramGL program = null; - - public static void paintScreen() { - - TextureGL tex = _wglGenTextures(); - _wglActiveTexture(_wGL_TEXTURE0); - _wglBindTexture(_wGL_TEXTURE_2D, tex); - _wglTexParameteri(_wGL_TEXTURE_2D, _wGL_TEXTURE_MAG_FILTER, _wGL_NEAREST); - _wglTexParameteri(_wGL_TEXTURE_2D, _wGL_TEXTURE_MIN_FILTER, _wGL_NEAREST); - _wglTexParameteri(_wGL_TEXTURE_2D, _wGL_TEXTURE_WRAP_S, _wGL_CLAMP); - _wglTexParameteri(_wGL_TEXTURE_2D, _wGL_TEXTURE_WRAP_T, _wGL_CLAMP); - BufferedImage img = loadPNG(Base64.decodeBase64(loadScreen)); - IntBuffer upload = GLAllocation.createDirectIntBuffer(192 * 192); - upload.put(img.getData()); - upload.flip(); - _wglTexImage2D(_wGL_TEXTURE_2D, 0, _wGL_RGBA, 192, 192, 0, _wGL_RGBA, _wGL_UNSIGNED_BYTE, upload); - - upload.clear(); - upload.put(Float.floatToIntBits(0.0f)); - upload.put(Float.floatToIntBits(0.0f)); - upload.put(Float.floatToIntBits(0.0f)); - upload.put(Float.floatToIntBits(1.0f)); - upload.put(Float.floatToIntBits(1.0f)); - upload.put(Float.floatToIntBits(0.0f)); - upload.put(Float.floatToIntBits(1.0f)); - upload.put(Float.floatToIntBits(0.0f)); - upload.put(Float.floatToIntBits(0.0f)); - upload.put(Float.floatToIntBits(1.0f)); - upload.put(Float.floatToIntBits(1.0f)); - upload.put(Float.floatToIntBits(1.0f)); - upload.flip(); - - vbo = _wglCreateBuffer(); - _wglBindBuffer(_wGL_ARRAY_BUFFER, vbo); - _wglBufferData0(_wGL_ARRAY_BUFFER, upload, _wGL_STATIC_DRAW); - - ShaderGL vert = _wglCreateShader(_wGL_VERTEX_SHADER); - _wglShaderSource(vert, _wgetShaderHeader() - + "\nprecision lowp float; in vec2 a_pos; out vec2 v_pos; void main() { gl_Position = vec4(((v_pos = a_pos) - 0.5) * vec2(2.0, -2.0), 0.0, 1.0); }"); - _wglCompileShader(vert); - - ShaderGL frag = _wglCreateShader(_wGL_FRAGMENT_SHADER); - _wglShaderSource(frag, _wgetShaderHeader() - + "\nprecision lowp float; in vec2 v_pos; out vec4 fragColor; uniform sampler2D tex; uniform vec2 aspect; void main() { fragColor = vec4(texture(tex, clamp(v_pos * aspect - ((aspect - 1.0) * 0.5), 0.02, 0.98)).rgb, 1.0); }"); - _wglCompileShader(frag); - - program = _wglCreateProgram(); - - _wglAttachShader(program, vert); - _wglAttachShader(program, frag); - _wglBindAttributeLocation(program, 0, "a_pos"); - _wglLinkProgram(program); - _wglDetachShader(program, vert); - _wglDetachShader(program, frag); - _wglDeleteShader(vert); - _wglDeleteShader(frag); - - try { - Thread.sleep(50l); - } catch (InterruptedException e) { - e.printStackTrace(); - } - - _wglUseProgram(program); - _wglUniform1i(_wglGetUniformLocation(program, "tex"), 0); - - int width = getCanvasWidth(); - int height = getCanvasHeight(); - float x, y; - if (width > height) { - x = (float) width / (float) height; - y = 1.0f; - } else { - x = 1.0f; - y = (float) height / (float) width; - } - - _wglActiveTexture(_wGL_TEXTURE0); - _wglBindTexture(_wGL_TEXTURE_2D, tex); - - _wglViewport(0, 0, width, height); - _wglClearColor(1.0f, 1.0f, 1.0f, 1.0f); - _wglClear(_wGL_COLOR_BUFFER_BIT | _wGL_DEPTH_BUFFER_BIT); - - _wglUniform2f(_wglGetUniformLocation(program, "aspect"), x, y); - - BufferArrayGL vao = _wglCreateVertexArray(); - _wglBindVertexArray(vao); - _wglEnableVertexAttribArray(0); - _wglVertexAttribPointer(0, 2, _wGL_FLOAT, false, 8, 0); - _wglDrawArrays(_wGL_TRIANGLES, 0, 6); - _wglDisableVertexAttribArray(0); - _wglFlush(); - updateDisplay(); - - _wglUseProgram(null); - _wglBindBuffer(_wGL_ARRAY_BUFFER, null); - _wglBindTexture(_wGL_TEXTURE_2D, null); - _wglDeleteTextures(tex); - _wglDeleteVertexArray(vao); - } - -} diff --git a/src/net/lax1dude/eaglercraft/GLAllocation.java b/src/net/lax1dude/eaglercraft/GLAllocation.java deleted file mode 100644 index c13b85f..0000000 --- a/src/net/lax1dude/eaglercraft/GLAllocation.java +++ /dev/null @@ -1,60 +0,0 @@ -package net.lax1dude.eaglercraft; - -import java.nio.*; -import java.util.ArrayList; -import java.util.List; - -import net.PeytonPlayz585.opengl.GL11; - -public class GLAllocation { - - public GLAllocation() { - } - - public static synchronized int generateDisplayLists(int i) { - int j = GL11.glGenLists(i); - displayLists.add(Integer.valueOf(j)); - displayLists.add(Integer.valueOf(i)); - return j; - } - - public static synchronized void generateTextureNames(IntBuffer intbuffer) { - - for (int i = intbuffer.position(); i < intbuffer.limit(); i++) { - int tx = GL11.glGenTextures(); - intbuffer.put(i, tx); - textureNames.add(Integer.valueOf(tx)); - } - - } - - public static synchronized void deleteTexturesAndDisplayLists() { - for (int i = 0; i < displayLists.size(); i += 2) { - GL11.glDeleteLists(((Integer) displayLists.get(i)).intValue(), - ((Integer) displayLists.get(i + 1)).intValue()); - } - - for (int j = 0; j < textureNames.size(); j++) { - GL11.glDeleteTextures(((Integer) textureNames.get(j)).intValue()); - } - - displayLists.clear(); - textureNames.clear(); - } - - public static ByteBuffer createDirectByteBuffer(int par0) { - return GL11.isWebGL ? ByteBuffer.wrap(new byte[par0]).order(ByteOrder.nativeOrder()) : ByteBuffer.allocateDirect(par0).order(ByteOrder.nativeOrder()); - } - - public static IntBuffer createDirectIntBuffer(int par0) { - return GL11.isWebGL ? IntBuffer.wrap(new int[par0]) : createDirectByteBuffer(par0 << 2).asIntBuffer(); - } - - public static FloatBuffer createDirectFloatBuffer(int par0) { - return GL11.isWebGL ? FloatBuffer.wrap(new float[par0]) : createDirectByteBuffer(par0 << 2).asFloatBuffer(); - } - - private static List displayLists = new ArrayList(); - private static List textureNames = new ArrayList(); - -} \ No newline at end of file diff --git a/src/net/lax1dude/eaglercraft/GeneralDigest.java b/src/net/lax1dude/eaglercraft/GeneralDigest.java deleted file mode 100644 index 079352d..0000000 --- a/src/net/lax1dude/eaglercraft/GeneralDigest.java +++ /dev/null @@ -1,108 +0,0 @@ -package net.lax1dude.eaglercraft; - -/** - * base implementation of MD4 family style digest as outlined in "Handbook of - * Applied Cryptography", pages 344 - 347. - */ -public abstract class GeneralDigest { - private byte[] xBuf; - private int xBufOff; - - private long byteCount; - - /** - * Standard constructor - */ - protected GeneralDigest() { - xBuf = new byte[4]; - xBufOff = 0; - } - - /** - * Copy constructor. We are using copy constructors in place of the - * Object.clone() interface as this interface is not supported by J2ME. - */ - protected GeneralDigest(GeneralDigest t) { - xBuf = new byte[t.xBuf.length]; - System.arraycopy(t.xBuf, 0, xBuf, 0, t.xBuf.length); - - xBufOff = t.xBufOff; - byteCount = t.byteCount; - } - - public void update(byte in) { - xBuf[xBufOff++] = in; - - if (xBufOff == xBuf.length) { - processWord(xBuf, 0); - xBufOff = 0; - } - - byteCount++; - } - - public void update(byte[] in, int inOff, int len) { - // - // fill the current word - // - while ((xBufOff != 0) && (len > 0)) { - update(in[inOff]); - - inOff++; - len--; - } - - // - // process whole words. - // - while (len > xBuf.length) { - processWord(in, inOff); - - inOff += xBuf.length; - len -= xBuf.length; - byteCount += xBuf.length; - } - - // - // load in the remainder. - // - while (len > 0) { - update(in[inOff]); - - inOff++; - len--; - } - } - - public void finish() { - long bitLength = (byteCount << 3); - - // - // add the pad bytes. - // - update((byte) 128); - - while (xBufOff != 0) { - update((byte) 0); - } - - processLength(bitLength); - - processBlock(); - } - - public void reset() { - byteCount = 0; - - xBufOff = 0; - for (int i = 0; i < xBuf.length; i++) { - xBuf[i] = 0; - } - } - - protected abstract void processWord(byte[] in, int inOff); - - protected abstract void processLength(long bitLength); - - protected abstract void processBlock(); -} \ No newline at end of file diff --git a/src/net/lax1dude/eaglercraft/ImageIO.java b/src/net/lax1dude/eaglercraft/ImageIO.java deleted file mode 100644 index 350c10d..0000000 --- a/src/net/lax1dude/eaglercraft/ImageIO.java +++ /dev/null @@ -1,21 +0,0 @@ -package net.lax1dude.eaglercraft; - -import java.io.ByteArrayInputStream; -import java.io.InputStream; - -import net.PeytonPlayz585.opengl.GL11; - -public class ImageIO { - - public static BufferedImage read(InputStream var1) { - ByteArrayInputStream bais = (ByteArrayInputStream)var1; - byte[] data = bais.readAllBytes(); - - return GL11.loadPNG(data); - } - - public static BufferedImage read(BufferedImage resource) { - return resource; - } - -} diff --git a/src/net/lax1dude/eaglercraft/SHA1Digest.java b/src/net/lax1dude/eaglercraft/SHA1Digest.java deleted file mode 100644 index 9ba1d4d..0000000 --- a/src/net/lax1dude/eaglercraft/SHA1Digest.java +++ /dev/null @@ -1,213 +0,0 @@ -package net.lax1dude.eaglercraft; - -/** - * implementation of SHA-1 as outlined in "Handbook of Applied Cryptography", - * pages 346 - 349. - * - * It is interesting to ponder why the, apart from the extra IV, the other - * difference here from MD5 is the "endienness" of the word processing! - */ -public class SHA1Digest extends GeneralDigest { - private static final int DIGEST_LENGTH = 20; - - private int H1, H2, H3, H4, H5; - - private int[] X = new int[80]; - private int xOff; - - /** - * Standard constructor - */ - public SHA1Digest() { - reset(); - } - - /** - * Copy constructor. This will copy the state of the provided message digest. - */ - public SHA1Digest(SHA1Digest t) { - super(t); - - H1 = t.H1; - H2 = t.H2; - H3 = t.H3; - H4 = t.H4; - H5 = t.H5; - - System.arraycopy(t.X, 0, X, 0, t.X.length); - xOff = t.xOff; - } - - public String getAlgorithmName() { - return "SHA-1"; - } - - public int getDigestSize() { - return DIGEST_LENGTH; - } - - protected void processWord(byte[] in, int inOff) { - X[xOff++] = ((in[inOff] & 0xff) << 24) | ((in[inOff + 1] & 0xff) << 16) | ((in[inOff + 2] & 0xff) << 8) - | ((in[inOff + 3] & 0xff)); - - if (xOff == 16) { - processBlock(); - } - } - - private void unpackWord(int word, byte[] out, int outOff) { - out[outOff] = (byte) (word >>> 24); - out[outOff + 1] = (byte) (word >>> 16); - out[outOff + 2] = (byte) (word >>> 8); - out[outOff + 3] = (byte) word; - } - - protected void processLength(long bitLength) { - if (xOff > 14) { - processBlock(); - } - - X[14] = (int) (bitLength >>> 32); - X[15] = (int) (bitLength & 0xffffffff); - } - - public int doFinal(byte[] out, int outOff) { - finish(); - - unpackWord(H1, out, outOff); - unpackWord(H2, out, outOff + 4); - unpackWord(H3, out, outOff + 8); - unpackWord(H4, out, outOff + 12); - unpackWord(H5, out, outOff + 16); - - reset(); - - return DIGEST_LENGTH; - } - - /** - * reset the chaining variables - */ - public void reset() { - super.reset(); - - H1 = 0x67452301; - H2 = 0xefcdab89; - H3 = 0x98badcfe; - H4 = 0x10325476; - H5 = 0xc3d2e1f0; - - xOff = 0; - for (int i = 0; i != X.length; i++) { - X[i] = 0; - } - } - - // - // Additive constants - // - private static final int Y1 = 0x5a827999; - private static final int Y2 = 0x6ed9eba1; - private static final int Y3 = 0x8f1bbcdc; - private static final int Y4 = 0xca62c1d6; - - private int f(int u, int v, int w) { - return ((u & v) | ((~u) & w)); - } - - private int h(int u, int v, int w) { - return (u ^ v ^ w); - } - - private int g(int u, int v, int w) { - return ((u & v) | (u & w) | (v & w)); - } - - private int rotateLeft(int x, int n) { - return (x << n) | (x >>> (32 - n)); - } - - protected void processBlock() { - // - // expand 16 word block into 80 word block. - // - for (int i = 16; i <= 79; i++) { - X[i] = rotateLeft((X[i - 3] ^ X[i - 8] ^ X[i - 14] ^ X[i - 16]), 1); - } - - // - // set up working variables. - // - int A = H1; - int B = H2; - int C = H3; - int D = H4; - int E = H5; - - // - // round 1 - // - for (int j = 0; j <= 19; j++) { - int t = rotateLeft(A, 5) + f(B, C, D) + E + X[j] + Y1; - - E = D; - D = C; - C = rotateLeft(B, 30); - B = A; - A = t; - } - - // - // round 2 - // - for (int j = 20; j <= 39; j++) { - int t = rotateLeft(A, 5) + h(B, C, D) + E + X[j] + Y2; - - E = D; - D = C; - C = rotateLeft(B, 30); - B = A; - A = t; - } - - // - // round 3 - // - for (int j = 40; j <= 59; j++) { - int t = rotateLeft(A, 5) + g(B, C, D) + E + X[j] + Y3; - - E = D; - D = C; - C = rotateLeft(B, 30); - B = A; - A = t; - } - - // - // round 4 - // - for (int j = 60; j <= 79; j++) { - int t = rotateLeft(A, 5) + h(B, C, D) + E + X[j] + Y4; - - E = D; - D = C; - C = rotateLeft(B, 30); - B = A; - A = t; - } - - H1 += A; - H2 += B; - H3 += C; - H4 += D; - H5 += E; - - // - // reset the offset and clean out the word buffer. - // - xOff = 0; - for (int i = 0; i != X.length; i++) { - X[i] = 0; - } - } -} \ No newline at end of file diff --git a/src/net/lax1dude/eaglercraft/adapter/EaglerAdapterImpl2.java b/src/net/lax1dude/eaglercraft/adapter/EaglerAdapterImpl2.java deleted file mode 100644 index f988418..0000000 --- a/src/net/lax1dude/eaglercraft/adapter/EaglerAdapterImpl2.java +++ /dev/null @@ -1,2113 +0,0 @@ -package net.lax1dude.eaglercraft.adapter; - -import java.io.ByteArrayInputStream; -import java.io.IOException; -import java.io.InputStream; -import java.nio.ByteBuffer; -import java.nio.IntBuffer; -import java.nio.charset.Charset; -import java.text.DateFormat; -import java.text.SimpleDateFormat; -import java.util.Collection; -import java.util.Date; -import java.util.HashMap; -import java.util.HashSet; -import java.util.LinkedList; -import java.util.Set; - -import org.teavm.interop.Async; -import org.teavm.interop.AsyncCallback; -import org.teavm.jso.JSBody; -import org.teavm.jso.JSFunctor; -import org.teavm.jso.JSObject; -import org.teavm.jso.ajax.ReadyStateChangeHandler; -import org.teavm.jso.ajax.XMLHttpRequest; -import org.teavm.jso.browser.TimerHandler; -import org.teavm.jso.browser.Window; -import org.teavm.jso.canvas.CanvasRenderingContext2D; -import org.teavm.jso.canvas.ImageData; -import org.teavm.jso.dom.css.CSSStyleDeclaration; -import org.teavm.jso.dom.events.Event; -import org.teavm.jso.dom.events.EventListener; -import org.teavm.jso.dom.events.KeyboardEvent; -import org.teavm.jso.dom.events.MessageEvent; -import org.teavm.jso.dom.events.MouseEvent; -import org.teavm.jso.dom.events.WheelEvent; -import org.teavm.jso.dom.html.HTMLCanvasElement; -import org.teavm.jso.dom.html.HTMLDocument; -import org.teavm.jso.dom.html.HTMLElement; -import org.teavm.jso.dom.html.HTMLImageElement; -import org.teavm.jso.dom.html.HTMLInputElement; -import org.teavm.jso.typedarrays.ArrayBuffer; -import org.teavm.jso.typedarrays.DataView; -import org.teavm.jso.typedarrays.Float32Array; -import org.teavm.jso.typedarrays.Int32Array; -import org.teavm.jso.typedarrays.Int8Array; -import org.teavm.jso.typedarrays.Uint8Array; -import org.teavm.jso.typedarrays.Uint8ClampedArray; -import org.teavm.jso.webaudio.AudioBuffer; -import org.teavm.jso.webaudio.AudioBufferSourceNode; -import org.teavm.jso.webaudio.AudioContext; -import org.teavm.jso.webaudio.AudioListener; -import org.teavm.jso.webaudio.DecodeErrorCallback; -import org.teavm.jso.webaudio.DecodeSuccessCallback; -import org.teavm.jso.webaudio.GainNode; -import org.teavm.jso.webaudio.MediaEvent; -import org.teavm.jso.webaudio.PannerNode; -import org.teavm.jso.webgl.WebGLBuffer; -import org.teavm.jso.webgl.WebGLFramebuffer; -import org.teavm.jso.webgl.WebGLProgram; -import org.teavm.jso.webgl.WebGLRenderbuffer; -import org.teavm.jso.webgl.WebGLShader; -import org.teavm.jso.webgl.WebGLTexture; -import org.teavm.jso.webgl.WebGLUniformLocation; -import org.teavm.jso.websocket.CloseEvent; -import org.teavm.jso.websocket.WebSocket; - -import net.lax1dude.eaglercraft.adapter.teavm.WebGLQuery; -import net.lax1dude.eaglercraft.adapter.teavm.WebGLVertexArray; -import net.minecraft.src.MathHelper; -import net.PeytonPlayz585.opengl.GL11; -import net.PeytonPlayz585.storage.LocalStorageManager; -import net.lax1dude.eaglercraft.EarlyLoadScreen; -import net.lax1dude.eaglercraft.AssetRepository; -import net.lax1dude.eaglercraft.Base64; -import net.lax1dude.eaglercraft.Client; -import net.lax1dude.eaglercraft.BufferedImage; -import net.lax1dude.eaglercraft.JSONObject; -import net.lax1dude.eaglercraft.adapter.teavm.IndexedDBFilesystem; -import net.lax1dude.eaglercraft.adapter.teavm.IndexedDBFilesystem.OpenState; -import net.lax1dude.eaglercraft.adapter.teavm.WebGL2RenderingContext; -import static net.lax1dude.eaglercraft.adapter.teavm.WebGL2RenderingContext.*; - -public class EaglerAdapterImpl2 { - - public static final boolean _wisWebGL() { - return true; - } - private static boolean isAnisotropicPatched = false; - public static final boolean _wisAnisotropicPatched() { - return isAnisotropicPatched; - } - public static final String _wgetShaderHeader() { - return "#version 300 es"; - } - - @JSBody(params = { }, script = "return window.location.href;") - private static native String getLocationString(); - - public static final boolean isSSLPage() { - return getLocationString().startsWith("https"); - } - - public static final InputStream loadResource(String path) { - byte[] file = loadResourceBytes(path); - if (file != null) { - return new ByteArrayInputStream(file); - } else { - return null; - } - } - - public static final byte[] loadResourceBytes(String path) { - return AssetRepository.getResource(path); - } - - public static final String fileContents(String path) { - byte[] contents = loadResourceBytes(path); - if(contents == null) { - return null; - }else { - return new String(contents, Charset.forName("UTF-8")); - } - } - - @JSBody(params = { }, script = "window.addEventListener('beforeunload', (event) => {event.preventDefault(); return '';});") - private static native void onBeforeCloseRegister(); - - public static final String[] fileContentsLines(String path) { - String contents = fileContents(path); - if(contents == null) { - return null; - }else { - return contents.replace("\r\n", "\n").split("[\r\n]"); - } - } - - @Async - public static native String downloadAssetPack(String assetPackageURI); - - private static void downloadAssetPack(String assetPackageURI, final AsyncCallback cb) { - final XMLHttpRequest request = XMLHttpRequest.create(); - request.setResponseType("arraybuffer"); - request.open("GET", assetPackageURI, true); - request.setOnReadyStateChange(new ReadyStateChangeHandler() { - public void stateChanged() { - if(request.getReadyState() == XMLHttpRequest.DONE) { - Uint8Array bl = Uint8Array.create((ArrayBuffer)request.getResponse()); - loadedPackage = new byte[bl.getByteLength()]; - for(int i = 0; i < loadedPackage.length; ++i) { - loadedPackage[i] = (byte) bl.get(i); - } - cb.complete("yee"); - } - } - }); - request.send(); - } - - @JSBody(params = { "obj" }, script = "window.currentContext = obj;") - private static native int setContextVar(JSObject obj); - - @JSBody(params = { "v", "s" }, script = "window[v] = s;") - public static native void setDebugVar(String v, String s); - - public static HTMLDocument doc = null; - public static HTMLElement parent = null; - public static HTMLCanvasElement canvas = null; - public static WebGL2RenderingContext webgl = null; - public static FramebufferGL backBuffer = null; - public static RenderbufferGL backBufferColor = null; - public static RenderbufferGL backBufferDepth = null; - public static Window win = null; - private static byte[] loadedPackage = null; - private static EventListener contextmenu = null; - private static EventListener mousedown = null; - private static EventListener mouseup = null; - private static EventListener mousemove = null; - private static EventListener keydown = null; - private static EventListener keyup = null; - private static EventListener keypress = null; - private static EventListener wheel = null; - private static String[] identifier = new String[0]; - - public static final String[] getIdentifier() { - return identifier; - } - - @JSBody(params = { }, script = "return window.navigator.userAgent;") - private static native String getUA(); - - @JSBody(params = { }, script = "return window.navigator.platform;") - private static native String getPlaf(); - - @JSBody(params = { "m" }, script = "return m.offsetX;") - private static native int getOffsetX(MouseEvent m); - - @JSBody(params = { "m" }, script = "return m.offsetY;") - private static native int getOffsetY(MouseEvent m); - - @JSBody(params = { "e" }, script = "return e.which;") - private static native int getWhich(KeyboardEvent e); - - public static final void initializeContext(HTMLElement rootElement, String assetPackageURI, JSONObject config) { - parent = rootElement; - String s = parent.getAttribute("style"); - parent.setAttribute("style", (s == null ? "" : s)+"overflow-x:hidden;overflow-y:hidden;"); - win = Window.current(); - doc = win.getDocument(); - canvas = (HTMLCanvasElement)doc.createElement("canvas"); - double r = win.getDevicePixelRatio(); - width = (int)(rootElement.getClientWidth() * r); - height = (int)(rootElement.getClientHeight() * r); - canvas.setWidth(width); - canvas.setHeight(height); - canvas.setAttribute("id", "deevis589723589"); - rootElement.appendChild(canvas); - CSSStyleDeclaration canvasStyle = canvas.getStyle(); - canvasStyle.setProperty("width", "100%"); - canvasStyle.setProperty("height", "100%"); - canvasStyle.setProperty("image-rendering", "pixelated"); - webgl = (WebGL2RenderingContext) canvas.getContext("webgl2", youEagler()); - if(webgl == null) { - throw new RuntimeException("WebGL 2.0 is not supported in your browser ("+getUA()+")"); - } - setContextVar(webgl); - setupBackBuffer(); - resizeBackBuffer(width, height); - - webgl.getExtension("EXT_texture_filter_anisotropic"); - - win.addEventListener("contextmenu", contextmenu = new EventListener() { - public void handleEvent(MouseEvent evt) { - evt.preventDefault(); - evt.stopPropagation(); - } - }); - canvas.addEventListener("mousedown", mousedown = new EventListener() { - public void handleEvent(MouseEvent evt) { - int b = evt.getButton(); - buttonStates[b == 1 ? 2 : (b == 2 ? 1 : b)] = true; - mouseEvents.add(evt); - evt.preventDefault(); - evt.stopPropagation(); - forceMouseGrabbed(); - } - }); - canvas.addEventListener("mouseup", mouseup = new EventListener() { - public void handleEvent(MouseEvent evt) { - int b = evt.getButton(); - buttonStates[b == 1 ? 2 : (b == 2 ? 1 : b)] = false; - mouseEvents.add(evt); - evt.preventDefault(); - evt.stopPropagation(); - } - }); - canvas.addEventListener("mousemove", mousemove = new EventListener() { - public void handleEvent(MouseEvent evt) { - double r = win.getDevicePixelRatio(); - mouseX = (int)(getOffsetX(evt) * r); - mouseY = (int)((canvas.getClientHeight() - getOffsetY(evt)) * r); - mouseDX += evt.getMovementX(); - mouseDY += -evt.getMovementY(); - evt.preventDefault(); - evt.stopPropagation(); - } - }); - win.addEventListener("keydown", keydown = new EventListener() { - public void handleEvent(KeyboardEvent evt) { - //keyStates[remapKey(evt.getKeyCode())] = true; - keyStates[remapKey(getWhich(evt))] = true; - keyEvents.add(evt); - evt.preventDefault(); - evt.stopPropagation(); - forceMouseGrabbed(); - } - }); - win.addEventListener("keyup", keyup = new EventListener() { - public void handleEvent(KeyboardEvent evt) { - //keyStates[remapKey(evt.getKeyCode())] = false; - keyStates[remapKey(getWhich(evt))] = false; - keyEvents.add(evt); - evt.preventDefault(); - evt.stopPropagation(); - } - }); - win.addEventListener("keypress", keypress = new EventListener() { - public void handleEvent(KeyboardEvent evt) { - if(enableRepeatEvents && evt.isRepeat()) keyEvents.add(evt); - evt.preventDefault(); - evt.stopPropagation(); - } - }); - canvas.addEventListener("wheel", wheel = new EventListener() { - public void handleEvent(WheelEvent evt) { - mouseEvents.add(evt); - evt.preventDefault(); - evt.stopPropagation(); - } - }); - win.addEventListener("blur", new EventListener() { - public void handleEvent(WheelEvent evt) { - isWindowFocused = false; - } - }); - win.addEventListener("focus", new EventListener() { - public void handleEvent(WheelEvent evt) { - isWindowFocused = true; - forceMouseGrabbed(); - } - }); - win.addEventListener("pointerlockchange", new EventListener() { - public void handleEvent(MouseEvent evt) { - lostFocus = true; - } - }); - onBeforeCloseRegister(); - - if(!config.isNull("dataBaseName")) { - dataBaseName = config.getString("dataBaseName"); - } - - EarlyLoadScreen.paintScreen(); - - OpenState st = IndexedDBFilesystem.initialize(); - if(st != OpenState.OPENED) { - if(st == OpenState.LOCKED) { - Client.showDatabaseLockedScreen("\nError: World folder is locked!\n\nYou are already playing Eaglercraft in a different tab.\nClose all other Eaglercraft tabs and reload"); - }else { - Client.showDatabaseLockedScreen("\nError: World folder could not be loaded!\n\n" + IndexedDBFilesystem.errorDetail()); - } - throw new Client.AbortedLaunchException(); - } - - downloadAssetPack(assetPackageURI); - - try { - AssetRepository.install(loadedPackage); - } catch (IOException e) { - e.printStackTrace(); - } - - audioctx = AudioContext.create(); - - mouseEvents.clear(); - keyEvents.clear(); - - if(!config.isNull("playerUsername")) { - forcedUser = config.getString("playerUsername"); - } - if(!config.isNull("serverIP")) { - forcedServer = config.getString("serverIP"); - } - - if(!config.isNull("joinServerOnLaunch")) { - joinServerOnLaunch = config.getBoolean("joinServerOnLaunch"); - } - } - - public static String forcedUser = null; - public static String forcedServer = null; - public static String dataBaseName = null; - public static boolean joinServerOnLaunch = false; - private static boolean lostFocus = false; - - public static final void destroyContext() { - - } - - public static final void removeEventHandlers() { - win.removeEventListener("contextmenu", contextmenu); - win.removeEventListener("mousedown", mousedown); - win.removeEventListener("mouseup", mouseup); - win.removeEventListener("mousemove", mousemove); - win.removeEventListener("keydown", keydown); - win.removeEventListener("keyup", keyup); - win.removeEventListener("keypress", keypress); - win.removeEventListener("wheel", wheel); - } - - private static LinkedList mouseEvents = new LinkedList(); - private static LinkedList keyEvents = new LinkedList(); - - private static int mouseX = 0; - private static int mouseY = 0; - private static double mouseDX = 0.0D; - private static double mouseDY = 0.0D; - private static int width = 0; - private static int height = 0; - private static boolean enableRepeatEvents = false; - private static boolean isWindowFocused = true; - - @JSBody(params = { }, script = "return {antialias: false, depth: true, powerPreference: \"high-performance\", desynchronized: true, preserveDrawingBuffer: false, premultipliedAlpha: false, alpha: false};") - public static native JSObject youEagler(); - - public static final int _wGL_TEXTURE_2D = TEXTURE_2D; - public static final int _wGL_DEPTH_TEST = DEPTH_TEST; - public static final int _wGL_LEQUAL = LEQUAL; - public static final int _wGL_GEQUAL = GEQUAL; - public static final int _wGL_GREATER = GREATER; - public static final int _wGL_LESS = LESS; - public static final int _wGL_BACK = BACK; - public static final int _wGL_FRONT = FRONT; - public static final int _wGL_FRONT_AND_BACK = FRONT_AND_BACK; - public static final int _wGL_COLOR_BUFFER_BIT = COLOR_BUFFER_BIT; - public static final int _wGL_DEPTH_BUFFER_BIT = DEPTH_BUFFER_BIT; - public static final int _wGL_BLEND = BLEND; - public static final int _wGL_RGBA = RGBA; - public static final int _wGL_RGB = RGB; - public static final int _wGL_RGB8 = RGB8; - public static final int _wGL_RGBA8 = RGBA8; - public static final int _wGL_UNSIGNED_BYTE = UNSIGNED_BYTE; - public static final int _wGL_UNSIGNED_SHORT = UNSIGNED_SHORT; - public static final int _wGL_SRC_ALPHA = SRC_ALPHA; - public static final int _wGL_ONE_MINUS_SRC_ALPHA = ONE_MINUS_SRC_ALPHA; - public static final int _wGL_ONE_MINUS_DST_COLOR = ONE_MINUS_DST_COLOR; - public static final int _wGL_ONE_MINUS_SRC_COLOR = ONE_MINUS_SRC_COLOR; - public static final int _wGL_ZERO = ZERO; - public static final int _wGL_CULL_FACE = CULL_FACE; - public static final int _wGL_TEXTURE_MIN_FILTER = TEXTURE_MIN_FILTER; - public static final int _wGL_TEXTURE_MAG_FILTER = TEXTURE_MAG_FILTER; - public static final int _wGL_LINEAR = LINEAR; - public static final int _wGL_EQUAL = EQUAL; - public static final int _wGL_SRC_COLOR = SRC_COLOR; - public static final int _wGL_ONE = ONE; - public static final int _wGL_NEAREST = NEAREST; - public static final int _wGL_CLAMP = CLAMP_TO_EDGE; - public static final int _wGL_TEXTURE_WRAP_S = TEXTURE_WRAP_S; - public static final int _wGL_TEXTURE_WRAP_T = TEXTURE_WRAP_T; - public static final int _wGL_REPEAT = REPEAT; - public static final int _wGL_DST_COLOR = DST_COLOR; - public static final int _wGL_DST_ALPHA = DST_ALPHA; - public static final int _wGL_FLOAT = FLOAT; - public static final int _wGL_SHORT = SHORT; - public static final int _wGL_TRIANGLES = TRIANGLES; - public static final int _wGL_TRIANGLE_STRIP = TRIANGLE_STRIP; - public static final int _wGL_TRIANGLE_FAN = TRIANGLE_FAN; - public static final int _wGL_LINE_STRIP = LINE_STRIP; - public static final int _wGL_LINES = LINES; - public static final int _wGL_PACK_ALIGNMENT = PACK_ALIGNMENT; - public static final int _wGL_UNPACK_ALIGNMENT = UNPACK_ALIGNMENT; - public static final int _wGL_TEXTURE0 = TEXTURE0; - public static final int _wGL_TEXTURE1 = TEXTURE1; - public static final int _wGL_TEXTURE2 = TEXTURE2; - public static final int _wGL_TEXTURE3 = TEXTURE3; - public static final int _wGL_VIEWPORT = VIEWPORT; - public static final int _wGL_VERTEX_SHADER = VERTEX_SHADER; - public static final int _wGL_FRAGMENT_SHADER = FRAGMENT_SHADER; - public static final int _wGL_ARRAY_BUFFER = ARRAY_BUFFER; - public static final int _wGL_ELEMENT_ARRAY_BUFFER = ELEMENT_ARRAY_BUFFER; - public static final int _wGL_STATIC_DRAW = STATIC_DRAW; - public static final int _wGL_DYNAMIC_DRAW = DYNAMIC_DRAW; - public static final int _wGL_STREAM_DRAW = STREAM_DRAW; - public static final int _wGL_INVALID_ENUM = INVALID_ENUM; - public static final int _wGL_INVALID_VALUE= INVALID_VALUE; - public static final int _wGL_INVALID_OPERATION = INVALID_OPERATION; - public static final int _wGL_OUT_OF_MEMORY = OUT_OF_MEMORY; - public static final int _wGL_CONTEXT_LOST_WEBGL = CONTEXT_LOST_WEBGL; - public static final int _wGL_FRAMEBUFFER_COMPLETE = FRAMEBUFFER_COMPLETE; - public static final int _wGL_FRAMEBUFFER_INCOMPLETE_ATTACHMENT = FRAMEBUFFER_INCOMPLETE_ATTACHMENT; - public static final int _wGL_FRAMEBUFFER_INCOMPLETE_MISSING_ATTACHMENT = FRAMEBUFFER_INCOMPLETE_MISSING_ATTACHMENT; - public static final int _wGL_COLOR_ATTACHMENT0 = COLOR_ATTACHMENT0; - public static final int _wGL_DEPTH_STENCIL_ATTACHMENT = DEPTH_STENCIL_ATTACHMENT; - public static final int _wGL_DEPTH_STENCIL = DEPTH_STENCIL; - public static final int _wGL_NEAREST_MIPMAP_LINEAR = NEAREST_MIPMAP_LINEAR; - public static final int _wGL_LINEAR_MIPMAP_LINEAR = LINEAR_MIPMAP_LINEAR; - public static final int _wGL_LINEAR_MIPMAP_NEAREST = LINEAR_MIPMAP_NEAREST; - public static final int _wGL_NEAREST_MIPMAP_NEAREST = NEAREST_MIPMAP_NEAREST; - public static final int _wGL_TEXTURE_MAX_LEVEL = TEXTURE_MAX_LEVEL; - public static final int _wGL_UNSIGNED_INT_24_8 = UNSIGNED_INT_24_8; - public static final int _wGL_UNSIGNED_INT = UNSIGNED_INT; - public static final int _wGL_ANY_SAMPLES_PASSED = ANY_SAMPLES_PASSED; - public static final int _wGL_QUERY_RESULT = QUERY_RESULT; - public static final int _wGL_QUERY_RESULT_AVAILABLE = QUERY_RESULT_AVAILABLE; - public static final int _wGL_TEXTURE_MAX_ANISOTROPY = TEXTURE_MAX_ANISOTROPY_EXT; - public static final int _wGL_DEPTH24_STENCIL8 = DEPTH24_STENCIL8; - public static final int _wGL_DEPTH_COMPONENT32F = DEPTH_COMPONENT32F; - public static final int _wGL_DEPTH_ATTACHMENT = DEPTH_ATTACHMENT; - public static final int _wGL_MULTISAMPLE = -1; - public static final int _wGL_LINE_SMOOTH = -1; - public static final int _wGL_READ_FRAMEBUFFER = READ_FRAMEBUFFER; - public static final int _wGL_DRAW_FRAMEBUFFER = DRAW_FRAMEBUFFER; - public static final int _wGL_FRAMEBUFFER = FRAMEBUFFER; - public static final int _wGL_POLYGON_OFFSET_FILL = POLYGON_OFFSET_FILL; - - public static final class TextureGL { - protected final WebGLTexture obj; - public int w = -1; - public int h = -1; - public boolean nearest = true; - public boolean anisotropic = false; - protected TextureGL(WebGLTexture obj) { - this.obj = obj; - } - } - public static final class BufferGL { - protected final WebGLBuffer obj; - protected BufferGL(WebGLBuffer obj) { - this.obj = obj; - } - } - public static final class ShaderGL { - protected final WebGLShader obj; - protected ShaderGL(WebGLShader obj) { - this.obj = obj; - } - } - private static int progId = 0; - public static final class ProgramGL { - protected final WebGLProgram obj; - protected final int hashcode; - protected ProgramGL(WebGLProgram obj) { - this.obj = obj; - this.hashcode = ++progId; - } - } - public static final class UniformGL { - protected final WebGLUniformLocation obj; - protected UniformGL(WebGLUniformLocation obj) { - this.obj = obj; - } - } - public static final class BufferArrayGL { - protected final WebGLVertexArray obj; - public boolean isQuadBufferBound; - protected BufferArrayGL(WebGLVertexArray obj) { - this.obj = obj; - this.isQuadBufferBound = false; - } - } - public static final class FramebufferGL { - protected final WebGLFramebuffer obj; - protected FramebufferGL(WebGLFramebuffer obj) { - this.obj = obj; - } - } - public static final class RenderbufferGL { - protected final WebGLRenderbuffer obj; - protected RenderbufferGL(WebGLRenderbuffer obj) { - this.obj = obj; - } - } - public static final class QueryGL { - protected final WebGLQuery obj; - protected QueryGL(WebGLQuery obj) { - this.obj = obj; - } - } - - public static final void _wglEnable(int p1) { - webgl.enable(p1); - } - public static final void _wglClearDepth(float p1) { - webgl.clearDepth(p1); - } - public static final void _wglDepthFunc(int p1) { - webgl.depthFunc(p1); - } - public static final void _wglCullFace(int p1) { - webgl.cullFace(p1); - } - private static int[] viewportCache = new int[4]; - public static final void _wglViewport(int p1, int p2, int p3, int p4) { - viewportCache[0] = p1; viewportCache[1] = p2; - viewportCache[2] = p3; viewportCache[3] = p4; - webgl.viewport(p1, p2, p3, p4); - } - public static final void _wglClear(int p1) { - webgl.clear(p1); - } - public static final void _wglClearColor(float p1, float p2, float p3, float p4) { - webgl.clearColor(p1, p2, p3, p4); - } - public static final void _wglDisable(int p1) { - webgl.disable(p1); - } - public static final int _wglGetError() { - return webgl.getError(); - } - public static final void _wglFlush() { - webgl.flush(); - } - private static Uint8Array uploadBuffer = Uint8Array.create(ArrayBuffer.create(4 * 1024 * 1024)); - public static final void _wglTexImage2D(int p1, int p2, int p3, int p4, int p5, int p6, int p7, int p8, ByteBuffer p9) { - if(p9 == null) { - webgl.texImage2D(p1, p2, p3, p4, p5, p6, p7, p8, null); - }else { - int len = p9.remaining(); - Uint8Array uploadBuffer1 = uploadBuffer; - for(int i = 0; i < len; ++i) { - uploadBuffer1.set(i, (short) ((int)p9.get() & 0xff)); - } - Uint8Array data = Uint8Array.create(uploadBuffer.getBuffer(), 0, len); - webgl.texImage2D(p1, p2, p3, p4, p5, p6, p7, p8, data); - } - } - public static final void _wglBlendFunc(int p1, int p2) { - webgl.blendFunc(p1, p2); - } - public static final void _wglBlendFuncSeparate(int p1, int p2, int p3, int p4) { - webgl.blendFuncSeparate(p1, p2, p3, p4); - } - public static final void _wglDepthMask(boolean p1) { - webgl.depthMask(p1); - } - public static final void _wglColorMask(boolean p1, boolean p2, boolean p3, boolean p4) { - webgl.colorMask(p1, p2, p3, p4); - } - public static final void _wglBindTexture(int p1, TextureGL p2) { - webgl.bindTexture(p1, p2 == null ? null : p2.obj); - } - public static final void _wglCopyTexSubImage2D(int p1, int p2, int p3, int p4, int p5, int p6, int p7, int p8) { - webgl.copyTexSubImage2D(p1, p2, p3, p4, p5, p6, p7, p8); - } - public static final void _wglTexParameteri(int p1, int p2, int p3) { - webgl.texParameteri(p1, p2, p3); - } - public static final void _wglTexParameterf(int p1, int p2, float p3) { - webgl.texParameterf(p1, p2, p3); - } - public static final void _wglTexImage2D(int p1, int p2, int p3, int p4, int p5, int p6, int p7, int p8, IntBuffer p9) { - int len = p9.remaining(); - Int32Array deevis = Int32Array.create(uploadBuffer.getBuffer()); - for(int i = 0; i < len; ++i) { - deevis.set(i, p9.get()); - } - Uint8Array data = Uint8Array.create(uploadBuffer.getBuffer(), 0, len*4); - webgl.texImage2D(p1, p2, p3, p4, p5, p6, p7, p8, data); - } - public static final void _wglTexSubImage2D(int p1, int p2, int p3, int p4, int p5, int p6, int p7, int p8, IntBuffer p9) { - int len = p9.remaining(); - Int32Array deevis = Int32Array.create(uploadBuffer.getBuffer()); - for(int i = 0; i < len; ++i) { - deevis.set(i, p9.get()); - } - Uint8Array data = Uint8Array.create(uploadBuffer.getBuffer(), 0, len*4); - webgl.texSubImage2D(p1, p2, p3, p4, p5, p6, p7, p8, data); - } - public static final void _wglDeleteTextures(TextureGL p1) { - webgl.deleteTexture(p1.obj); - } - public static final void _wglDrawArrays(int p1, int p2, int p3) { - webgl.drawArrays(p1, p2, p3); - } - public static final void _wglDrawElements(int p1, int p2, int p3, int p4) { - webgl.drawElements(p1, p2, p3, p4); - } - public static final TextureGL _wglGenTextures() { - return new TextureGL(webgl.createTexture()); - } - public static final void _wglTexSubImage2D(int p1, int p2, int p3, int p4, int p5, int p6, int p7, int p8, ByteBuffer p9) { - int len = p9.remaining(); - for(int i = 0; i < len; ++i) { - uploadBuffer.set(i, (short) ((int)p9.get() & 0xff)); - } - Uint8Array data = Uint8Array.create(uploadBuffer.getBuffer(), 0, len); - webgl.texSubImage2D(p1, p2, p3, p4, p5, p6, p7, p8, data); - } - public static final void _wglActiveTexture(int p1) { - webgl.activeTexture(p1); - } - public static final ProgramGL _wglCreateProgram() { - return new ProgramGL(webgl.createProgram()); - } - public static final ShaderGL _wglCreateShader(int p1) { - return new ShaderGL(webgl.createShader(p1)); - } - public static final void _wglAttachShader(ProgramGL p1, ShaderGL p2) { - webgl.attachShader(p1.obj, p2.obj); - } - public static final void _wglDetachShader(ProgramGL p1, ShaderGL p2) { - webgl.detachShader(p1.obj, p2.obj); - } - public static final void _wglCompileShader(ShaderGL p1) { - webgl.compileShader(p1.obj); - } - public static final void _wglLinkProgram(ProgramGL p1) { - webgl.linkProgram(p1.obj); - } - public static final void _wglShaderSource(ShaderGL p1, String p2) { - webgl.shaderSource(p1.obj, p2); - } - public static final String _wglGetShaderInfoLog(ShaderGL p1) { - return webgl.getShaderInfoLog(p1.obj); - } - public static final String _wglGetProgramInfoLog(ProgramGL p1) { - return webgl.getProgramInfoLog(p1.obj); - } - public static final boolean _wglGetShaderCompiled(ShaderGL p1) { - return webgl.getShaderParameteri(p1.obj, COMPILE_STATUS) == 1; - } - public static final boolean _wglGetProgramLinked(ProgramGL p1) { - return webgl.getProgramParameteri(p1.obj, LINK_STATUS) == 1; - } - public static final void _wglDeleteShader(ShaderGL p1) { - webgl.deleteShader(p1.obj); - } - public static final void _wglDeleteProgram(ProgramGL p1) { - webgl.deleteProgram(p1.obj); - } - public static final BufferGL _wglCreateBuffer() { - return new BufferGL(webgl.createBuffer()); - } - public static final void _wglDeleteBuffer(BufferGL p1) { - webgl.deleteBuffer(p1.obj); - } - public static final void _wglBindBuffer(int p1, BufferGL p2) { - webgl.bindBuffer(p1, p2 == null ? null : p2.obj); - } - public static final void _wglBufferData0(int p1, IntBuffer p2, int p3) { - int len = p2.remaining(); - Int32Array deevis = Int32Array.create(uploadBuffer.getBuffer()); - for(int i = 0; i < len; ++i) { - deevis.set(i, p2.get()); - } - Uint8Array data = Uint8Array.create(uploadBuffer.getBuffer(), 0, len*4); - webgl.bufferData(p1, data, p3); - } - public static final void _wglBufferData00(int p1, long len, int p3) { - webgl.bufferData(p1, (int)len, p3); - } - public static final void _wglBufferSubData0(int p1, int p2, IntBuffer p3) { - int len = p3.remaining(); - Int32Array deevis = Int32Array.create(uploadBuffer.getBuffer()); - for(int i = 0; i < len; ++i) { - deevis.set(i, p3.get()); - } - Uint8Array data = Uint8Array.create(uploadBuffer.getBuffer(), 0, len*4); - webgl.bufferSubData(p1, p2, data); - } - public static final void _wglBufferData(int p1, Object p2, int p3) { - webgl.bufferData(p1, (Int32Array)p2, p3); - } - public static final void _wglBufferSubData(int p1, int p2, Object p3) { - webgl.bufferSubData(p1, p2, (Int32Array)p3); - } - public static final void _wglBindAttribLocation(ProgramGL p1, int p2, String p3) { - webgl.bindAttribLocation(p1.obj, p2, p3); - } - public static final void _wglEnableVertexAttribArray(int p1) { - webgl.enableVertexAttribArray(p1); - } - public static final void _wglDisableVertexAttribArray(int p1) { - webgl.disableVertexAttribArray(p1); - } - public static final UniformGL _wglGetUniformLocation(ProgramGL p1, String p2) { - WebGLUniformLocation u = webgl.getUniformLocation(p1.obj, p2); - return u == null ? null : new UniformGL(u); - } - public static final void _wglBindAttributeLocation(ProgramGL p1, int p2, String p3) { - webgl.bindAttribLocation(p1.obj, p2, p3); - } - public static final void _wglUniform1f(UniformGL p1, float p2) { - if(p1 != null) webgl.uniform1f(p1.obj, p2); - } - public static final void _wglUniform2f(UniformGL p1, float p2, float p3) { - if(p1 != null) webgl.uniform2f(p1.obj, p2, p3); - } - public static final void _wglUniform3f(UniformGL p1, float p2, float p3, float p4) { - if(p1 != null) webgl.uniform3f(p1.obj, p2, p3, p4); - } - public static final void _wglUniform4f(UniformGL p1, float p2, float p3, float p4, float p5) { - if(p1 != null) webgl.uniform4f(p1.obj, p2, p3, p4, p5); - } - public static final void _wglUniform1i(UniformGL p1, int p2) { - if(p1 != null) webgl.uniform1i(p1.obj, p2); - } - public static final void _wglUniform2i(UniformGL p1, int p2, int p3) { - if(p1 != null) webgl.uniform2i(p1.obj, p2, p3); - } - public static final void _wglUniform3i(UniformGL p1, int p2, int p3, int p4) { - if(p1 != null) webgl.uniform3i(p1.obj, p2, p3, p4); - } - public static final void _wglUniform4i(UniformGL p1, int p2, int p3, int p4, int p5) { - if(p1 != null) webgl.uniform4i(p1.obj, p2, p3, p4, p5); - } - private static Float32Array mat2 = Float32Array.create(4); - private static Float32Array mat3 = Float32Array.create(9); - private static Float32Array mat4 = Float32Array.create(16); - public static final void _wglUniformMat2fv(UniformGL p1, float[] mat) { - mat2.set(mat); - if(p1 != null) webgl.uniformMatrix2fv(p1.obj, false, mat2); - } - public static final void _wglUniformMat3fv(UniformGL p1, float[] mat) { - mat3.set(mat); - if(p1 != null) webgl.uniformMatrix3fv(p1.obj, false, mat3); - } - public static final void _wglUniformMat4fv(UniformGL p1, float[] mat) { - mat4.set(mat); - if(p1 != null) webgl.uniformMatrix4fv(p1.obj, false, mat4); - } - private static int currentProgram = -1; - public static final void _wglUseProgram(ProgramGL p1) { - if(p1 != null && currentProgram != p1.hashcode) { - currentProgram = p1.hashcode; - webgl.useProgram(p1.obj); - } - } - public static final void _wglGetParameter(int p1, int size, int[] ret) { - if(p1 == _wGL_VIEWPORT) { - ret[0] = viewportCache[0]; - ret[1] = viewportCache[1]; - ret[2] = viewportCache[2]; - ret[3] = viewportCache[3]; - } - } - public static final void _wglPolygonOffset(float p1, float p2) { - webgl.polygonOffset(p1, p2); - } - public static final void _wglVertexAttribPointer(int p1, int p2, int p3, boolean p4, int p5, int p6) { - webgl.vertexAttribPointer(p1, p2, p3, p4, p5, p6); - } - public static final void _wglBindFramebuffer(int p1, FramebufferGL p2) { - webgl.bindFramebuffer(p1, p2 == null ? backBuffer.obj : p2.obj); - } - public static final FramebufferGL _wglCreateFramebuffer() { - return new FramebufferGL(webgl.createFramebuffer()); - } - public static final void _wglDeleteFramebuffer(FramebufferGL p1) { - webgl.deleteFramebuffer(p1.obj); - } - public static final void _wglFramebufferTexture2D(int p1, TextureGL p2) { - webgl.framebufferTexture2D(FRAMEBUFFER, p1, TEXTURE_2D, p2 == null ? null : p2.obj, 0); - } - public static final void _wglFramebufferTexture2D(int p1, TextureGL p2, int p3) { - webgl.framebufferTexture2D(FRAMEBUFFER, p1, TEXTURE_2D, p2 == null ? null : p2.obj, p3); - } - public static final QueryGL _wglCreateQuery() { - return new QueryGL(webgl.createQuery()); - } - public static final void _wglBeginQuery(int p1, QueryGL p2) { - webgl.beginQuery(p1, p2.obj); - } - public static final void _wglEndQuery(int p1) { - webgl.endQuery(p1); - } - public static final void _wglDeleteQuery(QueryGL p1) { - webgl.deleteQuery(p1.obj); - } - public static final int _wglGetQueryObjecti(QueryGL p1, int p2) { - return webgl.getQueryParameter(p1.obj, p2); - } - public static final BufferArrayGL _wglCreateVertexArray() { - return new BufferArrayGL(webgl.createVertexArray()); - } - public static final void _wglDeleteVertexArray(BufferArrayGL p1) { - webgl.deleteVertexArray(p1.obj); - } - public static final void _wglBindVertexArray(BufferArrayGL p1) { - webgl.bindVertexArray(p1 == null ? null : p1.obj); - } - public static final void _wglDrawBuffer(int p1) { - webgl.drawBuffers(new int[] { p1 }); - } - public static final RenderbufferGL _wglCreateRenderBuffer() { - return new RenderbufferGL(webgl.createRenderbuffer()); - } - public static final void _wglBindRenderbuffer(RenderbufferGL p1) { - webgl.bindRenderbuffer(RENDERBUFFER, p1 == null ? null : p1.obj); - } - public static final void _wglRenderbufferStorage(int p1, int p2, int p3) { - webgl.renderbufferStorage(RENDERBUFFER, p1, p2, p3); - } - public static final void _wglFramebufferRenderbuffer(int p1, RenderbufferGL p2) { - webgl.framebufferRenderbuffer(FRAMEBUFFER, p1, RENDERBUFFER, p2 == null ? null : p2.obj); - } - public static final void _wglDeleteRenderbuffer(RenderbufferGL p1) { - webgl.deleteRenderbuffer(p1.obj); - } - public static final void _wglRenderbufferStorageMultisample(int p1, int p2, int p3, int p4) { - webgl.renderbufferStorageMultisample(RENDERBUFFER, p1, p2, p3, p4); - } - public static final void _wglBlitFramebuffer(int p1, int p2, int p3, int p4, int p5, int p6, int p7, int p8, int p9, int p10) { - webgl.blitFramebuffer(p1, p2, p3, p4, p5, p6, p7, p8, p9, p10); - } - public static final int _wglGetAttribLocation(ProgramGL p1, String p2) { - return webgl.getAttribLocation(p1.obj, p2); - } - - @JSBody(params = { "ctx", "p" }, script = "return ctx.getTexParameter(0x0DE1, p) | 0;") - private static final native int __wglGetTexParameteri(WebGL2RenderingContext ctx, int p); - public static final int _wglGetTexParameteri(int p1) { - return __wglGetTexParameteri(webgl, p1); - } - @JSBody(params = { "ctx", "p" }, script = "return (0.0 + ctx.getTexParameter(0x0DE1, p));") - private static final native float __wglGetTexParameterf(WebGL2RenderingContext ctx, int p); - public static final float _wglGetTexParameterf(int p1) { - return __wglGetTexParameterf(webgl, p1); - } - public static final void _wglPixelStorei(int i1, int i2) { - webgl.pixelStorei(i1, i2); - } - public static final boolean isWindows() { - return getPlaf().toLowerCase().contains("win"); - } - private static HTMLCanvasElement imageLoadCanvas = null; - private static CanvasRenderingContext2D imageLoadContext = null; - - @JSBody(params = { "buf", "mime" }, script = "return URL.createObjectURL(new Blob([buf], {type: mime}));") - private static native String getDataURL(ArrayBuffer buf, String mime); - - @JSBody(params = { "url" }, script = "URL.revokeObjectURL(url);") - private static native void freeDataURL(String url); - - public static final BufferedImage loadPNG(byte[] data) { - ArrayBuffer arr = ArrayBuffer.create(data.length); - Uint8Array.create(arr).set(data); - return loadPNG0(arr); - } - - @JSBody(params = { "cccc", "ennn" }, script = "cccc.imageSmoothingEnabled = ennn;") - private static native void setImageSmoothingMode(CanvasRenderingContext2D cc, boolean en); - - @Async - private static native BufferedImage loadPNG0(ArrayBuffer data); - - private static void loadPNG0(ArrayBuffer data, final AsyncCallback ret) { - final HTMLImageElement toLoad = (HTMLImageElement) doc.createElement("img"); - toLoad.addEventListener("load", new EventListener() { - public void handleEvent(Event evt) { - if(imageLoadCanvas == null) { - imageLoadCanvas = (HTMLCanvasElement) doc.createElement("canvas"); - } - if(imageLoadCanvas.getWidth() < toLoad.getWidth()) { - imageLoadCanvas.setWidth(toLoad.getWidth()); - } - if(imageLoadCanvas.getHeight() < toLoad.getHeight()) { - imageLoadCanvas.setHeight(toLoad.getHeight()); - } - if(imageLoadContext == null) { - imageLoadContext = (CanvasRenderingContext2D) imageLoadCanvas.getContext("2d"); - setImageSmoothingMode(imageLoadContext, false); - } - imageLoadContext.clearRect(0, 0, toLoad.getWidth(), toLoad.getHeight()); - imageLoadContext.drawImage(toLoad, 0, 0, toLoad.getWidth(), toLoad.getHeight()); - ImageData pxlsDat = imageLoadContext.getImageData(0, 0, toLoad.getWidth(), toLoad.getHeight()); - Uint8ClampedArray pxls = pxlsDat.getData(); - int totalPixels = pxlsDat.getWidth() * pxlsDat.getHeight(); - freeDataURL(toLoad.getSrc()); - if(pxls.getByteLength() < totalPixels * 4) { - ret.complete(null); - return; - } - DataView dv = DataView.create(pxls.getBuffer()); - int[] pixels = new int[totalPixels]; - for(int i = 0, j; i < pixels.length; ++i) { - j = dv.getUint32(i << 2, false); - pixels[i] = ((j >> 8) & 0xFFFFFF) | ((j & 0xFF) << 24); - } - ret.complete(new BufferedImage(pxlsDat.getWidth(), pxlsDat.getHeight(), pixels, true)); - } - }); - toLoad.addEventListener("error", new EventListener() { - public void handleEvent(Event evt) { - freeDataURL(toLoad.getSrc()); - ret.complete(null); - } - }); - String src = getDataURL(data, "image/png"); - if(src == null) { - ret.complete(null); - }else { - toLoad.setSrc(src); - } - } - - private static MouseEvent currentEvent = null; - private static KeyboardEvent currentEventK = null; - private static boolean[] buttonStates = new boolean[8]; - private static boolean[] keyStates = new boolean[256]; - public static final boolean mouseNext() { - currentEvent = null; - return !mouseEvents.isEmpty() && (currentEvent = mouseEvents.remove(0)) != null; - } - public static final int mouseGetEventButton() { - if(currentEvent == null) return -1; - int b = currentEvent.getButton(); - return b == 1 ? 2 : (b == 2 ? 1 : b); - } - public static final boolean mouseGetEventButtonState() { - return currentEvent == null ? false : currentEvent.getType().equals(MouseEvent.MOUSEDOWN); - } - public static final boolean mouseIsButtonDown(int p1) { - return buttonStates[p1]; - } - public static final int mouseGetEventDWheel() { - return ("wheel".equals(currentEvent.getType())) ? (((WheelEvent)currentEvent).getDeltaY() == 0.0D ? 0 : (((WheelEvent)currentEvent).getDeltaY() > 0.0D ? -1 : 1)) : 0; - } - public static final void mouseSetCursorPosition(int x, int y) { - - } - private static long mouseUngrabTimer = 0l; - private static int mouseUngrabTimeout = 0; - private static boolean needsPointerLock = false; - public static final void mouseSetGrabbed(boolean grabbed) { - needsPointerLock = grabbed; - if(grabbed) { - mouseDX = 0.0D; - mouseDY = 0.0D; - Window.setTimeout(new TimerHandler() { - public void onTimer() { - canvas.requestPointerLock(); - long t = System.currentTimeMillis(); - if(mouseUngrabTimeout != 0) Window.clearTimeout(mouseUngrabTimeout); - mouseUngrabTimeout = 0; - if(t - mouseUngrabTimer < 3000l) { - mouseUngrabTimeout = Window.setTimeout(new TimerHandler() { - public void onTimer() { - canvas.requestPointerLock(); - mouseUngrabTimeout = 0; - } - }, 3000 - (int)(t - mouseUngrabTimer)); - } - } - }, 200); - }else { - mouseUngrabTimer = System.currentTimeMillis(); - if(mouseUngrabTimeout != 0) Window.clearTimeout(mouseUngrabTimeout); - mouseUngrabTimeout = 0; - doc.exitPointerLock(); - } - } - private static void forceMouseGrabbed() { - long t = System.currentTimeMillis(); - if(t - mouseUngrabTimer > 3000l) { - if(needsPointerLock && !isPointerLocked()) { - canvas.requestPointerLock(); - if(isPointerLocked()) { - needsPointerLock = false; - } - } - } - } - public static final int mouseGetDX() { - double dx = mouseDX; - mouseDX = 0.0D; - return (int)dx; - } - public static final int mouseGetDY() { - double dy = mouseDY; - mouseDY = 0.0D; - return (int)dy; - } - public static final int mouseGetX() { - return mouseX; - } - public static final int mouseGetY() { - return mouseY; - } - public static final int mouseGetEventX() { - return currentEvent == null ? -1 : (int)(currentEvent.getClientX() * win.getDevicePixelRatio()); - } - public static final int mouseGetEventY() { - return currentEvent == null ? -1 : (int)((canvas.getClientHeight() - currentEvent.getClientY()) * win.getDevicePixelRatio()); - } - public static final boolean keysNext() { - if(unpressCTRL) { //un-press ctrl after copy/paste permission - keyEvents.clear(); - currentEventK = null; - keyStates[29] = false; - keyStates[157] = false; - keyStates[28] = false; - keyStates[219] = false; - keyStates[220] = false; - unpressCTRL = false; - return false; - } - currentEventK = null; - return !keyEvents.isEmpty() && (currentEventK = keyEvents.remove(0)) != null; - } - public static final int getEventKey() { - return currentEventK == null ? -1 : remapKey(getWhich(currentEventK)); - } - public static final char getEventChar() { - if(currentEventK == null) return '\0'; - String s = currentEventK.getKey(); - return currentEventK == null ? ' ' : (char) (s.length() > 1 ? '\0' : s.charAt(0)); - } - public static final boolean getEventKeyState() { - return currentEventK == null? false : !currentEventK.getType().equals("keyup"); - } - public static final boolean isKeyDown(int p1) { - if(unpressCTRL) { //un-press ctrl after copy/paste permission - keyStates[28] = false; - keyStates[29] = false; - keyStates[157] = false; - keyStates[219] = false; - keyStates[220] = false; - } - return keyStates[p1]; - } - public static final String getKeyName(int p1) { - return (p1 >= 0 && p1 < 256) ? LWJGLKeyNames[p1] : "null"; - } - public static final void setFullscreen(boolean p1) { - if(p1) { - fullscreen(); - } else { - exitFullscreen(); - } - } - - @JSBody(params = { }, script = "if(!document.fullscreenElement){document.documentElement.requestFullscreen();}") - public static final native void fullscreen(); - - @JSBody(params = { }, script = "if(document.fullscreenElement){document.exitFullscreen();}") - public static final native void exitFullscreen(); - - public static final boolean shouldShutdown() { - return false; - } - public static final boolean isFunctionKeyDown(boolean mod, int p1) { - return mod && p1 >= 59 && p1 <= 67 && getEventKey() == (2 + (p1 - 59)); - } - public static final boolean isFunctionKeyDown(int mod, int p1) { - return isKeyDown(mod) && p1 >= 59 && p1 <= 67 & getEventKey() == (2 + (p1 - 59)); - } - public static final boolean isFunctionKeyHeldDown(int mod, int p1) { - return isKeyDown(mod) && p1 >= 59 && p1 <= 67 & isKeyDown(2 + (p1 - 59)); - } - - public static final void updateDisplay() { - double r = win.getDevicePixelRatio(); - int w = (int)(canvas.getClientWidth() * r); - int h = (int)(canvas.getClientHeight() * r); - if(canvas.getWidth() != w) { - canvas.setWidth(w); - } - if(canvas.getHeight() != h) { - canvas.setHeight(h); - } - - webgl.bindFramebuffer(FRAMEBUFFER, null); - webgl.bindFramebuffer(READ_FRAMEBUFFER, backBuffer.obj); - webgl.bindFramebuffer(DRAW_FRAMEBUFFER, null); - webgl.blitFramebuffer(0, 0, backBufferWidth, backBufferHeight, 0, 0, w, h, COLOR_BUFFER_BIT, NEAREST); - webgl.bindFramebuffer(FRAMEBUFFER, backBuffer.obj); - resizeBackBuffer(w, h); - try { - Thread.sleep(1l); - } catch (InterruptedException e) { - ; - } - } - public static final void setupBackBuffer() { - backBuffer = _wglCreateFramebuffer(); - _wglBindFramebuffer(_wGL_FRAMEBUFFER, null); - backBufferColor = _wglCreateRenderBuffer(); - _wglBindRenderbuffer(backBufferColor); - _wglFramebufferRenderbuffer(_wGL_COLOR_ATTACHMENT0, backBufferColor); - backBufferDepth = _wglCreateRenderBuffer(); - _wglBindRenderbuffer(backBufferDepth); - _wglFramebufferRenderbuffer(_wGL_DEPTH_ATTACHMENT, backBufferDepth); - } - private static int backBufferWidth = -1; - private static int backBufferHeight = -1; - public static final void resizeBackBuffer(int w, int h) { - if(w != backBufferWidth || h != backBufferHeight) { - _wglBindRenderbuffer(backBufferColor); - _wglRenderbufferStorage(_wGL_RGBA8, w, h); - _wglBindRenderbuffer(backBufferDepth); - _wglRenderbufferStorage(_wGL_DEPTH_COMPONENT32F, w, h); - backBufferWidth = w; - backBufferHeight = h; - } - } - public static final void setVSyncEnabled(boolean p1) { - - } - public static final void enableRepeatEvents(boolean b) { - enableRepeatEvents = b; - } - - public static boolean isPointerLocked2() { - return mouseUngrabTimeout != 0 || isPointerLocked(); - } - - @JSBody(params = { }, script = "return document.pointerLockElement != null;") - public static native boolean isPointerLocked(); - - private static boolean pointerLockFlag = false; - - public static final boolean isFocused() { - if(lostFocus) { - lostFocus = false; - return false; - } - boolean yee = isPointerLocked(); - boolean dee = pointerLockFlag; - pointerLockFlag = yee; - if(!dee && yee) { - mouseDX = 0.0D; - mouseDY = 0.0D; - } - return isWindowFocused && !(dee && !yee); - } - public static final int getScreenWidth() { - return win.getScreen().getAvailWidth(); - } - public static final int getScreenHeight() { - return win.getScreen().getAvailHeight(); - } - public static final int getCanvasWidth() { - return (int)(parent.getClientWidth() * win.getDevicePixelRatio()); - } - public static final int getCanvasHeight() { - return (int)(parent.getClientHeight() * win.getDevicePixelRatio()); - } - public static final void setDisplaySize(int x, int y) { - - } - public static final void syncDisplay(int performanceToFps) { - - } - - private static final DateFormat dateFormatSS = new SimpleDateFormat("yyyy-MM-dd_HH.mm.ss"); - public static final void saveScreenshot() { - saveScreenshot("screenshot_" + dateFormatSS.format(new Date()).toString() + ".png", canvas); - } - - @JSBody(params = { "name", "cvs" }, script = "var a=document.createElement(\"a\");a.href=cvs.toDataURL(\"image/png\");a.download=name;a.click();") - private static native void saveScreenshot(String name, HTMLCanvasElement cvs); - - public static enum RateLimit { - NONE, FAILED, BLOCKED, FAILED_POSSIBLY_LOCKED, LOCKED, NOW_LOCKED; - } - - private static final Set rateLimitedAddresses = new HashSet(); - private static final Set blockedAddresses = new HashSet(); - - private static WebSocket sock = null; - private static boolean sockIsConnecting = false; - private static boolean sockIsConnected = false; - private static boolean sockIsAlive = false; - private static LinkedList readPackets = new LinkedList(); - private static RateLimit rateLimitStatus = null; - private static String currentSockURI = null; - - public static final RateLimit getRateLimitStatus() { - RateLimit l = rateLimitStatus; - rateLimitStatus = null; - return l; - } - public static final void logRateLimit(String addr, RateLimit l) { - if(l == RateLimit.BLOCKED) { - blockedAddresses.add(addr); - }else { - rateLimitedAddresses.add(addr); - } - } - public static final RateLimit checkRateLimitHistory(String addr) { - if(blockedAddresses.contains(addr)) { - return RateLimit.LOCKED; - }else if(rateLimitedAddresses.contains(addr)) { - return RateLimit.BLOCKED; - }else { - return RateLimit.NONE; - } - } - - @Async - public static native String connectWebSocket(String sockURI); - - private static void connectWebSocket(String sockURI, final AsyncCallback cb) { - sockIsConnecting = true; - sockIsConnected = false; - sockIsAlive = false; - rateLimitStatus = null; - currentSockURI = sockURI; - try { - sock = WebSocket.create(sockURI); - } catch(Throwable t) { - sockIsConnecting = false; - sockIsAlive = false; - return; - } - sock.setBinaryType("arraybuffer"); - sock.onOpen(new EventListener() { - @Override - public void handleEvent(Event evt) { - sockIsConnecting = false; - sockIsAlive = false; - sockIsConnected = true; - readPackets.clear(); - cb.complete("okay"); - } - }); - sock.onClose(new EventListener() { - @Override - public void handleEvent(CloseEvent evt) { - sock = null; - if(sockIsConnecting) { - if(rateLimitStatus == null) { - if(blockedAddresses.contains(currentSockURI)) { - rateLimitStatus = RateLimit.LOCKED; - }else if(rateLimitedAddresses.contains(currentSockURI)) { - rateLimitStatus = RateLimit.FAILED_POSSIBLY_LOCKED; - }else { - rateLimitStatus = RateLimit.FAILED; - } - } - }else if(!sockIsAlive) { - if(rateLimitStatus == null) { - if(blockedAddresses.contains(currentSockURI)) { - rateLimitStatus = RateLimit.LOCKED; - }else if(rateLimitedAddresses.contains(currentSockURI)) { - rateLimitStatus = RateLimit.BLOCKED; - } - } - } - boolean b = sockIsConnecting; - sockIsConnecting = false; - sockIsConnected = false; - sockIsAlive = false; - if(b) cb.complete("fail"); - } - }); - sock.onMessage(new EventListener() { - @Override - public void handleEvent(MessageEvent evt) { - sockIsAlive = true; - if(isString(evt.getData())) { - String stat = evt.getDataAsString(); - if(stat.equalsIgnoreCase("BLOCKED")) { - if(rateLimitStatus == null) { - rateLimitStatus = RateLimit.BLOCKED; - } - rateLimitedAddresses.add(currentSockURI); - }else if(stat.equalsIgnoreCase("LOCKED")) { - if(rateLimitStatus == null) { - rateLimitStatus = RateLimit.NOW_LOCKED; - } - rateLimitedAddresses.add(currentSockURI); - blockedAddresses.add(currentSockURI); - } - sockIsConnecting = false; - sockIsConnected = false; - sock.close(); - return; - } - Uint8Array a = Uint8Array.create(evt.getDataAsArray()); - byte[] b = new byte[a.getByteLength()]; - for(int i = 0; i < b.length; ++i) { - b[i] = (byte) (a.get(i) & 0xFF); - } - readPackets.add(b); - } - }); - } - - public static final boolean startConnection(String uri) { - String res = connectWebSocket(uri); - return "fail".equals(res) ? false : true; - } - public static final void endConnection() { - if(sock == null || sock.getReadyState() == 3) { - sockIsConnecting = false; - } - if(sock != null && !sockIsConnecting) sock.close(); - } - public static final boolean connectionOpen() { - if(sock == null || sock.getReadyState() == 3) { - sockIsConnecting = false; - } - return sock != null && !sockIsConnecting && sock.getReadyState() != 3; - } - @JSBody(params = { "sock", "buffer" }, script = "sock.send(buffer);") - private static native void nativeBinarySend(WebSocket sock, ArrayBuffer buffer); - public static final void writePacket(byte[] packet) { - if(sock != null && !sockIsConnecting) { - Uint8Array arr = Uint8Array.create(packet.length); - arr.set(packet); - nativeBinarySend(sock, arr.getBuffer()); - } - } - public static final byte[] readPacket() { - if(!readPackets.isEmpty()) { - return readPackets.remove(0); - }else { - return null; - } - } - - public static final byte[] loadLocalStorage(String key) { - String s = win.getLocalStorage().getItem("_eaglercraft_beta."+key); - if(s != null) { - return Base64.decodeBase64(s); - }else { - return null; - } - } - public static final void saveLocalStorage(String key, byte[] data) { - win.getLocalStorage().setItem("_eaglercraft_beta."+key, Base64.encodeBase64String(data)); - } - public static final void openLink(String url) { - win.open(url, "_blank"); - } - public static final void redirectTo(String url) { - Window.current().getLocation().setFullURL(url); - } - - @JSFunctor - private static interface FileChooserCallback extends JSObject { - void accept(String name, ArrayBuffer buffer); - } - - private static class FileChooserCallbackImpl implements FileChooserCallback { - - private static final FileChooserCallbackImpl instance = new FileChooserCallbackImpl(); - - @Override - public void accept(String name, ArrayBuffer buffer) { - fileChooserHasResult = true; - if(name == null) { - fileChooserResultObject = null; - }else { - Int8Array typedArray = Int8Array.create(buffer); - byte[] bytes = new byte[typedArray.getByteLength()]; - for(int i = 0; i < bytes.length; ++i) { - bytes[i] = typedArray.get(i); - } - fileChooserResultObject = new FileChooserResult(name, bytes); - } - } - - } - - private static volatile boolean fileChooserHasResult = false; - private static volatile FileChooserResult fileChooserResultObject = null; - - @JSBody(params = { "inputElement", "callback" }, script = - "if(inputElement.files.length > 0) {" - + "const value = inputElement.files[0];" - + "value.arrayBuffer().then(function(arr){ callback(value.name, arr); })" - + ".catch(function(){ callback(null, null); });" - + "} else callback(null, null);") - private static native void getFileChooserResult(HTMLInputElement inputElement, FileChooserCallback callback); - - @JSBody(params = { "inputElement", "value" }, script = "inputElement.accept = value;") - private static native void setAcceptSelection(HTMLInputElement inputElement, String value); - - @JSBody(params = { "inputElement", "enable" }, script = "inputElement.multiple = enable;") - private static native void setMultipleSelection(HTMLInputElement inputElement, boolean enable); - - public static void displayFileChooser(String mime, String ext) { - final HTMLInputElement inputElement = (HTMLInputElement) Window.current().getDocument().createElement("input"); - inputElement.setType("file"); - if(mime == null) { - setAcceptSelection(inputElement, "." + ext); - }else { - setAcceptSelection(inputElement, mime); - } - setMultipleSelection(inputElement, false); - inputElement.addEventListener("change", new EventListener() { - @Override - public void handleEvent(Event evt) { - getFileChooserResult(inputElement, FileChooserCallbackImpl.instance); - } - }); - inputElement.click(); - } - - public static boolean fileChooserHasResult() { - return fileChooserHasResult; - } - - public static FileChooserResult getFileChooserResult() { - fileChooserHasResult = false; - FileChooserResult res = fileChooserResultObject; - fileChooserResultObject = null; - return res; - } - - public static final void setListenerPos(float x, float y, float z, float vx, float vy, float vz, float pitch, float yaw) { - float var2 = MathHelper.cos(-yaw * 0.017453292F); - float var3 = MathHelper.sin(-yaw * 0.017453292F); - float var4 = -MathHelper.cos(pitch * 0.017453292F); - float var5 = MathHelper.sin(pitch * 0.017453292F); - AudioListener l = audioctx.getListener(); - l.setPosition(x, y, z); - l.setOrientation(-var3 * var4, -var5, -var2 * var4, 0.0f, 1.0f, 0.0f); - } - - private static int playbackId = 0; - private static final HashMap loadedSoundFiles = new HashMap(); - private static AudioContext audioctx = null; - private static float playbackOffsetDelay = 0.03f; - - public static final void setPlaybackOffsetDelay(float f) { - playbackOffsetDelay = f; - } - - @Async - public static native AudioBuffer decodeAudioAsync(ArrayBuffer buffer); - - private static void decodeAudioAsync(ArrayBuffer buffer, final AsyncCallback cb) { - audioctx.decodeAudioData(buffer, new DecodeSuccessCallback() { - public void onSuccess(AudioBuffer decodedData) { - cb.complete(decodedData); - } - }, new DecodeErrorCallback() { - public void onError(JSObject error) { - cb.complete(null); - } - }); - } - - public static final HashMap activeSoundEffects = new HashMap(); - - private static class AudioBufferX { - private final AudioBuffer buffer; - private AudioBufferX(AudioBuffer buffer) { - this.buffer = buffer; - } - } - - public static class AudioBufferSourceNodeX { - private final AudioBufferSourceNode source; - private final PannerNode panner; - private final GainNode gain; - private AudioBufferSourceNodeX(AudioBufferSourceNode source, PannerNode panner, GainNode gain) { - this.source = source; - this.panner = panner; - this.gain = gain; - } - } - - private static final AudioBuffer getBufferFor(String fileName) { - AudioBufferX ret = loadedSoundFiles.get(fileName); - if(ret == null) { - byte[] file = loadResourceBytes(fileName); - if(file == null) return null; - Uint8Array buf = Uint8Array.create(file.length); - buf.set(file); - ret = new AudioBufferX(decodeAudioAsync(buf.getBuffer())); - loadedSoundFiles.put(fileName, ret); - } - return ret.buffer; - } - - public static final int beginPlayback(String fileName, float x, float y, float z, float volume, float pitch) { - AudioBuffer b = getBufferFor(fileName); - if(b == null) return -1; - AudioBufferSourceNode s = audioctx.createBufferSource(); - s.setBuffer(b); - s.getPlaybackRate().setValue(pitch); - PannerNode p = audioctx.createPanner(); - p.setPosition(x, y, z); - p.setMaxDistance(volume * 16f + 0.1f); - p.setRolloffFactor(1f); - //p.setVelocity(0f, 0f, 0f); - p.setDistanceModel("linear"); - p.setPanningModel("HRTF"); - p.setConeInnerAngle(360f); - p.setConeOuterAngle(0f); - p.setConeOuterGain(0f); - p.setOrientation(0f, 1f, 0f); - GainNode g = audioctx.createGain(); - g.getGain().setValue(volume > 1.0f ? 1.0f : volume); - s.connect(g); - g.connect(p); - p.connect(audioctx.getDestination()); - s.start(0.0d, playbackOffsetDelay); - final int theId = ++playbackId; - activeSoundEffects.put(theId, new AudioBufferSourceNodeX(s, p, g)); - s.setOnEnded(new EventListener() { - - @Override - public void handleEvent(MediaEvent evt) { - activeSoundEffects.remove(theId); - } - - }); - return theId; - } - public static final int beginPlaybackStatic(String fileName, float volume, float pitch) { - AudioBuffer b = getBufferFor(fileName); - if(b == null) return -1; - AudioBufferSourceNode s = audioctx.createBufferSource(); - s.setBuffer(b); - s.getPlaybackRate().setValue(pitch); - GainNode g = audioctx.createGain(); - g.getGain().setValue(volume > 1.0f ? 1.0f : volume); - s.connect(g); - g.connect(audioctx.getDestination()); - s.start(0.0d, playbackOffsetDelay); - final int theId = ++playbackId; - activeSoundEffects.put(theId, new AudioBufferSourceNodeX(s, null, g)); - s.setOnEnded(new EventListener() { - @Override - public void handleEvent(MediaEvent evt) { - activeSoundEffects.remove(theId); - } - - }); - return playbackId; - } - public static final void setPitch(int id, float pitch) { - AudioBufferSourceNodeX b = activeSoundEffects.get(id); - if(b != null) { - b.source.getPlaybackRate().setValue(pitch); - } - } - public static final void setVolume(int id, float volume) { - AudioBufferSourceNodeX b = activeSoundEffects.get(id); - if(b != null) { - b.gain.getGain().setValue(volume); - if(b.panner != null) b.panner.setMaxDistance(volume * 16f + 0.1f); - } - } - public static float getVolume(int id) { - AudioBufferSourceNodeX b = activeSoundEffects.get(id); - if(b != null) { - return b.gain.getGain().getValue(); - } - return 0.0F; - } - public static final void moveSound(int id, float x, float y, float z, float vx, float vy, float vz) { - AudioBufferSourceNodeX b = activeSoundEffects.get(id); - if(b != null && b.panner != null) { - b.panner.setPosition(x, y, z); - //b.panner.setVelocity(vx, vy, vz); - } - } - public static final void endSound(int id) { - AudioBufferSourceNodeX b = activeSoundEffects.get(id); - if(b != null) { - b.source.stop(); - activeSoundEffects.remove(id); - } - } - public static final boolean isPlaying(int id) { - return activeSoundEffects.containsKey(id); - } - public static final void openConsole() { - - } - private static boolean connected = false; - public static final void voiceConnect(String channel) { - win.alert("voice channels are not implemented yet"); - connected = true; - } - public static final void voiceVolume(float volume) { - - } - public static final boolean voiceActive() { - return connected; - } - public static final boolean voiceRelayed() { - return connected; - } - public static final String[] voiceUsers() { - return new String[0]; - } - public static final String[] voiceUsersTalking() { - return new String[0]; - } - public static final void voiceEnd() { - connected = false; - } - public static final void doJavascriptCoroutines() { - - } - public static final long maxMemory() { - return 1024*1024*1024; - } - public static final long totalMemory() { - return 1024*1024*1024; - } - public static final long freeMemory() { - return 0l; - } - public static final void exit() { - - } - - @JSBody(params = { }, script = "return window.navigator.userAgent;") - public static native String getUserAgent(); - - private static String[] LWJGLKeyNames = new String[] {"NONE", "ESCAPE", "1", "2", "3", "4", "5", "6", "7", "8", "9", "0", "MINUS", "EQUALS", "BACK", "TAB", "Q", "W", "E", "R", "T", "Y", "U", "I", "O", "P", "LBRACKET", "RBRACKET", "RETURN", "LCONTROL", "A", "S", "D", "F", "G", "H", "J", "K", "L", "SEMICOLON", "APOSTROPHE", "GRAVE", "LSHIFT", "BACKSLASH", "Z", "X", "C", "V", "B", "N", "M", "COMMA", "PERIOD", "SLASH", "RSHIFT", "MULTIPLY", "LMENU", "SPACE", "CAPITAL", "F1", "F2", "F3", "F4", "F5", "F6", "F7", "F8", "F9", "F10", "NUMLOCK", "SCROLL", "NUMPAD7", "NUMPAD8", "NUMPAD9", "SUBTRACT", "NUMPAD4", "NUMPAD5", "NUMPAD6", "ADD", "NUMPAD1", "NUMPAD2", "NUMPAD3", "NUMPAD0", "DECIMAL", "null", "null", "null", "F11", "F12", "null", "null", "null", "null", "null", "null", "null", "null", "null", "null", "null", "F13", "F14", "F15", "F16", "F17", "F18", "null", "null", "null", "null", "null", "null", "KANA", "F19", "null", "null", "null", "null", "null", "null", "null", "CONVERT", "null", "NOCONVERT", "null", "YEN", "null", "null", "null", "null", "null", "null", "null", "null", "null", "null", "null", "null", "null", "null", "null", "NUMPADEQUALS", "null", "null", "CIRCUMFLEX", "AT", "COLON", "UNDERLINE", "KANJI", "STOP", "AX", "UNLABELED", "null", "null", "null", "null", "NUMPADENTER", "RCONTROL", "null", "null", "null", "null", "null", "null", "null", "null", "null", "SECTION", "null", "null", "null", "null", "null", "null", "null", "null", "null", "null", "null", "NUMPADCOMMA", "null", "DIVIDE", "null", "SYSRQ", "RMENU", "null", "null", "null", "null", "null", "null", "null", "null", "null", "null", "null", "FUNCTION", "PAUSE", "null", "HOME", "UP", "PRIOR", "null", "LEFT", "null", "RIGHT", "null", "END", "DOWN", "NEXT", "INSERT", "DELETE", "null", "null", "null", "null", "null", "null", "CLEAR", "LMETA", "RMETA", "APPS", "POWER", "SLEEP", "null", "null", "null", "null", "null", "null", "null", "null", "null", "null", "null", "null", "null", "null", "null", "null", "null", "null", "null", "null", "null", "null", "null", "null", "null", "null", "null", "null", "null", "null", "null", "null"}; - - private static int[] LWJGLKeyCodes = new int[] { - /* 0 */ -1, - /* 1 */ -1, - /* 2 */ -1, - /* 3 */ -1, - /* 4 */ -1, - /* 5 */ -1, - /* 6 */ -1, - /* 7 */ -1, - /* 8 */ 14, - /* 9 */ 15, - /* 10 */ -1, - /* 11 */ -1, - /* 12 */ -1, - /* 13 */ 28, - /* 14 */ -1, - /* 15 */ -1, - /* 16 */ 42, - /* 17 */ 29, - /* 18 */ 56, - /* 19 */ -1, - /* 20 */ -1, - /* 21 */ -1, - /* 22 */ -1, - /* 23 */ -1, - /* 24 */ -1, - /* 25 */ -1, - /* 26 */ -1, - /* 27 */ 1, - /* 28 */ -1, - /* 29 */ -1, - /* 30 */ -1, - /* 31 */ -1, - /* 32 */ 57, - /* 33 */ 210, - /* 34 */ 201, - /* 35 */ 207, - /* 36 */ 199, - /* 37 */ 203, - /* 38 */ 200, - /* 39 */ 205, - /* 40 */ 208, - /* 41 */ 205, - /* 42 */ 208, - /* 43 */ -1, - /* 44 */ -1, - /* 45 */ 210, - /* 46 */ 211, - /* 47 */ 211, - /* 48 */ 11, - /* 49 */ 2, - /* 50 */ 3, - /* 51 */ 4, - /* 52 */ 5, - /* 53 */ 6, - /* 54 */ 7, - /* 55 */ 8, - /* 56 */ 9, - /* 57 */ 10, - /* 58 */ -1, - /* 59 */ -1, - /* 60 */ -1, - /* 61 */ -1, - /* 62 */ -1, - /* 63 */ -1, - /* 64 */ -1, - /* 65 */ 30, - /* 66 */ 48, - /* 67 */ 46, - /* 68 */ 32, - /* 69 */ 18, - /* 70 */ 33, - /* 71 */ 34, - /* 72 */ 35, - /* 73 */ 23, - /* 74 */ 36, - /* 75 */ 37, - /* 76 */ 38, - /* 77 */ 50, - /* 78 */ 49, - /* 79 */ 24, - /* 80 */ 25, - /* 81 */ 16, - /* 82 */ 19, - /* 83 */ 31, - /* 84 */ 20, - /* 85 */ 22, - /* 86 */ 47, - /* 87 */ 17, - /* 88 */ 45, - /* 89 */ 21, - /* 90 */ 44, - /* 91 */ -1, - /* 92 */ -1, - /* 93 */ -1, - /* 94 */ -1, - /* 95 */ -1, - /* 96 */ -1, - /* 97 */ -1, - /* 98 */ -1, - /* 99 */ -1, - /* 100 */ -1, - /* 101 */ -1, - /* 102 */ -1, - /* 103 */ -1, - /* 104 */ -1, - /* 105 */ -1, - /* 106 */ -1, - /* 107 */ -1, - /* 108 */ -1, - /* 109 */ 12, - /* 110 */ 52, - /* 111 */ 53, - /* 112 */ -1, - /* 113 */ -1, - /* 114 */ -1, - /* 115 */ -1, - /* 116 */ -1, - /* 117 */ -1, - /* 118 */ -1, - /* 119 */ -1, - /* 120 */ -1, - /* 121 */ -1, - /* 122 */ -1, - /* 123 */ -1, - /* 124 */ -1, - /* 125 */ -1, - /* 126 */ -1, - /* 127 */ -1, - /* 128 */ -1, - /* 129 */ -1, - /* 130 */ -1, - /* 131 */ -1, - /* 132 */ -1, - /* 133 */ -1, - /* 134 */ -1, - /* 135 */ -1, - /* 136 */ -1, - /* 137 */ -1, - /* 138 */ -1, - /* 139 */ -1, - /* 140 */ -1, - /* 141 */ -1, - /* 142 */ -1, - /* 143 */ -1, - /* 144 */ -1, - /* 145 */ -1, - /* 146 */ -1, - /* 147 */ -1, - /* 148 */ -1, - /* 149 */ -1, - /* 150 */ -1, - /* 151 */ -1, - /* 152 */ -1, - /* 153 */ -1, - /* 154 */ -1, - /* 155 */ -1, - /* 156 */ -1, - /* 157 */ -1, - /* 158 */ -1, - /* 159 */ -1, - /* 160 */ -1, - /* 161 */ -1, - /* 162 */ -1, - /* 163 */ -1, - /* 164 */ -1, - /* 165 */ -1, - /* 166 */ -1, - /* 167 */ -1, - /* 168 */ -1, - /* 169 */ -1, - /* 170 */ -1, - /* 171 */ -1, - /* 172 */ -1, - /* 173 */ -1, - /* 174 */ -1, - /* 175 */ -1, - /* 176 */ -1, - /* 177 */ -1, - /* 178 */ -1, - /* 179 */ -1, - /* 180 */ -1, - /* 181 */ -1, - /* 182 */ -1, - /* 183 */ -1, - /* 184 */ -1, - /* 185 */ -1, - /* 186 */ 39, - /* 187 */ 13, - /* 188 */ 51, - /* 189 */ 12, - /* 190 */ 52, - /* 191 */ 53, - /* 192 */ -1, - /* 193 */ -1, - /* 194 */ -1, - /* 195 */ -1, - /* 196 */ -1, - /* 197 */ -1, - /* 198 */ -1, - /* 199 */ -1, - /* 200 */ -1, - /* 200 */ -1, - /* 201 */ -1, - /* 202 */ -1, - /* 203 */ -1, - /* 204 */ -1, - /* 205 */ -1, - /* 206 */ -1, - /* 207 */ -1, - /* 208 */ -1, - /* 209 */ -1, - /* 210 */ -1, - /* 211 */ -1, - /* 212 */ -1, - /* 213 */ -1, - /* 214 */ -1, - /* 215 */ -1, - /* 216 */ -1, - /* 217 */ -1, - /* 218 */ -1, - /* 219 */ 26, - /* 220 */ 43, - /* 221 */ 27, - /* 222 */ 40 - }; - - public static final int _wArrayByteLength(Object obj) { - return ((Int32Array)obj).getByteLength(); - } - - public static final Object _wCreateLowLevelIntBuffer(int len) { - return Int32Array.create(len); - } - - private static int appendbufferindex = 0; - private static Int32Array appendbuffer = Int32Array.create(ArrayBuffer.create(525000*4)); - - public static final void _wAppendLowLevelBuffer(Object arr) { - Int32Array a = ((Int32Array)arr); - if(appendbufferindex + a.getLength() < appendbuffer.getLength()) { - appendbuffer.set(a, appendbufferindex); - appendbufferindex += a.getLength(); - } - } - - public static final Object _wGetLowLevelBuffersAppended() { - Int32Array ret = Int32Array.create(appendbuffer.getBuffer(), 0, appendbufferindex); - appendbufferindex = 0; - return ret; - } - - private static int remapKey(int k) { - return (k > LWJGLKeyCodes.length || k < 0) ? -1 : LWJGLKeyCodes[k]; - } - - @JSFunctor - private static interface StupidFunctionResolveString extends JSObject { - void resolveStr(String s); - } - - private static boolean unpressCTRL = false; - - @Async - public static native String getClipboard(); - - private static void getClipboard(final AsyncCallback cb) { - final long start = System.currentTimeMillis(); - getClipboard0(new StupidFunctionResolveString() { - public void resolveStr(String s) { - if(System.currentTimeMillis() - start > 500l) { - unpressCTRL = true; - } - cb.complete(s); - } - }); - } - - @JSBody(params = { "cb" }, script = "if(!window.navigator.clipboard) cb(null); else window.navigator.clipboard.readText().then(function(s) { cb(s); }, function(s) { cb(null); });") - private static native void getClipboard0(StupidFunctionResolveString cb); - - @JSBody(params = { "str" }, script = "if(window.navigator.clipboard) window.navigator.clipboard.writeText(str);") - public static native void setClipboard(String str); - - @JSBody(params = { "obj" }, script = "return typeof obj === \"string\";") - private static native boolean isString(JSObject obj); - - public static final boolean fileExists(String path) { - return IndexedDBFilesystem.fileExists(path); - } - - public static final boolean directoryExists(String path) { - return IndexedDBFilesystem.directoryExists(path); - } - - public static final boolean pathExists(String path) { - return IndexedDBFilesystem.pathExists(path); - } - - public static final boolean exists(String path) { - return readFile(path) != null; - } - - public static final void mkdir(String path) { - String[] parts = path.split("/"); - String dir = parts[parts.length - 1]; - - if(path.endsWith("/")) { - String file = "placeholder.txt"; - path = path.replace(dir + "/", ""); - if(!path.endsWith("/")) { - path = path + "/"; - } - GL11.writeFile(path + dir + "/" + file, "UwU".getBytes()); - } else { - String file = "placeholder.txt"; - path = path.replace(dir, ""); - if(!path.endsWith("/")) { - path = path + "/"; - } - GL11.writeFile(path + dir + "/" + file, "UwU".getBytes()); - } - } - - public static final void writeFile(String path, byte[] data) { - IndexedDBFilesystem.writeFile(path, data); - } - - public static final byte[] readFile(String path) { - return IndexedDBFilesystem.readFile(path); - } - - public static final long getLastModified(String path) { - return IndexedDBFilesystem.getLastModified(path); - } - - public static final int getFileSize(String path) { - return IndexedDBFilesystem.getFileSize(path); - } - - public static final void renameFile(String oldPath, String newPath) { - IndexedDBFilesystem.renameFile(oldPath, newPath); - } - - public static final void copyFile(String oldPath, String newPath) { - IndexedDBFilesystem.copyFile(oldPath, newPath); - } - - public static final void deleteFile(String path) { - IndexedDBFilesystem.deleteFile(path); - } - - public static final Collection listFiles(String path, boolean listDirs, boolean recursiveDirs) { - return IndexedDBFilesystem.listFiles(path, listDirs, recursiveDirs); - } - - public static final Collection listFilesAndDirectories(String path) { - return listFiles(path, true, false); - } - - public static final Collection listFilesRecursive(String path) { - return listFiles(path, false, true); - } - - public static final FileEntry[] listFiles(String path) { - Collection entries = IndexedDBFilesystem.listFiles(path, true, false); - FileEntry[] entryArray = new FileEntry[entries.size()]; - - int i = 0; - for(FileEntry entry : entries) { - entryArray[i] = entry; - i = i + 1; - } - return entryArray; - } - - public static class FileEntry { - - public final String path; - public final boolean isDirectory; - public final long lastModified; - - public FileEntry(String path, boolean isDirectory, long lastModified) { - this.path = path; - this.isDirectory = isDirectory; - this.lastModified = lastModified; - } - - public String getName() { - int i = path.indexOf('/'); - if(i >= 0) { - return path.substring(i + 1); - }else { - return path; - } - } - - } - - private static String stripPath(String str) { - if(str.startsWith("/")) { - str = str.substring(1); - } - if(str.endsWith("/")) { - str = str.substring(0, str.length() - 1); - } - return str; - } - - @JSBody(params = { "name", "cvs" }, script = "var a=document.createElement(\"a\");a.href=URL.createObjectURL(new Blob([cvs],{type:\"application/octet-stream\"}));a.download=name;a.click();URL.revokeObjectURL(a.href);") - private static native void downloadFile0(String name, ArrayBuffer cvs); - - public static final void downloadFile(String filename, byte[] data) { - Uint8Array b = Uint8Array.create(data.length); - b.set(data); - downloadFile0(filename, b.getBuffer()); - } - - public static boolean isCompressed(byte[] b) { - if(b == null || b.length < 2) { - return false; - } - return (b[0] == (byte) 0x1F) && (b[1] == (byte) 0x8B); - } - - public static boolean escapeKeyPressed() { - return getEventKey() == 1 || escapeKeyPressed2(); - } - - @JSBody(params = {}, script = "return document.esc;") - public static native boolean escapeKeyPressed2(); - -} \ No newline at end of file diff --git a/src/net/lax1dude/eaglercraft/adapter/FileChooserResult.java b/src/net/lax1dude/eaglercraft/adapter/FileChooserResult.java deleted file mode 100644 index 5ec8561..0000000 --- a/src/net/lax1dude/eaglercraft/adapter/FileChooserResult.java +++ /dev/null @@ -1,26 +0,0 @@ -package net.lax1dude.eaglercraft.adapter; - -/** - * Copyright (c) 2022-2023 LAX1DUDE. All Rights Reserved. - * - * WITH THE EXCEPTION OF PATCH FILES, MINIFIED JAVASCRIPT, AND ALL FILES - * NORMALLY FOUND IN AN UNMODIFIED MINECRAFT RESOURCE PACK, YOU ARE NOT ALLOWED - * TO SHARE, DISTRIBUTE, OR REPURPOSE ANY FILE USED BY OR PRODUCED BY THE - * SOFTWARE IN THIS REPOSITORY WITHOUT PRIOR PERMISSION FROM THE PROJECT AUTHOR. - * - * NOT FOR COMMERCIAL OR MALICIOUS USE - * - * (please read the 'LICENSE' file this repo's root directory for more info) - * - */ -public class FileChooserResult { - - public final String fileName; - public final byte[] fileData; - - public FileChooserResult(String fileName, byte[] fileData) { - this.fileName = fileName; - this.fileData = fileData; - } - -} \ No newline at end of file diff --git a/src/net/lax1dude/eaglercraft/adapter/teavm/BufferConverter.java b/src/net/lax1dude/eaglercraft/adapter/teavm/BufferConverter.java deleted file mode 100644 index 6125bc7..0000000 --- a/src/net/lax1dude/eaglercraft/adapter/teavm/BufferConverter.java +++ /dev/null @@ -1,34 +0,0 @@ -package net.lax1dude.eaglercraft.adapter.teavm; - -import java.nio.ByteBuffer; -import java.nio.FloatBuffer; -import java.nio.IntBuffer; -import java.nio.ShortBuffer; - -public class BufferConverter { - - public static final byte[] convertByteBuffer(ByteBuffer b) { - byte[] ret = new byte[b.limit() - b.position()]; - b.get(ret); - return ret; - } - - public static final short[] convertShortBuffer(ShortBuffer b) { - short[] ret = new short[b.limit() - b.position()]; - b.get(ret); - return ret; - } - - public static final int[] convertIntBuffer(IntBuffer b) { - int[] ret = new int[b.limit() - b.position()]; - b.get(ret); - return ret; - } - - public static final float[] convertFloatBuffer(FloatBuffer b) { - float[] ret = new float[b.limit() - b.position()]; - b.get(ret); - return ret; - } - -} diff --git a/src/net/lax1dude/eaglercraft/adapter/teavm/WebGL2RenderingContext.java b/src/net/lax1dude/eaglercraft/adapter/teavm/WebGL2RenderingContext.java deleted file mode 100644 index 91c0487..0000000 --- a/src/net/lax1dude/eaglercraft/adapter/teavm/WebGL2RenderingContext.java +++ /dev/null @@ -1,42 +0,0 @@ -package net.lax1dude.eaglercraft.adapter.teavm; - -import org.teavm.jso.webgl.WebGLRenderingContext; - -public interface WebGL2RenderingContext extends WebGLRenderingContext { - - int TEXTURE_MAX_LEVEL = 0x0000813D; - int TEXTURE_MAX_ANISOTROPY_EXT = 0x000084FE; - int UNSIGNED_INT_24_8 = 0x000084FA; - int ANY_SAMPLES_PASSED = 0x00008D6A; - int QUERY_RESULT = 0x00008866; - int QUERY_RESULT_AVAILABLE = 0x00008867; - int DEPTH24_STENCIL8 = 0x000088F0; - int DEPTH_COMPONENT32F = 0x00008CAC; - int READ_FRAMEBUFFER = 0x00008CA8; - int DRAW_FRAMEBUFFER = 0x00008CA9; - int RGB8 = 0x00008051; - int RGBA8 = 0x00008058; - - WebGLQuery createQuery(); - - void beginQuery(int p1, WebGLQuery obj); - - void endQuery(int p1); - - void deleteQuery(WebGLQuery obj); - - int getQueryParameter(WebGLQuery obj, int p2); - - WebGLVertexArray createVertexArray(); - - void deleteVertexArray(WebGLVertexArray obj); - - void bindVertexArray(WebGLVertexArray obj); - - void renderbufferStorageMultisample(int p1, int p2, int p3, int p4, int p5); - - void blitFramebuffer(int p1, int p2, int p3, int p4, int p5, int p6, int p7, int p8, int p9, int p10); - - void drawBuffers(int[] p1); - -} diff --git a/src/net/lax1dude/eaglercraft/adapter/teavm/WebGLQuery.java b/src/net/lax1dude/eaglercraft/adapter/teavm/WebGLQuery.java deleted file mode 100644 index 40c65c0..0000000 --- a/src/net/lax1dude/eaglercraft/adapter/teavm/WebGLQuery.java +++ /dev/null @@ -1,6 +0,0 @@ -package net.lax1dude.eaglercraft.adapter.teavm; - -import org.teavm.jso.JSObject; - -public interface WebGLQuery extends JSObject { -} diff --git a/src/net/lax1dude/eaglercraft/adapter/teavm/WebGLVertexArray.java b/src/net/lax1dude/eaglercraft/adapter/teavm/WebGLVertexArray.java deleted file mode 100644 index 34d1c5f..0000000 --- a/src/net/lax1dude/eaglercraft/adapter/teavm/WebGLVertexArray.java +++ /dev/null @@ -1,6 +0,0 @@ -package net.lax1dude.eaglercraft.adapter.teavm; - -import org.teavm.jso.JSObject; - -public interface WebGLVertexArray extends JSObject { -} diff --git a/src/net/minecraft/client/Minecraft.java b/src/net/minecraft/client/Minecraft.java index 63ba314..e5e9ae8 100644 --- a/src/net/minecraft/client/Minecraft.java +++ b/src/net/minecraft/client/Minecraft.java @@ -1,8 +1,10 @@ package net.minecraft.client; -import net.PeytonPlayz585.input.Keyboard; -import net.PeytonPlayz585.input.Mouse; -import net.PeytonPlayz585.opengl.GL11; +import org.lwjgl.input.Keyboard; +import org.lwjgl.input.Mouse; +import org.lwjgl.opengl.Display; +import org.lwjgl.opengl.GL11; + import net.minecraft.src.AchievementList; import net.minecraft.src.AxisAlignedBB; import net.minecraft.src.Block; @@ -136,9 +138,9 @@ public class Minecraft implements Runnable { public Minecraft() { StatList.func_27360_a(); - this.tempDisplayHeight = GL11.getCanvasHeight(); - this.displayWidth = GL11.getCanvasWidth(); - this.displayHeight = GL11.getCanvasHeight(); + this.tempDisplayHeight = GL11.EaglerAdapterImpl2.getCanvasHeight(); + this.displayWidth = GL11.EaglerAdapterImpl2.getCanvasWidth(); + this.displayHeight = GL11.EaglerAdapterImpl2.getCanvasHeight(); theMinecraft = this; } @@ -233,7 +235,7 @@ public class Minecraft implements Runnable { //Emulate Display.swapBuffers() GL11.glFlush(); - GL11.updateDisplay(); + Display.update(); GL11.optimize(); } @@ -370,7 +372,7 @@ public class Minecraft implements Runnable { this.theWorld.updatingLighting(); } - GL11.updateDisplay(); + Display.update(); if(this.thePlayer != null && this.thePlayer.isEntityInsideOpaqueBlock()) { this.gameSettings.thirdPersonView = false; @@ -393,9 +395,9 @@ public class Minecraft implements Runnable { this.guiAchievement.updateAchievementWindow(); Thread.yield(); - if(GL11.getCanvasWidth() != this.displayWidth || GL11.getCanvasHeight() != this.displayHeight) { - this.displayWidth = GL11.getCanvasWidth(); - this.displayHeight = GL11.getCanvasHeight(); + if(GL11.EaglerAdapterImpl2.getCanvasWidth() != this.displayWidth || GL11.EaglerAdapterImpl2.getCanvasHeight() != this.displayHeight) { + this.displayWidth = GL11.EaglerAdapterImpl2.getCanvasWidth(); + this.displayHeight = GL11.EaglerAdapterImpl2.getCanvasHeight(); if(this.displayWidth <= 0) { this.displayWidth = 1; } @@ -784,19 +786,19 @@ public class Minecraft implements Runnable { this.displayInGameMenu(); } - if(Keyboard.getEventKey() == 33 && GL11.isKeyDown(2)) { + if(Keyboard.getEventKey() == 33 && Keyboard.isKeyDown(2)) { this.gameSettings.hideGUI = !this.gameSettings.hideGUI; } - if(Keyboard.getEventKey() == 33 && GL11.isKeyDown(4)) { + if(Keyboard.getEventKey() == 33 && Keyboard.isKeyDown(4)) { this.gameSettings.showDebugInfo = !this.gameSettings.showDebugInfo; } - if(Keyboard.getEventKey() == 33 && GL11.isKeyDown(6)) { + if(Keyboard.getEventKey() == 33 && Keyboard.isKeyDown(6)) { this.gameSettings.thirdPersonView = !this.gameSettings.thirdPersonView; } - if(Keyboard.getEventKey() == 33 && GL11.isKeyDown(9)) { + if(Keyboard.getEventKey() == 33 && Keyboard.isKeyDown(9)) { this.gameSettings.smoothCamera = !this.gameSettings.smoothCamera; } diff --git a/src/net/minecraft/src/ChunkLoader.java b/src/net/minecraft/src/ChunkLoader.java index 74a794a..aef6d81 100644 --- a/src/net/minecraft/src/ChunkLoader.java +++ b/src/net/minecraft/src/ChunkLoader.java @@ -5,7 +5,7 @@ import java.io.ByteArrayOutputStream; import java.io.IOException; import java.util.Iterator; -import net.PeytonPlayz585.opengl.GL11; +import net.PeytonPlayz585.fileutils.File; public class ChunkLoader implements IChunkLoader { private String saveDir; @@ -34,7 +34,7 @@ public class ChunkLoader implements IChunkLoader { public Chunk loadChunk(World var1, int var2, int var3) throws IOException { String var4 = this.chunkFileForXZ(var2, var3); - byte[] chunkData = GL11.readFile(var4); + byte[] chunkData = File.readFile(var4); if(chunkData != null) { try { @@ -45,7 +45,7 @@ public class ChunkLoader implements IChunkLoader { int z = var6.getInteger("zPos"); if(var2 != x || var3 != z) { String var7 = this.chunkFileForXZ(x, z); - GL11.renameFile(var4, var7); + File.renameFile(var4, var7); return null; } @@ -53,7 +53,7 @@ public class ChunkLoader implements IChunkLoader { var7.func_25124_i(); return var7; } catch(IOException e) { - GL11.deleteFile(var4); + File.deleteFile(var4); return null; } } else { @@ -66,9 +66,9 @@ public class ChunkLoader implements IChunkLoader { String var3 = this.chunkFileForXZ(var2.xPosition, var2.zPosition); ByteArrayOutputStream var5 = new ByteArrayOutputStream(); - if(GL11.exists(var3)) { + if(File.exists(var3)) { WorldInfo var4 = var1.getWorldInfo(); - var4.setSizeOnDisk(var4.getSizeOnDisk() - GL11.getFileSize(var3)); + var4.setSizeOnDisk(var4.getSizeOnDisk() - File.getFileSize(var3)); } NBTTagCompound var6 = new NBTTagCompound(); @@ -84,9 +84,9 @@ public class ChunkLoader implements IChunkLoader { } var5.flush(); - GL11.writeFile(var3, var5.toByteArray()); + File.writeFile(var3, var5.toByteArray()); WorldInfo var8 = var1.getWorldInfo(); - var8.setSizeOnDisk(var8.getSizeOnDisk() + GL11.getFileSize(var3)); + var8.setSizeOnDisk(var8.getSizeOnDisk() + File.getFileSize(var3)); } public static void storeChunkInCompound(Chunk var0, World var1, NBTTagCompound var2) { diff --git a/src/net/minecraft/src/EaglerSaveFormat.java b/src/net/minecraft/src/EaglerSaveFormat.java index 7f5ba8e..d96b245 100644 --- a/src/net/minecraft/src/EaglerSaveFormat.java +++ b/src/net/minecraft/src/EaglerSaveFormat.java @@ -11,9 +11,8 @@ import java.util.Collection; import java.util.List; import java.util.function.Consumer; -import net.PeytonPlayz585.opengl.GL11; - -import static net.PeytonPlayz585.opengl.GL11.FileEntry; +import net.PeytonPlayz585.fileutils.File; +import net.PeytonPlayz585.fileutils.FileEntry; public class EaglerSaveFormat implements ISaveFormat { @@ -37,7 +36,7 @@ public class EaglerSaveFormat implements ISaveFormat { //Returns a list a worlds public List func_22176_b() { ArrayList lst = new ArrayList<>(); - GL11.listFilesAndDirectories(saveDir).forEach(new Consumer() { + File.listFilesAndDirectories(saveDir).forEach(new Consumer() { @Override public void accept(FileEntry t) { if(!t.isDirectory) { @@ -45,7 +44,7 @@ public class EaglerSaveFormat implements ISaveFormat { } String folderName = t.getName(); String dir = t.path; - byte[] lvl = GL11.readFile(dir + "/level.dat"); + byte[] lvl = File.readFile(dir + "/level.dat"); if(lvl != null) { try { NBTBase nbt = NBTBase.readTag(new DataInputStream(new ByteArrayInputStream(lvl))); @@ -78,7 +77,7 @@ public class EaglerSaveFormat implements ISaveFormat { //Returns world info for the world public WorldInfo func_22173_b(String var1) { - byte[] lvl = GL11.readFile(saveDir + "/" + var1 + "/level.dat"); + byte[] lvl = File.readFile(saveDir + "/" + var1 + "/level.dat"); if(lvl != null) { try { NBTBase nbt = NBTBase.readTag(new DataInputStream(new ByteArrayInputStream(lvl))); @@ -113,7 +112,7 @@ public class EaglerSaveFormat implements ISaveFormat { if(var2.contains("/saves/saves/")) { var2 = var2.replace("/saves/saves/", "/saves/"); } - byte[] lvl = GL11.readFile(saveDir + "/" + var1 + "/level.dat"); + byte[] lvl = File.readFile(saveDir + "/" + var1 + "/level.dat"); if(lvl != null) { try { NBTBase nbt = NBTBase.readTag(new DataInputStream(new ByteArrayInputStream(lvl))); @@ -122,7 +121,7 @@ public class EaglerSaveFormat implements ISaveFormat { w.setString("LevelName", var2); ByteArrayOutputStream out = new ByteArrayOutputStream(lvl.length + 16 + var2.length() * 2); NBTBase.writeTag(w, new DataOutputStream(out)); - GL11.writeFile(saveDir + "/" + var1 + "/level.dat", out.toByteArray()); + File.writeFile(saveDir + "/" + var1 + "/level.dat", out.toByteArray()); }else { throw new IOException("file '" + saveDir + "/" + var1 + "/level.dat' does not contain an NBTTagCompound"); } diff --git a/src/net/minecraft/src/EaglerSaveHandler.java b/src/net/minecraft/src/EaglerSaveHandler.java index 6a14337..7574516 100644 --- a/src/net/minecraft/src/EaglerSaveHandler.java +++ b/src/net/minecraft/src/EaglerSaveHandler.java @@ -7,7 +7,7 @@ import java.io.DataOutputStream; import java.io.IOException; import java.util.List; -import net.PeytonPlayz585.opengl.GL11; +import net.PeytonPlayz585.fileutils.File; public class EaglerSaveHandler implements ISaveHandler { @@ -18,7 +18,7 @@ public class EaglerSaveHandler implements ISaveHandler { } public WorldInfo loadWorldInfo() { - byte[] file = GL11.readFile(saveDir + "/level.dat"); + byte[] file = File.readFile(saveDir + "/level.dat"); if(file != null) { try { NBTBase nbt = NBTBase.readTag(new DataInputStream(new ByteArrayInputStream(file))); @@ -55,7 +55,7 @@ public class EaglerSaveHandler implements ISaveHandler { e.printStackTrace(); return; } - GL11.writeFile(saveDir + "/level.dat", out.toByteArray()); + File.writeFile(saveDir + "/level.dat", out.toByteArray()); } @Override @@ -69,7 +69,7 @@ public class EaglerSaveHandler implements ISaveHandler { e.printStackTrace(); return; } - GL11.writeFile(saveDir + "/level.dat", out.toByteArray()); + File.writeFile(saveDir + "/level.dat", out.toByteArray()); } public String func_28113_a(String var1) { diff --git a/src/net/minecraft/src/EntityRenderer.java b/src/net/minecraft/src/EntityRenderer.java index 38fc765..534965e 100644 --- a/src/net/minecraft/src/EntityRenderer.java +++ b/src/net/minecraft/src/EntityRenderer.java @@ -6,6 +6,7 @@ import java.util.List; import net.PeytonPlayz585.glemu.GameOverlayFramebuffer; import net.minecraft.client.Minecraft; import org.lwjgl.input.Mouse; +import org.lwjgl.opengl.Display; import org.lwjgl.opengl.GL11; import org.lwjgl.util.glu.GLU; @@ -328,7 +329,7 @@ public class EntityRenderer { } public void updateCameraAndRender(float var1) { - if(!GL11.isFocused()) { + if(!Display.isFocused()) { this.mc.displayInGameMenu(); } else { this.prevFrameTime = System.currentTimeMillis(); diff --git a/src/net/minecraft/src/FilesystemUtils.java b/src/net/minecraft/src/FilesystemUtils.java index ec08984..290af3b 100644 --- a/src/net/minecraft/src/FilesystemUtils.java +++ b/src/net/minecraft/src/FilesystemUtils.java @@ -2,23 +2,24 @@ package net.minecraft.src; import java.util.Collection; -import net.PeytonPlayz585.opengl.GL11; +import net.PeytonPlayz585.fileutils.File; +import net.PeytonPlayz585.fileutils.FileEntry; public class FilesystemUtils { public static void recursiveDeleteDirectory(String dir) { - Collection lst = GL11.listFiles(dir, true, true); - for(GL11.FileEntry t : lst) { + Collection lst = File.listFiles(dir, true, true); + for(FileEntry t : lst) { if(!t.isDirectory) { - GL11.deleteFile(t.path); + File.deleteFile(t.path); } } - for(GL11.FileEntry t : lst) { + for(FileEntry t : lst) { if(t.isDirectory) { - GL11.deleteFile(t.path); + File.deleteFile(t.path); } } - GL11.deleteFile(dir); + File.deleteFile(dir); } } diff --git a/src/net/minecraft/src/FontRenderer.java b/src/net/minecraft/src/FontRenderer.java index 77d89c7..5226ede 100644 --- a/src/net/minecraft/src/FontRenderer.java +++ b/src/net/minecraft/src/FontRenderer.java @@ -8,8 +8,8 @@ import java.util.Map; import org.lwjgl.opengl.GL11; -import net.lax1dude.eaglercraft.BufferedImage; -import net.lax1dude.eaglercraft.ImageIO; +import net.PeytonPlayz585.awt.image.BufferedImage; +import net.PeytonPlayz585.awt.image.ImageIO; public class FontRenderer { private int[] charWidth = new int[256]; diff --git a/src/net/minecraft/src/GLAllocation.java b/src/net/minecraft/src/GLAllocation.java index 2952686..e34afcb 100644 --- a/src/net/minecraft/src/GLAllocation.java +++ b/src/net/minecraft/src/GLAllocation.java @@ -49,14 +49,14 @@ public class GLAllocation { } public static ByteBuffer createDirectByteBuffer(int par0) { - return GL11.isWebGL ? ByteBuffer.wrap(new byte[par0]).order(ByteOrder.nativeOrder()) : ByteBuffer.allocateDirect(par0).order(ByteOrder.nativeOrder()); + return ByteBuffer.wrap(new byte[par0]).order(ByteOrder.nativeOrder()); } public static IntBuffer createDirectIntBuffer(int par0) { - return GL11.isWebGL ? IntBuffer.wrap(new int[par0]) : createDirectByteBuffer(par0 << 2).asIntBuffer(); + return IntBuffer.wrap(new int[par0]); } public static FloatBuffer createDirectFloatBuffer(int par0) { - return GL11.isWebGL ? FloatBuffer.wrap(new float[par0]) : createDirectByteBuffer(par0 << 2).asFloatBuffer(); + return FloatBuffer.wrap(new float[par0]); } } diff --git a/src/net/minecraft/src/GameSettings.java b/src/net/minecraft/src/GameSettings.java index a9c8e2d..996af1d 100644 --- a/src/net/minecraft/src/GameSettings.java +++ b/src/net/minecraft/src/GameSettings.java @@ -1,12 +1,13 @@ package net.minecraft.src; import java.io.BufferedReader; + import java.io.ByteArrayInputStream; import java.io.ByteArrayOutputStream; import java.io.InputStreamReader; import java.io.PrintWriter; -import net.PeytonPlayz585.opengl.GL11; +import net.PeytonPlayz585.fileutils.File; import net.minecraft.client.Minecraft; import org.lwjgl.input.Keyboard; @@ -177,11 +178,11 @@ public class GameSettings { public void loadOptions() { try { - if(!GL11.exists(this.optionsFile)) { + if(!File.exists(this.optionsFile)) { return; } - ByteArrayInputStream byteArrayInputStream = new ByteArrayInputStream(GL11.readFile(this.optionsFile)); + ByteArrayInputStream byteArrayInputStream = new ByteArrayInputStream(File.readFile(this.optionsFile)); InputStreamReader inputStreamReader = new InputStreamReader(byteArrayInputStream, "UTF-8"); BufferedReader var1 = new BufferedReader(inputStreamReader); String var2 = ""; @@ -301,7 +302,7 @@ public class GameSettings { var1.flush(); byte[] data = byteArrayOutputStream.toByteArray(); - GL11.writeFile(this.optionsFile, data); + File.writeFile(this.optionsFile, data); var1.close(); } catch (Exception var3) { diff --git a/src/net/minecraft/src/GuiIngame.java b/src/net/minecraft/src/GuiIngame.java index e2a5cdc..3aed992 100644 --- a/src/net/minecraft/src/GuiIngame.java +++ b/src/net/minecraft/src/GuiIngame.java @@ -165,9 +165,9 @@ public class GuiIngame extends Gui { var8.drawStringWithShadow(this.mc.func_6262_n(), 2, 22, 16777215); var8.drawStringWithShadow(this.mc.func_6245_o(), 2, 32, 16777215); var8.drawStringWithShadow(this.mc.func_21002_o(), 2, 42, 16777215); - long var24 = GL11.maxMemory(); - long var29 = GL11.totalMemory(); - long var30 = GL11.freeMemory(); + long var24 = GL11.EaglerAdapterImpl2.maxMemory(); + long var29 = GL11.EaglerAdapterImpl2.totalMemory(); + long var30 = GL11.EaglerAdapterImpl2.freeMemory(); long var21 = var29 - var30; var23 = "Used memory: " + var21 * 100L / var24 + "% (" + var21 / 1024L / 1024L + "MB) of " + var24 / 1024L / 1024L + "MB"; this.drawString(var8, var23, var6 - var8.getStringWidth(var23) - 2, 2, 14737632); diff --git a/src/net/minecraft/src/IsoImageBuffer.java b/src/net/minecraft/src/IsoImageBuffer.java index b7819e1..fc9af18 100644 --- a/src/net/minecraft/src/IsoImageBuffer.java +++ b/src/net/minecraft/src/IsoImageBuffer.java @@ -1,6 +1,6 @@ package net.minecraft.src; -import net.lax1dude.eaglercraft.BufferedImage; +import net.PeytonPlayz585.awt.image.BufferedImage; public class IsoImageBuffer { public BufferedImage field_1348_a; diff --git a/src/net/minecraft/src/LoadingScreenRenderer.java b/src/net/minecraft/src/LoadingScreenRenderer.java index 0465a1a..5270d3d 100644 --- a/src/net/minecraft/src/LoadingScreenRenderer.java +++ b/src/net/minecraft/src/LoadingScreenRenderer.java @@ -1,6 +1,8 @@ package net.minecraft.src; import net.minecraft.client.Minecraft; + +import org.lwjgl.opengl.Display; import org.lwjgl.opengl.GL11; public class LoadingScreenRenderer implements IProgressUpdate { @@ -109,7 +111,7 @@ public class LoadingScreenRenderer implements IProgressUpdate { this.mc.fontRenderer.drawStringWithShadow(this.field_1007_c, (var5 - this.mc.fontRenderer.getStringWidth(this.field_1007_c)) / 2, var6 / 2 - 4 - 16, 16777215); this.mc.fontRenderer.drawStringWithShadow(this.field_1004_a, (var5 - this.mc.fontRenderer.getStringWidth(this.field_1004_a)) / 2, var6 / 2 - 4 + 8, 16777215); - GL11.updateDisplay(); + Display.update(); try { Thread.yield(); diff --git a/src/net/minecraft/src/MapItemRenderer.java b/src/net/minecraft/src/MapItemRenderer.java index 211552e..66ad2a1 100644 --- a/src/net/minecraft/src/MapItemRenderer.java +++ b/src/net/minecraft/src/MapItemRenderer.java @@ -3,7 +3,7 @@ package net.minecraft.src; import java.util.Iterator; import org.lwjgl.opengl.GL11; -import net.lax1dude.eaglercraft.BufferedImage; +import net.PeytonPlayz585.awt.image.BufferedImage; public class MapItemRenderer { private int[] field_28159_a = new int[16384]; diff --git a/src/net/minecraft/src/MapStorage.java b/src/net/minecraft/src/MapStorage.java index 6be445e..3987fe5 100644 --- a/src/net/minecraft/src/MapStorage.java +++ b/src/net/minecraft/src/MapStorage.java @@ -10,7 +10,7 @@ import java.util.Iterator; import java.util.List; import java.util.Map; -import net.PeytonPlayz585.opengl.GL11; +import net.PeytonPlayz585.fileutils.File; public class MapStorage { private ISaveHandler field_28191_a; @@ -31,14 +31,14 @@ public class MapStorage { if(this.field_28191_a != null) { try { String var4 = this.field_28191_a.func_28113_a(var2); - if(var4 != null && GL11.exists(var4)) { + if(var4 != null && File.exists(var4)) { try { var3 = (MapDataBase)var1.getConstructor(new Class[]{String.class}).newInstance(new Object[]{var2}); } catch (Exception var7) { throw new RuntimeException("Failed to instantiate " + var1.toString(), var7); } - ByteArrayInputStream var5 = new ByteArrayInputStream(GL11.readFile(var4)); + ByteArrayInputStream var5 = new ByteArrayInputStream(File.readFile(var4)); NBTTagCompound var6 = CompressedStreamTools.func_1138_a(var5); var5.close(); var3.readFromNBT(var6.getCompoundTag("data")); @@ -92,7 +92,7 @@ public class MapStorage { var4.setCompoundTag("data", var3); ByteArrayOutputStream var5 = new ByteArrayOutputStream(); CompressedStreamTools.writeGzippedCompoundToOutputStream(var4, var5); - GL11.writeFile(var2, var5.toByteArray()); + File.writeFile(var2, var5.toByteArray()); var5.close(); } } catch (Exception var6) { @@ -110,8 +110,8 @@ public class MapStorage { } String var1 = this.field_28191_a.func_28113_a("idcounts"); - if(var1 != null && GL11.exists(var1)) { - DataInputStream var2 = new DataInputStream(new ByteArrayInputStream(GL11.readFile(var1))); + if(var1 != null && File.exists(var1)) { + DataInputStream var2 = new DataInputStream(new ByteArrayInputStream(File.readFile(var1))); NBTTagCompound var3 = CompressedStreamTools.func_1141_a(var2); var2.close(); Iterator var4 = var3.func_28110_c().iterator(); @@ -159,7 +159,7 @@ public class MapStorage { ByteArrayOutputStream baos = new ByteArrayOutputStream(); DataOutputStream var9 = new DataOutputStream(baos); CompressedStreamTools.func_1139_a(var4, var9); - GL11.writeFile(var3, baos.toByteArray()); + File.writeFile(var3, baos.toByteArray()); var9.close(); } } catch (Exception var8) { diff --git a/src/net/minecraft/src/MouseHelper.java b/src/net/minecraft/src/MouseHelper.java index fcf9798..d8a8965 100644 --- a/src/net/minecraft/src/MouseHelper.java +++ b/src/net/minecraft/src/MouseHelper.java @@ -1,6 +1,6 @@ package net.minecraft.src; -import net.PeytonPlayz585.input.Mouse; +import org.lwjgl.input.Mouse; public class MouseHelper { public int deltaX; diff --git a/src/net/minecraft/src/NetClientHandler.java b/src/net/minecraft/src/NetClientHandler.java index b80da0b..eb9d8ed 100644 --- a/src/net/minecraft/src/NetClientHandler.java +++ b/src/net/minecraft/src/NetClientHandler.java @@ -7,7 +7,8 @@ import java.io.IOException; //import java.net.UnknownHostException; import java.util.List; -import net.PeytonPlayz585.opengl.GL11; +import org.lwjgl.opengl.GL11; + import net.PeytonPlayz585.socket.Socket; import net.minecraft.client.Minecraft; @@ -31,7 +32,7 @@ public class NetClientHandler extends NetHandler { uri = var2.substring(6); }else if(!var2.contains("://")){ uri = var2; - if(GL11.isSSLPage()) { + if(GL11.EaglerAdapterImpl2.isSSLPage()) { var2 = "wss://" + var2; } else { var2 = "ws://" + var2; diff --git a/src/net/minecraft/src/RenderEngine.java b/src/net/minecraft/src/RenderEngine.java index 5c587c3..ba00c32 100644 --- a/src/net/minecraft/src/RenderEngine.java +++ b/src/net/minecraft/src/RenderEngine.java @@ -12,8 +12,7 @@ import java.util.List; import java.util.Map; import org.lwjgl.opengl.GL11; -import net.lax1dude.eaglercraft.BufferedImage; -import net.lax1dude.eaglercraft.adapter.EaglerAdapterImpl2.TextureGL; +import net.PeytonPlayz585.awt.image.BufferedImage; public class RenderEngine { public static boolean useMipmaps = false; @@ -390,7 +389,7 @@ public class RenderEngine { } private BufferedImage readTextureImage(InputStream var1) throws IOException { - return GL11.loadPNG(((ByteArrayInputStream)var1).readAllBytes()); + return GL11.EaglerAdapterImpl2.loadPNG(((ByteArrayInputStream)var1).readAllBytes()); } public void bindTexture(int var1) { diff --git a/src/net/minecraft/src/RenderHelper.java b/src/net/minecraft/src/RenderHelper.java index 577495a..80e6efb 100644 --- a/src/net/minecraft/src/RenderHelper.java +++ b/src/net/minecraft/src/RenderHelper.java @@ -16,6 +16,7 @@ public class RenderHelper { GL11.glEnable(GL11.GL_LIGHT1); GL11.glEnable(GL11.GL_COLOR_MATERIAL); GL11.glColorMaterial(GL11.GL_FRONT_AND_BACK, GL11.GL_AMBIENT_AND_DIFFUSE); - GL11.copyModelToLightMatrix(); + GL11.copyModelToLightMatrix2(); + GL11.flipBothLightMatrix(); } } diff --git a/src/net/minecraft/src/SoundManager.java b/src/net/minecraft/src/SoundManager.java index 7d046ef..015900a 100644 --- a/src/net/minecraft/src/SoundManager.java +++ b/src/net/minecraft/src/SoundManager.java @@ -3,7 +3,7 @@ package net.minecraft.src; import java.util.ArrayList; import java.util.List; -import net.PeytonPlayz585.opengl.GL11; +import org.lwjgl.opengl.GL11; public class SoundManager { @@ -24,7 +24,7 @@ public class SoundManager { public void onSoundOptionsChanged() { for(int i = 0; i < sounds.size(); i++) { - if(!GL11.isPlaying(sounds.get(i))) { + if(!GL11.EaglerAdapterImpl2.isPlaying(sounds.get(i))) { sounds.remove(i); } } @@ -32,24 +32,24 @@ public class SoundManager { if(loaded) { if(this.options.musicVolume == 0.0F) { if(BgMusic != -1) { - GL11.endSound(BgMusic); + GL11.EaglerAdapterImpl2.endSound(BgMusic); } } else { if(BgMusic != -1) { - GL11.setVolume(BgMusic, this.options.musicVolume); + GL11.EaglerAdapterImpl2.setVolume(BgMusic, this.options.musicVolume); } } if(this.options.soundVolume == 0.0F) { for(Integer i : sounds) { if(i != -1) { - GL11.endSound(i); + GL11.EaglerAdapterImpl2.endSound(i); } } } else { for(Integer i : sounds) { if(i != -1) { - GL11.setVolume(i, this.options.soundVolume); + GL11.EaglerAdapterImpl2.setVolume(i, this.options.soundVolume); } } } @@ -70,13 +70,13 @@ public class SoundManager { public void playRandomMusicIfReady() { for(int i = 0; i < sounds.size(); i++) { - if(!GL11.isPlaying(sounds.get(i))) { + if(!GL11.EaglerAdapterImpl2.isPlaying(sounds.get(i))) { sounds.remove(i); } } if(loaded && this.options.musicVolume != 0.0F) { - if(!GL11.isPlaying(BgMusic)) { + if(!GL11.EaglerAdapterImpl2.isPlaying(BgMusic)) { try { if(this.ticksBeforeMusic > 0) { --this.ticksBeforeMusic; @@ -86,7 +86,7 @@ public class SoundManager { //Apparently I DO NOT know how to use random.nextInt int var1 = rand.nextInt(music.length); this.ticksBeforeMusic = this.rand.nextInt(12000) + 12000; - BgMusic = GL11.beginPlaybackStatic(music[var1].replace(".", "/").replace("_", "."), this.options.musicVolume, 1.0F); + BgMusic = GL11.EaglerAdapterImpl2.beginPlaybackStatic(music[var1].replace(".", "/").replace("_", "."), this.options.musicVolume, 1.0F); } catch(Exception e) { BgMusic = -1; return; @@ -97,7 +97,7 @@ public class SoundManager { public void func_338_a(EntityLiving var1, float var2) { for(int i = 0; i < sounds.size(); i++) { - if(!GL11.isPlaying(sounds.get(i))) { + if(!GL11.EaglerAdapterImpl2.isPlaying(sounds.get(i))) { sounds.remove(i); } } @@ -110,7 +110,7 @@ public class SoundManager { double var6 = var1.prevPosY + (var1.posY - var1.prevPosY) * (double)var2; double var8 = var1.prevPosZ + (var1.posZ - var1.prevPosZ) * (double)var2; try { - GL11.setListenerPos((float)var4, (float)var6, (float)var8, (float)var1.motionX, (float)var1.motionY, (float)var1.motionZ, (float)var9, (float)var3); + GL11.EaglerAdapterImpl2.setListenerPos((float)var4, (float)var6, (float)var8, (float)var1.motionX, (float)var1.motionY, (float)var1.motionZ, (float)var9, (float)var3); } catch(Exception e) { // ??? } @@ -124,7 +124,7 @@ public class SoundManager { public void playSound(String var1, float var2, float var3, float var4, float var5, float var6, int number) { for(int i = 0; i < sounds.size(); i++) { - if(!GL11.isPlaying(sounds.get(i))) { + if(!GL11.EaglerAdapterImpl2.isPlaying(sounds.get(i))) { sounds.remove(i); } } @@ -141,7 +141,7 @@ public class SoundManager { var5 = 1.0F; } - int i = GL11.beginPlayback(var7.replace("0", ""), var2, var3, var4, var5 * this.options.soundVolume, var6); + int i = GL11.EaglerAdapterImpl2.beginPlayback(var7.replace("0", ""), var2, var3, var4, var5 * this.options.soundVolume, var6); if(i != -1) { sounds.add(i); } else { @@ -161,7 +161,7 @@ public class SoundManager { public void playSoundFX(String var1, float var2, float var3, int number) { for(int i = 0; i < sounds.size(); i++) { - if(!GL11.isPlaying(sounds.get(i))) { + if(!GL11.EaglerAdapterImpl2.isPlaying(sounds.get(i))) { sounds.remove(i); } } @@ -173,7 +173,7 @@ public class SoundManager { var2 = 1.0F; } - int i = GL11.beginPlaybackStatic(var4.replace("0", ""), var2 * this.options.soundVolume, var3); + int i = GL11.EaglerAdapterImpl2.beginPlaybackStatic(var4.replace("0", ""), var2 * this.options.soundVolume, var3); if(i != -1) { sounds.add(i); } else { diff --git a/src/net/minecraft/src/StatFileWriter.java b/src/net/minecraft/src/StatFileWriter.java index d00f866..b91fab8 100644 --- a/src/net/minecraft/src/StatFileWriter.java +++ b/src/net/minecraft/src/StatFileWriter.java @@ -6,7 +6,8 @@ import java.util.List; import java.util.Map; import java.util.Map.Entry; -import net.PeytonPlayz585.opengl.GL11; +import net.PeytonPlayz585.fileutils.File; +import net.PeytonPlayz585.fileutils.FileEntry; public class StatFileWriter { private Map field_25102_a = new HashMap(); @@ -17,16 +18,16 @@ public class StatFileWriter { public StatFileWriter(Session var1, String var2) { String var3 = var2 + "/" + "stats"; - GL11.FileEntry[] var4 = GL11.listFiles(var2); + FileEntry[] var4 = File.listFiles(var2); int var5 = var4.length; for(int var6 = 0; var6 < var5; ++var6) { - GL11.FileEntry var7 = var4[var6]; + FileEntry var7 = var4[var6]; if(var7.getName().startsWith("stats_") && var7.getName().endsWith(".dat")) { String var8 = var3 + "/" + var7.getName(); - if(!GL11.exists(var8)) { + if(!File.exists(var8)) { System.out.println("Relocating " + var7.getName()); - GL11.renameFile(var7.path, var8); + File.renameFile(var7.path, var8); } } } diff --git a/src/net/minecraft/src/StatsSyncher.java b/src/net/minecraft/src/StatsSyncher.java index 3e8fb26..e46b02f 100644 --- a/src/net/minecraft/src/StatsSyncher.java +++ b/src/net/minecraft/src/StatsSyncher.java @@ -8,7 +8,7 @@ import java.io.InputStreamReader; import java.io.PrintWriter; import java.util.Map; -import net.PeytonPlayz585.opengl.GL11; +import net.PeytonPlayz585.fileutils.File; public class StatsSyncher { private volatile boolean field_27438_a = false; @@ -43,7 +43,7 @@ public class StatsSyncher { this.field_27435_d = var2; this.field_27428_k = var1; - if(GL11.exists(this.field_27434_e)) { + if(File.exists(this.field_27434_e)) { var2.func_27179_a(this.func_27415_a(this.field_27434_e, this.field_27432_g, this.field_27430_i)); } @@ -52,18 +52,18 @@ public class StatsSyncher { private void func_28214_a(String var1, String var2, String var3) { String var4 = makeFilePath(var1, var2); - if(GL11.exists(var4) && !GL11.directoryExists(var4) && !GL11.exists(var3)) { - GL11.renameFile(var4, var3); + if(File.exists(var4) && !File.directoryExists(var4) && !File.exists(var3)) { + File.renameFile(var4, var3); } } private Map func_27415_a(String var1, String var2, String var3) { - return GL11.exists(var1) ? this.func_27408_a(var1) : (GL11.exists(var3) ? this.func_27408_a(var3) : (GL11.exists(var2) ? this.func_27408_a(var2) : null)); + return File.exists(var1) ? this.func_27408_a(var1) : (File.exists(var3) ? this.func_27408_a(var3) : (File.exists(var2) ? this.func_27408_a(var2) : null)); } private Map func_27408_a(String var1) { - byte[] bytes = GL11.readFile(var1); + byte[] bytes = File.readFile(var1); if (bytes == null || bytes.length == 0) { return null; } @@ -76,20 +76,20 @@ public class StatsSyncher { try { var5.print(StatFileWriter.func_27185_a(this.field_27428_k.username, "local", var1)); - GL11.writeFile(var3, baos.toByteArray()); + File.writeFile(var3, baos.toByteArray()); } finally { var5.close(); } - if(GL11.exists(var4)) { - GL11.deleteFile(var4); + if(File.exists(var4)) { + File.deleteFile(var4); } - if(GL11.exists(var2)) { - GL11.renameFile(var2, var4); + if(File.exists(var2)) { + File.renameFile(var2, var4); } - GL11.renameFile(var3, var2); + File.renameFile(var3, var2); } public void func_27418_a() { diff --git a/src/net/minecraft/src/TerrainTextureManager.java b/src/net/minecraft/src/TerrainTextureManager.java index 7685027..026b520 100644 --- a/src/net/minecraft/src/TerrainTextureManager.java +++ b/src/net/minecraft/src/TerrainTextureManager.java @@ -4,8 +4,8 @@ import java.util.Arrays; import org.lwjgl.opengl.GL11; -import net.lax1dude.eaglercraft.BufferedImage; -import net.lax1dude.eaglercraft.ImageIO; +import net.PeytonPlayz585.awt.image.BufferedImage; +import net.PeytonPlayz585.awt.image.ImageIO; public class TerrainTextureManager { private float[] field_1181_a = new float[768]; diff --git a/src/net/minecraft/src/Tessellator.java b/src/net/minecraft/src/Tessellator.java index 6f770da..380ff8a 100644 --- a/src/net/minecraft/src/Tessellator.java +++ b/src/net/minecraft/src/Tessellator.java @@ -54,7 +54,7 @@ public class Tessellator { } GL11.glEnableClientState(GL11.GL_VERTEX_ARRAY); - GL11.glDrawArrays(this.drawMode, GL11.GL_POINTS, this.vertexCount, Int32Array.create(intBuffer.getBuffer(), 0, this.vertexCount * 7)); + GL11.glDrawArrays(this.drawMode, GL11.GL_POINTS, this.vertexCount, Int32Array.create(intBuffer.getBuffer(), 0, this.vertexCount * 8)); GL11.glDisableClientState(GL11.GL_VERTEX_ARRAY); if(this.hasTexture) { @@ -189,7 +189,7 @@ public class Tessellator { intBuffer0.set(this.rawBufferIndex + 6, this.normal); } - this.rawBufferIndex += 7; + this.rawBufferIndex += 8; ++this.vertexCount; if(this.vertexCount % 4 == 0 && this.rawBufferIndex >= this.bufferSize - 32) { this.draw(); diff --git a/src/net/minecraft/src/TextureCompassFX.java b/src/net/minecraft/src/TextureCompassFX.java index 8769824..d8b4a3f 100644 --- a/src/net/minecraft/src/TextureCompassFX.java +++ b/src/net/minecraft/src/TextureCompassFX.java @@ -4,8 +4,8 @@ import java.io.IOException; import org.lwjgl.opengl.GL11; -import net.lax1dude.eaglercraft.BufferedImage; -import net.lax1dude.eaglercraft.ImageIO; +import net.PeytonPlayz585.awt.image.BufferedImage; +import net.PeytonPlayz585.awt.image.ImageIO; import net.minecraft.client.Minecraft; public class TextureCompassFX extends TextureFX { diff --git a/src/net/minecraft/src/ThreadStatSyncherReceive.java b/src/net/minecraft/src/ThreadStatSyncherReceive.java index 9a0638f..c94399c 100644 --- a/src/net/minecraft/src/ThreadStatSyncherReceive.java +++ b/src/net/minecraft/src/ThreadStatSyncherReceive.java @@ -1,6 +1,6 @@ package net.minecraft.src; -import net.PeytonPlayz585.opengl.GL11; +import net.PeytonPlayz585.fileutils.File; class ThreadStatSyncherReceive extends Thread { final StatsSyncher field_27231_a; @@ -13,7 +13,7 @@ class ThreadStatSyncherReceive extends Thread { try { if(StatsSyncher.func_27422_a(this.field_27231_a) != null) { StatsSyncher.func_27412_a(this.field_27231_a, StatsSyncher.func_27422_a(this.field_27231_a), StatsSyncher.func_27423_b(this.field_27231_a), StatsSyncher.func_27411_c(this.field_27231_a), StatsSyncher.func_27413_d(this.field_27231_a)); - } else if(GL11.exists(StatsSyncher.func_27423_b(this.field_27231_a))) { + } else if(File.exists(StatsSyncher.func_27423_b(this.field_27231_a))) { StatsSyncher.func_27421_a(this.field_27231_a, StatsSyncher.func_27409_a(this.field_27231_a, StatsSyncher.func_27423_b(this.field_27231_a), StatsSyncher.func_27411_c(this.field_27231_a), StatsSyncher.func_27413_d(this.field_27231_a))); } } catch (Exception var5) { diff --git a/src/org/lwjgl/BufferUtils.java b/src/org/lwjgl/BufferUtils.java new file mode 100644 index 0000000..dccd2ed --- /dev/null +++ b/src/org/lwjgl/BufferUtils.java @@ -0,0 +1,161 @@ +package org.lwjgl; + +import java.nio.Buffer; +import java.nio.ByteBuffer; +import java.nio.ByteOrder; +import java.nio.CharBuffer; +import java.nio.DoubleBuffer; +import java.nio.FloatBuffer; +import java.nio.IntBuffer; +import java.nio.LongBuffer; +import java.nio.ShortBuffer; + +import net.minecraft.src.GLAllocation; + +public class BufferUtils { + + /** + * It's not possible to directly allocate and then convert the buffers in TeaVM + * So to fix this, I'm wrapping the values to the buffer instead + */ + + public static ByteBuffer createByteBuffer(int size) { + return ByteBuffer.wrap(new byte[size]).order(ByteOrder.nativeOrder()); + } + + public static ShortBuffer createShortBuffer(int size) { + return ShortBuffer.wrap(new short[size]); + } + + public static CharBuffer createCharBuffer(int size) { + return CharBuffer.wrap(new char[size]); + } + + public static IntBuffer createIntBuffer(int size) { + return IntBuffer.wrap(new int[size]); + } + + public static LongBuffer createLongBuffer(int size) { + return LongBuffer.wrap(new long[size]); + } + + public static FloatBuffer createFloatBuffer(int size) { + return FloatBuffer.wrap(new float[size]); + } + + public static DoubleBuffer createDoubleBuffer(int size) { + return DoubleBuffer.wrap(new double[size]); + } + + public static PointerBuffer createPointerBuffer(int size) { + //Doesn't actually directly allocate + //I rewrote the PointerBuffer class to use buffer.wrap + return PointerBuffer.allocateDirect(size); + } + + public static int getElementSizeExponent(Buffer buf) { + if (buf instanceof ByteBuffer) { + return 0; + } else if (buf instanceof ShortBuffer || buf instanceof CharBuffer) { + return 1; + } else if (buf instanceof FloatBuffer || buf instanceof IntBuffer) { + return 2; + } else if (buf instanceof LongBuffer || buf instanceof DoubleBuffer) { + return 3; + } else { + throw new IllegalStateException("Unsupported buffer type: " + buf); + } + } + + public static int getOffset(Buffer buffer) { + return buffer.position() << getElementSizeExponent(buffer); + } + + public static void zeroBuffer(ByteBuffer b) { + zeroBuffer0(b, b.position(), b.remaining()); + } + + public static void zeroBuffer(ShortBuffer b) { + zeroBuffer0(b, b.position()*2L, b.remaining()*2L); + } + + public static void zeroBuffer(CharBuffer b) { + zeroBuffer0(b, b.position()*2L, b.remaining()*2L); + } + + public static void zeroBuffer(IntBuffer b) { + zeroBuffer0(b, b.position()*4L, b.remaining()*4L); + } + + public static void zeroBuffer(FloatBuffer b) { + zeroBuffer0(b, b.position()*4L, b.remaining()*4L); + } + + public static void zeroBuffer(LongBuffer b) { + zeroBuffer0(b, b.position()*8L, b.remaining()*8L); + } + + public static void zeroBuffer(DoubleBuffer b) { + zeroBuffer0(b, b.position()*8L, b.remaining()*8L); + } + + //Wrote my own implementation since JNI isn't supported in TeaVM + private static void zeroBuffer0(Buffer b, long offset, long length) { + for (int i = 0; i < b.remaining(); i++) { + put(b, i, 0); + } + } + + private static void put(Buffer b, int i, int i2) { + if(b instanceof ByteBuffer) { + put((ByteBuffer)b, i, i2); + } else if(b instanceof ShortBuffer) { + put((ShortBuffer)b, i, i2); + } else if(b instanceof CharBuffer) { + put((CharBuffer)b, i, i2); + } else if(b instanceof IntBuffer) { + put((IntBuffer)b, i, i2); + } else if(b instanceof FloatBuffer) { + put((FloatBuffer)b, i, i2); + } else if(b instanceof LongBuffer) { + put((LongBuffer)b, i, i2); + } else if(b instanceof DoubleBuffer) { + put((DoubleBuffer)b, i, i2); + } else { + throw new IllegalArgumentException("Unsupported buffer type!"); + } + } + + private static void put(ByteBuffer b, int i, int i2) { + b.put(i, (byte) i2); + } + + private static void put(ShortBuffer b, int i, int i2) { + b.put(i, (short) i2); + } + + private static void put(CharBuffer b, int i, int i2) { + b.put(i, (char) i2); + } + + private static void put(IntBuffer b, int i, int i2) { + b.put(i, i2); + } + + private static void put(FloatBuffer b, int i, int i2) { + b.put(i, i2); + } + + private static void put(LongBuffer b, int i, int i2) { + b.put(i, i2); + } + + private static void put(DoubleBuffer b, int i, int i2) { + b.put(i, i2); + } + + //Not in BufferUtils but thought I would add it anyways + public static int getBufferSizeInBytes(Buffer buffer) { + return buffer.capacity() * getElementSizeExponent(buffer); + } +} \ No newline at end of file diff --git a/src/org/lwjgl/LWJGLException.java b/src/org/lwjgl/LWJGLException.java new file mode 100644 index 0000000..9ff13ca --- /dev/null +++ b/src/org/lwjgl/LWJGLException.java @@ -0,0 +1,21 @@ +package org.lwjgl; + +public class LWJGLException extends Exception { + private static final long serialVersionUID = 1L; + + public LWJGLException() { + super(); + } + + public LWJGLException(String msg) { + super(msg); + } + + public LWJGLException(String message, Throwable cause) { + super(message, cause); + } + + public LWJGLException(Throwable cause) { + super(cause); + } +} \ No newline at end of file diff --git a/src/org/lwjgl/PointerBuffer.java b/src/org/lwjgl/PointerBuffer.java new file mode 100644 index 0000000..2891c75 --- /dev/null +++ b/src/org/lwjgl/PointerBuffer.java @@ -0,0 +1,314 @@ +package org.lwjgl; + +import java.nio.*; + +public class PointerBuffer { + protected final ByteBuffer pointers; + protected final Buffer view; + protected final LongBuffer view64; + + public PointerBuffer(final int capacity) { + this(ByteBuffer.wrap(new byte[capacity * getPointerSize()]).order(ByteOrder.nativeOrder())); + } + + public PointerBuffer(final ByteBuffer source) { + checkSource(source); + pointers = source.slice().order(source.order()); + + view = view64 = pointers.asLongBuffer(); //Assumes 64-bit, no way to check for it + } + + private static void checkSource(final ByteBuffer source) { + if (!source.isDirect()) { + throw new IllegalArgumentException("The source buffer is not direct."); + } + + final int alignment = 8; + + //There is no reliable way of getting a memory address for a buffer in JS + if (source.remaining() % alignment != 0) { + throw new IllegalArgumentException("The source buffer is not aligned to " + alignment + " bytes."); + } + } + + public ByteBuffer getBuffer() { + return pointers; + } + + public static boolean is64Bit() { + //No reliable way to check this + //So I'm just assuming it's true + return true; + } + + public static int getPointerSize() { + return 8; //Also assumes 64-bit + } + + public final int capacity() { + return view.capacity(); + } + + public final int position() { + return view.position(); + } + + public final int positionByte() { + return position() * getPointerSize(); + } + + public final PointerBuffer position(int newPosition) { + view.position(newPosition); + return this; + } + + public final int limit() { + return view.limit(); + } + + public final PointerBuffer limit(int newLimit) { + view.limit(newLimit); + return this; + } + + public final PointerBuffer mark() { + view.mark(); + return this; + } + + public final PointerBuffer reset() { + view.reset(); + return this; + } + + public final PointerBuffer clear() { + view.clear(); + return this; + } + + public final PointerBuffer flip() { + view.flip(); + return this; + } + + public final PointerBuffer rewind() { + view.rewind(); + return this; + } + + public final int remaining() { + return view.remaining(); + } + + public final int remainingByte() { + return remaining() * getPointerSize(); + } + + public final boolean hasRemaining() { + return view.hasRemaining(); + } + + public static PointerBuffer allocateDirect(int capacity) { + return new PointerBuffer(capacity); + } + + protected PointerBuffer newInstance(final ByteBuffer source) { + return new PointerBuffer(source); + } + + public PointerBuffer slice() { + final int pointerSize = getPointerSize(); + + pointers.position(view.position() * pointerSize); + pointers.limit(view.limit() * pointerSize); + + try { + return newInstance(pointers); //Buffer is sliced in constructors + } finally { + pointers.clear(); + } + } + + public PointerBuffer duplicate() { + final PointerBuffer buffer = newInstance(pointers); + + buffer.position(view.position()); + buffer.limit(view.limit()); + + return buffer; + } + + //I don't like this + public PointerBuffer asReadOnlyBuffer() { + final PointerBuffer buffer = new PointerBufferR(pointers); + + buffer.position(view.position()); + buffer.limit(view.limit()); + + return buffer; + } + + public boolean isReadOnly() { + return false; + } + + public long get() { + return view64.get(); + } + + public PointerBuffer put(long l) { + view64.put(l); + return this; + } + + public PointerBuffer put(final PointerWrapper pointer) { + return put(pointer.getPointer()); + } + + public static void put(final ByteBuffer target, long l) { + target.putLong(l); + } + + public long get(int index) { + return view64.get(index); + } + + public PointerBuffer put(int index, long l) { + view64.put(index, l); + return this; + } + + public PointerBuffer put(int index, PointerWrapper pointer) { + return put(index, pointer.getPointer()); + } + + public static void put(final ByteBuffer target, int index, long l) { + target.putLong(index, l); + } + + public PointerBuffer get(long[] dst, int offset, int length) { + view64.get(dst, offset, length); + return this; + } + + public PointerBuffer get(long[] dst) { + return get(dst, 0, dst.length); + } + + public PointerBuffer put(PointerBuffer src) { + view64.put(src.view64); + return this; + } + + public PointerBuffer put(long[] src, int offset, int length) { + view64.put(src, offset, length); + return this; + } + + public final PointerBuffer put(long[] src) { + return put(src, 0, src.length); + } + + public PointerBuffer compact() { + view64.compact(); + return this; + } + + public ByteOrder order() { + return view64.order(); + } + + public String toString() { + //Use String.format instead of StringBuilder + return String.format("%s[pos=%d, lim=%d, cap=%d]", getClass().getName(), position(), limit(), capacity()); + } + + public int hashCode() { + int h = 1; + int p = position(); + for (int i = limit() - 1; i >= p; i--) { + h = 31 * h + (int)get(i); + } + return h; + } + + public boolean equals(Object ob) { + if (!(ob instanceof PointerBuffer)) { + return false; + } + PointerBuffer that = (PointerBuffer)ob; + if (this.remaining() != that.remaining()) { + return false; + } + int p = this.position(); + for (int i = this.limit() - 1, j = that.limit() - 1; i >= p; i--, j--) { + long v1 = this.get(i); + long v2 = that.get(j); + if ( v1 != v2 ) { + return false; + } + } + return true; + } + + public int compareTo(Object o) { + final PointerBuffer that = (PointerBuffer)o; + int n = this.position() + Math.min(this.remaining(), that.remaining()); + for (int i = this.position(), j = that.position(); i < n; i++, j++) { + long v1 = this.get(i); + long v2 = that.get(j); + if ( v1 == v2 ) { + continue; + } + if (v1 < v2) { + return -1; + } + return +1; + } + return this.remaining() - that.remaining(); + } + + private static void checkBounds(int off, int len, int size) { + if ((off | len | (off + len) | (size - (off + len))) < 0) { + throw new IndexOutOfBoundsException(); + } + } + + private static final class PointerBufferR extends PointerBuffer { + PointerBufferR(final ByteBuffer source) { + super(source); + } + + public boolean isReadOnly() { + return true; + } + + protected PointerBuffer newInstance(final ByteBuffer source) { + return new PointerBufferR(source); + } + + public PointerBuffer asReadOnlyBuffer() { + return duplicate(); + } + + public PointerBuffer put(final long l) { + throw new ReadOnlyBufferException(); + } + + public PointerBuffer put(final int index, final long l) { + throw new ReadOnlyBufferException(); + } + + public PointerBuffer put(final PointerBuffer src) { + throw new ReadOnlyBufferException(); + } + + public PointerBuffer put(final long[] src, final int offset, final int length) { + throw new ReadOnlyBufferException(); + } + + public PointerBuffer compact() { + throw new ReadOnlyBufferException(); + } + } +} \ No newline at end of file diff --git a/src/org/lwjgl/PointerWrapper.java b/src/org/lwjgl/PointerWrapper.java new file mode 100644 index 0000000..515f16b --- /dev/null +++ b/src/org/lwjgl/PointerWrapper.java @@ -0,0 +1,5 @@ +package org.lwjgl; + +public interface PointerWrapper { + long getPointer(); +} \ No newline at end of file diff --git a/src/org/lwjgl/input/Keyboard.java b/src/org/lwjgl/input/Keyboard.java index edfb80b..941a240 100644 --- a/src/org/lwjgl/input/Keyboard.java +++ b/src/org/lwjgl/input/Keyboard.java @@ -1,5 +1,46 @@ package org.lwjgl.input; -public class Keyboard extends net.PeytonPlayz585.input.Keyboard { +import org.lwjgl.opengl.GL11; + +public class Keyboard { + + public static void destroy() { + } + + public static int getEventKey() { + return GL11.EaglerAdapterImpl2.getEventKey(); + } + + public static boolean isKeyDown(int i) { + return GL11.EaglerAdapterImpl2.isKeyDown(i); + } + + public static boolean getEventKeyState() { + return GL11.EaglerAdapterImpl2.getEventKeyState(); + } + + public static boolean next() { + return GL11.EaglerAdapterImpl2.keysNext(); + } + + public static String getKeyName(int var0) { + return GL11.EaglerAdapterImpl2.getKeyName(var0); + } + + public static void enableRepeatEvents(boolean b) { + GL11.EaglerAdapterImpl2.enableRepeatEvents(b); + } + + public static String getClipboardString() { + return GL11.EaglerAdapterImpl2.getClipboard(); + } + + public static void setClipboard(String s) { + GL11.EaglerAdapterImpl2.setClipboard(s); + } + + public static char getEventCharacter() { + return GL11.EaglerAdapterImpl2.getEventChar(); + } } diff --git a/src/org/lwjgl/input/Mouse.java b/src/org/lwjgl/input/Mouse.java index af42f74..48607d0 100644 --- a/src/org/lwjgl/input/Mouse.java +++ b/src/org/lwjgl/input/Mouse.java @@ -1,5 +1,61 @@ package org.lwjgl.input; -public class Mouse extends net.PeytonPlayz585.input.Mouse { +import org.lwjgl.opengl.GL11; + +public class Mouse { + + public static int getX() { + return GL11.EaglerAdapterImpl2.mouseGetX(); + } + + public static int getY() { + return GL11.EaglerAdapterImpl2.mouseGetY(); + } + + public static void create() { + } + + public static void setGrabbed(boolean b) { + GL11.EaglerAdapterImpl2.mouseSetGrabbed(b); + } + + public static int getDX() { + return GL11.EaglerAdapterImpl2.mouseGetDX(); + } + + public static int getDY() { + return GL11.EaglerAdapterImpl2.mouseGetDY(); + } + + public static void destroy() { + } + + public static boolean next() { + return GL11.EaglerAdapterImpl2.mouseNext(); + } + + public static int getEventButton() { + return GL11.EaglerAdapterImpl2.mouseGetEventButton(); + } + + public static boolean getEventButtonState() { + return GL11.EaglerAdapterImpl2.mouseGetEventButtonState(); + } + + public static int getEventDWheel() { + return GL11.EaglerAdapterImpl2.mouseGetEventDWheel(); + } + + public static boolean isButtonDown(int i) { + return GL11.EaglerAdapterImpl2.mouseIsButtonDown(i); + } + + public static int getEventX() { + return GL11.EaglerAdapterImpl2.mouseGetEventX(); + } + + public static int getEventY() { + return GL11.EaglerAdapterImpl2.mouseGetEventY(); + } } diff --git a/src/org/lwjgl/opengl/Display.java b/src/org/lwjgl/opengl/Display.java new file mode 100644 index 0000000..ee9f0bc --- /dev/null +++ b/src/org/lwjgl/opengl/Display.java @@ -0,0 +1,58 @@ +package org.lwjgl.opengl; + +public class Display { + + static Display display = new Display(); + + //Can NOT be null! + private static String title = "Minecraft"; + + public Display() { + + } + + public static boolean isActive() { + return GL11.EaglerAdapterImpl2.isFocused(); + } + + public static int getWidth() { + return GL11.EaglerAdapterImpl2.getCanvasWidth(); + } + + public static int getHeight() { + return GL11.EaglerAdapterImpl2.getCanvasHeight(); + } + + public static void setFullscreen(boolean b) { + GL11.EaglerAdapterImpl2.setFullscreen(b); + } + + public static void setTitle(String newTitle) { + if(newTitle == null) { + throw new IllegalArgumentException("title CAN NOT be null"); + } + title = newTitle; + } + + public static void update() { + GL11.EaglerAdapterImpl2.doc.setTitle(title); + GL11.EaglerAdapterImpl2.updateDisplay(); + } + + public static Display getDisplayMode() { + return display; + } + + public static void swapBuffers() { + GL11.glFlush(); + GL11.EaglerAdapterImpl2.updateDisplay(); + } + + public static void destroy() { + } + + public static boolean isFocused() { + return GL11.EaglerAdapterImpl2.isFocused(); + } + +} diff --git a/src/org/lwjgl/opengl/GL11.java b/src/org/lwjgl/opengl/GL11.java index 9d4eb7a..5d60295 100644 --- a/src/org/lwjgl/opengl/GL11.java +++ b/src/org/lwjgl/opengl/GL11.java @@ -1,27 +1,8233 @@ package org.lwjgl.opengl; +import java.io.ByteArrayInputStream; +import java.io.DataInputStream; +import java.io.IOException; import java.io.InputStream; +import java.math.BigInteger; +import java.nio.ByteBuffer; +import java.nio.FloatBuffer; +import java.nio.IntBuffer; +import java.nio.charset.Charset; +import java.text.DateFormat; +import java.text.SimpleDateFormat; +import java.util.ArrayList; +import java.util.Arrays; +import java.util.Date; +import java.util.HashMap; +import java.util.HashSet; +import java.util.LinkedList; +import java.util.List; +import java.util.Set; -import net.lax1dude.eaglercraft.BufferedImage; +import org.lwjgl.BufferUtils; +import org.lwjgl.util.vector.Matrix4f; +import org.lwjgl.util.vector.Vector2f; +import org.lwjgl.util.vector.Vector3f; +import org.lwjgl.util.vector.Vector4f; +import org.teavm.interop.Async; +import org.teavm.interop.AsyncCallback; +import org.teavm.jso.JSBody; +import org.teavm.jso.JSFunctor; +import org.teavm.jso.JSObject; +import org.teavm.jso.ajax.ReadyStateChangeHandler; +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.canvas.CanvasRenderingContext2D; +import org.teavm.jso.canvas.ImageData; +import org.teavm.jso.dom.css.CSSStyleDeclaration; +import org.teavm.jso.dom.events.Event; +import org.teavm.jso.dom.events.EventListener; +import org.teavm.jso.dom.events.KeyboardEvent; +import org.teavm.jso.dom.events.MessageEvent; +import org.teavm.jso.dom.events.MouseEvent; +import org.teavm.jso.dom.events.WheelEvent; +import org.teavm.jso.dom.html.HTMLBodyElement; +import org.teavm.jso.dom.html.HTMLCanvasElement; +import org.teavm.jso.dom.html.HTMLDocument; +import org.teavm.jso.dom.html.HTMLElement; +import org.teavm.jso.dom.html.HTMLImageElement; +import org.teavm.jso.typedarrays.ArrayBuffer; +import org.teavm.jso.typedarrays.DataView; +import org.teavm.jso.typedarrays.Float32Array; +import org.teavm.jso.typedarrays.Int32Array; +import org.teavm.jso.typedarrays.Uint8Array; +import org.teavm.jso.typedarrays.Uint8ClampedArray; +import org.teavm.jso.webaudio.AudioBuffer; +import org.teavm.jso.webaudio.AudioBufferSourceNode; +import org.teavm.jso.webaudio.AudioContext; +import org.teavm.jso.webaudio.AudioListener; +import org.teavm.jso.webaudio.DecodeErrorCallback; +import org.teavm.jso.webaudio.DecodeSuccessCallback; +import org.teavm.jso.webaudio.GainNode; +import org.teavm.jso.webaudio.MediaEvent; +import org.teavm.jso.webaudio.PannerNode; +import org.teavm.jso.webgl.WebGLBuffer; +import org.teavm.jso.webgl.WebGLFramebuffer; +import org.teavm.jso.webgl.WebGLProgram; +import org.teavm.jso.webgl.WebGLRenderbuffer; +import org.teavm.jso.webgl.WebGLRenderingContext; +import org.teavm.jso.webgl.WebGLShader; +import org.teavm.jso.webgl.WebGLTexture; +import org.teavm.jso.webgl.WebGLUniformLocation; +import org.teavm.jso.websocket.CloseEvent; +import org.teavm.jso.websocket.WebSocket; -public class GL11 extends net.PeytonPlayz585.opengl.GL11 { +import com.jcraft.jzlib.CRC32; +import com.jcraft.jzlib.GZIPInputStream; +import com.jcraft.jzlib.InflaterInputStream; - public static final int GL_POINTS = 0; +import net.PeytonPlayz585.Client; +import net.PeytonPlayz585.awt.image.BufferedImage; +import net.PeytonPlayz585.awt.image.ImageIO; +import net.PeytonPlayz585.glemu.FixedFunctionShader; +import net.PeytonPlayz585.glemu.StreamBuffer; +import net.PeytonPlayz585.glemu.StreamBuffer.StreamBufferInstance; +import net.minecraft.src.MathHelper; +import net.minecraft.src.ScaledResolution; +import net.minecraft.src.Tessellator; + +import static org.lwjgl.opengl.GL11.EaglerAdapterImpl2.*; +import static org.lwjgl.opengl.GL11.WebGL2RenderingContext.*; + +public class GL11 implements JSObject { + + public static final int GL_ZERO = RealOpenGLEnums.GL_ZERO; + public static final int GL_ONE = RealOpenGLEnums.GL_ONE; + public static final int GL_TEXTURE_2D = RealOpenGLEnums.GL_TEXTURE_2D; + public static final int GL_SMOOTH = RealOpenGLEnums.GL_SMOOTH; + public static final int GL_DEPTH_TEST = RealOpenGLEnums.GL_DEPTH_TEST; + public static final int GL_LEQUAL = RealOpenGLEnums.GL_LEQUAL; + public static final int GL_ALPHA_TEST = RealOpenGLEnums.GL_ALPHA_TEST; + public static final int GL_GREATER = RealOpenGLEnums.GL_GREATER; + public static final int GL_BACK = RealOpenGLEnums.GL_BACK; + public static final int GL_PROJECTION = RealOpenGLEnums.GL_PROJECTION; + public static final int GL_MODELVIEW = RealOpenGLEnums.GL_MODELVIEW; + public static final int GL_COLOR_BUFFER_BIT = RealOpenGLEnums.GL_COLOR_BUFFER_BIT; + public static final int GL_DEPTH_BUFFER_BIT = RealOpenGLEnums.GL_DEPTH_BUFFER_BIT; + public static final int GL_LIGHTING = RealOpenGLEnums.GL_LIGHTING; + public static final int GL_FOG = RealOpenGLEnums.GL_FOG; + public static final int GL_COLOR_MATERIAL = RealOpenGLEnums.GL_COLOR_MATERIAL; + public static final int GL_BLEND = RealOpenGLEnums.GL_BLEND; + public static final int GL_RGBA = RealOpenGLEnums.GL_RGBA; + public static final int GL_UNSIGNED_BYTE = RealOpenGLEnums.GL_UNSIGNED_BYTE; + public static final int GL_TEXTURE_WIDTH = RealOpenGLEnums.GL_TEXTURE_WIDTH; + public static final int GL_LIGHT0 = RealOpenGLEnums.GL_LIGHT0; + public static final int GL_LIGHT1 = RealOpenGLEnums.GL_LIGHT1; + public static final int GL_POSITION = RealOpenGLEnums.GL_POSITION; + public static final int GL_DIFFUSE = RealOpenGLEnums.GL_DIFFUSE; + public static final int GL_SPECULAR = RealOpenGLEnums.GL_SPECULAR; + public static final int GL_AMBIENT = RealOpenGLEnums.GL_AMBIENT; + public static final int GL_FLAT = RealOpenGLEnums.GL_FLAT; + public static final int GL_LIGHT_MODEL_AMBIENT = RealOpenGLEnums.GL_LIGHT_MODEL_AMBIENT; + public static final int GL_FRONT_AND_BACK = RealOpenGLEnums.GL_FRONT_AND_BACK; + public static final int GL_AMBIENT_AND_DIFFUSE = RealOpenGLEnums.GL_AMBIENT_AND_DIFFUSE; + public static final int GL_MODELVIEW_MATRIX = RealOpenGLEnums.GL_MODELVIEW_MATRIX; + public static final int GL_PROJECTION_MATRIX = RealOpenGLEnums.GL_PROJECTION_MATRIX; + public static final int GL_VIEWPORT = RealOpenGLEnums.GL_VIEWPORT; + public static final int GL_RESCALE_NORMAL = RealOpenGLEnums.GL_RESCALE_NORMAL; + public static final int GL_SRC_ALPHA = RealOpenGLEnums.GL_SRC_ALPHA; + public static final int GL_ONE_MINUS_SRC_ALPHA = RealOpenGLEnums.GL_ONE_MINUS_SRC_ALPHA; + public static final int GL_ONE_MINUS_DST_COLOR = RealOpenGLEnums.GL_ONE_MINUS_DST_COLOR; + public static final int GL_ONE_MINUS_SRC_COLOR = RealOpenGLEnums.GL_ONE_MINUS_SRC_COLOR; + public static final int GL_CULL_FACE = RealOpenGLEnums.GL_CULL_FACE; + public static final int GL_TEXTURE_MIN_FILTER = RealOpenGLEnums.GL_TEXTURE_MIN_FILTER; + public static final int GL_TEXTURE_MAG_FILTER = RealOpenGLEnums.GL_TEXTURE_MAG_FILTER; + public static final int GL_LINEAR = RealOpenGLEnums.GL_LINEAR; + public static final int GL_COLOR_LOGIC_OP = RealOpenGLEnums.GL_COLOR_LOGIC_OP; + public static final int GL_OR_REVERSE = RealOpenGLEnums.GL_OR_REVERSE; + public static final int GL_EQUAL = RealOpenGLEnums.GL_EQUAL; + public static final int GL_SRC_COLOR = RealOpenGLEnums.GL_SRC_COLOR; + public static final int GL_TEXTURE = RealOpenGLEnums.GL_TEXTURE; + public static final int GL_FRONT = RealOpenGLEnums.GL_FRONT; + public static final int GL_COMPILE = RealOpenGLEnums.GL_COMPILE; + public static final int GL_S = RealOpenGLEnums.GL_S; + public static final int GL_T = RealOpenGLEnums.GL_T; + public static final int GL_R = RealOpenGLEnums.GL_R; + public static final int GL_Q = RealOpenGLEnums.GL_Q; + public static final int GL_TEXTURE_GEN_S = RealOpenGLEnums.GL_TEXTURE_GEN_S; + public static final int GL_TEXTURE_GEN_T = RealOpenGLEnums.GL_TEXTURE_GEN_T; + public static final int GL_TEXTURE_GEN_R = RealOpenGLEnums.GL_TEXTURE_GEN_R; + public static final int GL_TEXTURE_GEN_Q = RealOpenGLEnums.GL_TEXTURE_GEN_Q; + public static final int GL_TEXTURE_GEN_MODE = RealOpenGLEnums.GL_TEXTURE_GEN_MODE; + public static final int GL_OBJECT_PLANE = RealOpenGLEnums.GL_OBJECT_PLANE; + public static final int GL_EYE_PLANE = RealOpenGLEnums.GL_EYE_PLANE; + public static final int GL_OBJECT_LINEAR = RealOpenGLEnums.GL_OBJECT_LINEAR; + public static final int GL_EYE_LINEAR = RealOpenGLEnums.GL_EYE_LINEAR; + public static final int GL_NEAREST = RealOpenGLEnums.GL_NEAREST; + public static final int GL_CLAMP = RealOpenGLEnums.GL_CLAMP_TO_EDGE; + public static final int GL_TEXTURE_WRAP_S = RealOpenGLEnums.GL_TEXTURE_WRAP_S; + public static final int GL_TEXTURE_WRAP_T = RealOpenGLEnums.GL_TEXTURE_WRAP_T; + public static final int GL_REPEAT = RealOpenGLEnums.GL_REPEAT; + public static final int GL_BGRA = RealOpenGLEnums.GL_BGRA; + public static final int GL_UNSIGNED_INT_8_8_8_8_REV = RealOpenGLEnums.GL_UNSIGNED_INT_8_8_8_8_REV; + public static final int GL_DST_COLOR = RealOpenGLEnums.GL_DST_COLOR; + public static final int GL_CONSTANT_COLOR = RealOpenGLEnums.GL_CONSTANT_COLOR; + public static final int GL_ONE_MINUS_CONSTANT_COLOR = RealOpenGLEnums.GL_ONE_MINUS_CONSTANT_COLOR; + public static final int GL_CONSTANT_ALPHA = RealOpenGLEnums.GL_CONSTANT_ALPHA; + public static final int GL_ONE_MINUS_CONSTANT_ALPHA = RealOpenGLEnums.GL_ONE_MINUS_CONSTANT_ALPHA; + public static final int GL_POLYGON_OFFSET_FILL = RealOpenGLEnums.GL_POLYGON_OFFSET_FILL; + public static final int GL_NORMALIZE = RealOpenGLEnums.GL_NORMALIZE; + public static final int GL_DST_ALPHA = RealOpenGLEnums.GL_DST_ALPHA; + public static final int GL_FLOAT = RealOpenGLEnums.GL_FLOAT; + public static final int GL_TEXTURE_COORD_ARRAY = RealOpenGLEnums.GL_TEXTURE_COORD_ARRAY; + public static final int GL_SHORT = RealOpenGLEnums.GL_SHORT; + public static final int GL_COLOR_ARRAY = RealOpenGLEnums.GL_COLOR_ARRAY; + public static final int GL_VERTEX_ARRAY = RealOpenGLEnums.GL_VERTEX_ARRAY; + public static final int GL_TRIANGLES = RealOpenGLEnums.GL_TRIANGLES; + public static final int GL_NORMAL_ARRAY = RealOpenGLEnums.GL_NORMAL_ARRAY; + public static final int GL_TEXTURE_3D = RealOpenGLEnums.GL_TEXTURE_3D; + public static final int GL_FOG_MODE = RealOpenGLEnums.GL_FOG_MODE; + public static final int GL_EXP = RealOpenGLEnums.GL_EXP; + public static final int GL_FOG_DENSITY = RealOpenGLEnums.GL_FOG_DENSITY; + public static final int GL_FOG_START = RealOpenGLEnums.GL_FOG_START; + public static final int GL_FOG_END = RealOpenGLEnums.GL_FOG_END; + public static final int GL_FOG_COLOR = RealOpenGLEnums.GL_FOG_COLOR; + public static final int GL_TRIANGLE_STRIP = RealOpenGLEnums.GL_TRIANGLE_STRIP; + public static final int GL_PACK_ALIGNMENT = RealOpenGLEnums.GL_PACK_ALIGNMENT; + public static final int GL_UNPACK_ALIGNMENT = RealOpenGLEnums.GL_UNPACK_ALIGNMENT; + public static final int GL_QUADS = RealOpenGLEnums.GL_QUADS; + public static final int GL_TEXTURE0 = RealOpenGLEnums.GL_TEXTURE0; + public static final int GL_TEXTURE1 = RealOpenGLEnums.GL_TEXTURE1; + public static final int GL_TEXTURE2 = RealOpenGLEnums.GL_TEXTURE2; + public static final int GL_TEXTURE3 = RealOpenGLEnums.GL_TEXTURE3; + public static final int GL_INVALID_ENUM = RealOpenGLEnums.GL_INVALID_ENUM; + public static final int GL_INVALID_VALUE = RealOpenGLEnums.GL_INVALID_VALUE; + public static final int GL_INVALID_OPERATION = RealOpenGLEnums.GL_INVALID_OPERATION; + public static final int GL_OUT_OF_MEMORY = RealOpenGLEnums.GL_OUT_OF_MEMORY; + public static final int GL_CONTEXT_LOST_WEBGL = -100; + public static final int GL_TRIANGLE_FAN = RealOpenGLEnums.GL_TRIANGLE_FAN; + public static final int GL_LINE_STRIP = RealOpenGLEnums.GL_LINE_STRIP; + public static final int EAG_SWAP_RB = -101; + public static final int GL_LINES = RealOpenGLEnums.GL_LINES; + public static final int GL_NEAREST_MIPMAP_LINEAR = RealOpenGLEnums.GL_NEAREST_MIPMAP_LINEAR; + public static final int GL_TEXTURE_MAX_ANISOTROPY = -103; + public static final int GL_TEXTURE_MAX_LEVEL = RealOpenGLEnums.GL_TEXTURE_MAX_LEVEL; + 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 InputStream getResourceAsStream(String var1) { - return loadResource(var1); + //Just some extra ones :) + public static final int GL_GEQUAL = RealOpenGLEnums.GL_GEQUAL; + public static final int GL_LESS = RealOpenGLEnums.GL_LESS; + public static final int GL_POINTS = RealOpenGLEnums.GL_POINTS; + + static final GLObjectMap texObjects = new GLObjectMap(256); + + static boolean enableTexture2D = false; + static boolean enableTexture2D_1 = false; + static boolean enableLighting = false; + static boolean enableAlphaTest = false; + public static float alphaThresh = 0.1f; + + static boolean isDepthTest = false; + static int currentDepthFunc = -99999; + static boolean isCullFace = false; + static int currentCullFace = -99999; + static boolean isPolygonOffset = false; + static float polygonOffset1 = -999.9f; + static float polygonOffset2 = -999.9f; + static boolean isBlend = false; + static int blendSRC = 0; + static int blendDST = 0; + static int colorMask = 15; + static boolean isDepthMask = true; + + static boolean isCompilingDisplayList = false; + static DisplayList compilingDisplayList = null; + + static boolean enableColorArray = false; + static boolean enableNormalArray = false; + static boolean enableTex0Array = false; + static boolean enableTex1Array = false; + + public static boolean enableAnisotropicFix = false; + public static int anisotropicFixSerial = 0; + public static float anisotropicFixX = 1024.0f; + public static float anisotropicFixY = 1024.0f; + + public static int colorSerial = 0; + public static float colorR = 1.0f; + public static float colorG = 1.0f; + public static float colorB = 1.0f; + public static float colorA = 1.0f; + + public static int normalSerial = 0; + public static float normalX = 1.0f; + public static float normalY = 0.0f; + public static float normalZ = 0.0f; + + static int selectedTex = 0; + static int selectedClientTex = 0; + static int[] boundTexI = new int[2]; + static TextureGL[] boundTex = new TextureGL[2]; + public static int tex0Serial = 0; + public static float tex0X = 0; + public static float tex0Y = 0; + public static int tex1Serial = 0; + public static float tex1X = 0; + public static float tex1Y = 0; + static TextureGL boundTexture0 = null; + static boolean enableAnisotropicPatch = false; + static boolean hintAnisotropicPatch = false; + static boolean swapRB = true; + + public static final void anisotropicPatch(boolean e) { + enableAnisotropicPatch = e; } - public static void glEnableClientState(int glTextureState) { - glEnableVertexAttrib(glTextureState); + static boolean enableTexGen = false; + static boolean enableColorMaterial = false; + + public static int texPlaneSerial = 0; + public static int texSSerial = 0; + public static int texS_plane = 0; + public static float texS_X = 0.0f; + public static float texS_Y = 0.0f; + public static float texS_Z = 0.0f; + public static float texS_W = 0.0f; + + public static int texTSerial = 0; + public static int texT_plane = 0; + public static float texT_X = 0.0f; + public static float texT_Y = 0.0f; + public static float texT_Z = 0.0f; + public static float texT_W = 0.0f; + + public static int texRSerial = 0; + public static int texR_plane = 0; + public static float texR_X = 0.0f; + public static float texR_Y = 0.0f; + public static float texR_Z = 0.0f; + public static float texR_W = 0.0f; + + public static int texQSerial = 0; + public static int texQ_plane = 0; + public static float texQ_X = 0.0f; + public static float texQ_Y = 0.0f; + public static float texQ_Z = 0.0f; + public static float texQ_W = 0.0f; + + public static int fogColorSerial = 0; + public static float fogColorR = 1.0f; + public static float fogColorG = 1.0f; + public static float fogColorB = 1.0f; + public static float fogColorA = 1.0f; + public static int fogCfgSerial = 0; + public static int fogMode = 1; + static boolean fogEnabled = false; + public static float fogStart = 1.0f; + public static float fogEnd = 1.0f; + public static float fogDensity = 1.0f; + + static int bytesUploaded = 0; + static int vertexDrawn = 0; + static int triangleDrawn = 0; + + static int matrixMode = GL_MODELVIEW; + + public static int matModelSerialCounter = 0; + public static int[] matModelVSerial = new int[32]; + public static Matrix4f[] matModelV = new Matrix4f[32]; + public static int matModelPointer = 0; + + public static int matProjSerialCounter = 0; + public static int[] matProjVSerial = new int[6]; + public static Matrix4f[] matProjV = new Matrix4f[6]; + public static int matProjPointer = 0; + + public static int matTexSerialCounter = 0; + public static int[] matTexVSerial = new int[16]; + public static Matrix4f[] matTexV = new Matrix4f[16]; + public static int matTexPointer = 0; + + static { + for (int i = 0; i < matModelV.length; ++i) { + matModelV[i] = new Matrix4f(); + } + for (int i = 0; i < matProjV.length; ++i) { + matProjV[i] = new Matrix4f(); + } + for (int i = 0; i < matTexV.length; ++i) { + matTexV[i] = new Matrix4f(); + } } - public static void glDisableClientState(int glTextureState) { - glDisableVertexAttrib(glTextureState); + 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; + } + + 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 List translate = new ArrayList(); + + private DisplayList(int id) { + this.id = id; + this.glarray = null; + this.glbuffer = null; + this.shaderMode = -1; + this.listLength = 0; + } } + private static class Translate { + private float f, f1, f2; + + private Translate(float f, float f1, float f2) { + this.f = f; + this.f1 = f1; + this.f2 = f2; + } + } + + 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) { + case GL_DEPTH_TEST: + if(!isDepthTest) { + _wglEnable(_wGL_DEPTH_TEST); + isDepthTest = true; + } + break; + case GL_CULL_FACE: + if(!isCullFace) { + _wglEnable(_wGL_CULL_FACE); + isCullFace = true; + } + break; + case GL_BLEND: + if(!isBlend) { + _wglEnable(_wGL_BLEND); + isBlend = true; + } + break; + case GL_RESCALE_NORMAL: + break; + case GL_TEXTURE_2D: + if (selectedTex == 0) { + enableTexture2D = true; + } + if (selectedTex == 1) { + enableTexture2D_1 = true; + } + break; + case GL_LIGHTING: + enableLighting = true; + break; + case GL_ALPHA_TEST: + enableAlphaTest = true; + break; + case GL_FOG: + fogEnabled = true; + break; + case GL_COLOR_MATERIAL: + enableColorMaterial = true; + break; + case GL_TEXTURE_GEN_S: + case GL_TEXTURE_GEN_T: + case GL_TEXTURE_GEN_R: + case GL_TEXTURE_GEN_Q: + enableTexGen = true; + break; + case GL_POLYGON_OFFSET_FILL: + if(!isPolygonOffset) { + _wglEnable(_wGL_POLYGON_OFFSET_FILL); + isPolygonOffset = true; + } + break; + case EAG_SWAP_RB: + swapRB = true; + break; + default: + break; + } + } + + public static final void glShadeModel(int p1) { + + } + + public static final void glClearDepth(float p1) { + _wglClearDepth(1.0F-p1); + } + + public static final void glClearDepth(double p1) { + _wglClearDepth((float)(1.0F-p1)); + } + + public static final void glDepthFunc(int p1) { + int rev = p1; + switch(p1) { + case GL_GREATER: + rev = _wGL_LESS; + break; + case GL_GEQUAL: + rev = _wGL_LEQUAL; + break; + case GL_EQUAL: + rev = _wGL_EQUAL; + break; + case GL_LEQUAL: + rev = _wGL_GEQUAL; + break; + case GL_LESS: + rev = _wGL_GREATER; + break; + } + if(rev != currentDepthFunc) { + _wglDepthFunc(rev); + currentDepthFunc = rev; + } + } + + public static final void glAlphaFunc(int p1, float p2) { + alphaThresh = p2; + } + + public static final void glCullFace(int p1) { + if(p1 != currentCullFace) { + _wglCullFace(p1); + currentCullFace = p1; + } + } + + public static final void glMatrixMode(int p1) { + matrixMode = p1; + } + + private static final Matrix4f getMatrixIncrSerial() { + switch (matrixMode) { + case GL_MODELVIEW: + default: + matModelVSerial[matModelPointer] = ++matModelSerialCounter; + return matModelV[matModelPointer]; + case GL_PROJECTION: + matProjVSerial[matProjPointer] = ++matProjSerialCounter; + return matProjV[matProjPointer]; + case GL_TEXTURE: + matTexVSerial[matTexPointer] = ++matTexSerialCounter; + return matTexV[matTexPointer]; + } + } + + public static final void glLoadIdentity() { + getMatrixIncrSerial().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 = getMatrixIncrSerial(); + 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; + } + + public static final void glOrtho(double left, double right, double bottom, double top, double zNear, double zFar) { + glOrtho((float) left, (float) right, (float) bottom, (float) top, (float) zNear, (float) zFar); + } + + private static final Vector3f deevis = new Vector3f(); + + public static final void glTranslatef(float p1, float p2, float p3) { +// deevis.set(p1, p2, p3); +// getMatrixIncrSerial().translate(deevis); +// if (isCompilingDisplayList) { +// System.err.println("matrix is not supported while recording display list use tessellator class instead"); +// } + deevis.set(p1, p2, p3); + getMatrixIncrSerial().translate(deevis); + if (isCompilingDisplayList) { + compilingDisplayList.translate.add(new Translate(p1, p2, p3)); + //throw new IllegalArgumentException("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) { + case GL_DEPTH_TEST: + if(isDepthTest) { + _wglDisable(_wGL_DEPTH_TEST); + isDepthTest = false; + } + break; + case GL_CULL_FACE: + if(isCullFace) { + _wglDisable(_wGL_CULL_FACE); + isCullFace = false; + } + break; + case GL_BLEND: + if(isBlend) { + _wglDisable(_wGL_BLEND); + isBlend = false; + } + break; + case GL_RESCALE_NORMAL: + break; + case GL_TEXTURE_2D: + if (selectedTex == 0) { + enableTexture2D = false; + } + if (selectedTex == 1) { + enableTexture2D_1 = false; + } + break; + case GL_LIGHTING: + enableLighting = false; + break; + case GL_ALPHA_TEST: + enableAlphaTest = false; + break; + case GL_FOG: + fogEnabled = false; + break; + case GL_COLOR_MATERIAL: + enableColorMaterial = false; + break; + case GL_TEXTURE_GEN_S: + case GL_TEXTURE_GEN_T: + case GL_TEXTURE_GEN_R: + case GL_TEXTURE_GEN_Q: + enableTexGen = false; + break; + case GL_POLYGON_OFFSET_FILL: + if(isPolygonOffset) { + _wglDisable(_wGL_POLYGON_OFFSET_FILL); + isPolygonOffset = false; + } + break; + case EAG_SWAP_RB: + swapRB = false; + break; + default: + break; + } + } + + public static final void glColor4f(float p1, float p2, float p3, float p4) { + ++colorSerial; + 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; + return err; + } + + public static final void glFlush() { + _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) { + 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 glLightModel(int p1, FloatBuffer p2) { + + } + + public static int lightPos0Serial = 0; + public static int lightPos1Serial = 0; + private static Vector4f lightPos0vec0 = new Vector4f(); + private static Vector4f lightPos1vec0 = new Vector4f(); + public static Vector4f lightPos0vec = new Vector4f(); + public static Vector4f lightPos1vec = new Vector4f(); + + private static float[] light0 = new float[4]; + private static float[] light1 = new float[4]; + + public static final void glLight(int light, int pname, FloatBuffer param) { + if(pname == GL_POSITION) { + switch(light) { + case GL_LIGHT0: + try { + light0[0] = param.get(param.position()); + light0[1] = param.get(param.position() + 1); + light0[2] = param.get(param.position() + 2); + light0[3] = param.get(param.position() + 3); + } catch(Exception e) { + System.err.println("Failed to shade model (GL_LIGHT0)"); + light0[0] = 0.0F; + light0[1] = 0.0F; + light0[2] = 0.0F; + light0[3] = 0.0F; + } + case GL_LIGHT1: + try { + light1[0] = param.get(param.position()); + light1[1] = param.get(param.position() + 1); + light1[2] = param.get(param.position() + 2); + light1[3] = param.get(param.position() + 3); + } catch(Exception e) { + System.err.println("Failed to shade model (GL_LIGHT1)"); + light1[0] = 0.0F; + light1[1] = 0.0F; + light1[2] = 0.0F; + light1[3] = 0.0F; + } + } + } + } + + public static final void copyModelToLightMatrix() { + ++lightPos0Serial; + ++lightPos1Serial; + lightPos0vec0.set(lightPos0vec); + lightPos1vec0.set(lightPos1vec); + lightPos0vec.set(light1[0], light1[1], light1[2], light1[3]); + lightPos0vec.normalise(); + lightPos1vec.set(light0[0], light0[1], light0[2], light0[3]); + lightPos1vec.normalise(); + Matrix4f.transform(matModelV[matModelPointer], lightPos0vec, lightPos0vec).normalise(); + Matrix4f.transform(matModelV[matModelPointer], lightPos1vec, lightPos1vec).normalise(); + } + + public static final void copyModelToLightMatrix2() { + ++lightPos0Serial; + ++lightPos1Serial; + 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(); + Matrix4f.transform(matModelV[matModelPointer], lightPos0vec, lightPos0vec).normalise(); + Matrix4f.transform(matModelV[matModelPointer], lightPos1vec, lightPos1vec).normalise(); + } + + public static final void flipBothLightMatrix() { + ++lightPos0Serial; + ++lightPos1Serial; + lightPos0vec.x = -lightPos0vec.x; + lightPos1vec.x = -lightPos1vec.x; + lightPos0vec.y = -lightPos0vec.y; + lightPos1vec.y = -lightPos1vec.y; + lightPos0vec.z = -lightPos0vec.z; + lightPos1vec.z = -lightPos1vec.z; + } + + public static final void flipFirstLightMatrix() { + ++lightPos0Serial; + ++lightPos1Serial; + lightPos0vec.x = -lightPos0vec.x; + lightPos0vec.y = -lightPos0vec.y; + lightPos0vec.z = -lightPos0vec.z; + } + + public static final void flipSecondLightMatrix() { + ++lightPos0Serial; + ++lightPos1Serial; + lightPos1vec.x = -lightPos1vec.x; + lightPos1vec.y = -lightPos1vec.y; + lightPos1vec.z = -lightPos1vec.z; + } + + public static final void revertBothLightMatrix() { + ++lightPos0Serial; + ++lightPos1Serial; + lightPos0vec.set(lightPos0vec0); + lightPos1vec.set(lightPos1vec0); + } + + public static final void revertFirstLightMatrix() { + ++lightPos0Serial; + ++lightPos1Serial; + lightPos0vec.set(lightPos0vec0); + } + + public static final void revertSecondLightMatrix() { + ++lightPos0Serial; + ++lightPos1Serial; + lightPos1vec.set(lightPos1vec0); + } + + public static final void glPushMatrix() { + switch (matrixMode) { + case GL_MODELVIEW: + default: + if (matModelPointer < matModelV.length - 1) { + ++matModelPointer; + matModelV[matModelPointer].load(matModelV[matModelPointer - 1]); + matModelVSerial[matModelPointer] = matModelVSerial[matModelPointer - 1]; + } else { + System.err.println("modelview matrix stack overflow"); + } + break; + case GL_PROJECTION: + if (matProjPointer < matProjV.length - 1) { + ++matProjPointer; + matProjV[matProjPointer].load(matProjV[matProjPointer - 1]); + matProjVSerial[matProjPointer] = matProjVSerial[matProjPointer - 1]; + } else { + System.err.println("projection matrix stack overflow"); + } + break; + case GL_TEXTURE: + if (matTexPointer < matTexV.length - 1) { + ++matTexPointer; + matTexV[matTexPointer].load(matTexV[matTexPointer - 1]); + matTexVSerial[matTexPointer] = matTexVSerial[matTexPointer - 1]; + } 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); + getMatrixIncrSerial().rotate(p1 * toRad, deevis); + if (isCompilingDisplayList) { + System.err.println("matrix is not supported while recording display list use tessellator class instead"); + } + } + + public static final void glPopMatrix() { + switch (matrixMode) { + case GL_MODELVIEW: + default: + if (matModelPointer > 0) { + --matModelPointer; + } else { + System.err.println("modelview matrix stack underflow"); + } + break; + case GL_PROJECTION: + if (matProjPointer > 0) { + --matProjPointer; + } else { + System.err.println("projection matrix stack underflow"); + } + break; + case GL_TEXTURE: + if (matTexPointer > 0) { + --matTexPointer; + } 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) { + case GL_MODELVIEW_MATRIX: + default: + matModelV[matModelPointer].store(p2); + break; + case GL_PROJECTION_MATRIX: + matProjV[matProjPointer].store(p2); + break; + } + } + + public static final void glGetInteger(int p1, int[] p2) { + 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); + getMatrixIncrSerial().scale(deevis); + if (isCompilingDisplayList) { + System.err.println("matrix is not supported while recording display list use tessellator class instead"); + } + } + + public static final void glScaled(double p1, double p2, double p3) { + glScalef((float)p1, (float)p2, (float)p3); + } + + private static final Matrix4f tmpMat = new Matrix4f(); + + public static final void glMultMatrixf(Matrix4f mat) { + getMatrixIncrSerial().load(Matrix4f.mul(getMatrixIncrSerial(), mat, tmpMat)); + } + + public static final void glBlendFunc(int p1, int p2) { + if(overlayFBOBlending) { + int i = p1 | 0x10000; + int j = p2 | 0x10000; + if(blendSRC != i || blendDST != j) { + _wglBlendFuncSeparate(p1, p2, GL_ONE, GL_ONE_MINUS_SRC_ALPHA); + blendSRC = i; + blendDST = j; + } + }else { + if(blendSRC != p1 || blendDST != p2) { + _wglBlendFunc(p1, p2); + blendSRC = p1; + blendDST = p2; + } + } + } + + private static boolean overlayFBOBlending = false; + + public static final void enableOverlayFramebufferBlending(boolean en) { + overlayFBOBlending = en; + } + + public static final void glDepthMask(boolean p1) { + if(isDepthMask != p1) { + _wglDepthMask(p1); + isDepthMask = p1; + } + } + + public static final void glColorMask(boolean p1, boolean p2, boolean p3, boolean p4) { + int hsh = (p1 ? 1 : 0) | (p2 ? 2 : 0) | (p3 ? 4 : 0) | (p4 ? 8 : 0); + if(colorMask != hsh) { + _wglColorMask(p1, p2, p3, p4); + colorMask = hsh; + } + } + + private static final void updateAnisotropicPatch() { + if (selectedTex == 0) { + enableAnisotropicFix = false; + if (enableAnisotropicPatch && boundTexture0 != null && boundTexture0.anisotropic && boundTexture0.nearest) { + enableAnisotropicFix = true; + ++anisotropicFixSerial; + anisotropicFixX = boundTexture0.w; + anisotropicFixY = boundTexture0.h; + } + } + } + + public static final void glBindTexture(int p1, int p2) { + if(boundTexI[selectedTex] != p2) { + TextureGL t = texObjects.get(p2); + if(boundTex[selectedTex] != t) { + _wglBindTexture(_wGL_TEXTURE_2D, t); + if (selectedTex == 0) { + boundTexture0 = t; + updateAnisotropicPatch(); + } + boundTex[selectedTex] = t; + } + boundTexI[selectedTex] = p2; + } + } + + public static final void glBindTexture(int p1, TextureGL p2) { + boundTexI[selectedTex] = -1; + if(boundTex[selectedTex] != p2) { + _wglBindTexture(_wGL_TEXTURE_2D, p2); + if (selectedTex == 0) { + boundTexture0 = p2; + updateAnisotropicPatch(); + } + boundTex[selectedTex] = p2; + } + } + + 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) { + boundTexture0.nearest = p3 == GL_NEAREST; + } + _wglTexParameteri(p1, p2, p3); + updateAnisotropicPatch(); + } + + public static final void glTexParameterf(int p1, int p2, float p3) { + if(p2 == GL_TEXTURE_MAX_ANISOTROPY && !anisotropicFilteringSupported()) { + return; + } + 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) { + ++normalSerial; + //float len = (float) Math.sqrt(p1 * p1 + p2 * p2 + p3 * p3); + //normalX = p1 / len; + //normalY = p2 / len; + //normalZ = p3 / len; + normalX = p1; + normalY = p2; + normalZ = p3; + } + + public static final int glGenLists(int p1) { + int base = displayListId + 1; + 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) { + if(currentArray != p1) { + currentArray = p1; + _wglBindVertexArray(p1); + } + } + + private static int displayListId = 0; + + public static final void glCallList(int p1) { + if (!isCompilingDisplayList) { + DisplayList d = displayListsInitialized.get(p1); + if (d != null && d.listLength > 0) { + bindTheShader(d.shaderMode | getShaderModeFlag1()); + _wglBindVertexArray0(d.glarray); + + //glTranslate support for display lists + for(Translate t : d.translate) { + deevis.set(t.f, t.f1, t.f2); + getMatrixIncrSerial().translate(deevis); + } + + _wglDrawQuadArrays(0, d.listLength); + shader.unuseProgram(); + vertexDrawn += d.listLength * 6 / 4; + triangleDrawn += d.listLength / 2; + } + } + } + + public static final void glNewList(int p1, int p2) { + if (!isCompilingDisplayList) { + compilingDisplayList = displayLists.get(p1); + if (compilingDisplayList != null) { + compilingDisplayList.shaderMode = -1; + compilingDisplayList.listLength = 0; + isCompilingDisplayList = true; + } + } + } + + public static final void glEndList() { + if (isCompilingDisplayList) { + isCompilingDisplayList = false; + Object upload = _wGetLowLevelBuffersAppended(); + int l = _wArrayByteLength(upload); + if (l > 0) { + if (compilingDisplayList.glbuffer == null) { + displayListsInitialized.put(compilingDisplayList.id, compilingDisplayList); + compilingDisplayList.glarray = _wglCreateVertexArray(); + compilingDisplayList.glbuffer = _wglCreateBuffer(); + FixedFunctionShader f = FixedFunctionShader.instance(compilingDisplayList.shaderMode); + _wglBindVertexArray0(compilingDisplayList.glarray); + _wglBindBuffer(_wGL_ARRAY_BUFFER, compilingDisplayList.glbuffer); + f.setupArrayForProgram(); + } + _wglBindBuffer(_wGL_ARRAY_BUFFER, compilingDisplayList.glbuffer); + _wglBufferData(_wGL_ARRAY_BUFFER, upload, _wGL_STATIC_DRAW); + bytesUploaded += l; + } + } + } + + public static final void flushDisplayList(int p1) { + DisplayList d = displayListsInitialized.get(p1); + if (d != null) { + if (d.glbuffer != null) { + _wglDeleteBuffer(d.glbuffer); + _wglDeleteVertexArray(d.glarray); + d.glbuffer = null; + d.glarray = null; + } + } + } + + public static final void glColor3f(float p1, float p2, float p3) { + ++colorSerial; + colorR = p1; + colorG = p2; + colorB = p3; + colorA = 1.0f; + } + + public static final void glTexGeni(int p1, int p2, int p3) { + + } + + private static final Vector4f tmpTexGenPlane = new Vector4f(); + + public static final void glTexGen(int p1, int p2, FloatBuffer p3) { + Vector4f vec = tmpTexGenPlane; + vec.load(p3); + if(p2 == GL_EYE_PLANE) { + tmpMat.load(matModelV[matModelPointer]).invert().transpose(); + Matrix4f.transform(tmpMat, vec, vec); + } + switch (p1) { + case GL_S: + ++texPlaneSerial; + ++texSSerial; + texS_plane = (p2 == GL_EYE_PLANE ? 1 : 0); + texS_X = vec.x; + texS_Y = vec.y; + texS_Z = vec.z; + texS_W = vec.w; + break; + case GL_T: + ++texPlaneSerial; + ++texTSerial; + texT_plane = (p2 == GL_EYE_PLANE ? 1 : 0); + texT_X = vec.x; + texT_Y = vec.y; + texT_Z = vec.z; + texT_W = vec.w; + break; + case GL_R: + ++texPlaneSerial; + ++texRSerial; + texR_plane = (p2 == GL_EYE_PLANE ? 1 : 0); + texR_X = vec.x; + texR_Y = vec.y; + texR_Z = vec.z; + texR_W = vec.w; + break; + case GL_Q: + ++texPlaneSerial; + ++texQSerial; + texQ_plane = (p2 == GL_EYE_PLANE ? 1 : 0); + texQ_X = vec.x; + texQ_Y = vec.y; + texQ_Z = vec.z; + texQ_W = vec.w; + break; + } + } + + 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) { + boundTexture0.w = p4; + boundTexture0.h = p5; + } + 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) { + boundTexture0.w = p4; + boundTexture0.h = p5; + } + 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) { + int pp1 = 0; + switch (p1) { + default: + 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; + _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 glDeleteTextures(IntBuffer p1) { + while(p1.hasRemaining()) { + _wglDeleteTextures(texObjects.free(p1.get())); + } + } + + public static final void glPolygonOffset(float p1, float p2) { + if(p1 != polygonOffset1 || p2 != polygonOffset2) { + _wglPolygonOffset(p1, p2); + polygonOffset1 = p1; + polygonOffset2 = p2; + } + } + + public static final void glCallLists(IntBuffer p1) { + while (p1.hasRemaining()) { + glCallList(p1.get()); + } + } + + public static final void glEnableClientState(int p1) { + switch (p1) { + case GL_COLOR_ARRAY: + enableColorArray = true; + break; + case GL_NORMAL_ARRAY: + enableNormalArray = true; + break; + case GL_TEXTURE_COORD_ARRAY: + switch (selectedClientTex) { + case 0: + enableTex0Array = true; + break; + case 1: + enableTex1Array = true; + break; + default: + break; + } + break; + default: + break; + } + } + + public static final void glDisableClientState(int p1) { + switch (p1) { + case GL_COLOR_ARRAY: + enableColorArray = false; + break; + case GL_NORMAL_ARRAY: + enableNormalArray = false; + break; + case GL_TEXTURE_COORD_ARRAY: + switch (selectedClientTex) { + case 0: + enableTex0Array = false; + break; + case 1: + enableTex1Array = false; + break; + default: + break; + } + break; + default: + break; + } + } + + public static final void hintAnisotropicFix(boolean hint) { + hintAnisotropicPatch = hint; + } + + private static final int getShaderModeFlag0() { + int mode = 0; + mode = (mode | (enableColorArray ? FixedFunctionShader.COLOR : 0)); + mode = (mode | (enableNormalArray ? FixedFunctionShader.NORMAL : 0)); + mode = (mode | (enableTex0Array ? FixedFunctionShader.TEXTURE0 : 0)); + mode = (mode | (enableTex1Array ? FixedFunctionShader.TEXTURE1 : 0)); + return mode; + } + + private static final int getShaderModeFlag1() { + int mode = 0; + mode = (mode | (enableTexGen ? FixedFunctionShader.TEXGEN : 0)); + mode = (mode | ((enableColorMaterial && enableLighting) ? FixedFunctionShader.LIGHTING : 0)); + mode = (mode | (fogEnabled ? FixedFunctionShader.FOG : 0)); + 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 | (swapRB ? FixedFunctionShader.SWAP_RB : 0)); + return mode; + } + + private static final int getShaderModeFlag() { + int mode = 0; + mode = (mode | (enableColorArray ? FixedFunctionShader.COLOR : 0)); + mode = (mode | (enableNormalArray ? FixedFunctionShader.NORMAL : 0)); + mode = (mode | (enableTex0Array ? FixedFunctionShader.TEXTURE0 : 0)); + mode = (mode | (enableTex1Array ? FixedFunctionShader.TEXTURE1 : 0)); + mode = (mode | (enableTexGen ? FixedFunctionShader.TEXGEN : 0)); + mode = (mode | ((enableColorMaterial && enableLighting) ? FixedFunctionShader.LIGHTING : 0)); + mode = (mode | (fogEnabled ? FixedFunctionShader.FOG : 0)); + 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 | (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(); + s.update(); + } + + static Tessellator tess = Tessellator.instance; + + public static void glBegin(int mode) { + tess.startDrawing(mode); + } + + public static void glTexCoord2f(float x, float z) { + tess.setTextureUV(x, z); + } + + public static void glVertex3f(float x, float y, float z) { + tess.addVertex(x, y, z); + } + + public static void glEnd() { + tess.draw(); + } + + 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) { + compilingDisplayList.shaderMode = getShaderModeFlag0(); + } else { + if (compilingDisplayList.shaderMode != getShaderModeFlag0()) { + System.err.println("vertex format inconsistent in display list"); + } + } + compilingDisplayList.listLength += p3; + _wAppendLowLevelBuffer(buffer); + } else { + System.err.println("only GL_QUADS supported in a display list"); + } + } else { + int bl = _wArrayByteLength(buffer); + bytesUploaded += bl; + vertexDrawn += p3; + + bindTheShader(); + + StreamBufferInstance sb = shader.streamBuffer.getBuffer(bl); + _wglBindVertexArray0(sb.vertexArray); + _wglBindBuffer(_wGL_ARRAY_BUFFER, sb.vertexBuffer); + if (!shader.bufferIsInitialized) { + shader.bufferIsInitialized = true; + _wglBufferData(_wGL_ARRAY_BUFFER, blankUploadArray, _wGL_DYNAMIC_DRAW); + } + _wglBufferSubData(_wGL_ARRAY_BUFFER, 0, buffer); + + if (p1 == GL_QUADS) { + _wglDrawQuadArrays(p2, p3); + triangleDrawn += p3 / 2; + } else { + switch (p1) { + default: + case GL_TRIANGLES: + triangleDrawn += p3 / 3; + break; + case GL_TRIANGLE_STRIP: + triangleDrawn += p3 - 2; + break; + case GL_TRIANGLE_FAN: + triangleDrawn += p3 - 2; + break; + case GL_LINE_STRIP: + triangleDrawn += p3 - 1; + break; + case GL_LINES: + triangleDrawn += p3 / 2; + break; + } + _wglDrawArrays(p1, p2, p3); + } + + shader.unuseProgram(); + + } + } + + private static final void _wglDrawQuadArrays(int p2, int p3) { + if (quadsToTrianglesBuffer == null) { + IntBuffer upload = IntBuffer.wrap(new int[98400 / 2]); + for (int i = 0; i < 16384; ++i) { + int v1 = i * 4; + int v2 = i * 4 + 1; + int v3 = i * 4 + 2; + int v4 = i * 4 + 3; + upload.put(v1 | (v2 << 16)); + upload.put(v4 | (v2 << 16)); + upload.put(v3 | (v4 << 16)); + } + upload.flip(); + quadsToTrianglesBuffer = _wglCreateBuffer(); + _wglBindBuffer(_wGL_ELEMENT_ARRAY_BUFFER, quadsToTrianglesBuffer); + _wglBufferData0(_wGL_ELEMENT_ARRAY_BUFFER, upload, _wGL_STATIC_DRAW); + } + 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 = IntBuffer.wrap(new int[108]); + 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"); + + _wglCompileShader(frag); + 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); + _wglDetachShader(occlusion_program, vert); + _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] ")); + + _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() { + return queryObjs.register(_wglCreateQuery()); + } + + 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(); + _wglUseProgram(occlusion_program); + _wglBindVertexArray0(occlusion_vao); + 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) { + glPushMatrix(); + glTranslatef(posX - sizeX * 0.01f, posY - sizeY * 0.01f, posZ - sizeZ * 0.01f); + glScalef(sizeX * 1.02f, sizeY * 1.02f, sizeZ * 1.02f); + matModelV[matModelPointer].store(occlusionModel); + _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; + } + + public static final void glGetQueryResult(int in, IntBuffer out) { + QueryGL q = queryObjs.get(in); + out.put(_wglGetQueryObjecti(q, _wGL_QUERY_RESULT_AVAILABLE)); + } + + public static final int glGenTextures() { + return texObjects.register(_wglGenTextures()); + } + + public static final void glGenTextures(IntBuffer buf) { + for(int i = buf.position(); i < buf.limit(); i++) { + buf.put(i, glGenTextures()); + } + } + + 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) { + default: + 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(); + _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) { + default: + case GL_LINEAR: + ++fogCfgSerial; + fogMode = 1; + break; + case GL_EXP: + ++fogCfgSerial; + fogMode = 2; + break; + } + } + } + + public static final void glFogf(int p1, float p2) { + switch (p1) { + case GL_FOG_START: + ++fogCfgSerial; + fogStart = p2; + break; + case GL_FOG_END: + ++fogCfgSerial; + fogEnd = p2; + break; + case GL_FOG_DENSITY: + ++fogCfgSerial; + fogDensity = p2; + break; + default: + break; + } + } + + public static final void glFog(int p1, FloatBuffer p2) { + if (p1 == GL_FOG_COLOR) { + ++fogColorSerial; + 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++) { + DisplayList d = displayListsInitialized.remove(p1 + i); + if (d != null) { + _wglDeleteVertexArray(d.glarray); + _wglDeleteBuffer(d.glbuffer); + } + displayLists.remove(p1 + i); + } + } + + public static final void glActiveTexture(int p1) { + switch (p1) { + case GL_TEXTURE0: + if(selectedTex != 0) { + selectedTex = 0; + _wglActiveTexture(_wGL_TEXTURE0); + } + break; + case GL_TEXTURE1: + if(selectedTex != 1) { + selectedTex = 1; + _wglActiveTexture(_wGL_TEXTURE1); + } + break; + default: + System.err.println("only two texture units implemented"); + break; + } + } + + public static final void glClientActiveTexture(int p1) { + switch (p1) { + case GL_TEXTURE0: + selectedClientTex = 0; + break; + case GL_TEXTURE1: + selectedClientTex = 1; + break; + default: + System.err.println("only two texture units implemented"); + break; + } + } + + public static final void glMultiTexCoord2f(int p1, float p2, float p3) { + switch (p1) { + case GL_TEXTURE0: + ++tex0Serial; + tex0X = p2; + tex0Y = p3; + break; + case GL_TEXTURE1: + ++tex1Serial; + tex1X = p2; + tex1Y = p3; + break; + default: + System.err.println("only two texture units implemented"); + 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) { + 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); + 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 = getMatrixIncrSerial(); + float cotangent = (float) Math.cos(fovy * toRad * 0.5f) / (float) Math.sin(fovy * toRad * 0.5f); + res.m00 = cotangent / aspect; + res.m01 = 0.0f; + res.m02 = 0.0f; + res.m03 = 0.0f; + res.m10 = 0.0f; + res.m11 = cotangent; + res.m12 = 0.0f; + res.m13 = 0.0f; + res.m20 = 0.0f; + res.m21 = 0.0f; + res.m22 = (zFar + zNear) / (zFar - zNear); + res.m23 = -1.0f; + res.m30 = 0.0f; + res.m31 = 0.0f; + 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 = getMatrixIncrSerial(); + float cotangent = (float) Math.cos(fovy * toRad * 0.5f) / (float) Math.sin(fovy * toRad * 0.5f); + res.m00 = cotangent / aspect; + res.m01 = 0.0f; + res.m02 = 0.0f; + res.m03 = 0.0f; + res.m10 = 0.0f; + res.m11 = cotangent; + res.m12 = 0.0f; + res.m13 = 0.0f; + res.m20 = 0.0f; + res.m21 = 0.0f; + res.m22 = ((zFar + zNear) / (zFar - zNear)) * 0.001f; + res.m23 = -1.0f; + res.m30 = 0.0f; + res.m31 = 0.0f; + 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"; + } + } + + public static final void optimize() { + FixedFunctionShader.optimize(); + } + + private static long lastBandwidthReset = 0l; + private static int lastBandwidth = 0; + + public static final int getBitsPerSecond() { + 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; + return ret; + } + + + @SuppressWarnings("unused") + private static class RealOpenGLEnums { + + // Field descriptor #544 I + public static final int GL_ACCUM = 256; + + // Field descriptor #544 I + public static final int GL_LOAD = 257; + + // Field descriptor #544 I + public static final int GL_RETURN = 258; + + // Field descriptor #544 I + public static final int GL_MULT = 259; + + // Field descriptor #544 I + public static final int GL_ADD = 260; + + // Field descriptor #544 I + public static final int GL_NEVER = 512; + + // Field descriptor #544 I + public static final int GL_LESS = 513; + + // Field descriptor #544 I + public static final int GL_EQUAL = 514; + + // Field descriptor #544 I + public static final int GL_LEQUAL = 515; + + // Field descriptor #544 I + public static final int GL_GREATER = 516; + + // Field descriptor #544 I + public static final int GL_NOTEQUAL = 517; + + // Field descriptor #544 I + public static final int GL_GEQUAL = 518; + + // Field descriptor #544 I + public static final int GL_ALWAYS = 519; + + // Field descriptor #544 I + public static final int GL_CURRENT_BIT = 1; + + // Field descriptor #544 I + public static final int GL_POINT_BIT = 2; + + // Field descriptor #544 I + public static final int GL_LINE_BIT = 4; + + // Field descriptor #544 I + public static final int GL_POLYGON_BIT = 8; + + // Field descriptor #544 I + public static final int GL_POLYGON_STIPPLE_BIT = 16; + + // Field descriptor #544 I + public static final int GL_PIXEL_MODE_BIT = 32; + + // Field descriptor #544 I + public static final int GL_LIGHTING_BIT = 64; + + // Field descriptor #544 I + public static final int GL_FOG_BIT = 128; + + // Field descriptor #544 I + public static final int GL_DEPTH_BUFFER_BIT = 256; + + // Field descriptor #544 I + public static final int GL_ACCUM_BUFFER_BIT = 512; + + // Field descriptor #544 I + public static final int GL_STENCIL_BUFFER_BIT = 1024; + + // Field descriptor #544 I + public static final int GL_VIEWPORT_BIT = 2048; + + // Field descriptor #544 I + public static final int GL_TRANSFORM_BIT = 4096; + + // Field descriptor #544 I + public static final int GL_ENABLE_BIT = 8192; + + // Field descriptor #544 I + public static final int GL_COLOR_BUFFER_BIT = 16384; + + // Field descriptor #544 I + public static final int GL_HINT_BIT = 32768; + + // Field descriptor #544 I + public static final int GL_EVAL_BIT = 65536; + + // Field descriptor #544 I + public static final int GL_LIST_BIT = 131072; + + // Field descriptor #544 I + public static final int GL_TEXTURE_BIT = 262144; + + // Field descriptor #544 I + public static final int GL_SCISSOR_BIT = 524288; + + // Field descriptor #544 I + public static final int GL_ALL_ATTRIB_BITS = 1048575; + + // Field descriptor #544 I + public static final int GL_POINTS = 0; + + // Field descriptor #544 I + public static final int GL_LINES = 1; + + // Field descriptor #544 I + public static final int GL_LINE_LOOP = 2; + + // Field descriptor #544 I + public static final int GL_LINE_STRIP = 3; + + // Field descriptor #544 I + public static final int GL_TRIANGLES = 4; + + // Field descriptor #544 I + public static final int GL_TRIANGLE_STRIP = 5; + + // Field descriptor #544 I + public static final int GL_TRIANGLE_FAN = 6; + + // Field descriptor #544 I + public static final int GL_QUADS = 7; + + // Field descriptor #544 I + public static final int GL_QUAD_STRIP = 8; + + // Field descriptor #544 I + public static final int GL_POLYGON = 9; + + // Field descriptor #544 I + public static final int GL_ZERO = 0; + + // Field descriptor #544 I + public static final int GL_ONE = 1; + + // Field descriptor #544 I + public static final int GL_SRC_COLOR = 768; + + // Field descriptor #544 I + public static final int GL_ONE_MINUS_SRC_COLOR = 769; + + // Field descriptor #544 I + public static final int GL_SRC_ALPHA = 770; + + // Field descriptor #544 I + public static final int GL_ONE_MINUS_SRC_ALPHA = 771; + + // Field descriptor #544 I + public static final int GL_DST_ALPHA = 772; + + // Field descriptor #544 I + public static final int GL_ONE_MINUS_DST_ALPHA = 773; + + // Field descriptor #544 I + public static final int GL_DST_COLOR = 774; + + // Field descriptor #544 I + public static final int GL_ONE_MINUS_DST_COLOR = 775; + + // Field descriptor #544 I + public static final int GL_SRC_ALPHA_SATURATE = 776; + + // Field descriptor #544 I + public static final int GL_CONSTANT_COLOR = 32769; + + // Field descriptor #544 I + public static final int GL_ONE_MINUS_CONSTANT_COLOR = 32770; + + // Field descriptor #544 I + public static final int GL_CONSTANT_ALPHA = 32771; + + // Field descriptor #544 I + public static final int GL_ONE_MINUS_CONSTANT_ALPHA = 32772; + + // Field descriptor #544 I + public static final int GL_TRUE = 1; + + // Field descriptor #544 I + public static final int GL_FALSE = 0; + + // Field descriptor #544 I + public static final int GL_CLIP_PLANE0 = 12288; + + // Field descriptor #544 I + public static final int GL_CLIP_PLANE1 = 12289; + + // Field descriptor #544 I + public static final int GL_CLIP_PLANE2 = 12290; + + // Field descriptor #544 I + public static final int GL_CLIP_PLANE3 = 12291; + + // Field descriptor #544 I + public static final int GL_CLIP_PLANE4 = 12292; + + // Field descriptor #544 I + public static final int GL_CLIP_PLANE5 = 12293; + + // Field descriptor #544 I + public static final int GL_BYTE = 5120; + + // Field descriptor #544 I + public static final int GL_UNSIGNED_BYTE = 5121; + + // Field descriptor #544 I + public static final int GL_SHORT = 5122; + + // Field descriptor #544 I + public static final int GL_UNSIGNED_SHORT = 5123; + + // Field descriptor #544 I + public static final int GL_INT = 5124; + + // Field descriptor #544 I + public static final int GL_UNSIGNED_INT = 5125; + + // Field descriptor #544 I + public static final int GL_FLOAT = 5126; + + // Field descriptor #544 I + public static final int GL_2_BYTES = 5127; + + // Field descriptor #544 I + public static final int GL_3_BYTES = 5128; + + // Field descriptor #544 I + public static final int GL_4_BYTES = 5129; + + // Field descriptor #544 I + public static final int GL_DOUBLE = 5130; + + // Field descriptor #544 I + public static final int GL_NONE = 0; + + // Field descriptor #544 I + public static final int GL_FRONT_LEFT = 1024; + + // Field descriptor #544 I + public static final int GL_FRONT_RIGHT = 1025; + + // Field descriptor #544 I + public static final int GL_BACK_LEFT = 1026; + + // Field descriptor #544 I + public static final int GL_BACK_RIGHT = 1027; + + // Field descriptor #544 I + public static final int GL_FRONT = 1028; + + // Field descriptor #544 I + public static final int GL_BACK = 1029; + + // Field descriptor #544 I + public static final int GL_LEFT = 1030; + + // Field descriptor #544 I + public static final int GL_RIGHT = 1031; + + // Field descriptor #544 I + public static final int GL_FRONT_AND_BACK = 1032; + + // Field descriptor #544 I + public static final int GL_AUX0 = 1033; + + // Field descriptor #544 I + public static final int GL_AUX1 = 1034; + + // Field descriptor #544 I + public static final int GL_AUX2 = 1035; + + // Field descriptor #544 I + public static final int GL_AUX3 = 1036; + + // Field descriptor #544 I + public static final int GL_NO_ERROR = 0; + + // Field descriptor #544 I + public static final int GL_INVALID_ENUM = 1280; + + // Field descriptor #544 I + public static final int GL_INVALID_VALUE = 1281; + + // Field descriptor #544 I + public static final int GL_INVALID_OPERATION = 1282; + + // Field descriptor #544 I + public static final int GL_STACK_OVERFLOW = 1283; + + // Field descriptor #544 I + public static final int GL_STACK_UNDERFLOW = 1284; + + // Field descriptor #544 I + public static final int GL_OUT_OF_MEMORY = 1285; + + // Field descriptor #544 I + public static final int GL_2D = 1536; + + // Field descriptor #544 I + public static final int GL_3D = 1537; + + // Field descriptor #544 I + public static final int GL_3D_COLOR = 1538; + + // Field descriptor #544 I + public static final int GL_3D_COLOR_TEXTURE = 1539; + + // Field descriptor #544 I + public static final int GL_4D_COLOR_TEXTURE = 1540; + + // Field descriptor #544 I + public static final int GL_PASS_THROUGH_TOKEN = 1792; + + // Field descriptor #544 I + public static final int GL_POINT_TOKEN = 1793; + + // Field descriptor #544 I + public static final int GL_LINE_TOKEN = 1794; + + // Field descriptor #544 I + public static final int GL_POLYGON_TOKEN = 1795; + + // Field descriptor #544 I + public static final int GL_BITMAP_TOKEN = 1796; + + // Field descriptor #544 I + public static final int GL_DRAW_PIXEL_TOKEN = 1797; + + // Field descriptor #544 I + public static final int GL_COPY_PIXEL_TOKEN = 1798; + + // Field descriptor #544 I + public static final int GL_LINE_RESET_TOKEN = 1799; + + // Field descriptor #544 I + public static final int GL_EXP = 2048; + + // Field descriptor #544 I + public static final int GL_EXP2 = 2049; + + // Field descriptor #544 I + public static final int GL_CW = 2304; + + // Field descriptor #544 I + public static final int GL_CCW = 2305; + + // Field descriptor #544 I + public static final int GL_COEFF = 2560; + + // Field descriptor #544 I + public static final int GL_ORDER = 2561; + + // Field descriptor #544 I + public static final int GL_DOMAIN = 2562; + + // Field descriptor #544 I + public static final int GL_CURRENT_COLOR = 2816; + + // Field descriptor #544 I + public static final int GL_CURRENT_INDEX = 2817; + + // Field descriptor #544 I + public static final int GL_CURRENT_NORMAL = 2818; + + // Field descriptor #544 I + public static final int GL_CURRENT_TEXTURE_COORDS = 2819; + + // Field descriptor #544 I + public static final int GL_CURRENT_RASTER_COLOR = 2820; + + // Field descriptor #544 I + public static final int GL_CURRENT_RASTER_INDEX = 2821; + + // Field descriptor #544 I + public static final int GL_CURRENT_RASTER_TEXTURE_COORDS = 2822; + + // Field descriptor #544 I + public static final int GL_CURRENT_RASTER_POSITION = 2823; + + // Field descriptor #544 I + public static final int GL_CURRENT_RASTER_POSITION_VALID = 2824; + + // Field descriptor #544 I + public static final int GL_CURRENT_RASTER_DISTANCE = 2825; + + // Field descriptor #544 I + public static final int GL_POINT_SMOOTH = 2832; + + // Field descriptor #544 I + public static final int GL_POINT_SIZE = 2833; + + // Field descriptor #544 I + public static final int GL_POINT_SIZE_RANGE = 2834; + + // Field descriptor #544 I + public static final int GL_POINT_SIZE_GRANULARITY = 2835; + + // Field descriptor #544 I + public static final int GL_LINE_SMOOTH = 2848; + + // Field descriptor #544 I + public static final int GL_LINE_WIDTH = 2849; + + // Field descriptor #544 I + public static final int GL_LINE_WIDTH_RANGE = 2850; + + // Field descriptor #544 I + public static final int GL_LINE_WIDTH_GRANULARITY = 2851; + + // Field descriptor #544 I + public static final int GL_LINE_STIPPLE = 2852; + + // Field descriptor #544 I + public static final int GL_LINE_STIPPLE_PATTERN = 2853; + + // Field descriptor #544 I + public static final int GL_LINE_STIPPLE_REPEAT = 2854; + + // Field descriptor #544 I + public static final int GL_LIST_MODE = 2864; + + // Field descriptor #544 I + public static final int GL_MAX_LIST_NESTING = 2865; + + // Field descriptor #544 I + public static final int GL_LIST_BASE = 2866; + + // Field descriptor #544 I + public static final int GL_LIST_INDEX = 2867; + + // Field descriptor #544 I + public static final int GL_POLYGON_MODE = 2880; + + // Field descriptor #544 I + public static final int GL_POLYGON_SMOOTH = 2881; + + // Field descriptor #544 I + public static final int GL_POLYGON_STIPPLE = 2882; + + // Field descriptor #544 I + public static final int GL_EDGE_FLAG = 2883; + + // Field descriptor #544 I + public static final int GL_CULL_FACE = 2884; + + // Field descriptor #544 I + public static final int GL_CULL_FACE_MODE = 2885; + + // Field descriptor #544 I + public static final int GL_FRONT_FACE = 2886; + + // Field descriptor #544 I + public static final int GL_LIGHTING = 2896; + + // Field descriptor #544 I + public static final int GL_LIGHT_MODEL_LOCAL_VIEWER = 2897; + + // Field descriptor #544 I + public static final int GL_LIGHT_MODEL_TWO_SIDE = 2898; + + // Field descriptor #544 I + public static final int GL_LIGHT_MODEL_AMBIENT = 2899; + + // Field descriptor #544 I + public static final int GL_SHADE_MODEL = 2900; + + // Field descriptor #544 I + public static final int GL_COLOR_MATERIAL_FACE = 2901; + + // Field descriptor #544 I + public static final int GL_COLOR_MATERIAL_PARAMETER = 2902; + + // Field descriptor #544 I + public static final int GL_COLOR_MATERIAL = 2903; + + // Field descriptor #544 I + public static final int GL_FOG = 2912; + + // Field descriptor #544 I + public static final int GL_FOG_INDEX = 2913; + + // Field descriptor #544 I + public static final int GL_FOG_DENSITY = 2914; + + // Field descriptor #544 I + public static final int GL_FOG_START = 2915; + + // Field descriptor #544 I + public static final int GL_FOG_END = 2916; + + // Field descriptor #544 I + public static final int GL_FOG_MODE = 2917; + + // Field descriptor #544 I + public static final int GL_FOG_COLOR = 2918; + + // Field descriptor #544 I + public static final int GL_DEPTH_RANGE = 2928; + + // Field descriptor #544 I + public static final int GL_DEPTH_TEST = 2929; + + // Field descriptor #544 I + public static final int GL_DEPTH_WRITEMASK = 2930; + + // Field descriptor #544 I + public static final int GL_DEPTH_CLEAR_VALUE = 2931; + + // Field descriptor #544 I + public static final int GL_DEPTH_FUNC = 2932; + + // Field descriptor #544 I + public static final int GL_ACCUM_CLEAR_VALUE = 2944; + + // Field descriptor #544 I + public static final int GL_STENCIL_TEST = 2960; + + // Field descriptor #544 I + public static final int GL_STENCIL_CLEAR_VALUE = 2961; + + // Field descriptor #544 I + public static final int GL_STENCIL_FUNC = 2962; + + // Field descriptor #544 I + public static final int GL_STENCIL_VALUE_MASK = 2963; + + // Field descriptor #544 I + public static final int GL_STENCIL_FAIL = 2964; + + // Field descriptor #544 I + public static final int GL_STENCIL_PASS_DEPTH_FAIL = 2965; + + // Field descriptor #544 I + public static final int GL_STENCIL_PASS_DEPTH_PASS = 2966; + + // Field descriptor #544 I + public static final int GL_STENCIL_REF = 2967; + + // Field descriptor #544 I + public static final int GL_STENCIL_WRITEMASK = 2968; + + // Field descriptor #544 I + public static final int GL_MATRIX_MODE = 2976; + + // Field descriptor #544 I + public static final int GL_NORMALIZE = 2977; + + // Field descriptor #544 I + public static final int GL_VIEWPORT = 2978; + + // Field descriptor #544 I + public static final int GL_MODELVIEW_STACK_DEPTH = 2979; + + // Field descriptor #544 I + public static final int GL_PROJECTION_STACK_DEPTH = 2980; + + // Field descriptor #544 I + public static final int GL_TEXTURE_STACK_DEPTH = 2981; + + // Field descriptor #544 I + public static final int GL_MODELVIEW_MATRIX = 2982; + + // Field descriptor #544 I + public static final int GL_PROJECTION_MATRIX = 2983; + + // Field descriptor #544 I + public static final int GL_TEXTURE_MATRIX = 2984; + + // Field descriptor #544 I + public static final int GL_ATTRIB_STACK_DEPTH = 2992; + + // Field descriptor #544 I + public static final int GL_CLIENT_ATTRIB_STACK_DEPTH = 2993; + + // Field descriptor #544 I + public static final int GL_ALPHA_TEST = 3008; + + // Field descriptor #544 I + public static final int GL_ALPHA_TEST_FUNC = 3009; + + // Field descriptor #544 I + public static final int GL_ALPHA_TEST_REF = 3010; + + // Field descriptor #544 I + public static final int GL_DITHER = 3024; + + // Field descriptor #544 I + public static final int GL_BLEND_DST = 3040; + + // Field descriptor #544 I + public static final int GL_BLEND_SRC = 3041; + + // Field descriptor #544 I + public static final int GL_BLEND = 3042; + + // Field descriptor #544 I + public static final int GL_LOGIC_OP_MODE = 3056; + + // Field descriptor #544 I + public static final int GL_INDEX_LOGIC_OP = 3057; + + // Field descriptor #544 I + public static final int GL_COLOR_LOGIC_OP = 3058; + + // Field descriptor #544 I + public static final int GL_AUX_BUFFERS = 3072; + + // Field descriptor #544 I + public static final int GL_DRAW_BUFFER = 3073; + + // Field descriptor #544 I + public static final int GL_READ_BUFFER = 3074; + + // Field descriptor #544 I + public static final int GL_SCISSOR_BOX = 3088; + + // Field descriptor #544 I + public static final int GL_SCISSOR_TEST = 3089; + + // Field descriptor #544 I + public static final int GL_INDEX_CLEAR_VALUE = 3104; + + // Field descriptor #544 I + public static final int GL_INDEX_WRITEMASK = 3105; + + // Field descriptor #544 I + public static final int GL_COLOR_CLEAR_VALUE = 3106; + + // Field descriptor #544 I + public static final int GL_COLOR_WRITEMASK = 3107; + + // Field descriptor #544 I + public static final int GL_INDEX_MODE = 3120; + + // Field descriptor #544 I + public static final int GL_RGBA_MODE = 3121; + + // Field descriptor #544 I + public static final int GL_DOUBLEBUFFER = 3122; + + // Field descriptor #544 I + public static final int GL_STEREO = 3123; + + // Field descriptor #544 I + public static final int GL_RENDER_MODE = 3136; + + // Field descriptor #544 I + public static final int GL_PERSPECTIVE_CORRECTION_HINT = 3152; + + // Field descriptor #544 I + public static final int GL_POINT_SMOOTH_HINT = 3153; + + // Field descriptor #544 I + public static final int GL_LINE_SMOOTH_HINT = 3154; + + // Field descriptor #544 I + public static final int GL_POLYGON_SMOOTH_HINT = 3155; + + // Field descriptor #544 I + public static final int GL_FOG_HINT = 3156; + + // Field descriptor #544 I + public static final int GL_TEXTURE_GEN_S = 3168; + + // Field descriptor #544 I + public static final int GL_TEXTURE_GEN_T = 3169; + + // Field descriptor #544 I + public static final int GL_TEXTURE_GEN_R = 3170; + + // Field descriptor #544 I + public static final int GL_TEXTURE_GEN_Q = 3171; + + // Field descriptor #544 I + public static final int GL_PIXEL_MAP_I_TO_I = 3184; + + // Field descriptor #544 I + public static final int GL_PIXEL_MAP_S_TO_S = 3185; + + // Field descriptor #544 I + public static final int GL_PIXEL_MAP_I_TO_R = 3186; + + // Field descriptor #544 I + public static final int GL_PIXEL_MAP_I_TO_G = 3187; + + // Field descriptor #544 I + public static final int GL_PIXEL_MAP_I_TO_B = 3188; + + // Field descriptor #544 I + public static final int GL_PIXEL_MAP_I_TO_A = 3189; + + // Field descriptor #544 I + public static final int GL_PIXEL_MAP_R_TO_R = 3190; + + // Field descriptor #544 I + public static final int GL_PIXEL_MAP_G_TO_G = 3191; + + // Field descriptor #544 I + public static final int GL_PIXEL_MAP_B_TO_B = 3192; + + // Field descriptor #544 I + public static final int GL_PIXEL_MAP_A_TO_A = 3193; + + // Field descriptor #544 I + public static final int GL_PIXEL_MAP_I_TO_I_SIZE = 3248; + + // Field descriptor #544 I + public static final int GL_PIXEL_MAP_S_TO_S_SIZE = 3249; + + // Field descriptor #544 I + public static final int GL_PIXEL_MAP_I_TO_R_SIZE = 3250; + + // Field descriptor #544 I + public static final int GL_PIXEL_MAP_I_TO_G_SIZE = 3251; + + // Field descriptor #544 I + public static final int GL_PIXEL_MAP_I_TO_B_SIZE = 3252; + + // Field descriptor #544 I + public static final int GL_PIXEL_MAP_I_TO_A_SIZE = 3253; + + // Field descriptor #544 I + public static final int GL_PIXEL_MAP_R_TO_R_SIZE = 3254; + + // Field descriptor #544 I + public static final int GL_PIXEL_MAP_G_TO_G_SIZE = 3255; + + // Field descriptor #544 I + public static final int GL_PIXEL_MAP_B_TO_B_SIZE = 3256; + + // Field descriptor #544 I + public static final int GL_PIXEL_MAP_A_TO_A_SIZE = 3257; + + // Field descriptor #544 I + public static final int GL_UNPACK_SWAP_BYTES = 3312; + + // Field descriptor #544 I + public static final int GL_UNPACK_LSB_FIRST = 3313; + + // Field descriptor #544 I + public static final int GL_UNPACK_ROW_LENGTH = 3314; + + // Field descriptor #544 I + public static final int GL_UNPACK_SKIP_ROWS = 3315; + + // Field descriptor #544 I + public static final int GL_UNPACK_SKIP_PIXELS = 3316; + + // Field descriptor #544 I + public static final int GL_UNPACK_ALIGNMENT = 3317; + + // Field descriptor #544 I + public static final int GL_PACK_SWAP_BYTES = 3328; + + // Field descriptor #544 I + public static final int GL_PACK_LSB_FIRST = 3329; + + // Field descriptor #544 I + public static final int GL_PACK_ROW_LENGTH = 3330; + + // Field descriptor #544 I + public static final int GL_PACK_SKIP_ROWS = 3331; + + // Field descriptor #544 I + public static final int GL_PACK_SKIP_PIXELS = 3332; + + // Field descriptor #544 I + public static final int GL_PACK_ALIGNMENT = 3333; + + // Field descriptor #544 I + public static final int GL_MAP_COLOR = 3344; + + // Field descriptor #544 I + public static final int GL_MAP_STENCIL = 3345; + + // Field descriptor #544 I + public static final int GL_INDEX_SHIFT = 3346; + + // Field descriptor #544 I + public static final int GL_INDEX_OFFSET = 3347; + + // Field descriptor #544 I + public static final int GL_RED_SCALE = 3348; + + // Field descriptor #544 I + public static final int GL_RED_BIAS = 3349; + + // Field descriptor #544 I + public static final int GL_ZOOM_X = 3350; + + // Field descriptor #544 I + public static final int GL_ZOOM_Y = 3351; + + // Field descriptor #544 I + public static final int GL_GREEN_SCALE = 3352; + + // Field descriptor #544 I + public static final int GL_GREEN_BIAS = 3353; + + // Field descriptor #544 I + public static final int GL_BLUE_SCALE = 3354; + + // Field descriptor #544 I + public static final int GL_BLUE_BIAS = 3355; + + // Field descriptor #544 I + public static final int GL_ALPHA_SCALE = 3356; + + // Field descriptor #544 I + public static final int GL_ALPHA_BIAS = 3357; + + // Field descriptor #544 I + public static final int GL_DEPTH_SCALE = 3358; + + // Field descriptor #544 I + public static final int GL_DEPTH_BIAS = 3359; + + // Field descriptor #544 I + public static final int GL_MAX_EVAL_ORDER = 3376; + + // Field descriptor #544 I + public static final int GL_MAX_LIGHTS = 3377; + + // Field descriptor #544 I + public static final int GL_MAX_CLIP_PLANES = 3378; + + // Field descriptor #544 I + public static final int GL_MAX_TEXTURE_SIZE = 3379; + + // Field descriptor #544 I + public static final int GL_MAX_PIXEL_MAP_TABLE = 3380; + + // Field descriptor #544 I + public static final int GL_MAX_ATTRIB_STACK_DEPTH = 3381; + + // Field descriptor #544 I + public static final int GL_MAX_MODELVIEW_STACK_DEPTH = 3382; + + // Field descriptor #544 I + public static final int GL_MAX_NAME_STACK_DEPTH = 3383; + + // Field descriptor #544 I + public static final int GL_MAX_PROJECTION_STACK_DEPTH = 3384; + + // Field descriptor #544 I + public static final int GL_MAX_TEXTURE_STACK_DEPTH = 3385; + + // Field descriptor #544 I + public static final int GL_MAX_VIEWPORT_DIMS = 3386; + + // Field descriptor #544 I + public static final int GL_MAX_CLIENT_ATTRIB_STACK_DEPTH = 3387; + + // Field descriptor #544 I + public static final int GL_SUBPIXEL_BITS = 3408; + + // Field descriptor #544 I + public static final int GL_INDEX_BITS = 3409; + + // Field descriptor #544 I + public static final int GL_RED_BITS = 3410; + + // Field descriptor #544 I + public static final int GL_GREEN_BITS = 3411; + + // Field descriptor #544 I + public static final int GL_BLUE_BITS = 3412; + + // Field descriptor #544 I + public static final int GL_ALPHA_BITS = 3413; + + // Field descriptor #544 I + public static final int GL_DEPTH_BITS = 3414; + + // Field descriptor #544 I + public static final int GL_STENCIL_BITS = 3415; + + // Field descriptor #544 I + public static final int GL_ACCUM_RED_BITS = 3416; + + // Field descriptor #544 I + public static final int GL_ACCUM_GREEN_BITS = 3417; + + // Field descriptor #544 I + public static final int GL_ACCUM_BLUE_BITS = 3418; + + // Field descriptor #544 I + public static final int GL_ACCUM_ALPHA_BITS = 3419; + + // Field descriptor #544 I + public static final int GL_NAME_STACK_DEPTH = 3440; + + // Field descriptor #544 I + public static final int GL_AUTO_NORMAL = 3456; + + // Field descriptor #544 I + public static final int GL_MAP1_COLOR_4 = 3472; + + // Field descriptor #544 I + public static final int GL_MAP1_INDEX = 3473; + + // Field descriptor #544 I + public static final int GL_MAP1_NORMAL = 3474; + + // Field descriptor #544 I + public static final int GL_MAP1_TEXTURE_COORD_1 = 3475; + + // Field descriptor #544 I + public static final int GL_MAP1_TEXTURE_COORD_2 = 3476; + + // Field descriptor #544 I + public static final int GL_MAP1_TEXTURE_COORD_3 = 3477; + + // Field descriptor #544 I + public static final int GL_MAP1_TEXTURE_COORD_4 = 3478; + + // Field descriptor #544 I + public static final int GL_MAP1_VERTEX_3 = 3479; + + // Field descriptor #544 I + public static final int GL_MAP1_VERTEX_4 = 3480; + + // Field descriptor #544 I + public static final int GL_MAP2_COLOR_4 = 3504; + + // Field descriptor #544 I + public static final int GL_MAP2_INDEX = 3505; + + // Field descriptor #544 I + public static final int GL_MAP2_NORMAL = 3506; + + // Field descriptor #544 I + public static final int GL_MAP2_TEXTURE_COORD_1 = 3507; + + // Field descriptor #544 I + public static final int GL_MAP2_TEXTURE_COORD_2 = 3508; + + // Field descriptor #544 I + public static final int GL_MAP2_TEXTURE_COORD_3 = 3509; + + // Field descriptor #544 I + public static final int GL_MAP2_TEXTURE_COORD_4 = 3510; + + // Field descriptor #544 I + public static final int GL_MAP2_VERTEX_3 = 3511; + + // Field descriptor #544 I + public static final int GL_MAP2_VERTEX_4 = 3512; + + // Field descriptor #544 I + public static final int GL_MAP1_GRID_DOMAIN = 3536; + + // Field descriptor #544 I + public static final int GL_MAP1_GRID_SEGMENTS = 3537; + + // Field descriptor #544 I + public static final int GL_MAP2_GRID_DOMAIN = 3538; + + // Field descriptor #544 I + public static final int GL_MAP2_GRID_SEGMENTS = 3539; + + // Field descriptor #544 I + public static final int GL_TEXTURE_1D = 3552; + + // Field descriptor #544 I + public static final int GL_TEXTURE_2D = 3553; + + // Field descriptor #544 I + public static final int GL_FEEDBACK_BUFFER_POINTER = 3568; + + // Field descriptor #544 I + public static final int GL_FEEDBACK_BUFFER_SIZE = 3569; + + // Field descriptor #544 I + public static final int GL_FEEDBACK_BUFFER_TYPE = 3570; + + // Field descriptor #544 I + public static final int GL_SELECTION_BUFFER_POINTER = 3571; + + // Field descriptor #544 I + public static final int GL_SELECTION_BUFFER_SIZE = 3572; + + // Field descriptor #544 I + public static final int GL_TEXTURE_WIDTH = 4096; + + // Field descriptor #544 I + public static final int GL_TEXTURE_HEIGHT = 4097; + + // Field descriptor #544 I + public static final int GL_TEXTURE_INTERNAL_FORMAT = 4099; + + // Field descriptor #544 I + public static final int GL_TEXTURE_BORDER_COLOR = 4100; + + // Field descriptor #544 I + public static final int GL_TEXTURE_BORDER = 4101; + + // Field descriptor #544 I + public static final int GL_DONT_CARE = 4352; + + // Field descriptor #544 I + public static final int GL_FASTEST = 4353; + + // Field descriptor #544 I + public static final int GL_NICEST = 4354; + + // Field descriptor #544 I + public static final int GL_LIGHT0 = 16384; + + // Field descriptor #544 I + public static final int GL_LIGHT1 = 16385; + + // Field descriptor #544 I + public static final int GL_LIGHT2 = 16386; + + // Field descriptor #544 I + public static final int GL_LIGHT3 = 16387; + + // Field descriptor #544 I + public static final int GL_LIGHT4 = 16388; + + // Field descriptor #544 I + public static final int GL_LIGHT5 = 16389; + + // Field descriptor #544 I + public static final int GL_LIGHT6 = 16390; + + // Field descriptor #544 I + public static final int GL_LIGHT7 = 16391; + + // Field descriptor #544 I + public static final int GL_AMBIENT = 4608; + + // Field descriptor #544 I + public static final int GL_DIFFUSE = 4609; + + // Field descriptor #544 I + public static final int GL_SPECULAR = 4610; + + // Field descriptor #544 I + public static final int GL_POSITION = 4611; + + // Field descriptor #544 I + public static final int GL_SPOT_DIRECTION = 4612; + + // Field descriptor #544 I + public static final int GL_SPOT_EXPONENT = 4613; + + // Field descriptor #544 I + public static final int GL_SPOT_CUTOFF = 4614; + + // Field descriptor #544 I + public static final int GL_CONSTANT_ATTENUATION = 4615; + + // Field descriptor #544 I + public static final int GL_LINEAR_ATTENUATION = 4616; + + // Field descriptor #544 I + public static final int GL_QUADRATIC_ATTENUATION = 4617; + + // Field descriptor #544 I + public static final int GL_COMPILE = 4864; + + // Field descriptor #544 I + public static final int GL_COMPILE_AND_EXECUTE = 4865; + + // Field descriptor #544 I + public static final int GL_CLEAR = 5376; + + // Field descriptor #544 I + public static final int GL_AND = 5377; + + // Field descriptor #544 I + public static final int GL_AND_REVERSE = 5378; + + // Field descriptor #544 I + public static final int GL_COPY = 5379; + + // Field descriptor #544 I + public static final int GL_AND_INVERTED = 5380; + + // Field descriptor #544 I + public static final int GL_NOOP = 5381; + + // Field descriptor #544 I + public static final int GL_XOR = 5382; + + // Field descriptor #544 I + public static final int GL_OR = 5383; + + // Field descriptor #544 I + public static final int GL_NOR = 5384; + + // Field descriptor #544 I + public static final int GL_EQUIV = 5385; + + // Field descriptor #544 I + public static final int GL_INVERT = 5386; + + // Field descriptor #544 I + public static final int GL_OR_REVERSE = 5387; + + // Field descriptor #544 I + public static final int GL_COPY_INVERTED = 5388; + + // Field descriptor #544 I + public static final int GL_OR_INVERTED = 5389; + + // Field descriptor #544 I + public static final int GL_NAND = 5390; + + // Field descriptor #544 I + public static final int GL_SET = 5391; + + // Field descriptor #544 I + public static final int GL_EMISSION = 5632; + + // Field descriptor #544 I + public static final int GL_SHININESS = 5633; + + // Field descriptor #544 I + public static final int GL_AMBIENT_AND_DIFFUSE = 5634; + + // Field descriptor #544 I + public static final int GL_COLOR_INDEXES = 5635; + + // Field descriptor #544 I + public static final int GL_MODELVIEW = 5888; + + // Field descriptor #544 I + public static final int GL_PROJECTION = 5889; + + // Field descriptor #544 I + public static final int GL_TEXTURE = 5890; + + // Field descriptor #544 I + public static final int GL_COLOR = 6144; + + // Field descriptor #544 I + public static final int GL_DEPTH = 6145; + + // Field descriptor #544 I + public static final int GL_STENCIL = 6146; + + // Field descriptor #544 I + public static final int GL_COLOR_INDEX = 6400; + + // Field descriptor #544 I + public static final int GL_STENCIL_INDEX = 6401; + + // Field descriptor #544 I + public static final int GL_DEPTH_COMPONENT = 6402; + + // Field descriptor #544 I + public static final int GL_RED = 6403; + + // Field descriptor #544 I + public static final int GL_GREEN = 6404; + + // Field descriptor #544 I + public static final int GL_BLUE = 6405; + + // Field descriptor #544 I + public static final int GL_ALPHA = 6406; + + // Field descriptor #544 I + public static final int GL_RGB = 6407; + + // Field descriptor #544 I + public static final int GL_RGBA = 6408; + + // Field descriptor #544 I + public static final int GL_LUMINANCE = 6409; + + // Field descriptor #544 I + public static final int GL_LUMINANCE_ALPHA = 6410; + + // Field descriptor #544 I + public static final int GL_BITMAP = 6656; + + // Field descriptor #544 I + public static final int GL_POINT = 6912; + + // Field descriptor #544 I + public static final int GL_LINE = 6913; + + // Field descriptor #544 I + public static final int GL_FILL = 6914; + + // Field descriptor #544 I + public static final int GL_RENDER = 7168; + + // Field descriptor #544 I + public static final int GL_FEEDBACK = 7169; + + // Field descriptor #544 I + public static final int GL_SELECT = 7170; + + // Field descriptor #544 I + public static final int GL_FLAT = 7424; + + // Field descriptor #544 I + public static final int GL_SMOOTH = 7425; + + // Field descriptor #544 I + public static final int GL_KEEP = 7680; + + // Field descriptor #544 I + public static final int GL_REPLACE = 7681; + + // Field descriptor #544 I + public static final int GL_INCR = 7682; + + // Field descriptor #544 I + public static final int GL_DECR = 7683; + + // Field descriptor #544 I + public static final int GL_VENDOR = 7936; + + // Field descriptor #544 I + public static final int GL_RENDERER = 7937; + + // Field descriptor #544 I + public static final int GL_VERSION = 7938; + + // Field descriptor #544 I + public static final int GL_EXTENSIONS = 7939; + + // Field descriptor #544 I + public static final int GL_S = 8192; + + // Field descriptor #544 I + public static final int GL_T = 8193; + + // Field descriptor #544 I + public static final int GL_R = 8194; + + // Field descriptor #544 I + public static final int GL_Q = 8195; + + // Field descriptor #544 I + public static final int GL_MODULATE = 8448; + + // Field descriptor #544 I + public static final int GL_DECAL = 8449; + + // Field descriptor #544 I + public static final int GL_TEXTURE_ENV_MODE = 8704; + + // Field descriptor #544 I + public static final int GL_TEXTURE_ENV_COLOR = 8705; + + // Field descriptor #544 I + public static final int GL_TEXTURE_ENV = 8960; + + // Field descriptor #544 I + public static final int GL_EYE_LINEAR = 9216; + + // Field descriptor #544 I + public static final int GL_OBJECT_LINEAR = 9217; + + // Field descriptor #544 I + public static final int GL_SPHERE_MAP = 9218; + + // Field descriptor #544 I + public static final int GL_TEXTURE_GEN_MODE = 9472; + + // Field descriptor #544 I + public static final int GL_OBJECT_PLANE = 9473; + + // Field descriptor #544 I + public static final int GL_EYE_PLANE = 9474; + + // Field descriptor #544 I + public static final int GL_NEAREST = 9728; + + // Field descriptor #544 I + public static final int GL_LINEAR = 9729; + + // Field descriptor #544 I + public static final int GL_NEAREST_MIPMAP_NEAREST = 9984; + + // Field descriptor #544 I + public static final int GL_LINEAR_MIPMAP_NEAREST = 9985; + + // Field descriptor #544 I + public static final int GL_NEAREST_MIPMAP_LINEAR = 9986; + + // Field descriptor #544 I + public static final int GL_LINEAR_MIPMAP_LINEAR = 9987; + + // Field descriptor #544 I + public static final int GL_TEXTURE_MAG_FILTER = 10240; + + // Field descriptor #544 I + public static final int GL_TEXTURE_MIN_FILTER = 10241; + + // Field descriptor #544 I + public static final int GL_TEXTURE_WRAP_S = 10242; + + // Field descriptor #544 I + public static final int GL_TEXTURE_WRAP_T = 10243; + + // Field descriptor #544 I + public static final int GL_CLAMP = 10496; + + // Field descriptor #544 I + public static final int GL_REPEAT = 10497; + + // Field descriptor #544 I + public static final int GL_CLIENT_PIXEL_STORE_BIT = 1; + + // Field descriptor #544 I + public static final int GL_CLIENT_VERTEX_ARRAY_BIT = 2; + + // Field descriptor #544 I + public static final int GL_ALL_CLIENT_ATTRIB_BITS = -1; + + // Field descriptor #544 I + public static final int GL_POLYGON_OFFSET_FACTOR = 32824; + + // Field descriptor #544 I + public static final int GL_POLYGON_OFFSET_UNITS = 10752; + + // Field descriptor #544 I + public static final int GL_POLYGON_OFFSET_POINT = 10753; + + // Field descriptor #544 I + public static final int GL_POLYGON_OFFSET_LINE = 10754; + + // Field descriptor #544 I + public static final int GL_POLYGON_OFFSET_FILL = 32823; + + // Field descriptor #544 I + public static final int GL_ALPHA4 = 32827; + + // Field descriptor #544 I + public static final int GL_ALPHA8 = 32828; + + // Field descriptor #544 I + public static final int GL_ALPHA12 = 32829; + + // Field descriptor #544 I + public static final int GL_ALPHA16 = 32830; + + // Field descriptor #544 I + public static final int GL_LUMINANCE4 = 32831; + + // Field descriptor #544 I + public static final int GL_LUMINANCE8 = 32832; + + // Field descriptor #544 I + public static final int GL_LUMINANCE12 = 32833; + + // Field descriptor #544 I + public static final int GL_LUMINANCE16 = 32834; + + // Field descriptor #544 I + public static final int GL_LUMINANCE4_ALPHA4 = 32835; + + // Field descriptor #544 I + public static final int GL_LUMINANCE6_ALPHA2 = 32836; + + // Field descriptor #544 I + public static final int GL_LUMINANCE8_ALPHA8 = 32837; + + // Field descriptor #544 I + public static final int GL_LUMINANCE12_ALPHA4 = 32838; + + // Field descriptor #544 I + public static final int GL_LUMINANCE12_ALPHA12 = 32839; + + // Field descriptor #544 I + public static final int GL_LUMINANCE16_ALPHA16 = 32840; + + // Field descriptor #544 I + public static final int GL_INTENSITY = 32841; + + // Field descriptor #544 I + public static final int GL_INTENSITY4 = 32842; + + // Field descriptor #544 I + public static final int GL_INTENSITY8 = 32843; + + // Field descriptor #544 I + public static final int GL_INTENSITY12 = 32844; + + // Field descriptor #544 I + public static final int GL_INTENSITY16 = 32845; + + // Field descriptor #544 I + public static final int GL_R3_G3_B2 = 10768; + + // Field descriptor #544 I + public static final int GL_RGB4 = 32847; + + // Field descriptor #544 I + public static final int GL_RGB5 = 32848; + + // Field descriptor #544 I + public static final int GL_RGB8 = 32849; + + // Field descriptor #544 I + public static final int GL_RGB10 = 32850; + + // Field descriptor #544 I + public static final int GL_RGB12 = 32851; + + // Field descriptor #544 I + public static final int GL_RGB16 = 32852; + + // Field descriptor #544 I + public static final int GL_RGBA2 = 32853; + + // Field descriptor #544 I + public static final int GL_RGBA4 = 32854; + + // Field descriptor #544 I + public static final int GL_RGB5_A1 = 32855; + + // Field descriptor #544 I + public static final int GL_RGBA8 = 32856; + + // Field descriptor #544 I + public static final int GL_RGB10_A2 = 32857; + + // Field descriptor #544 I + public static final int GL_RGBA12 = 32858; + + // Field descriptor #544 I + public static final int GL_RGBA16 = 32859; + + // Field descriptor #544 I + public static final int GL_TEXTURE_RED_SIZE = 32860; + + // Field descriptor #544 I + public static final int GL_TEXTURE_GREEN_SIZE = 32861; + + // Field descriptor #544 I + public static final int GL_TEXTURE_BLUE_SIZE = 32862; + + // Field descriptor #544 I + public static final int GL_TEXTURE_ALPHA_SIZE = 32863; + + // Field descriptor #544 I + public static final int GL_TEXTURE_LUMINANCE_SIZE = 32864; + + // Field descriptor #544 I + public static final int GL_TEXTURE_INTENSITY_SIZE = 32865; + + // Field descriptor #544 I + public static final int GL_PROXY_TEXTURE_1D = 32867; + + // Field descriptor #544 I + public static final int GL_PROXY_TEXTURE_2D = 32868; + + // Field descriptor #544 I + public static final int GL_TEXTURE_PRIORITY = 32870; + + // Field descriptor #544 I + public static final int GL_TEXTURE_RESIDENT = 32871; + + // Field descriptor #544 I + public static final int GL_TEXTURE_BINDING_1D = 32872; + + // Field descriptor #544 I + public static final int GL_TEXTURE_BINDING_2D = 32873; + + // Field descriptor #544 I + public static final int GL_VERTEX_ARRAY = 32884; + + // Field descriptor #544 I + public static final int GL_NORMAL_ARRAY = 32885; + + // Field descriptor #544 I + public static final int GL_COLOR_ARRAY = 32886; + + // Field descriptor #544 I + public static final int GL_INDEX_ARRAY = 32887; + + // Field descriptor #544 I + public static final int GL_TEXTURE_COORD_ARRAY = 32888; + + // Field descriptor #544 I + public static final int GL_EDGE_FLAG_ARRAY = 32889; + + // Field descriptor #544 I + public static final int GL_VERTEX_ARRAY_SIZE = 32890; + + // Field descriptor #544 I + public static final int GL_VERTEX_ARRAY_TYPE = 32891; + + // Field descriptor #544 I + public static final int GL_VERTEX_ARRAY_STRIDE = 32892; + + // Field descriptor #544 I + public static final int GL_NORMAL_ARRAY_TYPE = 32894; + + // Field descriptor #544 I + public static final int GL_NORMAL_ARRAY_STRIDE = 32895; + + // Field descriptor #544 I + public static final int GL_COLOR_ARRAY_SIZE = 32897; + + // Field descriptor #544 I + public static final int GL_COLOR_ARRAY_TYPE = 32898; + + // Field descriptor #544 I + public static final int GL_COLOR_ARRAY_STRIDE = 32899; + + // Field descriptor #544 I + public static final int GL_INDEX_ARRAY_TYPE = 32901; + + // Field descriptor #544 I + public static final int GL_INDEX_ARRAY_STRIDE = 32902; + + // Field descriptor #544 I + public static final int GL_TEXTURE_COORD_ARRAY_SIZE = 32904; + + // Field descriptor #544 I + public static final int GL_TEXTURE_COORD_ARRAY_TYPE = 32905; + + // Field descriptor #544 I + public static final int GL_TEXTURE_COORD_ARRAY_STRIDE = 32906; + + // Field descriptor #544 I + public static final int GL_EDGE_FLAG_ARRAY_STRIDE = 32908; + + // Field descriptor #544 I + public static final int GL_VERTEX_ARRAY_POINTER = 32910; + + // Field descriptor #544 I + public static final int GL_NORMAL_ARRAY_POINTER = 32911; + + // Field descriptor #544 I + public static final int GL_COLOR_ARRAY_POINTER = 32912; + + // Field descriptor #544 I + public static final int GL_INDEX_ARRAY_POINTER = 32913; + + // Field descriptor #544 I + public static final int GL_TEXTURE_COORD_ARRAY_POINTER = 32914; + + // Field descriptor #544 I + public static final int GL_EDGE_FLAG_ARRAY_POINTER = 32915; + + // Field descriptor #544 I + public static final int GL_V2F = 10784; + + // Field descriptor #544 I + public static final int GL_V3F = 10785; + + // Field descriptor #544 I + public static final int GL_C4UB_V2F = 10786; + + // Field descriptor #544 I + public static final int GL_C4UB_V3F = 10787; + + // Field descriptor #544 I + public static final int GL_C3F_V3F = 10788; + + // Field descriptor #544 I + public static final int GL_N3F_V3F = 10789; + + // Field descriptor #544 I + public static final int GL_C4F_N3F_V3F = 10790; + + // Field descriptor #544 I + public static final int GL_T2F_V3F = 10791; + + // Field descriptor #544 I + public static final int GL_T4F_V4F = 10792; + + // Field descriptor #544 I + public static final int GL_T2F_C4UB_V3F = 10793; + + // Field descriptor #544 I + public static final int GL_T2F_C3F_V3F = 10794; + + // Field descriptor #544 I + public static final int GL_T2F_N3F_V3F = 10795; + + // Field descriptor #544 I + public static final int GL_T2F_C4F_N3F_V3F = 10796; + + // Field descriptor #544 I + public static final int GL_T4F_C4F_N3F_V4F = 10797; + + // Field descriptor #544 I + public static final int GL_LOGIC_OP = 3057; + + // Field descriptor #544 I + public static final int GL_TEXTURE_COMPONENTS = 4099; + + // Field descriptor #45 I + public static final int GL_TEXTURE_BINDING_3D = 32874; + + // Field descriptor #45 I + public static final int GL_PACK_SKIP_IMAGES = 32875; + + // Field descriptor #45 I + public static final int GL_PACK_IMAGE_HEIGHT = 32876; + + // Field descriptor #45 I + public static final int GL_UNPACK_SKIP_IMAGES = 32877; + + // Field descriptor #45 I + public static final int GL_UNPACK_IMAGE_HEIGHT = 32878; + + // Field descriptor #45 I + public static final int GL_TEXTURE_3D = 32879; + + // Field descriptor #45 I + public static final int GL_PROXY_TEXTURE_3D = 32880; + + // Field descriptor #45 I + public static final int GL_TEXTURE_DEPTH = 32881; + + // Field descriptor #45 I + public static final int GL_TEXTURE_WRAP_R = 32882; + + // Field descriptor #45 I + public static final int GL_MAX_3D_TEXTURE_SIZE = 32883; + + // Field descriptor #45 I + public static final int GL_BGR = 32992; + + // Field descriptor #45 I + public static final int GL_BGRA = 32993; + + // Field descriptor #45 I + public static final int GL_UNSIGNED_BYTE_3_3_2 = 32818; + + // Field descriptor #45 I + public static final int GL_UNSIGNED_BYTE_2_3_3_REV = 33634; + + // Field descriptor #45 I + public static final int GL_UNSIGNED_SHORT_5_6_5 = 33635; + + // Field descriptor #45 I + public static final int GL_UNSIGNED_SHORT_5_6_5_REV = 33636; + + // Field descriptor #45 I + public static final int GL_UNSIGNED_SHORT_4_4_4_4 = 32819; + + // Field descriptor #45 I + public static final int GL_UNSIGNED_SHORT_4_4_4_4_REV = 33637; + + // Field descriptor #45 I + public static final int GL_UNSIGNED_SHORT_5_5_5_1 = 32820; + + // Field descriptor #45 I + public static final int GL_UNSIGNED_SHORT_1_5_5_5_REV = 33638; + + // Field descriptor #45 I + public static final int GL_UNSIGNED_INT_8_8_8_8 = 32821; + + // Field descriptor #45 I + public static final int GL_UNSIGNED_INT_8_8_8_8_REV = 33639; + + // Field descriptor #45 I + public static final int GL_UNSIGNED_INT_10_10_10_2 = 32822; + + // Field descriptor #45 I + public static final int GL_UNSIGNED_INT_2_10_10_10_REV = 33640; + + // Field descriptor #45 I + public static final int GL_RESCALE_NORMAL = 32826; + + // Field descriptor #45 I + public static final int GL_LIGHT_MODEL_COLOR_CONTROL = 33272; + + // Field descriptor #45 I + public static final int GL_SINGLE_COLOR = 33273; + + // Field descriptor #45 I + public static final int GL_SEPARATE_SPECULAR_COLOR = 33274; + + // Field descriptor #45 I + public static final int GL_CLAMP_TO_EDGE = 33071; + + // Field descriptor #45 I + public static final int GL_TEXTURE_MIN_LOD = 33082; + + // Field descriptor #45 I + public static final int GL_TEXTURE_MAX_LOD = 33083; + + // Field descriptor #45 I + public static final int GL_TEXTURE_BASE_LEVEL = 33084; + + // Field descriptor #45 I + public static final int GL_TEXTURE_MAX_LEVEL = 33085; + + // Field descriptor #45 I + public static final int GL_MAX_ELEMENTS_VERTICES = 33000; + + // Field descriptor #45 I + public static final int GL_MAX_ELEMENTS_INDICES = 33001; + + // Field descriptor #45 I + public static final int GL_ALIASED_POINT_SIZE_RANGE = 33901; + + // Field descriptor #45 I + public static final int GL_ALIASED_LINE_WIDTH_RANGE = 33902; + + // Field descriptor #45 I + public static final int GL_SMOOTH_POINT_SIZE_RANGE = 2834; + + // Field descriptor #45 I + public static final int GL_SMOOTH_POINT_SIZE_GRANULARITY = 2835; + + // Field descriptor #45 I + public static final int GL_SMOOTH_LINE_WIDTH_RANGE = 2850; + + // Field descriptor #45 I + public static final int GL_SMOOTH_LINE_WIDTH_GRANULARITY = 2851; + + // Field descriptor #76 I + public static final int GL_TEXTURE0 = 33984; + + // Field descriptor #76 I + public static final int GL_TEXTURE1 = 33985; + + // Field descriptor #76 I + public static final int GL_TEXTURE2 = 33986; + + // Field descriptor #76 I + public static final int GL_TEXTURE3 = 33987; + + // Field descriptor #76 I + public static final int GL_TEXTURE4 = 33988; + + // Field descriptor #76 I + public static final int GL_TEXTURE5 = 33989; + + // Field descriptor #76 I + public static final int GL_TEXTURE6 = 33990; + + // Field descriptor #76 I + public static final int GL_TEXTURE7 = 33991; + + // Field descriptor #76 I + public static final int GL_TEXTURE8 = 33992; + + // Field descriptor #76 I + public static final int GL_TEXTURE9 = 33993; + + // Field descriptor #76 I + public static final int GL_TEXTURE10 = 33994; + + // Field descriptor #76 I + public static final int GL_TEXTURE11 = 33995; + + // Field descriptor #76 I + public static final int GL_TEXTURE12 = 33996; + + // Field descriptor #76 I + public static final int GL_TEXTURE13 = 33997; + + // Field descriptor #76 I + public static final int GL_TEXTURE14 = 33998; + + // Field descriptor #76 I + public static final int GL_TEXTURE15 = 33999; + + // Field descriptor #76 I + public static final int GL_TEXTURE16 = 34000; + + // Field descriptor #76 I + public static final int GL_TEXTURE17 = 34001; + + // Field descriptor #76 I + public static final int GL_TEXTURE18 = 34002; + + // Field descriptor #76 I + public static final int GL_TEXTURE19 = 34003; + + // Field descriptor #76 I + public static final int GL_TEXTURE20 = 34004; + + // Field descriptor #76 I + public static final int GL_TEXTURE21 = 34005; + + // Field descriptor #76 I + public static final int GL_TEXTURE22 = 34006; + + // Field descriptor #76 I + public static final int GL_TEXTURE23 = 34007; + + // Field descriptor #76 I + public static final int GL_TEXTURE24 = 34008; + + // Field descriptor #76 I + public static final int GL_TEXTURE25 = 34009; + + // Field descriptor #76 I + public static final int GL_TEXTURE26 = 34010; + + // Field descriptor #76 I + public static final int GL_TEXTURE27 = 34011; + + // Field descriptor #76 I + public static final int GL_TEXTURE28 = 34012; + + // Field descriptor #76 I + public static final int GL_TEXTURE29 = 34013; + + // Field descriptor #76 I + public static final int GL_TEXTURE30 = 34014; + + // Field descriptor #76 I + public static final int GL_TEXTURE31 = 34015; + + // Field descriptor #76 I + public static final int GL_ACTIVE_TEXTURE = 34016; + + // Field descriptor #76 I + public static final int GL_CLIENT_ACTIVE_TEXTURE = 34017; + + // Field descriptor #76 I + public static final int GL_MAX_TEXTURE_UNITS = 34018; + + // Field descriptor #76 I + public static final int GL_NORMAL_MAP = 34065; + + // Field descriptor #76 I + public static final int GL_REFLECTION_MAP = 34066; + + // Field descriptor #76 I + public static final int GL_TEXTURE_CUBE_MAP = 34067; + + // Field descriptor #76 I + public static final int GL_TEXTURE_BINDING_CUBE_MAP = 34068; + + // Field descriptor #76 I + public static final int GL_TEXTURE_CUBE_MAP_POSITIVE_X = 34069; + + // Field descriptor #76 I + public static final int GL_TEXTURE_CUBE_MAP_NEGATIVE_X = 34070; + + // Field descriptor #76 I + public static final int GL_TEXTURE_CUBE_MAP_POSITIVE_Y = 34071; + + // Field descriptor #76 I + public static final int GL_TEXTURE_CUBE_MAP_NEGATIVE_Y = 34072; + + // Field descriptor #76 I + public static final int GL_TEXTURE_CUBE_MAP_POSITIVE_Z = 34073; + + // Field descriptor #76 I + public static final int GL_TEXTURE_CUBE_MAP_NEGATIVE_Z = 34074; + + // Field descriptor #76 I + public static final int GL_PROXY_TEXTURE_CUBE_MAP = 34075; + + // Field descriptor #76 I + public static final int GL_MAX_CUBE_MAP_TEXTURE_SIZE = 34076; + + // Field descriptor #76 I + public static final int GL_COMPRESSED_ALPHA = 34025; + + // Field descriptor #76 I + public static final int GL_COMPRESSED_LUMINANCE = 34026; + + // Field descriptor #76 I + public static final int GL_COMPRESSED_LUMINANCE_ALPHA = 34027; + + // Field descriptor #76 I + public static final int GL_COMPRESSED_INTENSITY = 34028; + + // Field descriptor #76 I + public static final int GL_COMPRESSED_RGB = 34029; + + // Field descriptor #76 I + public static final int GL_COMPRESSED_RGBA = 34030; + + // Field descriptor #76 I + public static final int GL_TEXTURE_COMPRESSION_HINT = 34031; + + // Field descriptor #76 I + public static final int GL_TEXTURE_COMPRESSED_IMAGE_SIZE = 34464; + + // Field descriptor #76 I + public static final int GL_TEXTURE_COMPRESSED = 34465; + + // Field descriptor #76 I + public static final int GL_NUM_COMPRESSED_TEXTURE_FORMATS = 34466; + + // Field descriptor #76 I + public static final int GL_COMPRESSED_TEXTURE_FORMATS = 34467; + + // Field descriptor #76 I + public static final int GL_MULTISAMPLE = 32925; + + // Field descriptor #76 I + public static final int GL_SAMPLE_ALPHA_TO_COVERAGE = 32926; + + // Field descriptor #76 I + public static final int GL_SAMPLE_ALPHA_TO_ONE = 32927; + + // Field descriptor #76 I + public static final int GL_SAMPLE_COVERAGE = 32928; + + // Field descriptor #76 I + public static final int GL_SAMPLE_BUFFERS = 32936; + + // Field descriptor #76 I + public static final int GL_SAMPLES = 32937; + + // Field descriptor #76 I + public static final int GL_SAMPLE_COVERAGE_VALUE = 32938; + + // Field descriptor #76 I + public static final int GL_SAMPLE_COVERAGE_INVERT = 32939; + + // Field descriptor #76 I + public static final int GL_MULTISAMPLE_BIT = 536870912; + + // Field descriptor #76 I + public static final int GL_TRANSPOSE_MODELVIEW_MATRIX = 34019; + + // Field descriptor #76 I + public static final int GL_TRANSPOSE_PROJECTION_MATRIX = 34020; + + // Field descriptor #76 I + public static final int GL_TRANSPOSE_TEXTURE_MATRIX = 34021; + + // Field descriptor #76 I + public static final int GL_TRANSPOSE_COLOR_MATRIX = 34022; + + // Field descriptor #76 I + public static final int GL_COMBINE = 34160; + + // Field descriptor #76 I + public static final int GL_COMBINE_RGB = 34161; + + // Field descriptor #76 I + public static final int GL_COMBINE_ALPHA = 34162; + + // Field descriptor #76 I + public static final int GL_SOURCE0_RGB = 34176; + + // Field descriptor #76 I + public static final int GL_SOURCE1_RGB = 34177; + + // Field descriptor #76 I + public static final int GL_SOURCE2_RGB = 34178; + + // Field descriptor #76 I + public static final int GL_SOURCE0_ALPHA = 34184; + + // Field descriptor #76 I + public static final int GL_SOURCE1_ALPHA = 34185; + + // Field descriptor #76 I + public static final int GL_SOURCE2_ALPHA = 34186; + + // Field descriptor #76 I + public static final int GL_OPERAND0_RGB = 34192; + + // Field descriptor #76 I + public static final int GL_OPERAND1_RGB = 34193; + + // Field descriptor #76 I + public static final int GL_OPERAND2_RGB = 34194; + + // Field descriptor #76 I + public static final int GL_OPERAND0_ALPHA = 34200; + + // Field descriptor #76 I + public static final int GL_OPERAND1_ALPHA = 34201; + + // Field descriptor #76 I + public static final int GL_OPERAND2_ALPHA = 34202; + + // Field descriptor #76 I + public static final int GL_RGB_SCALE = 34163; + + // Field descriptor #76 I + public static final int GL_ADD_SIGNED = 34164; + + // Field descriptor #76 I + public static final int GL_INTERPOLATE = 34165; + + // Field descriptor #76 I + public static final int GL_SUBTRACT = 34023; + + // Field descriptor #76 I + public static final int GL_CONSTANT = 34166; + + // Field descriptor #76 I + public static final int GL_PRIMARY_COLOR = 34167; + + // Field descriptor #76 I + public static final int GL_PREVIOUS = 34168; + + // Field descriptor #76 I + public static final int GL_DOT3_RGB = 34478; + + // Field descriptor #76 I + public static final int GL_DOT3_RGBA = 34479; + + // Field descriptor #76 I + public static final int GL_CLAMP_TO_BORDER = 33069; + + // Field descriptor #71 I + public static final int GL_ARRAY_BUFFER = 34962; + + // Field descriptor #71 I + public static final int GL_ELEMENT_ARRAY_BUFFER = 34963; + + // Field descriptor #71 I + public static final int GL_ARRAY_BUFFER_BINDING = 34964; + + // Field descriptor #71 I + public static final int GL_ELEMENT_ARRAY_BUFFER_BINDING = 34965; + + // Field descriptor #71 I + public static final int GL_VERTEX_ARRAY_BUFFER_BINDING = 34966; + + // Field descriptor #71 I + public static final int GL_NORMAL_ARRAY_BUFFER_BINDING = 34967; + + // Field descriptor #71 I + public static final int GL_COLOR_ARRAY_BUFFER_BINDING = 34968; + + // Field descriptor #71 I + public static final int GL_INDEX_ARRAY_BUFFER_BINDING = 34969; + + // Field descriptor #71 I + public static final int GL_TEXTURE_COORD_ARRAY_BUFFER_BINDING = 34970; + + // Field descriptor #71 I + public static final int GL_EDGE_FLAG_ARRAY_BUFFER_BINDING = 34971; + + // Field descriptor #71 I + public static final int GL_SECONDARY_COLOR_ARRAY_BUFFER_BINDING = 34972; + + // Field descriptor #71 I + public static final int GL_FOG_COORDINATE_ARRAY_BUFFER_BINDING = 34973; + + // Field descriptor #71 I + public static final int GL_WEIGHT_ARRAY_BUFFER_BINDING = 34974; + + // Field descriptor #71 I + public static final int GL_VERTEX_ATTRIB_ARRAY_BUFFER_BINDING = 34975; + + // Field descriptor #71 I + public static final int GL_STREAM_DRAW = 35040; + + // Field descriptor #71 I + public static final int GL_STREAM_READ = 35041; + + // Field descriptor #71 I + public static final int GL_STREAM_COPY = 35042; + + // Field descriptor #71 I + public static final int GL_STATIC_DRAW = 35044; + + // Field descriptor #71 I + public static final int GL_STATIC_READ = 35045; + + // Field descriptor #71 I + public static final int GL_STATIC_COPY = 35046; + + // Field descriptor #71 I + public static final int GL_DYNAMIC_DRAW = 35048; + + // Field descriptor #71 I + public static final int GL_DYNAMIC_READ = 35049; + + // Field descriptor #71 I + public static final int GL_DYNAMIC_COPY = 35050; + + // Field descriptor #71 I + public static final int GL_READ_ONLY = 35000; + + // Field descriptor #71 I + public static final int GL_WRITE_ONLY = 35001; + + // Field descriptor #71 I + public static final int GL_READ_WRITE = 35002; + + // Field descriptor #71 I + public static final int GL_BUFFER_SIZE = 34660; + + // Field descriptor #71 I + public static final int GL_BUFFER_USAGE = 34661; + + // Field descriptor #71 I + public static final int GL_BUFFER_ACCESS = 35003; + + // Field descriptor #71 I + public static final int GL_BUFFER_MAPPED = 35004; + + // Field descriptor #71 I + public static final int GL_BUFFER_MAP_POINTER = 35005; + + // Field descriptor #71 I + public static final int GL_FOG_COORD_SRC = 33872; + + // Field descriptor #71 I + public static final int GL_FOG_COORD = 33873; + + // Field descriptor #71 I + public static final int GL_CURRENT_FOG_COORD = 33875; + + // Field descriptor #71 I + public static final int GL_FOG_COORD_ARRAY_TYPE = 33876; + + // Field descriptor #71 I + public static final int GL_FOG_COORD_ARRAY_STRIDE = 33877; + + // Field descriptor #71 I + public static final int GL_FOG_COORD_ARRAY_POINTER = 33878; + + // Field descriptor #71 I + public static final int GL_FOG_COORD_ARRAY = 33879; + + // Field descriptor #71 I + public static final int GL_FOG_COORD_ARRAY_BUFFER_BINDING = 34973; + + // Field descriptor #71 I + public static final int GL_SRC0_RGB = 34176; + + // Field descriptor #71 I + public static final int GL_SRC1_RGB = 34177; + + // Field descriptor #71 I + public static final int GL_SRC2_RGB = 34178; + + // Field descriptor #71 I + public static final int GL_SRC0_ALPHA = 34184; + + // Field descriptor #71 I + public static final int GL_SRC1_ALPHA = 34185; + + // Field descriptor #71 I + public static final int GL_SRC2_ALPHA = 34186; + + // Field descriptor #71 I + public static final int GL_SAMPLES_PASSED = 35092; + + // Field descriptor #71 I + public static final int GL_QUERY_COUNTER_BITS = 34916; + + // Field descriptor #71 I + public static final int GL_CURRENT_QUERY = 34917; + + // Field descriptor #71 I + public static final int GL_QUERY_RESULT = 34918; + + // Field descriptor #71 I + public static final int GL_QUERY_RESULT_AVAILABLE = 34919; + + // Field descriptor #194 I + public static final int GL_SHADING_LANGUAGE_VERSION = 35724; + + // Field descriptor #194 I + public static final int GL_CURRENT_PROGRAM = 35725; + + // Field descriptor #194 I + public static final int GL_SHADER_TYPE = 35663; + + // Field descriptor #194 I + public static final int GL_DELETE_STATUS = 35712; + + // Field descriptor #194 I + public static final int GL_COMPILE_STATUS = 35713; + + // Field descriptor #194 I + public static final int GL_LINK_STATUS = 35714; + + // Field descriptor #194 I + public static final int GL_VALIDATE_STATUS = 35715; + + // Field descriptor #194 I + public static final int GL_INFO_LOG_LENGTH = 35716; + + // Field descriptor #194 I + public static final int GL_ATTACHED_SHADERS = 35717; + + // Field descriptor #194 I + public static final int GL_ACTIVE_UNIFORMS = 35718; + + // Field descriptor #194 I + public static final int GL_ACTIVE_UNIFORM_MAX_LENGTH = 35719; + + // Field descriptor #194 I + public static final int GL_ACTIVE_ATTRIBUTES = 35721; + + // Field descriptor #194 I + public static final int GL_ACTIVE_ATTRIBUTE_MAX_LENGTH = 35722; + + // Field descriptor #194 I + public static final int GL_SHADER_SOURCE_LENGTH = 35720; + + // Field descriptor #194 I + public static final int GL_SHADER_OBJECT = 35656; + + // Field descriptor #194 I + public static final int GL_FLOAT_VEC2 = 35664; + + // Field descriptor #194 I + public static final int GL_FLOAT_VEC3 = 35665; + + // Field descriptor #194 I + public static final int GL_FLOAT_VEC4 = 35666; + + // Field descriptor #194 I + public static final int GL_INT_VEC2 = 35667; + + // Field descriptor #194 I + public static final int GL_INT_VEC3 = 35668; + + // Field descriptor #194 I + public static final int GL_INT_VEC4 = 35669; + + // Field descriptor #194 I + public static final int GL_BOOL = 35670; + + // Field descriptor #194 I + public static final int GL_BOOL_VEC2 = 35671; + + // Field descriptor #194 I + public static final int GL_BOOL_VEC3 = 35672; + + // Field descriptor #194 I + public static final int GL_BOOL_VEC4 = 35673; + + // Field descriptor #194 I + public static final int GL_FLOAT_MAT2 = 35674; + + // Field descriptor #194 I + public static final int GL_FLOAT_MAT3 = 35675; + + // Field descriptor #194 I + public static final int GL_FLOAT_MAT4 = 35676; + + // Field descriptor #194 I + public static final int GL_SAMPLER_1D = 35677; + + // Field descriptor #194 I + public static final int GL_SAMPLER_2D = 35678; + + // Field descriptor #194 I + public static final int GL_SAMPLER_3D = 35679; + + // Field descriptor #194 I + public static final int GL_SAMPLER_CUBE = 35680; + + // Field descriptor #194 I + public static final int GL_SAMPLER_1D_SHADOW = 35681; + + // Field descriptor #194 I + public static final int GL_SAMPLER_2D_SHADOW = 35682; + + // Field descriptor #194 I + public static final int GL_VERTEX_SHADER = 35633; + + // Field descriptor #194 I + public static final int GL_MAX_VERTEX_UNIFORM_COMPONENTS = 35658; + + // Field descriptor #194 I + public static final int GL_MAX_VARYING_FLOATS = 35659; + + // Field descriptor #194 I + public static final int GL_MAX_VERTEX_ATTRIBS = 34921; + + // Field descriptor #194 I + public static final int GL_MAX_TEXTURE_IMAGE_UNITS = 34930; + + // Field descriptor #194 I + public static final int GL_MAX_VERTEX_TEXTURE_IMAGE_UNITS = 35660; + + // Field descriptor #194 I + public static final int GL_MAX_COMBINED_TEXTURE_IMAGE_UNITS = 35661; + + // Field descriptor #194 I + public static final int GL_MAX_TEXTURE_COORDS = 34929; + + // Field descriptor #194 I + public static final int GL_VERTEX_PROGRAM_POINT_SIZE = 34370; + + // Field descriptor #194 I + public static final int GL_VERTEX_PROGRAM_TWO_SIDE = 34371; + + // Field descriptor #194 I + public static final int GL_VERTEX_ATTRIB_ARRAY_ENABLED = 34338; + + // Field descriptor #194 I + public static final int GL_VERTEX_ATTRIB_ARRAY_SIZE = 34339; + + // Field descriptor #194 I + public static final int GL_VERTEX_ATTRIB_ARRAY_STRIDE = 34340; + + // Field descriptor #194 I + public static final int GL_VERTEX_ATTRIB_ARRAY_TYPE = 34341; + + // Field descriptor #194 I + public static final int GL_VERTEX_ATTRIB_ARRAY_NORMALIZED = 34922; + + // Field descriptor #194 I + public static final int GL_CURRENT_VERTEX_ATTRIB = 34342; + + // Field descriptor #194 I + public static final int GL_VERTEX_ATTRIB_ARRAY_POINTER = 34373; + + // Field descriptor #194 I + public static final int GL_FRAGMENT_SHADER = 35632; + + // Field descriptor #194 I + public static final int GL_MAX_FRAGMENT_UNIFORM_COMPONENTS = 35657; + + // Field descriptor #194 I + public static final int GL_FRAGMENT_SHADER_DERIVATIVE_HINT = 35723; + + // Field descriptor #194 I + public static final int GL_MAX_DRAW_BUFFERS = 34852; + + // Field descriptor #194 I + public static final int GL_DRAW_BUFFER0 = 34853; + + // Field descriptor #194 I + public static final int GL_DRAW_BUFFER1 = 34854; + + // Field descriptor #194 I + public static final int GL_DRAW_BUFFER2 = 34855; + + // Field descriptor #194 I + public static final int GL_DRAW_BUFFER3 = 34856; + + // Field descriptor #194 I + public static final int GL_DRAW_BUFFER4 = 34857; + + // Field descriptor #194 I + public static final int GL_DRAW_BUFFER5 = 34858; + + // Field descriptor #194 I + public static final int GL_DRAW_BUFFER6 = 34859; + + // Field descriptor #194 I + public static final int GL_DRAW_BUFFER7 = 34860; + + // Field descriptor #194 I + public static final int GL_DRAW_BUFFER8 = 34861; + + // Field descriptor #194 I + public static final int GL_DRAW_BUFFER9 = 34862; + + // Field descriptor #194 I + public static final int GL_DRAW_BUFFER10 = 34863; + + // Field descriptor #194 I + public static final int GL_DRAW_BUFFER11 = 34864; + + // Field descriptor #194 I + public static final int GL_DRAW_BUFFER12 = 34865; + + // Field descriptor #194 I + public static final int GL_DRAW_BUFFER13 = 34866; + + // Field descriptor #194 I + public static final int GL_DRAW_BUFFER14 = 34867; + + // Field descriptor #194 I + public static final int GL_DRAW_BUFFER15 = 34868; + + // Field descriptor #194 I + public static final int GL_POINT_SPRITE = 34913; + + // Field descriptor #194 I + public static final int GL_COORD_REPLACE = 34914; + + // Field descriptor #194 I + public static final int GL_POINT_SPRITE_COORD_ORIGIN = 36000; + + // Field descriptor #194 I + public static final int GL_LOWER_LEFT = 36001; + + // Field descriptor #194 I + public static final int GL_UPPER_LEFT = 36002; + + // Field descriptor #194 I + public static final int GL_STENCIL_BACK_FUNC = 34816; + + // Field descriptor #194 I + public static final int GL_STENCIL_BACK_FAIL = 34817; + + // Field descriptor #194 I + public static final int GL_STENCIL_BACK_PASS_DEPTH_FAIL = 34818; + + // Field descriptor #194 I + public static final int GL_STENCIL_BACK_PASS_DEPTH_PASS = 34819; + + // Field descriptor #194 I + public static final int GL_STENCIL_BACK_REF = 36003; + + // Field descriptor #194 I + public static final int GL_STENCIL_BACK_VALUE_MASK = 36004; + + // Field descriptor #194 I + public static final int GL_STENCIL_BACK_WRITEMASK = 36005; + + // Field descriptor #194 I + public static final int GL_BLEND_EQUATION_RGB = 32777; + + // Field descriptor #194 I + public static final int GL_BLEND_EQUATION_ALPHA = 34877; + + } + + public static class EaglerAdapterImpl2 { + + public static final String _wgetShaderHeader() { + return "#version 300 es"; + } + + @JSBody(params = { }, script = "return window.location.href;") + private static native String getLocationString(); + + public static final boolean isSSLPage() { + return getLocationString().startsWith("https"); + } + + public static final InputStream loadResource(String path) { + byte[] file = loadResourceBytes(path); + if (file != null) { + return new ByteArrayInputStream(file); + } else { + return null; + } + } + + public static final byte[] loadResourceBytes(String path) { + return AssetRepository.getResource(path); + } + + public static final String fileContents(String path) { + byte[] contents = loadResourceBytes(path); + if(contents == null) { + return null; + }else { + return new String(contents, Charset.forName("UTF-8")); + } + } + + public static final String[] fileContentsLines(String path) { + String contents = fileContents(path); + if(contents == null) { + return null; + }else { + return contents.replace("\r\n", "\n").split("[\r\n]"); + } + } + + @Async + public static native String downloadAssetPack(String assetPackageURI); + + private static void downloadAssetPack(String assetPackageURI, final AsyncCallback cb) { + final XMLHttpRequest request = XMLHttpRequest.create(); + request.setResponseType("arraybuffer"); + request.open("GET", assetPackageURI, true); + request.setOnReadyStateChange(new ReadyStateChangeHandler() { + @Override + public void stateChanged() { + if(request.getReadyState() == XMLHttpRequest.DONE) { + Uint8Array bl = Uint8Array.create((ArrayBuffer)request.getResponse()); + loadedPackage = new byte[bl.getByteLength()]; + for(int i = 0; i < loadedPackage.length; ++i) { + loadedPackage[i] = (byte) bl.get(i); + } + cb.complete("yee"); + } + } + }); + request.send(); + } + + @Async + public static native byte[] downloadURL(String url); + + private static void downloadURL(String url, final AsyncCallback cb) { + if(url.isEmpty()) { + cb.complete(new byte[0]); + return; + } + final XMLHttpRequest request = XMLHttpRequest.create(); + request.setResponseType("arraybuffer"); + request.open("GET", url, true); + request.setOnReadyStateChange(new ReadyStateChangeHandler() { + @Override + public void stateChanged() { + if(request.getReadyState() == XMLHttpRequest.DONE) { + Uint8Array bl = Uint8Array.create((ArrayBuffer)request.getResponse()); + byte[] res = new byte[bl.getByteLength()]; + for(int i = 0; i < res.length; ++i) { + res[i] = (byte) bl.get(i); + } + cb.complete(res); + } + } + }); + request.send(); + } + + @JSBody(params = { "v", "s" }, script = "window[v] = s;") + public static native void setDebugVar(String v, String s); + + @JSBody(params = { }, script = "if(window.navigator.userActivation){return window.navigator.userActivation.hasBeenActive;}else{return false;}") + public static native boolean hasBeenActive(); + + public static HTMLDocument doc = null; + public static HTMLElement parent = null; + public static HTMLCanvasElement canvas = null; + public static WebGL2RenderingContext webgl = null; + public static FramebufferGL backBuffer = null; + public static RenderbufferGL backBufferColor = null; + public static RenderbufferGL backBufferDepth = null; + public static Window win = null; + private static byte[] loadedPackage = null; + private static EventListener contextmenu = null; + private static EventListener mousedown = null; + private static EventListener mouseup = null; + private static EventListener mousemove = null; + private static EventListener keydown = null; + private static EventListener keyup = null; + private static EventListener keypress = null; + private static EventListener wheel = null; + private static String[] identifier = new String[0]; + private static String integratedServerScript = "worker_bootstrap.js"; + private static boolean anisotropicFilteringSupported = false; + + public static final String[] getIdentifier() { + return identifier; + } + + @JSBody(params = { "v" }, script = "try { return \"\"+window.navigator[v]; } catch(e) { return \"\"; }") + private static native String getNavString(String var); + + @JSBody(params = { "m" }, script = "return m.offsetX;") + private static native int getOffsetX(MouseEvent m); + + @JSBody(params = { "m" }, script = "return m.offsetY;") + private static native int getOffsetY(MouseEvent m); + + @JSBody(params = { "e" }, script = "return e.which;") + private static native int getWhich(KeyboardEvent e); + + @JSBody(params = { }, script = "window.addEventListener('beforeunload', (event) => {event.preventDefault(); return '';});") + private static native void onBeforeCloseRegister(); + + @JSBody(params = { }, script = "return window.assetsURI != null;") + private static native boolean hasAssetsURI(); + + @JSBody(params = { }, script = "return window.assetsURI;") + private static native String getAssetsURI(); + + public static final void initializeContext(String assetsURI) { + HTMLElement rootElement = Window.current().getDocument().getBody(); + parent = rootElement; + String s = parent.getAttribute("style"); + parent.setAttribute("style", (s == null ? "" : s)+"overflow-x:hidden;overflow-y:hidden;"); + win = Window.current(); + doc = win.getDocument(); + double r = win.getDevicePixelRatio(); + int iw = parent.getClientWidth(); + int ih = parent.getClientHeight(); + int sw = (int)(r * iw); + int sh = (int)(r * ih); + canvas = (HTMLCanvasElement)doc.createElement("canvas"); + CSSStyleDeclaration canvasStyle = canvas.getStyle(); + canvasStyle.setProperty("width", "100%"); + canvasStyle.setProperty("height", "100%"); + canvasStyle.setProperty("image-rendering", "pixelated"); + canvas.setWidth(sw); + canvas.setHeight(sh); + rootElement.appendChild(canvas); + try { + doc.exitPointerLock(); + }catch(Throwable t) { + Client.showIncompatibleScreen("Mouse cursor lock is not available on this device!"); + throw new RuntimeException("Mouse cursor lock is not available on this device!"); + } + webgl = (WebGL2RenderingContext) canvas.getContext("webgl2", youEagler()); + if(webgl == null) { + Client.showIncompatibleScreen("WebGL 2.0 is not supported on this device!"); + throw new RuntimeException("WebGL 2.0 is not supported in your browser ("+getNavString("userAgent")+")"); + } + + setupBackBuffer(); + resizeBackBuffer(sw, sh); + + anisotropicFilteringSupported = webgl.getExtension("EXT_texture_filter_anisotropic") != null; + + win.addEventListener("contextmenu", contextmenu = new EventListener() { + @Override + public void handleEvent(MouseEvent evt) { + evt.preventDefault(); + evt.stopPropagation(); + } + }); + canvas.addEventListener("mousedown", mousedown = new EventListener() { + @Override + public void handleEvent(MouseEvent evt) { + int b = evt.getButton(); + buttonStates[b == 1 ? 2 : (b == 2 ? 1 : b)] = true; + mouseEvents.add(evt); + evt.preventDefault(); + evt.stopPropagation(); + } + }); + canvas.addEventListener("mouseup", mouseup = new EventListener() { + @Override + public void handleEvent(MouseEvent evt) { + int b = evt.getButton(); + buttonStates[b == 1 ? 2 : (b == 2 ? 1 : b)] = false; + mouseEvents.add(evt); + evt.preventDefault(); + evt.stopPropagation(); + } + }); + canvas.addEventListener("mousemove", mousemove = new EventListener() { + @Override + public void handleEvent(MouseEvent evt) { + mouseX = (int)(getOffsetX(evt) * win.getDevicePixelRatio()); + mouseY = (int)((canvas.getClientHeight() - getOffsetY(evt)) * win.getDevicePixelRatio()); + mouseDX += evt.getMovementX(); + mouseDY += -evt.getMovementY(); + if(hasBeenActive()) { + mouseEvents.add(evt); + } + evt.preventDefault(); + evt.stopPropagation(); + } + }); + win.addEventListener("keydown", keydown = new EventListener() { + @Override + public void handleEvent(KeyboardEvent evt) { + //keyStates[remapKey(evt.getKeyCode())] = true; + keyStates[remapKey(getWhich(evt))] = true; + keyEvents.add(evt); + evt.preventDefault(); + evt.stopPropagation(); + } + }); + win.addEventListener("keyup", keyup = new EventListener() { + @Override + public void handleEvent(KeyboardEvent evt) { + //keyStates[remapKey(evt.getKeyCode())] = false; + keyStates[remapKey(getWhich(evt))] = false; + keyEvents.add(evt); + evt.preventDefault(); + evt.stopPropagation(); + } + }); + win.addEventListener("keypress", keypress = new EventListener() { + @Override + public void handleEvent(KeyboardEvent evt) { + if(enableRepeatEvents && evt.isRepeat()) keyEvents.add(evt); + evt.preventDefault(); + evt.stopPropagation(); + } + }); + canvas.addEventListener("wheel", wheel = new EventListener() { + @Override + public void handleEvent(WheelEvent evt) { + mouseEvents.add(evt); + evt.preventDefault(); + evt.stopPropagation(); + } + }); + win.addEventListener("blur", new EventListener() { + @Override + public void handleEvent(WheelEvent evt) { + isWindowFocused = false; + } + }); + win.addEventListener("focus", new EventListener() { + @Override + public void handleEvent(WheelEvent evt) { + isWindowFocused = true; + } + }); + win.addEventListener("pointerlockchange", new EventListener() { + public void handleEvent(MouseEvent evt) { + lostFocus = true; + } + }); + onBeforeCloseRegister(); + + EarlyLoadScreen.paintScreen(); + + downloadAssetPack(assetsURI); + + try { + AssetRepository.install(loadedPackage); + } catch (IOException e) { + e.printStackTrace(); + } + + if(mouseEvents.isEmpty() && keyEvents.isEmpty() && !hasBeenActive()) { + EarlyLoadScreen.paintEnable(); + + while(mouseEvents.isEmpty() && keyEvents.isEmpty()) { + try { + Thread.sleep(100l); + } catch (InterruptedException e) { + ; + } + } + } + + audioctx = AudioContext.create(); + + mouseEvents.clear(); + keyEvents.clear(); + } + + public static final void setListenerPos(float x, float y, float z, float vx, float vy, float vz, float pitch, float yaw) { + float var2 = MathHelper.cos(-yaw * 0.017453292F); + float var3 = MathHelper.sin(-yaw * 0.017453292F); + float var4 = -MathHelper.cos(pitch * 0.017453292F); + float var5 = MathHelper.sin(pitch * 0.017453292F); + AudioListener l = audioctx.getListener(); + l.setPosition(x, y, z); + l.setOrientation(-var3 * var4, -var5, -var2 * var4, 0.0f, 1.0f, 0.0f); + } + + private static int playbackId = 0; + private static final HashMap loadedSoundFiles = new HashMap(); + private static AudioContext audioctx = null; + private static float playbackOffsetDelay = 0.03f; + + public static final void setPlaybackOffsetDelay(float f) { + playbackOffsetDelay = f; + } + + @Async + public static native AudioBuffer decodeAudioAsync(ArrayBuffer buffer); + + private static void decodeAudioAsync(ArrayBuffer buffer, final AsyncCallback cb) { + audioctx.decodeAudioData(buffer, new DecodeSuccessCallback() { + public void onSuccess(AudioBuffer decodedData) { + cb.complete(decodedData); + } + }, new DecodeErrorCallback() { + public void onError(JSObject error) { + cb.complete(null); + } + }); + } + + public static final HashMap activeSoundEffects = new HashMap(); + + private static class AudioBufferX { + private final AudioBuffer buffer; + private AudioBufferX(AudioBuffer buffer) { + this.buffer = buffer; + } + } + + public static class AudioBufferSourceNodeX { + private final AudioBufferSourceNode source; + private final PannerNode panner; + private final GainNode gain; + private AudioBufferSourceNodeX(AudioBufferSourceNode source, PannerNode panner, GainNode gain) { + this.source = source; + this.panner = panner; + this.gain = gain; + } + } + + private static final AudioBuffer getBufferFor(String fileName) { + AudioBufferX ret = loadedSoundFiles.get(fileName); + if(ret == null) { + byte[] file = loadResourceBytes(fileName); + if(file == null) return null; + Uint8Array buf = Uint8Array.create(file.length); + buf.set(file); + ret = new AudioBufferX(decodeAudioAsync(buf.getBuffer())); + loadedSoundFiles.put(fileName, ret); + } + return ret.buffer; + } + + public static final int beginPlayback(String fileName, float x, float y, float z, float volume, float pitch) { + AudioBuffer b = getBufferFor(fileName); + if(b == null) return -1; + AudioBufferSourceNode s = audioctx.createBufferSource(); + s.setBuffer(b); + s.getPlaybackRate().setValue(pitch); + PannerNode p = audioctx.createPanner(); + p.setPosition(x, y, z); + p.setMaxDistance(volume * 16f + 0.1f); + p.setRolloffFactor(1f); + //p.setVelocity(0f, 0f, 0f); + p.setDistanceModel("linear"); + p.setPanningModel("HRTF"); + p.setConeInnerAngle(360f); + p.setConeOuterAngle(0f); + p.setConeOuterGain(0f); + p.setOrientation(0f, 1f, 0f); + GainNode g = audioctx.createGain(); + g.getGain().setValue(volume > 1.0f ? 1.0f : volume); + s.connect(g); + g.connect(p); + p.connect(audioctx.getDestination()); + s.start(0.0d, playbackOffsetDelay); + final int theId = ++playbackId; + activeSoundEffects.put(theId, new AudioBufferSourceNodeX(s, p, g)); + s.setOnEnded(new EventListener() { + + @Override + public void handleEvent(MediaEvent evt) { + activeSoundEffects.remove(theId); + } + + }); + return theId; + } + public static final int beginPlaybackStatic(String fileName, float volume, float pitch) { + AudioBuffer b = getBufferFor(fileName); + if(b == null) return -1; + AudioBufferSourceNode s = audioctx.createBufferSource(); + s.setBuffer(b); + s.getPlaybackRate().setValue(pitch); + GainNode g = audioctx.createGain(); + g.getGain().setValue(volume > 1.0f ? 1.0f : volume); + s.connect(g); + g.connect(audioctx.getDestination()); + s.start(0.0d, playbackOffsetDelay); + final int theId = ++playbackId; + activeSoundEffects.put(theId, new AudioBufferSourceNodeX(s, null, g)); + s.setOnEnded(new EventListener() { + @Override + public void handleEvent(MediaEvent evt) { + activeSoundEffects.remove(theId); + } + + }); + return playbackId; + } + public static final void setPitch(int id, float pitch) { + AudioBufferSourceNodeX b = activeSoundEffects.get(id); + if(b != null) { + b.source.getPlaybackRate().setValue(pitch); + } + } + public static final void setVolume(int id, float volume) { + AudioBufferSourceNodeX b = activeSoundEffects.get(id); + if(b != null) { + b.gain.getGain().setValue(volume); + if(b.panner != null) b.panner.setMaxDistance(volume * 16f + 0.1f); + } + } + public static float getVolume(int id) { + AudioBufferSourceNodeX b = activeSoundEffects.get(id); + if(b != null) { + return b.gain.getGain().getValue(); + } + return 0.0F; + } + public static final void moveSound(int id, float x, float y, float z, float vx, float vy, float vz) { + AudioBufferSourceNodeX b = activeSoundEffects.get(id); + if(b != null && b.panner != null) { + b.panner.setPosition(x, y, z); + //b.panner.setVelocity(vx, vy, vz); + } + } + public static final void endSound(int id) { + AudioBufferSourceNodeX b = activeSoundEffects.get(id); + if(b != null) { + b.source.stop(); + activeSoundEffects.remove(id); + } + } + public static final boolean isPlaying(int id) { + return activeSoundEffects.containsKey(id); + } + + private static LinkedList mouseEvents = new LinkedList(); + private static LinkedList keyEvents = new LinkedList(); + + private static int mouseX = 0; + private static int mouseY = 0; + private static double mouseDX = 0.0D; + private static double mouseDY = 0.0D; + private static int width = 0; + private static int height = 0; + private static boolean enableRepeatEvents = false; + private static boolean isWindowFocused = true; + + @JSBody(params = { }, script = "return {antialias: false, depth: true, powerPreference: \"high-performance\", desynchronized: true, preserveDrawingBuffer: false, premultipliedAlpha: false, alpha: false};") + public static native JSObject youEagler(); + + public static final int _wGL_TEXTURE_2D = TEXTURE_2D; + public static final int _wGL_DEPTH_TEST = DEPTH_TEST; + public static final int _wGL_LEQUAL = LEQUAL; + public static final int _wGL_GEQUAL = GEQUAL; + public static final int _wGL_GREATER = GREATER; + public static final int _wGL_LESS = LESS; + public static final int _wGL_BACK = BACK; + public static final int _wGL_FRONT = FRONT; + public static final int _wGL_FRONT_AND_BACK = FRONT_AND_BACK; + public static final int _wGL_COLOR_BUFFER_BIT = COLOR_BUFFER_BIT; + public static final int _wGL_DEPTH_BUFFER_BIT = DEPTH_BUFFER_BIT; + public static final int _wGL_BLEND = BLEND; + public static final int _wGL_RGBA = RGBA; + public static final int _wGL_RGB = RGB; + public static final int _wGL_RGB8 = RGB8; + public static final int _wGL_RGBA8 = RGBA8; + public static final int _wGL_RED = RED; + public static final int _wGL_R8 = R8; + public static final int _wGL_UNSIGNED_BYTE = UNSIGNED_BYTE; + public static final int _wGL_UNSIGNED_SHORT = UNSIGNED_SHORT; + public static final int _wGL_SRC_ALPHA = SRC_ALPHA; + public static final int _wGL_ONE_MINUS_SRC_ALPHA = ONE_MINUS_SRC_ALPHA; + public static final int _wGL_ONE_MINUS_DST_COLOR = ONE_MINUS_DST_COLOR; + public static final int _wGL_ONE_MINUS_SRC_COLOR = ONE_MINUS_SRC_COLOR; + public static final int _wGL_ZERO = ZERO; + public static final int _wGL_CULL_FACE = CULL_FACE; + public static final int _wGL_TEXTURE_MIN_FILTER = TEXTURE_MIN_FILTER; + public static final int _wGL_TEXTURE_MAG_FILTER = TEXTURE_MAG_FILTER; + public static final int _wGL_LINEAR = LINEAR; + public static final int _wGL_EQUAL = EQUAL; + public static final int _wGL_SRC_COLOR = SRC_COLOR; + public static final int _wGL_ONE = ONE; + public static final int _wGL_NEAREST = NEAREST; + public static final int _wGL_CLAMP = CLAMP_TO_EDGE; + public static final int _wGL_TEXTURE_WRAP_S = TEXTURE_WRAP_S; + public static final int _wGL_TEXTURE_WRAP_T = TEXTURE_WRAP_T; + public static final int _wGL_REPEAT = REPEAT; + public static final int _wGL_DST_COLOR = DST_COLOR; + public static final int _wGL_DST_ALPHA = DST_ALPHA; + public static final int _wGL_FLOAT = FLOAT; + public static final int _wGL_SHORT = SHORT; + public static final int _wGL_TRIANGLES = TRIANGLES; + public static final int _wGL_TRIANGLE_STRIP = TRIANGLE_STRIP; + public static final int _wGL_TRIANGLE_FAN = TRIANGLE_FAN; + public static final int _wGL_LINE_STRIP = LINE_STRIP; + public static final int _wGL_LINES = LINES; + public static final int _wGL_PACK_ALIGNMENT = PACK_ALIGNMENT; + public static final int _wGL_UNPACK_ALIGNMENT = UNPACK_ALIGNMENT; + public static final int _wGL_TEXTURE0 = TEXTURE0; + public static final int _wGL_TEXTURE1 = TEXTURE1; + public static final int _wGL_TEXTURE2 = TEXTURE2; + public static final int _wGL_TEXTURE3 = TEXTURE3; + public static final int _wGL_VIEWPORT = VIEWPORT; + public static final int _wGL_VERTEX_SHADER = VERTEX_SHADER; + public static final int _wGL_FRAGMENT_SHADER = FRAGMENT_SHADER; + public static final int _wGL_ARRAY_BUFFER = ARRAY_BUFFER; + public static final int _wGL_ELEMENT_ARRAY_BUFFER = ELEMENT_ARRAY_BUFFER; + public static final int _wGL_STATIC_DRAW = STATIC_DRAW; + public static final int _wGL_DYNAMIC_DRAW = DYNAMIC_DRAW; + public static final int _wGL_STREAM_DRAW = STREAM_DRAW; + public static final int _wGL_INVALID_ENUM = INVALID_ENUM; + public static final int _wGL_INVALID_VALUE= INVALID_VALUE; + public static final int _wGL_INVALID_OPERATION = INVALID_OPERATION; + public static final int _wGL_OUT_OF_MEMORY = OUT_OF_MEMORY; + public static final int _wGL_CONTEXT_LOST_WEBGL = CONTEXT_LOST_WEBGL; + public static final int _wGL_FRAMEBUFFER_COMPLETE = FRAMEBUFFER_COMPLETE; + public static final int _wGL_FRAMEBUFFER_INCOMPLETE_ATTACHMENT = FRAMEBUFFER_INCOMPLETE_ATTACHMENT; + public static final int _wGL_FRAMEBUFFER_INCOMPLETE_MISSING_ATTACHMENT = FRAMEBUFFER_INCOMPLETE_MISSING_ATTACHMENT; + public static final int _wGL_COLOR_ATTACHMENT0 = COLOR_ATTACHMENT0; + public static final int _wGL_DEPTH_STENCIL_ATTACHMENT = DEPTH_STENCIL_ATTACHMENT; + public static final int _wGL_DEPTH_STENCIL = DEPTH_STENCIL; + public static final int _wGL_NEAREST_MIPMAP_LINEAR = NEAREST_MIPMAP_LINEAR; + public static final int _wGL_LINEAR_MIPMAP_LINEAR = LINEAR_MIPMAP_LINEAR; + public static final int _wGL_LINEAR_MIPMAP_NEAREST = LINEAR_MIPMAP_NEAREST; + public static final int _wGL_NEAREST_MIPMAP_NEAREST = NEAREST_MIPMAP_NEAREST; + public static final int _wGL_TEXTURE_MAX_LEVEL = TEXTURE_MAX_LEVEL; + public static final int _wGL_UNSIGNED_INT_24_8 = UNSIGNED_INT_24_8; + public static final int _wGL_UNSIGNED_INT = UNSIGNED_INT; + public static final int _wGL_ANY_SAMPLES_PASSED = ANY_SAMPLES_PASSED; + public static final int _wGL_QUERY_RESULT = QUERY_RESULT; + public static final int _wGL_QUERY_RESULT_AVAILABLE = QUERY_RESULT_AVAILABLE; + public static final int _wGL_TEXTURE_MAX_ANISOTROPY = TEXTURE_MAX_ANISOTROPY_EXT; + public static final int _wGL_DEPTH24_STENCIL8 = DEPTH24_STENCIL8; + public static final int _wGL_DEPTH_COMPONENT32F = DEPTH_COMPONENT32F; + public static final int _wGL_DEPTH_ATTACHMENT = DEPTH_ATTACHMENT; + public static final int _wGL_MULTISAMPLE = -1; + public static final int _wGL_LINE_SMOOTH = -1; + public static final int _wGL_READ_FRAMEBUFFER = READ_FRAMEBUFFER; + public static final int _wGL_DRAW_FRAMEBUFFER = DRAW_FRAMEBUFFER; + public static final int _wGL_FRAMEBUFFER = FRAMEBUFFER; + public static final int _wGL_POLYGON_OFFSET_FILL = POLYGON_OFFSET_FILL; + + public static final class TextureGL { + protected final WebGLTexture obj; + public int w = -1; + public int h = -1; + public boolean nearest = true; + public boolean anisotropic = false; + protected TextureGL(WebGLTexture obj) { + this.obj = obj; + } + } + public static final class BufferGL { + protected final WebGLBuffer obj; + protected BufferGL(WebGLBuffer obj) { + this.obj = obj; + } + } + public static final class ShaderGL { + protected final WebGLShader obj; + protected ShaderGL(WebGLShader obj) { + this.obj = obj; + } + } + private static int progId = 0; + public static final class ProgramGL { + protected final WebGLProgram obj; + protected final int hashcode; + protected ProgramGL(WebGLProgram obj) { + this.obj = obj; + this.hashcode = ++progId; + } + } + public static final class UniformGL { + protected final WebGLUniformLocation obj; + protected UniformGL(WebGLUniformLocation obj) { + this.obj = obj; + } + } + public static final class BufferArrayGL { + protected final WebGLVertexArray obj; + public boolean isQuadBufferBound; + protected BufferArrayGL(WebGLVertexArray obj) { + this.obj = obj; + this.isQuadBufferBound = false; + } + } + public static final class FramebufferGL { + protected final WebGLFramebuffer obj; + protected FramebufferGL(WebGLFramebuffer obj) { + this.obj = obj; + } + } + public static final class RenderbufferGL { + protected final WebGLRenderbuffer obj; + protected RenderbufferGL(WebGLRenderbuffer obj) { + this.obj = obj; + } + } + public static final class QueryGL { + protected final WebGLQuery obj; + protected QueryGL(WebGLQuery obj) { + this.obj = obj; + } + } + + public static final boolean anisotropicFilteringSupported() { + return anisotropicFilteringSupported; + } + public static final void _wglEnable(int p1) { + webgl.enable(p1); + } + public static final void _wglClearDepth(float p1) { + webgl.clearDepth(p1); + } + public static final void _wglDepthFunc(int p1) { + webgl.depthFunc(p1); + } + public static final void _wglCullFace(int p1) { + webgl.cullFace(p1); + } + private static int[] viewportCache = new int[4]; + public static final void _wglViewport(int p1, int p2, int p3, int p4) { + viewportCache[0] = p1; viewportCache[1] = p2; + viewportCache[2] = p3; viewportCache[3] = p4; + webgl.viewport(p1, p2, p3, p4); + } + public static final void _wglClear(int p1) { + webgl.clear(p1); + } + public static final void _wglClearColor(float p1, float p2, float p3, float p4) { + webgl.clearColor(p1, p2, p3, p4); + } + public static final void _wglDisable(int p1) { + webgl.disable(p1); + } + public static final int _wglGetError() { + return webgl.getError(); + } + public static final void _wglFlush() { + //webgl.flush(); + } + private static Uint8Array uploadBuffer = Uint8Array.create(ArrayBuffer.create(4 * 1024 * 1024)); + public static final void _wglTexImage2D(int p1, int p2, int p3, int p4, int p5, int p6, int p7, int p8, ByteBuffer p9) { + if(p9 == null) { + webgl.texImage2D(p1, p2, p3, p4, p5, p6, p7, p8, null); + }else { + int len = p9.remaining(); + Uint8Array uploadBuffer1 = uploadBuffer; + for(int i = 0; i < len; ++i) { + uploadBuffer1.set(i, (short) ((int)p9.get() & 0xff)); + } + Uint8Array data = Uint8Array.create(uploadBuffer.getBuffer(), 0, len); + webgl.texImage2D(p1, p2, p3, p4, p5, p6, p7, p8, data); + } + } + public static final void _wglBlendFunc(int p1, int p2) { + webgl.blendFunc(p1, p2); + } + public static final void _wglBlendFuncSeparate(int p1, int p2, int p3, int p4) { + webgl.blendFuncSeparate(p1, p2, p3, p4); + } + public static final void _wglBlendColor(float r, float g, float b, float a) { + webgl.blendColor(r, g, b, a); + } + public static final void _wglDepthMask(boolean p1) { + webgl.depthMask(p1); + } + public static final void _wglColorMask(boolean p1, boolean p2, boolean p3, boolean p4) { + webgl.colorMask(p1, p2, p3, p4); + } + public static final void _wglBindTexture(int p1, TextureGL p2) { + webgl.bindTexture(p1, p2 == null ? null : p2.obj); + } + public static final void _wglCopyTexSubImage2D(int p1, int p2, int p3, int p4, int p5, int p6, int p7, int p8) { + webgl.copyTexSubImage2D(p1, p2, p3, p4, p5, p6, p7, p8); + } + public static final void _wglTexParameteri(int p1, int p2, int p3) { + webgl.texParameteri(p1, p2, p3); + } + public static final void _wglTexParameterf(int p1, int p2, float p3) { + webgl.texParameterf(p1, p2, p3); + } + public static final void _wglTexImage2D(int p1, int p2, int p3, int p4, int p5, int p6, int p7, int p8, IntBuffer p9) { + int len = p9.remaining(); + DataView deevis = DataView.create(uploadBuffer.getBuffer()); + for(int i = 0; i < len; ++i) { + deevis.setInt32(i * 4, p9.get(), true); + } + Uint8Array data = Uint8Array.create(uploadBuffer.getBuffer(), 0, len*4); + webgl.texImage2D(p1, p2, p3, p4, p5, p6, p7, p8, data); + } + public static final void _wglTexSubImage2D(int p1, int p2, int p3, int p4, int p5, int p6, int p7, int p8, IntBuffer p9) { + int len = p9.remaining(); + DataView deevis = DataView.create(uploadBuffer.getBuffer()); + for(int i = 0; i < len; ++i) { + deevis.setInt32(i * 4, p9.get(), true); + } + Uint8Array data = Uint8Array.create(uploadBuffer.getBuffer(), 0, len*4); + webgl.texSubImage2D(p1, p2, p3, p4, p5, p6, p7, p8, data); + } + public static final void _wglDeleteTextures(TextureGL p1) { + webgl.deleteTexture(p1.obj); + } + public static final void _wglDrawArrays(int p1, int p2, int p3) { + webgl.drawArrays(p1, p2, p3); + } + public static final void _wglDrawElements(int p1, int p2, int p3, int p4) { + webgl.drawElements(p1, p2, p3, p4); + } + public static final TextureGL _wglGenTextures() { + return new TextureGL(webgl.createTexture()); + } + public static final void _wglTexSubImage2D(int p1, int p2, int p3, int p4, int p5, int p6, int p7, int p8, ByteBuffer p9) { + int len = p9.remaining(); + for(int i = 0; i < len; ++i) { + //uploadBuffer.set(swapEndian ? ((i >> 2) + (3 - (i & 3))) : i, (short) ((int)p9.get() & 0xff)); + uploadBuffer.set(i, (short) ((int)p9.get() & 0xff)); + } + Uint8Array data = Uint8Array.create(uploadBuffer.getBuffer(), 0, len); + webgl.texSubImage2D(p1, p2, p3, p4, p5, p6, p7, p8, data); + } + public static final void _wglActiveTexture(int p1) { + webgl.activeTexture(p1); + } + public static final ProgramGL _wglCreateProgram() { + return new ProgramGL(webgl.createProgram()); + } + public static final ShaderGL _wglCreateShader(int p1) { + return new ShaderGL(webgl.createShader(p1)); + } + public static final void _wglAttachShader(ProgramGL p1, ShaderGL p2) { + webgl.attachShader(p1.obj, p2.obj); + } + public static final void _wglDetachShader(ProgramGL p1, ShaderGL p2) { + webgl.detachShader(p1.obj, p2.obj); + } + public static final void _wglCompileShader(ShaderGL p1) { + webgl.compileShader(p1.obj); + } + public static final void _wglLinkProgram(ProgramGL p1) { + webgl.linkProgram(p1.obj); + } + public static final void _wglShaderSource(ShaderGL p1, String p2) { + webgl.shaderSource(p1.obj, p2); + } + public static final String _wglGetShaderInfoLog(ShaderGL p1) { + return webgl.getShaderInfoLog(p1.obj); + } + public static final String _wglGetProgramInfoLog(ProgramGL p1) { + return webgl.getProgramInfoLog(p1.obj); + } + public static final boolean _wglGetShaderCompiled(ShaderGL p1) { + return webgl.getShaderParameteri(p1.obj, COMPILE_STATUS) == 1; + } + public static final boolean _wglGetProgramLinked(ProgramGL p1) { + return webgl.getProgramParameteri(p1.obj, LINK_STATUS) == 1; + } + public static final void _wglDeleteShader(ShaderGL p1) { + webgl.deleteShader(p1.obj); + } + public static final void _wglDeleteProgram(ProgramGL p1) { + webgl.deleteProgram(p1.obj); + } + public static final BufferGL _wglCreateBuffer() { + return new BufferGL(webgl.createBuffer()); + } + public static final void _wglDeleteBuffer(BufferGL p1) { + webgl.deleteBuffer(p1.obj); + } + public static final void _wglBindBuffer(int p1, BufferGL p2) { + webgl.bindBuffer(p1, p2 == null ? null : p2.obj); + } + public static final void _wglBufferData0(int p1, IntBuffer p2, int p3) { + int len = p2.remaining(); + DataView deevis = DataView.create(uploadBuffer.getBuffer()); + for(int i = 0; i < len; ++i) { + deevis.setInt32(i * 4, p2.get(), true); + } + Uint8Array data = Uint8Array.create(uploadBuffer.getBuffer(), 0, len*4); + webgl.bufferData(p1, data, p3); + } + public static final void _wglBufferSubData0(int p1, int p2, IntBuffer p3) { + int len = p3.remaining(); + DataView deevis = DataView.create(uploadBuffer.getBuffer()); + for(int i = 0; i < len; ++i) { + deevis.setInt32(i * 4, p3.get(), true); + } + Uint8Array data = Uint8Array.create(uploadBuffer.getBuffer(), 0, len*4); + webgl.bufferSubData(p1, p2, data); + } + public static final void _wglBufferData(int p1, Object p2, int p3) { + webgl.bufferData(p1, (Int32Array)p2, p3); + } + public static final void _wglBufferData00(int p1, long len, int p3) { + webgl.bufferData(p1, (int)len, p3); + } + public static final void _wglBufferSubData(int p1, int p2, Object p3) { + webgl.bufferSubData(p1, p2, (Int32Array)p3); + } + public static final void _wglBindAttribLocation(ProgramGL p1, int p2, String p3) { + webgl.bindAttribLocation(p1.obj, p2, p3); + } + public static final void _wglEnableVertexAttribArray(int p1) { + webgl.enableVertexAttribArray(p1); + } + public static final void _wglDisableVertexAttribArray(int p1) { + webgl.disableVertexAttribArray(p1); + } + public static final UniformGL _wglGetUniformLocation(ProgramGL p1, String p2) { + WebGLUniformLocation u = webgl.getUniformLocation(p1.obj, p2); + return u == null ? null : new UniformGL(u); + } + public static final void _wglBindAttributeLocation(ProgramGL p1, int p2, String p3) { + webgl.bindAttribLocation(p1.obj, p2, p3); + } + public static final void _wglUniform1f(UniformGL p1, float p2) { + if(p1 != null) webgl.uniform1f(p1.obj, p2); + } + public static final void _wglUniform2f(UniformGL p1, float p2, float p3) { + if(p1 != null) webgl.uniform2f(p1.obj, p2, p3); + } + public static final void _wglUniform3f(UniformGL p1, float p2, float p3, float p4) { + if(p1 != null) webgl.uniform3f(p1.obj, p2, p3, p4); + } + public static final void _wglUniform4f(UniformGL p1, float p2, float p3, float p4, float p5) { + if(p1 != null) webgl.uniform4f(p1.obj, p2, p3, p4, p5); + } + public static final void _wglUniform1i(UniformGL p1, int p2) { + if(p1 != null) webgl.uniform1i(p1.obj, p2); + } + public static final void _wglUniform2i(UniformGL p1, int p2, int p3) { + if(p1 != null) webgl.uniform2i(p1.obj, p2, p3); + } + public static final void _wglUniform3i(UniformGL p1, int p2, int p3, int p4) { + if(p1 != null) webgl.uniform3i(p1.obj, p2, p3, p4); + } + public static final void _wglUniform4i(UniformGL p1, int p2, int p3, int p4, int p5) { + if(p1 != null) webgl.uniform4i(p1.obj, p2, p3, p4, p5); + } + private static Float32Array mat2 = Float32Array.create(4); + private static Float32Array mat3 = Float32Array.create(9); + private static Float32Array mat4 = Float32Array.create(16); + public static final void _wglUniformMat2fv(UniformGL p1, float[] mat) { + mat2.set(mat); + if(p1 != null) webgl.uniformMatrix2fv(p1.obj, false, mat2); + } + public static final void _wglUniformMat3fv(UniformGL p1, float[] mat) { + mat3.set(mat); + if(p1 != null) webgl.uniformMatrix3fv(p1.obj, false, mat3); + } + public static final void _wglUniformMat4fv(UniformGL p1, float[] mat) { + mat4.set(mat); + if(p1 != null) webgl.uniformMatrix4fv(p1.obj, false, mat4); + } + private static int currentProgram = -1; + public static final void _wglUseProgram(ProgramGL p1) { + if(p1 != null && currentProgram != p1.hashcode) { + currentProgram = p1.hashcode; + webgl.useProgram(p1.obj); + } + } + public static final void _wglGetParameter(int p1, int size, int[] ret) { + if(p1 == _wGL_VIEWPORT) { + ret[0] = viewportCache[0]; + ret[1] = viewportCache[1]; + ret[2] = viewportCache[2]; + ret[3] = viewportCache[3]; + } + } + public static final void _wglPolygonOffset(float p1, float p2) { + webgl.polygonOffset(p1, p2); + } + public static final void _wglVertexAttribPointer(int p1, int p2, int p3, boolean p4, int p5, int p6) { + webgl.vertexAttribPointer(p1, p2, p3, p4, p5, p6); + } + public static final void _wglBindFramebuffer(int p1, FramebufferGL p2) { + webgl.bindFramebuffer(p1, p2 == null ? backBuffer.obj : p2.obj); + } + public static final void _wglReadBuffer(int p1) { + webgl.readBuffer(p1); + } + public static final FramebufferGL _wglCreateFramebuffer() { + return new FramebufferGL(webgl.createFramebuffer()); + } + public static final void _wglDeleteFramebuffer(FramebufferGL p1) { + webgl.deleteFramebuffer(p1.obj); + } + public static final void _wglFramebufferTexture2D(int p1, TextureGL p2) { + webgl.framebufferTexture2D(FRAMEBUFFER, p1, TEXTURE_2D, p2 == null ? null : p2.obj, 0); + } + public static final void _wglFramebufferTexture2D(int p1, TextureGL p2, int p3) { + webgl.framebufferTexture2D(FRAMEBUFFER, p1, TEXTURE_2D, p2 == null ? null : p2.obj, p3); + } + public static final QueryGL _wglCreateQuery() { + return new QueryGL(webgl.createQuery()); + } + public static final void _wglBeginQuery(int p1, QueryGL p2) { + webgl.beginQuery(p1, p2.obj); + } + public static final void _wglEndQuery(int p1) { + webgl.endQuery(p1); + } + public static final void _wglDeleteQuery(QueryGL p1) { + webgl.deleteQuery(p1.obj); + } + public static final int _wglGetQueryObjecti(QueryGL p1, int p2) { + return webgl.getQueryParameter(p1.obj, p2); + } + public static final BufferArrayGL _wglCreateVertexArray() { + return new BufferArrayGL(webgl.createVertexArray()); + } + public static final void _wglDeleteVertexArray(BufferArrayGL p1) { + webgl.deleteVertexArray(p1.obj); + } + public static final void _wglBindVertexArray(BufferArrayGL p1) { + webgl.bindVertexArray(p1 == null ? null : p1.obj); + } + public static final void _wglDrawBuffer(int p1) { + webgl.drawBuffers(new int[] { p1 }); + } + public static final RenderbufferGL _wglCreateRenderBuffer() { + return new RenderbufferGL(webgl.createRenderbuffer()); + } + public static final void _wglBindRenderbuffer(RenderbufferGL p1) { + webgl.bindRenderbuffer(RENDERBUFFER, p1 == null ? null : p1.obj); + } + public static final void _wglRenderbufferStorage(int p1, int p2, int p3) { + webgl.renderbufferStorage(RENDERBUFFER, p1, p2, p3); + } + public static final void _wglFramebufferRenderbuffer(int p1, RenderbufferGL p2) { + webgl.framebufferRenderbuffer(FRAMEBUFFER, p1, RENDERBUFFER, p2 == null ? null : p2.obj); + } + public static final void _wglDeleteRenderbuffer(RenderbufferGL p1) { + webgl.deleteRenderbuffer(p1.obj); + } + public static final void _wglRenderbufferStorageMultisample(int p1, int p2, int p3, int p4) { + webgl.renderbufferStorageMultisample(RENDERBUFFER, p1, p2, p3, p4); + } + public static final void _wglBlitFramebuffer(int p1, int p2, int p3, int p4, int p5, int p6, int p7, int p8, int p9, int p10) { + webgl.blitFramebuffer(p1, p2, p3, p4, p5, p6, p7, p8, p9, p10); + } + public static final int _wglGetAttribLocation(ProgramGL p1, String p2) { + return webgl.getAttribLocation(p1.obj, p2); + } + + @JSBody(params = { "ctx", "p" }, script = "return ctx.getTexParameter(0x0DE1, p) | 0;") + private static final native int __wglGetTexParameteri(WebGL2RenderingContext ctx, int p); + public static final int _wglGetTexParameteri(int p1) { + return __wglGetTexParameteri(webgl, p1); + } + @JSBody(params = { "ctx", "p" }, script = "return (0.0 + ctx.getTexParameter(0x0DE1, p));") + private static final native float __wglGetTexParameterf(WebGL2RenderingContext ctx, int p); + public static final float _wglGetTexParameterf(int p1) { + return __wglGetTexParameterf(webgl, p1); + } + public static final boolean isWindows() { + return getNavString("platform").toLowerCase().contains("win"); + } + public static final boolean glNeedsAnisotropicFix() { + return anisotropicFilteringSupported && DetectAnisotropicGlitch.hasGlitch(); + } + + private static HTMLCanvasElement imageLoadCanvas = null; + private static CanvasRenderingContext2D imageLoadContext = null; + + @JSBody(params = { "buf", "mime" }, script = "return URL.createObjectURL(new Blob([buf], {type: mime}));") + private static native String getDataURL(ArrayBuffer buf, String mime); + + @JSBody(params = { "url" }, script = "URL.revokeObjectURL(url);") + private static native void freeDataURL(String url); + + public static final BufferedImage loadPNG(byte[] data) { + ArrayBuffer arr = ArrayBuffer.create(data.length); + Uint8Array.create(arr).set(data); + return loadPNG0(arr); + } + + @JSBody(params = { "cccc", "ennn" }, script = "cccc.imageSmoothingEnabled = ennn;") + private static native void setImageSmoothingMode(CanvasRenderingContext2D cc, boolean en); + + @Async + private static native BufferedImage loadPNG0(ArrayBuffer data); + + private static void loadPNG0(ArrayBuffer data, final AsyncCallback ret) { + final HTMLImageElement toLoad = (HTMLImageElement) doc.createElement("img"); + toLoad.addEventListener("load", new EventListener() { + @Override + public void handleEvent(Event evt) { + if(imageLoadCanvas == null) { + imageLoadCanvas = (HTMLCanvasElement) doc.createElement("canvas"); + } + if(imageLoadCanvas.getWidth() < toLoad.getWidth()) { + imageLoadCanvas.setWidth(toLoad.getWidth()); + } + if(imageLoadCanvas.getHeight() < toLoad.getHeight()) { + imageLoadCanvas.setHeight(toLoad.getHeight()); + } + if(imageLoadContext == null) { + imageLoadContext = (CanvasRenderingContext2D) imageLoadCanvas.getContext("2d"); + setImageSmoothingMode(imageLoadContext, false); + } + imageLoadContext.clearRect(0, 0, toLoad.getWidth(), toLoad.getHeight()); + imageLoadContext.drawImage(toLoad, 0, 0, toLoad.getWidth(), toLoad.getHeight()); + ImageData pxlsDat = imageLoadContext.getImageData(0, 0, toLoad.getWidth(), toLoad.getHeight()); + Uint8ClampedArray pxls = pxlsDat.getData(); + int totalPixels = pxlsDat.getWidth() * pxlsDat.getHeight(); + freeDataURL(toLoad.getSrc()); + if(pxls.getByteLength() < totalPixels << 2) { + ret.complete(null); + return; + } + DataView dv = DataView.create(pxls.getBuffer()); + int[] pixels = new int[totalPixels]; + for(int i = 0, j; i < pixels.length; ++i) { + j = dv.getUint32(i << 2, false); + pixels[i] = ((j >> 8) & 0xFFFFFF) | ((j & 0xFF) << 24); + } + ret.complete(new BufferedImage(pixels, pxlsDat.getWidth(), pxlsDat.getHeight(), true)); + } + }); + toLoad.addEventListener("error", new EventListener() { + @Override + public void handleEvent(Event evt) { + freeDataURL(toLoad.getSrc()); + ret.complete(null); + } + }); + String src = getDataURL(data, "image/png"); + if(src == null) { + ret.complete(null); + }else { + toLoad.setSrc(src); + } + } + + private static MouseEvent currentEvent = null; + private static KeyboardEvent currentEventK = null; + private static boolean[] buttonStates = new boolean[8]; + private static boolean[] keyStates = new boolean[256]; + public static final boolean mouseNext() { + currentEvent = null; + return !mouseEvents.isEmpty() && (currentEvent = mouseEvents.remove(0)) != null; + } + public static final int mouseGetEventButton() { + if(currentEvent == null || currentEvent.getType().equals(MouseEvent.MOUSEMOVE)) return -1; + int b = currentEvent.getButton(); + return b == 1 ? 2 : (b == 2 ? 1 : b); + } + public static final boolean mouseGetEventButtonState() { + return currentEvent == null ? false : currentEvent.getType().equals(MouseEvent.MOUSEDOWN); + } + public static final boolean mouseIsButtonDown(int p1) { + return buttonStates[p1]; + } + public static final int mouseGetEventDWheel() { + return ("wheel".equals(currentEvent.getType())) ? (((WheelEvent)currentEvent).getDeltaY() == 0.0D ? 0 : (((WheelEvent)currentEvent).getDeltaY() > 0.0D ? -1 : 1)) : 0; + } + public static final void mouseSetCursorPosition(int x, int y) { + + } + private static long mouseUngrabTimer = 0l; + private static int mouseUngrabTimeout = 0; + public static final void mouseSetGrabbed(boolean grabbed) { + if(grabbed) { + canvas.requestPointerLock(); + long t = System.currentTimeMillis(); + if(mouseUngrabTimeout != 0) Window.clearTimeout(mouseUngrabTimeout); + mouseUngrabTimeout = 0; + if(t - mouseUngrabTimer < 3000l) { + mouseUngrabTimeout = Window.setTimeout(new TimerHandler() { + @Override + public void onTimer() { + canvas.requestPointerLock(); + } + }, 3000 - (int)(t - mouseUngrabTimer)); + } + }else { + mouseUngrabTimer = System.currentTimeMillis(); + if(mouseUngrabTimeout != 0) Window.clearTimeout(mouseUngrabTimeout); + mouseUngrabTimeout = 0; + doc.exitPointerLock(); + } + } + public static final int mouseGetDX() { + double dx = mouseDX; + mouseDX = 0.0D; + return (int)dx; + } + public static final int mouseGetDY() { + double dy = mouseDY; + mouseDY = 0.0D; + return (int)dy; + } + public static final int mouseGetX() { + return mouseX; + } + public static final int mouseGetY() { + return mouseY; + } + public static final int mouseGetEventX() { + return currentEvent == null ? -1 : (int)(currentEvent.getClientX() * win.getDevicePixelRatio()); + } + public static final int mouseGetEventY() { + return currentEvent == null ? -1 : (int)((canvas.getClientHeight() - currentEvent.getClientY()) * win.getDevicePixelRatio()); + } + public static final boolean keysNext() { + if(unpressCTRL) { //un-press ctrl after copy/paste permission + keyEvents.clear(); + currentEventK = null; + keyStates[29] = false; + keyStates[157] = false; + keyStates[28] = false; + keyStates[219] = false; + keyStates[220] = false; + unpressCTRL = false; + return false; + } + currentEventK = null; + return !keyEvents.isEmpty() && (currentEventK = keyEvents.remove(0)) != null; + } + public static final int getEventKey() { + return currentEventK == null ? -1 : remapKey(getWhich(currentEventK)); + } + public static final char getEventChar() { + if(currentEventK == null) return '\0'; + String s = currentEventK.getKey(); + return currentEventK == null ? ' ' : (char) (s.length() > 1 ? '\0' : s.charAt(0)); + } + public static final boolean getEventKeyState() { + return currentEventK == null? false : !currentEventK.getType().equals("keyup"); + } + public static final boolean isKeyDown(int p1) { + if(unpressCTRL) { //un-press ctrl after copy/paste permission + keyStates[28] = false; + keyStates[29] = false; + keyStates[157] = false; + keyStates[219] = false; + keyStates[220] = false; + } + return keyStates[p1]; + } + public static final String getKeyName(int p1) { + return (p1 >= 0 && p1 < 256) ? LWJGLKeyNames[p1] : "null"; + } + public static final void setFullscreen(boolean p1) { + Window.alert("use F11 to enter fullscreen"); + } + public static final boolean shouldShutdown() { + return false; + } + public static final void updateDisplay() { + double r = win.getDevicePixelRatio(); + int w = parent.getClientWidth(); + int h = parent.getClientHeight(); + int w2 = (int)(w * r); + int h2 = (int)(h * r); + if(canvas.getWidth() != w2) { + canvas.setWidth(w2); + } + if(canvas.getHeight() != h2) { + canvas.setHeight(h2); + } + webgl.bindFramebuffer(FRAMEBUFFER, null); + webgl.bindFramebuffer(READ_FRAMEBUFFER, backBuffer.obj); + webgl.bindFramebuffer(DRAW_FRAMEBUFFER, null); + webgl.blitFramebuffer(0, 0, backBufferWidth, backBufferHeight, 0, 0, w2, h2, COLOR_BUFFER_BIT, NEAREST); + webgl.bindFramebuffer(FRAMEBUFFER, backBuffer.obj); + resizeBackBuffer(w2, h2); + try { + Thread.sleep(1l); + } catch (InterruptedException e) { + ; + } + } + public static final void setupBackBuffer() { + backBuffer = _wglCreateFramebuffer(); + _wglBindFramebuffer(_wGL_FRAMEBUFFER, null); + backBufferColor = _wglCreateRenderBuffer(); + _wglBindRenderbuffer(backBufferColor); + _wglFramebufferRenderbuffer(_wGL_COLOR_ATTACHMENT0, backBufferColor); + backBufferDepth = _wglCreateRenderBuffer(); + _wglBindRenderbuffer(backBufferDepth); + _wglFramebufferRenderbuffer(_wGL_DEPTH_ATTACHMENT, backBufferDepth); + } + private static int backBufferWidth = -1; + private static int backBufferHeight = -1; + public static final void resizeBackBuffer(int w, int h) { + if(w != backBufferWidth || h != backBufferHeight) { + _wglBindRenderbuffer(backBufferColor); + _wglRenderbufferStorage(_wGL_RGBA8, w, h); + _wglBindRenderbuffer(backBufferDepth); + _wglRenderbufferStorage(_wGL_DEPTH_COMPONENT32F, w, h); + backBufferWidth = w; + backBufferHeight = h; + } + } + public static final float getContentScaling() { + return (float)win.getDevicePixelRatio(); + } + public static final void setVSyncEnabled(boolean p1) { + + } + public static final void enableRepeatEvents(boolean b) { + enableRepeatEvents = b; + } + + @JSBody(params = { }, script = "return document.pointerLockElement != null;") + public static native boolean isPointerLocked(); + + private static boolean pointerLockFlag = false; + + public static final boolean isFocused() { + if(lostFocus) { + lostFocus = false; + return false; + } + + boolean yee = isPointerLocked(); + boolean dee = pointerLockFlag; + pointerLockFlag = yee; + if(!dee && yee) { + mouseDX = 0.0D; + mouseDY = 0.0D; + } + return isWindowFocused && !(dee && !yee); + } + public static final int getScreenWidth() { + return win.getScreen().getAvailWidth(); + } + public static final int getScreenHeight() { + return win.getScreen().getAvailHeight(); + } + public static final int getCanvasWidth() { + return canvas.getWidth(); + } + public static final int getCanvasHeight() { + return canvas.getHeight(); + } + public static final void setDisplaySize(int x, int y) { + + } + public static final void syncDisplay(int performanceToFps) { + + } + + private static final DateFormat dateFormatSS = new SimpleDateFormat("yyyy-MM-dd_HH.mm.ss"); + public static final String saveScreenshot() { + webgl.finish(); + HTMLCanvasElement retardedCanvas = (HTMLCanvasElement)doc.createElement("canvas"); + retardedCanvas.setWidth(canvas.getWidth()); + retardedCanvas.setHeight(canvas.getHeight()); + CanvasRenderingContext2D cc = (CanvasRenderingContext2D)retardedCanvas.getContext("2d"); + setImageSmoothingMode(cc, false); + cc.setFillStyle("black"); + cc.fillRect(0, 0, canvas.getWidth(), canvas.getHeight()); + cc.drawImage(canvas, 0, 0, canvas.getWidth(), canvas.getHeight()); + String s = "screenshot_" + dateFormatSS.format(new Date()).toString() + ".png"; + saveScreenshot(s, retardedCanvas); + return s; + } + + @JSBody(params = { "name", "cvs" }, script = "var a=document.createElement(\"a\");a.href=cvs.toDataURL(\"image/png\");a.download=name;a.click();") + private static native void saveScreenshot(String name, HTMLCanvasElement cvs); + + public static enum RateLimit { + NONE, FAILED, BLOCKED, FAILED_POSSIBLY_LOCKED, LOCKED, NOW_LOCKED; + } + + private static final Set rateLimitedAddresses = new HashSet(); + private static final Set blockedAddresses = new HashSet(); + + private static WebSocket sock = null; + private static boolean sockIsConnecting = false; + private static boolean sockIsConnected = false; + private static boolean sockIsAlive = false; + private static LinkedList readPackets = new LinkedList(); + private static RateLimit rateLimitStatus = null; + private static String currentSockURI = null; + + public static final RateLimit getRateLimitStatus() { + RateLimit l = rateLimitStatus; + rateLimitStatus = null; + return l; + } + public static final void logRateLimit(String addr, RateLimit l) { + if(l == RateLimit.BLOCKED) { + blockedAddresses.add(addr); + }else { + rateLimitedAddresses.add(addr); + } + } + public static final RateLimit checkRateLimitHistory(String addr) { + if(blockedAddresses.contains(addr)) { + return RateLimit.LOCKED; + }else if(rateLimitedAddresses.contains(addr)) { + return RateLimit.BLOCKED; + }else { + return RateLimit.NONE; + } + } + + @Async + public static native String connectWebSocket(String sockURI); + + private static void connectWebSocket(String sockURI, final AsyncCallback cb) { + sockIsConnecting = true; + sockIsConnected = false; + sockIsAlive = false; + rateLimitStatus = null; + currentSockURI = sockURI; + try { + sock = WebSocket.create(sockURI); + } catch(Throwable t) { + sockIsConnecting = false; + sockIsAlive = false; + return; + } + sock.setBinaryType("arraybuffer"); + sock.onOpen(new EventListener() { + @Override + public void handleEvent(Event evt) { + sockIsConnecting = false; + sockIsAlive = false; + sockIsConnected = true; + readPackets.clear(); + cb.complete("okay"); + } + }); + sock.onClose(new EventListener() { + @Override + public void handleEvent(CloseEvent evt) { + sock = null; + if(sockIsConnecting) { + if(rateLimitStatus == null) { + if(blockedAddresses.contains(currentSockURI)) { + rateLimitStatus = RateLimit.LOCKED; + }else if(rateLimitedAddresses.contains(currentSockURI)) { + rateLimitStatus = RateLimit.FAILED_POSSIBLY_LOCKED; + }else { + rateLimitStatus = RateLimit.FAILED; + } + } + }else if(!sockIsAlive) { + if(rateLimitStatus == null) { + if(blockedAddresses.contains(currentSockURI)) { + rateLimitStatus = RateLimit.LOCKED; + }else if(rateLimitedAddresses.contains(currentSockURI)) { + rateLimitStatus = RateLimit.BLOCKED; + } + } + } + boolean b = sockIsConnecting; + sockIsConnecting = false; + sockIsConnected = false; + sockIsAlive = false; + if(b) cb.complete("fail"); + } + }); + sock.onMessage(new EventListener() { + @Override + public void handleEvent(MessageEvent evt) { + sockIsAlive = true; + if(isString(evt.getData())) { + String stat = evt.getDataAsString(); + if(stat.equalsIgnoreCase("BLOCKED")) { + if(rateLimitStatus == null) { + rateLimitStatus = RateLimit.BLOCKED; + } + rateLimitedAddresses.add(currentSockURI); + }else if(stat.equalsIgnoreCase("LOCKED")) { + if(rateLimitStatus == null) { + rateLimitStatus = RateLimit.NOW_LOCKED; + } + rateLimitedAddresses.add(currentSockURI); + blockedAddresses.add(currentSockURI); + } + sockIsConnecting = false; + sockIsConnected = false; + sock.close(); + return; + } + Uint8Array a = Uint8Array.create(evt.getDataAsArray()); + byte[] b = new byte[a.getByteLength()]; + for(int i = 0; i < b.length; ++i) { + b[i] = (byte) (a.get(i) & 0xFF); + } + readPackets.add(b); + } + }); + } + + public static final boolean startConnection(String uri) { + String res = connectWebSocket(uri); + return !"fail".equals(res); + } + public static final void endConnection() { + if(sock == null || sock.getReadyState() == 3) { + sockIsConnecting = false; + } + if(sock != null && !sockIsConnecting) sock.close(); + } + public static final boolean connectionOpen() { + if(sock == null || sock.getReadyState() == 3) { + sockIsConnecting = false; + } + return sock != null && !sockIsConnecting && sock.getReadyState() != 3; + } + @JSBody(params = { "sock", "buffer" }, script = "sock.send(buffer);") + private static native void nativeBinarySend(WebSocket sock, ArrayBuffer buffer); + public static final void writePacket(byte[] packet) { + if(sock != null && !sockIsConnecting) { + Uint8Array arr = Uint8Array.create(packet.length); + arr.set(packet); + nativeBinarySend(sock, arr.getBuffer()); + } + } + public static final byte[] readPacket() { + if(!readPackets.isEmpty()) { + return readPackets.remove(0); + }else { + return null; + } + } + public static final byte[] loadLocalStorage(String key) { + try { + Storage strg = win.getLocalStorage(); + if(strg != null) { + String s = strg.getItem("_eaglercraft_beta."+key); + if(s != null) { + return Base64.decodeBase64(s); + }else { + return null; + } + }else { + return null; + } + }catch(Throwable t) { + return null; + } + } + public static final void saveLocalStorage(String key, byte[] data) { + try { + Storage strg = win.getLocalStorage(); + if(strg != null) { + strg.setItem("_eaglercraft_beta."+key, Base64.encodeBase64String(data)); + } + }catch(Throwable t) { + } + } + + public static final long maxMemory() { + return 1024*1024*1024; + } + public static final long totalMemory() { + return 1024*1024*1024; + } + public static final long freeMemory() { + return 0l; + } + public static final void exit() { + + } + + @JSBody(params = { }, script = "return window.navigator.userAgent;") + public static native String getUserAgent(); + + private static String[] LWJGLKeyNames = new String[] {"NONE", "ESCAPE", "1", "2", "3", "4", "5", "6", "7", "8", "9", "0", "MINUS", "EQUALS", "BACK", "TAB", "Q", "W", "E", "R", "T", "Y", "U", "I", "O", "P", "LBRACKET", "RBRACKET", "RETURN", "LCONTROL", "A", "S", "D", "F", "G", "H", "J", "K", "L", "SEMICOLON", "APOSTROPHE", "GRAVE", "LSHIFT", "BACKSLASH", "Z", "X", "C", "V", "B", "N", "M", "COMMA", "PERIOD", "SLASH", "RSHIFT", "MULTIPLY", "LMENU", "SPACE", "CAPITAL", "F1", "F2", "F3", "F4", "F5", "F6", "F7", "F8", "F9", "F10", "NUMLOCK", "SCROLL", "NUMPAD7", "NUMPAD8", "NUMPAD9", "SUBTRACT", "NUMPAD4", "NUMPAD5", "NUMPAD6", "ADD", "NUMPAD1", "NUMPAD2", "NUMPAD3", "NUMPAD0", "DECIMAL", "null", "null", "null", "F11", "F12", "null", "null", "null", "null", "null", "null", "null", "null", "null", "null", "null", "F13", "F14", "F15", "F16", "F17", "F18", "null", "null", "null", "null", "null", "null", "KANA", "F19", "null", "null", "null", "null", "null", "null", "null", "CONVERT", "null", "NOCONVERT", "null", "YEN", "null", "null", "null", "null", "null", "null", "null", "null", "null", "null", "null", "null", "null", "null", "null", "NUMPADEQUALS", "null", "null", "CIRCUMFLEX", "AT", "COLON", "UNDERLINE", "KANJI", "STOP", "AX", "UNLABELED", "null", "null", "null", "null", "NUMPADENTER", "RCONTROL", "null", "null", "null", "null", "null", "null", "null", "null", "null", "SECTION", "null", "null", "null", "null", "null", "null", "null", "null", "null", "null", "null", "NUMPADCOMMA", "null", "DIVIDE", "null", "SYSRQ", "RMENU", "null", "null", "null", "null", "null", "null", "null", "null", "null", "null", "null", "FUNCTION", "PAUSE", "null", "HOME", "UP", "PRIOR", "null", "LEFT", "null", "RIGHT", "null", "END", "DOWN", "NEXT", "INSERT", "DELETE", "null", "null", "null", "null", "null", "null", "CLEAR", "LMETA", "RMETA", "APPS", "POWER", "SLEEP", "null", "null", "null", "null", "null", "null", "null", "null", "null", "null", "null", "null", "null", "null", "null", "null", "null", "null", "null", "null", "null", "null", "null", "null", "null", "null", "null", "null", "null", "null", "null", "null"}; + + private static int[] LWJGLKeyCodes = new int[] { + /* 0 */ -1, /* 1 */ -1, /* 2 */ -1, /* 3 */ -1, /* 4 */ -1, + /* 5 */ -1, /* 6 */ -1, /* 7 */ -1, /* 8 */ 14, /* 9 */ 15, + /* 10 */ -1, /* 11 */ -1, /* 12 */ -1, /* 13 */ 28, /* 14 */ -1, + /* 15 */ -1, /* 16 */ 42, /* 17 */ 29, /* 18 */ 56, /* 19 */ -1, + /* 20 */ -1, /* 21 */ -1, /* 22 */ -1, /* 23 */ -1, /* 24 */ -1, + /* 25 */ -1, /* 26 */ -1, /* 27 */ 1, /* 28 */ -1, /* 29 */ -1, + /* 30 */ -1, /* 31 */ -1, /* 32 */ 57, /* 33 */ 210, /* 34 */ 201, + /* 35 */ 207, /* 36 */ 199, /* 37 */ 203, /* 38 */ 200, /* 39 */ 205, + /* 40 */ 208, /* 41 */ 205, /* 42 */ 208, /* 43 */ -1, /* 44 */ -1, + /* 45 */ 210, /* 46 */ 211, /* 47 */ 211, /* 48 */ 11, /* 49 */ 2, + /* 50 */ 3, /* 51 */ 4, /* 52 */ 5, /* 53 */ 6, /* 54 */ 7, + /* 55 */ 8, /* 56 */ 9, /* 57 */ 10, /* 58 */ -1, /* 59 */ -1, + /* 60 */ -1, /* 61 */ -1, /* 62 */ -1, /* 63 */ -1, /* 64 */ -1, + /* 65 */ 30, /* 66 */ 48, /* 67 */ 46, /* 68 */ 32, /* 69 */ 18, + /* 70 */ 33, /* 71 */ 34, /* 72 */ 35, /* 73 */ 23, /* 74 */ 36, + /* 75 */ 37, /* 76 */ 38, /* 77 */ 50, /* 78 */ 49, /* 79 */ 24, + /* 80 */ 25, /* 81 */ 16, /* 82 */ 19, /* 83 */ 31, /* 84 */ 20, + /* 85 */ 22, /* 86 */ 47, /* 87 */ 17, /* 88 */ 45, /* 89 */ 21, + /* 90 */ 44, /* 91 */ -1, /* 92 */ -1, /* 93 */ -1, /* 94 */ -1, + /* 95 */ -1, /* 96 */ -1, /* 97 */ -1, /* 98 */ -1, /* 99 */ -1, + /* 100 */ -1, /* 101 */ -1, /* 102 */ -1, /* 103 */ -1, /* 104 */ -1, + /* 105 */ -1, /* 106 */ -1, /* 107 */ -1, /* 108 */ -1, /* 109 */ 12, + /* 110 */ 52, /* 111 */ 53, /* 112 */ -1, /* 113 */ -1, /* 114 */ -1, + /* 115 */ -1, /* 116 */ -1, /* 117 */ -1, /* 118 */ -1, /* 119 */ -1, + /* 120 */ -1, /* 121 */ -1, /* 122 */ -1, /* 123 */ -1, /* 124 */ -1, + /* 125 */ -1, /* 126 */ -1, /* 127 */ -1, /* 128 */ -1, /* 129 */ -1, + /* 130 */ -1, /* 131 */ -1, /* 132 */ -1, /* 133 */ -1, /* 134 */ -1, + /* 135 */ -1, /* 136 */ -1, /* 137 */ -1, /* 138 */ -1, /* 139 */ -1, + /* 140 */ -1, /* 141 */ -1, /* 142 */ -1, /* 143 */ -1, /* 144 */ -1, + /* 145 */ -1, /* 146 */ -1, /* 147 */ -1, /* 148 */ -1, /* 149 */ -1, + /* 150 */ -1, /* 151 */ -1, /* 152 */ -1, /* 153 */ -1, /* 154 */ -1, + /* 155 */ -1, /* 156 */ -1, /* 157 */ -1, /* 158 */ -1, /* 159 */ -1, + /* 160 */ -1, /* 161 */ -1, /* 162 */ -1, /* 163 */ -1, /* 164 */ -1, + /* 165 */ -1, /* 166 */ -1, /* 167 */ -1, /* 168 */ -1, /* 169 */ -1, + /* 170 */ -1, /* 171 */ -1, /* 172 */ -1, /* 173 */ -1, /* 174 */ -1, + /* 175 */ -1, /* 176 */ -1, /* 177 */ -1, /* 178 */ -1, /* 179 */ -1, + /* 180 */ -1, /* 181 */ -1, /* 182 */ -1, /* 183 */ -1, /* 184 */ -1, + /* 185 */ -1, /* 186 */ 39, /* 187 */ 13, /* 188 */ 51, /* 189 */ 12, + /* 190 */ 52, /* 191 */ 53, /* 192 */ -1, /* 193 */ -1, /* 194 */ -1, + /* 195 */ -1, /* 196 */ -1, /* 197 */ -1, /* 198 */ -1, /* 199 */ -1, + /* 200 */ -1, /* 201 */ -1, /* 202 */ -1, /* 203 */ -1, /* 204 */ -1, + /* 205 */ -1, /* 206 */ -1, /* 207 */ -1, /* 208 */ -1, /* 209 */ -1, + /* 210 */ -1, /* 211 */ -1, /* 212 */ -1, /* 213 */ -1, /* 214 */ -1, + /* 215 */ -1, /* 216 */ -1, /* 217 */ -1, /* 218 */ -1, /* 219 */ 26, + /* 220 */ 43, /* 221 */ 27, /* 222 */ 40 + }; + + public static final int _wArrayByteLength(Object obj) { + return ((Int32Array)obj).getByteLength(); + } + + public static final Object _wCreateLowLevelIntBuffer(int len) { + return Int32Array.create(len); + } + + private static int appendbufferindex = 0; + private static Int32Array appendbuffer = Int32Array.create(ArrayBuffer.create(525000*4)); + + public static final void _wAppendLowLevelBuffer(Object arr) { + Int32Array a = ((Int32Array)arr); + if(appendbufferindex + a.getLength() < appendbuffer.getLength()) { + appendbuffer.set(a, appendbufferindex); + appendbufferindex += a.getLength(); + } + } + + public static final Object _wGetLowLevelBuffersAppended() { + Int32Array ret = Int32Array.create(appendbuffer.getBuffer(), 0, appendbufferindex); + appendbufferindex = 0; + return ret; + } + + private static int remapKey(int k) { + return (k > LWJGLKeyCodes.length || k < 0) ? -1 : LWJGLKeyCodes[k]; + } + + @JSFunctor + private static interface StupidFunctionResolveString extends JSObject { + void resolveStr(String s); + } + + private static boolean unpressCTRL = false; + + @Async + public static native String getClipboard(); + + private static void getClipboard(final AsyncCallback cb) { + final long start = System.currentTimeMillis(); + getClipboard0(new StupidFunctionResolveString() { + @Override + public void resolveStr(String s) { + if(System.currentTimeMillis() - start > 500l) { + unpressCTRL = true; + } + cb.complete(s); + } + }); + } + + @JSBody(params = { "cb" }, script = "if(!window.navigator.clipboard) cb(null); else window.navigator.clipboard.readText().then(function(s) { cb(s); }, function(s) { cb(null); });") + private static native void getClipboard0(StupidFunctionResolveString cb); + + @JSBody(params = { "str" }, script = "if(window.navigator.clipboard) window.navigator.clipboard.writeText(str);") + public static native void setClipboard(String str); + + @JSBody(params = { "obj" }, script = "return typeof obj === \"string\";") + private static native boolean isString(JSObject obj); + + private static boolean endianWasChecked = false; + private static boolean isBigEndian = false; + private static boolean isLittleEndian = false; + + public static final boolean isBigEndian() { + if(!endianWasChecked) { + int checkIntegerA = 0xFF000000; + int checkIntegerB = 0x000000FF; + + ArrayBuffer buf = ArrayBuffer.create(4); + Int32Array bufW = Int32Array.create(buf); + Uint8Array bufR = Uint8Array.create(buf); + + bufW.set(0, checkIntegerA); + + boolean knownBig1 = false; + if(bufR.get(0) == (short)0xFF && bufR.get(1) == (short)0 && bufR.get(2) == (short)0 && bufR.get(3) == (short)0) { + knownBig1 = true; + } + + boolean knownLittle1 = false; + if(bufR.get(0) == (short)0 && bufR.get(1) == (short)0 && bufR.get(2) == (short)0 && bufR.get(3) == (short)0xFF) { + knownLittle1 = true; + } + + bufW.set(0, checkIntegerB); + + boolean knownBig2 = false; + if(bufR.get(0) == (short)0 && bufR.get(1) == (short)0 && bufR.get(2) == (short)0 && bufR.get(3) == (short)0xFF) { + knownBig2 = true; + } + + boolean knownLittle2 = false; + if(bufR.get(0) == (short)0xFF && bufR.get(1) == (short)0 && bufR.get(2) == (short)0 && bufR.get(3) == (short)0) { + knownLittle2 = true; + } + + if(knownBig1 == knownBig2 && knownLittle1 == knownLittle2 && knownBig1 != knownLittle1) { + isBigEndian = knownBig1; + isLittleEndian = knownLittle1; + } + + if(isBigEndian) { + System.out.println("This browser is BIG endian!"); + }else if(isLittleEndian) { + System.out.println("This browser is LITTLE endian!"); + }else { + System.out.println("The byte order of this browser is inconsistent!"); + System.out.println(" - the sequence FF000000 was " + (knownBig1 ? "" : "not ") + "big endian."); + System.out.println(" - the sequence FF000000 was " + (knownLittle1 ? "" : "not ") + "little endian."); + System.out.println(" - the sequence 000000FF was " + (knownBig2 ? "" : "not ") + "big endian."); + System.out.println(" - the sequence 000000FF was " + (knownLittle2 ? "" : "not ") + "little endian."); + } + + endianWasChecked = true; + } + return !isLittleEndian; + } + + private static final ArrayBuffer convertToArrayBuffer(byte[] arr) { + Uint8Array buf = Uint8Array.create(arr.length); + buf.set(arr); + return buf.getBuffer(); + } + + private static boolean lostFocus = false; + + public static final void removeEventHandlers() { + try { + win.removeEventListener("contextmenu", contextmenu); + canvas.removeEventListener("mousedown", mousedown); + canvas.removeEventListener("mouseup", mouseup); + canvas.removeEventListener("mousemove", mousemove); + win.removeEventListener("keydown", keydown); + win.removeEventListener("keyup", keyup); + win.removeEventListener("keypress", keypress); + canvas.removeEventListener("wheel", wheel); + }catch(Throwable t) { + } + try { + String screenImg = canvas.toDataURL("image/png"); + canvas.delete(); + HTMLImageElement newImage = (HTMLImageElement) doc.createElement("img"); + newImage.setSrc(screenImg); + newImage.setWidth(parent.getClientWidth()); + newImage.setHeight(parent.getClientHeight()); + parent.appendChild(newImage); + }catch(Throwable t) { + } + } + } + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + private static class GLObjectMap { + private Object[] values; + private int size; + private int insertIndex; + public int allocatedObjects; + + public GLObjectMap(int initialSize) { + this.values = new Object[initialSize]; + this.size = initialSize; + this.insertIndex = 0; + this.allocatedObjects = 0; + } + + public int register(T obj) { + int start = insertIndex; + do { + ++insertIndex; + if(insertIndex >= size) { + insertIndex = 0; + } + if(insertIndex == start) { + resize(); + return register(obj); + } + }while(values[insertIndex] != null); + values[insertIndex] = obj; + ++allocatedObjects; + return insertIndex; + } + + @SuppressWarnings("unchecked") + public T free(int obj) { + if(obj >= size || obj < 0) return null; + Object ret = values[obj]; + values[obj] = null; + --allocatedObjects; + return (T) ret; + } + + @SuppressWarnings("unchecked") + public T get(int obj) { + if(obj >= size || obj < 0) return null; + return (T) values[obj]; + } + + private void resize() { + int oldSize = size; + size += size / 2; + Object[] oldValues = values; + values = new Object[size]; + System.arraycopy(oldValues, 0, values, 0, oldSize); + } + } + + public static interface WebGL2RenderingContext extends WebGLRenderingContext { + int TEXTURE_MAX_LEVEL = 0x0000813D; + int TEXTURE_MAX_ANISOTROPY_EXT = 0x000084FE; + int UNSIGNED_INT_24_8 = 0x000084FA; + int ANY_SAMPLES_PASSED = 0x00008D6A; + int QUERY_RESULT = 0x00008866; + int QUERY_RESULT_AVAILABLE = 0x00008867; + int DEPTH24_STENCIL8 = 0x000088F0; + int DEPTH_COMPONENT32F = 0x00008CAC; + int READ_FRAMEBUFFER = 0x00008CA8; + int DRAW_FRAMEBUFFER = 0x00008CA9; + int RGB8 = 0x00008051; + int RGBA8 = 0x00008058; + int R8 = 0x00008229; + int RED = 0x00001903; + + WebGLQuery createQuery(); + + void beginQuery(int p1, WebGLQuery obj); + + void endQuery(int p1); + + void deleteQuery(WebGLQuery obj); + + int getQueryParameter(WebGLQuery obj, int p2); + + WebGLVertexArray createVertexArray(); + + void deleteVertexArray(WebGLVertexArray obj); + + void bindVertexArray(WebGLVertexArray obj); + + void renderbufferStorageMultisample(int p1, int p2, int p3, int p4, int p5); + + void blitFramebuffer(int p1, int p2, int p3, int p4, int p5, int p6, int p7, int p8, int p9, int p10); + + void drawBuffers(int[] p1); + + void readBuffer(int p1); + + } + + private static interface WebGLQuery extends JSObject { + } + + private static interface WebGLVertexArray extends JSObject { + } + + public static class AssetRepository { + + private static final HashMap filePool = new HashMap(); + + public static final void install(byte[] pkg) throws IOException { + ByteArrayInputStream in2 = new ByteArrayInputStream(pkg); + DataInputStream in = new DataInputStream(in2); + byte[] header = new byte[8]; + in.read(header); + if (!"EAGPKG!!".equals(new String(header, Charset.forName("UTF-8")))) + throw new IOException("invalid epk file"); + in.readUTF(); + in = new DataInputStream(new InflaterInputStream(in2)); + String s = null; + SHA1Digest dg = new SHA1Digest(); + while ("".equals(s = in.readUTF())) { + String path = in.readUTF(); + byte[] digest = new byte[20]; + byte[] digest2 = new byte[20]; + in.read(digest); + int len = in.readInt(); + byte[] file = new byte[len]; + in.read(file); + if (filePool.containsKey(path)) + continue; + dg.update(file, 0, len); + dg.doFinal(digest2, 0); + if (!Arrays.equals(digest, digest2)) + throw new IOException("invalid file hash for " + path); + filePool.put(path, file); + if (!"".equals(in.readUTF())) + throw new IOException("invalid epk file"); + } + if (in.available() > 0 || !" end".equals(s)) + throw new IOException("invalid epk file"); + } + + public static final byte[] getResource(String path) { + if (path.startsWith("/")) + path = path.substring(1); + return filePool.get(path); + } + } + + @SuppressWarnings("unused") + private static class SHA1Digest extends GeneralDigest { + private static final int DIGEST_LENGTH = 20; + + private int H1, H2, H3, H4, H5; + + private int[] X = new int[80]; + private int xOff; + + public SHA1Digest() { + reset(); + } + + public SHA1Digest(SHA1Digest t) { + super(t); + + H1 = t.H1; + H2 = t.H2; + H3 = t.H3; + H4 = t.H4; + H5 = t.H5; + + System.arraycopy(t.X, 0, X, 0, t.X.length); + xOff = t.xOff; + } + + public String getAlgorithmName() { + return "SHA-1"; + } + + public int getDigestSize() { + return DIGEST_LENGTH; + } + + protected void processWord( + byte[] in, + int inOff) { + X[xOff++] = ((in [inOff] & 0xff) << 24) | ((in [inOff + 1] & 0xff) << 16) | + ((in [inOff + 2] & 0xff) << 8) | ((in [inOff + 3] & 0xff)); + + if (xOff == 16) { + processBlock(); + } + } + + private void unpackWord( + int word, + byte[] out, + int outOff) { + out[outOff] = (byte)(word >>> 24); + out[outOff + 1] = (byte)(word >>> 16); + out[outOff + 2] = (byte)(word >>> 8); + out[outOff + 3] = (byte) word; + } + + protected void processLength( + long bitLength) { + if (xOff > 14) { + processBlock(); + } + + X[14] = (int)(bitLength >>> 32); + X[15] = (int)(bitLength & 0xffffffff); + } + + public int doFinal( + byte[] out, + int outOff) { + finish(); + + unpackWord(H1, out, outOff); + unpackWord(H2, out, outOff + 4); + unpackWord(H3, out, outOff + 8); + unpackWord(H4, out, outOff + 12); + unpackWord(H5, out, outOff + 16); + + reset(); + + return DIGEST_LENGTH; + } + + public void reset() { + super.reset(); + + H1 = 0x67452301; + H2 = 0xefcdab89; + H3 = 0x98badcfe; + H4 = 0x10325476; + H5 = 0xc3d2e1f0; + + xOff = 0; + for (int i = 0; i != X.length; i++) { + X[i] = 0; + } + } + + private static final int Y1 = 0x5a827999; + private static final int Y2 = 0x6ed9eba1; + private static final int Y3 = 0x8f1bbcdc; + private static final int Y4 = 0xca62c1d6; + + private int f( + int u, + int v, + int w) { + return ((u & v) | ((~u) & w)); + } + + private int h( + int u, + int v, + int w) { + return (u ^ v ^ w); + } + + private int g( + int u, + int v, + int w) { + return ((u & v) | (u & w) | (v & w)); + } + + private int rotateLeft( + int x, + int n) { + return (x << n) | (x >>> (32 - n)); + } + + protected void processBlock() { + for (int i = 16; i <= 79; i++) { + X[i] = rotateLeft((X[i - 3] ^ X[i - 8] ^ X[i - 14] ^ X[i - 16]), 1); + } + + int A = H1; + int B = H2; + int C = H3; + int D = H4; + int E = H5; + + for (int j = 0; j <= 19; j++) { + int t = rotateLeft(A, 5) + f(B, C, D) + E + X[j] + Y1; + + E = D; + D = C; + C = rotateLeft(B, 30); + B = A; + A = t; + } + + for (int j = 20; j <= 39; j++) { + int t = rotateLeft(A, 5) + h(B, C, D) + E + X[j] + Y2; + + E = D; + D = C; + C = rotateLeft(B, 30); + B = A; + A = t; + } + + for (int j = 40; j <= 59; j++) { + int t = rotateLeft(A, 5) + g(B, C, D) + E + X[j] + Y3; + + E = D; + D = C; + C = rotateLeft(B, 30); + B = A; + A = t; + } + + for (int j = 60; j <= 79; j++) { + int t = rotateLeft(A, 5) + h(B, C, D) + E + X[j] + Y4; + + E = D; + D = C; + C = rotateLeft(B, 30); + B = A; + A = t; + } + + H1 += A; + H2 += B; + H3 += C; + H4 += D; + H5 += E; + + xOff = 0; + for (int i = 0; i != X.length; i++) { + X[i] = 0; + } + } + } + + private static abstract class GeneralDigest { + private byte[] xBuf; + private int xBufOff; + + private long byteCount; + + protected GeneralDigest() { + xBuf = new byte[4]; + xBufOff = 0; + } + + protected GeneralDigest(GeneralDigest t) { + xBuf = new byte[t.xBuf.length]; + System.arraycopy(t.xBuf, 0, xBuf, 0, t.xBuf.length); + + xBufOff = t.xBufOff; + byteCount = t.byteCount; + } + + public void update( + byte in ) { + xBuf[xBufOff++] = in; + + if (xBufOff == xBuf.length) { + processWord(xBuf, 0); + xBufOff = 0; + } + + byteCount++; + } + + public void update( + byte[] in, + int inOff, + int len) { + + while ((xBufOff != 0) && (len > 0)) { + update(in [inOff]); + + inOff++; + len--; + } + + while (len > xBuf.length) { + processWord(in, inOff); + + inOff += xBuf.length; + len -= xBuf.length; + byteCount += xBuf.length; + } + + while (len > 0) { + update(in [inOff]); + + inOff++; + len--; + } + } + + public void finish() { + long bitLength = (byteCount << 3); + + update((byte) 128); + + while (xBufOff != 0) { + update((byte) 0); + } + + processLength(bitLength); + + processBlock(); + } + + public void reset() { + byteCount = 0; + + xBufOff = 0; + for (int i = 0; i < xBuf.length; i++) { + xBuf[i] = 0; + } + } + + protected abstract void processWord(byte[] in, int inOff); + + protected abstract void processLength(long bitLength); + + protected abstract void processBlock(); + } + + @SuppressWarnings("unused") + private static class Base64 extends BaseNCodec { + + /** + * BASE32 characters are 6 bits in length. + * They are formed by taking a block of 3 octets to form a 24-bit string, + * which is converted into 4 BASE64 characters. + */ + private static final int BITS_PER_ENCODED_BYTE = 6; + private static final int BYTES_PER_UNENCODED_BLOCK = 3; + private static final int BYTES_PER_ENCODED_BLOCK = 4; + + /** + * This array is a lookup table that translates 6-bit positive integer index values into their "Base64 Alphabet" + * equivalents as specified in Table 1 of RFC 2045. + * + * Thanks to "commons" project in ws.apache.org for this code. + * http://svn.apache.org/repos/asf/webservices/commons/trunk/modules/util/ + */ + private static final byte[] STANDARD_ENCODE_TABLE = { + 'A', 'B', 'C', 'D', 'E', 'F', 'G', 'H', 'I', 'J', 'K', 'L', 'M', + 'N', 'O', 'P', 'Q', 'R', 'S', 'T', 'U', 'V', 'W', 'X', 'Y', 'Z', + 'a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j', 'k', 'l', 'm', + 'n', 'o', 'p', 'q', 'r', 's', 't', 'u', 'v', 'w', 'x', 'y', 'z', + '0', '1', '2', '3', '4', '5', '6', '7', '8', '9', '+', '/' + }; + + /** + * This is a copy of the STANDARD_ENCODE_TABLE above, but with + and / + * changed to - and _ to make the encoded Base64 results more URL-SAFE. + * This table is only used when the Base64's mode is set to URL-SAFE. + */ + private static final byte[] URL_SAFE_ENCODE_TABLE = { + 'A', 'B', 'C', 'D', 'E', 'F', 'G', 'H', 'I', 'J', 'K', 'L', 'M', + 'N', 'O', 'P', 'Q', 'R', 'S', 'T', 'U', 'V', 'W', 'X', 'Y', 'Z', + 'a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j', 'k', 'l', 'm', + 'n', 'o', 'p', 'q', 'r', 's', 't', 'u', 'v', 'w', 'x', 'y', 'z', + '0', '1', '2', '3', '4', '5', '6', '7', '8', '9', '-', '_' + }; + + /** + * This array is a lookup table that translates Unicode characters drawn from the "Base64 Alphabet" (as specified + * in Table 1 of RFC 2045) into their 6-bit positive integer equivalents. Characters that are not in the Base64 + * alphabet but fall within the bounds of the array are translated to -1. + * + * Note: '+' and '-' both decode to 62. '/' and '_' both decode to 63. This means decoder seamlessly handles both + * URL_SAFE and STANDARD base64. (The encoder, on the other hand, needs to know ahead of time what to emit). + * + * Thanks to "commons" project in ws.apache.org for this code. + * http://svn.apache.org/repos/asf/webservices/commons/trunk/modules/util/ + */ + private static final byte[] DECODE_TABLE = { + // 0 1 2 3 4 5 6 7 8 9 A B C D E F + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, // 00-0f + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, // 10-1f + -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 62, -1, 62, -1, 63, // 20-2f + - / + 52, 53, 54, 55, 56, 57, 58, 59, 60, 61, -1, -1, -1, -1, -1, -1, // 30-3f 0-9 + -1, 0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, // 40-4f A-O + 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, -1, -1, -1, -1, 63, // 50-5f P-Z _ + -1, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, // 60-6f a-o + 41, 42, 43, 44, 45, 46, 47, 48, 49, 50, 51 // 70-7a p-z + }; + + /** + * Base64 uses 6-bit fields. + */ + /** Mask used to extract 6 bits, used when encoding */ + private static final int MASK_6BITS = 0x3f; + /** Mask used to extract 4 bits, used when decoding final trailing character. */ + private static final int MASK_4BITS = 0xf; + /** Mask used to extract 2 bits, used when decoding final trailing character. */ + private static final int MASK_2BITS = 0x3; + + // The static final fields above are used for the original static byte[] methods on Base64. + // The private member fields below are used with the new streaming approach, which requires + // some state be preserved between calls of encode() and decode(). + + /** + * Decodes Base64 data into octets. + *

+ * Note: this method seamlessly handles data encoded in URL-safe or normal mode. + *

+ * + * @param base64Data + * Byte array containing Base64 data + * @return Array containing decoded data. + */ + public static byte[] decodeBase64(final byte[] base64Data) { + return new Base64().decode(base64Data); + } + + /** + * Decodes a Base64 String into octets. + *

+ * Note: this method seamlessly handles data encoded in URL-safe or normal mode. + *

+ * + * @param base64String + * String containing Base64 data + * @return Array containing decoded data. + * @since 1.4 + */ + public static byte[] decodeBase64(final String base64String) { + return new Base64().decode(base64String); + } + + // Implementation of integer encoding used for crypto + /** + * Decodes a byte64-encoded integer according to crypto standards such as W3C's XML-Signature. + * + * @param pArray + * a byte array containing base64 character data + * @return A BigInteger + * @since 1.4 + */ + public static BigInteger decodeInteger(final byte[] pArray) { + return new BigInteger(1, decodeBase64(pArray)); + } + + /** + * Encodes binary data using the base64 algorithm but does not chunk the output. + * + * @param binaryData + * binary data to encode + * @return byte[] containing Base64 characters in their UTF-8 representation. + */ + public static byte[] encodeBase64(final byte[] binaryData) { + return encodeBase64(binaryData, false); + } + + /** + * Encodes binary data using the base64 algorithm, optionally chunking the output into 76 character blocks. + * + * @param binaryData + * Array containing binary data to encode. + * @param isChunked + * if {@code true} this encoder will chunk the base64 output into 76 character blocks + * @return Base64-encoded data. + * @throws IllegalArgumentException + * Thrown when the input array needs an output array bigger than {@link Integer#MAX_VALUE} + */ + public static byte[] encodeBase64(final byte[] binaryData, final boolean isChunked) { + return encodeBase64(binaryData, isChunked, false); + } + + /** + * Encodes binary data using the base64 algorithm, optionally chunking the output into 76 character blocks. + * + * @param binaryData + * Array containing binary data to encode. + * @param isChunked + * if {@code true} this encoder will chunk the base64 output into 76 character blocks + * @param urlSafe + * if {@code true} this encoder will emit - and _ instead of the usual + and / characters. + * Note: no padding is added when encoding using the URL-safe alphabet. + * @return Base64-encoded data. + * @throws IllegalArgumentException + * Thrown when the input array needs an output array bigger than {@link Integer#MAX_VALUE} + * @since 1.4 + */ + public static byte[] encodeBase64(final byte[] binaryData, final boolean isChunked, final boolean urlSafe) { + return encodeBase64(binaryData, isChunked, urlSafe, Integer.MAX_VALUE); + } + + /** + * Encodes binary data using the base64 algorithm, optionally chunking the output into 76 character blocks. + * + * @param binaryData + * Array containing binary data to encode. + * @param isChunked + * if {@code true} this encoder will chunk the base64 output into 76 character blocks + * @param urlSafe + * if {@code true} this encoder will emit - and _ instead of the usual + and / characters. + * Note: no padding is added when encoding using the URL-safe alphabet. + * @param maxResultSize + * The maximum result size to accept. + * @return Base64-encoded data. + * @throws IllegalArgumentException + * Thrown when the input array needs an output array bigger than maxResultSize + * @since 1.4 + */ + public static byte[] encodeBase64(final byte[] binaryData, final boolean isChunked, + final boolean urlSafe, final int maxResultSize) { + if (binaryData == null || binaryData.length == 0) { + return binaryData; + } + + // Create this so can use the super-class method + // Also ensures that the same roundings are performed by the ctor and the code + final Base64 b64 = isChunked ? new Base64(urlSafe) : new Base64(0, CHUNK_SEPARATOR, urlSafe); + final long len = b64.getEncodedLength(binaryData); + if (len > maxResultSize) { + throw new IllegalArgumentException("Input array too big, the output array would be bigger (" + + len + + ") than the specified maximum size of " + + maxResultSize); + } + + return b64.encode(binaryData); + } + + /** + * Encodes binary data using the base64 algorithm and chunks the encoded output into 76 character blocks + * + * @param binaryData + * binary data to encode + * @return Base64 characters chunked in 76 character blocks + */ + public static byte[] encodeBase64Chunked(final byte[] binaryData) { + return encodeBase64(binaryData, true); + } + + /** + * Encodes binary data using the base64 algorithm but does not chunk the output. + * + * NOTE: We changed the behavior of this method from multi-line chunking (commons-codec-1.4) to + * single-line non-chunking (commons-codec-1.5). + * + * @param binaryData + * binary data to encode + * @return String containing Base64 characters. + * @since 1.4 (NOTE: 1.4 chunked the output, whereas 1.5 does not). + */ + public static String encodeBase64String(final byte[] binaryData) { + return new String(encodeBase64(binaryData, false), Charset.forName("UTF-8")); + } + + /** + * Encodes binary data using a URL-safe variation of the base64 algorithm but does not chunk the output. The + * url-safe variation emits - and _ instead of + and / characters. + * Note: no padding is added. + * @param binaryData + * binary data to encode + * @return byte[] containing Base64 characters in their UTF-8 representation. + * @since 1.4 + */ + public static byte[] encodeBase64URLSafe(final byte[] binaryData) { + return encodeBase64(binaryData, false, true); + } + + /** + * Encodes binary data using a URL-safe variation of the base64 algorithm but does not chunk the output. The + * url-safe variation emits - and _ instead of + and / characters. + * Note: no padding is added. + * @param binaryData + * binary data to encode + * @return String containing Base64 characters + * @since 1.4 + */ + public static String encodeBase64URLSafeString(final byte[] binaryData) { + return new String(encodeBase64(binaryData, false, true), Charset.forName("UTF-8")); + } + + /** + * Encodes to a byte64-encoded integer according to crypto standards such as W3C's XML-Signature. + * + * @param bigInteger + * a BigInteger + * @return A byte array containing base64 character data + * @throws NullPointerException + * if null is passed in + * @since 1.4 + */ + public static byte[] encodeInteger(final BigInteger bigInteger) { + return encodeBase64(toIntegerBytes(bigInteger), false); + } + + /** + * Tests a given byte array to see if it contains only valid characters within the Base64 alphabet. Currently the + * method treats whitespace as valid. + * + * @param arrayOctet + * byte array to test + * @return {@code true} if all bytes are valid characters in the Base64 alphabet or if the byte array is empty; + * {@code false}, otherwise + * @deprecated 1.5 Use {@link #isBase64(byte[])}, will be removed in 2.0. + */ + @Deprecated + public static boolean isArrayByteBase64(final byte[] arrayOctet) { + return isBase64(arrayOctet); + } + + /** + * Returns whether or not the {@code octet} is in the base 64 alphabet. + * + * @param octet + * The value to test + * @return {@code true} if the value is defined in the the base 64 alphabet, {@code false} otherwise. + * @since 1.4 + */ + public static boolean isBase64(final byte octet) { + return octet == PAD_DEFAULT || (octet >= 0 && octet < DECODE_TABLE.length && DECODE_TABLE[octet] != -1); + } + + /** + * Tests a given byte array to see if it contains only valid characters within the Base64 alphabet. Currently the + * method treats whitespace as valid. + * + * @param arrayOctet + * byte array to test + * @return {@code true} if all bytes are valid characters in the Base64 alphabet or if the byte array is empty; + * {@code false}, otherwise + * @since 1.5 + */ + public static boolean isBase64(final byte[] arrayOctet) { + for (int i = 0; i < arrayOctet.length; i++) { + if (!isBase64(arrayOctet[i]) && !isWhiteSpace(arrayOctet[i])) { + return false; + } + } + return true; + } + + /** + * Tests a given String to see if it contains only valid characters within the Base64 alphabet. Currently the + * method treats whitespace as valid. + * + * @param base64 + * String to test + * @return {@code true} if all characters in the String are valid characters in the Base64 alphabet or if + * the String is empty; {@code false}, otherwise + * @since 1.5 + */ + public static boolean isBase64(final String base64) { + return isBase64(base64.getBytes(Charset.forName("UTF-8"))); + } + + /** + * Returns a byte-array representation of a {@code BigInteger} without sign bit. + * + * @param bigInt + * {@code BigInteger} to be converted + * @return a byte array representation of the BigInteger parameter + */ + static byte[] toIntegerBytes(final BigInteger bigInt) { + int bitlen = bigInt.bitLength(); + // round bitlen + bitlen = ((bitlen + 7) >> 3) << 3; + final byte[] bigBytes = bigInt.toByteArray(); + + if (((bigInt.bitLength() % 8) != 0) && (((bigInt.bitLength() / 8) + 1) == (bitlen / 8))) { + return bigBytes; + } + // set up params for copying everything but sign bit + int startSrc = 0; + int len = bigBytes.length; + + // if bigInt is exactly byte-aligned, just skip signbit in copy + if ((bigInt.bitLength() % 8) == 0) { + startSrc = 1; + len--; + } + final int startDst = bitlen / 8 - len; // to pad w/ nulls as per spec + final byte[] resizedBytes = new byte[bitlen / 8]; + System.arraycopy(bigBytes, startSrc, resizedBytes, startDst, len); + return resizedBytes; + } + + /** + * Encode table to use: either STANDARD or URL_SAFE. Note: the DECODE_TABLE above remains static because it is able + * to decode both STANDARD and URL_SAFE streams, but the encodeTable must be a member variable so we can switch + * between the two modes. + */ + private final byte[] encodeTable; + + // Only one decode table currently; keep for consistency with Base32 code + private final byte[] decodeTable = DECODE_TABLE; + + /** + * Line separator for encoding. Not used when decoding. Only used if lineLength > 0. + */ + private final byte[] lineSeparator; + + /** + * Convenience variable to help us determine when our buffer is going to run out of room and needs resizing. + * {@code decodeSize = 3 + lineSeparator.length;} + */ + private final int decodeSize; + + /** + * Convenience variable to help us determine when our buffer is going to run out of room and needs resizing. + * {@code encodeSize = 4 + lineSeparator.length;} + */ + private final int encodeSize; + + /** + * Creates a Base64 codec used for decoding (all modes) and encoding in URL-unsafe mode. + *

+ * When encoding the line length is 0 (no chunking), and the encoding table is STANDARD_ENCODE_TABLE. + *

+ * + *

+ * When decoding all variants are supported. + *

+ */ + public Base64() { + this(0); + } + + /** + * Creates a Base64 codec used for decoding (all modes) and encoding in the given URL-safe mode. + *

+ * When encoding the line length is 76, the line separator is CRLF, and the encoding table is STANDARD_ENCODE_TABLE. + *

+ * + *

+ * When decoding all variants are supported. + *

+ * + * @param urlSafe + * if {@code true}, URL-safe encoding is used. In most cases this should be set to + * {@code false}. + * @since 1.4 + */ + public Base64(final boolean urlSafe) { + this(MIME_CHUNK_SIZE, CHUNK_SEPARATOR, urlSafe); + } + + /** + * Creates a Base64 codec used for decoding (all modes) and encoding in URL-unsafe mode. + *

+ * When encoding the line length is given in the constructor, the line separator is CRLF, and the encoding table is + * STANDARD_ENCODE_TABLE. + *

+ *

+ * Line lengths that aren't multiples of 4 will still essentially end up being multiples of 4 in the encoded data. + *

+ *

+ * When decoding all variants are supported. + *

+ * + * @param lineLength + * Each line of encoded data will be at most of the given length (rounded down to nearest multiple of + * 4). If lineLength <= 0, then the output will not be divided into lines (chunks). Ignored when + * decoding. + * @since 1.4 + */ + public Base64(final int lineLength) { + this(lineLength, CHUNK_SEPARATOR); + } + + /** + * Creates a Base64 codec used for decoding (all modes) and encoding in URL-unsafe mode. + *

+ * When encoding the line length and line separator are given in the constructor, and the encoding table is + * STANDARD_ENCODE_TABLE. + *

+ *

+ * Line lengths that aren't multiples of 4 will still essentially end up being multiples of 4 in the encoded data. + *

+ *

+ * When decoding all variants are supported. + *

+ * + * @param lineLength + * Each line of encoded data will be at most of the given length (rounded down to nearest multiple of + * 4). If lineLength <= 0, then the output will not be divided into lines (chunks). Ignored when + * decoding. + * @param lineSeparator + * Each line of encoded data will end with this sequence of bytes. + * @throws IllegalArgumentException + * Thrown when the provided lineSeparator included some base64 characters. + * @since 1.4 + */ + public Base64(final int lineLength, final byte[] lineSeparator) { + this(lineLength, lineSeparator, false); + } + + /** + * Creates a Base64 codec used for decoding (all modes) and encoding in URL-unsafe mode. + *

+ * When encoding the line length and line separator are given in the constructor, and the encoding table is + * STANDARD_ENCODE_TABLE. + *

+ *

+ * Line lengths that aren't multiples of 4 will still essentially end up being multiples of 4 in the encoded data. + *

+ *

+ * When decoding all variants are supported. + *

+ * + * @param lineLength + * Each line of encoded data will be at most of the given length (rounded down to nearest multiple of + * 4). If lineLength <= 0, then the output will not be divided into lines (chunks). Ignored when + * decoding. + * @param lineSeparator + * Each line of encoded data will end with this sequence of bytes. + * @param urlSafe + * Instead of emitting '+' and '/' we emit '-' and '_' respectively. urlSafe is only applied to encode + * operations. Decoding seamlessly handles both modes. + * Note: no padding is added when using the URL-safe alphabet. + * @throws IllegalArgumentException + * Thrown when the {@code lineSeparator} contains Base64 characters. + * @since 1.4 + */ + public Base64(final int lineLength, final byte[] lineSeparator, final boolean urlSafe) { + this(lineLength, lineSeparator, urlSafe, CodecPolicy.LENIANT); + } + + /** + * Creates a Base64 codec used for decoding (all modes) and encoding in URL-unsafe mode. + *

+ * When encoding the line length and line separator are given in the constructor, and the encoding table is + * STANDARD_ENCODE_TABLE. + *

+ *

+ * Line lengths that aren't multiples of 4 will still essentially end up being multiples of 4 in the encoded data. + *

+ *

+ * When decoding all variants are supported. + *

+ * + * @param lineLength + * Each line of encoded data will be at most of the given length (rounded down to nearest multiple of + * 4). If lineLength <= 0, then the output will not be divided into lines (chunks). Ignored when + * decoding. + * @param lineSeparator + * Each line of encoded data will end with this sequence of bytes. + * @param urlSafe + * Instead of emitting '+' and '/' we emit '-' and '_' respectively. urlSafe is only applied to encode + * operations. Decoding seamlessly handles both modes. + * Note: no padding is added when using the URL-safe alphabet. + * @param decodingPolicy The decoding policy. + * @throws IllegalArgumentException + * Thrown when the {@code lineSeparator} contains Base64 characters. + * @since 1.15 + */ + public Base64(final int lineLength, final byte[] lineSeparator, final boolean urlSafe, final CodecPolicy decodingPolicy) { + super(BYTES_PER_UNENCODED_BLOCK, BYTES_PER_ENCODED_BLOCK, + lineLength, + lineSeparator == null ? 0 : lineSeparator.length, + PAD_DEFAULT, + decodingPolicy); + // TODO could be simplified if there is no requirement to reject invalid line sep when length <=0 + // @see test case Base64Test.testConstructors() + if (lineSeparator != null) { + if (containsAlphabetOrPad(lineSeparator)) { + final String sep = new String(lineSeparator, Charset.forName("UTF-8")); + throw new IllegalArgumentException("lineSeparator must not contain base64 characters: [" + sep + "]"); + } + if (lineLength > 0){ // null line-sep forces no chunking rather than throwing IAE + this.encodeSize = BYTES_PER_ENCODED_BLOCK + lineSeparator.length; + this.lineSeparator = new byte[lineSeparator.length]; + System.arraycopy(lineSeparator, 0, this.lineSeparator, 0, lineSeparator.length); + } else { + this.encodeSize = BYTES_PER_ENCODED_BLOCK; + this.lineSeparator = null; + } + } else { + this.encodeSize = BYTES_PER_ENCODED_BLOCK; + this.lineSeparator = null; + } + this.decodeSize = this.encodeSize - 1; + this.encodeTable = urlSafe ? URL_SAFE_ENCODE_TABLE : STANDARD_ENCODE_TABLE; + } + + // Implementation of the Encoder Interface + + /** + *

+ * Decodes all of the provided data, starting at inPos, for inAvail bytes. Should be called at least twice: once + * with the data to decode, and once with inAvail set to "-1" to alert decoder that EOF has been reached. The "-1" + * call is not necessary when decoding, but it doesn't hurt, either. + *

+ *

+ * Ignores all non-base64 characters. This is how chunked (e.g. 76 character) data is handled, since CR and LF are + * silently ignored, but has implications for other bytes, too. This method subscribes to the garbage-in, + * garbage-out philosophy: it will not check the provided data for validity. + *

+ *

+ * Thanks to "commons" project in ws.apache.org for the bitwise operations, and general approach. + * http://svn.apache.org/repos/asf/webservices/commons/trunk/modules/util/ + *

+ * + * @param in + * byte[] array of ascii data to base64 decode. + * @param inPos + * Position to start reading data from. + * @param inAvail + * Amount of bytes available from input for decoding. + * @param context + * the context to be used + */ + @Override + void decode(final byte[] in, int inPos, final int inAvail, final Context context) { + if (context.eof) { + return; + } + if (inAvail < 0) { + context.eof = true; + } + for (int i = 0; i < inAvail; i++) { + final byte[] buffer = ensureBufferSize(decodeSize, context); + final byte b = in[inPos++]; + if (b == pad) { + // We're done. + context.eof = true; + break; + } + if (b >= 0 && b < DECODE_TABLE.length) { + final int result = DECODE_TABLE[b]; + if (result >= 0) { + context.modulus = (context.modulus+1) % BYTES_PER_ENCODED_BLOCK; + context.ibitWorkArea = (context.ibitWorkArea << BITS_PER_ENCODED_BYTE) + result; + if (context.modulus == 0) { + buffer[context.pos++] = (byte) ((context.ibitWorkArea >> 16) & MASK_8BITS); + buffer[context.pos++] = (byte) ((context.ibitWorkArea >> 8) & MASK_8BITS); + buffer[context.pos++] = (byte) (context.ibitWorkArea & MASK_8BITS); + } + } + } + } + + // Two forms of EOF as far as base64 decoder is concerned: actual + // EOF (-1) and first time '=' character is encountered in stream. + // This approach makes the '=' padding characters completely optional. + if (context.eof && context.modulus != 0) { + final byte[] buffer = ensureBufferSize(decodeSize, context); + + // We have some spare bits remaining + // Output all whole multiples of 8 bits and ignore the rest + switch (context.modulus) { +// case 0 : // impossible, as excluded above + case 1 : // 6 bits - either ignore entirely, or raise an exception + validateTrailingCharacter(); + break; + case 2 : // 12 bits = 8 + 4 + validateCharacter(MASK_4BITS, context); + context.ibitWorkArea = context.ibitWorkArea >> 4; // dump the extra 4 bits + buffer[context.pos++] = (byte) ((context.ibitWorkArea) & MASK_8BITS); + break; + case 3 : // 18 bits = 8 + 8 + 2 + validateCharacter(MASK_2BITS, context); + context.ibitWorkArea = context.ibitWorkArea >> 2; // dump 2 bits + buffer[context.pos++] = (byte) ((context.ibitWorkArea >> 8) & MASK_8BITS); + buffer[context.pos++] = (byte) ((context.ibitWorkArea) & MASK_8BITS); + break; + default: + throw new IllegalStateException("Impossible modulus " + context.modulus); + } + } + } + + /** + *

+ * Encodes all of the provided data, starting at inPos, for inAvail bytes. Must be called at least twice: once with + * the data to encode, and once with inAvail set to "-1" to alert encoder that EOF has been reached, to flush last + * remaining bytes (if not multiple of 3). + *

+ *

Note: no padding is added when encoding using the URL-safe alphabet.

+ *

+ * Thanks to "commons" project in ws.apache.org for the bitwise operations, and general approach. + * http://svn.apache.org/repos/asf/webservices/commons/trunk/modules/util/ + *

+ * + * @param in + * byte[] array of binary data to base64 encode. + * @param inPos + * Position to start reading data from. + * @param inAvail + * Amount of bytes available from input for encoding. + * @param context + * the context to be used + */ + @Override + void encode(final byte[] in, int inPos, final int inAvail, final Context context) { + if (context.eof) { + return; + } + // inAvail < 0 is how we're informed of EOF in the underlying data we're + // encoding. + if (inAvail < 0) { + context.eof = true; + if (0 == context.modulus && lineLength == 0) { + return; // no leftovers to process and not using chunking + } + final byte[] buffer = ensureBufferSize(encodeSize, context); + final int savedPos = context.pos; + switch (context.modulus) { // 0-2 + case 0 : // nothing to do here + break; + case 1 : // 8 bits = 6 + 2 + // top 6 bits: + buffer[context.pos++] = encodeTable[(context.ibitWorkArea >> 2) & MASK_6BITS]; + // remaining 2: + buffer[context.pos++] = encodeTable[(context.ibitWorkArea << 4) & MASK_6BITS]; + // URL-SAFE skips the padding to further reduce size. + if (encodeTable == STANDARD_ENCODE_TABLE) { + buffer[context.pos++] = pad; + buffer[context.pos++] = pad; + } + break; + + case 2 : // 16 bits = 6 + 6 + 4 + buffer[context.pos++] = encodeTable[(context.ibitWorkArea >> 10) & MASK_6BITS]; + buffer[context.pos++] = encodeTable[(context.ibitWorkArea >> 4) & MASK_6BITS]; + buffer[context.pos++] = encodeTable[(context.ibitWorkArea << 2) & MASK_6BITS]; + // URL-SAFE skips the padding to further reduce size. + if (encodeTable == STANDARD_ENCODE_TABLE) { + buffer[context.pos++] = pad; + } + break; + default: + throw new IllegalStateException("Impossible modulus " + context.modulus); + } + context.currentLinePos += context.pos - savedPos; // keep track of current line position + // if currentPos == 0 we are at the start of a line, so don't add CRLF + if (lineLength > 0 && context.currentLinePos > 0) { + System.arraycopy(lineSeparator, 0, buffer, context.pos, lineSeparator.length); + context.pos += lineSeparator.length; + } + } else { + for (int i = 0; i < inAvail; i++) { + final byte[] buffer = ensureBufferSize(encodeSize, context); + context.modulus = (context.modulus+1) % BYTES_PER_UNENCODED_BLOCK; + int b = in[inPos++]; + if (b < 0) { + b += 256; + } + context.ibitWorkArea = (context.ibitWorkArea << 8) + b; // BITS_PER_BYTE + if (0 == context.modulus) { // 3 bytes = 24 bits = 4 * 6 bits to extract + buffer[context.pos++] = encodeTable[(context.ibitWorkArea >> 18) & MASK_6BITS]; + buffer[context.pos++] = encodeTable[(context.ibitWorkArea >> 12) & MASK_6BITS]; + buffer[context.pos++] = encodeTable[(context.ibitWorkArea >> 6) & MASK_6BITS]; + buffer[context.pos++] = encodeTable[context.ibitWorkArea & MASK_6BITS]; + context.currentLinePos += BYTES_PER_ENCODED_BLOCK; + if (lineLength > 0 && lineLength <= context.currentLinePos) { + System.arraycopy(lineSeparator, 0, buffer, context.pos, lineSeparator.length); + context.pos += lineSeparator.length; + context.currentLinePos = 0; + } + } + } + } + } + + /** + * Returns whether or not the {@code octet} is in the Base64 alphabet. + * + * @param octet + * The value to test + * @return {@code true} if the value is defined in the the Base64 alphabet {@code false} otherwise. + */ + @Override + protected boolean isInAlphabet(final byte octet) { + return octet >= 0 && octet < decodeTable.length && decodeTable[octet] != -1; + } + + /** + * Returns our current encode mode. True if we're URL-SAFE, false otherwise. + * + * @return true if we're in URL-SAFE mode, false otherwise. + * @since 1.4 + */ + public boolean isUrlSafe() { + return this.encodeTable == URL_SAFE_ENCODE_TABLE; + } + + /** + * Validates whether decoding the final trailing character is possible in the context + * of the set of possible base 64 values. + * + *

The character is valid if the lower bits within the provided mask are zero. This + * is used to test the final trailing base-64 digit is zero in the bits that will be discarded. + * + * @param emptyBitsMask The mask of the lower bits that should be empty + * @param context the context to be used + * + * @throws IllegalArgumentException if the bits being checked contain any non-zero value + */ + private void validateCharacter(final int emptyBitsMask, final Context context) { + if (isStrictDecoding() && (context.ibitWorkArea & emptyBitsMask) != 0) { + throw new IllegalArgumentException( + "Strict decoding: Last encoded character (before the paddings if any) is a valid base 64 alphabet but not a possible encoding. " + + "Expected the discarded bits from the character to be zero."); + } + } + + /** + * Validates whether decoding allows an entire final trailing character that cannot be + * used for a complete byte. + * + * @throws IllegalArgumentException if strict decoding is enabled + */ + private void validateTrailingCharacter() { + if (isStrictDecoding()) { + throw new IllegalArgumentException( + "Strict decoding: Last encoded character (before the paddings if any) is a valid base 64 alphabet but not a possible encoding. " + + "Decoding requires at least two trailing 6-bit characters to create bytes."); + } + } + + } + + @SuppressWarnings("unused") + private static abstract class BaseNCodec { + + static enum CodecPolicy { + STRICT,LENIANT; + } + + /** + * Holds thread context so classes can be thread-safe. + * + * This class is not itself thread-safe; each thread must allocate its own copy. + * + * @since 1.7 + */ + static class Context { + + /** + * Place holder for the bytes we're dealing with for our based logic. + * Bitwise operations store and extract the encoding or decoding from this variable. + */ + int ibitWorkArea; + + /** + * Place holder for the bytes we're dealing with for our based logic. + * Bitwise operations store and extract the encoding or decoding from this variable. + */ + long lbitWorkArea; + + /** + * Buffer for streaming. + */ + byte[] buffer; + + /** + * Position where next character should be written in the buffer. + */ + int pos; + + /** + * Position where next character should be read from the buffer. + */ + int readPos; + + /** + * Boolean flag to indicate the EOF has been reached. Once EOF has been reached, this object becomes useless, + * and must be thrown away. + */ + boolean eof; + + /** + * Variable tracks how many characters have been written to the current line. Only used when encoding. We use + * it to make sure each encoded line never goes beyond lineLength (if lineLength > 0). + */ + int currentLinePos; + + /** + * Writes to the buffer only occur after every 3/5 reads when encoding, and every 4/8 reads when decoding. This + * variable helps track that. + */ + int modulus; + + Context() { + } + + /** + * Returns a String useful for debugging (especially within a debugger.) + * + * @return a String useful for debugging. + */ + @SuppressWarnings("boxing") // OK to ignore boxing here + @Override + public String toString() { + return String.format("%s[buffer=%s, currentLinePos=%s, eof=%s, ibitWorkArea=%s, lbitWorkArea=%s, " + + "modulus=%s, pos=%s, readPos=%s]", this.getClass().getSimpleName(), Arrays.toString(buffer), + currentLinePos, eof, ibitWorkArea, lbitWorkArea, modulus, pos, readPos); + } + } + + /** + * EOF + * + * @since 1.7 + */ + static final int EOF = -1; + + /** + * MIME chunk size per RFC 2045 section 6.8. + * + *

+ * The {@value} character limit does not count the trailing CRLF, but counts all other characters, including any + * equal signs. + *

+ * + * @see RFC 2045 section 6.8 + */ + public static final int MIME_CHUNK_SIZE = 76; + + /** + * PEM chunk size per RFC 1421 section 4.3.2.4. + * + *

+ * The {@value} character limit does not count the trailing CRLF, but counts all other characters, including any + * equal signs. + *

+ * + * @see RFC 1421 section 4.3.2.4 + */ + public static final int PEM_CHUNK_SIZE = 64; + + private static final int DEFAULT_BUFFER_RESIZE_FACTOR = 2; + + /** + * Defines the default buffer size - currently {@value} + * - must be large enough for at least one encoded block+separator + */ + private static final int DEFAULT_BUFFER_SIZE = 8192; + + /** + * The maximum size buffer to allocate. + * + *

This is set to the same size used in the JDK {@code java.util.ArrayList}:

+ *
+ * Some VMs reserve some header words in an array. + * Attempts to allocate larger arrays may result in + * OutOfMemoryError: Requested array size exceeds VM limit. + *
+ */ + private static final int MAX_BUFFER_SIZE = Integer.MAX_VALUE - 8; + + /** Mask used to extract 8 bits, used in decoding bytes */ + protected static final int MASK_8BITS = 0xff; + + /** + * Byte used to pad output. + */ + protected static final byte PAD_DEFAULT = '='; // Allow static access to default + + /** + * Chunk separator per RFC 2045 section 2.1. + * + * @see RFC 2045 section 2.1 + */ + static final byte[] CHUNK_SEPARATOR = {'\r', '\n'}; + + /** + * Compares two {@code int} values numerically treating the values + * as unsigned. Taken from JDK 1.8. + * + *

TODO: Replace with JDK 1.8 Integer::compareUnsigned(int, int).

+ * + * @param x the first {@code int} to compare + * @param y the second {@code int} to compare + * @return the value {@code 0} if {@code x == y}; a value less + * than {@code 0} if {@code x < y} as unsigned values; and + * a value greater than {@code 0} if {@code x > y} as + * unsigned values + */ + private static int compareUnsigned(final int xx, final int yy) { + int x = xx + Integer.MIN_VALUE; + int y = yy + Integer.MIN_VALUE; + return (x < y) ? -1 : ((x == y) ? 0 : 1); + } + + /** + * Create a positive capacity at least as large the minimum required capacity. + * If the minimum capacity is negative then this throws an OutOfMemoryError as no array + * can be allocated. + * + * @param minCapacity the minimum capacity + * @return the capacity + * @throws OutOfMemoryError if the {@code minCapacity} is negative + */ + private static int createPositiveCapacity(final int minCapacity) { + if (minCapacity < 0) { + // overflow + throw new OutOfMemoryError("Unable to allocate array size: " + (minCapacity & 0xffffffffL)); + } + // This is called when we require buffer expansion to a very big array. + // Use the conservative maximum buffer size if possible, otherwise the biggest required. + // + // Note: In this situation JDK 1.8 java.util.ArrayList returns Integer.MAX_VALUE. + // This excludes some VMs that can exceed MAX_BUFFER_SIZE but not allocate a full + // Integer.MAX_VALUE length array. + // The result is that we may have to allocate an array of this size more than once if + // the capacity must be expanded again. + return (minCapacity > MAX_BUFFER_SIZE) ? + minCapacity : + MAX_BUFFER_SIZE; + } + + /** + * Gets a copy of the chunk separator per RFC 2045 section 2.1. + * + * @return the chunk separator + * @see RFC 2045 section 2.1 + * @since 1.15 + */ + public static byte[] getChunkSeparator() { + return CHUNK_SEPARATOR.clone(); + } + + /** + * Checks if a byte value is whitespace or not. + * Whitespace is taken to mean: space, tab, CR, LF + * @param byteToCheck + * the byte to check + * @return true if byte is whitespace, false otherwise + */ + protected static boolean isWhiteSpace(final byte byteToCheck) { + switch (byteToCheck) { + case ' ' : + case '\n' : + case '\r' : + case '\t' : + return true; + default : + return false; + } + } + + /** + * Increases our buffer by the {@link #DEFAULT_BUFFER_RESIZE_FACTOR}. + * @param context the context to be used + * @param minCapacity the minimum required capacity + * @return the resized byte[] buffer + * @throws OutOfMemoryError if the {@code minCapacity} is negative + */ + private static byte[] resizeBuffer(final Context context, final int minCapacity) { + // Overflow-conscious code treats the min and new capacity as unsigned. + final int oldCapacity = context.buffer.length; + int newCapacity = oldCapacity * DEFAULT_BUFFER_RESIZE_FACTOR; + if (compareUnsigned(newCapacity, minCapacity) < 0) { + newCapacity = minCapacity; + } + if (compareUnsigned(newCapacity, MAX_BUFFER_SIZE) > 0) { + newCapacity = createPositiveCapacity(minCapacity); + } + + final byte[] b = new byte[newCapacity]; + System.arraycopy(context.buffer, 0, b, 0, context.buffer.length); + context.buffer = b; + return b; + } + + /** + * @deprecated Use {@link #pad}. Will be removed in 2.0. + */ + @Deprecated + protected final byte PAD = PAD_DEFAULT; // instance variable just in case it needs to vary later + + protected final byte pad; // instance variable just in case it needs to vary later + + /** Number of bytes in each full block of unencoded data, e.g. 4 for Base64 and 5 for Base32 */ + private final int unencodedBlockSize; + + /** Number of bytes in each full block of encoded data, e.g. 3 for Base64 and 8 for Base32 */ + private final int encodedBlockSize; + + /** + * Chunksize for encoding. Not used when decoding. + * A value of zero or less implies no chunking of the encoded data. + * Rounded down to nearest multiple of encodedBlockSize. + */ + protected final int lineLength; + + /** + * Size of chunk separator. Not used unless {@link #lineLength} > 0. + */ + private final int chunkSeparatorLength; + + /** + * Defines the decoding behavior when the input bytes contain leftover trailing bits that + * cannot be created by a valid encoding. These can be bits that are unused from the final + * character or entire characters. The default mode is lenient decoding. Set this to + * {@code true} to enable strict decoding. + *
    + *
  • Lenient: Any trailing bits are composed into 8-bit bytes where possible. + * The remainder are discarded. + *
  • Strict: The decoding will raise an {@link IllegalArgumentException} if trailing bits + * are not part of a valid encoding. Any unused bits from the final character must + * be zero. Impossible counts of entire final characters are not allowed. + *
+ * + *

When strict decoding is enabled it is expected that the decoded bytes will be re-encoded + * to a byte array that matches the original, i.e. no changes occur on the final + * character. This requires that the input bytes use the same padding and alphabet + * as the encoder. + */ + private final CodecPolicy decodingPolicy; + + /** + * Note {@code lineLength} is rounded down to the nearest multiple of the encoded block size. + * If {@code chunkSeparatorLength} is zero, then chunking is disabled. + * @param unencodedBlockSize the size of an unencoded block (e.g. Base64 = 3) + * @param encodedBlockSize the size of an encoded block (e.g. Base64 = 4) + * @param lineLength if > 0, use chunking with a length {@code lineLength} + * @param chunkSeparatorLength the chunk separator length, if relevant + */ + protected BaseNCodec(final int unencodedBlockSize, final int encodedBlockSize, + final int lineLength, final int chunkSeparatorLength) { + this(unencodedBlockSize, encodedBlockSize, lineLength, chunkSeparatorLength, PAD_DEFAULT); + } + + /** + * Note {@code lineLength} is rounded down to the nearest multiple of the encoded block size. + * If {@code chunkSeparatorLength} is zero, then chunking is disabled. + * @param unencodedBlockSize the size of an unencoded block (e.g. Base64 = 3) + * @param encodedBlockSize the size of an encoded block (e.g. Base64 = 4) + * @param lineLength if > 0, use chunking with a length {@code lineLength} + * @param chunkSeparatorLength the chunk separator length, if relevant + * @param pad byte used as padding byte. + */ + protected BaseNCodec(final int unencodedBlockSize, final int encodedBlockSize, + final int lineLength, final int chunkSeparatorLength, final byte pad) { + this(unencodedBlockSize, encodedBlockSize, lineLength, chunkSeparatorLength, pad, CodecPolicy.LENIANT); + } + + /** + * Note {@code lineLength} is rounded down to the nearest multiple of the encoded block size. + * If {@code chunkSeparatorLength} is zero, then chunking is disabled. + * @param unencodedBlockSize the size of an unencoded block (e.g. Base64 = 3) + * @param encodedBlockSize the size of an encoded block (e.g. Base64 = 4) + * @param lineLength if > 0, use chunking with a length {@code lineLength} + * @param chunkSeparatorLength the chunk separator length, if relevant + * @param pad byte used as padding byte. + * @param decodingPolicy Decoding policy. + * @since 1.15 + */ + protected BaseNCodec(final int unencodedBlockSize, final int encodedBlockSize, + final int lineLength, final int chunkSeparatorLength, final byte pad, final CodecPolicy decodingPolicy) { + this.unencodedBlockSize = unencodedBlockSize; + this.encodedBlockSize = encodedBlockSize; + final boolean useChunking = lineLength > 0 && chunkSeparatorLength > 0; + this.lineLength = useChunking ? (lineLength / encodedBlockSize) * encodedBlockSize : 0; + this.chunkSeparatorLength = chunkSeparatorLength; + this.pad = pad; + this.decodingPolicy = decodingPolicy; + } + + /** + * Returns the amount of buffered data available for reading. + * + * @param context the context to be used + * @return The amount of buffered data available for reading. + */ + int available(final Context context) { // package protected for access from I/O streams + return context.buffer != null ? context.pos - context.readPos : 0; + } + + /** + * Tests a given byte array to see if it contains any characters within the alphabet or PAD. + * + * Intended for use in checking line-ending arrays + * + * @param arrayOctet + * byte array to test + * @return {@code true} if any byte is a valid character in the alphabet or PAD; {@code false} otherwise + */ + protected boolean containsAlphabetOrPad(final byte[] arrayOctet) { + if (arrayOctet == null) { + return false; + } + for (final byte element : arrayOctet) { + if (pad == element || isInAlphabet(element)) { + return true; + } + } + return false; + } + + /** + * Decodes a byte[] containing characters in the Base-N alphabet. + * + * @param pArray + * A byte array containing Base-N character data + * @return a byte array containing binary data + */ + public byte[] decode(final byte[] pArray) { + if (pArray == null || pArray.length == 0) { + return pArray; + } + final Context context = new Context(); + decode(pArray, 0, pArray.length, context); + decode(pArray, 0, EOF, context); // Notify decoder of EOF. + final byte[] result = new byte[context.pos]; + readResults(result, 0, result.length, context); + return result; + } + + // package protected for access from I/O streams + abstract void decode(byte[] pArray, int i, int length, Context context); + + /** + * Decodes an Object using the Base-N algorithm. This method is provided in order to satisfy the requirements of + * the Decoder interface, and will throw a DecoderException if the supplied object is not of type byte[] or String. + * + * @param obj + * Object to decode + * @return An object (of type byte[]) containing the binary data which corresponds to the byte[] or String + * supplied. + * @throws DecoderException + * if the parameter supplied is not of type byte[] + */ + public Object decode(final Object obj) { + if (obj instanceof byte[]) { + return decode((byte[]) obj); + } else if (obj instanceof String) { + return decode((String) obj); + } else { + return null; + } + } + + /** + * Decodes a String containing characters in the Base-N alphabet. + * + * @param pArray + * A String containing Base-N character data + * @return a byte array containing binary data + */ + public byte[] decode(final String pArray) { + return decode(pArray.getBytes(Charset.forName("UTF-8"))); + } + + /** + * Encodes a byte[] containing binary data, into a byte[] containing characters in the alphabet. + * + * @param pArray + * a byte array containing binary data + * @return A byte array containing only the base N alphabetic character data + */ + public byte[] encode(final byte[] pArray) { + if (pArray == null || pArray.length == 0) { + return pArray; + } + return encode(pArray, 0, pArray.length); + } + + /** + * Encodes a byte[] containing binary data, into a byte[] containing + * characters in the alphabet. + * + * @param pArray + * a byte array containing binary data + * @param offset + * initial offset of the subarray. + * @param length + * length of the subarray. + * @return A byte array containing only the base N alphabetic character data + * @since 1.11 + */ + public byte[] encode(final byte[] pArray, final int offset, final int length) { + if (pArray == null || pArray.length == 0) { + return pArray; + } + final Context context = new Context(); + encode(pArray, offset, length, context); + encode(pArray, offset, EOF, context); // Notify encoder of EOF. + final byte[] buf = new byte[context.pos - context.readPos]; + readResults(buf, 0, buf.length, context); + return buf; + } + + // package protected for access from I/O streams + abstract void encode(byte[] pArray, int i, int length, Context context); + + /** + * Encodes an Object using the Base-N algorithm. This method is provided in order to satisfy the requirements of + * the Encoder interface, and will throw an EncoderException if the supplied object is not of type byte[]. + * + * @param obj + * Object to encode + * @return An object (of type byte[]) containing the Base-N encoded data which corresponds to the byte[] supplied. + * @throws EncoderException + * if the parameter supplied is not of type byte[] + */ + public Object encode(final Object obj) { + return encode((byte[]) obj); + } + + /** + * Encodes a byte[] containing binary data, into a String containing characters in the appropriate alphabet. + * Uses UTF8 encoding. + * + * @param pArray a byte array containing binary data + * @return String containing only character data in the appropriate alphabet. + * @since 1.5 + * This is a duplicate of {@link #encodeToString(byte[])}; it was merged during refactoring. + */ + public String encodeAsString(final byte[] pArray){ + return new String(encode(pArray), Charset.forName("UTF-8")); + } + + /** + * Encodes a byte[] containing binary data, into a String containing characters in the Base-N alphabet. + * Uses UTF8 encoding. + * + * @param pArray + * a byte array containing binary data + * @return A String containing only Base-N character data + */ + public String encodeToString(final byte[] pArray) { + return new String(encode(pArray), Charset.forName("UTF-8")); + } + + /** + * Ensure that the buffer has room for {@code size} bytes + * + * @param size minimum spare space required + * @param context the context to be used + * @return the buffer + */ + protected byte[] ensureBufferSize(final int size, final Context context){ + if (context.buffer == null) { + context.buffer = new byte[Math.max(size, getDefaultBufferSize())]; + context.pos = 0; + context.readPos = 0; + + // Overflow-conscious: + // x + y > z == x + y - z > 0 + } else if (context.pos + size - context.buffer.length > 0) { + return resizeBuffer(context, context.pos + size); + } + return context.buffer; + } + + /** + * Returns the decoding behavior policy. + * + *

+ * The default is lenient. If the decoding policy is strict, then decoding will raise an + * {@link IllegalArgumentException} if trailing bits are not part of a valid encoding. Decoding will compose + * trailing bits into 8-bit bytes and discard the remainder. + *

+ * + * @return true if using strict decoding + * @since 1.15 + */ + public CodecPolicy getCodecPolicy() { + return decodingPolicy; + } + + /** + * Get the default buffer size. Can be overridden. + * + * @return the default buffer size. + */ + protected int getDefaultBufferSize() { + return DEFAULT_BUFFER_SIZE; + } + + /** + * Calculates the amount of space needed to encode the supplied array. + * + * @param pArray byte[] array which will later be encoded + * + * @return amount of space needed to encoded the supplied array. + * Returns a long since a max-len array will require > Integer.MAX_VALUE + */ + public long getEncodedLength(final byte[] pArray) { + // Calculate non-chunked size - rounded up to allow for padding + // cast to long is needed to avoid possibility of overflow + long len = ((pArray.length + unencodedBlockSize-1) / unencodedBlockSize) * (long) encodedBlockSize; + if (lineLength > 0) { // We're using chunking + // Round up to nearest multiple + len += ((len + lineLength-1) / lineLength) * chunkSeparatorLength; + } + return len; + } + + /** + * Returns true if this object has buffered data for reading. + * + * @param context the context to be used + * @return true if there is data still available for reading. + */ + boolean hasData(final Context context) { // package protected for access from I/O streams + return context.buffer != null; + } + + /** + * Returns whether or not the {@code octet} is in the current alphabet. + * Does not allow whitespace or pad. + * + * @param value The value to test + * + * @return {@code true} if the value is defined in the current alphabet, {@code false} otherwise. + */ + protected abstract boolean isInAlphabet(byte value); + + /** + * Tests a given byte array to see if it contains only valid characters within the alphabet. + * The method optionally treats whitespace and pad as valid. + * + * @param arrayOctet byte array to test + * @param allowWSPad if {@code true}, then whitespace and PAD are also allowed + * + * @return {@code true} if all bytes are valid characters in the alphabet or if the byte array is empty; + * {@code false}, otherwise + */ + public boolean isInAlphabet(final byte[] arrayOctet, final boolean allowWSPad) { + for (final byte octet : arrayOctet) { + if (!isInAlphabet(octet) && + (!allowWSPad || (octet != pad) && !isWhiteSpace(octet))) { + return false; + } + } + return true; + } + + /** + * Tests a given String to see if it contains only valid characters within the alphabet. + * The method treats whitespace and PAD as valid. + * + * @param basen String to test + * @return {@code true} if all characters in the String are valid characters in the alphabet or if + * the String is empty; {@code false}, otherwise + * @see #isInAlphabet(byte[], boolean) + */ + public boolean isInAlphabet(final String basen) { + return isInAlphabet(basen.getBytes(Charset.forName("UTF-8")), true); + } + + /** + * Returns true if decoding behavior is strict. Decoding will raise an {@link IllegalArgumentException} if trailing + * bits are not part of a valid encoding. + * + *

+ * The default is false for lenient decoding. Decoding will compose trailing bits into 8-bit bytes and discard the + * remainder. + *

+ * + * @return true if using strict decoding + * @since 1.15 + */ + public boolean isStrictDecoding() { + return decodingPolicy == CodecPolicy.STRICT; + } + + /** + * Extracts buffered data into the provided byte[] array, starting at position bPos, up to a maximum of bAvail + * bytes. Returns how many bytes were actually extracted. + *

+ * Package protected for access from I/O streams. + * + * @param b + * byte[] array to extract the buffered data into. + * @param bPos + * position in byte[] array to start extraction at. + * @param bAvail + * amount of bytes we're allowed to extract. We may extract fewer (if fewer are available). + * @param context + * the context to be used + * @return The number of bytes successfully extracted into the provided byte[] array. + */ + int readResults(final byte[] b, final int bPos, final int bAvail, final Context context) { + if (context.buffer != null) { + final int len = Math.min(available(context), bAvail); + System.arraycopy(context.buffer, context.readPos, b, bPos, len); + context.readPos += len; + if (context.readPos >= context.pos) { + context.buffer = null; // so hasData() will return false, and this method can return -1 + } + return len; + } + return context.eof ? EOF : 0; + } + } + + public static class DetectAnisotropicGlitch { + + private static boolean known = false; + private static boolean detected = false; + + public static boolean hasGlitch() { + if(!known) { + detected = detect(); + known = true; + } + return detected; + } + + public static boolean detect() { + HTMLCanvasElement cvs = (HTMLCanvasElement) Window.current().getDocument().createElement("canvas"); + + cvs.setWidth(400); + cvs.setHeight(300); + + WebGL2RenderingContext ctx = (WebGL2RenderingContext) cvs.getContext("webgl2"); + + if(ctx == null) { + Client.showIncompatibleScreen("WebGL 2.0 is not supported on this device!"); + throw new UnsupportedOperationException("WebGL 2 is not supported on this device!"); + } + + if(ctx.getExtension("EXT_texture_filter_anisotropic") != null) { + + String vshSrc = "#version 300 es\n" + + "precision lowp float;" + + "in vec2 a_pos;" + + "out vec2 v_pos;" + + "void main() {" + + " gl_Position = vec4((v_pos = a_pos) * 2.0 - 1.0, 0.0, 1.0);" + + "}"; + + String fshSrc = "#version 300 es\n" + + "precision lowp float;" + + "precision lowp sampler2D;" + + "uniform sampler2D tex;" + + "in vec2 v_pos;" + + "out vec4 fragColor;" + + "void main() {" + + " fragColor = vec4(texture(tex, v_pos).rgb, 1.0);" + + "}"; + + WebGLShader vsh = ctx.createShader(WebGL2RenderingContext.VERTEX_SHADER); + ctx.shaderSource(vsh, vshSrc); + ctx.compileShader(vsh); + + if(!ctx.getShaderParameterb(vsh, WebGL2RenderingContext.COMPILE_STATUS)) { + System.err.println("ERROR: Could not check for ANGLE Issue #4994, VERTEX_SHADER did not compile:"); + System.err.println(ctx.getShaderInfoLog(vsh)); + ctx.deleteShader(vsh); + return false; + } + + WebGLShader fsh = ctx.createShader(WebGL2RenderingContext.FRAGMENT_SHADER); + ctx.shaderSource(fsh, fshSrc); + ctx.compileShader(fsh); + + if(!ctx.getShaderParameterb(fsh, WebGL2RenderingContext.COMPILE_STATUS)) { + System.err.println("ERROR: Could not check for ANGLE Issue #4994, FRAGMENT_SHADER did not compile:"); + System.err.println(ctx.getShaderInfoLog(fsh)); + ctx.deleteShader(vsh); + ctx.deleteShader(fsh); + return false; + } + + WebGLProgram pr = ctx.createProgram(); + + ctx.attachShader(pr, vsh); + ctx.attachShader(pr, fsh); + + ctx.bindAttribLocation(pr, 0, "a_pos"); + ctx.bindAttribLocation(pr, 0, "fragColor"); + + ctx.linkProgram(pr); + + ctx.detachShader(pr, vsh); + ctx.detachShader(pr, fsh); + + ctx.deleteShader(vsh); + ctx.deleteShader(fsh); + + if(!ctx.getProgramParameterb(pr, WebGL2RenderingContext.LINK_STATUS)) { + System.err.println("ERROR: Could not check for ANGLE Issue #4994, program did not link:"); + System.err.println(ctx.getProgramInfoLog(pr)); + ctx.deleteProgram(pr); + return false; + } + + ctx.useProgram(pr); + + ctx.uniform1i(ctx.getUniformLocation(pr, "tex"), 0); + + byte x0 = (byte)0x00; + byte x1 = (byte)0xFF; + + byte[] pixelsData = new byte[] { + x0, x0, x0, x1, + x0, x0, x0, x1, + x1, x1, x1, x1, + x0, x0, x0, x1, + x0, x0, x0, x1, + x0, x0, x0, x1, + x1, x1, x1, x1, + x0, x0, x0, x1, + x0, x0, x0, x1, + x0, x0, x0, x1, + x1, x1, x1, x1, + x0, x0, x0, x1 + }; + + Uint8Array pixels = Uint8Array.create(pixelsData.length); + pixels.set(pixelsData); + + WebGLTexture tex = ctx.createTexture(); + + ctx.bindTexture(WebGL2RenderingContext.TEXTURE_2D, tex); + + ctx.texParameteri(WebGL2RenderingContext.TEXTURE_2D, WebGL2RenderingContext.TEXTURE_WRAP_S, WebGL2RenderingContext.REPEAT); + ctx.texParameteri(WebGL2RenderingContext.TEXTURE_2D, WebGL2RenderingContext.TEXTURE_WRAP_T, WebGL2RenderingContext.REPEAT); + ctx.texParameteri(WebGL2RenderingContext.TEXTURE_2D, WebGL2RenderingContext.TEXTURE_MIN_FILTER, WebGL2RenderingContext.NEAREST_MIPMAP_LINEAR); + ctx.texParameteri(WebGL2RenderingContext.TEXTURE_2D, WebGL2RenderingContext.TEXTURE_MAG_FILTER, WebGL2RenderingContext.NEAREST); + ctx.texParameterf(WebGL2RenderingContext.TEXTURE_2D, WebGL2RenderingContext.TEXTURE_MAX_ANISOTROPY_EXT, 16.0f); + + ctx.texImage2D(WebGL2RenderingContext.TEXTURE_2D, 0, WebGL2RenderingContext.RGBA, 4, 3, 0, WebGL2RenderingContext.RGBA, WebGL2RenderingContext.UNSIGNED_BYTE, pixels); + ctx.generateMipmap(WebGL2RenderingContext.TEXTURE_2D); + + float[] vertsData = new float[] { + 0.0f, 0.0f, + 1.0f, 0.0f, + 0.0f, 1.0f, + 1.0f, 0.0f, + 1.0f, 1.0f, + 0.0f, 1.0f + }; + + Float32Array verts = Float32Array.create(vertsData.length); + verts.set(vertsData); + + WebGLBuffer buf = ctx.createBuffer(); + + ctx.bindBuffer(WebGL2RenderingContext.ARRAY_BUFFER, buf); + ctx.bufferData(WebGL2RenderingContext.ARRAY_BUFFER, verts, WebGL2RenderingContext.STATIC_DRAW); + + WebGLVertexArray arr = ctx.createVertexArray(); + + ctx.bindVertexArray(arr); + + ctx.enableVertexAttribArray(0); + ctx.vertexAttribPointer(0, 2, WebGL2RenderingContext.FLOAT, false, 8, 0); + + ctx.viewport(0, 0, 400, 300); + ctx.drawArrays(WebGL2RenderingContext.TRIANGLES, 0, 6); + + ctx.deleteVertexArray(arr); + ctx.deleteBuffer(buf); + ctx.deleteTexture(tex); + ctx.deleteProgram(pr); + + Uint8Array readPx = Uint8Array.create(4); + ctx.readPixels(175, 150, 1, 1, WebGL2RenderingContext.RGBA, WebGL2RenderingContext.UNSIGNED_BYTE, readPx); + + boolean b = (readPx.get(0) + readPx.get(1) + readPx.get(2)) != 0; + + if(b) { + System.out.println("ANGLE issue #4994 is unpatched on this browser, enabling anisotropic fix"); + } + + return b; + }else { + System.err.println("WARNING: EXT_texture_filter_anisotropic is not supported!"); + return false; + } + + } + + } + + private static class EarlyLoadScreen { + + public static final String loadScreen = "iVBORw0KGgoAAAANSUhEUgAAAMAAAADACAYAAABS3GwHAAAACXBIWXMAAAsTAAALEwEAmpwYAAAHx0lEQVR42u3da27jIBRAYbfqFp1FuovM/GLEMIDBhsRJviNVapsYY8y5vPz4ut/v9wX4UL4VAQgAEAAgAEAAgAAAAQACAAQACAAQACAAQACAAAABAAIABAAIABAAIABAAIAAAAEAAgAEAAgAEAAgAEAAgAAAAQACAAQACAAQACAAQACAAAABAAIABAAIABAAIABAAIAAAAEAAgAEAAgAEAAgAAgAEAAgAEAAgAAAAQACAAQACAAQACAAQACAAMBr86MI3ovf39/i/9Z1XdZ1VUgEeN/Kf7vdqt8hgC7QW6OCE+CjK/+2bcv9fieCLtDjux9x/1t/u1xOveWSlisBXmQASoB/+fr6+vv7/X7vHteE8hxZrrpAkyo/2mU42soSgAAfN8YZ3aoSQOV/GNu2ZX9vGdjPEuBnVmXIVYqePly8famCne0TtuS1tt/a9kfSbWnqZw2u9yQesc91XZ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ORK5CYII="; + public static final String enableScreen = "iVBORw0KGgoAAAANSUhEUgAAAIAAAACACAYAAADDPmHLAAAACXBIWXMAAC4jAAAuIwF4pT92AAAEAklEQVR42u2dvXbjIBBG7T0+xw+gTp06v//LmE6dO/VR5a3wGZNh+BGSFeveJgkIBrDy8TGKds8/Pz/PExyW8/P55AY4MP9YgmNzmeeZVUABAA8AKADgAQAFADwAoACABwAUAPAAgAIAHgBQAMADAAoAeABAAY7LOI7fpQDX65VPtZCt18w5d7rdbigAbOgBxnE8DcPwJnnDMCTrNJlsUVcizTnj9HWxeVvINfN9y361OdTEk30551ZZt3PsvYDYxOSChoPQ6sJ21mRLBm61jY0lpy61gDKWNdfcNcv5wErWLbfPF88I9/s9WtayzopXS85YtPqcMeT23SqedV1pucal1V4iTUooV/IaWSfbWHU5JmkvpmzrsayaB9DqfJnVTpMff72sc869/WzVlcjjOI7mOOVYfBzfT05exLfT5pqae008a71Ly6tPASV79CfPylvFjpm+teLH+tXiF5nA2LOAUMpCibckWpPBUOJT20btFuDjyK8p+S45Z4fX+ti+LDb3pef62PosWbfkDbBW8mFPhB/gt8Vr7gG+kZK9+C/GM2+ArffnnKRHbT5gSdJoK0+ydrziGyCW115LolLxnHOr59q3lt89b6U8Czg4pgdI5bUtKY3VzfOclGBtTLVSmmqn1cdyC7Iud+5791KX1MLJDz3Mg2s59pK6sM/asdTmLrRx5pzjS+e+awWw9lstVeuv1/a10rqwT8sn5LQr8RzaMVfmKrR2qfnFjs57/puLS0nyoTZp0fL8XGq+ap8v4AES+3Msx74kN2/tmblewWoXPl9o+RykZH5/5hTQYv+y+vj084XcPHpJbHmt1s7yGbV1q+UBnHO/gnoZje2RmuzK/Vr2F3sWEF6TGkvutqH5CG08qTmk5u77tLyK5Qtq62rgxRA8AO8FHBkygQeHLQAFADwAoACABwAUAPAAgAIAHgBQAMADAAoAeABAAQAPACgA4AEABQA8AKAAgAcAFAC+3gNM03Tqum7VQSyN4dtvMdZDKcBWC9oqhr8JoIEHeDwep77vf5VJfL0vl9fLa/u+f+vPfx9eszSGNXZo5AH6vlcXW36gsqykrzViwAIPYL3r3nXd63v5m6i9J2+VaT8viWGNHZQbYE97+KdjHPIGKH0XPSyL7eXSjPk2YZlsN03Tq21OjLAs598ZggIT2MpMbW3IMICFN0Dsv4xpfUbfAvIAK9wAcOAtAMgDwJHzAIACAB4AUADAAwAKAHgAQAEADwAoAOABAAUAPACgAIAHABQA8ACAAgAeAFAAwAMACgB4AEABAA8AKADgAQAFADwAoACABwAUAPAAgAIAHgBQAMADAAoAeABAAQAPACgA4AEABQA8AKAAgAcAFADwANCe/0of1jQ8XY5YAAAAAElFTkSuQmCC"; + + private static BufferGL vbo = null; + private static ProgramGL program = null; + + public static void paintScreen() { + + TextureGL tex = _wglGenTextures(); + _wglActiveTexture(_wGL_TEXTURE0); + glBindTexture(_wGL_TEXTURE_2D, tex); + _wglTexParameteri(_wGL_TEXTURE_2D, _wGL_TEXTURE_MAG_FILTER, _wGL_NEAREST); + _wglTexParameteri(_wGL_TEXTURE_2D, _wGL_TEXTURE_MIN_FILTER, _wGL_NEAREST); + _wglTexParameteri(_wGL_TEXTURE_2D, _wGL_TEXTURE_WRAP_S, _wGL_CLAMP); + _wglTexParameteri(_wGL_TEXTURE_2D, _wGL_TEXTURE_WRAP_T, _wGL_CLAMP); + BufferedImage img = loadPNG(Base64.decodeBase64(loadScreen)); + IntBuffer upload = BufferUtils.createIntBuffer(192*192); + upload.put(img.getData()); + upload.flip(); + _wglTexImage2D(_wGL_TEXTURE_2D, 0, _wGL_RGBA, 192, 192, 0, _wGL_RGBA, _wGL_UNSIGNED_BYTE, upload); + + upload.clear(); + upload.put(Float.floatToIntBits(0.0f)); upload.put(Float.floatToIntBits(0.0f)); + upload.put(Float.floatToIntBits(0.0f)); upload.put(Float.floatToIntBits(1.0f)); + upload.put(Float.floatToIntBits(1.0f)); upload.put(Float.floatToIntBits(0.0f)); + upload.put(Float.floatToIntBits(1.0f)); upload.put(Float.floatToIntBits(0.0f)); + upload.put(Float.floatToIntBits(0.0f)); upload.put(Float.floatToIntBits(1.0f)); + upload.put(Float.floatToIntBits(1.0f)); upload.put(Float.floatToIntBits(1.0f)); + upload.flip(); + + vbo = _wglCreateBuffer(); + _wglBindBuffer(_wGL_ARRAY_BUFFER, vbo); + _wglBufferData0(_wGL_ARRAY_BUFFER, upload, _wGL_STATIC_DRAW); + + ShaderGL vert = _wglCreateShader(_wGL_VERTEX_SHADER); + _wglShaderSource(vert, _wgetShaderHeader()+"\nprecision lowp float; in vec2 a_pos; out vec2 v_pos; void main() { gl_Position = vec4(((v_pos = a_pos) - 0.5) * vec2(2.0, -2.0), 0.0, 1.0); }"); + _wglCompileShader(vert); + + ShaderGL frag = _wglCreateShader(_wGL_FRAGMENT_SHADER); + _wglShaderSource(frag, _wgetShaderHeader()+"\nprecision lowp float; in vec2 v_pos; out vec4 fragColor; uniform sampler2D tex; uniform vec2 aspect; void main() { fragColor = vec4(texture(tex, clamp(v_pos * aspect - ((aspect - 1.0) * 0.5), 0.02, 0.98)).rgb, 1.0); }"); + _wglCompileShader(frag); + + program = _wglCreateProgram(); + + _wglAttachShader(program, vert); + _wglAttachShader(program, frag); + _wglBindAttributeLocation(program, 0, "a_pos"); + _wglLinkProgram(program); + _wglDetachShader(program, vert); + _wglDetachShader(program, frag); + _wglDeleteShader(vert); + _wglDeleteShader(frag); + + try { + Thread.sleep(50l); + } catch (InterruptedException e) { + e.printStackTrace(); + } + + _wglUseProgram(program); + _wglUniform1i(_wglGetUniformLocation(program, "tex"), 0); + + int width = getCanvasWidth(); + int height = getCanvasHeight(); + float x, y; + if(width > height) { + x = (float)width / (float)height; + y = 1.0f; + }else { + x = 1.0f; + y = (float)height / (float)width; + } + + _wglActiveTexture(_wGL_TEXTURE0); + glBindTexture(_wGL_TEXTURE_2D, tex); + + _wglViewport(0, 0, width, height); + _wglClearColor(1.0f, 1.0f, 1.0f, 1.0f); + _wglClear(_wGL_COLOR_BUFFER_BIT | _wGL_DEPTH_BUFFER_BIT); + + _wglUniform2f(_wglGetUniformLocation(program, "aspect"), x, y); + + BufferArrayGL vao = _wglCreateVertexArray(); + _wglBindVertexArray0(vao); + _wglEnableVertexAttribArray(0); + _wglVertexAttribPointer(0, 2, _wGL_FLOAT, false, 8, 0); + _wglDrawArrays(_wGL_TRIANGLES, 0, 6); + _wglDisableVertexAttribArray(0); + _wglFlush(); + updateDisplay(); + + _wglUseProgram(null); + _wglBindBuffer(_wGL_ARRAY_BUFFER, null); + glBindTexture(_wGL_TEXTURE_2D, null); + _wglDeleteTextures(tex); + _wglDeleteVertexArray(vao); + } + + public static void paintEnable() { + + TextureGL tex = _wglGenTextures(); + glActiveTexture(GL_TEXTURE0); + glBindTexture(_wGL_TEXTURE_2D, tex); + _wglTexParameteri(_wGL_TEXTURE_2D, _wGL_TEXTURE_MAG_FILTER, _wGL_NEAREST); + _wglTexParameteri(_wGL_TEXTURE_2D, _wGL_TEXTURE_MIN_FILTER, _wGL_NEAREST); + _wglTexParameteri(_wGL_TEXTURE_2D, _wGL_TEXTURE_WRAP_S, _wGL_CLAMP); + _wglTexParameteri(_wGL_TEXTURE_2D, _wGL_TEXTURE_WRAP_T, _wGL_CLAMP); + BufferedImage img = loadPNG(Base64.decodeBase64(enableScreen)); + IntBuffer upload = BufferUtils.createIntBuffer(128*128); + upload.put(img.getData()); + upload.flip(); + _wglTexImage2D(_wGL_TEXTURE_2D, 0, _wGL_RGBA, 128, 128, 0, _wGL_RGBA, _wGL_UNSIGNED_BYTE, upload); + + try { + Thread.sleep(50l); + } catch (InterruptedException e) { + e.printStackTrace(); + } + + _wglUseProgram(program); + + int width = getCanvasWidth(); + int height = getCanvasHeight(); + float x, y; + if(width > height) { + x = (float)width / (float)height; + y = 1.0f; + }else { + x = 1.0f; + y = (float)height / (float)width; + } + + glActiveTexture(GL_TEXTURE0); + glBindTexture(_wGL_TEXTURE_2D, tex); + + _wglViewport(0, 0, width, height); + _wglClearColor(1.0f, 1.0f, 1.0f, 1.0f); + _wglClear(_wGL_COLOR_BUFFER_BIT | _wGL_DEPTH_BUFFER_BIT); + + _wglUniform2f(_wglGetUniformLocation(program, "aspect"), x, y); + + BufferArrayGL vao = _wglCreateVertexArray(); + _wglBindVertexArray0(vao); + _wglBindBuffer(_wGL_ARRAY_BUFFER, vbo); + _wglEnableVertexAttribArray(0); + _wglVertexAttribPointer(0, 2, _wGL_FLOAT, false, 8, 0); + _wglDrawArrays(_wGL_TRIANGLES, 0, 6); + _wglDisableVertexAttribArray(0); + _wglFlush(); + updateDisplay(); + + _wglUseProgram(null); + _wglBindBuffer(_wGL_ARRAY_BUFFER, null); + glBindTexture(_wGL_TEXTURE_2D, null); + _wglDeleteTextures(tex); + _wglDeleteVertexArray(vao); + + } + } + + public static InputStream getResourceAsStream(String string) { + return ImageIO.getResourceAsStream(string); + } + + public static void glBindTexture(int texture) { + glBindTexture(GL_TEXTURE_2D, texture); + } + public static BufferedImage getResource(String string) { - return loadPNG(loadResourceBytes(string)); + return ImageIO.getResource(string); } - -} +} \ No newline at end of file diff --git a/src/org/lwjgl/opengl/GL12.java b/src/org/lwjgl/opengl/GL12.java index 4f1454e..078a318 100644 --- a/src/org/lwjgl/opengl/GL12.java +++ b/src/org/lwjgl/opengl/GL12.java @@ -1,5 +1,5 @@ package org.lwjgl.opengl; -public class GL12 extends net.PeytonPlayz585.opengl.GL11 { +public class GL12 extends GL11 { } diff --git a/src/org/lwjgl/opengl/GL13.java b/src/org/lwjgl/opengl/GL13.java new file mode 100644 index 0000000..779c61b --- /dev/null +++ b/src/org/lwjgl/opengl/GL13.java @@ -0,0 +1,5 @@ +package org.lwjgl.opengl; + +public class GL13 extends GL12 { + +} diff --git a/src/org/lwjgl/util/glu/GLU.java b/src/org/lwjgl/util/glu/GLU.java index f0f504b..ce042ec 100644 --- a/src/org/lwjgl/util/glu/GLU.java +++ b/src/org/lwjgl/util/glu/GLU.java @@ -1,7 +1,21 @@ package org.lwjgl.util.glu; +import java.nio.FloatBuffer; +import java.nio.IntBuffer; + import org.lwjgl.opengl.GL11; -public class GLU extends GL11 { - +public class GLU { + + public static final void gluUnProject(float p1, float p2, float p3, FloatBuffer p4, FloatBuffer p5, int[] p6, FloatBuffer p7) { + GL11.gluUnProject(p1, p2, p3, p4, p5, p6, p7); + } + + public static final void gluPerspective(float fovy, float aspect, float zNear, float zFar) { + GL11.gluPerspective(fovy, aspect, zNear, zFar); + } + + public static final String gluErrorString(int p1) { + return GL11.gluErrorString(p1); + } } diff --git a/src/org/lwjgl/util/vector/Matrix.java b/src/org/lwjgl/util/vector/Matrix.java new file mode 100644 index 0000000..f7d6608 --- /dev/null +++ b/src/org/lwjgl/util/vector/Matrix.java @@ -0,0 +1,31 @@ +package org.lwjgl.util.vector; + +import java.io.Serializable; +import java.nio.FloatBuffer; + +public abstract class Matrix implements Serializable { + + protected Matrix() { + super(); + } + + public abstract Matrix setIdentity(); + + public abstract Matrix invert(); + + public abstract Matrix load(FloatBuffer buf); + + public abstract Matrix loadTranspose(FloatBuffer buf); + + public abstract Matrix negate(); + + public abstract Matrix store(FloatBuffer buf); + + public abstract Matrix storeTranspose(FloatBuffer buf); + + public abstract Matrix transpose(); + + public abstract Matrix setZero(); + + public abstract float determinant(); +} \ No newline at end of file diff --git a/src/net/PeytonPlayz585/glemu/vector/Matrix4f.java b/src/org/lwjgl/util/vector/Matrix4f.java similarity index 52% rename from src/net/PeytonPlayz585/glemu/vector/Matrix4f.java rename to src/org/lwjgl/util/vector/Matrix4f.java index cddcf62..0f17707 100644 --- a/src/net/PeytonPlayz585/glemu/vector/Matrix4f.java +++ b/src/org/lwjgl/util/vector/Matrix4f.java @@ -1,923 +1,608 @@ -/* - * Copyright (c) 2002-2008 LWJGL Project - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are - * met: - * - * * Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * - * * Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in the - * documentation and/or other materials provided with the distribution. - * - * * Neither the name of 'LWJGL' nor the names of - * its contributors may be used to endorse or promote products derived - * from this software without specific prior written permission. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS - * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED - * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR - * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR - * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, - * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, - * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR - * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF - * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING - * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS - * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - */ -package net.PeytonPlayz585.glemu.vector; - -import java.io.Serializable; -import java.nio.FloatBuffer; - -/** - * Holds a 4x4 float matrix. - * - * @author foo - */ -public class Matrix4f extends Matrix implements Serializable { - private static final long serialVersionUID = 1L; - - public float m00, m01, m02, m03, m10, m11, m12, m13, m20, m21, m22, m23, m30, m31, m32, m33; - - /** - * Construct a new matrix, initialized to the identity. - */ - public Matrix4f() { - super(); - setIdentity(); - } - - public Matrix4f(final Matrix4f src) { - super(); - load(src); - } - - /** - * Returns a string representation of this matrix - */ - public String toString() { - StringBuilder buf = new StringBuilder(); - buf.append(m00).append(' ').append(m10).append(' ').append(m20).append(' ').append(m30).append('\n'); - buf.append(m01).append(' ').append(m11).append(' ').append(m21).append(' ').append(m31).append('\n'); - buf.append(m02).append(' ').append(m12).append(' ').append(m22).append(' ').append(m32).append('\n'); - buf.append(m03).append(' ').append(m13).append(' ').append(m23).append(' ').append(m33).append('\n'); - return buf.toString(); - } - - /** - * Set this matrix to be the identity matrix. - * - * @return this - */ - public Matrix setIdentity() { - return setIdentity(this); - } - - /** - * Set the given matrix to be the identity matrix. - * - * @param m The matrix to set to the identity - * @return m - */ - public static Matrix4f setIdentity(Matrix4f m) { - m.m00 = 1.0f; - m.m01 = 0.0f; - m.m02 = 0.0f; - m.m03 = 0.0f; - m.m10 = 0.0f; - m.m11 = 1.0f; - m.m12 = 0.0f; - m.m13 = 0.0f; - m.m20 = 0.0f; - m.m21 = 0.0f; - m.m22 = 1.0f; - m.m23 = 0.0f; - m.m30 = 0.0f; - m.m31 = 0.0f; - m.m32 = 0.0f; - m.m33 = 1.0f; - - return m; - } - - /** - * Set this matrix to 0. - * - * @return this - */ - public Matrix setZero() { - return setZero(this); - } - - /** - * Set the given matrix to 0. - * - * @param m The matrix to set to 0 - * @return m - */ - public static Matrix4f setZero(Matrix4f m) { - m.m00 = 0.0f; - m.m01 = 0.0f; - m.m02 = 0.0f; - m.m03 = 0.0f; - m.m10 = 0.0f; - m.m11 = 0.0f; - m.m12 = 0.0f; - m.m13 = 0.0f; - m.m20 = 0.0f; - m.m21 = 0.0f; - m.m22 = 0.0f; - m.m23 = 0.0f; - m.m30 = 0.0f; - m.m31 = 0.0f; - m.m32 = 0.0f; - m.m33 = 0.0f; - - return m; - } - - /** - * Load from another matrix4f - * - * @param src The source matrix - * @return this - */ - public Matrix4f load(Matrix4f src) { - return load(src, this); - } - - /** - * Copy the source matrix to the destination matrix - * - * @param src The source matrix - * @param dest The destination matrix, or null of a new one is to be created - * @return The copied matrix - */ - public static Matrix4f load(Matrix4f src, Matrix4f dest) { - if (dest == null) - dest = new Matrix4f(); - dest.m00 = src.m00; - dest.m01 = src.m01; - dest.m02 = src.m02; - dest.m03 = src.m03; - dest.m10 = src.m10; - dest.m11 = src.m11; - dest.m12 = src.m12; - dest.m13 = src.m13; - dest.m20 = src.m20; - dest.m21 = src.m21; - dest.m22 = src.m22; - dest.m23 = src.m23; - dest.m30 = src.m30; - dest.m31 = src.m31; - dest.m32 = src.m32; - dest.m33 = src.m33; - - return dest; - } - - /** - * Load from a float buffer. The buffer stores the matrix in column major - * (OpenGL) order. - * - * @param buf A float buffer to read from - * @return this - */ - public Matrix load(FloatBuffer buf) { - - m00 = buf.get(); - m01 = buf.get(); - m02 = buf.get(); - m03 = buf.get(); - m10 = buf.get(); - m11 = buf.get(); - m12 = buf.get(); - m13 = buf.get(); - m20 = buf.get(); - m21 = buf.get(); - m22 = buf.get(); - m23 = buf.get(); - m30 = buf.get(); - m31 = buf.get(); - m32 = buf.get(); - m33 = buf.get(); - - return this; - } - - /** - * Load from a float buffer. The buffer stores the matrix in row major (maths) - * order. - * - * @param buf A float buffer to read from - * @return this - */ - public Matrix loadTranspose(FloatBuffer buf) { - - m00 = buf.get(); - m10 = buf.get(); - m20 = buf.get(); - m30 = buf.get(); - m01 = buf.get(); - m11 = buf.get(); - m21 = buf.get(); - m31 = buf.get(); - m02 = buf.get(); - m12 = buf.get(); - m22 = buf.get(); - m32 = buf.get(); - m03 = buf.get(); - m13 = buf.get(); - m23 = buf.get(); - m33 = buf.get(); - - return this; - } - - /** - * Store this matrix in a float buffer. The matrix is stored in column major - * (openGL) order. - * - * @param buf The buffer to store this matrix in - */ - public Matrix store(FloatBuffer buf) { - buf.put(m00); - buf.put(m01); - buf.put(m02); - buf.put(m03); - buf.put(m10); - buf.put(m11); - buf.put(m12); - buf.put(m13); - buf.put(m20); - buf.put(m21); - buf.put(m22); - buf.put(m23); - buf.put(m30); - buf.put(m31); - buf.put(m32); - buf.put(m33); - return this; - } - - public Matrix store(float[] buf) { - buf[0] = m00; - buf[1] = m01; - buf[2] = m02; - buf[3] = m03; - buf[4] = m10; - buf[5] = m11; - buf[6] = m12; - buf[7] = m13; - buf[8] = m20; - buf[9] = m21; - buf[10] = m22; - buf[11] = m23; - buf[12] = m30; - buf[13] = m31; - buf[14] = m32; - buf[15] = m33; - return this; - } - - public float[] get() { - float[] buf = new float[15]; - buf[0] = m00; - buf[1] = m01; - buf[2] = m02; - buf[3] = m03; - buf[4] = m10; - buf[5] = m11; - buf[6] = m12; - buf[7] = m13; - buf[8] = m20; - buf[9] = m21; - buf[10] = m22; - buf[11] = m23; - buf[12] = m30; - buf[13] = m31; - buf[14] = m32; - buf[15] = m33; - return buf; - } - - /** - * Store this matrix in a float buffer. The matrix is stored in row major - * (maths) order. - * - * @param buf The buffer to store this matrix in - */ - public Matrix storeTranspose(FloatBuffer buf) { - buf.put(m00); - buf.put(m10); - buf.put(m20); - buf.put(m30); - buf.put(m01); - buf.put(m11); - buf.put(m21); - buf.put(m31); - buf.put(m02); - buf.put(m12); - buf.put(m22); - buf.put(m32); - buf.put(m03); - buf.put(m13); - buf.put(m23); - buf.put(m33); - return this; - } - - /** - * Store the rotation portion of this matrix in a float buffer. The matrix is - * stored in column major (openGL) order. - * - * @param buf The buffer to store this matrix in - */ - public Matrix store3f(FloatBuffer buf) { - buf.put(m00); - buf.put(m01); - buf.put(m02); - buf.put(m10); - buf.put(m11); - buf.put(m12); - buf.put(m20); - buf.put(m21); - buf.put(m22); - return this; - } - - /** - * Add two matrices together and place the result in a third matrix. - * - * @param left The left source matrix - * @param right The right source matrix - * @param dest The destination matrix, or null if a new one is to be created - * @return the destination matrix - */ - public static Matrix4f add(Matrix4f left, Matrix4f right, Matrix4f dest) { - if (dest == null) - dest = new Matrix4f(); - - dest.m00 = left.m00 + right.m00; - dest.m01 = left.m01 + right.m01; - dest.m02 = left.m02 + right.m02; - dest.m03 = left.m03 + right.m03; - dest.m10 = left.m10 + right.m10; - dest.m11 = left.m11 + right.m11; - dest.m12 = left.m12 + right.m12; - dest.m13 = left.m13 + right.m13; - dest.m20 = left.m20 + right.m20; - dest.m21 = left.m21 + right.m21; - dest.m22 = left.m22 + right.m22; - dest.m23 = left.m23 + right.m23; - dest.m30 = left.m30 + right.m30; - dest.m31 = left.m31 + right.m31; - dest.m32 = left.m32 + right.m32; - dest.m33 = left.m33 + right.m33; - - return dest; - } - - /** - * Subtract the right matrix from the left and place the result in a third - * matrix. - * - * @param left The left source matrix - * @param right The right source matrix - * @param dest The destination matrix, or null if a new one is to be created - * @return the destination matrix - */ - public static Matrix4f sub(Matrix4f left, Matrix4f right, Matrix4f dest) { - if (dest == null) - dest = new Matrix4f(); - - dest.m00 = left.m00 - right.m00; - dest.m01 = left.m01 - right.m01; - dest.m02 = left.m02 - right.m02; - dest.m03 = left.m03 - right.m03; - dest.m10 = left.m10 - right.m10; - dest.m11 = left.m11 - right.m11; - dest.m12 = left.m12 - right.m12; - dest.m13 = left.m13 - right.m13; - dest.m20 = left.m20 - right.m20; - dest.m21 = left.m21 - right.m21; - dest.m22 = left.m22 - right.m22; - dest.m23 = left.m23 - right.m23; - dest.m30 = left.m30 - right.m30; - dest.m31 = left.m31 - right.m31; - dest.m32 = left.m32 - right.m32; - dest.m33 = left.m33 - right.m33; - - return dest; - } - - /** - * Multiply the right matrix by the left and place the result in a third matrix. - * - * @param left The left source matrix - * @param right The right source matrix - * @param dest The destination matrix, or null if a new one is to be created - * @return the destination matrix - */ - public static Matrix4f mul(Matrix4f left, Matrix4f right, Matrix4f dest) { - if (dest == null) - dest = new Matrix4f(); - - float m00 = left.m00 * right.m00 + left.m10 * right.m01 + left.m20 * right.m02 + left.m30 * right.m03; - float m01 = left.m01 * right.m00 + left.m11 * right.m01 + left.m21 * right.m02 + left.m31 * right.m03; - float m02 = left.m02 * right.m00 + left.m12 * right.m01 + left.m22 * right.m02 + left.m32 * right.m03; - float m03 = left.m03 * right.m00 + left.m13 * right.m01 + left.m23 * right.m02 + left.m33 * right.m03; - float m10 = left.m00 * right.m10 + left.m10 * right.m11 + left.m20 * right.m12 + left.m30 * right.m13; - float m11 = left.m01 * right.m10 + left.m11 * right.m11 + left.m21 * right.m12 + left.m31 * right.m13; - float m12 = left.m02 * right.m10 + left.m12 * right.m11 + left.m22 * right.m12 + left.m32 * right.m13; - float m13 = left.m03 * right.m10 + left.m13 * right.m11 + left.m23 * right.m12 + left.m33 * right.m13; - float m20 = left.m00 * right.m20 + left.m10 * right.m21 + left.m20 * right.m22 + left.m30 * right.m23; - float m21 = left.m01 * right.m20 + left.m11 * right.m21 + left.m21 * right.m22 + left.m31 * right.m23; - float m22 = left.m02 * right.m20 + left.m12 * right.m21 + left.m22 * right.m22 + left.m32 * right.m23; - float m23 = left.m03 * right.m20 + left.m13 * right.m21 + left.m23 * right.m22 + left.m33 * right.m23; - float m30 = left.m00 * right.m30 + left.m10 * right.m31 + left.m20 * right.m32 + left.m30 * right.m33; - float m31 = left.m01 * right.m30 + left.m11 * right.m31 + left.m21 * right.m32 + left.m31 * right.m33; - float m32 = left.m02 * right.m30 + left.m12 * right.m31 + left.m22 * right.m32 + left.m32 * right.m33; - float m33 = left.m03 * right.m30 + left.m13 * right.m31 + left.m23 * right.m32 + left.m33 * right.m33; - - dest.m00 = m00; - dest.m01 = m01; - dest.m02 = m02; - dest.m03 = m03; - dest.m10 = m10; - dest.m11 = m11; - dest.m12 = m12; - dest.m13 = m13; - dest.m20 = m20; - dest.m21 = m21; - dest.m22 = m22; - dest.m23 = m23; - dest.m30 = m30; - dest.m31 = m31; - dest.m32 = m32; - dest.m33 = m33; - - return dest; - } - - /** - * Transform a Vector by a matrix and return the result in a destination vector. - * - * @param left The left matrix - * @param right The right vector - * @param dest The destination vector, or null if a new one is to be created - * @return the destination vector - */ - public static Vector4f transform(Matrix4f left, Vector4f right, Vector4f dest) { - if (dest == null) - dest = new Vector4f(); - - float x = left.m00 * right.x + left.m10 * right.y + left.m20 * right.z + left.m30 * right.w; - float y = left.m01 * right.x + left.m11 * right.y + left.m21 * right.z + left.m31 * right.w; - float z = left.m02 * right.x + left.m12 * right.y + left.m22 * right.z + left.m32 * right.w; - float w = left.m03 * right.x + left.m13 * right.y + left.m23 * right.z + left.m33 * right.w; - - dest.x = x; - dest.y = y; - dest.z = z; - dest.w = w; - - return dest; - } - - /** - * Transpose this matrix - * - * @return this - */ - public Matrix transpose() { - return transpose(this); - } - - /** - * Translate this matrix - * - * @param vec The vector to translate by - * @return this - */ - public Matrix4f translate(Vector2f vec) { - return translate(vec, this); - } - - /** - * Translate this matrix - * - * @param vec The vector to translate by - * @return this - */ - public Matrix4f translate(Vector3f vec) { - return translate(vec, this); - } - - /** - * Scales this matrix - * - * @param vec The vector to scale by - * @return this - */ - public Matrix4f scale(Vector3f vec) { - return scale(vec, this, this); - } - - /** - * Scales the source matrix and put the result in the destination matrix - * - * @param vec The vector to scale by - * @param src The source matrix - * @param dest The destination matrix, or null if a new matrix is to be created - * @return The scaled matrix - */ - public static Matrix4f scale(Vector3f vec, Matrix4f src, Matrix4f dest) { - if (dest == null) - dest = new Matrix4f(); - dest.m00 = src.m00 * vec.x; - dest.m01 = src.m01 * vec.x; - dest.m02 = src.m02 * vec.x; - dest.m03 = src.m03 * vec.x; - dest.m10 = src.m10 * vec.y; - dest.m11 = src.m11 * vec.y; - dest.m12 = src.m12 * vec.y; - dest.m13 = src.m13 * vec.y; - dest.m20 = src.m20 * vec.z; - dest.m21 = src.m21 * vec.z; - dest.m22 = src.m22 * vec.z; - dest.m23 = src.m23 * vec.z; - return dest; - } - - /** - * Rotates the matrix around the given axis the specified angle - * - * @param angle the angle, in radians. - * @param axis The vector representing the rotation axis. Must be normalized. - * @return this - */ - public Matrix4f rotate(float angle, Vector3f axis) { - return rotate(angle, axis, this); - } - - /** - * Rotates the matrix around the given axis the specified angle - * - * @param angle the angle, in radians. - * @param axis The vector representing the rotation axis. Must be normalized. - * @param dest The matrix to put the result, or null if a new matrix is to be - * created - * @return The rotated matrix - */ - public Matrix4f rotate(float angle, Vector3f axis, Matrix4f dest) { - return rotate(angle, axis, this, dest); - } - - /** - * Rotates the source matrix around the given axis the specified angle and put - * the result in the destination matrix. - * - * @param angle the angle, in radians. - * @param axis The vector representing the rotation axis. Must be normalized. - * @param src The matrix to rotate - * @param dest The matrix to put the result, or null if a new matrix is to be - * created - * @return The rotated matrix - */ - public static Matrix4f rotate(float angle, Vector3f axis, Matrix4f src, Matrix4f dest) { - if (dest == null) - dest = new Matrix4f(); - float c = (float) Math.cos(angle); - float s = (float) Math.sin(angle); - float oneminusc = 1.0f - c; - float xy = axis.x * axis.y; - float yz = axis.y * axis.z; - float xz = axis.x * axis.z; - float xs = axis.x * s; - float ys = axis.y * s; - float zs = axis.z * s; - - float f00 = axis.x * axis.x * oneminusc + c; - float f01 = xy * oneminusc + zs; - float f02 = xz * oneminusc - ys; - // n[3] not used - float f10 = xy * oneminusc - zs; - float f11 = axis.y * axis.y * oneminusc + c; - float f12 = yz * oneminusc + xs; - // n[7] not used - float f20 = xz * oneminusc + ys; - float f21 = yz * oneminusc - xs; - float f22 = axis.z * axis.z * oneminusc + c; - - float t00 = src.m00 * f00 + src.m10 * f01 + src.m20 * f02; - float t01 = src.m01 * f00 + src.m11 * f01 + src.m21 * f02; - float t02 = src.m02 * f00 + src.m12 * f01 + src.m22 * f02; - float t03 = src.m03 * f00 + src.m13 * f01 + src.m23 * f02; - float t10 = src.m00 * f10 + src.m10 * f11 + src.m20 * f12; - float t11 = src.m01 * f10 + src.m11 * f11 + src.m21 * f12; - float t12 = src.m02 * f10 + src.m12 * f11 + src.m22 * f12; - float t13 = src.m03 * f10 + src.m13 * f11 + src.m23 * f12; - dest.m20 = src.m00 * f20 + src.m10 * f21 + src.m20 * f22; - dest.m21 = src.m01 * f20 + src.m11 * f21 + src.m21 * f22; - dest.m22 = src.m02 * f20 + src.m12 * f21 + src.m22 * f22; - dest.m23 = src.m03 * f20 + src.m13 * f21 + src.m23 * f22; - dest.m00 = t00; - dest.m01 = t01; - dest.m02 = t02; - dest.m03 = t03; - dest.m10 = t10; - dest.m11 = t11; - dest.m12 = t12; - dest.m13 = t13; - return dest; - } - - /** - * Translate this matrix and stash the result in another matrix - * - * @param vec The vector to translate by - * @param dest The destination matrix or null if a new matrix is to be created - * @return the translated matrix - */ - public Matrix4f translate(Vector3f vec, Matrix4f dest) { - return translate(vec, this, dest); - } - - /** - * Translate the source matrix and stash the result in the destination matrix - * - * @param vec The vector to translate by - * @param src The source matrix - * @param dest The destination matrix or null if a new matrix is to be created - * @return The translated matrix - */ - public static Matrix4f translate(Vector3f vec, Matrix4f src, Matrix4f dest) { - if (dest == null) - dest = new Matrix4f(); - - dest.m30 += src.m00 * vec.x + src.m10 * vec.y + src.m20 * vec.z; - dest.m31 += src.m01 * vec.x + src.m11 * vec.y + src.m21 * vec.z; - dest.m32 += src.m02 * vec.x + src.m12 * vec.y + src.m22 * vec.z; - dest.m33 += src.m03 * vec.x + src.m13 * vec.y + src.m23 * vec.z; - - return dest; - } - - /** - * Translate this matrix and stash the result in another matrix - * - * @param vec The vector to translate by - * @param dest The destination matrix or null if a new matrix is to be created - * @return the translated matrix - */ - public Matrix4f translate(Vector2f vec, Matrix4f dest) { - return translate(vec, this, dest); - } - - /** - * Translate the source matrix and stash the result in the destination matrix - * - * @param vec The vector to translate by - * @param src The source matrix - * @param dest The destination matrix or null if a new matrix is to be created - * @return The translated matrix - */ - public static Matrix4f translate(Vector2f vec, Matrix4f src, Matrix4f dest) { - if (dest == null) - dest = new Matrix4f(); - - dest.m30 += src.m00 * vec.x + src.m10 * vec.y; - dest.m31 += src.m01 * vec.x + src.m11 * vec.y; - dest.m32 += src.m02 * vec.x + src.m12 * vec.y; - dest.m33 += src.m03 * vec.x + src.m13 * vec.y; - - return dest; - } - - /** - * Transpose this matrix and place the result in another matrix - * - * @param dest The destination matrix or null if a new matrix is to be created - * @return the transposed matrix - */ - public Matrix4f transpose(Matrix4f dest) { - return transpose(this, dest); - } - - /** - * Transpose the source matrix and place the result in the destination matrix - * - * @param src The source matrix - * @param dest The destination matrix or null if a new matrix is to be created - * @return the transposed matrix - */ - public static Matrix4f transpose(Matrix4f src, Matrix4f dest) { - if (dest == null) - dest = new Matrix4f(); - float m00 = src.m00; - float m01 = src.m10; - float m02 = src.m20; - float m03 = src.m30; - float m10 = src.m01; - float m11 = src.m11; - float m12 = src.m21; - float m13 = src.m31; - float m20 = src.m02; - float m21 = src.m12; - float m22 = src.m22; - float m23 = src.m32; - float m30 = src.m03; - float m31 = src.m13; - float m32 = src.m23; - float m33 = src.m33; - - dest.m00 = m00; - dest.m01 = m01; - dest.m02 = m02; - dest.m03 = m03; - dest.m10 = m10; - dest.m11 = m11; - dest.m12 = m12; - dest.m13 = m13; - dest.m20 = m20; - dest.m21 = m21; - dest.m22 = m22; - dest.m23 = m23; - dest.m30 = m30; - dest.m31 = m31; - dest.m32 = m32; - dest.m33 = m33; - - return dest; - } - - /** - * @return the determinant of the matrix - */ - public float determinant() { - float f = m00 * ((m11 * m22 * m33 + m12 * m23 * m31 + m13 * m21 * m32) - m13 * m22 * m31 - m11 * m23 * m32 - - m12 * m21 * m33); - f -= m01 * ((m10 * m22 * m33 + m12 * m23 * m30 + m13 * m20 * m32) - m13 * m22 * m30 - m10 * m23 * m32 - - m12 * m20 * m33); - f += m02 * ((m10 * m21 * m33 + m11 * m23 * m30 + m13 * m20 * m31) - m13 * m21 * m30 - m10 * m23 * m31 - - m11 * m20 * m33); - f -= m03 * ((m10 * m21 * m32 + m11 * m22 * m30 + m12 * m20 * m31) - m12 * m21 * m30 - m10 * m22 * m31 - - m11 * m20 * m32); - return f; - } - - /** - * Calculate the determinant of a 3x3 matrix - * - * @return result - */ - - private static float determinant3x3(float t00, float t01, float t02, float t10, float t11, float t12, float t20, - float t21, float t22) { - return t00 * (t11 * t22 - t12 * t21) + t01 * (t12 * t20 - t10 * t22) + t02 * (t10 * t21 - t11 * t20); - } - - /** - * Invert this matrix - * - * @return this if successful, null otherwise - */ - public Matrix invert() { - return invert(this, this); - } - - /** - * Invert the source matrix and put the result in the destination - * - * @param src The source matrix - * @param dest The destination matrix, or null if a new matrix is to be created - * @return The inverted matrix if successful, null otherwise - */ - public static Matrix4f invert(Matrix4f src, Matrix4f dest) { - float determinant = src.determinant(); - - if (determinant != 0) { - /* - * m00 m01 m02 m03 m10 m11 m12 m13 m20 m21 m22 m23 m30 m31 m32 m33 - */ - if (dest == null) - dest = new Matrix4f(); - float determinant_inv = 1f / determinant; - - // first row - float t00 = determinant3x3(src.m11, src.m12, src.m13, src.m21, src.m22, src.m23, src.m31, src.m32, src.m33); - float t01 = -determinant3x3(src.m10, src.m12, src.m13, src.m20, src.m22, src.m23, src.m30, src.m32, - src.m33); - float t02 = determinant3x3(src.m10, src.m11, src.m13, src.m20, src.m21, src.m23, src.m30, src.m31, src.m33); - float t03 = -determinant3x3(src.m10, src.m11, src.m12, src.m20, src.m21, src.m22, src.m30, src.m31, - src.m32); - // second row - float t10 = -determinant3x3(src.m01, src.m02, src.m03, src.m21, src.m22, src.m23, src.m31, src.m32, - src.m33); - float t11 = determinant3x3(src.m00, src.m02, src.m03, src.m20, src.m22, src.m23, src.m30, src.m32, src.m33); - float t12 = -determinant3x3(src.m00, src.m01, src.m03, src.m20, src.m21, src.m23, src.m30, src.m31, - src.m33); - float t13 = determinant3x3(src.m00, src.m01, src.m02, src.m20, src.m21, src.m22, src.m30, src.m31, src.m32); - // third row - float t20 = determinant3x3(src.m01, src.m02, src.m03, src.m11, src.m12, src.m13, src.m31, src.m32, src.m33); - float t21 = -determinant3x3(src.m00, src.m02, src.m03, src.m10, src.m12, src.m13, src.m30, src.m32, - src.m33); - float t22 = determinant3x3(src.m00, src.m01, src.m03, src.m10, src.m11, src.m13, src.m30, src.m31, src.m33); - float t23 = -determinant3x3(src.m00, src.m01, src.m02, src.m10, src.m11, src.m12, src.m30, src.m31, - src.m32); - // fourth row - float t30 = -determinant3x3(src.m01, src.m02, src.m03, src.m11, src.m12, src.m13, src.m21, src.m22, - src.m23); - float t31 = determinant3x3(src.m00, src.m02, src.m03, src.m10, src.m12, src.m13, src.m20, src.m22, src.m23); - float t32 = -determinant3x3(src.m00, src.m01, src.m03, src.m10, src.m11, src.m13, src.m20, src.m21, - src.m23); - float t33 = determinant3x3(src.m00, src.m01, src.m02, src.m10, src.m11, src.m12, src.m20, src.m21, src.m22); - - // transpose and divide by the determinant - dest.m00 = t00 * determinant_inv; - dest.m11 = t11 * determinant_inv; - dest.m22 = t22 * determinant_inv; - dest.m33 = t33 * determinant_inv; - dest.m01 = t10 * determinant_inv; - dest.m10 = t01 * determinant_inv; - dest.m20 = t02 * determinant_inv; - dest.m02 = t20 * determinant_inv; - dest.m12 = t21 * determinant_inv; - dest.m21 = t12 * determinant_inv; - dest.m03 = t30 * determinant_inv; - dest.m30 = t03 * determinant_inv; - dest.m13 = t31 * determinant_inv; - dest.m31 = t13 * determinant_inv; - dest.m32 = t23 * determinant_inv; - dest.m23 = t32 * determinant_inv; - return dest; - } else - return null; - } - - /** - * Negate this matrix - * - * @return this - */ - public Matrix negate() { - return negate(this); - } - - /** - * Negate this matrix and place the result in a destination matrix. - * - * @param dest The destination matrix, or null if a new matrix is to be created - * @return the negated matrix - */ - public Matrix4f negate(Matrix4f dest) { - return negate(this, dest); - } - - /** - * Negate this matrix and place the result in a destination matrix. - * - * @param src The source matrix - * @param dest The destination matrix, or null if a new matrix is to be created - * @return The negated matrix - */ - public static Matrix4f negate(Matrix4f src, Matrix4f dest) { - if (dest == null) - dest = new Matrix4f(); - - dest.m00 = -src.m00; - dest.m01 = -src.m01; - dest.m02 = -src.m02; - dest.m03 = -src.m03; - dest.m10 = -src.m10; - dest.m11 = -src.m11; - dest.m12 = -src.m12; - dest.m13 = -src.m13; - dest.m20 = -src.m20; - dest.m21 = -src.m21; - dest.m22 = -src.m22; - dest.m23 = -src.m23; - dest.m30 = -src.m30; - dest.m31 = -src.m31; - dest.m32 = -src.m32; - dest.m33 = -src.m33; - - return dest; - } - - public boolean equals(Object m) { - return (m instanceof Matrix4f) && equal(this, (Matrix4f) m); - } - - public static boolean equal(Matrix4f a, Matrix4f b) { - return a.m00 == b.m00 && a.m01 == b.m01 && a.m02 == b.m02 && a.m03 == b.m03 && a.m10 == b.m10 && a.m11 == b.m11 - && a.m12 == b.m12 && a.m13 == b.m13 && a.m20 == b.m20 && a.m21 == b.m21 && a.m22 == b.m22 - && a.m23 == b.m23 && a.m30 == b.m30 && a.m31 == b.m31 && a.m32 == b.m32 && a.m33 == b.m33; - } -} +package org.lwjgl.util.vector; + +import java.io.Serializable; +import java.nio.FloatBuffer; + +public class Matrix4f extends Matrix implements Serializable { + private static final long serialVersionUID = 1L; + + public float m00, m01, m02, m03, m10, m11, m12, m13, m20, m21, m22, m23, m30, m31, m32, m33; + + public Matrix4f() { + super(); + setIdentity(); + } + + public Matrix4f(final Matrix4f src) { + super(); + load(src); + } + + public String toString() { + StringBuilder buf = new StringBuilder(); + buf.append(m00).append(' ').append(m10).append(' ').append(m20).append(' ').append(m30).append('\n'); + buf.append(m01).append(' ').append(m11).append(' ').append(m21).append(' ').append(m31).append('\n'); + buf.append(m02).append(' ').append(m12).append(' ').append(m22).append(' ').append(m32).append('\n'); + buf.append(m03).append(' ').append(m13).append(' ').append(m23).append(' ').append(m33).append('\n'); + return buf.toString(); + } + + public Matrix setIdentity() { + return setIdentity(this); + } + + public static Matrix4f setIdentity(Matrix4f m) { + m.m00 = 1.0f; + m.m01 = 0.0f; + m.m02 = 0.0f; + m.m03 = 0.0f; + m.m10 = 0.0f; + m.m11 = 1.0f; + m.m12 = 0.0f; + m.m13 = 0.0f; + m.m20 = 0.0f; + m.m21 = 0.0f; + m.m22 = 1.0f; + m.m23 = 0.0f; + m.m30 = 0.0f; + m.m31 = 0.0f; + m.m32 = 0.0f; + m.m33 = 1.0f; + + return m; + } + + public Matrix setZero() { + return setZero(this); + } + + public static Matrix4f setZero(Matrix4f m) { + m.m00 = 0.0f; + m.m01 = 0.0f; + m.m02 = 0.0f; + m.m03 = 0.0f; + m.m10 = 0.0f; + m.m11 = 0.0f; + m.m12 = 0.0f; + m.m13 = 0.0f; + m.m20 = 0.0f; + m.m21 = 0.0f; + m.m22 = 0.0f; + m.m23 = 0.0f; + m.m30 = 0.0f; + m.m31 = 0.0f; + m.m32 = 0.0f; + m.m33 = 0.0f; + + return m; + } + + public Matrix4f load(Matrix4f src) { + return load(src, this); + } + + public static Matrix4f load(Matrix4f src, Matrix4f dest) { + if (dest == null) + dest = new Matrix4f(); + dest.m00 = src.m00; + dest.m01 = src.m01; + dest.m02 = src.m02; + dest.m03 = src.m03; + dest.m10 = src.m10; + dest.m11 = src.m11; + dest.m12 = src.m12; + dest.m13 = src.m13; + dest.m20 = src.m20; + dest.m21 = src.m21; + dest.m22 = src.m22; + dest.m23 = src.m23; + dest.m30 = src.m30; + dest.m31 = src.m31; + dest.m32 = src.m32; + dest.m33 = src.m33; + + return dest; + } + + public Matrix load(FloatBuffer buf) { + + m00 = buf.get(); + m01 = buf.get(); + m02 = buf.get(); + m03 = buf.get(); + m10 = buf.get(); + m11 = buf.get(); + m12 = buf.get(); + m13 = buf.get(); + m20 = buf.get(); + m21 = buf.get(); + m22 = buf.get(); + m23 = buf.get(); + m30 = buf.get(); + m31 = buf.get(); + m32 = buf.get(); + m33 = buf.get(); + + return this; + } + + public Matrix loadTranspose(FloatBuffer buf) { + + m00 = buf.get(); + m10 = buf.get(); + m20 = buf.get(); + m30 = buf.get(); + m01 = buf.get(); + m11 = buf.get(); + m21 = buf.get(); + m31 = buf.get(); + m02 = buf.get(); + m12 = buf.get(); + m22 = buf.get(); + m32 = buf.get(); + m03 = buf.get(); + m13 = buf.get(); + m23 = buf.get(); + m33 = buf.get(); + + return this; + } + + public Matrix store(FloatBuffer buf) { + buf.put(m00); + buf.put(m01); + buf.put(m02); + buf.put(m03); + buf.put(m10); + buf.put(m11); + buf.put(m12); + buf.put(m13); + buf.put(m20); + buf.put(m21); + buf.put(m22); + buf.put(m23); + buf.put(m30); + buf.put(m31); + buf.put(m32); + buf.put(m33); + return this; + } + + public Matrix store(float[] buf) { + buf[0] = m00; + buf[1] = m01; + buf[2] = m02; + buf[3] = m03; + buf[4] = m10; + buf[5] = m11; + buf[6] = m12; + buf[7] = m13; + buf[8] = m20; + buf[9] = m21; + buf[10] = m22; + buf[11] = m23; + buf[12] = m30; + buf[13] = m31; + buf[14] = m32; + buf[15] = m33; + return this; + } + + public Matrix storeTranspose(FloatBuffer buf) { + buf.put(m00); + buf.put(m10); + buf.put(m20); + buf.put(m30); + buf.put(m01); + buf.put(m11); + buf.put(m21); + buf.put(m31); + buf.put(m02); + buf.put(m12); + buf.put(m22); + buf.put(m32); + buf.put(m03); + buf.put(m13); + buf.put(m23); + buf.put(m33); + return this; + } + + public Matrix store3f(FloatBuffer buf) { + buf.put(m00); + buf.put(m01); + buf.put(m02); + buf.put(m10); + buf.put(m11); + buf.put(m12); + buf.put(m20); + buf.put(m21); + buf.put(m22); + return this; + } + + public static Matrix4f add(Matrix4f left, Matrix4f right, Matrix4f dest) { + if (dest == null) + dest = new Matrix4f(); + + dest.m00 = left.m00 + right.m00; + dest.m01 = left.m01 + right.m01; + dest.m02 = left.m02 + right.m02; + dest.m03 = left.m03 + right.m03; + dest.m10 = left.m10 + right.m10; + dest.m11 = left.m11 + right.m11; + dest.m12 = left.m12 + right.m12; + dest.m13 = left.m13 + right.m13; + dest.m20 = left.m20 + right.m20; + dest.m21 = left.m21 + right.m21; + dest.m22 = left.m22 + right.m22; + dest.m23 = left.m23 + right.m23; + dest.m30 = left.m30 + right.m30; + dest.m31 = left.m31 + right.m31; + dest.m32 = left.m32 + right.m32; + dest.m33 = left.m33 + right.m33; + + return dest; + } + + public static Matrix4f sub(Matrix4f left, Matrix4f right, Matrix4f dest) { + if (dest == null) + dest = new Matrix4f(); + + dest.m00 = left.m00 - right.m00; + dest.m01 = left.m01 - right.m01; + dest.m02 = left.m02 - right.m02; + dest.m03 = left.m03 - right.m03; + dest.m10 = left.m10 - right.m10; + dest.m11 = left.m11 - right.m11; + dest.m12 = left.m12 - right.m12; + dest.m13 = left.m13 - right.m13; + dest.m20 = left.m20 - right.m20; + dest.m21 = left.m21 - right.m21; + dest.m22 = left.m22 - right.m22; + dest.m23 = left.m23 - right.m23; + dest.m30 = left.m30 - right.m30; + dest.m31 = left.m31 - right.m31; + dest.m32 = left.m32 - right.m32; + dest.m33 = left.m33 - right.m33; + + return dest; + } + + public static Matrix4f mul(Matrix4f left, Matrix4f right, Matrix4f dest) { + if (dest == null) + dest = new Matrix4f(); + + float m00 = left.m00 * right.m00 + left.m10 * right.m01 + left.m20 * right.m02 + left.m30 * right.m03; + float m01 = left.m01 * right.m00 + left.m11 * right.m01 + left.m21 * right.m02 + left.m31 * right.m03; + float m02 = left.m02 * right.m00 + left.m12 * right.m01 + left.m22 * right.m02 + left.m32 * right.m03; + float m03 = left.m03 * right.m00 + left.m13 * right.m01 + left.m23 * right.m02 + left.m33 * right.m03; + float m10 = left.m00 * right.m10 + left.m10 * right.m11 + left.m20 * right.m12 + left.m30 * right.m13; + float m11 = left.m01 * right.m10 + left.m11 * right.m11 + left.m21 * right.m12 + left.m31 * right.m13; + float m12 = left.m02 * right.m10 + left.m12 * right.m11 + left.m22 * right.m12 + left.m32 * right.m13; + float m13 = left.m03 * right.m10 + left.m13 * right.m11 + left.m23 * right.m12 + left.m33 * right.m13; + float m20 = left.m00 * right.m20 + left.m10 * right.m21 + left.m20 * right.m22 + left.m30 * right.m23; + float m21 = left.m01 * right.m20 + left.m11 * right.m21 + left.m21 * right.m22 + left.m31 * right.m23; + float m22 = left.m02 * right.m20 + left.m12 * right.m21 + left.m22 * right.m22 + left.m32 * right.m23; + float m23 = left.m03 * right.m20 + left.m13 * right.m21 + left.m23 * right.m22 + left.m33 * right.m23; + float m30 = left.m00 * right.m30 + left.m10 * right.m31 + left.m20 * right.m32 + left.m30 * right.m33; + float m31 = left.m01 * right.m30 + left.m11 * right.m31 + left.m21 * right.m32 + left.m31 * right.m33; + float m32 = left.m02 * right.m30 + left.m12 * right.m31 + left.m22 * right.m32 + left.m32 * right.m33; + float m33 = left.m03 * right.m30 + left.m13 * right.m31 + left.m23 * right.m32 + left.m33 * right.m33; + + dest.m00 = m00; + dest.m01 = m01; + dest.m02 = m02; + dest.m03 = m03; + dest.m10 = m10; + dest.m11 = m11; + dest.m12 = m12; + dest.m13 = m13; + dest.m20 = m20; + dest.m21 = m21; + dest.m22 = m22; + dest.m23 = m23; + dest.m30 = m30; + dest.m31 = m31; + dest.m32 = m32; + dest.m33 = m33; + + return dest; + } + + public static Vector4f transform(Matrix4f left, Vector4f right, Vector4f dest) { + if (dest == null) + dest = new Vector4f(); + + float x = left.m00 * right.x + left.m10 * right.y + left.m20 * right.z + left.m30 * right.w; + float y = left.m01 * right.x + left.m11 * right.y + left.m21 * right.z + left.m31 * right.w; + float z = left.m02 * right.x + left.m12 * right.y + left.m22 * right.z + left.m32 * right.w; + float w = left.m03 * right.x + left.m13 * right.y + left.m23 * right.z + left.m33 * right.w; + + dest.x = x; + dest.y = y; + dest.z = z; + dest.w = w; + + return dest; + } + + public Matrix transpose() { + return transpose(this); + } + + public Matrix4f translate(Vector2f vec) { + return translate(vec, this); + } + + public Matrix4f translate(Vector3f vec) { + return translate(vec, this); + } + + public Matrix4f scale(Vector3f vec) { + return scale(vec, this, this); + } + + public static Matrix4f scale(Vector3f vec, Matrix4f src, Matrix4f dest) { + if (dest == null) + dest = new Matrix4f(); + dest.m00 = src.m00 * vec.x; + dest.m01 = src.m01 * vec.x; + dest.m02 = src.m02 * vec.x; + dest.m03 = src.m03 * vec.x; + dest.m10 = src.m10 * vec.y; + dest.m11 = src.m11 * vec.y; + dest.m12 = src.m12 * vec.y; + dest.m13 = src.m13 * vec.y; + dest.m20 = src.m20 * vec.z; + dest.m21 = src.m21 * vec.z; + dest.m22 = src.m22 * vec.z; + dest.m23 = src.m23 * vec.z; + return dest; + } + + public Matrix4f rotate(float angle, Vector3f axis) { + return rotate(angle, axis, this); + } + + public Matrix4f rotate(float angle, Vector3f axis, Matrix4f dest) { + return rotate(angle, axis, this, dest); + } + + public static Matrix4f rotate(float angle, Vector3f axis, Matrix4f src, Matrix4f dest) { + if (dest == null) + dest = new Matrix4f(); + float c = (float) Math.cos(angle); + float s = (float) Math.sin(angle); + float oneminusc = 1.0f - c; + float xy = axis.x*axis.y; + float yz = axis.y*axis.z; + float xz = axis.x*axis.z; + float xs = axis.x*s; + float ys = axis.y*s; + float zs = axis.z*s; + + float f00 = axis.x*axis.x*oneminusc+c; + float f01 = xy*oneminusc+zs; + float f02 = xz*oneminusc-ys; + float f10 = xy*oneminusc-zs; + float f11 = axis.y*axis.y*oneminusc+c; + float f12 = yz*oneminusc+xs; + float f20 = xz*oneminusc+ys; + float f21 = yz*oneminusc-xs; + float f22 = axis.z*axis.z*oneminusc+c; + + float t00 = src.m00 * f00 + src.m10 * f01 + src.m20 * f02; + float t01 = src.m01 * f00 + src.m11 * f01 + src.m21 * f02; + float t02 = src.m02 * f00 + src.m12 * f01 + src.m22 * f02; + float t03 = src.m03 * f00 + src.m13 * f01 + src.m23 * f02; + float t10 = src.m00 * f10 + src.m10 * f11 + src.m20 * f12; + float t11 = src.m01 * f10 + src.m11 * f11 + src.m21 * f12; + float t12 = src.m02 * f10 + src.m12 * f11 + src.m22 * f12; + float t13 = src.m03 * f10 + src.m13 * f11 + src.m23 * f12; + dest.m20 = src.m00 * f20 + src.m10 * f21 + src.m20 * f22; + dest.m21 = src.m01 * f20 + src.m11 * f21 + src.m21 * f22; + dest.m22 = src.m02 * f20 + src.m12 * f21 + src.m22 * f22; + dest.m23 = src.m03 * f20 + src.m13 * f21 + src.m23 * f22; + dest.m00 = t00; + dest.m01 = t01; + dest.m02 = t02; + dest.m03 = t03; + dest.m10 = t10; + dest.m11 = t11; + dest.m12 = t12; + dest.m13 = t13; + return dest; + } + + public Matrix4f translate(Vector3f vec, Matrix4f dest) { + return translate(vec, this, dest); + } + + public static Matrix4f translate(Vector3f vec, Matrix4f src, Matrix4f dest) { + if (dest == null) + dest = new Matrix4f(); + + dest.m30 += src.m00 * vec.x + src.m10 * vec.y + src.m20 * vec.z; + dest.m31 += src.m01 * vec.x + src.m11 * vec.y + src.m21 * vec.z; + dest.m32 += src.m02 * vec.x + src.m12 * vec.y + src.m22 * vec.z; + dest.m33 += src.m03 * vec.x + src.m13 * vec.y + src.m23 * vec.z; + + return dest; + } + + public Matrix4f translate(Vector2f vec, Matrix4f dest) { + return translate(vec, this, dest); + } + + public static Matrix4f translate(Vector2f vec, Matrix4f src, Matrix4f dest) { + if (dest == null) + dest = new Matrix4f(); + + dest.m30 += src.m00 * vec.x + src.m10 * vec.y; + dest.m31 += src.m01 * vec.x + src.m11 * vec.y; + dest.m32 += src.m02 * vec.x + src.m12 * vec.y; + dest.m33 += src.m03 * vec.x + src.m13 * vec.y; + + return dest; + } + + public Matrix4f transpose(Matrix4f dest) { + return transpose(this, dest); + } + + public static Matrix4f transpose(Matrix4f src, Matrix4f dest) { + if (dest == null) + dest = new Matrix4f(); + float m00 = src.m00; + float m01 = src.m10; + float m02 = src.m20; + float m03 = src.m30; + float m10 = src.m01; + float m11 = src.m11; + float m12 = src.m21; + float m13 = src.m31; + float m20 = src.m02; + float m21 = src.m12; + float m22 = src.m22; + float m23 = src.m32; + float m30 = src.m03; + float m31 = src.m13; + float m32 = src.m23; + float m33 = src.m33; + + dest.m00 = m00; + dest.m01 = m01; + dest.m02 = m02; + dest.m03 = m03; + dest.m10 = m10; + dest.m11 = m11; + dest.m12 = m12; + dest.m13 = m13; + dest.m20 = m20; + dest.m21 = m21; + dest.m22 = m22; + dest.m23 = m23; + dest.m30 = m30; + dest.m31 = m31; + dest.m32 = m32; + dest.m33 = m33; + + return dest; + } + + public float determinant() { + float f = + m00 + * ((m11 * m22 * m33 + m12 * m23 * m31 + m13 * m21 * m32) + - m13 * m22 * m31 + - m11 * m23 * m32 + - m12 * m21 * m33); + f -= m01 + * ((m10 * m22 * m33 + m12 * m23 * m30 + m13 * m20 * m32) + - m13 * m22 * m30 + - m10 * m23 * m32 + - m12 * m20 * m33); + f += m02 + * ((m10 * m21 * m33 + m11 * m23 * m30 + m13 * m20 * m31) + - m13 * m21 * m30 + - m10 * m23 * m31 + - m11 * m20 * m33); + f -= m03 + * ((m10 * m21 * m32 + m11 * m22 * m30 + m12 * m20 * m31) + - m12 * m21 * m30 + - m10 * m22 * m31 + - m11 * m20 * m32); + return f; + } + + private static float determinant3x3(float t00, float t01, float t02, + float t10, float t11, float t12, + float t20, float t21, float t22) + { + return t00 * (t11 * t22 - t12 * t21) + + t01 * (t12 * t20 - t10 * t22) + + t02 * (t10 * t21 - t11 * t20); + } + + public Matrix invert() { + return invert(this, this); + } + + public static Matrix4f invert(Matrix4f src, Matrix4f dest) { + float determinant = src.determinant(); + + if (determinant != 0) { + if (dest == null) + dest = new Matrix4f(); + float determinant_inv = 1f/determinant; + float t00 = determinant3x3(src.m11, src.m12, src.m13, src.m21, src.m22, src.m23, src.m31, src.m32, src.m33); + float t01 = -determinant3x3(src.m10, src.m12, src.m13, src.m20, src.m22, src.m23, src.m30, src.m32, src.m33); + float t02 = determinant3x3(src.m10, src.m11, src.m13, src.m20, src.m21, src.m23, src.m30, src.m31, src.m33); + float t03 = -determinant3x3(src.m10, src.m11, src.m12, src.m20, src.m21, src.m22, src.m30, src.m31, src.m32); + float t10 = -determinant3x3(src.m01, src.m02, src.m03, src.m21, src.m22, src.m23, src.m31, src.m32, src.m33); + float t11 = determinant3x3(src.m00, src.m02, src.m03, src.m20, src.m22, src.m23, src.m30, src.m32, src.m33); + float t12 = -determinant3x3(src.m00, src.m01, src.m03, src.m20, src.m21, src.m23, src.m30, src.m31, src.m33); + float t13 = determinant3x3(src.m00, src.m01, src.m02, src.m20, src.m21, src.m22, src.m30, src.m31, src.m32); + float t20 = determinant3x3(src.m01, src.m02, src.m03, src.m11, src.m12, src.m13, src.m31, src.m32, src.m33); + float t21 = -determinant3x3(src.m00, src.m02, src.m03, src.m10, src.m12, src.m13, src.m30, src.m32, src.m33); + float t22 = determinant3x3(src.m00, src.m01, src.m03, src.m10, src.m11, src.m13, src.m30, src.m31, src.m33); + float t23 = -determinant3x3(src.m00, src.m01, src.m02, src.m10, src.m11, src.m12, src.m30, src.m31, src.m32); + float t30 = -determinant3x3(src.m01, src.m02, src.m03, src.m11, src.m12, src.m13, src.m21, src.m22, src.m23); + float t31 = determinant3x3(src.m00, src.m02, src.m03, src.m10, src.m12, src.m13, src.m20, src.m22, src.m23); + float t32 = -determinant3x3(src.m00, src.m01, src.m03, src.m10, src.m11, src.m13, src.m20, src.m21, src.m23); + float t33 = determinant3x3(src.m00, src.m01, src.m02, src.m10, src.m11, src.m12, src.m20, src.m21, src.m22); + + dest.m00 = t00*determinant_inv; + dest.m11 = t11*determinant_inv; + dest.m22 = t22*determinant_inv; + dest.m33 = t33*determinant_inv; + dest.m01 = t10*determinant_inv; + dest.m10 = t01*determinant_inv; + dest.m20 = t02*determinant_inv; + dest.m02 = t20*determinant_inv; + dest.m12 = t21*determinant_inv; + dest.m21 = t12*determinant_inv; + dest.m03 = t30*determinant_inv; + dest.m30 = t03*determinant_inv; + dest.m13 = t31*determinant_inv; + dest.m31 = t13*determinant_inv; + dest.m32 = t23*determinant_inv; + dest.m23 = t32*determinant_inv; + return dest; + } else + return null; + } + + public Matrix negate() { + return negate(this); + } + + public Matrix4f negate(Matrix4f dest) { + return negate(this, dest); + } + + public static Matrix4f negate(Matrix4f src, Matrix4f dest) { + if (dest == null) + dest = new Matrix4f(); + + dest.m00 = -src.m00; + dest.m01 = -src.m01; + dest.m02 = -src.m02; + dest.m03 = -src.m03; + dest.m10 = -src.m10; + dest.m11 = -src.m11; + dest.m12 = -src.m12; + dest.m13 = -src.m13; + dest.m20 = -src.m20; + dest.m21 = -src.m21; + dest.m22 = -src.m22; + dest.m23 = -src.m23; + dest.m30 = -src.m30; + dest.m31 = -src.m31; + dest.m32 = -src.m32; + dest.m33 = -src.m33; + + return dest; + } +} \ No newline at end of file diff --git a/src/org/lwjgl/util/vector/ReadableVector.java b/src/org/lwjgl/util/vector/ReadableVector.java new file mode 100644 index 0000000..0e283da --- /dev/null +++ b/src/org/lwjgl/util/vector/ReadableVector.java @@ -0,0 +1,9 @@ +package org.lwjgl.util.vector; + +import java.nio.FloatBuffer; + +public interface ReadableVector { + float length(); + float lengthSquared(); + Vector store(FloatBuffer buf); +} \ No newline at end of file diff --git a/src/org/lwjgl/util/vector/ReadableVector2f.java b/src/org/lwjgl/util/vector/ReadableVector2f.java new file mode 100644 index 0000000..ad6a2d2 --- /dev/null +++ b/src/org/lwjgl/util/vector/ReadableVector2f.java @@ -0,0 +1,6 @@ +package org.lwjgl.util.vector; + +public interface ReadableVector2f extends ReadableVector { + float getX(); + float getY(); +} \ No newline at end of file diff --git a/src/org/lwjgl/util/vector/ReadableVector3f.java b/src/org/lwjgl/util/vector/ReadableVector3f.java new file mode 100644 index 0000000..a557470 --- /dev/null +++ b/src/org/lwjgl/util/vector/ReadableVector3f.java @@ -0,0 +1,5 @@ +package org.lwjgl.util.vector; + +public interface ReadableVector3f extends ReadableVector2f { + float getZ(); +} \ No newline at end of file diff --git a/src/org/lwjgl/util/vector/ReadableVector4f.java b/src/org/lwjgl/util/vector/ReadableVector4f.java new file mode 100644 index 0000000..f257633 --- /dev/null +++ b/src/org/lwjgl/util/vector/ReadableVector4f.java @@ -0,0 +1,7 @@ +package org.lwjgl.util.vector; + +public interface ReadableVector4f extends ReadableVector3f { + + float getW(); + +} \ No newline at end of file diff --git a/src/org/lwjgl/util/vector/Vector.java b/src/org/lwjgl/util/vector/Vector.java new file mode 100644 index 0000000..52411a1 --- /dev/null +++ b/src/org/lwjgl/util/vector/Vector.java @@ -0,0 +1,37 @@ +package org.lwjgl.util.vector; + +import java.io.Serializable; +import java.nio.FloatBuffer; + +public abstract class Vector implements Serializable, ReadableVector { + + protected Vector() { + super(); + } + + public final float length() { + return (float) Math.sqrt(lengthSquared()); + } + + public abstract float lengthSquared(); + + public abstract Vector load(FloatBuffer buf); + + public abstract Vector negate(); + + public final Vector normalise() { + float len = length(); + if (len != 0.0f) { + float l = 1.0f / len; + return scale(l); + } else + throw new IllegalStateException("Zero length vector"); + } + + public abstract Vector store(FloatBuffer buf); + + public abstract Vector scale(float scale); + + + +} \ No newline at end of file diff --git a/src/org/lwjgl/util/vector/Vector2f.java b/src/org/lwjgl/util/vector/Vector2f.java new file mode 100644 index 0000000..91a69fb --- /dev/null +++ b/src/org/lwjgl/util/vector/Vector2f.java @@ -0,0 +1,161 @@ +package org.lwjgl.util.vector; + +import java.io.Serializable; +import java.nio.FloatBuffer; + +import org.lwjgl.util.vector.Vector2f; + +public class Vector2f extends Vector implements Serializable, ReadableVector2f, WritableVector2f { + + private static final long serialVersionUID = 1L; + + public float x, y; + + public Vector2f() { + super(); + } + + public Vector2f(ReadableVector2f src) { + set(src); + } + + public Vector2f(float x, float y) { + set(x, y); + } + + public void set(float x, float y) { + this.x = x; + this.y = y; + } + + public Vector2f set(ReadableVector2f src) { + x = src.getX(); + y = src.getY(); + return this; + } + + public float lengthSquared() { + return x * x + y * y; + } + + public Vector2f translate(float x, float y) { + this.x += x; + this.y += y; + return this; + } + + public Vector negate() { + x = -x; + y = -y; + return this; + } + + public Vector2f negate(Vector2f dest) { + if (dest == null) + dest = new Vector2f(); + dest.x = -x; + dest.y = -y; + return dest; + } + + public Vector2f normalise(Vector2f dest) { + float l = length(); + + if (dest == null) + dest = new Vector2f(x / l, y / l); + else + dest.set(x / l, y / l); + + return dest; + } + + public static float dot(Vector2f left, Vector2f right) { + return left.x * right.x + left.y * right.y; + } + + public static float angle(Vector2f a, Vector2f b) { + float dls = dot(a, b) / (a.length() * b.length()); + if (dls < -1f) + dls = -1f; + else if (dls > 1.0f) + dls = 1.0f; + return (float)Math.acos(dls); + } + + public static Vector2f add(Vector2f left, Vector2f right, Vector2f dest) { + if (dest == null) + return new Vector2f(left.x + right.x, left.y + right.y); + else { + dest.set(left.x + right.x, left.y + right.y); + return dest; + } + } + + public static Vector2f sub(Vector2f left, Vector2f right, Vector2f dest) { + if (dest == null) + return new Vector2f(left.x - right.x, left.y - right.y); + else { + dest.set(left.x - right.x, left.y - right.y); + return dest; + } + } + + public Vector store(FloatBuffer buf) { + buf.put(x); + buf.put(y); + return this; + } + + public Vector load(FloatBuffer buf) { + x = buf.get(); + y = buf.get(); + return this; + } + + public Vector scale(float scale) { + + x *= scale; + y *= scale; + + return this; + } + + public String toString() { + StringBuilder sb = new StringBuilder(64); + + sb.append("Vector2f["); + sb.append(x); + sb.append(", "); + sb.append(y); + sb.append(']'); + return sb.toString(); + } + + public final float getX() { + return x; + } + + public final float getY() { + return y; + } + + public final void setX(float x) { + this.x = x; + } + + public final void setY(float y) { + this.y = y; + } + + public boolean equals(Object obj) { + if (this == obj) return true; + if (obj == null) return false; + if (getClass() != obj.getClass()) return false; + Vector2f other = (Vector2f)obj; + + if (x == other.x && y == other.y) return true; + + return false; + } + +} \ No newline at end of file diff --git a/src/org/lwjgl/util/vector/Vector3f.java b/src/org/lwjgl/util/vector/Vector3f.java new file mode 100644 index 0000000..08c08c0 --- /dev/null +++ b/src/org/lwjgl/util/vector/Vector3f.java @@ -0,0 +1,202 @@ +package org.lwjgl.util.vector; + +import java.io.Serializable; +import java.nio.FloatBuffer; + +public class Vector3f extends Vector implements Serializable, ReadableVector3f, WritableVector3f { + + private static final long serialVersionUID = 1L; + + public float x, y, z; + + public Vector3f() { + super(); + } + + public Vector3f(ReadableVector3f src) { + set(src); + } + + public Vector3f(float x, float y, float z) { + set(x, y, z); + } + + public void set(float x, float y) { + this.x = x; + this.y = y; + } + + public void set(float x, float y, float z) { + this.x = x; + this.y = y; + this.z = z; + } + + public Vector3f set(ReadableVector3f src) { + x = src.getX(); + y = src.getY(); + z = src.getZ(); + return this; + } + + public float lengthSquared() { + return x * x + y * y + z * z; + } + + public Vector3f translate(float x, float y, float z) { + this.x += x; + this.y += y; + this.z += z; + return this; + } + + public static Vector3f add(Vector3f left, Vector3f right, Vector3f dest) { + if (dest == null) + return new Vector3f(left.x + right.x, left.y + right.y, left.z + right.z); + else { + dest.set(left.x + right.x, left.y + right.y, left.z + right.z); + return dest; + } + } + + public static Vector3f sub(Vector3f left, Vector3f right, Vector3f dest) { + if (dest == null) + return new Vector3f(left.x - right.x, left.y - right.y, left.z - right.z); + else { + dest.set(left.x - right.x, left.y - right.y, left.z - right.z); + return dest; + } + } + + public static Vector3f cross( + Vector3f left, + Vector3f right, + Vector3f dest) + { + + if (dest == null) + dest = new Vector3f(); + + dest.set( + left.y * right.z - left.z * right.y, + right.x * left.z - right.z * left.x, + left.x * right.y - left.y * right.x + ); + + return dest; + } + + public Vector negate() { + x = -x; + y = -y; + z = -z; + return this; + } + + public Vector3f negate(Vector3f dest) { + if (dest == null) + dest = new Vector3f(); + dest.x = -x; + dest.y = -y; + dest.z = -z; + return dest; + } + + public Vector3f normalise(Vector3f dest) { + float l = length(); + + if (dest == null) + dest = new Vector3f(x / l, y / l, z / l); + else + dest.set(x / l, y / l, z / l); + + return dest; + } + + public static float dot(Vector3f left, Vector3f right) { + return left.x * right.x + left.y * right.y + left.z * right.z; + } + + public static float angle(Vector3f a, Vector3f b) { + float dls = dot(a, b) / (a.length() * b.length()); + if (dls < -1f) + dls = -1f; + else if (dls > 1.0f) + dls = 1.0f; + return (float)Math.acos(dls); + } + + public Vector load(FloatBuffer buf) { + x = buf.get(); + y = buf.get(); + z = buf.get(); + return this; + } + + public Vector scale(float scale) { + + x *= scale; + y *= scale; + z *= scale; + + return this; + + } + + public Vector store(FloatBuffer buf) { + + buf.put(x); + buf.put(y); + buf.put(z); + + return this; + } + + public String toString() { + StringBuilder sb = new StringBuilder(64); + + sb.append("Vector3f["); + sb.append(x); + sb.append(", "); + sb.append(y); + sb.append(", "); + sb.append(z); + sb.append(']'); + return sb.toString(); + } + + public final float getX() { + return x; + } + + public final float getY() { + return y; + } + + public final void setX(float x) { + this.x = x; + } + + public final void setY(float y) { + this.y = y; + } + + public void setZ(float z) { + this.z = z; + } + + public float getZ() { + return z; + } + + public boolean equals(Object obj) { + if (this == obj) return true; + if (obj == null) return false; + if (getClass() != obj.getClass()) return false; + Vector3f other = (Vector3f)obj; + + if (x == other.x && y == other.y && z == other.z) return true; + + return false; + } +} \ No newline at end of file diff --git a/src/org/lwjgl/util/vector/Vector4f.java b/src/org/lwjgl/util/vector/Vector4f.java new file mode 100644 index 0000000..c5d9365 --- /dev/null +++ b/src/org/lwjgl/util/vector/Vector4f.java @@ -0,0 +1,196 @@ +package org.lwjgl.util.vector; + +import java.io.Serializable; +import java.nio.FloatBuffer; + +import org.lwjgl.util.vector.Vector4f; + +public class Vector4f extends Vector implements Serializable, ReadableVector4f, WritableVector4f { + + private static final long serialVersionUID = 1L; + + public float x, y, z, w; + + public Vector4f() { + super(); + } + + public Vector4f(ReadableVector4f src) { + set(src); + } + + public Vector4f(float x, float y, float z, float w) { + set(x, y, z, w); + } + + public void set(float x, float y) { + this.x = x; + this.y = y; + } + + public void set(float x, float y, float z) { + this.x = x; + this.y = y; + this.z = z; + } + + public void set(float x, float y, float z, float w) { + this.x = x; + this.y = y; + this.z = z; + this.w = w; + } + + public Vector4f set(ReadableVector4f src) { + x = src.getX(); + y = src.getY(); + z = src.getZ(); + w = src.getW(); + return this; + } + + public float lengthSquared() { + return x * x + y * y + z * z + w * w; + } + + public Vector4f translate(float x, float y, float z, float w) { + this.x += x; + this.y += y; + this.z += z; + this.w += w; + return this; + } + + public static Vector4f add(Vector4f left, Vector4f right, Vector4f dest) { + if (dest == null) + return new Vector4f(left.x + right.x, left.y + right.y, left.z + right.z, left.w + right.w); + else { + dest.set(left.x + right.x, left.y + right.y, left.z + right.z, left.w + right.w); + return dest; + } + } + + public static Vector4f sub(Vector4f left, Vector4f right, Vector4f dest) { + if (dest == null) + return new Vector4f(left.x - right.x, left.y - right.y, left.z - right.z, left.w - right.w); + else { + dest.set(left.x - right.x, left.y - right.y, left.z - right.z, left.w - right.w); + return dest; + } + } + + public Vector negate() { + x = -x; + y = -y; + z = -z; + w = -w; + return this; + } + + public Vector4f negate(Vector4f dest) { + if (dest == null) + dest = new Vector4f(); + dest.x = -x; + dest.y = -y; + dest.z = -z; + dest.w = -w; + return dest; + } + + public Vector4f normalise(Vector4f dest) { + float l = length(); + + if (dest == null) + dest = new Vector4f(x / l, y / l, z / l, w / l); + else + dest.set(x / l, y / l, z / l, w / l); + + return dest; + } + + public static float dot(Vector4f left, Vector4f right) { + return left.x * right.x + left.y * right.y + left.z * right.z + left.w * right.w; + } + + public static float angle(Vector4f a, Vector4f b) { + float dls = dot(a, b) / (a.length() * b.length()); + if (dls < -1f) + dls = -1f; + else if (dls > 1.0f) + dls = 1.0f; + return (float)Math.acos(dls); + } + + public Vector load(FloatBuffer buf) { + x = buf.get(); + y = buf.get(); + z = buf.get(); + w = buf.get(); + return this; + } + + public Vector scale(float scale) { + x *= scale; + y *= scale; + z *= scale; + w *= scale; + return this; + } + + public Vector store(FloatBuffer buf) { + + buf.put(x); + buf.put(y); + buf.put(z); + buf.put(w); + + return this; + } + + public String toString() { + return "Vector4f: " + x + " " + y + " " + z + " " + w; + } + + public final float getX() { + return x; + } + + public final float getY() { + return y; + } + + public final void setX(float x) { + this.x = x; + } + + public final void setY(float y) { + this.y = y; + } + + public void setZ(float z) { + this.z = z; + } + + public float getZ() { + return z; + } + + public void setW(float w) { + this.w = w; + } + + public float getW() { + return w; + } + + public boolean equals(Object obj) { + if (this == obj) return true; + if (obj == null) return false; + if (getClass() != obj.getClass()) return false; + Vector4f other = (Vector4f)obj; + + if (x == other.x && y == other.y && z == other.z && w == other.w) return true; + + return false; + } +} \ No newline at end of file diff --git a/src/org/lwjgl/util/vector/WritableVector2f.java b/src/org/lwjgl/util/vector/WritableVector2f.java new file mode 100644 index 0000000..36f6b3a --- /dev/null +++ b/src/org/lwjgl/util/vector/WritableVector2f.java @@ -0,0 +1,11 @@ +package org.lwjgl.util.vector; + +public interface WritableVector2f { + + void setX(float x); + + void setY(float y); + + void set(float x, float y); + +} \ No newline at end of file diff --git a/src/org/lwjgl/util/vector/WritableVector3f.java b/src/org/lwjgl/util/vector/WritableVector3f.java new file mode 100644 index 0000000..567f2d6 --- /dev/null +++ b/src/org/lwjgl/util/vector/WritableVector3f.java @@ -0,0 +1,9 @@ +package org.lwjgl.util.vector; + +public interface WritableVector3f extends WritableVector2f { + + void setZ(float z); + + void set(float x, float y, float z); + +} \ No newline at end of file diff --git a/src/org/lwjgl/util/vector/WritableVector4f.java b/src/org/lwjgl/util/vector/WritableVector4f.java new file mode 100644 index 0000000..239c806 --- /dev/null +++ b/src/org/lwjgl/util/vector/WritableVector4f.java @@ -0,0 +1,9 @@ +package org.lwjgl.util.vector; + +public interface WritableVector4f extends WritableVector3f { + + void setW(float w); + + void set(float x, float y, float z, float w); + +} \ No newline at end of file