| 1 | #pragma once |
| 2 | |
| 3 | #include "gfx/seadColor.h" |
| 4 | #include "math/seadBoundBox.h" |
| 5 | #include "math/seadVector.h" |
| 6 | #include "prim/seadRuntimeTypeInfo.h" |
| 7 | |
| 8 | namespace sead |
| 9 | { |
| 10 | class DrawContext; |
| 11 | class DisplayBuffer; |
| 12 | |
| 13 | class LogicalFrameBuffer |
| 14 | { |
| 15 | SEAD_RTTI_BASE(LogicalFrameBuffer) |
| 16 | |
| 17 | public: |
| 18 | LogicalFrameBuffer(const Vector2f& virtual_size, const BoundBox2f& physical_area) |
| 19 | : mVirtualSize(virtual_size), mPhysicalArea(physical_area) |
| 20 | { |
| 21 | } |
| 22 | LogicalFrameBuffer(const Vector2f& virtual_size, f32 physical_x, f32 physical_y, f32 physical_w, |
| 23 | f32 physical_h) |
| 24 | : mVirtualSize(virtual_size), |
| 25 | mPhysicalArea(physical_x, physical_y, physical_x + physical_w, physical_y + physical_h) |
| 26 | { |
| 27 | } |
| 28 | LogicalFrameBuffer(const Vector2f& virtual_size, f32 physical_x, f32 physical_y, u32 physical_w, |
| 29 | u32 physical_h) |
| 30 | : mVirtualSize(virtual_size), |
| 31 | mPhysicalArea(physical_x, physical_y, physical_x + physical_w, physical_y + physical_h) |
| 32 | { |
| 33 | } |
| 34 | virtual ~LogicalFrameBuffer(); |
| 35 | |
| 36 | const Vector2f& getVirtualSize() const { return mVirtualSize; } |
| 37 | const BoundBox2f& getPhysicalArea() const { return mPhysicalArea; } |
| 38 | void setVirtualSize(const Vector2f& virtual_size) { mVirtualSize = virtual_size; } |
| 39 | void setPhysicalArea(const BoundBox2f& ph_size) |
| 40 | { |
| 41 | mPhysicalArea.set(min: ph_size.getMin(), max: ph_size.getMax()); |
| 42 | } |
| 43 | void setPhysicalArea(f32 x, f32 y, f32 w, f32 h) { mPhysicalArea.set(x0: x, y0: y, x1: x + w, y1: y + h); } |
| 44 | void setPhysicalArea(f32 x, f32 y, u32 w, u32 h) { mPhysicalArea.set(x0: x, y0: y, x1: x + w, y1: y + h); } |
| 45 | |
| 46 | private: |
| 47 | Vector2f mVirtualSize; |
| 48 | BoundBox2f mPhysicalArea; |
| 49 | }; |
| 50 | |
| 51 | class FrameBuffer : public LogicalFrameBuffer |
| 52 | { |
| 53 | SEAD_RTTI_OVERRIDE(FrameBuffer, LogicalFrameBuffer) |
| 54 | public: |
| 55 | FrameBuffer(const Vector2f& virtual_size, const BoundBox2f& physical_area) |
| 56 | : LogicalFrameBuffer(virtual_size, physical_area) |
| 57 | { |
| 58 | } |
| 59 | |
| 60 | FrameBuffer(const Vector2f& virtual_size, f32 physical_x, f32 physical_y, f32 physical_w, |
| 61 | f32 physical_h) |
| 62 | : LogicalFrameBuffer(virtual_size, physical_x, physical_y, physical_w, physical_h) |
| 63 | { |
| 64 | } |
| 65 | |
| 66 | FrameBuffer(const Vector2f& virtual_size, f32 physical_x, f32 physical_y, u32 physical_w, |
| 67 | u32 physical_h) |
| 68 | : LogicalFrameBuffer(virtual_size, physical_x, physical_y, physical_w, physical_h) |
| 69 | { |
| 70 | } |
| 71 | ~FrameBuffer() override; |
| 72 | |
| 73 | virtual void copyToDisplayBuffer(DrawContext* draw_context, |
| 74 | const DisplayBuffer* display_buffer) const; |
| 75 | virtual void clear(DrawContext* draw_context, u32 clr_flag, const Color4f& color, f32 depth, |
| 76 | u32 stencil) const = 0; |
| 77 | virtual void clearMRT(DrawContext* draw_context, u32 target, const Color4f& color) const; |
| 78 | virtual void bindImpl_(DrawContext* draw_context) const = 0; |
| 79 | |
| 80 | void bind(DrawContext* draw_context) const; |
| 81 | }; |
| 82 | |
| 83 | } // namespace sead |
| 84 | |