|
@@ -14,9 +14,19 @@ private class BorderShader extends h3d.shader.ScreenShader {
|
|
|
|
|
|
class Border extends ScreenFx<BorderShader> {
|
|
|
|
|
|
+ var width(default, null) : Int;
|
|
|
+ var height(default, null) : Int;
|
|
|
+ var size(default, null) : Int;
|
|
|
+
|
|
|
public function new( width : Int, height : Int, size : Int = 1 ) {
|
|
|
super(new BorderShader());
|
|
|
+ this.width = width;
|
|
|
+ this.height = height;
|
|
|
+ this.size = height;
|
|
|
+ shader.color.set(1,1,1,1);
|
|
|
+ }
|
|
|
|
|
|
+ function createPrimitive() {
|
|
|
var bbuf = new hxd.FloatBuffer();
|
|
|
inline function add(x, y) {
|
|
|
bbuf.push((x / width) * 2 - 1);
|
|
@@ -43,12 +53,18 @@ class Border extends ScreenFx<BorderShader> {
|
|
|
add(width, height);
|
|
|
|
|
|
this.primitive = new h3d.prim.RawPrimitive({ vbuf : bbuf, format : hxd.BufferFormat.make([{ name : "position", type : DVec2 }]) }, true);
|
|
|
- shader.color.set(1,1,1,1);
|
|
|
+ }
|
|
|
+
|
|
|
+ override function render() {
|
|
|
+ if (primitive == null)
|
|
|
+ createPrimitive();
|
|
|
+ super.render();
|
|
|
}
|
|
|
|
|
|
override function dispose() {
|
|
|
+ if (primitive != null)
|
|
|
+ this.primitive.dispose();
|
|
|
super.dispose();
|
|
|
- this.primitive.dispose();
|
|
|
}
|
|
|
|
|
|
}
|