Graphics.h 2.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990
  1. #ifndef INCLUDE_GRAPHICS_H
  2. #define INCLUDE_GRAPHICS_H
  3. /*
  4. * Graphics.h
  5. * Graphics backend abstraction
  6. */
  7. #include <cstdint>
  8. #include "render/Pixel.h"
  9. #include "utility/Rect.h"
  10. #include "Texture.h"
  11. namespace WalrusRPG
  12. {
  13. namespace Graphics
  14. {
  15. void init();
  16. void deinit();
  17. /*
  18. * Allows doing stuff before drawing, the GC requires this,
  19. * and it's a nice to have
  20. */
  21. void frame_begin();
  22. /*
  23. * Signal the graphics system that we're done drawing so that
  24. * the frame can be pushed to the screen
  25. */
  26. void frame_end();
  27. /*
  28. * Draws a sprite with clipping given as window.
  29. */
  30. void put_sprite(const WalrusRPG::Graphics::Texture &sheet, int x, int y,
  31. const WalrusRPG::Utils::Rect &window);
  32. void put_sprite_clipping(const Texture &sheet, int x, int y,
  33. const WalrusRPG::Utils::Rect &sprite_window,
  34. const WalrusRPG::Utils::Rect &clipping_window);
  35. /*
  36. * Draws a sprite with clipping given as window and color
  37. * tinting.
  38. */
  39. void put_sprite_tint(const Texture &sheet, int x, int y,
  40. const WalrusRPG::Utils::Rect &window,
  41. const WalrusRPG::Graphics::Pixel &color);
  42. /*
  43. * Fill the screen with a color
  44. */
  45. void fill(const WalrusRPG::Graphics::Pixel &color);
  46. /*
  47. * Draws a pixel on the screen.
  48. */
  49. void put_pixel(uint16_t x, uint16_t y, const WalrusRPG::Graphics::Pixel &color);
  50. // Primitives drawing
  51. /*
  52. * Draws an horizontal line on the screen.
  53. */
  54. void put_horizontal_line(uint16_t x, uint16_t x2, uint16_t y,
  55. const WalrusRPG::Graphics::Pixel &color);
  56. /*
  57. * Draws an vertical line on the screen.
  58. */
  59. void put_vertical_line(uint16_t x, uint16_t y, uint16_t y2,
  60. const WalrusRPG::Graphics::Pixel &color);
  61. /*
  62. * Draws a line on the screen. As it uses Bresenham's algorithm, it won't be the
  63. * most optimized way
  64. * to draw vertical or horizontal lines.
  65. */
  66. void put_line(uint16_t x, uint16_t y, uint16_t x2, uint16_t y2,
  67. const WalrusRPG::Graphics::Pixel &color);
  68. /*
  69. * Draws a filled rectangle on the screen.
  70. */
  71. void put_rectangle(const WalrusRPG::Utils::Rect &rect,
  72. const WalrusRPG::Graphics::Pixel &color);
  73. }
  74. }
  75. #endif