Cleaned up some code
This commit is contained in:
+2
-1
@@ -2,5 +2,6 @@ export/
|
||||
dump/
|
||||
latest/windows/obj/
|
||||
latest/windows/haxe/
|
||||
.vscode/
|
||||
.vscode/*
|
||||
!.vscode/settings.json
|
||||
.haxelib/
|
||||
Vendored
+4
@@ -0,0 +1,4 @@
|
||||
{
|
||||
"editor.detectIndentation": false,
|
||||
"editor.insertSpaces": false
|
||||
}
|
||||
@@ -40,7 +40,6 @@ class Flx3DCamera extends FlxCamera {
|
||||
super(X, Y, Width, Height, DefaultZoom);
|
||||
__cur3DStageID = __3DIDS++;
|
||||
|
||||
|
||||
view = new View3D();
|
||||
view.width = this.width;
|
||||
view.height = this.height;
|
||||
|
||||
@@ -92,7 +92,6 @@ class Highscore
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
typedef SongScore = {
|
||||
@:optional var score:Int;
|
||||
@:optional var accuracy:Float;
|
||||
|
||||
@@ -18,6 +18,10 @@ import openfl.display.ShaderParameter;
|
||||
import openfl.display.BitmapData;
|
||||
import openfl.display.ShaderInput;
|
||||
|
||||
@:access(openfl.display3D.Context3D)
|
||||
@:access(openfl.display3D.Program3D)
|
||||
@:access(openfl.display.ShaderInput)
|
||||
@:access(openfl.display.ShaderParameter)
|
||||
class FunkinShader extends FlxShader implements IHScriptCustomBehaviour {
|
||||
private static var __instanceFields = Type.getInstanceFields(FunkinShader);
|
||||
|
||||
@@ -33,13 +37,35 @@ class FunkinShader extends FlxShader implements IHScriptCustomBehaviour {
|
||||
public override function new(frag:String, vert:String, glslVer:String = "120") {
|
||||
if (frag == null) frag = ShaderTemplates.defaultFragmentSource;
|
||||
if (vert == null) vert = ShaderTemplates.defaultVertexSource;
|
||||
this.glFragmentSource = frag.replace("#pragma header", ShaderTemplates.fragHeader).replace("#pragma body", ShaderTemplates.fragBody);
|
||||
this.glVertexSource = vert.replace("#pragma header", ShaderTemplates.vertHeader).replace("#pragma body", ShaderTemplates.vertBody);
|
||||
this.glFragmentSource = frag;
|
||||
this.glVertexSource = vert;
|
||||
|
||||
this.glslVer = glslVer;
|
||||
super();
|
||||
}
|
||||
|
||||
@:noCompletion override private function set_glFragmentSource(value:String):String
|
||||
{
|
||||
value = value.replace("#pragma header", ShaderTemplates.fragHeader).replace("#pragma body", ShaderTemplates.fragBody);
|
||||
if (value != __glFragmentSource)
|
||||
{
|
||||
__glSourceDirty = true;
|
||||
}
|
||||
|
||||
return __glFragmentSource = value;
|
||||
}
|
||||
|
||||
@:noCompletion override private function set_glVertexSource(value:String):String
|
||||
{
|
||||
value = value.replace("#pragma header", ShaderTemplates.vertHeader).replace("#pragma body", ShaderTemplates.vertBody);
|
||||
if (value != __glVertexSource)
|
||||
{
|
||||
__glSourceDirty = true;
|
||||
}
|
||||
|
||||
return __glVertexSource = value;
|
||||
}
|
||||
|
||||
@:noCompletion private override function __initGL():Void
|
||||
{
|
||||
if (__glSourceDirty || __paramBool == null)
|
||||
@@ -61,7 +87,7 @@ class FunkinShader extends FlxShader implements IHScriptCustomBehaviour {
|
||||
{
|
||||
var prefix = '#version ${glslVer}\n';
|
||||
|
||||
@:privateAccess var gl = __context.gl;
|
||||
var gl = __context.gl;
|
||||
|
||||
prefix += "#ifdef GL_ES
|
||||
"
|
||||
@@ -78,82 +104,82 @@ class FunkinShader extends FlxShader implements IHScriptCustomBehaviour {
|
||||
var fragment = prefix + glFragmentSource;
|
||||
|
||||
var id = vertex + fragment;
|
||||
@:privateAccess
|
||||
|
||||
if (__context.__programs.exists(id))
|
||||
{
|
||||
@:privateAccess program = __context.__programs.get(id);
|
||||
program = __context.__programs.get(id);
|
||||
}
|
||||
else
|
||||
{
|
||||
program = __context.createProgram(GLSL);
|
||||
|
||||
@:privateAccess program.__glProgram = __createGLProgram(vertex, fragment);
|
||||
program.__glProgram = __createGLProgram(vertex, fragment);
|
||||
|
||||
@:privateAccess __context.__programs.set(id, program);
|
||||
__context.__programs.set(id, program);
|
||||
}
|
||||
|
||||
if (program != null)
|
||||
{
|
||||
@:privateAccess glProgram = program.__glProgram;
|
||||
glProgram = program.__glProgram;
|
||||
|
||||
for (input in __inputBitmapData)
|
||||
{
|
||||
@:privateAccess
|
||||
|
||||
if (input.__isUniform)
|
||||
{
|
||||
@:privateAccess input.index = gl.getUniformLocation(glProgram, input.name);
|
||||
input.index = gl.getUniformLocation(glProgram, input.name);
|
||||
}
|
||||
else
|
||||
{
|
||||
@:privateAccess input.index = gl.getAttribLocation(glProgram, input.name);
|
||||
input.index = gl.getAttribLocation(glProgram, input.name);
|
||||
}
|
||||
}
|
||||
|
||||
for (parameter in __paramBool)
|
||||
{
|
||||
@:privateAccess
|
||||
|
||||
if (parameter.__isUniform)
|
||||
{
|
||||
@:privateAccess parameter.index = gl.getUniformLocation(glProgram, parameter.name);
|
||||
parameter.index = gl.getUniformLocation(glProgram, parameter.name);
|
||||
}
|
||||
else
|
||||
{
|
||||
@:privateAccess parameter.index = gl.getAttribLocation(glProgram, parameter.name);
|
||||
parameter.index = gl.getAttribLocation(glProgram, parameter.name);
|
||||
}
|
||||
}
|
||||
|
||||
for (parameter in __paramFloat)
|
||||
{
|
||||
@:privateAccess
|
||||
|
||||
if (parameter.__isUniform)
|
||||
{
|
||||
@:privateAccess parameter.index = gl.getUniformLocation(glProgram, parameter.name);
|
||||
parameter.index = gl.getUniformLocation(glProgram, parameter.name);
|
||||
}
|
||||
else
|
||||
{
|
||||
@:privateAccess parameter.index = gl.getAttribLocation(glProgram, parameter.name);
|
||||
parameter.index = gl.getAttribLocation(glProgram, parameter.name);
|
||||
}
|
||||
}
|
||||
|
||||
for (parameter in __paramInt)
|
||||
{
|
||||
@:privateAccess
|
||||
|
||||
if (parameter.__isUniform)
|
||||
{
|
||||
@:privateAccess
|
||||
|
||||
parameter.index = gl.getUniformLocation(glProgram, parameter.name);
|
||||
}
|
||||
else
|
||||
{
|
||||
@:privateAccess
|
||||
|
||||
parameter.index = gl.getAttribLocation(glProgram, parameter.name);
|
||||
}
|
||||
}
|
||||
}
|
||||
// initInstance(vertex, fragment); // btw make sure to disable the prefixes for ._isInstance
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@:noCompletion private override function __processGLData(source:String, storageType:String):Void
|
||||
{
|
||||
var lastMatch = 0, position, regex, name, type;
|
||||
@@ -332,8 +358,6 @@ class FunkinShader extends FlxShader implements IHScriptCustomBehaviour {
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
public function hget(v:String):Dynamic {
|
||||
if (__instanceFields.contains(v) || __instanceFields.contains('get_${v}')) {
|
||||
return Reflect.getProperty(this, v);
|
||||
|
||||
@@ -107,6 +107,8 @@ class Main extends Sprite
|
||||
// addChild(new FramerateField(10, 3, 0xFFFFFF));
|
||||
addChild(new funkin.system.framerate.Framerate());
|
||||
#end
|
||||
|
||||
trace("Hello", "World");
|
||||
}
|
||||
|
||||
@:dox(hide)
|
||||
|
||||
Reference in New Issue
Block a user