Display Draw.h 4.3 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162
  1. /******************************************************************************
  2. 'DisplayDraw' contains all the basic 2D drawing options.
  3. /******************************************************************************/
  4. struct DisplayDraw // Display Drawing Functions, this class methods can be called by the use of 'D' display object
  5. {
  6. // draw dot
  7. static void dot (C Color &color, C Vec2 &v, Flt radius=0.007f) {v .draw (color, radius);}
  8. static void dot (C Color &color, Flt x, Flt y, Flt radius=0.007f) {Vec2(x, y).draw (color, radius);}
  9. static void dot (C Color &color, C Vec &v, Flt radius=0.007f) {v .draw (color, radius);}
  10. static void dotP(C Color &color, C Vec &v, Flt radius=0.007f) {v .drawP(color, radius);} // with perspective size depending on distance to camera
  11. // draw line
  12. static void line(C Color &color, C Edge2 &edge ) {edge .draw(color);}
  13. static void line(C Color &color, C Vec2 &a, C Vec2 &b ) {Edge2(a , b ).draw(color);}
  14. static void line(C Color &color, Flt x0, Flt y0, Flt x1, Flt y1) {Edge2(x0, y0, x1, y1).draw(color);}
  15. static void line(C Color &color, C Edge &edge ) {edge .draw(color);}
  16. static void line(C Color &color, C Vec &a, C Vec &b ) {Edge(a , b ).draw(color);}
  17. static void lineX(C Color &color, Flt y, Flt x0, Flt x1 ); // draw horizontal line
  18. static void lineY(C Color &color, Flt x, Flt y0, Flt y1 ); // draw vertical line
  19. static void lines(C Color &color, C Vec2 *point, Int points); // draw continuous lines, 'point'=point array, 'points'=number of points
  20. // draw text
  21. static void text(C TextStyleParams &ts, Flt x, Flt y, CChar *t); // draw using custom text style
  22. static void text(C TextStyleParams &ts, Flt x, Flt y, CChar8 *t); // draw using custom text style
  23. static void text( Flt x, Flt y, CChar *t); // draw using default text style
  24. static void text( Flt x, Flt y, CChar8 *t); // draw using default text style
  25. static void text(C TextStyleParams &ts, C Vec2 &p , CChar *t) {text(ts, p.x, p.y, t);}
  26. static void text(C TextStyleParams &ts, C Vec2 &p , CChar8 *t) {text(ts, p.x, p.y, t);}
  27. static void text( C Vec2 &p , CChar *t) {text( p.x, p.y, t);}
  28. static void text( C Vec2 &p , CChar8 *t) {text( p.x, p.y, t);}
  29. // draw text in rectangle area
  30. static void text(C TextStyleParams &ts, C Rect &rect, CChar *t, AUTO_LINE_MODE auto_line=AUTO_LINE_NONE);
  31. static void text(C TextStyleParams &ts, C Rect &rect, CChar8 *t, AUTO_LINE_MODE auto_line=AUTO_LINE_NONE);
  32. static void text( C Rect &rect, CChar *t, AUTO_LINE_MODE auto_line=AUTO_LINE_NONE);
  33. static void text( C Rect &rect, CChar8 *t, AUTO_LINE_MODE auto_line=AUTO_LINE_NONE);
  34. // set text depth
  35. static void textDepth(Bool use, Flt depth=0); // this function can be optionally called before drawing text, to specify depth of the text (Z value for the Depth Buffer), if enabled then the text will be drawn with depth buffer test enabled and will be occluded by objects with depth smaller than 'depth'
  36. // draw shadow
  37. static void drawShadowBorders(Byte alpha, C Rect &rect, Flt shadow_radius=0.05f);
  38. static void drawShadow (Byte alpha, C Rect &rect, Flt shadow_radius=0.05f);
  39. // backbuffer effects
  40. static void fxBegin(); // begin drawing to secondary render target, this can be called only outside of Render function, after calling this function a secondary render target will be set, it will not be initialized to any color, therefore you may want to clear it using 'D.clearCol'
  41. static ImageRTPtr fxEnd (); // end drawing to secondary render target and restore the main render target, helper render target is returned which can be used as Image for drawing, including the use of custom shaders
  42. #if !EE_PRIVATE
  43. private:
  44. #endif
  45. Bool _text_depth;
  46. DisplayDraw();
  47. };
  48. /******************************************************************************/
  49. void DrawKeyboardCursor (C Vec2 &pos, Flt height);
  50. void DrawKeyboardCursorOverwrite(C Vec2 &pos, Flt height, C TextStyleParams &text_style, Char chr);
  51. /******************************************************************************/