23w49a "Service Pack #1" Various Fixes

This commit is contained in:
lax1dude 2023-12-09 20:31:39 -08:00
parent f573dbb78b
commit b31e337a55
19 changed files with 28306 additions and 170970 deletions

View File

@ -37,7 +37,7 @@ dependencies {
teavm { teavm {
compileScopes = null; compileScopes = null;
minifying = false; minifying = true;
maxTopLevelNames = 10000; maxTopLevelNames = 10000;
properties = null; properties = null;
debugInformationGenerated = false; debugInformationGenerated = false;

Binary file not shown.

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

View File

@ -1,9 +1,7 @@
// eaglercraft opengl 1.3 emulation // copyright (c) 2020-2023 lax1dude
// copyright (c) 2020 calder young
// creative commons BY-NC 4.0
#line 7 #line 4
precision highp int; precision highp int;
precision highp sampler2D; precision highp sampler2D;
@ -99,6 +97,8 @@ in vec2 v_texture0;
out vec4 fragColor; out vec4 fragColor;
#define TEX_MAT3x2(mat4In) mat3x2(mat4In[0].xy,mat4In[1].xy,mat4In[3].xy)
void main(){ void main(){
#ifdef CC_a_color #ifdef CC_a_color
vec4 color = colorUniform * v_color; vec4 color = colorUniform * v_color;
@ -108,9 +108,9 @@ void main(){
#ifdef CC_unit0 #ifdef CC_unit0
#ifdef CC_a_texture0 #ifdef CC_a_texture0
color *= texture(tex0, (matrix_t * vec4(v_texture0, 0.0, 1.0)).xy).rgba; color *= texture(tex0, (TEX_MAT3x2(matrix_t) * vec3(v_texture0, 1.0)).xy).rgba;
#else #else
color *= texture(tex0, (matrix_t * vec4(texCoordV0, 0.0, 1.0)).xy).rgba; color *= texture(tex0, (TEX_MAT3x2(matrix_t) * vec3(texCoordV0, 1.0)).xy).rgba;
#endif #endif
#endif #endif
@ -133,7 +133,7 @@ void main(){
#ifdef CC_fog #ifdef CC_fog
float dist = sqrt(dot(v_position, v_position)); float dist = sqrt(dot(v_position, v_position));
float i = (fogMode == 1) ? clamp((dist - fogStart) / (fogEnd - fogStart), 0.0, 1.0) : clamp(1.0 - pow(2.718, -(fogDensity * dist)), 0.0, 1.0); float i = (fogMode == 1) ? clamp((dist - fogStart) / (fogEnd - fogStart), 0.0, 1.0) : clamp(1.0 - exp(-(fogDensity * dist)), 0.0, 1.0);
color.rgb = mix(color.rgb, fogColor.xyz, i * fogColor.a); color.rgb = mix(color.rgb, fogColor.xyz, i * fogColor.a);
#endif #endif

View File

@ -1,18 +1,68 @@
#line 0 #line 2
// Remove this line below if you plan to modify this file
#define USE_OPTIMIZED
/*
* 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)
*
*/
/*
* This file was modified by lax1dude to remove dead code
*
* Original: https://gist.github.com/kosua20/0c506b81b3812ac900048059d2383126
*
*/
/*
* ============================================================================
*
*
* NVIDIA FXAA 3.11 by TIMOTHY LOTTES
*
*
* ------------------------------------------------------------------------------
* COPYRIGHT (C) 2010, 2011 NVIDIA CORPORATION. ALL RIGHTS RESERVED.
* ------------------------------------------------------------------------------
* TO THE MAXIMUM EXTENT PERMITTED BY APPLICABLE LAW, THIS SOFTWARE IS PROVIDED
* *AS IS* AND NVIDIA AND ITS SUPPLIERS DISCLAIM ALL WARRANTIES, EITHER EXPRESS
* OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, IMPLIED WARRANTIES OF
* MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. IN NO EVENT SHALL NVIDIA
* OR ITS SUPPLIERS BE LIABLE FOR ANY SPECIAL, INCIDENTAL, INDIRECT, OR
* CONSEQUENTIAL DAMAGES WHATSOEVER (INCLUDING, WITHOUT LIMITATION, DAMAGES FOR
* LOSS OF BUSINESS PROFITS, BUSINESS INTERRUPTION, LOSS OF BUSINESS INFORMATION,
* OR ANY OTHER PECUNIARY LOSS) ARISING OUT OF THE USE OF OR INABILITY TO USE
* THIS SOFTWARE, EVEN IF NVIDIA HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH
* DAMAGES.
*
*/
precision lowp int; precision lowp int;
precision lowp sampler2D; precision mediump float;
precision lowp float; precision mediump sampler2D;
in vec2 pos; in vec2 pos;
out vec4 fragColor; layout(location = 0) out vec4 output4f;
#define FXAA_PC 1 uniform sampler2D f_color;
#define FXAA_GLSL_130 1 uniform vec2 screenSize;
#define FXAA_FAST_PIXEL_OFFSET 0
#define FXAA_GATHER4_ALPHA 0
#ifndef USE_OPTIMIZED
#ifndef FXAA_GREEN_AS_LUMA #ifndef FXAA_GREEN_AS_LUMA
// For those using non-linear color, // For those using non-linear color,
// and either not able to get luma in alpha, or not wanting to, // and either not able to get luma in alpha, or not wanting to,
@ -31,7 +81,7 @@ out vec4 fragColor;
// 1 = On. // 1 = On.
// 0 = Off. // 0 = Off.
// //
#define FXAA_GREEN_AS_LUMA 1 #define FXAA_GREEN_AS_LUMA 0
#endif #endif
#ifndef FXAA_DISCARD #ifndef FXAA_DISCARD
@ -58,14 +108,13 @@ out vec4 fragColor;
#define FxaaTex sampler2D #define FxaaTex sampler2D
/*--------------------------------------------------------------------------*/ /*--------------------------------------------------------------------------*/
#define FxaaTexTop(t, p) texture(t, p) #define FxaaTexTop(t, p) textureLod(t, p, 0.0)
/*============================================================================ /*============================================================================
GREEN AS LUMA OPTION SUPPORT FUNCTION GREEN AS LUMA OPTION SUPPORT FUNCTION
============================================================================*/ ============================================================================*/
#if (FXAA_GREEN_AS_LUMA == 0) #if (FXAA_GREEN_AS_LUMA == 0)
// TODO Luma FxaaFloat FxaaLuma(FxaaFloat4 rgba) { return dot(rgba.xyz * rgba.xyz, vec3(0.299, 0.587, 0.114)); }
FxaaFloat FxaaLuma(FxaaFloat4 rgba) { return dot(rgba.xyz, vec3(0.299, 0.587, 0.114)); }
#else #else
FxaaFloat FxaaLuma(FxaaFloat4 rgba) { return rgba.y; } FxaaFloat FxaaLuma(FxaaFloat4 rgba) { return rgba.y; }
#endif #endif
@ -232,24 +281,91 @@ FxaaFloat4 FxaaPixelShader(
} }
/*==========================================================================*/ /*==========================================================================*/
uniform sampler2D f_color; #define edgeSharpness 3.0
#define edgeThreshold 0.15
uniform vec2 screenSize; #define edgeThresholdMin 0.05
#define edgeSharpness 7.0
#define edgeThreshold 0.1
#define edgeThresholdMin 0.005
void main(){ void main(){
vec4 posPos; vec2 screenSize05 = 0.5 * screenSize;
posPos.xy = pos - (0.6 / screenSize);
posPos.zw = pos + (0.6 / screenSize);
vec4 rcpFrameOpt;
rcpFrameOpt.xy = vec2(-0.50, -0.50) / screenSize;
rcpFrameOpt.zw = vec2( 0.50, 0.50) / screenSize;
vec4 rcpFrameOpt2;
rcpFrameOpt2.xy = vec2(-2.0, -2.0) / screenSize;
rcpFrameOpt2.zw = vec2( 2.0, 2.0) / screenSize;
fragColor = vec4(FxaaPixelShader(pos, posPos, f_color, rcpFrameOpt, rcpFrameOpt2, edgeSharpness, edgeThreshold, edgeThresholdMin).rgb, 1.0); vec4 posPos;
posPos.xy = pos;
posPos.zw = pos + screenSize;
vec4 rcpFrameOpt;
rcpFrameOpt.xy = -screenSize05;
rcpFrameOpt.zw = screenSize05;
output4f = vec4(FxaaPixelShader(pos + screenSize05, posPos, f_color, rcpFrameOpt, rcpFrameOpt * 4.0, edgeSharpness, edgeThreshold, edgeThresholdMin).rgb, 1.0);
} }
#else
// This 'optimized' code was generated using glslangValidator + spirv-cross + spirv-opt on the source code above
// Is it faster? Idfk, probably compiles faster at least, what matters it I tried
float _616;
vec4 _617;
void main()
{
mediump vec2 _257 = screenSize * 0.5;
mediump vec4 _611 = vec4(pos, pos + screenSize);
mediump vec4 _612 = vec4(_616, _616, _257);
mediump vec2 _290 = pos + _257;
mediump vec4 _608;
for(;;)
{
mediump vec3 _532 = textureLod(f_color, _611.xy, 0.0).xyz;
mediump float _536 = dot(_532 * _532, vec3(0.2989999949932098388671875, 0.58700001239776611328125, 0.114000000059604644775390625));
mediump vec3 _540 = textureLod(f_color, _611.xw, 0.0).xyz;
mediump float _544 = dot(_540 * _540, vec3(0.2989999949932098388671875, 0.58700001239776611328125, 0.114000000059604644775390625));
mediump vec3 _548 = textureLod(f_color, _611.zy, 0.0).xyz;
mediump vec3 _556 = textureLod(f_color, _611.zw, 0.0).xyz;
mediump float _560 = dot(_556 * _556, vec3(0.2989999949932098388671875, 0.58700001239776611328125, 0.114000000059604644775390625));
mediump vec4 _390 = textureLod(f_color, _290, 0.0);
mediump vec3 _564 = _390.xyz;
mediump float _568 = dot(_564 * _564, vec3(0.2989999949932098388671875, 0.58700001239776611328125, 0.114000000059604644775390625));
mediump float _397 = dot(_548 * _548, vec3(0.2989999949932098388671875, 0.58700001239776611328125, 0.114000000059604644775390625)) + 0.00260416674427688121795654296875;
mediump float _409 = max(max(_397, _560), max(_536, _544));
mediump float _412 = min(min(_397, _560), min(_536, _544));
mediump float _427 = _544 - _397;
mediump float _433 = _560 - _536;
if ((max(_409, _568) - min(_412, _568)) < max(0.0500000007450580596923828125, _409 * 0.1500000059604644775390625))
{
_608 = _390;
break;
}
mediump vec2 _449 = normalize(vec2(_427 + _433, _427 - _433));
vec2 hp_copy_449 = _449;
mediump vec2 _454 = _612.zw;
vec2 _614 = -hp_copy_449;
mediump vec2 mp_copy_614 = _614;
mediump vec2 _481 = clamp(_449 / vec2(min(abs(_449.x), abs(_449.y)) * 3.0), vec2(-2.0), vec2(2.0));
vec2 hp_copy_481 = _481;
mediump vec2 _484 = (_612 * 4.0).zw;
vec2 _615 = -hp_copy_481;
mediump vec2 mp_copy_615 = _615;
mediump vec4 _498 = textureLod(f_color, mp_copy_614 * _454 + _290, 0.0) + textureLod(f_color, _449 * _454 + _290, 0.0);
mediump vec4 _505 = ((textureLod(f_color, mp_copy_615 * _484 + _290, 0.0) + textureLod(f_color, _481 * _484 + _290, 0.0)) * 0.25) + (_498 * 0.25);
mediump float _576 = dot(_505.xyz * _505.xyz, vec3(0.2989999949932098388671875, 0.58700001239776611328125, 0.114000000059604644775390625));
mediump vec4 _607;
if ((_576 < _412) || (_576 > _409))
{
mediump vec3 _518 = _498.xyz * 0.5;
mediump vec4 _600;
_600.x = _518.x;
_600.y = _518.y;
_600.z = _518.z;
_607 = _600;
}
else
{
_607 = _505;
}
_608 = _607;
break;
}
output4f = vec4(_608.xyz, 1.0);
}
#endif

View File

@ -4,10 +4,10 @@ public class ConfigConstants {
public static boolean profanity = false; public static boolean profanity = false;
public static final String version = "22w22b"; public static final String version = "23w49a";
public static final String mainMenuString = "eaglercraft beta-" + version; public static final String mainMenuString = "eaglercraft beta-" + version;
public static final String forkMe = "https://github.com/LAX1DUDE/eaglercraft"; public static final String forkMe = null;
public static final boolean html5build = true; public static final boolean html5build = true;

File diff suppressed because one or more lines are too long

View File

@ -91,7 +91,7 @@ public class EffectPipelineFXAA {
_wglTexParameteri(_wGL_TEXTURE_2D, _wGL_TEXTURE_MIN_FILTER, _wGL_NEAREST); _wglTexParameteri(_wGL_TEXTURE_2D, _wGL_TEXTURE_MIN_FILTER, _wGL_NEAREST);
_wglTexParameteri(_wGL_TEXTURE_2D, _wGL_TEXTURE_WRAP_S, _wGL_CLAMP); _wglTexParameteri(_wGL_TEXTURE_2D, _wGL_TEXTURE_WRAP_S, _wGL_CLAMP);
_wglTexParameteri(_wGL_TEXTURE_2D, _wGL_TEXTURE_WRAP_T, _wGL_CLAMP); _wglTexParameteri(_wGL_TEXTURE_2D, _wGL_TEXTURE_WRAP_T, _wGL_CLAMP);
_wglTexImage2D(_wGL_TEXTURE_2D, 0, _wGL_RGB8, width, height, 0, _wGL_RGB, _wGL_UNSIGNED_BYTE, (ByteBuffer)null); _wglTexImage2D(_wGL_TEXTURE_2D, 0, _wGL_RGBA8, width, height, 0, _wGL_RGBA, _wGL_UNSIGNED_BYTE, (ByteBuffer)null);
framebuffer_depth = _wglCreateRenderBuffer(); framebuffer_depth = _wglCreateRenderBuffer();
_wglBindRenderbuffer(framebuffer_depth); _wglBindRenderbuffer(framebuffer_depth);
@ -125,7 +125,7 @@ public class EffectPipelineFXAA {
initFXAA(); initFXAA();
}else { }else {
_wglBindTexture(_wGL_TEXTURE_2D, fxaaSourceTexture); _wglBindTexture(_wGL_TEXTURE_2D, fxaaSourceTexture);
_wglTexImage2D(_wGL_TEXTURE_2D, 0, _wGL_RGB8, width, height, 0, _wGL_RGB, _wGL_UNSIGNED_BYTE, (ByteBuffer)null); _wglTexImage2D(_wGL_TEXTURE_2D, 0, _wGL_RGBA8, width, height, 0, _wGL_RGBA, _wGL_UNSIGNED_BYTE, (ByteBuffer)null);
_wglBindRenderbuffer(framebuffer_depth); _wglBindRenderbuffer(framebuffer_depth);
_wglRenderbufferStorage(_wGL_DEPTH_COMPONENT32F, width, height); _wglRenderbufferStorage(_wGL_DEPTH_COMPONENT32F, width, height);
} }
@ -147,7 +147,7 @@ public class EffectPipelineFXAA {
_wglDisable(_wGL_CULL_FACE); _wglDisable(_wGL_CULL_FACE);
_wglDepthMask(false); _wglDepthMask(false);
_wglUseProgram(fxaaProgram); _wglUseProgram(fxaaProgram);
_wglUniform2f(fxaaScreenSize, width, height); _wglUniform2f(fxaaScreenSize, 1.0f / width, 1.0f / height);
_wglBindVertexArray(renderQuadArray); _wglBindVertexArray(renderQuadArray);
_wglDrawArrays(_wGL_TRIANGLES, 0, 6); _wglDrawArrays(_wGL_TRIANGLES, 0, 6);
_wglEnable(_wGL_DEPTH_TEST); _wglEnable(_wGL_DEPTH_TEST);

View File

@ -571,7 +571,7 @@ public class RenderGlobal implements IWorldAccess {
float f12 = ((float) j * 3.141593F * 2.0F) / (float) i; float f12 = ((float) j * 3.141593F * 2.0F) / (float) i;
float f14 = MathHelper.sin(f12); float f14 = MathHelper.sin(f12);
float f15 = MathHelper.cos(f12); float f15 = MathHelper.cos(f12);
tessellator.addVertex(f14 * 120F, f15 * 120F, -f15 * 40F * af[3]); tessellator.addVertex(f14 * 120F, f15 * 120F, f15 * 40F * af[3]);
} }
tessellator.draw(); tessellator.draw();

View File

@ -77,7 +77,7 @@ public class SoundManager {
try { try {
EaglerAdapter.setListenerPos((float)x, (float)y, (float)z, (float)par1EntityLiving.motionX, (float)par1EntityLiving.motionY, (float)par1EntityLiving.motionZ, (float)pitch, (float)yaw); EaglerAdapter.setListenerPos((float)x, (float)y, (float)z, (float)par1EntityLiving.motionX, (float)par1EntityLiving.motionY, (float)par1EntityLiving.motionZ, (float)pitch, (float)yaw);
}catch(Throwable t) { }catch(Throwable t) {
System.err.println("AudioListener f***ed up again"); System.err.println("AudioListener is being a vigg again");
} }
} }
} }

View File

@ -30,6 +30,11 @@ public class Client {
// yee // yee
} }
// avoid inlining of constant
private static String crashImageWrapper() {
return crashImage.substring(0);
}
public static HTMLElement rootElement = null; public static HTMLElement rootElement = null;
public static Minecraft instance = null; public static Minecraft instance = null;
public static void main(String[] args) { public static void main(String[] args) {
@ -101,7 +106,7 @@ public class Client {
str.append(t); str.append(t);
str.append('\n').append('\n'); str.append('\n').append('\n');
str.append("eaglercraft.version = \"").append(ConfigConstants.version).append("\"\n"); str.append("eaglercraft.version = \"").append(ConfigConstants.version).append("\"\n");
str.append("eaglercraft.minecraft = \"1.5.2\"\n"); str.append("eaglercraft.minecraft = \"b1.3\"\n");
str.append("eaglercraft.brand = \"eagtek\"\n"); str.append("eaglercraft.brand = \"eagtek\"\n");
//str.append("eaglercraft.username = \"").append(EaglerProfile.username).append("\"\n"); //str.append("eaglercraft.username = \"").append(EaglerProfile.username).append("\"\n");
//str.append("eaglercraft.channel = \"").append(EaglerProfile.myChannel).append("\"\n"); //str.append("eaglercraft.channel = \"").append(EaglerProfile.myChannel).append("\"\n");
@ -143,7 +148,7 @@ public class Client {
HTMLElement img = doc.createElement("img"); HTMLElement img = doc.createElement("img");
HTMLElement div = doc.createElement("div"); HTMLElement div = doc.createElement("div");
img.setAttribute("style", "z-index:100;position:absolute;top:10px;left:calc(50% - 151px);"); img.setAttribute("style", "z-index:100;position:absolute;top:10px;left:calc(50% - 151px);");
img.setAttribute("src", crashImage); img.setAttribute("src", crashImageWrapper());
div.setAttribute("style", "z-index:100;position:absolute;top:135px;left:10%;right:10%;bottom:30px;background-color:white;border:1px solid #cccccc;overflow-x:hidden;overflow-y:scroll;overflow-wrap:break-word;white-space:pre-wrap;font: 14px monospace;padding:10px;"); div.setAttribute("style", "z-index:100;position:absolute;top:135px;left:10%;right:10%;bottom:30px;background-color:white;border:1px solid #cccccc;overflow-x:hidden;overflow-y:scroll;overflow-wrap:break-word;white-space:pre-wrap;font: 14px monospace;padding:10px;");
rootElement.appendChild(img); rootElement.appendChild(img);
rootElement.appendChild(div); rootElement.appendChild(div);
@ -159,7 +164,7 @@ public class Client {
HTMLElement img = doc.createElement("img"); HTMLElement img = doc.createElement("img");
HTMLElement div = doc.createElement("div"); HTMLElement div = doc.createElement("div");
img.setAttribute("style", "z-index:100;position:absolute;top:10px;left:calc(50% - 151px);"); img.setAttribute("style", "z-index:100;position:absolute;top:10px;left:calc(50% - 151px);");
img.setAttribute("src", crashImage); img.setAttribute("src", crashImageWrapper());
div.setAttribute("style", "z-index:100;position:absolute;top:135px;left:10%;right:10%;bottom:30px;background-color:white;border:1px solid #cccccc;overflow-x:hidden;overflow-y:scroll;overflow-wrap:break-word;white-space:pre-wrap;font: 24px sans-serif;padding:10px;"); div.setAttribute("style", "z-index:100;position:absolute;top:135px;left:10%;right:10%;bottom:30px;background-color:white;border:1px solid #cccccc;overflow-x:hidden;overflow-y:scroll;overflow-wrap:break-word;white-space:pre-wrap;font: 24px sans-serif;padding:10px;");
rootElement.appendChild(img); rootElement.appendChild(img);
rootElement.appendChild(div); rootElement.appendChild(div);

View File

@ -26,6 +26,7 @@ import org.teavm.jso.browser.TimerHandler;
import org.teavm.jso.browser.Window; import org.teavm.jso.browser.Window;
import org.teavm.jso.canvas.CanvasRenderingContext2D; import org.teavm.jso.canvas.CanvasRenderingContext2D;
import org.teavm.jso.canvas.ImageData; import org.teavm.jso.canvas.ImageData;
import org.teavm.jso.dom.css.CSSStyleDeclaration;
import org.teavm.jso.dom.events.Event; import org.teavm.jso.dom.events.Event;
import org.teavm.jso.dom.events.EventListener; import org.teavm.jso.dom.events.EventListener;
import org.teavm.jso.dom.events.KeyboardEvent; import org.teavm.jso.dom.events.KeyboardEvent;
@ -207,13 +208,18 @@ public class EaglerAdapterImpl2 {
win = Window.current(); win = Window.current();
doc = win.getDocument(); doc = win.getDocument();
canvas = (HTMLCanvasElement)doc.createElement("canvas"); canvas = (HTMLCanvasElement)doc.createElement("canvas");
width = rootElement.getClientWidth(); double r = win.getDevicePixelRatio();
height = rootElement.getClientHeight(); width = (int)(rootElement.getClientWidth() * r);
height = (int)(rootElement.getClientHeight() * r);
canvas.setWidth(width); canvas.setWidth(width);
canvas.setHeight(height); canvas.setHeight(height);
canvasContext = (CanvasRenderingContext2D) canvas.getContext("2d"); canvasContext = (CanvasRenderingContext2D) canvas.getContext("2d");
canvas.setAttribute("id", "deevis589723589"); canvas.setAttribute("id", "deevis589723589");
rootElement.appendChild(canvas); rootElement.appendChild(canvas);
CSSStyleDeclaration canvasStyle = canvas.getStyle();
canvasStyle.setProperty("width", "100%");
canvasStyle.setProperty("height", "100%");
canvasStyle.setProperty("image-rendering", "pixelated");
canvasBack = (HTMLCanvasElement)doc.createElement("canvas"); canvasBack = (HTMLCanvasElement)doc.createElement("canvas");
canvasBack.setWidth(width); canvasBack.setWidth(width);
canvasBack.setHeight(height); canvasBack.setHeight(height);
@ -259,8 +265,9 @@ public class EaglerAdapterImpl2 {
canvas.addEventListener("mousemove", mousemove = new EventListener<MouseEvent>() { canvas.addEventListener("mousemove", mousemove = new EventListener<MouseEvent>() {
@Override @Override
public void handleEvent(MouseEvent evt) { public void handleEvent(MouseEvent evt) {
mouseX = getOffsetX(evt); double r = win.getDevicePixelRatio();
mouseY = canvas.getClientHeight() - getOffsetY(evt); mouseX = (int)(getOffsetX(evt) * r);
mouseY = (int)((canvas.getClientHeight() - getOffsetY(evt)) * r);
mouseDX += evt.getMovementX(); mouseDX += evt.getMovementX();
mouseDY += -evt.getMovementY(); mouseDY += -evt.getMovementY();
evt.preventDefault(); evt.preventDefault();
@ -1056,10 +1063,10 @@ public class EaglerAdapterImpl2 {
return mouseY; return mouseY;
} }
public static final int mouseGetEventX() { public static final int mouseGetEventX() {
return currentEvent == null ? -1 : currentEvent.getClientX(); return currentEvent == null ? -1 : (int)(currentEvent.getClientX() * win.getDevicePixelRatio());
} }
public static final int mouseGetEventY() { public static final int mouseGetEventY() {
return currentEvent == null ? -1 : canvas.getClientHeight() - currentEvent.getClientY(); return currentEvent == null ? -1 : (int)((canvas.getClientHeight() - currentEvent.getClientY()) * win.getDevicePixelRatio());
} }
public static final boolean keysNext() { public static final boolean keysNext() {
if(unpressCTRL) { //un-press ctrl after copy/paste permission if(unpressCTRL) { //un-press ctrl after copy/paste permission
@ -1121,10 +1128,10 @@ public class EaglerAdapterImpl2 {
public static final void updateDisplay() { public static final void updateDisplay() {
commitContext(webgl); commitContext(webgl);
canvasContext.drawImage(canvasBack, 0d, 0d, canvas.getWidth(), canvas.getHeight()); canvasContext.drawImage(canvasBack, 0d, 0d, canvasBack.getWidth(), canvasBack.getHeight());
double r = win.getDevicePixelRatio();
int ww = canvas.getClientWidth(); int ww = (int)(canvas.getClientWidth() * r);
int hh = canvas.getClientHeight(); int hh = (int)(canvas.getClientHeight() * r);
if(ww != width || hh != height) { if(ww != width || hh != height) {
width = ww; width = ww;
height = hh; height = hh;
@ -1171,7 +1178,7 @@ public class EaglerAdapterImpl2 {
return win.getScreen().getAvailHeight(); return win.getScreen().getAvailHeight();
} }
public static final int getCanvasWidth() { public static final int getCanvasWidth() {
int w = parent.getClientWidth(); int w = (int)(parent.getClientWidth() * win.getDevicePixelRatio());
if(w != width) { if(w != width) {
canvas.setWidth(w); canvas.setWidth(w);
canvasBack.setWidth(w); canvasBack.setWidth(w);
@ -1180,7 +1187,7 @@ public class EaglerAdapterImpl2 {
return w; return w;
} }
public static final int getCanvasHeight() { public static final int getCanvasHeight() {
int h = parent.getClientHeight(); int h = (int)(parent.getClientHeight() * win.getDevicePixelRatio());
if(h != height) { if(h != height) {
canvas.setHeight(h); canvas.setHeight(h);
canvasBack.setHeight(h); canvasBack.setHeight(h);
@ -1474,10 +1481,14 @@ public class EaglerAdapterImpl2 {
public static final int beginPlayback(String fileName, float x, float y, float z, float volume, float pitch) { public static final int beginPlayback(String fileName, float x, float y, float z, float volume, float pitch) {
AudioBuffer b = getBufferFor(fileName); AudioBuffer b = getBufferFor(fileName);
if(b == null) return -1; if(b == null) return -1;
AudioBufferSourceNode s = audioctx.createBufferSource(); AudioBufferSourceNode s;
PannerNode p;
GainNode g;
try {
s = audioctx.createBufferSource();
s.setBuffer(b); s.setBuffer(b);
s.getPlaybackRate().setValue(pitch); s.getPlaybackRate().setValue(pitch);
PannerNode p = audioctx.createPanner(); p = audioctx.createPanner();
p.setPosition(x, y, z); p.setPosition(x, y, z);
p.setMaxDistance(volume * 16f + 0.1f); p.setMaxDistance(volume * 16f + 0.1f);
p.setRolloffFactor(1f); p.setRolloffFactor(1f);
@ -1488,12 +1499,16 @@ public class EaglerAdapterImpl2 {
p.setConeOuterAngle(0f); p.setConeOuterAngle(0f);
p.setConeOuterGain(0f); p.setConeOuterGain(0f);
p.setOrientation(0f, 1f, 0f); p.setOrientation(0f, 1f, 0f);
GainNode g = audioctx.createGain(); g = audioctx.createGain();
g.getGain().setValue(volume > 1.0f ? 1.0f : volume); g.getGain().setValue(volume > 1.0f ? 1.0f : volume);
s.connect(g); s.connect(g);
g.connect(p); g.connect(p);
p.connect(audioctx.getDestination()); p.connect(audioctx.getDestination());
s.start(0.0d, playbackOffsetDelay); s.start(0.0d, playbackOffsetDelay);
}catch(Throwable t) {
System.err.println("Failed to set up 3D audio source node! " + t.toString());
return -1;
}
final int theId = ++playbackId; final int theId = ++playbackId;
activeSoundEffects.put(theId, new AudioBufferSourceNodeX(s, p, g)); activeSoundEffects.put(theId, new AudioBufferSourceNodeX(s, p, g));
s.setOnEnded(new EventListener<MediaEvent>() { s.setOnEnded(new EventListener<MediaEvent>() {
@ -1509,14 +1524,21 @@ public class EaglerAdapterImpl2 {
public static final int beginPlaybackStatic(String fileName, float volume, float pitch) { public static final int beginPlaybackStatic(String fileName, float volume, float pitch) {
AudioBuffer b = getBufferFor(fileName); AudioBuffer b = getBufferFor(fileName);
if(b == null) return -1; if(b == null) return -1;
AudioBufferSourceNode s = audioctx.createBufferSource(); AudioBufferSourceNode s;
GainNode g;
try {
s = audioctx.createBufferSource();
s.setBuffer(b); s.setBuffer(b);
s.getPlaybackRate().setValue(pitch); s.getPlaybackRate().setValue(pitch);
GainNode g = audioctx.createGain(); g = audioctx.createGain();
g.getGain().setValue(volume > 1.0f ? 1.0f : volume); g.getGain().setValue(volume > 1.0f ? 1.0f : volume);
s.connect(g); s.connect(g);
g.connect(audioctx.getDestination()); g.connect(audioctx.getDestination());
s.start(0.0d, playbackOffsetDelay); s.start(0.0d, playbackOffsetDelay);
}catch(Throwable t) {
System.err.println("Failed to set up 2D audio source node! " + t.toString());
return -1;
}
final int theId = ++playbackId; final int theId = ++playbackId;
activeSoundEffects.put(theId, new AudioBufferSourceNodeX(s, null, g)); activeSoundEffects.put(theId, new AudioBufferSourceNodeX(s, null, g));
s.setOnEnded(new EventListener<MediaEvent>() { s.setOnEnded(new EventListener<MediaEvent>() {
@ -1544,7 +1566,11 @@ public class EaglerAdapterImpl2 {
public static final void moveSound(int id, float x, float y, float z, float vx, float vy, float vz) { public static final void moveSound(int id, float x, float y, float z, float vx, float vy, float vz) {
AudioBufferSourceNodeX b = activeSoundEffects.get(id); AudioBufferSourceNodeX b = activeSoundEffects.get(id);
if(b != null && b.panner != null) { if(b != null && b.panner != null) {
try {
b.panner.setPosition(x, y, z); b.panner.setPosition(x, y, z);
}catch(Throwable t) {
System.err.println("Could not reposition audio node " + id + ": " + t.toString());
}
//b.panner.setVelocity(vx, vy, vz); //b.panner.setVelocity(vx, vy, vz);
} }
} }

File diff suppressed because one or more lines are too long

Binary file not shown.

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long