Update #49 - Fix unclosable pause menu glitch
This commit is contained in:
parent
ed97c1ac00
commit
ad900211dd
client_version
patches/minecraft/net/minecraft
client
model
renderer
resources
util
world/storage
sources
main/java/net
lax1dude/eaglercraft/v1_8
EaglercraftVersion.java
internal/vfs2
minecraft
opengl
profile
socket/protocol/client
optifine
resources
setup/workspace_template/wasm_gc_teavm/javascript
teavm/java/net/lax1dude/eaglercraft/v1_8/internal
wasm-gc-teavm
java/net/lax1dude/eaglercraft/v1_8
internal
PlatformApplication.javaPlatformAssets.javaPlatformAudio.javaPlatformInput.javaPlatformWebRTC.javaPlatformWebView.java
buffer
wasm_gc_teavm
sp
js
|
@ -1 +1 @@
|
|||
u48
|
||||
u49
|
|
@ -33,7 +33,7 @@
|
|||
|
||||
> CHANGE 1 : 3 @ 1 : 4
|
||||
|
||||
~ // note: vanilla order for this function is YXZ not ZYX for some reason
|
||||
~ // note: vanilla order for this transformation was YXZ not ZYX for some reason
|
||||
~ GlStateManager.rotateZYXRad(this.rotateAngleX, this.rotateAngleY, this.rotateAngleZ);
|
||||
|
||||
> DELETE 1 @ 1 : 5
|
||||
|
|
|
@ -83,25 +83,25 @@
|
|||
|
||||
~ import net.optifine.Config;
|
||||
|
||||
> CHANGE 9 : 10 @ 9 : 10
|
||||
> INSERT 4 : 6 @ 4
|
||||
|
||||
+ private static final ResourceLocation locationRainDeferredPng = new ResourceLocation(
|
||||
+ "eagler:glsl/deferred/rain.png");
|
||||
|
||||
> CHANGE 5 : 6 @ 5 : 6
|
||||
|
||||
~ private EaglercraftRandom random = new EaglercraftRandom();
|
||||
|
||||
> DELETE 43 @ 43 : 59
|
||||
|
||||
> INSERT 3 : 5 @ 3
|
||||
> INSERT 3 : 7 @ 3
|
||||
|
||||
+ private GameOverlayFramebuffer overlayFramebuffer;
|
||||
+ private float eagPartialTicks = 0.0f;
|
||||
|
||||
> INSERT 1 : 5 @ 1
|
||||
|
||||
+ public float currentProjMatrixFOV = 0.0f;
|
||||
+
|
||||
+ private boolean initializedOF = false;
|
||||
+
|
||||
|
||||
> DELETE 1 @ 1 : 2
|
||||
> DELETE 2 @ 2 : 3
|
||||
|
||||
> CHANGE 9 : 10 @ 9 : 10
|
||||
|
||||
|
@ -584,7 +584,12 @@
|
|||
|
||||
~ GlStateManager.gluPerspective(this.getFOVModifier(partialTicks, true),
|
||||
|
||||
> CHANGE 9 : 10 @ 9 : 10
|
||||
> CHANGE 4 : 6 @ 4 : 5
|
||||
|
||||
~ // renderGlobalIn.renderClouds(partialTicks, pass);
|
||||
~ renderGlobalIn.cloudRenderer.renderClouds(partialTicks, pass);
|
||||
|
||||
> CHANGE 4 : 5 @ 4 : 5
|
||||
|
||||
~ GlStateManager.gluPerspective(this.getFOVModifier(partialTicks, true),
|
||||
|
||||
|
@ -636,11 +641,10 @@
|
|||
|
||||
~ if (f2 >= 0.15F) {
|
||||
|
||||
> CHANGE 6 : 15 @ 6 : 7
|
||||
> CHANGE 6 : 14 @ 6 : 7
|
||||
|
||||
~ this.mc.getTextureManager()
|
||||
~ .bindTexture(df ? new ResourceLocation("eagler:glsl/deferred/rain.png")
|
||||
~ : locationRainPng);
|
||||
~ .bindTexture(df ? locationRainDeferredPng : locationRainPng);
|
||||
~ if (df) {
|
||||
~ DeferredStateManager.setRoughnessConstant(0.5f);
|
||||
~ DeferredStateManager.setMetalnessConstant(0.05f);
|
||||
|
|
|
@ -16,7 +16,7 @@
|
|||
~ import net.lax1dude.eaglercraft.v1_8.Keyboard;
|
||||
~
|
||||
|
||||
> INSERT 2 : 24 @ 2
|
||||
> INSERT 2 : 25 @ 2
|
||||
|
||||
+
|
||||
+ import com.google.common.collect.Lists;
|
||||
|
@ -28,6 +28,7 @@
|
|||
+ import net.lax1dude.eaglercraft.v1_8.log4j.Logger;
|
||||
+ import net.lax1dude.eaglercraft.v1_8.minecraft.ChunkUpdateManager;
|
||||
+ import net.lax1dude.eaglercraft.v1_8.minecraft.EaglerTextureAtlasSprite;
|
||||
+ import net.lax1dude.eaglercraft.v1_8.minecraft.EaglerCloudRenderer;
|
||||
+ import net.lax1dude.eaglercraft.v1_8.opengl.EaglercraftGPU;
|
||||
+ import net.lax1dude.eaglercraft.v1_8.opengl.GlStateManager;
|
||||
+ import net.lax1dude.eaglercraft.v1_8.opengl.VertexFormat;
|
||||
|
@ -75,21 +76,22 @@
|
|||
~ private float lastViewProjMatrixFOV = Float.MIN_VALUE;
|
||||
~ private final ChunkUpdateManager renderDispatcher = new ChunkUpdateManager();
|
||||
|
||||
> INSERT 17 : 19 @ 17
|
||||
> INSERT 16 : 18 @ 16
|
||||
|
||||
+ private final DeduplicatedLongQueue alfheim$lightUpdatesQueue = new DeduplicatedLongQueue(8192);
|
||||
+
|
||||
+ public final EaglerCloudRenderer cloudRenderer;
|
||||
|
||||
> CHANGE 5 : 7 @ 5 : 7
|
||||
> CHANGE 6 : 8 @ 6 : 8
|
||||
|
||||
~ EaglercraftGPU.glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_REPEAT);
|
||||
~ EaglercraftGPU.glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_REPEAT);
|
||||
|
||||
> CHANGE 2 : 5 @ 2 : 14
|
||||
> CHANGE 2 : 6 @ 2 : 14
|
||||
|
||||
~ this.vboEnabled = false;
|
||||
~ this.renderContainer = new RenderList();
|
||||
~ this.renderChunkFactory = new ListChunkFactory();
|
||||
~ this.cloudRenderer = new EaglerCloudRenderer(mcIn);
|
||||
|
||||
> DELETE 19 @ 19 : 23
|
||||
|
||||
|
@ -121,7 +123,16 @@
|
|||
~ tessellator.draw();
|
||||
~ EaglercraftGPU.glEndList();
|
||||
|
||||
> DELETE 29 @ 29 : 32
|
||||
> DELETE 4 @ 4 : 6
|
||||
|
||||
> CHANGE 1 : 5 @ 1 : 18
|
||||
|
||||
~ worldRendererIn.pos(-384, parFloat1, -384).endVertex();
|
||||
~ worldRendererIn.pos(-384, parFloat1, 384).endVertex();
|
||||
~ worldRendererIn.pos(384, parFloat1, 384).endVertex();
|
||||
~ worldRendererIn.pos(384, parFloat1, -384).endVertex();
|
||||
|
||||
> DELETE 5 @ 5 : 8
|
||||
|
||||
> CHANGE 6 : 13 @ 6 : 21
|
||||
|
||||
|
@ -674,7 +685,11 @@
|
|||
|
||||
+ GlStateManager.enableDepth();
|
||||
|
||||
> CHANGE 331 : 332 @ 331 : 332
|
||||
> DELETE 3 @ 3 : 79
|
||||
|
||||
> DELETE 4 @ 4 : 251
|
||||
|
||||
> CHANGE 1 : 2 @ 1 : 2
|
||||
|
||||
~ this.displayListEntitiesDirty |= this.renderDispatcher.updateChunks(finishTimeNano);
|
||||
|
||||
|
@ -719,7 +734,7 @@
|
|||
|
||||
~ EaglercraftRandom random = this.theWorld.rand;
|
||||
|
||||
> INSERT 229 : 263 @ 229
|
||||
> INSERT 229 : 267 @ 229
|
||||
|
||||
+
|
||||
+ public String getDebugInfoShort() {
|
||||
|
@ -755,5 +770,9 @@
|
|||
+
|
||||
+ alfheim$lightUpdatesQueue.newDeduplicationSet();
|
||||
+ }
|
||||
+
|
||||
+ public double getCloudCounter(float partialTicks) {
|
||||
+ return (double) cloudTickCounter + partialTicks;
|
||||
+ }
|
||||
|
||||
> EOF
|
||||
|
|
|
@ -5,16 +5,16 @@
|
|||
# Version: 1.0
|
||||
# Author: lax1dude
|
||||
|
||||
> CHANGE 2 : 6 @ 2 : 5
|
||||
> CHANGE 2 : 4 @ 2 : 5
|
||||
|
||||
~ import net.lax1dude.eaglercraft.v1_8.internal.buffer.FloatBuffer;
|
||||
~
|
||||
~ import net.lax1dude.eaglercraft.v1_8.opengl.GlStateManager;
|
||||
~ import net.lax1dude.eaglercraft.v1_8.opengl.ext.deferred.DeferredStateManager;
|
||||
|
||||
> DELETE 1 @ 1 : 2
|
||||
|
||||
> CHANGE 7 : 13 @ 7 : 11
|
||||
> DELETE 2 @ 2 : 3
|
||||
|
||||
> CHANGE 4 : 10 @ 4 : 8
|
||||
|
||||
~ if (!DeferredStateManager.isInDeferredPass()) {
|
||||
~ GlStateManager.disableLighting();
|
||||
|
@ -33,7 +33,9 @@
|
|||
~ GlStateManager.enableColorMaterial();
|
||||
~ }
|
||||
|
||||
> CHANGE 15 : 22 @ 15 : 20
|
||||
> DELETE 2 @ 2 : 14
|
||||
|
||||
> CHANGE 1 : 8 @ 1 : 6
|
||||
|
||||
~ if (!DeferredStateManager.isInDeferredPass()) {
|
||||
~ GlStateManager.pushMatrix();
|
||||
|
|
|
@ -11,16 +11,20 @@
|
|||
~ import net.lax1dude.eaglercraft.v1_8.opengl.WorldRenderer;
|
||||
~ import net.lax1dude.eaglercraft.v1_8.opengl.WorldVertexBufferUploader;
|
||||
|
||||
> INSERT 4 : 13 @ 4
|
||||
> CHANGE 3 : 12 @ 3 : 4
|
||||
|
||||
+
|
||||
+ public static final int GL_TRIANGLES = RealOpenGLEnums.GL_TRIANGLES;
|
||||
+ public static final int GL_TRIANGLE_STRIP = RealOpenGLEnums.GL_TRIANGLE_STRIP;
|
||||
+ public static final int GL_TRIANGLE_FAN = RealOpenGLEnums.GL_TRIANGLE_FAN;
|
||||
+ public static final int GL_QUADS = RealOpenGLEnums.GL_QUADS;
|
||||
+ public static final int GL_LINES = RealOpenGLEnums.GL_LINES;
|
||||
+ public static final int GL_LINE_STRIP = RealOpenGLEnums.GL_LINE_STRIP;
|
||||
+ public static final int GL_LINE_LOOP = RealOpenGLEnums.GL_LINE_LOOP;
|
||||
+
|
||||
~
|
||||
~ public static final int GL_TRIANGLES = RealOpenGLEnums.GL_TRIANGLES;
|
||||
~ public static final int GL_TRIANGLE_STRIP = RealOpenGLEnums.GL_TRIANGLE_STRIP;
|
||||
~ public static final int GL_TRIANGLE_FAN = RealOpenGLEnums.GL_TRIANGLE_FAN;
|
||||
~ public static final int GL_QUADS = RealOpenGLEnums.GL_QUADS;
|
||||
~ public static final int GL_LINES = RealOpenGLEnums.GL_LINES;
|
||||
~ public static final int GL_LINE_STRIP = RealOpenGLEnums.GL_LINE_STRIP;
|
||||
~ public static final int GL_LINE_LOOP = RealOpenGLEnums.GL_LINE_LOOP;
|
||||
~
|
||||
|
||||
> CHANGE 12 : 13 @ 12 : 13
|
||||
|
||||
~ WorldVertexBufferUploader.func_181679_a(this.worldRenderer);
|
||||
|
||||
> EOF
|
||||
|
|
|
@ -5,9 +5,8 @@
|
|||
# Version: 1.0
|
||||
# Author: lax1dude
|
||||
|
||||
> INSERT 2 : 4 @ 2
|
||||
> INSERT 2 : 3 @ 2
|
||||
|
||||
+ import net.lax1dude.eaglercraft.v1_8.internal.IFramebufferGL;
|
||||
+ import net.lax1dude.eaglercraft.v1_8.minecraft.EaglerTextureAtlasSprite;
|
||||
|
||||
> DELETE 1 @ 1 : 3
|
||||
|
|
|
@ -5,9 +5,8 @@
|
|||
# Version: 1.0
|
||||
# Author: lax1dude
|
||||
|
||||
> INSERT 2 : 4 @ 2
|
||||
> INSERT 2 : 3 @ 2
|
||||
|
||||
+ import net.lax1dude.eaglercraft.v1_8.internal.IFramebufferGL;
|
||||
+ import net.lax1dude.eaglercraft.v1_8.minecraft.EaglerTextureAtlasSprite;
|
||||
|
||||
> DELETE 1 @ 1 : 3
|
||||
|
|
|
@ -7,11 +7,7 @@
|
|||
|
||||
> DELETE 2 @ 2 : 3
|
||||
|
||||
> INSERT 2 : 3 @ 2
|
||||
|
||||
+ import java.util.Collection;
|
||||
|
||||
> INSERT 1 : 4 @ 1
|
||||
> INSERT 3 : 6 @ 3
|
||||
|
||||
+
|
||||
+ import net.lax1dude.eaglercraft.v1_8.minecraft.ResourceIndex;
|
||||
|
|
|
@ -13,4 +13,16 @@
|
|||
~ public int y;
|
||||
~ public int z;
|
||||
|
||||
> CHANGE 33 : 34 @ 33 : 34
|
||||
|
||||
~ public final int getX() {
|
||||
|
||||
> CHANGE 3 : 4 @ 3 : 4
|
||||
|
||||
~ public final int getY() {
|
||||
|
||||
> CHANGE 3 : 4 @ 3 : 4
|
||||
|
||||
~ public final int getZ() {
|
||||
|
||||
> EOF
|
||||
|
|
|
@ -41,33 +41,53 @@
|
|||
|
||||
~ worldinfo.areCommandsAllowed(), null));
|
||||
|
||||
> CHANGE 10 : 11 @ 10 : 11
|
||||
> CHANGE 10 : 17 @ 10 : 22
|
||||
|
||||
~ VFile2 file1 = WorldsDB.newVFile(this.savesDirectory, saveName);
|
||||
~ VFile2 file2 = WorldsDB.newVFile(file1, "level.dat");
|
||||
~ if (file2.exists()) {
|
||||
~ try {
|
||||
~ NBTTagCompound nbttagcompound2;
|
||||
~ try (InputStream is = file2.getInputStream()) {
|
||||
~ nbttagcompound2 = CompressedStreamTools.readCompressed(is);
|
||||
|
||||
> CHANGE 3 : 4 @ 3 : 4
|
||||
> INSERT 1 : 6 @ 1
|
||||
|
||||
~ VFile2 file2 = WorldsDB.newVFile(file1, "level.dat");
|
||||
+ NBTTagCompound nbttagcompound3 = nbttagcompound2.getCompoundTag("Data");
|
||||
+ return new WorldInfo(nbttagcompound3);
|
||||
+ } catch (Exception exception1) {
|
||||
+ logger.error("Exception reading " + file2);
|
||||
+ logger.error(exception1);
|
||||
|
||||
> CHANGE 2 : 6 @ 2 : 3
|
||||
> INSERT 1 : 2 @ 1
|
||||
|
||||
~ NBTTagCompound nbttagcompound2;
|
||||
~ try (InputStream is = file2.getInputStream()) {
|
||||
~ nbttagcompound2 = CompressedStreamTools.readCompressed(is);
|
||||
~ }
|
||||
+ }
|
||||
|
||||
> CHANGE 7 : 8 @ 7 : 8
|
||||
> CHANGE 1 : 7 @ 1 : 9
|
||||
|
||||
~ file2 = WorldsDB.newVFile(file1, "level.dat_old");
|
||||
~ file2 = WorldsDB.newVFile(file1, "level.dat_old");
|
||||
~ if (file2.exists()) {
|
||||
~ try {
|
||||
~ NBTTagCompound nbttagcompound;
|
||||
~ try (InputStream is = file2.getInputStream()) {
|
||||
~ nbttagcompound = CompressedStreamTools.readCompressed(is);
|
||||
|
||||
> CHANGE 2 : 6 @ 2 : 3
|
||||
> INSERT 1 : 6 @ 1
|
||||
|
||||
~ NBTTagCompound nbttagcompound;
|
||||
~ try (InputStream is = file2.getInputStream()) {
|
||||
~ nbttagcompound = CompressedStreamTools.readCompressed(is);
|
||||
~ }
|
||||
+ NBTTagCompound nbttagcompound1 = nbttagcompound.getCompoundTag("Data");
|
||||
+ return new WorldInfo(nbttagcompound1);
|
||||
+ } catch (Exception exception) {
|
||||
+ logger.error("Exception reading " + file2);
|
||||
+ logger.error(exception);
|
||||
|
||||
> CHANGE 11 : 15 @ 11 : 15
|
||||
> DELETE 1 @ 1 : 3
|
||||
|
||||
> INSERT 1 : 3 @ 1
|
||||
|
||||
+
|
||||
+ return null;
|
||||
|
||||
> CHANGE 2 : 6 @ 2 : 6
|
||||
|
||||
~ public boolean renameWorld(String dirName, String newName) {
|
||||
~ VFile2 file1 = WorldsDB.newVFile(this.savesDirectory, dirName);
|
||||
|
|
|
@ -10,7 +10,7 @@ public class EaglercraftVersion {
|
|||
/// Customize these to fit your fork:
|
||||
|
||||
public static final String projectForkName = "EaglercraftX";
|
||||
public static final String projectForkVersion = "u48";
|
||||
public static final String projectForkVersion = "u49";
|
||||
public static final String projectForkVendor = "lax1dude";
|
||||
|
||||
public static final String projectForkURL = "https://gitlab.com/lax1dude/eaglercraftx-1.8";
|
||||
|
@ -20,20 +20,20 @@ public class EaglercraftVersion {
|
|||
public static final String projectOriginName = "EaglercraftX";
|
||||
public static final String projectOriginAuthor = "lax1dude";
|
||||
public static final String projectOriginRevision = "1.8";
|
||||
public static final String projectOriginVersion = "u48";
|
||||
public static final String projectOriginVersion = "u49";
|
||||
|
||||
public static final String projectOriginURL = "https://gitlab.com/lax1dude/eaglercraftx-1.8"; // rest in peace
|
||||
|
||||
// EPK Version Identifier
|
||||
|
||||
public static final String EPKVersionIdentifier = "u48"; // Set to null to disable EPK version check
|
||||
public static final String EPKVersionIdentifier = "u49"; // Set to null to disable EPK version check
|
||||
|
||||
// Updating configuration
|
||||
|
||||
public static final boolean enableUpdateService = true;
|
||||
|
||||
public static final String updateBundlePackageName = "net.lax1dude.eaglercraft.v1_8.client";
|
||||
public static final int updateBundlePackageVersionInt = 48;
|
||||
public static final int updateBundlePackageVersionInt = 49;
|
||||
|
||||
public static final String updateLatestLocalStorageKey = "latestUpdate_" + updateBundlePackageName;
|
||||
|
||||
|
|
|
@ -1,13 +1,13 @@
|
|||
package net.lax1dude.eaglercraft.v1_8.internal.vfs2;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.io.OutputStream;
|
||||
|
||||
import net.lax1dude.eaglercraft.v1_8.EaglerOutputStream;
|
||||
import net.lax1dude.eaglercraft.v1_8.internal.PlatformRuntime;
|
||||
import net.lax1dude.eaglercraft.v1_8.internal.buffer.ByteBuffer;
|
||||
|
||||
/**
|
||||
* Copyright (c) 2023-2024 lax1dude. All Rights Reserved.
|
||||
* Copyright (c) 2023-2025 lax1dude. All Rights Reserved.
|
||||
*
|
||||
* 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
|
||||
|
@ -21,29 +21,58 @@ import net.lax1dude.eaglercraft.v1_8.internal.buffer.ByteBuffer;
|
|||
* POSSIBILITY OF SUCH DAMAGE.
|
||||
*
|
||||
*/
|
||||
class VFileOutputStream extends EaglerOutputStream {
|
||||
class VFileOutputStream extends OutputStream {
|
||||
|
||||
private final VFile2 vfsFile;
|
||||
private boolean closed = false;
|
||||
private ByteBuffer buffer;
|
||||
|
||||
VFileOutputStream(VFile2 vfsFile) {
|
||||
super(256);
|
||||
this.buffer = PlatformRuntime.allocateByteBuffer(256);
|
||||
this.vfsFile = vfsFile;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void write(int b) throws IOException {
|
||||
if(buffer == null) throw new IOException("File is closed!");
|
||||
if(buffer.remaining() < 1) {
|
||||
buffer.flip();
|
||||
ByteBuffer buf = PlatformRuntime.allocateByteBuffer(buffer.limit() << 1);
|
||||
buf.put(buffer);
|
||||
PlatformRuntime.freeByteBuffer(buffer);
|
||||
buffer = buf;
|
||||
}
|
||||
buffer.put((byte)(b & 0xFF));
|
||||
}
|
||||
|
||||
@Override
|
||||
public void write(byte[] b, int off, int len) throws IOException {
|
||||
if(buffer == null) throw new IOException("File is closed!");
|
||||
if(buffer.remaining() < len) {
|
||||
buffer.flip();
|
||||
int oldLen = buffer.limit();
|
||||
int newLen = oldLen;
|
||||
do {
|
||||
newLen <<= 1;
|
||||
}while(newLen < oldLen + len);
|
||||
ByteBuffer buf = PlatformRuntime.allocateByteBuffer(newLen);
|
||||
buf.put(buffer);
|
||||
PlatformRuntime.freeByteBuffer(buffer);
|
||||
buffer = buf;
|
||||
}
|
||||
buffer.put(b, off, len);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void close() throws IOException {
|
||||
if(!closed) {
|
||||
closed = true;
|
||||
ByteBuffer copyBuffer = PlatformRuntime.allocateByteBuffer(count);
|
||||
if(buffer != null) {
|
||||
buffer.flip();
|
||||
try {
|
||||
copyBuffer.put(buf, 0, count);
|
||||
copyBuffer.flip();
|
||||
vfsFile.getFS().eaglerWrite(vfsFile.path, copyBuffer);
|
||||
vfsFile.getFS().eaglerWrite(vfsFile.path, buffer);
|
||||
}catch(Throwable t) {
|
||||
throw new IOException("Could not write stream contents to file!", t);
|
||||
}finally {
|
||||
PlatformRuntime.freeByteBuffer(copyBuffer);
|
||||
PlatformRuntime.freeByteBuffer(buffer);
|
||||
buffer = null;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -9,7 +9,6 @@ import net.lax1dude.eaglercraft.v1_8.EagRuntime;
|
|||
import net.lax1dude.eaglercraft.v1_8.log4j.LogManager;
|
||||
import net.lax1dude.eaglercraft.v1_8.log4j.Logger;
|
||||
import net.lax1dude.eaglercraft.v1_8.opengl.EaglercraftGPU;
|
||||
import net.lax1dude.eaglercraft.v1_8.opengl.GlStateManager;
|
||||
import net.lax1dude.eaglercraft.v1_8.opengl.WorldRenderer;
|
||||
import net.lax1dude.eaglercraft.v1_8.opengl.WorldVertexBufferUploader;
|
||||
import net.minecraft.client.Minecraft;
|
||||
|
@ -25,7 +24,6 @@ public class ChunkUpdateManager {
|
|||
|
||||
private static final Logger LOGGER = LogManager.getLogger();
|
||||
|
||||
private final WorldVertexBufferUploader worldVertexUploader;
|
||||
private final RegionRenderCacheBuilder renderCache;
|
||||
|
||||
private int chunkUpdatesTotal = 0;
|
||||
|
@ -39,7 +37,6 @@ public class ChunkUpdateManager {
|
|||
private final List<ChunkCompileTaskGenerator> queue = new LinkedList<>();
|
||||
|
||||
public ChunkUpdateManager() {
|
||||
worldVertexUploader = new WorldVertexBufferUploader();
|
||||
renderCache = new RegionRenderCacheBuilder();
|
||||
}
|
||||
|
||||
|
@ -202,9 +199,7 @@ public class ChunkUpdateManager {
|
|||
|
||||
private void uploadDisplayList(WorldRenderer chunkRenderer, int parInt1, RenderChunk parRenderChunk) {
|
||||
EaglercraftGPU.glNewList(parInt1, GL_COMPILE);
|
||||
GlStateManager.pushMatrix();
|
||||
this.worldVertexUploader.func_181679_a(chunkRenderer);
|
||||
GlStateManager.popMatrix();
|
||||
WorldVertexBufferUploader.func_181679_a(chunkRenderer);
|
||||
EaglercraftGPU.glEndList();
|
||||
}
|
||||
|
||||
|
|
|
@ -0,0 +1,344 @@
|
|||
package net.lax1dude.eaglercraft.v1_8.minecraft;
|
||||
|
||||
import static net.lax1dude.eaglercraft.v1_8.opengl.RealOpenGLEnums.*;
|
||||
|
||||
import java.util.BitSet;
|
||||
|
||||
import net.lax1dude.eaglercraft.v1_8.opengl.EaglercraftGPU;
|
||||
import net.lax1dude.eaglercraft.v1_8.opengl.GlStateManager;
|
||||
import net.lax1dude.eaglercraft.v1_8.opengl.WorldRenderer;
|
||||
import net.lax1dude.eaglercraft.v1_8.opengl.ext.deferred.BetterFrustum;
|
||||
import net.lax1dude.eaglercraft.v1_8.vector.Matrix4f;
|
||||
import net.minecraft.client.Minecraft;
|
||||
import net.minecraft.client.renderer.Tessellator;
|
||||
import net.minecraft.client.renderer.vertex.DefaultVertexFormats;
|
||||
import net.minecraft.entity.Entity;
|
||||
import net.minecraft.util.MathHelper;
|
||||
import net.minecraft.util.ResourceLocation;
|
||||
import net.minecraft.util.Vec3;
|
||||
|
||||
/**
|
||||
* Copyright (c) 2025 lax1dude. All Rights Reserved.
|
||||
*
|
||||
* 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 HOLDER 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.
|
||||
*
|
||||
*/
|
||||
public class EaglerCloudRenderer {
|
||||
|
||||
private static final ResourceLocation locationCloudsPNG = new ResourceLocation("textures/environment/clouds.png");
|
||||
|
||||
private final Minecraft mc;
|
||||
|
||||
private int renderList = -1;
|
||||
|
||||
private static final int RENDER_STATE_FAST = 0;
|
||||
private static final int RENDER_STATE_FANCY_BELOW = 1;
|
||||
private static final int RENDER_STATE_FANCY_INSIDE = 2;
|
||||
private static final int RENDER_STATE_FANCY_ABOVE = 3;
|
||||
|
||||
private int currentRenderState = -1;
|
||||
|
||||
private int[] renderListFancy = new int[] { -1, -1, -1, -1, -1, -1, -1, -1, -1 };
|
||||
|
||||
// 1.8 seems to use a different projection matrix for clouds
|
||||
private final Matrix4f fancyCloudProjView = new Matrix4f();
|
||||
private final BetterFrustum frustum = new BetterFrustum();
|
||||
|
||||
private final BitSet visibleCloudParts = new BitSet();
|
||||
|
||||
public EaglerCloudRenderer(Minecraft mc) {
|
||||
this.mc = mc;
|
||||
}
|
||||
|
||||
public void renderClouds(float partialTicks, int pass) {
|
||||
if (!this.mc.theWorld.provider.isSurfaceWorld()) {
|
||||
return;
|
||||
}
|
||||
|
||||
int c = mc.gameSettings.func_181147_e();
|
||||
if(c == 0) {
|
||||
return;
|
||||
}
|
||||
|
||||
int newState;
|
||||
Entity rve = this.mc.getRenderViewEntity();
|
||||
float f = (float) (rve.lastTickPosY + (rve.posY - rve.lastTickPosY) * (double) partialTicks);
|
||||
float f3 = this.mc.theWorld.provider.getCloudHeight() - f + 0.33F;
|
||||
if(c == 2) {
|
||||
if (f3 > -5.0F) {
|
||||
if (f3 <= 5.0F) {
|
||||
newState = RENDER_STATE_FANCY_INSIDE;
|
||||
}else {
|
||||
newState = RENDER_STATE_FANCY_ABOVE;
|
||||
}
|
||||
}else {
|
||||
newState = RENDER_STATE_FANCY_BELOW;
|
||||
}
|
||||
}else {
|
||||
newState = RENDER_STATE_FAST;
|
||||
}
|
||||
|
||||
if(newState != currentRenderState) {
|
||||
rebuild(newState);
|
||||
currentRenderState = newState;
|
||||
}
|
||||
|
||||
mc.getTextureManager().bindTexture(locationCloudsPNG);
|
||||
|
||||
GlStateManager.enableBlend();
|
||||
GlStateManager.tryBlendFuncSeparate(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA, 1, 0);
|
||||
|
||||
Vec3 vec3 = mc.theWorld.getCloudColour(partialTicks);
|
||||
float _f1 = (float) vec3.xCoord;
|
||||
float _f2 = (float) vec3.yCoord;
|
||||
float _f3 = (float) vec3.zCoord;
|
||||
if (pass != 2) {
|
||||
float _f4 = (_f1 * 30.0F + _f2 * 59.0F + _f3 * 11.0F) / 100.0F;
|
||||
float _f5 = (_f1 * 30.0F + _f2 * 70.0F) / 100.0F;
|
||||
float _f6 = (_f1 * 30.0F + _f3 * 70.0F) / 100.0F;
|
||||
_f1 = _f4;
|
||||
_f2 = _f5;
|
||||
_f3 = _f6;
|
||||
}
|
||||
|
||||
if(newState != RENDER_STATE_FAST) {
|
||||
GlStateManager.disableCull();
|
||||
double d0 = this.mc.renderGlobal.getCloudCounter(partialTicks);
|
||||
double d1 = (rve.prevPosX + (rve.posX - rve.prevPosX) * (double) partialTicks + d0 * 0.029999999329447746D) / 12.0D;
|
||||
double d2 = (rve.prevPosZ + (rve.posZ - rve.prevPosZ) * (double) partialTicks) / 12.0D + 0.33000001311302185D;
|
||||
int i = MathHelper.floor_double(d1 / 2048.0D);
|
||||
int j = MathHelper.floor_double(d2 / 2048.0D);
|
||||
d1 = d1 - (double) (i * 2048);
|
||||
d2 = d2 - (double) (j * 2048);
|
||||
float f17 = (float) MathHelper.floor_double(d1) * 0.00390625F;
|
||||
float f18 = (float) MathHelper.floor_double(d2) * 0.00390625F;
|
||||
float f19 = (float) (d1 - (double) MathHelper.floor_double(d1));
|
||||
float f20 = (float) (d2 - (double) MathHelper.floor_double(d2));
|
||||
|
||||
GlStateManager.pushMatrix();
|
||||
GlStateManager.scale(12.0F, 1.0F, 12.0F);
|
||||
|
||||
Matrix4f.mul(GlStateManager.getProjectionReference(), GlStateManager.getModelViewReference(), fancyCloudProjView);
|
||||
frustum.set(fancyCloudProjView);
|
||||
|
||||
visibleCloudParts.clear();
|
||||
|
||||
for (int k = 0; k < 2; ++k) {
|
||||
if (k == 0) {
|
||||
GlStateManager.colorMask(false, false, false, false);
|
||||
} else {
|
||||
switch (pass) {
|
||||
case 0:
|
||||
GlStateManager.colorMask(false, true, true, true);
|
||||
break;
|
||||
case 1:
|
||||
GlStateManager.colorMask(true, false, false, true);
|
||||
break;
|
||||
case 2:
|
||||
GlStateManager.colorMask(true, true, true, true);
|
||||
}
|
||||
}
|
||||
|
||||
int j1;
|
||||
for (int l = -3; l <= 3; ++l) {
|
||||
for (int i1 = -3; i1 <= 3; ++i1) {
|
||||
float f22 = (float) (l * 8);
|
||||
float f23 = (float) (i1 * 8);
|
||||
float f24 = f22 - f19;
|
||||
float f25 = f23 - f20;
|
||||
|
||||
j1 = (l + 3) * 7 + i1 + 3;
|
||||
if(k == 0) {
|
||||
if(frustum.testAab(f24, f3, f25, (f24 + 8.0f), f3 + 4.0f, (f25 + 8.0f))) {
|
||||
visibleCloudParts.set(j1);
|
||||
}else {
|
||||
continue;
|
||||
}
|
||||
}else {
|
||||
if(!visibleCloudParts.get(j1)) {
|
||||
continue;
|
||||
}
|
||||
}
|
||||
|
||||
GlStateManager.pushMatrix();
|
||||
GlStateManager.translate(f24, f3, f25);
|
||||
if(k != 0) {
|
||||
GlStateManager.color(_f1, _f2, _f3, 0.8f);
|
||||
}
|
||||
GlStateManager.matrixMode(GL_TEXTURE);
|
||||
GlStateManager.pushMatrix();
|
||||
GlStateManager.translate(f22 * 0.00390625F + f17, f23 * 0.00390625F + f18, 0.0f);
|
||||
|
||||
int xx = 0;
|
||||
int yy = 0;
|
||||
if (l <= -1) {
|
||||
xx = -1;
|
||||
}else if (l >= 1) {
|
||||
xx = 1;
|
||||
}
|
||||
|
||||
if (i1 <= -1) {
|
||||
yy = -1;
|
||||
}else if (i1 >= 1) {
|
||||
yy = 1;
|
||||
}
|
||||
|
||||
EaglercraftGPU.glCallList(renderListFancy[(yy + 1) * 3 + xx + 1]);
|
||||
|
||||
GlStateManager.popMatrix();
|
||||
GlStateManager.matrixMode(GL_MODELVIEW);
|
||||
GlStateManager.popMatrix();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
GlStateManager.popMatrix();
|
||||
}else {
|
||||
GlStateManager.disableCull();
|
||||
double d2 = this.mc.renderGlobal.getCloudCounter(partialTicks);
|
||||
double d0 = rve.prevPosX + (rve.posX - rve.prevPosX) * (double) partialTicks + d2 * 0.029999999329447746D;
|
||||
double d1 = rve.prevPosZ + (rve.posZ - rve.prevPosZ) * (double) partialTicks;
|
||||
int i = MathHelper.floor_double(d0 / 2048.0D);
|
||||
int j = MathHelper.floor_double(d1 / 2048.0D);
|
||||
d0 = d0 - (double) (i * 2048);
|
||||
d1 = d1 - (double) (j * 2048);
|
||||
float f8 = (float) (d0 * 4.8828125E-4D);
|
||||
float f9 = (float) (d1 * 4.8828125E-4D);
|
||||
GlStateManager.pushMatrix();
|
||||
GlStateManager.translate(0.0f, f3, 0.0f);
|
||||
GlStateManager.color(_f1, _f2, _f3, 0.8f);
|
||||
GlStateManager.matrixMode(GL_TEXTURE);
|
||||
GlStateManager.pushMatrix();
|
||||
GlStateManager.translate(f8, f9, 0.0f);
|
||||
EaglercraftGPU.glCallList(renderList);
|
||||
GlStateManager.popMatrix();
|
||||
GlStateManager.matrixMode(GL_MODELVIEW);
|
||||
GlStateManager.popMatrix();
|
||||
}
|
||||
|
||||
GlStateManager.color(1.0F, 1.0F, 1.0F, 1.0F);
|
||||
GlStateManager.disableBlend();
|
||||
GlStateManager.enableCull();
|
||||
}
|
||||
|
||||
private void rebuild(int newState) {
|
||||
Tessellator tessellator = Tessellator.getInstance();
|
||||
WorldRenderer worldrenderer = tessellator.getWorldRenderer();
|
||||
if(newState != RENDER_STATE_FAST) {
|
||||
if(renderList != -1) {
|
||||
EaglercraftGPU.glDeleteLists(renderList);
|
||||
renderList = -1;
|
||||
}
|
||||
for(int i = 0; i < renderListFancy.length; ++i) {
|
||||
if(renderListFancy[i] == -1) {
|
||||
renderListFancy[i] = EaglercraftGPU.glGenLists();
|
||||
}
|
||||
EaglercraftGPU.glNewList(renderListFancy[i], GL_COMPILE);
|
||||
worldrenderer.begin(7, DefaultVertexFormats.POSITION_TEX_COLOR);
|
||||
generateFancyClouds(worldrenderer, i, newState != RENDER_STATE_FANCY_BELOW, newState != RENDER_STATE_FANCY_ABOVE);
|
||||
tessellator.draw();
|
||||
EaglercraftGPU.glEndList();
|
||||
}
|
||||
}else {
|
||||
if(renderList == -1) {
|
||||
renderList = EaglercraftGPU.glGenLists();
|
||||
}
|
||||
for(int i = 0; i < renderListFancy.length; ++i) {
|
||||
if(renderListFancy[i] != -1) {
|
||||
EaglercraftGPU.glDeleteLists(renderListFancy[i]);
|
||||
renderListFancy[i] = -1;
|
||||
}
|
||||
}
|
||||
EaglercraftGPU.glNewList(renderList, GL_COMPILE);
|
||||
worldrenderer.begin(7, DefaultVertexFormats.POSITION_TEX);
|
||||
final double d = 4.8828125E-4;
|
||||
worldrenderer.pos(-256.0f, 0.0f, 256.0f).tex(-256.0f * d, 256.0f * d).endVertex();
|
||||
worldrenderer.pos(256.0f, 0.0f, 256.0f).tex(256.0f * d, 256.0f * d).endVertex();
|
||||
worldrenderer.pos(256.0f, 0.0f, -256.0f).tex(256.0f * d, -256.0f * d).endVertex();
|
||||
worldrenderer.pos(-256.0f, 0.0f, -256.0f).tex(-256.0f * d, -256.0f * d).endVertex();
|
||||
tessellator.draw();
|
||||
EaglercraftGPU.glEndList();
|
||||
}
|
||||
}
|
||||
|
||||
private static void generateFancyClouds(WorldRenderer worldrenderer, int mesh, boolean renderAbove, boolean renderBelow) {
|
||||
if (renderAbove) {
|
||||
worldrenderer.pos(0.0f, 0.0f, 8.0f).tex(0.0f, 8.0f * 0.00390625F).color(0.7f, 0.7f, 0.7f, 1.0f).endVertex();
|
||||
worldrenderer.pos(8.0f, 0.0f, 8.0f).tex(8.0f * 0.00390625f, 8.0f * 0.00390625f).color(0.7f, 0.7f, 0.7f, 1.0f).endVertex();
|
||||
worldrenderer.pos(8.0f, 0.0f, 0.0f).tex(8.0f * 0.00390625f, 0.0f).color(0.7f, 0.7f, 0.7f, 1.0f).endVertex();
|
||||
worldrenderer.pos(0.0f, 0.0f, 0.0f).tex(0.0f, 0.0f).color(0.7f, 0.7f, 0.7f, 1.0f).endVertex();
|
||||
}
|
||||
|
||||
if (renderBelow) {
|
||||
worldrenderer.pos(0.0f, 4.0f - 9.765625E-4f, 8.0f).tex(0.0f, 8.0f * 0.00390625f).color(1.0f, 1.0f, 1.0f, 1.0f).endVertex();
|
||||
worldrenderer.pos(8.0f, 4.0f - 9.765625E-4f, 8.0f).tex(8.0f * 0.00390625F, 8.0f * 0.00390625f).color(1.0f, 1.0f, 1.0f, 1.0f).endVertex();
|
||||
worldrenderer.pos(8.0f, 4.0f - 9.765625E-4f, 0.0f).tex(8.0f * 0.00390625f, 0.0f).color(1.0f, 1.0f, 1.0f, 1.0f).endVertex();
|
||||
worldrenderer.pos(0.0f, 4.0f - 9.765625E-4f, 0.0f).tex(0.0f, 0.0f).color(1.0f, 1.0f, 1.0f, 1.0f).endVertex();
|
||||
}
|
||||
|
||||
int xx = (mesh % 3) - 1;
|
||||
int yy = (mesh / 3) - 1;
|
||||
|
||||
if (xx != -1) {
|
||||
for (int j1 = 0; j1 < 8; ++j1) {
|
||||
worldrenderer.pos(j1, 0.0f, 8.0f).tex((j1 + 0.5f) * 0.00390625f, 8.0f * 0.00390625f)
|
||||
.color(0.9f, 0.9f, 0.9f, 1.0f).endVertex();
|
||||
worldrenderer.pos(j1, 4.0f, 8.0f).tex((j1 + 0.5f) * 0.00390625f, 8.0f * 0.00390625f)
|
||||
.color(0.9f, 0.9f, 0.9f, 1.0f).endVertex();
|
||||
worldrenderer.pos(j1, 4.0f, 0.0f).tex((j1 + 0.5f) * 0.00390625f, 0.0f).color(0.9f, 0.9f, 0.9f, 1.0f)
|
||||
.endVertex();
|
||||
worldrenderer.pos(j1, 0.0f, 0.0f).tex((j1 + 0.5f) * 0.00390625f, 0.0f).color(0.9f, 0.9f, 0.9f, 1.0f)
|
||||
.endVertex();
|
||||
}
|
||||
}
|
||||
|
||||
if (xx != 1) {
|
||||
for (int k1 = 0; k1 < 8; ++k1) {
|
||||
worldrenderer.pos(k1 + 1.0f - 9.765625E-4f, 0.0f, 8.0f)
|
||||
.tex((k1 + 0.5f) * 0.00390625f, 8.0f * 0.00390625f).color(0.9f, 0.9f, 0.9f, 1.0f).endVertex();
|
||||
worldrenderer.pos(k1 + 1.0f - 9.765625E-4f, 4.0f, 8.0f)
|
||||
.tex((k1 + 0.5f) * 0.00390625f, 8.0f * 0.00390625f).color(0.9f, 0.9f, 0.9f, 1.0f).endVertex();
|
||||
worldrenderer.pos(k1 + 1.0f - 9.765625E-4f, 4.0f, 0.0f).tex((k1 + 0.5f) * 0.00390625f, 0.0f)
|
||||
.color(0.9f, 0.9f, 0.9f, 1.0f).endVertex();
|
||||
worldrenderer.pos(k1 + 1.0f - 9.765625E-4f, 0.0f, 0.0f).tex((k1 + 0.5f) * 0.00390625f, 0.0f)
|
||||
.color(0.9f, 0.9f, 0.9f, 1.0f).endVertex();
|
||||
}
|
||||
}
|
||||
|
||||
if (yy != -1) {
|
||||
for (int l1 = 0; l1 < 8; ++l1) {
|
||||
worldrenderer.pos(0.0f, 4.0f, l1).tex(0.0f, (l1 + 0.5f) * 0.00390625f).color(0.8f, 0.8f, 0.8f, 1.0f)
|
||||
.endVertex();
|
||||
worldrenderer.pos(8.0f, 4.0f, l1).tex(8.0f * 0.00390625f, (l1 + 0.5f) * 0.00390625f)
|
||||
.color(0.8f, 0.8f, 0.8f, 1.0f).endVertex();
|
||||
worldrenderer.pos(8.0f, 0.0f, l1).tex(8.0f * 0.00390625f, (l1 + 0.5f) * 0.00390625f)
|
||||
.color(0.8f, 0.8f, 0.8f, 1.0f).endVertex();
|
||||
worldrenderer.pos(0.0f, 0.0f, l1).tex(0.0f, (l1 + 0.5f) * 0.00390625f).color(0.8f, 0.8f, 0.8f, 1.0f)
|
||||
.endVertex();
|
||||
}
|
||||
}
|
||||
|
||||
if (yy != 1) {
|
||||
for (int i2 = 0; i2 < 8; ++i2) {
|
||||
worldrenderer.pos(0.0f, 4.0f, i2 + 1.0f - 9.765625E-4f).tex(0.0f, (i2 + 0.5f) * 0.00390625f)
|
||||
.color(0.8f, 0.8f, 0.8f, 1.0f).endVertex();
|
||||
worldrenderer.pos(8.0f, 4.0f, i2 + 1.0f - 9.765625E-4f)
|
||||
.tex(8.0f * 0.00390625f, (i2 + 0.5f) * 0.00390625f).color(0.8f, 0.8f, 0.8f, 1.0f).endVertex();
|
||||
worldrenderer.pos(8.0f, 0.0f, i2 + 1.0f - 9.765625E-4f)
|
||||
.tex(8.0f * 0.00390625f, (i2 + 0.5f) * 0.00390625f).color(0.8f, 0.8f, 0.8f, 1.0f).endVertex();
|
||||
worldrenderer.pos(0.0f, 0.0f, i2 + 1.0f - 9.765625E-4f).tex(0.0f, (i2 + 0.5f) * 0.00390625f)
|
||||
.color(0.8f, 0.8f, 0.8f, 1.0f).endVertex();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
|
@ -268,16 +268,19 @@ public class GlStateManager {
|
|||
private static final Vector4f paramVector4 = new Vector4f();
|
||||
public static final void enableMCLight(int light, float diffuse, double dirX,
|
||||
double dirY, double dirZ, double dirW) {
|
||||
if(dirW != 0.0) throw new IllegalArgumentException("dirW must be 0.0!");
|
||||
paramVector4.x = (float)dirX;
|
||||
paramVector4.y = (float)dirY;
|
||||
paramVector4.z = (float)dirZ;
|
||||
paramVector4.w = (float)dirW;
|
||||
paramVector4.w = (float)0.0f;
|
||||
Matrix4f.transform(modelMatrixStack[modelMatrixStackPointer], paramVector4, paramVector4);
|
||||
paramVector4.normalise();
|
||||
Vector4f dest = stateLightsStack[stateLightsStackPointer][light];
|
||||
dest.x = paramVector4.x;
|
||||
dest.y = paramVector4.y;
|
||||
dest.z = paramVector4.z;
|
||||
float len = MathHelper.sqrt_float(paramVector4.x * paramVector4.x
|
||||
+ paramVector4.y * paramVector4.y
|
||||
+ paramVector4.z * paramVector4.z);
|
||||
dest.x = paramVector4.x / len;
|
||||
dest.y = paramVector4.y / len;
|
||||
dest.z = paramVector4.z / len;
|
||||
dest.w = diffuse;
|
||||
stateLightsEnabled[stateLightsStackPointer][light] = true;
|
||||
++stateLightingSerial[stateLightsStackPointer];
|
||||
|
@ -1267,6 +1270,10 @@ public class GlStateManager {
|
|||
return modelMatrixStack[modelMatrixStackPointer];
|
||||
}
|
||||
|
||||
public static final Matrix4f getProjectionReference() {
|
||||
return projectionMatrixStack[projectionMatrixStackPointer];
|
||||
}
|
||||
|
||||
public static void recompileShaders() {
|
||||
FixedFunctionPipeline.flushCache();
|
||||
}
|
||||
|
|
|
@ -18,7 +18,7 @@ import net.lax1dude.eaglercraft.v1_8.internal.buffer.ByteBuffer;
|
|||
*
|
||||
*/
|
||||
public class WorldVertexBufferUploader {
|
||||
public void func_181679_a(WorldRenderer parWorldRenderer) {
|
||||
public static void func_181679_a(WorldRenderer parWorldRenderer) {
|
||||
int cunt = parWorldRenderer.getVertexCount();
|
||||
if (cunt > 0) {
|
||||
VertexFormat fmt = parWorldRenderer.getVertexFormat();
|
||||
|
|
|
@ -1,6 +1,5 @@
|
|||
package net.lax1dude.eaglercraft.v1_8.opengl.ext.deferred.texture;
|
||||
|
||||
import net.lax1dude.eaglercraft.v1_8.internal.IFramebufferGL;
|
||||
import net.minecraft.client.Minecraft;
|
||||
import net.minecraft.util.MathHelper;
|
||||
|
||||
|
|
|
@ -1,6 +1,5 @@
|
|||
package net.lax1dude.eaglercraft.v1_8.opengl.ext.deferred.texture;
|
||||
|
||||
import net.lax1dude.eaglercraft.v1_8.internal.IFramebufferGL;
|
||||
import net.minecraft.client.Minecraft;
|
||||
import net.minecraft.util.BlockPos;
|
||||
import net.minecraft.util.MathHelper;
|
||||
|
|
|
@ -47,7 +47,7 @@ public class SkinPackets {
|
|||
k = i * 3 + 2;
|
||||
packet[k] = v3data[j + 1];
|
||||
packet[k + 1] = v3data[j + 2];
|
||||
packet[k + 2] = (byte)((v3data[j + 3] >>> 1) | (v3data[j] & 0x80));
|
||||
packet[k + 2] = (byte)(((v3data[j + 3] & 0xFF) >>> 1) | (v3data[j] & 0x80));
|
||||
}
|
||||
return packet;
|
||||
}
|
||||
|
|
|
@ -145,7 +145,7 @@ public class GameProtocolMessageController {
|
|||
pkt = sendQueueV4.remove(0);
|
||||
sendFunction.sendPluginMessage(GamePluginMessageConstants.V4_CHANNEL, pkt);
|
||||
}else {
|
||||
int i, j, sendCount, totalLen;
|
||||
int i, j, sendCount, totalLen, lastLen;
|
||||
PacketBuffer sendBuffer;
|
||||
while(sendQueueV4.size() > 0) {
|
||||
sendCount = 0;
|
||||
|
@ -153,11 +153,13 @@ public class GameProtocolMessageController {
|
|||
Iterator<PacketBuffer> itr = sendQueueV4.iterator();
|
||||
do {
|
||||
i = itr.next().readableBytes();
|
||||
totalLen += GamePacketOutputBuffer.getVarIntSize(i) + i;
|
||||
lastLen = GamePacketOutputBuffer.getVarIntSize(i) + i;
|
||||
totalLen += lastLen;
|
||||
++sendCount;
|
||||
}while(totalLen < 32760 && itr.hasNext());
|
||||
if(totalLen >= 32760) {
|
||||
--sendCount;
|
||||
totalLen -= lastLen;
|
||||
}
|
||||
if(sendCount <= 1) {
|
||||
pkt = sendQueueV4.remove(0);
|
||||
|
|
|
@ -6,10 +6,7 @@ import java.util.HashMap;
|
|||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Properties;
|
||||
import java.util.function.Function;
|
||||
|
||||
import net.lax1dude.eaglercraft.v1_8.minecraft.EaglerTextureAtlasSprite;
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.block.properties.IProperty;
|
||||
import net.minecraft.block.state.IBlockState;
|
||||
import net.minecraft.client.Minecraft;
|
||||
|
|
|
@ -2,8 +2,6 @@ package net.optifine;
|
|||
|
||||
import java.io.FileNotFoundException;
|
||||
import java.io.InputStream;
|
||||
import java.io.StringReader;
|
||||
import java.nio.charset.StandardCharsets;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.Collections;
|
||||
|
@ -15,7 +13,6 @@ import java.util.Map;
|
|||
import java.util.Properties;
|
||||
import java.util.Set;
|
||||
|
||||
import net.lax1dude.eaglercraft.v1_8.IOUtils;
|
||||
import net.lax1dude.eaglercraft.v1_8.minecraft.EaglerTextureAtlasSprite;
|
||||
import net.minecraft.block.Block;
|
||||
import net.minecraft.block.BlockGlass;
|
||||
|
|
|
@ -1,7 +1,6 @@
|
|||
package net.optifine;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collection;
|
||||
import java.util.HashMap;
|
||||
import java.util.LinkedHashMap;
|
||||
import java.util.List;
|
||||
|
@ -13,7 +12,6 @@ import java.util.TreeSet;
|
|||
import net.lax1dude.eaglercraft.v1_8.internal.ITextureGL;
|
||||
import net.lax1dude.eaglercraft.v1_8.minecraft.EaglerTextureAtlasSprite;
|
||||
import net.lax1dude.eaglercraft.v1_8.opengl.EaglercraftGPU;
|
||||
import net.lax1dude.eaglercraft.v1_8.opengl.GlStateManager;
|
||||
import net.minecraft.client.Minecraft;
|
||||
import net.minecraft.client.renderer.block.model.BakedQuad;
|
||||
import net.minecraft.client.renderer.block.model.BlockPart;
|
||||
|
|
|
@ -1 +1 @@
|
|||
u48
|
||||
u49
|
Binary file not shown.
|
@ -1 +1 @@
|
|||
{"pluginName":"EaglercraftXBungee","pluginVersion":"1.3.5","pluginButton":"Download \"EaglerXBungee-1.3.5.jar\"","pluginFilename":"EaglerXBungee.zip"}
|
||||
{"pluginName":"EaglercraftXBungee","pluginVersion":"1.3.6","pluginButton":"Download \"EaglerXBungee-1.3.6.jar\"","pluginFilename":"EaglerXBungee.zip"}
|
|
@ -1,8 +1,8 @@
|
|||
client-version-integer=48
|
||||
client-version-integer=49
|
||||
client-package-name=net.lax1dude.eaglercraft.v1_8.client
|
||||
client-origin-name=EaglercraftX
|
||||
client-origin-version=u48
|
||||
client-origin-version=u49
|
||||
client-origin-vendor=lax1dude
|
||||
client-fork-name=EaglercraftX
|
||||
client-fork-version=u48
|
||||
client-fork-version=u49
|
||||
client-fork-vendor=lax1dude
|
||||
|
|
|
@ -328,6 +328,7 @@ public class PlatformInput {
|
|||
public void handleEvent(MouseEvent evt) {
|
||||
evt.preventDefault();
|
||||
evt.stopPropagation();
|
||||
handleWindowFocus();
|
||||
if(tryGrabCursorHook()) return;
|
||||
int b = evt.getButton();
|
||||
b = b == 1 ? 2 : (b == 2 ? 1 : b);
|
||||
|
@ -400,6 +401,7 @@ public class PlatformInput {
|
|||
public void handleEvent(TouchEvent evt) {
|
||||
evt.preventDefault();
|
||||
evt.stopPropagation();
|
||||
handleWindowFocus();
|
||||
SortedTouchEvent sorted = new SortedTouchEvent(evt, touchUIDMapperCreate);
|
||||
currentTouchState = sorted;
|
||||
List<OffsetTouch> lst = sorted.getEventTouches();
|
||||
|
@ -794,6 +796,14 @@ public class PlatformInput {
|
|||
enumerateGamepads();
|
||||
}
|
||||
|
||||
private static void handleWindowFocus() {
|
||||
if(!isWindowFocused) {
|
||||
PlatformRuntime.logger.warn("Detected mouse input while the window was not focused, setting the window focused so the client doesn't pause");
|
||||
isWindowFocused = true;
|
||||
}
|
||||
isMouseOverWindow = true;
|
||||
}
|
||||
|
||||
@JSFunctor
|
||||
private static interface KeyboardLayoutIterator extends JSObject {
|
||||
void call(String key, String val);
|
||||
|
|
|
@ -1,9 +1,11 @@
|
|||
package net.lax1dude.eaglercraft.v1_8.internal.teavm;
|
||||
|
||||
import org.teavm.jso.JSBody;
|
||||
|
||||
import net.lax1dude.eaglercraft.v1_8.sp.server.internal.teavm.WorkerMain;
|
||||
|
||||
/**
|
||||
* Copyright (c) 2022-2024 lax1dude. All Rights Reserved.
|
||||
* Copyright (c) 2022-2025 lax1dude. All Rights Reserved.
|
||||
*
|
||||
* 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
|
||||
|
@ -20,6 +22,7 @@ import net.lax1dude.eaglercraft.v1_8.sp.server.internal.teavm.WorkerMain;
|
|||
public class MainClass {
|
||||
|
||||
public static void main(String[] args) {
|
||||
setStackTraceLimit();
|
||||
if(args.length == 1) {
|
||||
if("_worker_process_".equalsIgnoreCase(args[0])) {
|
||||
workerMain();
|
||||
|
@ -39,4 +42,8 @@ public class MainClass {
|
|||
private static void workerMain() {
|
||||
WorkerMain._main();
|
||||
}
|
||||
|
||||
@JSBody(script = "Error.stackTraceLimit = 1024;")
|
||||
private static native void setStackTraceLimit();
|
||||
|
||||
}
|
||||
|
|
|
@ -23,6 +23,7 @@ import org.teavm.jso.typedarrays.Uint8ClampedArray;
|
|||
|
||||
import net.lax1dude.eaglercraft.v1_8.Base64;
|
||||
import net.lax1dude.eaglercraft.v1_8.internal.buffer.ByteBuffer;
|
||||
import net.lax1dude.eaglercraft.v1_8.internal.buffer.MemoryStack;
|
||||
import net.lax1dude.eaglercraft.v1_8.internal.buffer.WASMGCBufferAllocator;
|
||||
import net.lax1dude.eaglercraft.v1_8.internal.buffer.WASMGCDirectArrayConverter;
|
||||
import net.lax1dude.eaglercraft.v1_8.internal.wasm_gc_teavm.BetterJSStringConverter;
|
||||
|
@ -242,11 +243,11 @@ public class PlatformApplication {
|
|||
}
|
||||
|
||||
public static void downloadFileWithName(String str, byte[] dat) {
|
||||
ByteBuffer buf = WASMGCDirectArrayConverter.byteArrayToBuffer(dat);
|
||||
MemoryStack.push();
|
||||
try {
|
||||
downloadFileWithNameTeaVM(BetterJSStringConverter.stringToJS(str), WASMGCBufferAllocator.getUnsignedByteBufferView(buf));
|
||||
downloadFileWithNameTeaVM(BetterJSStringConverter.stringToJS(str), WASMGCDirectArrayConverter.byteArrayToStackU8Array(dat));
|
||||
}finally {
|
||||
PlatformRuntime.freeByteBuffer(buf);
|
||||
MemoryStack.pop();
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -16,6 +16,7 @@ import org.teavm.jso.typedarrays.Uint8ClampedArray;
|
|||
|
||||
import net.lax1dude.eaglercraft.v1_8.EaglerInputStream;
|
||||
import net.lax1dude.eaglercraft.v1_8.internal.buffer.ByteBuffer;
|
||||
import net.lax1dude.eaglercraft.v1_8.internal.buffer.MemoryStack;
|
||||
import net.lax1dude.eaglercraft.v1_8.internal.buffer.WASMGCBufferAllocator;
|
||||
import net.lax1dude.eaglercraft.v1_8.internal.buffer.WASMGCDirectArrayConverter;
|
||||
import net.lax1dude.eaglercraft.v1_8.internal.wasm_gc_teavm.BetterJSStringConverter;
|
||||
|
@ -163,12 +164,13 @@ public class PlatformAssets {
|
|||
}
|
||||
|
||||
public static ImageData loadImageFile(byte[] data, String mime) {
|
||||
ByteBuffer buf = WASMGCDirectArrayConverter.byteArrayToBuffer(data);
|
||||
JSImageLoadResult asyncResult;
|
||||
MemoryStack.push();
|
||||
try {
|
||||
asyncResult = loadImageFile0(WASMGCBufferAllocator.getUnsignedByteBufferView(buf), BetterJSStringConverter.stringToJS(mime));
|
||||
asyncResult = loadImageFile0(WASMGCDirectArrayConverter.byteArrayToStackU8Array(data),
|
||||
BetterJSStringConverter.stringToJS(mime));
|
||||
}finally {
|
||||
PlatformRuntime.freeByteBuffer(buf);
|
||||
MemoryStack.pop();
|
||||
}
|
||||
|
||||
if(asyncResult == null) {
|
||||
|
@ -178,15 +180,17 @@ public class PlatformAssets {
|
|||
int w = asyncResult.getWidth();
|
||||
int h = asyncResult.getHeight();
|
||||
int len = w * h;
|
||||
int len2 = len << 2;
|
||||
|
||||
ByteBuffer dataDest = PlatformRuntime.allocateByteBuffer(len << 2);
|
||||
MemoryStack.push();
|
||||
try {
|
||||
loadImageFile1(asyncResult, WASMGCBufferAllocator.getUnsignedClampedByteBufferView(dataDest));
|
||||
Address dataDest = MemoryStack.malloc(len2);
|
||||
loadImageFile1(asyncResult, WASMGCBufferAllocator.getUnsignedClampedByteBufferView0(dataDest, len2));
|
||||
int[] pixelsArray = new int[len];
|
||||
copyPixelArrayFast(pixelsArray, WASMGCBufferAllocator.getByteBufferAddress(dataDest), len);
|
||||
copyPixelArrayFast(pixelsArray, dataDest, len2);
|
||||
return new ImageData(w, h, pixelsArray, true);
|
||||
}finally {
|
||||
PlatformRuntime.freeByteBuffer(dataDest);
|
||||
MemoryStack.pop();
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -208,7 +212,7 @@ public class PlatformAssets {
|
|||
|
||||
@Unmanaged
|
||||
private static void copyPixelArrayFast(int[] pixelsArray, Address addr, int count) {
|
||||
Address addrEnd = addr.add(count << 2);
|
||||
Address addrEnd = addr.add(count);
|
||||
int dstOffset = 0;
|
||||
while(addr.isLessThan(addrEnd)) {
|
||||
pixelsArray[dstOffset] = addr.getInt();
|
||||
|
|
|
@ -23,8 +23,7 @@ import org.teavm.jso.webaudio.MediaStreamAudioDestinationNode;
|
|||
import org.teavm.jso.webaudio.PannerNode;
|
||||
|
||||
import net.lax1dude.eaglercraft.v1_8.EagRuntime;
|
||||
import net.lax1dude.eaglercraft.v1_8.internal.buffer.ByteBuffer;
|
||||
import net.lax1dude.eaglercraft.v1_8.internal.buffer.WASMGCBufferAllocator;
|
||||
import net.lax1dude.eaglercraft.v1_8.internal.buffer.MemoryStack;
|
||||
import net.lax1dude.eaglercraft.v1_8.internal.buffer.WASMGCDirectArrayConverter;
|
||||
import net.lax1dude.eaglercraft.v1_8.internal.wasm_gc_teavm.BetterJSStringConverter;
|
||||
import net.lax1dude.eaglercraft.v1_8.internal.wasm_gc_teavm.JOrbisAudioBufferDecoder;
|
||||
|
@ -79,16 +78,16 @@ public class PlatformAudio {
|
|||
logger.info("Note: Using embedded JOrbis OGG decoder");
|
||||
}else {
|
||||
byte[] fileData = EagRuntime.getRequiredResourceBytes("/assets/eagler/audioctx_test_ogg.dat");
|
||||
ByteBuffer buf = WASMGCDirectArrayConverter.byteArrayToBuffer(fileData);
|
||||
MemoryStack.push();
|
||||
try {
|
||||
AudioBuffer audioBuffer = decodeAudioBrowserAsync(WASMGCBufferAllocator.getUnsignedByteBufferView(buf),
|
||||
AudioBuffer audioBuffer = decodeAudioBrowserAsync(WASMGCDirectArrayConverter.byteArrayToStackU8Array(fileData),
|
||||
BetterJSStringConverter.stringToJS("audioctx_test_ogg.dat"));
|
||||
if(audioBuffer != null && audioBuffer.getLength() > 0) {
|
||||
oggSupport = true;
|
||||
}
|
||||
}catch(Throwable t) {
|
||||
}finally {
|
||||
PlatformRuntime.freeByteBuffer(buf);
|
||||
MemoryStack.pop();
|
||||
}
|
||||
if(!oggSupport) {
|
||||
logger.error("OGG file support detected as false! Using embedded JOrbis OGG decoder");
|
||||
|
@ -294,27 +293,17 @@ public class PlatformAudio {
|
|||
if(data == null) {
|
||||
return null;
|
||||
}
|
||||
if(oggSupport) {
|
||||
ByteBuffer buf = WASMGCDirectArrayConverter.byteArrayToBuffer(data);
|
||||
if(oggSupport || !(data.length > 4 && data[0] == (byte) 0x4F && data[1] == (byte) 0x67 && data[2] == (byte) 0x67
|
||||
&& data[3] == (byte) 0x53)) {
|
||||
MemoryStack.push();
|
||||
try {
|
||||
return decodeAudioBrowserAsync(WASMGCBufferAllocator.getUnsignedByteBufferView(buf),
|
||||
return decodeAudioBrowserAsync(WASMGCDirectArrayConverter.byteArrayToStackU8Array(data),
|
||||
BetterJSStringConverter.stringToJS(errorFileName));
|
||||
}finally {
|
||||
PlatformRuntime.freeByteBuffer(buf);
|
||||
MemoryStack.pop();
|
||||
}
|
||||
}else {
|
||||
if (data.length > 4 && data[0] == (byte) 0x4F && data[1] == (byte) 0x67 && data[2] == (byte) 0x67
|
||||
&& data[3] == (byte) 0x53) {
|
||||
return JOrbisAudioBufferDecoder.decodeAudioJOrbis(data, errorFileName);
|
||||
}else {
|
||||
ByteBuffer buf = WASMGCDirectArrayConverter.byteArrayToBuffer(data);
|
||||
try {
|
||||
return decodeAudioBrowserAsync(WASMGCBufferAllocator.getUnsignedByteBufferView(buf),
|
||||
BetterJSStringConverter.stringToJS(errorFileName));
|
||||
}finally {
|
||||
PlatformRuntime.freeByteBuffer(buf);
|
||||
}
|
||||
}
|
||||
return JOrbisAudioBufferDecoder.decodeAudioJOrbis(data, errorFileName);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -382,6 +382,7 @@ public class PlatformInput {
|
|||
int posY = windowHeight - (int)(obj.getPosY() * windowDPI) - 1;
|
||||
switch(type) {
|
||||
case EVENT_MOUSE_DOWN: {
|
||||
handleWindowFocus();
|
||||
int button = obj.getButton();
|
||||
button = button == 1 ? 2 : (button == 2 ? 1 : button);
|
||||
if(button >= 0 && button < buttonStates.length) {
|
||||
|
@ -466,6 +467,7 @@ public class PlatformInput {
|
|||
JSTouchEvent obj = evt.getEventObj();
|
||||
switch(obj.getEventType()) {
|
||||
case EVENT_TOUCH_START:
|
||||
handleWindowFocus();
|
||||
touchEvents.add(currentTouchState = SortedTouchEvent.createTouchEvent(EnumTouchEvent.TOUCHSTART, obj.getChangedTouches(),
|
||||
obj.getTargetTouches(), touchUIDMapperCreate, windowHeight, windowDPI));
|
||||
break;
|
||||
|
@ -598,6 +600,14 @@ public class PlatformInput {
|
|||
}
|
||||
}
|
||||
|
||||
private static void handleWindowFocus() {
|
||||
if(!isWindowFocused) {
|
||||
PlatformRuntime.logger.warn("Detected mouse input while the window was not focused, setting the window focused so the client doesn't pause");
|
||||
isWindowFocused = true;
|
||||
}
|
||||
isMouseOverWindow = true;
|
||||
}
|
||||
|
||||
public static int getWindowWidth() {
|
||||
return windowWidth;
|
||||
}
|
||||
|
|
|
@ -12,8 +12,7 @@ import org.teavm.jso.core.JSArray;
|
|||
import org.teavm.jso.core.JSString;
|
||||
import org.teavm.jso.typedarrays.Uint8Array;
|
||||
|
||||
import net.lax1dude.eaglercraft.v1_8.internal.buffer.ByteBuffer;
|
||||
import net.lax1dude.eaglercraft.v1_8.internal.buffer.WASMGCBufferAllocator;
|
||||
import net.lax1dude.eaglercraft.v1_8.internal.buffer.MemoryStack;
|
||||
import net.lax1dude.eaglercraft.v1_8.internal.buffer.WASMGCDirectArrayConverter;
|
||||
import net.lax1dude.eaglercraft.v1_8.internal.wasm_gc_teavm.BetterJSStringConverter;
|
||||
import net.lax1dude.eaglercraft.v1_8.log4j.LogManager;
|
||||
|
@ -67,11 +66,11 @@ public class PlatformWebRTC {
|
|||
public static native void clientLANCloseConnection();
|
||||
|
||||
public static void clientLANSendPacket(byte[] pkt) {
|
||||
ByteBuffer buf = WASMGCDirectArrayConverter.byteArrayToBuffer(pkt);
|
||||
MemoryStack.push();
|
||||
try {
|
||||
clientLANSendPacket0(WASMGCBufferAllocator.getUnsignedByteBufferView(buf));
|
||||
clientLANSendPacket0(WASMGCDirectArrayConverter.byteArrayToStackU8Array(pkt));
|
||||
}finally {
|
||||
PlatformRuntime.freeByteBuffer(buf);
|
||||
MemoryStack.pop();
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -254,11 +253,11 @@ public class PlatformWebRTC {
|
|||
|
||||
private void writePacket(byte[] pkt) {
|
||||
if(dead) return;
|
||||
ByteBuffer buf = WASMGCDirectArrayConverter.byteArrayToBuffer(pkt);
|
||||
MemoryStack.push();
|
||||
try {
|
||||
handle.writePacket(WASMGCBufferAllocator.getUnsignedByteBufferView(buf));
|
||||
handle.writePacket(WASMGCDirectArrayConverter.byteArrayToStackU8Array(pkt));
|
||||
}finally {
|
||||
PlatformRuntime.freeByteBuffer(buf);
|
||||
MemoryStack.pop();
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -14,8 +14,7 @@ import org.teavm.jso.typedarrays.ArrayBuffer;
|
|||
import org.teavm.jso.typedarrays.Uint8Array;
|
||||
|
||||
import net.lax1dude.eaglercraft.v1_8.internal.PlatformRuntime.JSEagRuntimeEvent;
|
||||
import net.lax1dude.eaglercraft.v1_8.internal.buffer.ByteBuffer;
|
||||
import net.lax1dude.eaglercraft.v1_8.internal.buffer.WASMGCBufferAllocator;
|
||||
import net.lax1dude.eaglercraft.v1_8.internal.buffer.MemoryStack;
|
||||
import net.lax1dude.eaglercraft.v1_8.internal.buffer.WASMGCDirectArrayConverter;
|
||||
import net.lax1dude.eaglercraft.v1_8.internal.wasm_gc_teavm.BetterJSStringConverter;
|
||||
import net.lax1dude.eaglercraft.v1_8.log4j.LogManager;
|
||||
|
@ -224,12 +223,12 @@ public class PlatformWebView {
|
|||
sendStringMessage(BetterJSStringConverter.stringToJS(currentMessageChannelName),
|
||||
BetterJSStringConverter.stringToJS(new String(packet.data, StandardCharsets.UTF_8)));
|
||||
}else if(packet.type == SPacketWebViewMessageV4EAG.TYPE_BINARY) {
|
||||
ByteBuffer buf = WASMGCDirectArrayConverter.byteArrayToBuffer(packet.data);
|
||||
MemoryStack.push();
|
||||
try {
|
||||
sendBinaryMessage(BetterJSStringConverter.stringToJS(currentMessageChannelName),
|
||||
WASMGCBufferAllocator.getUnsignedByteBufferView(buf));
|
||||
WASMGCDirectArrayConverter.byteArrayToStackU8Array(packet.data));
|
||||
}finally {
|
||||
PlatformRuntime.freeByteBuffer(buf);
|
||||
MemoryStack.pop();
|
||||
}
|
||||
}
|
||||
}else {
|
||||
|
@ -342,12 +341,12 @@ public class PlatformWebView {
|
|||
JSWebViewOptions opts = makeOptions(isBlob ? 1 : 0, BetterJSStringConverter.stringToJS(options.fallbackTitle),
|
||||
options.scriptEnabled, options.strictCSPEnable, options.serverMessageAPIEnabled);
|
||||
if(isBlob) {
|
||||
ByteBuffer buf = WASMGCDirectArrayConverter.byteArrayToBuffer(options.blob);
|
||||
MemoryStack.push();
|
||||
try {
|
||||
opts.setBlob(WASMGCBufferAllocator.getUnsignedByteBufferView(buf));
|
||||
opts.setBlob(WASMGCDirectArrayConverter.byteArrayToStackU8Array(options.blob));
|
||||
beginShowing0(state, opts, x, y, w, h);
|
||||
}finally {
|
||||
PlatformRuntime.freeByteBuffer(buf);
|
||||
MemoryStack.pop();
|
||||
}
|
||||
}else {
|
||||
opts.setURI(BetterJSStringConverter.stringToJS(options.url.toString()));
|
||||
|
|
|
@ -0,0 +1,131 @@
|
|||
package net.lax1dude.eaglercraft.v1_8.internal.buffer;
|
||||
|
||||
import org.teavm.interop.Address;
|
||||
import org.teavm.interop.DirectMalloc;
|
||||
|
||||
/**
|
||||
* Copyright (c) 2025 lax1dude. All Rights Reserved.
|
||||
*
|
||||
* 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 HOLDER 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.
|
||||
*
|
||||
*/
|
||||
public class MemoryStack {
|
||||
|
||||
public static final int STACK_SIZE = 2 * 1024 * 1024;
|
||||
public static final int MALLOC_THRESHOLD = 512 * 1024;
|
||||
public static final int RESERVE_SIZE = 64 * 1024;
|
||||
|
||||
public static final Address stackBase;
|
||||
public static final Address stackMax;
|
||||
|
||||
private static Address stackBottomPointer;
|
||||
private static Address stackTopPointer;
|
||||
|
||||
static {
|
||||
stackBase = DirectMalloc.malloc(STACK_SIZE + 16);
|
||||
if(stackBase.toInt() == 0) {
|
||||
throw new IllegalStateException("Could not allocate MemoryStack of size " + STACK_SIZE);
|
||||
}
|
||||
stackMax = stackBase.add(STACK_SIZE);
|
||||
stackBottomPointer = stackBase;
|
||||
stackBottomPointer.putInt(0);
|
||||
stackBottomPointer.add(4).putInt(0);
|
||||
stackTopPointer = stackBottomPointer.add(8);
|
||||
}
|
||||
|
||||
public static void push() {
|
||||
stackTopPointer.putAddress(stackBottomPointer);
|
||||
stackTopPointer.add(4).putInt(0);
|
||||
stackBottomPointer = stackTopPointer;
|
||||
stackTopPointer = stackBottomPointer.add(8);
|
||||
if(stackTopPointer.toInt() > stackMax.toInt()) {
|
||||
throw new StackOverflowError();
|
||||
}
|
||||
}
|
||||
|
||||
public static void pop() {
|
||||
stackTopPointer = stackBottomPointer;
|
||||
stackBottomPointer = stackTopPointer.getAddress();
|
||||
Address cleanup = stackTopPointer.add(4).getAddress();
|
||||
while(cleanup.toInt() != 0) {
|
||||
WASMGCBufferAllocator.free(cleanup.getAddress());
|
||||
cleanup = cleanup.add(4).getAddress();
|
||||
}
|
||||
if(stackBottomPointer.toInt() == 0) {
|
||||
throw new IllegalStateException("MemoryStack underflow");
|
||||
}
|
||||
}
|
||||
|
||||
public static Address malloc(int length) {
|
||||
if(length > MALLOC_THRESHOLD || (stackMax.toInt() - stackTopPointer.toInt()) < RESERVE_SIZE) {
|
||||
if(stackTopPointer.toInt() + 8 > stackMax.toInt()) {
|
||||
throw new StackOverflowError();
|
||||
}
|
||||
Address malloced = WASMGCBufferAllocator.malloc(length);
|
||||
Address cleanup = stackBottomPointer.add(4).getAddress();
|
||||
stackTopPointer.putAddress(malloced);
|
||||
stackTopPointer.add(4).putAddress(cleanup);
|
||||
stackBottomPointer.add(4).putAddress(stackTopPointer);
|
||||
stackTopPointer = stackTopPointer.add(8);
|
||||
return malloced;
|
||||
}else {
|
||||
Address ret = stackTopPointer;
|
||||
stackTopPointer = stackTopPointer.add((length + 3) & 0xFFFFFFFC);
|
||||
return ret;
|
||||
}
|
||||
}
|
||||
|
||||
public static ByteBuffer mallocByteBuffer(int length) {
|
||||
return new DirectMallocByteBuffer(malloc(length), length, false);
|
||||
}
|
||||
|
||||
public static IntBuffer mallocIntBuffer(int length) {
|
||||
return new DirectMallocIntBuffer(malloc(length << 2), length, false);
|
||||
}
|
||||
|
||||
public static FloatBuffer mallocFloatBuffer(int length) {
|
||||
return new DirectMallocFloatBuffer(malloc(length << 2), length, false);
|
||||
}
|
||||
|
||||
public static Address calloc(int length) {
|
||||
if(length > MALLOC_THRESHOLD || (stackMax.toInt() - stackTopPointer.toInt()) < RESERVE_SIZE) {
|
||||
if(stackTopPointer.toInt() + 8 > stackMax.toInt()) {
|
||||
throw new StackOverflowError();
|
||||
}
|
||||
Address malloced = WASMGCBufferAllocator.calloc(length);
|
||||
Address cleanup = stackBottomPointer.add(4).getAddress();
|
||||
stackTopPointer.putAddress(malloced);
|
||||
stackTopPointer.add(4).putAddress(cleanup);
|
||||
stackBottomPointer.add(4).putAddress(stackTopPointer);
|
||||
stackTopPointer = stackTopPointer.add(8);
|
||||
return malloced;
|
||||
}else {
|
||||
DirectMalloc.zmemset(stackTopPointer, length);
|
||||
Address ret = stackTopPointer;
|
||||
stackTopPointer = stackTopPointer.add((length + 3) & 0xFFFFFFFC);
|
||||
return ret;
|
||||
}
|
||||
}
|
||||
|
||||
public static ByteBuffer callocByteBuffer(int length) {
|
||||
return new DirectMallocByteBuffer(calloc(length), length, false);
|
||||
}
|
||||
|
||||
public static IntBuffer callocIntBuffer(int length) {
|
||||
return new DirectMallocIntBuffer(calloc(length << 2), length, false);
|
||||
}
|
||||
|
||||
public static FloatBuffer callocFloatBuffer(int length) {
|
||||
return new DirectMallocFloatBuffer(calloc(length << 2), length, false);
|
||||
}
|
||||
|
||||
}
|
|
@ -10,7 +10,7 @@ import org.teavm.jso.typedarrays.Uint8Array;
|
|||
import org.teavm.jso.typedarrays.Uint8ClampedArray;
|
||||
|
||||
/**
|
||||
* Copyright (c) 2024 lax1dude. All Rights Reserved.
|
||||
* Copyright (c) 2024-2025 lax1dude. All Rights Reserved.
|
||||
*
|
||||
* 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
|
||||
|
@ -33,6 +33,13 @@ public class WASMGCDirectArrayConverter {
|
|||
return new DirectMallocByteBuffer(ret, len, true);
|
||||
}
|
||||
|
||||
public static ByteBuffer byteArrayToStackBuffer(byte[] byteArray) {
|
||||
int len = byteArray.length;
|
||||
Address ret = MemoryStack.malloc(len);
|
||||
WASMGCDirectArrayCopy.memcpy(ret, byteArray, 0, len);
|
||||
return new DirectMallocByteBuffer(ret, len, true);
|
||||
}
|
||||
|
||||
public static ByteBuffer byteArrayToBuffer(byte[] byteArray, int offset, int length) {
|
||||
if(offset < 0) throw Buffer.makeIOOBE(offset);
|
||||
if(offset + length > byteArray.length) throw Buffer.makeIOOBE(offset + length - 1);
|
||||
|
@ -41,6 +48,14 @@ public class WASMGCDirectArrayConverter {
|
|||
return new DirectMallocByteBuffer(ret, length, true);
|
||||
}
|
||||
|
||||
public static ByteBuffer byteArrayToStackBuffer(byte[] byteArray, int offset, int length) {
|
||||
if(offset < 0) throw Buffer.makeIOOBE(offset);
|
||||
if(offset + length > byteArray.length) throw Buffer.makeIOOBE(offset + length - 1);
|
||||
Address ret = MemoryStack.malloc(length);
|
||||
WASMGCDirectArrayCopy.memcpy(ret, byteArray, offset, length);
|
||||
return new DirectMallocByteBuffer(ret, length, true);
|
||||
}
|
||||
|
||||
public static ShortBuffer shortArrayToBuffer(short[] shortArray) {
|
||||
int len = shortArray.length;
|
||||
Address ret = WASMGCBufferAllocator.malloc(len << 1);
|
||||
|
@ -48,6 +63,13 @@ public class WASMGCDirectArrayConverter {
|
|||
return new DirectMallocShortBuffer(ret, len, true);
|
||||
}
|
||||
|
||||
public static ShortBuffer shortArrayToStackBuffer(short[] shortArray) {
|
||||
int len = shortArray.length;
|
||||
Address ret = MemoryStack.malloc(len << 1);
|
||||
WASMGCDirectArrayCopy.memcpy(ret, shortArray, 0, len);
|
||||
return new DirectMallocShortBuffer(ret, len, true);
|
||||
}
|
||||
|
||||
public static ShortBuffer shortArrayToBuffer(short[] shortArray, int offset, int length) {
|
||||
if(offset < 0) throw Buffer.makeIOOBE(offset);
|
||||
if(offset + length > shortArray.length) throw Buffer.makeIOOBE(offset + length - 1);
|
||||
|
@ -56,6 +78,14 @@ public class WASMGCDirectArrayConverter {
|
|||
return new DirectMallocShortBuffer(ret, length, true);
|
||||
}
|
||||
|
||||
public static ShortBuffer shortArrayToStackBuffer(short[] shortArray, int offset, int length) {
|
||||
if(offset < 0) throw Buffer.makeIOOBE(offset);
|
||||
if(offset + length > shortArray.length) throw Buffer.makeIOOBE(offset + length - 1);
|
||||
Address ret = MemoryStack.malloc(length << 1);
|
||||
WASMGCDirectArrayCopy.memcpy(ret, shortArray, offset, length);
|
||||
return new DirectMallocShortBuffer(ret, length, true);
|
||||
}
|
||||
|
||||
public static IntBuffer intArrayToBuffer(int[] intArray) {
|
||||
int len = intArray.length;
|
||||
Address ret = WASMGCBufferAllocator.malloc(len << 2);
|
||||
|
@ -63,6 +93,13 @@ public class WASMGCDirectArrayConverter {
|
|||
return new DirectMallocIntBuffer(ret, len, true);
|
||||
}
|
||||
|
||||
public static IntBuffer intArrayToStackBuffer(int[] intArray) {
|
||||
int len = intArray.length;
|
||||
Address ret = MemoryStack.malloc(len << 2);
|
||||
WASMGCDirectArrayCopy.memcpy(ret, intArray, 0, len);
|
||||
return new DirectMallocIntBuffer(ret, len, true);
|
||||
}
|
||||
|
||||
public static IntBuffer intArrayToBuffer(int[] intArray, int offset, int length) {
|
||||
if(offset < 0) throw Buffer.makeIOOBE(offset);
|
||||
if(offset + length > intArray.length) throw Buffer.makeIOOBE(offset + length - 1);
|
||||
|
@ -71,6 +108,14 @@ public class WASMGCDirectArrayConverter {
|
|||
return new DirectMallocIntBuffer(ret, length, true);
|
||||
}
|
||||
|
||||
public static IntBuffer intArrayToStackBuffer(int[] intArray, int offset, int length) {
|
||||
if(offset < 0) throw Buffer.makeIOOBE(offset);
|
||||
if(offset + length > intArray.length) throw Buffer.makeIOOBE(offset + length - 1);
|
||||
Address ret = MemoryStack.malloc(length << 2);
|
||||
WASMGCDirectArrayCopy.memcpy(ret, intArray, offset, length);
|
||||
return new DirectMallocIntBuffer(ret, length, true);
|
||||
}
|
||||
|
||||
public static FloatBuffer floatArrayToBuffer(float[] floatArray) {
|
||||
int len = floatArray.length;
|
||||
Address ret = WASMGCBufferAllocator.malloc(len << 2);
|
||||
|
@ -78,6 +123,13 @@ public class WASMGCDirectArrayConverter {
|
|||
return new DirectMallocFloatBuffer(ret, len, true);
|
||||
}
|
||||
|
||||
public static FloatBuffer floatArrayToStackBuffer(float[] floatArray) {
|
||||
int len = floatArray.length;
|
||||
Address ret = MemoryStack.malloc(len << 2);
|
||||
WASMGCDirectArrayCopy.memcpy(ret, floatArray, 0, len);
|
||||
return new DirectMallocFloatBuffer(ret, len, true);
|
||||
}
|
||||
|
||||
public static FloatBuffer floatArrayToBuffer(float[] floatArray, int offset, int length) {
|
||||
if(offset < 0) throw Buffer.makeIOOBE(offset);
|
||||
if(offset + length > floatArray.length) throw Buffer.makeIOOBE(offset + length - 1);
|
||||
|
@ -86,6 +138,14 @@ public class WASMGCDirectArrayConverter {
|
|||
return new DirectMallocFloatBuffer(ret, length, true);
|
||||
}
|
||||
|
||||
public static FloatBuffer floatArrayToStackBuffer(float[] floatArray, int offset, int length) {
|
||||
if(offset < 0) throw Buffer.makeIOOBE(offset);
|
||||
if(offset + length > floatArray.length) throw Buffer.makeIOOBE(offset + length - 1);
|
||||
Address ret = MemoryStack.malloc(length << 2);
|
||||
WASMGCDirectArrayCopy.memcpy(ret, floatArray, offset, length);
|
||||
return new DirectMallocFloatBuffer(ret, length, true);
|
||||
}
|
||||
|
||||
private static final Uint8Array UINT8ZeroLength = new Uint8Array(0);
|
||||
private static final Uint8ClampedArray UINT8CZeroLength = new Uint8ClampedArray(0);
|
||||
private static final Int8Array INT8ZeroLength = new Int8Array(0);
|
||||
|
@ -99,148 +159,269 @@ public class WASMGCDirectArrayConverter {
|
|||
if(len == 0) {
|
||||
return UINT8ZeroLength;
|
||||
}
|
||||
Address addr = WASMGCBufferAllocator.malloc(len);
|
||||
MemoryStack.push();
|
||||
Address addr = MemoryStack.malloc(len);
|
||||
WASMGCDirectArrayCopy.memcpy(addr, byteArray, 0, len);
|
||||
Uint8Array ret = new Uint8Array(len);
|
||||
ret.set(WASMGCBufferAllocator.getUnsignedByteBufferView0(addr, len));
|
||||
WASMGCBufferAllocator.free(addr);
|
||||
MemoryStack.pop();
|
||||
return ret;
|
||||
}
|
||||
|
||||
public static Uint8Array byteArrayToStackU8Array(byte[] byteArray) {
|
||||
int len = byteArray.length;
|
||||
if(len == 0) {
|
||||
return UINT8ZeroLength;
|
||||
}
|
||||
Address addr = MemoryStack.malloc(len);
|
||||
WASMGCDirectArrayCopy.memcpy(addr, byteArray, 0, len);
|
||||
return WASMGCBufferAllocator.getUnsignedByteBufferView0(addr, len);
|
||||
}
|
||||
|
||||
public static Uint8ClampedArray byteArrayToExternU8CArray(byte[] byteArray) {
|
||||
int len = byteArray.length;
|
||||
if(len == 0) {
|
||||
return UINT8CZeroLength;
|
||||
}
|
||||
Address addr = WASMGCBufferAllocator.malloc(len);
|
||||
MemoryStack.push();
|
||||
Address addr = MemoryStack.malloc(len);
|
||||
WASMGCDirectArrayCopy.memcpy(addr, byteArray, 0, len);
|
||||
Uint8ClampedArray ret = new Uint8ClampedArray(len);
|
||||
ret.set(WASMGCBufferAllocator.getUnsignedClampedByteBufferView0(addr, len));
|
||||
WASMGCBufferAllocator.free(addr);
|
||||
MemoryStack.pop();
|
||||
return ret;
|
||||
}
|
||||
|
||||
public static Uint8ClampedArray byteArrayToStackU8CArray(byte[] byteArray) {
|
||||
int len = byteArray.length;
|
||||
if(len == 0) {
|
||||
return UINT8CZeroLength;
|
||||
}
|
||||
Address addr = MemoryStack.malloc(len);
|
||||
WASMGCDirectArrayCopy.memcpy(addr, byteArray, 0, len);
|
||||
return WASMGCBufferAllocator.getUnsignedClampedByteBufferView0(addr, len);
|
||||
}
|
||||
|
||||
public static Int8Array byteArrayToExternI8Array(byte[] byteArray) {
|
||||
int len = byteArray.length;
|
||||
if(len == 0) {
|
||||
return INT8ZeroLength;
|
||||
}
|
||||
Address addr = WASMGCBufferAllocator.malloc(len);
|
||||
MemoryStack.push();
|
||||
Address addr = MemoryStack.malloc(len);
|
||||
WASMGCDirectArrayCopy.memcpy(addr, byteArray, 0, len);
|
||||
Int8Array ret = new Int8Array(len);
|
||||
ret.set(WASMGCBufferAllocator.getByteBufferView0(addr, len));
|
||||
WASMGCBufferAllocator.free(addr);
|
||||
MemoryStack.pop();
|
||||
return ret;
|
||||
}
|
||||
|
||||
public static Int8Array byteArrayToStackI8Array(byte[] byteArray) {
|
||||
int len = byteArray.length;
|
||||
if(len == 0) {
|
||||
return INT8ZeroLength;
|
||||
}
|
||||
Address addr = MemoryStack.malloc(len);
|
||||
WASMGCDirectArrayCopy.memcpy(addr, byteArray, 0, len);
|
||||
return WASMGCBufferAllocator.getByteBufferView0(addr, len);
|
||||
}
|
||||
|
||||
public static Uint16Array byteArrayToExternU16Array(byte[] byteArray) {
|
||||
int len = byteArray.length & 0xFFFFFFFE;
|
||||
if(len == 0) {
|
||||
return UINT16ZeroLength;
|
||||
}
|
||||
Address addr = WASMGCBufferAllocator.malloc(len);
|
||||
MemoryStack.push();
|
||||
Address addr = MemoryStack.malloc(len);
|
||||
WASMGCDirectArrayCopy.memcpy(addr, byteArray, 0, len);
|
||||
len >>= 1;
|
||||
Uint16Array ret = new Uint16Array(len);
|
||||
ret.set(WASMGCBufferAllocator.getUnsignedShortBufferView0(addr, len));
|
||||
WASMGCBufferAllocator.free(addr);
|
||||
MemoryStack.pop();
|
||||
return ret;
|
||||
}
|
||||
|
||||
public static Uint16Array byteArrayToStackU16Array(byte[] byteArray) {
|
||||
int len = byteArray.length & 0xFFFFFFFE;
|
||||
if(len == 0) {
|
||||
return UINT16ZeroLength;
|
||||
}
|
||||
Address addr = MemoryStack.malloc(len);
|
||||
WASMGCDirectArrayCopy.memcpy(addr, byteArray, 0, len);
|
||||
return WASMGCBufferAllocator.getUnsignedShortBufferView0(addr, len >> 1);
|
||||
}
|
||||
|
||||
public static Int16Array byteArrayToExternI16Array(byte[] byteArray) {
|
||||
int len = byteArray.length & 0xFFFFFFFE;
|
||||
if(len == 0) {
|
||||
return INT16ZeroLength;
|
||||
}
|
||||
Address addr = WASMGCBufferAllocator.malloc(len);
|
||||
MemoryStack.push();
|
||||
Address addr = MemoryStack.malloc(len);
|
||||
WASMGCDirectArrayCopy.memcpy(addr, byteArray, 0, len);
|
||||
len >>= 1;
|
||||
Int16Array ret = new Int16Array(len);
|
||||
ret.set(WASMGCBufferAllocator.getShortBufferView0(addr, len));
|
||||
WASMGCBufferAllocator.free(addr);
|
||||
MemoryStack.pop();
|
||||
return ret;
|
||||
}
|
||||
|
||||
public static Int16Array byteArrayToStackI16Array(byte[] byteArray) {
|
||||
int len = byteArray.length & 0xFFFFFFFE;
|
||||
if(len == 0) {
|
||||
return INT16ZeroLength;
|
||||
}
|
||||
Address addr = MemoryStack.malloc(len);
|
||||
WASMGCDirectArrayCopy.memcpy(addr, byteArray, 0, len);
|
||||
return WASMGCBufferAllocator.getShortBufferView0(addr, len >> 1);
|
||||
}
|
||||
|
||||
public static Uint16Array shortArrayToExternU16Array(short[] shortArray) {
|
||||
int len = shortArray.length;
|
||||
if(len == 0) {
|
||||
return UINT16ZeroLength;
|
||||
}
|
||||
Address addr = WASMGCBufferAllocator.malloc(len << 1);
|
||||
MemoryStack.push();
|
||||
Address addr = MemoryStack.malloc(len << 1);
|
||||
WASMGCDirectArrayCopy.memcpy(addr, shortArray, 0, len);
|
||||
Uint16Array ret = new Uint16Array(len);
|
||||
ret.set(WASMGCBufferAllocator.getUnsignedShortBufferView0(addr, len));
|
||||
WASMGCBufferAllocator.free(addr);
|
||||
MemoryStack.pop();
|
||||
return ret;
|
||||
}
|
||||
|
||||
public static Uint16Array shortArrayToStackU16Array(short[] shortArray) {
|
||||
int len = shortArray.length;
|
||||
if(len == 0) {
|
||||
return UINT16ZeroLength;
|
||||
}
|
||||
Address addr = MemoryStack.malloc(len << 1);
|
||||
WASMGCDirectArrayCopy.memcpy(addr, shortArray, 0, len);
|
||||
return WASMGCBufferAllocator.getUnsignedShortBufferView0(addr, len);
|
||||
}
|
||||
|
||||
public static Int16Array shortArrayToExternI16Array(short[] shortArray) {
|
||||
int len = shortArray.length;
|
||||
if(len == 0) {
|
||||
return INT16ZeroLength;
|
||||
}
|
||||
Address addr = WASMGCBufferAllocator.malloc(len << 1);
|
||||
MemoryStack.push();
|
||||
Address addr = MemoryStack.malloc(len << 1);
|
||||
WASMGCDirectArrayCopy.memcpy(addr, shortArray, 0, len);
|
||||
Int16Array ret = new Int16Array(len);
|
||||
ret.set(WASMGCBufferAllocator.getShortBufferView0(addr, len));
|
||||
WASMGCBufferAllocator.free(addr);
|
||||
MemoryStack.pop();
|
||||
return ret;
|
||||
}
|
||||
|
||||
public static Int16Array shortArrayToStackI16Array(short[] shortArray) {
|
||||
int len = shortArray.length;
|
||||
if(len == 0) {
|
||||
return INT16ZeroLength;
|
||||
}
|
||||
Address addr = MemoryStack.malloc(len << 1);
|
||||
WASMGCDirectArrayCopy.memcpy(addr, shortArray, 0, len);
|
||||
return WASMGCBufferAllocator.getShortBufferView0(addr, len);
|
||||
}
|
||||
|
||||
public static Int32Array byteArrayToExternI32Array(byte[] byteArray) {
|
||||
int len = byteArray.length & 0xFFFFFFFC;
|
||||
if(len == 0) {
|
||||
return INT32ZeroLength;
|
||||
}
|
||||
Address addr = WASMGCBufferAllocator.malloc(len);
|
||||
MemoryStack.push();
|
||||
Address addr = MemoryStack.malloc(len);
|
||||
WASMGCDirectArrayCopy.memcpy(addr, byteArray, 0, len);
|
||||
len >>= 2;
|
||||
Int32Array ret = new Int32Array(len);
|
||||
ret.set(WASMGCBufferAllocator.getIntBufferView0(addr, len));
|
||||
WASMGCBufferAllocator.free(addr);
|
||||
MemoryStack.pop();
|
||||
return ret;
|
||||
}
|
||||
|
||||
public static Int32Array byteArrayToStackI32Array(byte[] byteArray) {
|
||||
int len = byteArray.length & 0xFFFFFFFC;
|
||||
if(len == 0) {
|
||||
return INT32ZeroLength;
|
||||
}
|
||||
Address addr = MemoryStack.malloc(len);
|
||||
WASMGCDirectArrayCopy.memcpy(addr, byteArray, 0, len);
|
||||
return WASMGCBufferAllocator.getIntBufferView0(addr, len >> 2);
|
||||
}
|
||||
|
||||
public static Int32Array intArrayToExternI32Array(int[] intArray) {
|
||||
int len = intArray.length;
|
||||
if(len == 0) {
|
||||
return INT32ZeroLength;
|
||||
}
|
||||
Address addr = WASMGCBufferAllocator.malloc(len << 2);
|
||||
MemoryStack.push();
|
||||
Address addr = MemoryStack.malloc(len << 2);
|
||||
WASMGCDirectArrayCopy.memcpy(addr, intArray, 0, len);
|
||||
Int32Array ret = new Int32Array(len);
|
||||
ret.set(WASMGCBufferAllocator.getIntBufferView0(addr, len));
|
||||
WASMGCBufferAllocator.free(addr);
|
||||
MemoryStack.pop();
|
||||
return ret;
|
||||
}
|
||||
|
||||
public static Int32Array intArrayToStackI32Array(int[] intArray) {
|
||||
int len = intArray.length;
|
||||
if(len == 0) {
|
||||
return INT32ZeroLength;
|
||||
}
|
||||
Address addr = MemoryStack.malloc(len << 2);
|
||||
WASMGCDirectArrayCopy.memcpy(addr, intArray, 0, len);
|
||||
return WASMGCBufferAllocator.getIntBufferView0(addr, len);
|
||||
}
|
||||
|
||||
public static Float32Array byteArrayToExternF32Array(byte[] byteArray) {
|
||||
int len = byteArray.length & 0xFFFFFFFC;
|
||||
if(len == 0) {
|
||||
return FLOAT32ZeroLength;
|
||||
}
|
||||
Address addr = WASMGCBufferAllocator.malloc(len);
|
||||
MemoryStack.push();
|
||||
Address addr = MemoryStack.malloc(len);
|
||||
WASMGCDirectArrayCopy.memcpy(addr, byteArray, 0, len);
|
||||
len >>= 2;
|
||||
Float32Array ret = new Float32Array(len);
|
||||
ret.set(WASMGCBufferAllocator.getFloatBufferView0(addr, len));
|
||||
WASMGCBufferAllocator.free(addr);
|
||||
MemoryStack.pop();
|
||||
return ret;
|
||||
}
|
||||
|
||||
public static Float32Array byteArrayToStackF32Array(byte[] byteArray) {
|
||||
int len = byteArray.length & 0xFFFFFFFC;
|
||||
if(len == 0) {
|
||||
return FLOAT32ZeroLength;
|
||||
}
|
||||
Address addr = MemoryStack.malloc(len);
|
||||
WASMGCDirectArrayCopy.memcpy(addr, byteArray, 0, len);
|
||||
return WASMGCBufferAllocator.getFloatBufferView0(addr, len >> 2);
|
||||
}
|
||||
|
||||
public static Float32Array floatArrayToExternF32Array(float[] floatArray) {
|
||||
int len = floatArray.length;
|
||||
if(len == 0) {
|
||||
return FLOAT32ZeroLength;
|
||||
}
|
||||
Address addr = WASMGCBufferAllocator.malloc(len << 2);
|
||||
MemoryStack.push();
|
||||
Address addr = MemoryStack.malloc(len << 2);
|
||||
WASMGCDirectArrayCopy.memcpy(addr, floatArray, 0, len);
|
||||
Float32Array ret = new Float32Array(len);
|
||||
ret.set(WASMGCBufferAllocator.getFloatBufferView0(addr, len));
|
||||
WASMGCBufferAllocator.free(addr);
|
||||
MemoryStack.pop();
|
||||
return ret;
|
||||
}
|
||||
|
||||
public static Float32Array floatArrayToStackF32Array(float[] floatArray) {
|
||||
int len = floatArray.length;
|
||||
if(len == 0) {
|
||||
return FLOAT32ZeroLength;
|
||||
}
|
||||
Address addr = MemoryStack.malloc(len << 2);
|
||||
WASMGCDirectArrayCopy.memcpy(addr, floatArray, 0, len);
|
||||
return WASMGCBufferAllocator.getFloatBufferView0(addr, len);
|
||||
}
|
||||
|
||||
private static final byte[] byteZeroLength = new byte[0];
|
||||
private static final short[] shortZeroLength = new short[0];
|
||||
private static final int[] intZeroLength = new int[0];
|
||||
|
@ -251,11 +432,12 @@ public class WASMGCDirectArrayConverter {
|
|||
if(len == 0) {
|
||||
return byteZeroLength;
|
||||
}
|
||||
Address addr = WASMGCBufferAllocator.malloc(len);
|
||||
MemoryStack.push();
|
||||
Address addr = MemoryStack.malloc(len);
|
||||
WASMGCBufferAllocator.getUnsignedByteBufferView0(addr, len).set(U8Array);
|
||||
byte[] ret = new byte[len];
|
||||
WASMGCDirectArrayCopy.memcpy(ret, 0, addr, len);
|
||||
WASMGCBufferAllocator.free(addr);
|
||||
MemoryStack.pop();
|
||||
return ret;
|
||||
}
|
||||
|
||||
|
@ -264,11 +446,12 @@ public class WASMGCDirectArrayConverter {
|
|||
if(len == 0) {
|
||||
return byteZeroLength;
|
||||
}
|
||||
Address addr = WASMGCBufferAllocator.malloc(len);
|
||||
MemoryStack.push();
|
||||
Address addr = MemoryStack.malloc(len);
|
||||
WASMGCBufferAllocator.getUnsignedClampedByteBufferView0(addr, len).set(U8CArray);
|
||||
byte[] ret = new byte[len];
|
||||
WASMGCDirectArrayCopy.memcpy(ret, 0, addr, len);
|
||||
WASMGCBufferAllocator.free(addr);
|
||||
MemoryStack.pop();
|
||||
return ret;
|
||||
}
|
||||
|
||||
|
@ -277,11 +460,12 @@ public class WASMGCDirectArrayConverter {
|
|||
if(len == 0) {
|
||||
return byteZeroLength;
|
||||
}
|
||||
Address addr = WASMGCBufferAllocator.malloc(len);
|
||||
MemoryStack.push();
|
||||
Address addr = MemoryStack.malloc(len);
|
||||
WASMGCBufferAllocator.getByteBufferView0(addr, len).set(I8Array);
|
||||
byte[] ret = new byte[len];
|
||||
WASMGCDirectArrayCopy.memcpy(ret, 0, addr, len);
|
||||
WASMGCBufferAllocator.free(addr);
|
||||
MemoryStack.pop();
|
||||
return ret;
|
||||
}
|
||||
|
||||
|
@ -291,11 +475,12 @@ public class WASMGCDirectArrayConverter {
|
|||
return byteZeroLength;
|
||||
}
|
||||
int len2 = len << 1;
|
||||
Address addr = WASMGCBufferAllocator.malloc(len2);
|
||||
MemoryStack.push();
|
||||
Address addr = MemoryStack.malloc(len2);
|
||||
WASMGCBufferAllocator.getUnsignedShortBufferView0(addr, len).set(U16Array);
|
||||
byte[] ret = new byte[len2];
|
||||
WASMGCDirectArrayCopy.memcpy(ret, 0, addr, len2);
|
||||
WASMGCBufferAllocator.free(addr);
|
||||
MemoryStack.pop();
|
||||
return ret;
|
||||
}
|
||||
|
||||
|
@ -305,11 +490,12 @@ public class WASMGCDirectArrayConverter {
|
|||
return byteZeroLength;
|
||||
}
|
||||
int len2 = len << 1;
|
||||
Address addr = WASMGCBufferAllocator.malloc(len2);
|
||||
MemoryStack.push();
|
||||
Address addr = MemoryStack.malloc(len2);
|
||||
WASMGCBufferAllocator.getShortBufferView0(addr, len).set(I16Array);
|
||||
byte[] ret = new byte[len2];
|
||||
WASMGCDirectArrayCopy.memcpy(ret, 0, addr, len2);
|
||||
WASMGCBufferAllocator.free(addr);
|
||||
MemoryStack.pop();
|
||||
return ret;
|
||||
}
|
||||
|
||||
|
@ -318,11 +504,12 @@ public class WASMGCDirectArrayConverter {
|
|||
if(len == 0) {
|
||||
return shortZeroLength;
|
||||
}
|
||||
Address addr = WASMGCBufferAllocator.malloc(len << 1);
|
||||
MemoryStack.push();
|
||||
Address addr = MemoryStack.malloc(len << 1);
|
||||
WASMGCBufferAllocator.getUnsignedShortBufferView0(addr, len).set(U16Array);
|
||||
short[] ret = new short[len];
|
||||
WASMGCDirectArrayCopy.memcpy(ret, 0, addr, len);
|
||||
WASMGCBufferAllocator.free(addr);
|
||||
MemoryStack.pop();
|
||||
return ret;
|
||||
}
|
||||
|
||||
|
@ -331,11 +518,12 @@ public class WASMGCDirectArrayConverter {
|
|||
if(len == 0) {
|
||||
return shortZeroLength;
|
||||
}
|
||||
Address addr = WASMGCBufferAllocator.malloc(len << 1);
|
||||
MemoryStack.push();
|
||||
Address addr = MemoryStack.malloc(len << 1);
|
||||
WASMGCBufferAllocator.getShortBufferView0(addr, len).set(I16Array);
|
||||
short[] ret = new short[len];
|
||||
WASMGCDirectArrayCopy.memcpy(ret, 0, addr, len);
|
||||
WASMGCBufferAllocator.free(addr);
|
||||
MemoryStack.pop();
|
||||
return ret;
|
||||
}
|
||||
|
||||
|
@ -345,11 +533,12 @@ public class WASMGCDirectArrayConverter {
|
|||
return byteZeroLength;
|
||||
}
|
||||
int len2 = len << 2;
|
||||
Address addr = WASMGCBufferAllocator.malloc(len2);
|
||||
MemoryStack.push();
|
||||
Address addr = MemoryStack.malloc(len2);
|
||||
WASMGCBufferAllocator.getIntBufferView0(addr, len).set(I32Array);
|
||||
byte[] ret = new byte[len2];
|
||||
WASMGCDirectArrayCopy.memcpy(ret, 0, addr, len2);
|
||||
WASMGCBufferAllocator.free(addr);
|
||||
MemoryStack.pop();
|
||||
return ret;
|
||||
}
|
||||
|
||||
|
@ -358,11 +547,12 @@ public class WASMGCDirectArrayConverter {
|
|||
if(len == 0) {
|
||||
return intZeroLength;
|
||||
}
|
||||
Address addr = WASMGCBufferAllocator.malloc(len << 2);
|
||||
MemoryStack.push();
|
||||
Address addr = MemoryStack.malloc(len << 2);
|
||||
WASMGCBufferAllocator.getIntBufferView0(addr, len).set(I32Array);
|
||||
int[] ret = new int[len];
|
||||
WASMGCDirectArrayCopy.memcpy(ret, 0, addr, len);
|
||||
WASMGCBufferAllocator.free(addr);
|
||||
MemoryStack.pop();
|
||||
return ret;
|
||||
}
|
||||
|
||||
|
@ -372,11 +562,12 @@ public class WASMGCDirectArrayConverter {
|
|||
return byteZeroLength;
|
||||
}
|
||||
int len2 = len << 2;
|
||||
Address addr = WASMGCBufferAllocator.malloc(len2);
|
||||
MemoryStack.push();
|
||||
Address addr = MemoryStack.malloc(len2);
|
||||
WASMGCBufferAllocator.getFloatBufferView0(addr, len).set(F32Array);
|
||||
byte[] ret = new byte[len2];
|
||||
WASMGCDirectArrayCopy.memcpy(ret, 0, addr, len2);
|
||||
WASMGCBufferAllocator.free(addr);
|
||||
MemoryStack.pop();
|
||||
return ret;
|
||||
}
|
||||
|
||||
|
@ -385,11 +576,12 @@ public class WASMGCDirectArrayConverter {
|
|||
if(len == 0) {
|
||||
return floatZeroLength;
|
||||
}
|
||||
Address addr = WASMGCBufferAllocator.malloc(len << 2);
|
||||
MemoryStack.push();
|
||||
Address addr = MemoryStack.malloc(len << 2);
|
||||
WASMGCBufferAllocator.getFloatBufferView0(addr, len).set(F32Array);
|
||||
float[] ret = new float[len];
|
||||
WASMGCDirectArrayCopy.memcpy(ret, 0, addr, len);
|
||||
WASMGCBufferAllocator.free(addr);
|
||||
MemoryStack.pop();
|
||||
return ret;
|
||||
}
|
||||
|
||||
|
|
|
@ -6,6 +6,7 @@ import org.teavm.interop.Unmanaged;
|
|||
import org.teavm.jso.core.JSArray;
|
||||
import org.teavm.jso.core.JSString;
|
||||
|
||||
import net.lax1dude.eaglercraft.v1_8.internal.buffer.MemoryStack;
|
||||
import net.lax1dude.eaglercraft.v1_8.internal.buffer.WASMGCBufferAllocator;
|
||||
|
||||
/**
|
||||
|
@ -31,12 +32,13 @@ public class BetterJSStringConverter {
|
|||
public static JSString stringToJS(String input) {
|
||||
if(input == null) return null;
|
||||
int len = input.length();
|
||||
Address tmpAddr = WASMGCBufferAllocator.malloc(len << 1);
|
||||
MemoryStack.push();
|
||||
Address tmpAddr = MemoryStack.malloc(len << 1);
|
||||
for(int i = 0; i < len; ++i) {
|
||||
tmpAddr.add(i << 1).putChar(input.charAt(i));
|
||||
}
|
||||
JSString ret = textDecoder.decode(WASMGCBufferAllocator.getUnsignedByteBufferView0(tmpAddr, len << 1));
|
||||
WASMGCBufferAllocator.free(tmpAddr);
|
||||
MemoryStack.pop();
|
||||
return ret;
|
||||
}
|
||||
|
||||
|
|
|
@ -11,10 +11,10 @@ import net.lax1dude.eaglercraft.v1_8.internal.IShaderGL;
|
|||
import net.lax1dude.eaglercraft.v1_8.internal.ITextureGL;
|
||||
import net.lax1dude.eaglercraft.v1_8.internal.PlatformAssets;
|
||||
import net.lax1dude.eaglercraft.v1_8.internal.PlatformInput;
|
||||
import net.lax1dude.eaglercraft.v1_8.internal.PlatformRuntime;
|
||||
import net.lax1dude.eaglercraft.v1_8.internal.buffer.ByteBuffer;
|
||||
import net.lax1dude.eaglercraft.v1_8.internal.buffer.FloatBuffer;
|
||||
import net.lax1dude.eaglercraft.v1_8.internal.buffer.IntBuffer;
|
||||
import net.lax1dude.eaglercraft.v1_8.internal.buffer.MemoryStack;
|
||||
import net.lax1dude.eaglercraft.v1_8.opengl.EaglercraftGPU;
|
||||
import net.lax1dude.eaglercraft.v1_8.opengl.ImageData;
|
||||
|
||||
|
@ -56,29 +56,32 @@ public class EarlyLoadScreen {
|
|||
_wglTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE);
|
||||
|
||||
ImageData img = PlatformAssets.loadImageFile(Base64.decodeBase64(loadScreen));
|
||||
ByteBuffer upload = PlatformRuntime.allocateByteBuffer(192*192*4);
|
||||
IntBuffer pixelUpload = upload.asIntBuffer();
|
||||
pixelUpload.put(img.pixels);
|
||||
pixelUpload.flip();
|
||||
_wglTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, 192, 192, 0, GL_RGBA, GL_UNSIGNED_BYTE, pixelUpload);
|
||||
|
||||
// create vertex buffer:
|
||||
|
||||
FloatBuffer vertexUpload = upload.asFloatBuffer();
|
||||
vertexUpload.clear();
|
||||
vertexUpload.put(0.0f); vertexUpload.put(0.0f);
|
||||
vertexUpload.put(0.0f); vertexUpload.put(1.0f);
|
||||
vertexUpload.put(1.0f); vertexUpload.put(0.0f);
|
||||
vertexUpload.put(1.0f); vertexUpload.put(0.0f);
|
||||
vertexUpload.put(0.0f); vertexUpload.put(1.0f);
|
||||
vertexUpload.put(1.0f); vertexUpload.put(1.0f);
|
||||
vertexUpload.flip();
|
||||
|
||||
vbo = _wglGenBuffers();
|
||||
_wglBindBuffer(GL_ARRAY_BUFFER, vbo);
|
||||
_wglBufferData(GL_ARRAY_BUFFER, vertexUpload, GL_STATIC_DRAW);
|
||||
|
||||
PlatformRuntime.freeByteBuffer(upload);
|
||||
MemoryStack.push();
|
||||
try {
|
||||
ByteBuffer upload = MemoryStack.mallocByteBuffer(192*192*4);
|
||||
IntBuffer pixelUpload = upload.asIntBuffer();
|
||||
pixelUpload.put(img.pixels);
|
||||
pixelUpload.flip();
|
||||
_wglTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, 192, 192, 0, GL_RGBA, GL_UNSIGNED_BYTE, pixelUpload);
|
||||
|
||||
// create vertex buffer:
|
||||
|
||||
FloatBuffer vertexUpload = upload.asFloatBuffer();
|
||||
vertexUpload.clear();
|
||||
vertexUpload.put(0.0f); vertexUpload.put(0.0f);
|
||||
vertexUpload.put(0.0f); vertexUpload.put(1.0f);
|
||||
vertexUpload.put(1.0f); vertexUpload.put(0.0f);
|
||||
vertexUpload.put(1.0f); vertexUpload.put(0.0f);
|
||||
vertexUpload.put(0.0f); vertexUpload.put(1.0f);
|
||||
vertexUpload.put(1.0f); vertexUpload.put(1.0f);
|
||||
vertexUpload.flip();
|
||||
|
||||
vbo = _wglGenBuffers();
|
||||
_wglBindBuffer(GL_ARRAY_BUFFER, vbo);
|
||||
_wglBufferData(GL_ARRAY_BUFFER, vertexUpload, GL_STATIC_DRAW);
|
||||
}finally {
|
||||
MemoryStack.pop();
|
||||
}
|
||||
|
||||
// compile the splash shader:
|
||||
|
||||
|
@ -165,11 +168,15 @@ public class EarlyLoadScreen {
|
|||
_wglTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST);
|
||||
_wglTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE);
|
||||
_wglTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE);
|
||||
IntBuffer upload = PlatformRuntime.allocateIntBuffer(img.width * img.height);
|
||||
upload.put(img.pixels);
|
||||
upload.flip();
|
||||
_wglTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, img.width, img.height, 0, GL_RGBA, GL_UNSIGNED_BYTE, upload);
|
||||
PlatformRuntime.freeIntBuffer(upload);
|
||||
MemoryStack.push();
|
||||
try {
|
||||
IntBuffer upload = MemoryStack.mallocIntBuffer(img.width * img.height);
|
||||
upload.put(img.pixels);
|
||||
upload.flip();
|
||||
_wglTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, img.width, img.height, 0, GL_RGBA, GL_UNSIGNED_BYTE, upload);
|
||||
}finally {
|
||||
MemoryStack.pop();
|
||||
}
|
||||
}
|
||||
|
||||
public static void paintFinal(boolean softVAOs) {
|
||||
|
|
|
@ -17,8 +17,8 @@ import com.jcraft.jorbis.Info;
|
|||
|
||||
import net.lax1dude.eaglercraft.v1_8.EaglerInputStream;
|
||||
import net.lax1dude.eaglercraft.v1_8.internal.PlatformAudio;
|
||||
import net.lax1dude.eaglercraft.v1_8.internal.PlatformRuntime;
|
||||
import net.lax1dude.eaglercraft.v1_8.internal.buffer.FloatBuffer;
|
||||
import net.lax1dude.eaglercraft.v1_8.internal.buffer.MemoryStack;
|
||||
import net.lax1dude.eaglercraft.v1_8.internal.buffer.WASMGCBufferAllocator;
|
||||
import net.lax1dude.eaglercraft.v1_8.log4j.LogManager;
|
||||
import net.lax1dude.eaglercraft.v1_8.log4j.Logger;
|
||||
|
@ -88,8 +88,9 @@ public class JOrbisAudioBufferDecoder {
|
|||
logger.error("[{}]: Empty file", errorString);
|
||||
return null;
|
||||
}
|
||||
FloatBuffer buf = PlatformRuntime.allocateFloatBuffer(ch * len);
|
||||
MemoryStack.push();
|
||||
try {
|
||||
FloatBuffer buf = MemoryStack.mallocFloatBuffer(ch * len);
|
||||
int len2 = 0;
|
||||
for(float[][] fl : lst) {
|
||||
for(int i = 0; i < ch; ++i) {
|
||||
|
@ -102,7 +103,7 @@ public class JOrbisAudioBufferDecoder {
|
|||
return PlatformAudio.decodeAudioBufferPCMBrowser(WASMGCBufferAllocator.getFloatBufferView(buf), ch,
|
||||
len, dec.jorbisInfo.rate);
|
||||
}finally {
|
||||
PlatformRuntime.freeFloatBuffer(buf);
|
||||
MemoryStack.pop();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -5,6 +5,7 @@ import java.util.List;
|
|||
|
||||
import org.teavm.jso.JSObject;
|
||||
import org.teavm.jso.JSProperty;
|
||||
import org.teavm.jso.core.JSString;
|
||||
import org.teavm.jso.typedarrays.Uint8Array;
|
||||
|
||||
import net.lax1dude.eaglercraft.v1_8.EagUtils;
|
||||
|
@ -12,8 +13,7 @@ import net.lax1dude.eaglercraft.v1_8.internal.EnumEaglerConnectionState;
|
|||
import net.lax1dude.eaglercraft.v1_8.internal.IWebSocketClient;
|
||||
import net.lax1dude.eaglercraft.v1_8.internal.IWebSocketFrame;
|
||||
import net.lax1dude.eaglercraft.v1_8.internal.PlatformRuntime;
|
||||
import net.lax1dude.eaglercraft.v1_8.internal.buffer.ByteBuffer;
|
||||
import net.lax1dude.eaglercraft.v1_8.internal.buffer.WASMGCBufferAllocator;
|
||||
import net.lax1dude.eaglercraft.v1_8.internal.buffer.MemoryStack;
|
||||
import net.lax1dude.eaglercraft.v1_8.internal.buffer.WASMGCDirectArrayConverter;
|
||||
|
||||
/**
|
||||
|
@ -40,7 +40,7 @@ public class WASMGCWebSocketClient implements IWebSocketClient {
|
|||
|
||||
void closeSocket();
|
||||
|
||||
void sendStringFrame(String str);
|
||||
void sendStringFrame(JSString str);
|
||||
|
||||
void sendBinaryFrame(Uint8Array arr);
|
||||
|
||||
|
@ -220,16 +220,16 @@ public class WASMGCWebSocketClient implements IWebSocketClient {
|
|||
|
||||
@Override
|
||||
public void send(String str) {
|
||||
handle.sendStringFrame(str);
|
||||
handle.sendStringFrame(BetterJSStringConverter.stringToJS(str));
|
||||
}
|
||||
|
||||
@Override
|
||||
public void send(byte[] bytes) {
|
||||
ByteBuffer buf = WASMGCDirectArrayConverter.byteArrayToBuffer(bytes);
|
||||
MemoryStack.push();
|
||||
try {
|
||||
handle.sendBinaryFrame(WASMGCBufferAllocator.getUnsignedByteBufferView(buf));
|
||||
handle.sendBinaryFrame(WASMGCDirectArrayConverter.byteArrayToStackU8Array(bytes));
|
||||
}finally {
|
||||
PlatformRuntime.freeByteBuffer(buf);
|
||||
MemoryStack.pop();
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -10,8 +10,8 @@ import net.lax1dude.eaglercraft.v1_8.internal.IProgramGL;
|
|||
import net.lax1dude.eaglercraft.v1_8.internal.IRenderbufferGL;
|
||||
import net.lax1dude.eaglercraft.v1_8.internal.IShaderGL;
|
||||
import net.lax1dude.eaglercraft.v1_8.internal.ITextureGL;
|
||||
import net.lax1dude.eaglercraft.v1_8.internal.PlatformRuntime;
|
||||
import net.lax1dude.eaglercraft.v1_8.internal.buffer.ByteBuffer;
|
||||
import net.lax1dude.eaglercraft.v1_8.internal.buffer.MemoryStack;
|
||||
import net.lax1dude.eaglercraft.v1_8.opengl.EaglercraftGPU;
|
||||
import net.lax1dude.eaglercraft.v1_8.opengl.GlStateManager;
|
||||
|
||||
|
@ -93,21 +93,24 @@ public class WebGLBackBuffer {
|
|||
_wglBindRenderbuffer(_GL_RENDERBUFFER, gles2DepthRenderbuffer);
|
||||
_wglRenderbufferStorage(_GL_RENDERBUFFER, _GL_DEPTH_COMPONENT16, sw, sh);
|
||||
_wglFramebufferRenderbuffer(_GL_FRAMEBUFFER, _GL_DEPTH_ATTACHMENT, _GL_RENDERBUFFER, gles2DepthRenderbuffer);
|
||||
|
||||
ByteBuffer upload = PlatformRuntime.allocateByteBuffer(48);
|
||||
upload.putFloat(0.0f); upload.putFloat(0.0f);
|
||||
upload.putFloat(1.0f); upload.putFloat(0.0f);
|
||||
upload.putFloat(0.0f); upload.putFloat(1.0f);
|
||||
upload.putFloat(1.0f); upload.putFloat(0.0f);
|
||||
upload.putFloat(1.0f); upload.putFloat(1.0f);
|
||||
upload.putFloat(0.0f); upload.putFloat(1.0f);
|
||||
upload.flip();
|
||||
|
||||
gles2BlitVBO = _wglGenBuffers();
|
||||
EaglercraftGPU.bindVAOGLArrayBufferNow(gles2BlitVBO);
|
||||
_wglBufferData(GL_ARRAY_BUFFER, upload, GL_STATIC_DRAW);
|
||||
|
||||
PlatformRuntime.freeByteBuffer(upload);
|
||||
|
||||
MemoryStack.push();
|
||||
try {
|
||||
ByteBuffer upload = MemoryStack.mallocByteBuffer(48);
|
||||
upload.putFloat(0.0f); upload.putFloat(0.0f);
|
||||
upload.putFloat(1.0f); upload.putFloat(0.0f);
|
||||
upload.putFloat(0.0f); upload.putFloat(1.0f);
|
||||
upload.putFloat(1.0f); upload.putFloat(0.0f);
|
||||
upload.putFloat(1.0f); upload.putFloat(1.0f);
|
||||
upload.putFloat(0.0f); upload.putFloat(1.0f);
|
||||
upload.flip();
|
||||
|
||||
gles2BlitVBO = _wglGenBuffers();
|
||||
EaglercraftGPU.bindVAOGLArrayBufferNow(gles2BlitVBO);
|
||||
_wglBufferData(GL_ARRAY_BUFFER, upload, GL_STATIC_DRAW);
|
||||
}finally {
|
||||
MemoryStack.pop();
|
||||
}
|
||||
|
||||
if(isVAOCapable) {
|
||||
gles2BlitVAO = _wglGenVertexArrays();
|
||||
|
|
|
@ -11,8 +11,7 @@ import org.teavm.jso.typedarrays.Uint8Array;
|
|||
|
||||
import net.lax1dude.eaglercraft.v1_8.internal.IPCPacketData;
|
||||
import net.lax1dude.eaglercraft.v1_8.internal.PlatformRuntime;
|
||||
import net.lax1dude.eaglercraft.v1_8.internal.buffer.ByteBuffer;
|
||||
import net.lax1dude.eaglercraft.v1_8.internal.buffer.WASMGCBufferAllocator;
|
||||
import net.lax1dude.eaglercraft.v1_8.internal.buffer.MemoryStack;
|
||||
import net.lax1dude.eaglercraft.v1_8.internal.buffer.WASMGCDirectArrayConverter;
|
||||
import net.lax1dude.eaglercraft.v1_8.internal.wasm_gc_teavm.BetterJSStringConverter;
|
||||
import net.lax1dude.eaglercraft.v1_8.internal.wasm_gc_teavm.WASMGCClientConfigAdapter;
|
||||
|
@ -69,11 +68,12 @@ public class ClientPlatformSingleplayer {
|
|||
if(isSingleThreadMode) {
|
||||
SingleThreadWorker.sendPacketToWorker(packet);
|
||||
}else {
|
||||
ByteBuffer buf = WASMGCDirectArrayConverter.byteArrayToBuffer(packet.contents);
|
||||
MemoryStack.push();
|
||||
try {
|
||||
sendPacket0(BetterJSStringConverter.stringToJS(packet.channel), WASMGCBufferAllocator.getUnsignedByteBufferView(buf));
|
||||
}finally {
|
||||
PlatformRuntime.freeByteBuffer(buf);
|
||||
sendPacket0(BetterJSStringConverter.stringToJS(packet.channel),
|
||||
WASMGCDirectArrayConverter.byteArrayToStackU8Array(packet.contents));
|
||||
} finally {
|
||||
MemoryStack.pop();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -16,9 +16,7 @@ import net.lax1dude.eaglercraft.v1_8.Filesystem;
|
|||
import net.lax1dude.eaglercraft.v1_8.internal.IClientConfigAdapter;
|
||||
import net.lax1dude.eaglercraft.v1_8.internal.IEaglerFilesystem;
|
||||
import net.lax1dude.eaglercraft.v1_8.internal.IPCPacketData;
|
||||
import net.lax1dude.eaglercraft.v1_8.internal.PlatformRuntime;
|
||||
import net.lax1dude.eaglercraft.v1_8.internal.buffer.ByteBuffer;
|
||||
import net.lax1dude.eaglercraft.v1_8.internal.buffer.WASMGCBufferAllocator;
|
||||
import net.lax1dude.eaglercraft.v1_8.internal.buffer.MemoryStack;
|
||||
import net.lax1dude.eaglercraft.v1_8.internal.buffer.WASMGCDirectArrayConverter;
|
||||
import net.lax1dude.eaglercraft.v1_8.internal.vfs2.VFile2;
|
||||
import net.lax1dude.eaglercraft.v1_8.internal.wasm_gc_teavm.BetterJSStringConverter;
|
||||
|
@ -71,11 +69,12 @@ public class ServerPlatformSingleplayer {
|
|||
if(singleThreadMode) {
|
||||
singleThreadCB.accept(packet);
|
||||
}else {
|
||||
ByteBuffer buf = WASMGCDirectArrayConverter.byteArrayToBuffer(packet.contents);
|
||||
MemoryStack.push();
|
||||
try {
|
||||
sendPacket0(BetterJSStringConverter.stringToJS(packet.channel), WASMGCBufferAllocator.getUnsignedByteBufferView(buf));
|
||||
}finally {
|
||||
PlatformRuntime.freeByteBuffer(buf);
|
||||
sendPacket0(BetterJSStringConverter.stringToJS(packet.channel),
|
||||
WASMGCDirectArrayConverter.byteArrayToStackU8Array(packet.contents));
|
||||
} finally {
|
||||
MemoryStack.pop();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -16,6 +16,7 @@
|
|||
|
||||
async function entryPoint() {
|
||||
try {
|
||||
Error["stackTraceLimit"] = 1024;
|
||||
eaglercraftXOpts = self.__eaglercraftXLoaderContext.getEaglercraftXOpts();
|
||||
eagRuntimeJSURL = self.__eaglercraftXLoaderContext.getEagRuntimeJSURL();
|
||||
const classesWASM = self.__eaglercraftXLoaderContext.getClassesWASMURL();
|
||||
|
|
|
@ -370,7 +370,7 @@ async function initPlatformInput(inputImports) {
|
|||
}
|
||||
|
||||
window.addEventListener("keydown", /** @type {function(Event)} */ (currentEventListeners.keydown = function(/** KeyboardEvent */ evt) {
|
||||
if(integratedServerCrashPanelShowing) {
|
||||
if(!integratedServerCrashPanelShowing) {
|
||||
evt.preventDefault();
|
||||
evt.stopPropagation();
|
||||
}
|
||||
|
@ -383,7 +383,7 @@ async function initPlatformInput(inputImports) {
|
|||
}));
|
||||
|
||||
window.addEventListener("keyup", /** @type {function(Event)} */ (currentEventListeners.keyup = function(/** KeyboardEvent */ evt) {
|
||||
if(integratedServerCrashPanelShowing) {
|
||||
if(!integratedServerCrashPanelShowing) {
|
||||
evt.preventDefault();
|
||||
evt.stopPropagation();
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue
Block a user