deltaluca

Untitled

Apr 10th, 2013
38
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Haxe 1.36 KB | None | 0 0
  1. abstract IntBuffer(IntBufferImpl) to ArrayBuffer {
  2.     public function new(raw:BytesData) this = new IntBufferImpl(raw);
  3.     @:arrayAccess public inline function get(i:Int):Float
  4.         return untyped __global__.__hxcpp_memory_get_i32(this.buffer, i*4);
  5.     @:arrayAccess public inline function set(i:Int, x:Int):Float {
  6.         untyped __global__.__hxcpp_memory_set_i32(this.buffer, i*4, x);
  7.         return get(this, i);
  8.     }
  9. }
  10. class IntBufferImpl extends ArrayBuffer {
  11.     public function new(buffer:BytesData) super(buffer, 4, GL.INT);
  12. }
  13.  
  14. abstract FloatBuffer(FloatBufferImpl) to ArrayBuffer {
  15.     public function new(raw:BytesData) this = new FloatBufferImpl(raw);
  16.     @:arrayAccess public inline function get(i:Int):Float
  17.         return untyped __global__.__hxcpp_memory_get_float(this.buffer, i*4);
  18.     @:arrayAccess public inline function set<T>(i:Int, x:T):Float {
  19.         untyped __global__.__hxcpp_memory_set_float(this.buffer, i*4, x);
  20.         return get(this, i);
  21.     }
  22. }
  23. class FloatBufferImpl extends ArrayBuffer {
  24.     public function new(buffer:BytesData) super(buffer, 4, GL.FLOAT);
  25. }
  26.  
  27. class ArrayBuffer {
  28.     public var size:Int;
  29.     public var type:Int;
  30.     public var buffer:BytesData;
  31.     public function new(buffer:BytesData, size:Int, type:Int) {
  32.         this.buffer = buffer;
  33.         this.size = size;
  34.         this.type = type;
  35.     }
  36. }
Advertisement
Add Comment
Please, Sign In to add comment