shader test project
This commit is contained in:
4
shader-test/source/AssetPaths.hx
Normal file
4
shader-test/source/AssetPaths.hx
Normal file
@@ -0,0 +1,4 @@
|
||||
package;
|
||||
|
||||
@:build(flixel.system.FlxAssets.buildFileReferences("assets", true))
|
||||
class AssetPaths {}
|
19
shader-test/source/CShader.hx
Normal file
19
shader-test/source/CShader.hx
Normal file
@@ -0,0 +1,19 @@
|
||||
import flixel.system.FlxAssets.FlxShader;
|
||||
|
||||
class CShader extends FlxShader {
|
||||
@:glFragmentSource('
|
||||
#pragma header
|
||||
|
||||
void main()
|
||||
{
|
||||
vec4 color = flixel_texture2D(bitmap, openfl_TextureCoordv);
|
||||
gl_FragColor = vec4((1.0 - color.r) * color.a, (1.0 - color.g) * color.a, (1.0 - color.b) * color.a, color.a);
|
||||
}'
|
||||
)
|
||||
|
||||
|
||||
|
||||
public function new() {
|
||||
super();
|
||||
}
|
||||
}
|
13
shader-test/source/Main.hx
Normal file
13
shader-test/source/Main.hx
Normal file
@@ -0,0 +1,13 @@
|
||||
package;
|
||||
|
||||
import flixel.FlxGame;
|
||||
import openfl.display.Sprite;
|
||||
|
||||
class Main extends Sprite
|
||||
{
|
||||
public function new()
|
||||
{
|
||||
super();
|
||||
addChild(new FlxGame(0, 0, PlayState));
|
||||
}
|
||||
}
|
20
shader-test/source/PlayState.kiss
Normal file
20
shader-test/source/PlayState.kiss
Normal file
@@ -0,0 +1,20 @@
|
||||
(import flixel.FlxState)
|
||||
(import flixel.FlxG)
|
||||
(import flixel.FlxSprite)
|
||||
(import openfl.filters.BitmapFilter)
|
||||
(import openfl.filters.ShaderFilter)
|
||||
|
||||
(extends FlxState)
|
||||
|
||||
(method &override :Void create []
|
||||
(super.create)
|
||||
(let [bg (new FlxSprite 0 0 "assets/images/apTestRoomEdited.jpg")]
|
||||
(bg.setGraphicSize FlxG.width FlxG.height)
|
||||
(bg.screenCenter)
|
||||
(add bg))
|
||||
(let [:BitmapFilter filter (new ShaderFilter (new CShader))
|
||||
:Array<BitmapFilter> filters [filter]]
|
||||
(FlxG.camera.setFilters filters)))
|
||||
|
||||
(method &override :Void update [:Float elapsed]
|
||||
(super.update elapsed))
|
Reference in New Issue
Block a user