yaze 0.2.2
Link to the Past ROM Editor
 
Loading...
Searching...
No Matches
arena.h
Go to the documentation of this file.
1#ifndef YAZE_APP_GFX_ARENA_H
2#define YAZE_APP_GFX_ARENA_H
3
4#include <array>
5#include <cstdint>
6#include <memory>
7#include <unordered_map>
8
11
12namespace yaze {
13namespace gfx {
14
15// Arena is a class that manages a collection of textures and surfaces
16class Arena {
17 public:
18 static Arena& Get();
19
20 ~Arena();
21
22 SDL_Texture* AllocateTexture(SDL_Renderer* renderer, int width, int height);
23 void FreeTexture(SDL_Texture* texture);
24 void UpdateTexture(SDL_Texture* texture, SDL_Surface* surface);
25
26 SDL_Surface* AllocateSurface(int width, int height, int depth, int format);
27 void FreeSurface(SDL_Surface* surface);
28
29 std::array<gfx::Bitmap, 223>& gfx_sheets() { return gfx_sheets_; }
30 auto gfx_sheet(int i) { return gfx_sheets_[i]; }
31 auto mutable_gfx_sheet(int i) { return &gfx_sheets_[i]; }
32 auto mutable_gfx_sheets() { return &gfx_sheets_; }
33
34 auto& bg1() { return bg1_; }
35 auto& bg2() { return bg2_; }
36
37 private:
38 Arena();
39
42
43 static constexpr int kTilesPerRow = 64;
44 static constexpr int kTilesPerColumn = 64;
45 static constexpr int kTotalTiles = kTilesPerRow * kTilesPerColumn;
46
47 std::array<uint16_t, kTotalTiles> layer1_buffer_;
48 std::array<uint16_t, kTotalTiles> layer2_buffer_;
49
50 std::array<gfx::Bitmap, 223> gfx_sheets_;
51
52 std::unordered_map<SDL_Texture*,
53 std::unique_ptr<SDL_Texture, core::SDL_Texture_Deleter>>
55
56 std::unordered_map<SDL_Surface*,
57 std::unique_ptr<SDL_Surface, core::SDL_Surface_Deleter>>
59};
60
61} // namespace gfx
62} // namespace yaze
63
64#endif // YAZE_APP_GFX_ARENA_H
SDL_Texture * AllocateTexture(SDL_Renderer *renderer, int width, int height)
Definition arena.cc:25
SDL_Surface * AllocateSurface(int width, int height, int depth, int format)
Definition arena.cc:93
BackgroundBuffer bg2_
Definition arena.h:41
auto gfx_sheet(int i)
Definition arena.h:30
static constexpr int kTotalTiles
Definition arena.h:45
std::array< uint16_t, kTotalTiles > layer2_buffer_
Definition arena.h:48
static constexpr int kTilesPerColumn
Definition arena.h:44
static constexpr int kTilesPerRow
Definition arena.h:43
auto mutable_gfx_sheets()
Definition arena.h:32
std::unordered_map< SDL_Texture *, std::unique_ptr< SDL_Texture, core::SDL_Texture_Deleter > > textures_
Definition arena.h:54
std::unordered_map< SDL_Surface *, std::unique_ptr< SDL_Surface, core::SDL_Surface_Deleter > > surfaces_
Definition arena.h:58
void FreeSurface(SDL_Surface *surface)
Definition arena.cc:107
auto mutable_gfx_sheet(int i)
Definition arena.h:31
BackgroundBuffer bg1_
Definition arena.h:40
std::array< gfx::Bitmap, 223 > gfx_sheets_
Definition arena.h:50
auto & bg2()
Definition arena.h:35
std::array< gfx::Bitmap, 223 > & gfx_sheets()
Definition arena.h:29
void FreeTexture(SDL_Texture *texture)
Definition arena.cc:50
std::array< uint16_t, kTotalTiles > layer1_buffer_
Definition arena.h:47
void UpdateTexture(SDL_Texture *texture, SDL_Surface *surface)
Definition arena.cc:59
auto & bg1()
Definition arena.h:34
static Arena & Get()
Definition arena.cc:10
Contains classes for handling graphical data.
Definition arena.cc:8
Main namespace for the application.
Definition controller.cc:18