mirror of
https://github.com/Eaglercraft-Archive/Eaglercraftx-1.8.8-src.git
synced 2025-06-28 02:48:14 -05:00
Update #40 - FPS boost and fixed IndexOutOfBoundsException
This commit is contained in:
@ -43,6 +43,7 @@ public class PlatformAudio {
|
||||
|
||||
protected final String sourceName;
|
||||
protected long stall;
|
||||
protected boolean paused = false;
|
||||
|
||||
protected PaulscodeAudioHandle(String sourceName) {
|
||||
this.sourceName = sourceName;
|
||||
@ -55,10 +56,12 @@ public class PlatformAudio {
|
||||
if(sndSystem.playing(sourceName)) {
|
||||
sndSystem.pause(sourceName);
|
||||
}
|
||||
paused = true;
|
||||
}else {
|
||||
if(!sndSystem.playing(sourceName)) {
|
||||
sndSystem.play(sourceName);
|
||||
}
|
||||
paused = false;
|
||||
}
|
||||
}
|
||||
|
||||
@ -67,6 +70,7 @@ public class PlatformAudio {
|
||||
this.stall = PlatformRuntime.steadyTimeMillis();
|
||||
sndSystem.rewind(sourceName);
|
||||
sndSystem.play(sourceName);
|
||||
paused = false;
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -87,13 +91,14 @@ public class PlatformAudio {
|
||||
@Override
|
||||
public void end() {
|
||||
sndSystem.stop(sourceName);
|
||||
paused = false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean shouldFree() {
|
||||
return !sndSystem.playing(sourceName) && PlatformRuntime.steadyTimeMillis() - this.stall > 250l; //TODO: I hate this hack
|
||||
return !paused && !sndSystem.playing(sourceName) && PlatformRuntime.steadyTimeMillis() - this.stall > 250l; //TODO: I hate this hack
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
public static IAudioResource loadAudioData(String filename, boolean holdInCache) {
|
||||
@ -113,10 +118,6 @@ public class PlatformAudio {
|
||||
|
||||
}
|
||||
|
||||
public static interface IAudioCacheLoader {
|
||||
byte[] loadFile(String filename);
|
||||
}
|
||||
|
||||
public static IAudioResource loadAudioDataNew(String filename, boolean holdInCache, IAudioCacheLoader loader) {
|
||||
throw new UnsupportedOperationException("Browser only!");
|
||||
}
|
||||
|
@ -14,6 +14,8 @@ import org.lwjgl.glfw.GLFWGamepadState;
|
||||
import org.lwjgl.glfw.GLFWVidMode;
|
||||
import org.lwjgl.system.MemoryStack;
|
||||
|
||||
import net.lax1dude.eaglercraft.v1_8.Display;
|
||||
|
||||
/**
|
||||
* Copyright (c) 2022-2024 lax1dude, ayunami2000. All Rights Reserved.
|
||||
*
|
||||
@ -60,7 +62,6 @@ public class PlatformInput {
|
||||
private static boolean enableRepeatEvents = false;
|
||||
private static int functionKeyModifier = GLFW_KEY_F;
|
||||
|
||||
public static boolean lockKeys = false;
|
||||
|
||||
private static final List<Character> keyboardCharList = new LinkedList<>();
|
||||
|
||||
@ -298,12 +299,23 @@ public class PlatformInput {
|
||||
}
|
||||
|
||||
public static void update() {
|
||||
update(0);
|
||||
}
|
||||
|
||||
private static final long[] syncTimer = new long[1];
|
||||
|
||||
public static void update(int limitFps) {
|
||||
glfwPollEvents();
|
||||
if(vsync != glfwVSyncState) {
|
||||
glfwSwapInterval(vsync ? 1 : 0);
|
||||
glfwVSyncState = vsync;
|
||||
}
|
||||
glfwSwapBuffers(win);
|
||||
if(limitFps > 0 && !vsync) {
|
||||
Display.sync(limitFps, syncTimer);
|
||||
}else {
|
||||
syncTimer[0] = 0l;
|
||||
}
|
||||
}
|
||||
|
||||
public static boolean isVSyncSupported() {
|
||||
@ -415,6 +427,10 @@ public class PlatformInput {
|
||||
enableRepeatEvents = b;
|
||||
}
|
||||
|
||||
public static boolean keyboardAreKeysLocked() {
|
||||
return false;
|
||||
}
|
||||
|
||||
public static boolean mouseNext() {
|
||||
if(mouseEventList.size() > 0) {
|
||||
currentMouseEvent = mouseEventList.remove(0);
|
||||
|
@ -432,7 +432,7 @@ public class PlatformOpenGL {
|
||||
data == null ? 0l : EaglerLWJGLAllocator.getAddress(data));
|
||||
}
|
||||
|
||||
public static final void _wglTexImage2D(int target, int level, int internalFormat, int width, int height,
|
||||
public static final void _wglTexImage2Df32(int target, int level, int internalFormat, int width, int height,
|
||||
int border, int format, int type, FloatBuffer data) {
|
||||
nglTexImage2D(target, level, internalFormat, width, height, border, format, type,
|
||||
data == null ? 0l : EaglerLWJGLAllocator.getAddress(data));
|
||||
@ -462,7 +462,7 @@ public class PlatformOpenGL {
|
||||
data == null ? 0l : EaglerLWJGLAllocator.getAddress(data));
|
||||
}
|
||||
|
||||
public static final void _wglTexSubImage2D(int target, int level, int xoffset, int yoffset, int width, int height,
|
||||
public static final void _wglTexSubImage2Df32(int target, int level, int xoffset, int yoffset, int width, int height,
|
||||
int format, int type, FloatBuffer data) {
|
||||
nglTexSubImage2D(target, level, xoffset, yoffset, width, height, format, type,
|
||||
data == null ? 0l : EaglerLWJGLAllocator.getAddress(data));
|
||||
|
@ -618,6 +618,13 @@ public class PlatformRuntime {
|
||||
return System.nanoTime();
|
||||
}
|
||||
|
||||
public static void sleep(int millis) {
|
||||
try {
|
||||
Thread.sleep(millis);
|
||||
} catch (InterruptedException e) {
|
||||
}
|
||||
}
|
||||
|
||||
public static void postCreate() {
|
||||
|
||||
}
|
||||
|
@ -78,9 +78,14 @@ public class DesktopClientConfigAdapter implements IClientConfigAdapter {
|
||||
return relays;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isCheckGLErrors() {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isCheckShaderGLErrors() {
|
||||
return true;
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -54,7 +54,7 @@ public class LWJGLEntryPoint {
|
||||
lr.setVisible(true);
|
||||
|
||||
while(lr.isVisible()) {
|
||||
EagUtils.sleep(100l);
|
||||
EagUtils.sleep(100);
|
||||
}
|
||||
|
||||
lr.dispose();
|
||||
@ -71,7 +71,7 @@ public class LWJGLEntryPoint {
|
||||
|
||||
EagRuntime.create();
|
||||
|
||||
Main.appMain(new String[0]);
|
||||
Main.appMain();
|
||||
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user