Update #18 - Final release, added PBR shaders

This commit is contained in:
LAX1DUDE
2023-04-07 16:48:33 -07:00
parent af6d2ffc18
commit b2274a25b0
497 changed files with 28342 additions and 1014 deletions

View File

@ -54,7 +54,8 @@ public class PlatformApplication {
}
public static String getClipboard() {
return glfwGetClipboardString(win);
String str = glfwGetClipboardString(win);
return str == null ? "" : str;
}
public static void setLocalStorage(String name, byte[] data) {

View File

@ -2,6 +2,7 @@ package net.lax1dude.eaglercraft.v1_8.internal;
import java.net.URL;
import net.lax1dude.eaglercraft.v1_8.internal.PlatformAudio.IAudioCacheLoader;
import net.lax1dude.eaglercraft.v1_8.internal.paulscode.lwjgl3.LibraryLWJGLOpenAL;
import net.lax1dude.eaglercraft.v1_8.log4j.LogManager;
import net.lax1dude.eaglercraft.v1_8.log4j.Logger;
@ -106,6 +107,18 @@ public class PlatformAudio {
public static void clearAudioCache() {
// browser only
}
public static void flushAudioCache() {
}
public static interface IAudioCacheLoader {
byte[] loadFile(String filename);
}
public static IAudioResource loadAudioDataNew(String filename, boolean holdInCache, IAudioCacheLoader loader) {
throw new UnsupportedOperationException("Browser only!");
}
private static final Logger logger = LogManager.getLogger("EaglercraftPlatformAudio");
private static SoundSystem sndSystem = null;

View File

@ -3,6 +3,19 @@ package net.lax1dude.eaglercraft.v1_8.internal;
import net.lax1dude.eaglercraft.v1_8.internal.buffer.ByteBuffer;
import net.lax1dude.eaglercraft.v1_8.internal.buffer.IntBuffer;
/**
* Copyright (c) 2022-2023 LAX1DUDE. All Rights Reserved.
*
* WITH THE EXCEPTION OF PATCH FILES, MINIFIED JAVASCRIPT, AND ALL FILES
* NORMALLY FOUND IN AN UNMODIFIED MINECRAFT RESOURCE PACK, YOU ARE NOT ALLOWED
* TO SHARE, DISTRIBUTE, OR REPURPOSE ANY FILE USED BY OR PRODUCED BY THE
* SOFTWARE IN THIS REPOSITORY WITHOUT PRIOR PERMISSION FROM THE PROJECT AUTHOR.
*
* NOT FOR COMMERCIAL OR MALICIOUS USE
*
* (please read the 'LICENSE' file this repo's root directory for more info)
*
*/
public class PlatformBufferFunctions {
public static void put(ByteBuffer newBuffer, ByteBuffer flip) {

View File

@ -70,6 +70,10 @@ public class PlatformOpenGL {
glBlendEquation(glEnum);
}
public static final void _wglBlendColor(float r, float g, float b, float a) {
glBlendColor(r, g, b, a);
}
public static final void _wglColorMask(boolean r, boolean g, boolean b, boolean a) {
glColorMask(r, g, b, a);
}
@ -233,6 +237,12 @@ public class PlatformOpenGL {
glTexParameteri(target, param, value);
}
public static final void _wglTexImage3D(int target, int level, int internalFormat, int width, int height, int depth,
int border, int format, int type, ByteBuffer data) {
nglTexImage3D(target, level, internalFormat, width, height, depth, border, format, type,
data == null ? 0l : EaglerLWJGLAllocator.getAddress(data));
}
public static final void _wglTexImage2D(int target, int level, int internalFormat, int width, int height,
int border, int format, int type, ByteBuffer data) {
nglTexImage2D(target, level, internalFormat, width, height, border, format, type,
@ -251,15 +261,21 @@ public class PlatformOpenGL {
data == null ? 0l : EaglerLWJGLAllocator.getAddress(data));
}
public static final void _wglTexImage2Du16(int target, int level, int internalFormat, int width, int height,
int border, int format, int type, ByteBuffer data) {
nglTexImage2D(target, level, internalFormat, width, height, border, format, type,
data == null ? 0l : EaglerLWJGLAllocator.getAddress(data));
}
public static final void _wglTexSubImage2D(int target, int level, int xoffset, int yoffset, int width, int height,
int format, int type, ByteBuffer data) {
glTexSubImage2D(target, level, xoffset, yoffset, width, height, format, type,
nglTexSubImage2D(target, level, xoffset, yoffset, width, height, format, type,
data == null ? 0l : EaglerLWJGLAllocator.getAddress(data));
}
public static final void _wglTexSubImage2D(int target, int level, int xoffset, int yoffset, int width, int height,
int format, int type, IntBuffer data) {
glTexSubImage2D(target, level, xoffset, yoffset, width, height, format, type,
nglTexSubImage2D(target, level, xoffset, yoffset, width, height, format, type,
data == null ? 0l : EaglerLWJGLAllocator.getAddress(data));
}
@ -269,11 +285,21 @@ public class PlatformOpenGL {
data == null ? 0l : EaglerLWJGLAllocator.getAddress(data));
}
public static final void _wglTexSubImage2Du16(int target, int level, int xoffset, int yoffset, int width, int height,
int format, int type, ByteBuffer data) {
nglTexSubImage2D(target, level, xoffset, yoffset, width, height, format, type,
data == null ? 0l : EaglerLWJGLAllocator.getAddress(data));
}
public static final void _wglCopyTexSubImage2D(int target, int level, int xoffset, int yoffset, int x, int y,
int width, int height) {
glCopyTexSubImage2D(target, level, xoffset, yoffset, x, y, width, height);
}
public static final void _wglTexStorage2D(int target, int levels, int internalFormat, int w, int h) {
glTexStorage2D(target, levels, internalFormat, w, h);
}
public static final void _wglPixelStorei(int pname, int value) {
glPixelStorei(pname, value);
}
@ -351,6 +377,18 @@ public class PlatformOpenGL {
return loc < 0 ? null : new OpenGLObjects.UniformGL(loc);
}
public static final int _wglGetUniformBlockIndex(IProgramGL obj, String name) {
return glGetUniformBlockIndex(((OpenGLObjects.ProgramGL) obj).ptr, name);
}
public static final void _wglBindBufferRange(int target, int index, IBufferGL buffer, int offset, int size) {
glBindBufferRange(target, index, ((OpenGLObjects.BufferGL) buffer).ptr, offset, size);
}
public static final void _wglUniformBlockBinding(IProgramGL obj, int blockIndex, int bufferIndex) {
glUniformBlockBinding(((OpenGLObjects.ProgramGL) obj).ptr, blockIndex, bufferIndex);
}
public static final void _wglUniform1f(IUniformGL obj, float x) {
if (obj != null)
glUniform1f(((OpenGLObjects.UniformGL) obj).ptr, x);
@ -403,14 +441,36 @@ public class PlatformOpenGL {
EaglerLWJGLAllocator.getAddress(mat));
}
public static final void _wglUniformMatrix3x2fv(IUniformGL obj, boolean transpose, FloatBuffer mat) {
if (obj != null)
nglUniformMatrix3x2fv(((OpenGLObjects.UniformGL) obj).ptr, mat.remaining() / 6, transpose,
EaglerLWJGLAllocator.getAddress(mat));
}
public static final void _wglUniformMatrix4fv(IUniformGL obj, boolean transpose, FloatBuffer mat) {
if (obj != null)
nglUniformMatrix4fv(((OpenGLObjects.UniformGL) obj).ptr, mat.remaining() >> 4, transpose,
EaglerLWJGLAllocator.getAddress(mat));
}
public static final void _wglUniformMatrix4x2fv(IUniformGL obj, boolean transpose, FloatBuffer mat) {
if (obj != null)
nglUniformMatrix4x2fv(((OpenGLObjects.UniformGL) obj).ptr, mat.remaining() >> 3, transpose,
EaglerLWJGLAllocator.getAddress(mat));
}
public static final void _wglUniformMatrix4x3fv(IUniformGL obj, boolean transpose, FloatBuffer mat) {
if (obj != null)
nglUniformMatrix4x3fv(((OpenGLObjects.UniformGL) obj).ptr, mat.remaining() / 12, transpose,
EaglerLWJGLAllocator.getAddress(mat));
}
public static final void _wglBindFramebuffer(int target, IFramebufferGL framebuffer) {
glBindFramebuffer(target, framebuffer == null ? 0 : ((OpenGLObjects.FramebufferGL) framebuffer).ptr);
if(framebuffer == null) {
glBindFramebuffer(target, 0);
}else {
glBindFramebuffer(target, ((OpenGLObjects.FramebufferGL) framebuffer).ptr);
}
}
public static final int _wglCheckFramebufferStatus(int target) {
@ -422,6 +482,10 @@ public class PlatformOpenGL {
glFramebufferTexture2D(target, attachment, texTarget, ((OpenGLObjects.TextureGL) texture).ptr, level);
}
public static final void _wglFramebufferTextureLayer(int target, int attachment, ITextureGL texture, int level, int layer) {
glFramebufferTextureLayer(target, attachment, ((OpenGLObjects.TextureGL) texture).ptr, level, layer);
}
public static final void _wglBlitFramebuffer(int srcX0, int srcY0, int srcX1, int srcY1, int dstX0, int dstY0,
int dstX1, int dstY1, int bits, int filter) {
glBlitFramebuffer(srcX0, srcY0, srcX1, srcY1, dstX0, dstY0, dstX1, dstY1, bits, filter);
@ -453,4 +517,8 @@ public class PlatformOpenGL {
return glGetError();
}
public static final boolean checkHDRFramebufferSupport(int bits) {
return true;
}
}

View File

@ -232,6 +232,7 @@ public class PlatformRuntime {
logger.info("Initializing Hooks...");
PlatformInput.initHooks(windowHandle);
PlatformApplication.initHooks(windowHandle);
}
public static void destroy() {

View File

@ -2,9 +2,11 @@ package net.lax1dude.eaglercraft.v1_8.internal;
import java.net.URI;
import java.nio.ByteBuffer;
import java.nio.charset.StandardCharsets;
import org.java_websocket.client.WebSocketClient;
import org.java_websocket.drafts.Draft;
import org.java_websocket.drafts.Draft_6455;
import org.java_websocket.extensions.permessage_deflate.PerMessageDeflateExtension;
import org.java_websocket.handshake.ServerHandshake;
import net.lax1dude.eaglercraft.v1_8.log4j.LogManager;
@ -24,12 +26,15 @@ import net.lax1dude.eaglercraft.v1_8.log4j.Logger;
*
*/
class WebSocketPlayClient extends WebSocketClient {
private static final Draft perMessageDeflateDraft = new Draft_6455(new PerMessageDeflateExtension());
public static final Logger logger = LogManager.getLogger("WebSocket");
WebSocketPlayClient(URI serverUri) {
super(serverUri);
super(serverUri, perMessageDeflateDraft);
this.setConnectionLostTimeout(15);
this.setTcpNoDelay(true);
}
@Override

View File

@ -6,6 +6,9 @@ import java.util.LinkedList;
import java.util.List;
import org.java_websocket.client.WebSocketClient;
import org.java_websocket.drafts.Draft;
import org.java_websocket.drafts.Draft_6455;
import org.java_websocket.extensions.permessage_deflate.PerMessageDeflateExtension;
import org.java_websocket.handshake.ServerHandshake;
import org.json.JSONObject;
@ -27,6 +30,8 @@ import net.lax1dude.eaglercraft.v1_8.log4j.Logger;
*/
class WebSocketServerQuery extends WebSocketClient implements IServerQuery {
private static final Draft perMessageDeflateDraft = new Draft_6455(new PerMessageDeflateExtension());
public static final Logger logger = LogManager.getLogger("WebSocketQuery");
private final List<QueryResponse> queryResponses = new LinkedList();
@ -39,7 +44,7 @@ class WebSocketServerQuery extends WebSocketClient implements IServerQuery {
private EnumServerRateLimit rateLimit = EnumServerRateLimit.OK;
WebSocketServerQuery(String type, URI serverUri) {
super(serverUri);
super(serverUri, perMessageDeflateDraft);
this.type = type;
this.setConnectionLostTimeout(5);
this.setTcpNoDelay(true);

View File

@ -7,6 +7,7 @@ import net.lax1dude.eaglercraft.v1_8.EagRuntime;
import net.lax1dude.eaglercraft.v1_8.EagUtils;
import net.lax1dude.eaglercraft.v1_8.internal.EnumPlatformANGLE;
import net.lax1dude.eaglercraft.v1_8.internal.PlatformRuntime;
import net.lax1dude.eaglercraft.v1_8.opengl.ext.deferred.program.ShaderSource;
import net.minecraft.client.main.Main;
/**
@ -45,6 +46,12 @@ public class LWJGLEntryPoint {
getANGLEPlatformFromArgs(args);
for(int i = 0; i < args.length; ++i) {
if(args[i].equalsIgnoreCase("highp")) {
ShaderSource.setHighP(true);
}
}
EagRuntime.create();
Main.appMain(new String[0]);