Graphics.cpp 1.0 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950
  1. #include "Graphics.h"
  2. #include "CXfb.h"
  3. #include "stdio.h"
  4. #define GRAPHICS WalrusRPG::Graphics
  5. using namespace Nspire;
  6. void GRAPHICS::init()
  7. {
  8. CXfb::buffer_allocate();
  9. }
  10. void GRAPHICS::deinit()
  11. {
  12. CXfb::buffer_free();
  13. }
  14. void GRAPHICS::frame_begin()
  15. {
  16. }
  17. void GRAPHICS::frame_end()
  18. {
  19. CXfb::buffer_swap_render();
  20. }
  21. void GRAPHICS::put_sprite(const Texture &sheet, int x, int y,
  22. const WalrusRPG::Utils::Rect &window)
  23. {
  24. CXfb::draw_sprite_sheet(sheet.data, x, y, window);
  25. }
  26. void GRAPHICS::put_sprite_tint(const Texture &sheet, int x, int y,
  27. const WalrusRPG::Utils::Rect &window,
  28. const WalrusRPG::Graphics::Pixel &color)
  29. {
  30. CXfb::draw_sprite_sheet_tint(sheet.data, x, y, window, color.value);
  31. }
  32. void GRAPHICS::fill(const WalrusRPG::Graphics::Pixel &color)
  33. {
  34. CXfb::buffer_fill(color);
  35. }
  36. void GRAPHICS::put_pixel(uint16_t x, uint16_t y, const WalrusRPG::Graphics::Pixel &color)
  37. {
  38. CXfb::draw_pixel(x, y, color.value);
  39. }