Plane2D.hx 1021 B

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556
  1. package h3d.prim;
  2. class Plane2D extends Primitive {
  3. public function new() {
  4. }
  5. override function triCount() {
  6. return 2;
  7. }
  8. override function vertexCount() {
  9. return 4;
  10. }
  11. override function alloc( engine : h3d.Engine ) {
  12. var v = new hxd.FloatBuffer();
  13. v.push( -1);
  14. v.push( -1);
  15. v.push( 0);
  16. v.push( 1 );
  17. v.push( -1);
  18. v.push( 1);
  19. v.push( 0);
  20. v.push( 0);
  21. v.push( 1);
  22. v.push( -1);
  23. v.push( 1);
  24. v.push( 1);
  25. v.push( 1);
  26. v.push( 1);
  27. v.push( 1);
  28. v.push( 0);
  29. buffer = h3d.Buffer.ofFloats(v, hxd.BufferFormat.XY_UV);
  30. }
  31. override function render(engine:h3d.Engine) {
  32. if( buffer == null || buffer.isDisposed() ) alloc(engine);
  33. engine.renderQuadBuffer(buffer);
  34. }
  35. public static function get() {
  36. var engine = h3d.Engine.getCurrent();
  37. var inst = @:privateAccess engine.resCache.get(Plane2D);
  38. if( inst == null ) {
  39. inst = new Plane2D();
  40. @:privateAccess engine.resCache.set(Plane2D, inst);
  41. }
  42. return inst;
  43. }
  44. }