WHY_CPP  0.1
video_memory_holder.h
1 #pragma once
2 
3 #include <whycpp/color.h>
4 #include <whycpp/types.h>
5 #include <memory>
6 #include <vector>
7 #include "../i_object.h"
8 
21 class VideoMemoryHolder : public IObject {
22  public:
23  explicit VideoMemoryHolder(i32 width, i32 height);
24  ~VideoMemoryHolder() override;
25 
26  i32 GetScreenWidth() const;
27  void SetScreenWidth(i32 screen_width);
28  i32 GetScreenHeight() const;
29  void SetScreenHeight(i32 screen_height);
30  i32 GetWidth() const;
31  i32 GetHeight() const;
32  const RGBA Get(i32 x, i32 y) const;
33  void Set(i32 x, i32 y, const RGBA& color);
34  void Fill(const RGBA& color);
35  const uint8_t* GetBuffer() const;
36 
37  private:
38  i32 width;
39  i32 height;
40  i32 screen_width = 0;
41  i32 screen_height = 0;
42  std::unique_ptr<uint32_t[]> buffer;
43 
44  inline size_t CheckX(i32 x) const;
45  inline size_t CheckY(i32 y) const;
46 };
47 
Definition: color.h:11