Merge remote-tracking branch 'dev/main'
This commit is contained in:
@@ -27,6 +27,7 @@ import openfl.utils._internal.UInt8Array;
|
||||
import openfl.utils.AGALMiniAssembler;
|
||||
import openfl.utils.ByteArray;
|
||||
#if lime
|
||||
import lime.graphics.opengl.GL;
|
||||
import lime.graphics.Image;
|
||||
import lime.graphics.ImageBuffer;
|
||||
import lime.graphics.RenderContext;
|
||||
@@ -271,7 +272,7 @@ import lime.math.Vector2;
|
||||
@:noCompletion private var __enableErrorChecking:Bool;
|
||||
@:noCompletion private var __fragmentConstants:Float32Array;
|
||||
@:noCompletion private var __frontBufferTexture:RectangleTexture;
|
||||
@:noCompletion private var __positionScale:Float32Array;
|
||||
@:noCompletion private var __positionScale:Float32Array; // TODO: Better approach?
|
||||
@:noCompletion private var __present:Bool;
|
||||
@:noCompletion private var __programs:Map<String, Program3D>;
|
||||
@:noCompletion private var __quadIndexBuffer:IndexBuffer3D;
|
||||
@@ -291,7 +292,11 @@ import lime.math.Vector2;
|
||||
__stage3D = stage3D;
|
||||
|
||||
__context = stage.window.context;
|
||||
#if (js && html5 && dom)
|
||||
gl = GL.context;
|
||||
#else
|
||||
gl = __context.webgl;
|
||||
#end
|
||||
|
||||
if (__contextState == null) __contextState = new Context3DState();
|
||||
__state = new Context3DState();
|
||||
@@ -575,6 +580,14 @@ import lime.math.Vector2;
|
||||
public function configureBackBuffer(width:Int, height:Int, antiAlias:Int, enableDepthAndStencil:Bool = true, wantsBestResolution:Bool = false,
|
||||
wantsBestResolutionOnBrowserZoom:Bool = false):Void
|
||||
{
|
||||
#if !openfl_dpi_aware
|
||||
if (wantsBestResolution)
|
||||
{
|
||||
width = Std.int(width * __stage.window.scale);
|
||||
height = Std.int(height * __stage.window.scale);
|
||||
}
|
||||
#end
|
||||
|
||||
if (__stage3D == null)
|
||||
{
|
||||
backBufferWidth = width;
|
||||
@@ -600,7 +613,16 @@ import lime.math.Vector2;
|
||||
__stage3D.__vertexBuffer = createVertexBuffer(4, 5);
|
||||
}
|
||||
|
||||
var vertexData = new Vector<Float>([width, height, 0, 1, 1, 0, height, 0, 0, 1, width, 0, 0, 1, 0, 0, 0, 0, 0, 0.0]);
|
||||
#if openfl_dpi_aware
|
||||
var scaledWidth = width;
|
||||
var scaledHeight = height;
|
||||
#else
|
||||
var scaledWidth = wantsBestResolution ? width : Std.int(width * __stage.window.scale);
|
||||
var scaledHeight = wantsBestResolution ? height : Std.int(height * __stage.window.scale);
|
||||
#end
|
||||
var vertexData = new Vector<Float>([
|
||||
scaledWidth, scaledHeight, 0, 1, 1, 0, scaledHeight, 0, 0, 1, scaledWidth, 0, 0, 1, 0, 0, 0, 0, 0, 0.0
|
||||
]);
|
||||
|
||||
__stage3D.__vertexBuffer.uploadFromVector(vertexData, 0, 20);
|
||||
|
||||
@@ -1000,6 +1022,8 @@ import lime.math.Vector2;
|
||||
**/
|
||||
public function dispose(recreate:Bool = true):Void
|
||||
{
|
||||
// TODO: Dispose all related buffers
|
||||
|
||||
gl = null;
|
||||
__dispose();
|
||||
}
|
||||
@@ -1172,12 +1196,14 @@ import lime.math.Vector2;
|
||||
#if !openfl_disable_display_render
|
||||
if (__state.renderToTexture == null)
|
||||
{
|
||||
// TODO: Make sure state is correct for this?
|
||||
if (__stage.context3D == this && !__stage.__renderer.__cleared)
|
||||
{
|
||||
__stage.__renderer.__clear();
|
||||
}
|
||||
else if (!__cleared)
|
||||
{
|
||||
// TODO: Throw error if error reporting is enabled?
|
||||
clear(0, 0, 0, 0, 1, 0, Context3DClearMask.COLOR);
|
||||
}
|
||||
}
|
||||
@@ -1223,7 +1249,7 @@ import lime.math.Vector2;
|
||||
if (!__cleared)
|
||||
{
|
||||
// Make sure texture is initialized
|
||||
// BASE-TODO: Throw error if error reporting is enabled?
|
||||
// TODO: Throw error if error reporting is enabled?
|
||||
clear(0, 0, 0, 0, 1, 0, Context3DClearMask.COLOR);
|
||||
}
|
||||
|
||||
@@ -1284,7 +1310,7 @@ import lime.math.Vector2;
|
||||
__state.blendSourceAlphaFactor = sourceAlphaFactor;
|
||||
__state.blendDestinationAlphaFactor = destinationAlphaFactor;
|
||||
|
||||
// BASE-TODO: Better way to handle this?
|
||||
// TODO: Better way to handle this?
|
||||
__setGLBlendEquation(gl.FUNC_ADD);
|
||||
}
|
||||
|
||||
@@ -1363,7 +1389,7 @@ import lime.math.Vector2;
|
||||
public function setProgram(program:Program3D):Void
|
||||
{
|
||||
__state.program = program;
|
||||
__state.shader = null; // BASE-TODO: Merge this logic
|
||||
__state.shader = null; // TODO: Merge this logic
|
||||
|
||||
if (program != null)
|
||||
{
|
||||
@@ -1407,11 +1433,11 @@ import lime.math.Vector2;
|
||||
|
||||
if (__state.program != null && __state.program.__format == GLSL)
|
||||
{
|
||||
// BASE-TODO
|
||||
// TODO
|
||||
}
|
||||
else
|
||||
{
|
||||
// BASE-TODO: Cleanup?
|
||||
// TODO: Cleanup?
|
||||
|
||||
if (numRegisters == -1)
|
||||
{
|
||||
@@ -1421,7 +1447,7 @@ import lime.math.Vector2;
|
||||
var isVertex = (programType == VERTEX);
|
||||
var dest = isVertex ? __vertexConstants : __fragmentConstants;
|
||||
|
||||
var floatData = Float32Array.fromBytes(data, 0, data.length);
|
||||
var floatData = Float32Array.fromBytes(data, 0);
|
||||
var outOffset = firstRegister * 4;
|
||||
var inOffset = Std.int(byteArrayOffset / 4);
|
||||
|
||||
@@ -1465,7 +1491,7 @@ import lime.math.Vector2;
|
||||
{
|
||||
__flushGLProgram();
|
||||
|
||||
// BASE-TODO: Cache value, prevent need to copy
|
||||
// TODO: Cache value, prevent need to copy
|
||||
var data = new Float32Array(16);
|
||||
for (i in 0...16)
|
||||
{
|
||||
@@ -1867,6 +1893,8 @@ import lime.math.Vector2;
|
||||
**/
|
||||
public function setVertexBufferAt(index:Int, buffer:VertexBuffer3D, bufferOffset:Int = 0, format:Context3DVertexBufferFormat = FLOAT_4):Void
|
||||
{
|
||||
if (index < 0) return;
|
||||
|
||||
if (buffer == null)
|
||||
{
|
||||
gl.disableVertexAttribArray(index);
|
||||
@@ -1930,7 +1958,7 @@ import lime.math.Vector2;
|
||||
|
||||
@:noCompletion private function __bindGLTexture2D(texture:GLTexture):Void
|
||||
{
|
||||
// BASE-TODO: Need to consider activeTexture ID
|
||||
// TODO: Need to consider activeTexture ID
|
||||
|
||||
// if (#if openfl_disable_context_cache true #else __contextState.__currentGLTexture2D != texture #end) {
|
||||
|
||||
@@ -1942,7 +1970,7 @@ import lime.math.Vector2;
|
||||
|
||||
@:noCompletion private function __bindGLTextureCubeMap(texture:GLTexture):Void
|
||||
{
|
||||
// BASE-TODO: Need to consider activeTexture ID
|
||||
// TODO: Need to consider activeTexture ID
|
||||
|
||||
// if (#if openfl_disable_context_cache true #else __contextState.__currentGLTextureCubeMap != texture #end) {
|
||||
|
||||
@@ -1981,14 +2009,14 @@ import lime.math.Vector2;
|
||||
#if !openfl_disable_display_render
|
||||
if (__state.renderToTexture == null)
|
||||
{
|
||||
// BASE-TODO: Make sure state is correct for this?
|
||||
// TODO: Make sure state is correct for this?
|
||||
if (__stage.context3D == this && !__stage.__renderer.__cleared)
|
||||
{
|
||||
__stage.__renderer.__clear();
|
||||
}
|
||||
else if (!__cleared)
|
||||
{
|
||||
// BASE-TODO: Throw error if error reporting is enabled?
|
||||
// TODO: Throw error if error reporting is enabled?
|
||||
clear(0, 0, 0, 0, 1, 0, Context3DClearMask.COLOR);
|
||||
}
|
||||
}
|
||||
@@ -2184,7 +2212,7 @@ import lime.math.Vector2;
|
||||
|
||||
if (#if openfl_disable_context_cache true #else __contextState.shader != shader #end)
|
||||
{
|
||||
// BASE-TODO: Merge this logic
|
||||
// TODO: Merge this logic
|
||||
|
||||
if (__contextState.shader != null)
|
||||
{
|
||||
@@ -2240,11 +2268,20 @@ import lime.math.Vector2;
|
||||
var scissorY = Std.int(__state.scissorRectangle.y);
|
||||
var scissorWidth = Std.int(__state.scissorRectangle.width);
|
||||
var scissorHeight = Std.int(__state.scissorRectangle.height);
|
||||
#if !openfl_dpi_aware
|
||||
if (__backBufferWantsBestResolution)
|
||||
{
|
||||
scissorX = Std.int(__state.scissorRectangle.x * __stage.window.scale);
|
||||
scissorY = Std.int(__state.scissorRectangle.y * __stage.window.scale);
|
||||
scissorWidth = Std.int(__state.scissorRectangle.width * __stage.window.scale);
|
||||
scissorHeight = Std.int(__state.scissorRectangle.height * __stage.window.scale);
|
||||
}
|
||||
#end
|
||||
|
||||
if (__state.renderToTexture == null && __stage3D == null)
|
||||
{
|
||||
var contextHeight = Std.int(__stage.window.height * __stage.window.scale);
|
||||
scissorY = contextHeight - Std.int(__state.scissorRectangle.height) - scissorY;
|
||||
scissorY = contextHeight - scissorHeight - scissorY;
|
||||
}
|
||||
|
||||
if (#if openfl_disable_context_cache true #else __contextState.scissorRectangle.x != scissorX
|
||||
@@ -2312,7 +2349,7 @@ import lime.math.Vector2;
|
||||
{
|
||||
// if (#if openfl_disable_context_cache true #else texture != __contextState.textures[i] #end) {
|
||||
|
||||
// BASE-TODO: Cleaner approach?
|
||||
// TODO: Cleaner approach?
|
||||
if (texture.__textureTarget == gl.TEXTURE_2D)
|
||||
{
|
||||
__bindGLTexture2D(texture.__getTexture());
|
||||
@@ -2323,7 +2360,7 @@ import lime.math.Vector2;
|
||||
}
|
||||
|
||||
#if (desktop && !html5)
|
||||
// BASE-TODO: Cache?
|
||||
// TODO: Cache?
|
||||
gl.enable(gl.TEXTURE_2D);
|
||||
#end
|
||||
|
||||
@@ -2357,7 +2394,7 @@ import lime.math.Vector2;
|
||||
gl.uniform1i(__state.program.__agalAlphaSamplerEnabled[sampler].location, 1);
|
||||
|
||||
#if (desktop && !html5)
|
||||
// BASE-TODO: Cache?
|
||||
// TODO: Cache?
|
||||
gl.enable(gl.TEXTURE_2D);
|
||||
#end
|
||||
}
|
||||
@@ -2377,15 +2414,24 @@ import lime.math.Vector2;
|
||||
|
||||
@:noCompletion private function __flushGLViewport():Void
|
||||
{
|
||||
// BASE-TODO: Cache
|
||||
// TODO: Cache
|
||||
|
||||
if (__state.renderToTexture == null)
|
||||
{
|
||||
if (__stage.context3D == this)
|
||||
{
|
||||
var scaledBackBufferWidth = backBufferWidth;
|
||||
var scaledBackBufferHeight = backBufferHeight;
|
||||
#if !openfl_dpi_aware
|
||||
if (__stage3D == null && !__backBufferWantsBestResolution)
|
||||
{
|
||||
scaledBackBufferWidth = Std.int(backBufferWidth * __stage.window.scale);
|
||||
scaledBackBufferHeight = Std.int(backBufferHeight * __stage.window.scale);
|
||||
}
|
||||
#end
|
||||
var x = __stage3D == null ? 0 : Std.int(__stage3D.x);
|
||||
var y = Std.int((__stage.window.height * __stage.window.scale) - backBufferHeight - (__stage3D == null ? 0 : __stage3D.y));
|
||||
gl.viewport(x, y, backBufferWidth, backBufferHeight);
|
||||
var y = Std.int((__stage.window.height * __stage.window.scale) - scaledBackBufferHeight - (__stage3D == null ? 0 : __stage3D.y));
|
||||
gl.viewport(x, y, scaledBackBufferWidth, scaledBackBufferHeight);
|
||||
}
|
||||
else
|
||||
{
|
||||
@@ -2396,7 +2442,7 @@ import lime.math.Vector2;
|
||||
{
|
||||
var width = 0, height = 0;
|
||||
|
||||
// BASE-TODO: Avoid use of Std.is
|
||||
// TODO: Avoid use of Std.is
|
||||
if ((__state.renderToTexture is Texture))
|
||||
{
|
||||
var texture2D:Texture = cast __state.renderToTexture;
|
||||
@@ -2460,7 +2506,7 @@ import lime.math.Vector2;
|
||||
case GREATER: gl.GREATER;
|
||||
case GREATER_EQUAL: gl.GEQUAL;
|
||||
case LESS: gl.LESS;
|
||||
case LESS_EQUAL: gl.LEQUAL; // BASE-TODO : wrong value
|
||||
case LESS_EQUAL: gl.LEQUAL; // TODO : wrong value
|
||||
case NEVER: gl.NEVER;
|
||||
case NOT_EQUAL: gl.NOTEQUAL;
|
||||
default: gl.EQUAL;
|
||||
@@ -2655,7 +2701,7 @@ import lime.math.Vector2;
|
||||
{
|
||||
if (__glMemoryCurrentAvailable != -1)
|
||||
{
|
||||
// BASE-TODO: Return amount used by this application only
|
||||
// TODO: Return amount used by this application only
|
||||
var current = gl.getParameter(__glMemoryCurrentAvailable);
|
||||
var total = gl.getParameter(__glMemoryTotalAvailable);
|
||||
|
||||
|
||||
@@ -636,10 +636,12 @@ class Sound extends EventDispatcher
|
||||
return null;
|
||||
}
|
||||
|
||||
#if !macro
|
||||
if (changeID < funkin.backend.system.Main.changeID) {
|
||||
changeID = funkin.backend.system.Main.changeID;
|
||||
regen();
|
||||
}
|
||||
#end
|
||||
|
||||
if (sndTransform == null)
|
||||
{
|
||||
|
||||
@@ -1,8 +1,10 @@
|
||||
package openfl.utils;
|
||||
|
||||
#if !macro
|
||||
import funkin.backend.system.Main;
|
||||
import funkin.options.Options;
|
||||
import funkin.backend.system.OptimizedBitmapData;
|
||||
#end
|
||||
import openfl.utils._internal.Log;
|
||||
import openfl.display.BitmapData;
|
||||
import openfl.display.MovieClip;
|
||||
@@ -113,10 +115,10 @@ class Assets
|
||||
var bitmapData = image.src;
|
||||
#else
|
||||
var bitmapData:BitmapData = null;
|
||||
if (pushToGPU && !Main.forceGPUOnlyBitmapsOff && Options.gpuOnlyBitmaps) {
|
||||
#if !macro if (pushToGPU && !Main.forceGPUOnlyBitmapsOff && Options.gpuOnlyBitmaps) {
|
||||
bitmapData = new OptimizedBitmapData(0, 0, true, 0);
|
||||
bitmapData.__fromImage(image);
|
||||
} else {
|
||||
} else #end {
|
||||
bitmapData = BitmapData.fromImage(image);
|
||||
}
|
||||
#end
|
||||
@@ -497,10 +499,10 @@ class Assets
|
||||
var bitmapData = image.src;
|
||||
#else
|
||||
var bitmapData:BitmapData = null;
|
||||
if (!Main.forceGPUOnlyBitmapsOff && Options.gpuOnlyBitmaps) {
|
||||
#if !macro if (!Main.forceGPUOnlyBitmapsOff && Options.gpuOnlyBitmaps) {
|
||||
bitmapData = new OptimizedBitmapData(0, 0, true, 0);
|
||||
bitmapData.__fromImage(image);
|
||||
} else {
|
||||
} else #end {
|
||||
bitmapData = BitmapData.fromImage(image);
|
||||
}
|
||||
#end
|
||||
|
||||
Reference in New Issue
Block a user