diff options
| author | SuperDude88 <82904174+SuperDude88@users.noreply.github.com> | 2023-09-10 18:35:46 -0400 |
|---|---|---|
| committer | SuperDude88 <82904174+SuperDude88@users.noreply.github.com> | 2023-09-10 18:35:46 -0400 |
| commit | 37e0ee5732d6c3b090f3c59038633a2e4c1de1f4 (patch) | |
| tree | 5738b634be1fbf71098125f6ec310497c8977572 /include/JSystem/J2DGraph | |
| parent | ef45f47306641870607b73c29faf9f92a84eb62e (diff) | |
JFramework
Match most of JFramework
Diffstat (limited to 'include/JSystem/J2DGraph')
| -rw-r--r-- | include/JSystem/J2DGraph/J2DGrafContext.h | 61 | ||||
| -rw-r--r-- | include/JSystem/J2DGraph/J2DOrthoGraph.h | 39 |
2 files changed, 100 insertions, 0 deletions
diff --git a/include/JSystem/J2DGraph/J2DGrafContext.h b/include/JSystem/J2DGraph/J2DGrafContext.h new file mode 100644 index 00000000..1d41b509 --- /dev/null +++ b/include/JSystem/J2DGraph/J2DGrafContext.h @@ -0,0 +1,61 @@ +#ifndef J2DGRAFCONTEXT_H +#define J2DGRAFCONTEXT_H + +#include "JSystem/JGeometry.h" +#include "JSystem/JUtility/TColor.h" +#include "dolphin/mtx/mtx.h" +#include "dolphin/types.h" + +class J2DGrafContext { +public: + struct Blend { + /* 0x0 */ u8 mType; + /* 0x1 */ u8 mSrcFactor; + /* 0x2 */ u8 mDstFactor; + }; + + + /* 802E8B08 */ J2DGrafContext(f32 x, f32 y, f32 width, f32 height); + /* 802E90C0 */ void scissor(JGeometry::TBox2<f32> const& bounds); + void setColor(JUtility::TColor c) { this->setColor(c, c, c, c); } + /* 802E9118 */ void setColor(JUtility::TColor colorTL, JUtility::TColor colorTR, + JUtility::TColor colorBR, JUtility::TColor colorBL); + /* 802E9234 */ void setLineWidth(u8); + /* 802E9260 */ void fillBox(JGeometry::TBox2<f32> const& box); + /* 802E9368 */ void drawFrame(JGeometry::TBox2<f32> const& box); + /* 802E9488 */ void line(JGeometry::TVec2<f32> start, JGeometry::TVec2<f32> end); + /* 802E9564 */ void lineTo(JGeometry::TVec2<f32> pos); + void lineTo(f32 x, f32 y) { this->lineTo(JGeometry::TVec2<f32>(x, y)); } + void moveTo(f32 x, f32 y) { this->moveTo(JGeometry::TVec2<f32>(x, y)); } + + void moveTo(JGeometry::TVec2<f32> pos) { mPrevPos = pos; } + + /* 802E95D4 */ virtual ~J2DGrafContext() {} + /* 802E90E4 */ virtual void place(JGeometry::TBox2<f32> const& bounds); + /* 802E961C */ virtual void place(f32 x, f32 y, f32 width, f32 height) { + JGeometry::TBox2<f32> box(x, y, x + width, y + height); + this->place(box); + } + /* 802E8BB4 */ virtual void setPort(); + /* 802E8C44 */ virtual void setup2D(); + /* 802E8E20 */ virtual void setScissor(); + /* 802E9664 */ virtual s32 getGrafType() const { return 0; } + /* 802E966C */ virtual void setLookat() {} + +public: + /* 0x04 */ JGeometry::TBox2<f32> mBounds; + /* 0x14 */ JGeometry::TBox2<f32> mScissorBounds; + /* 0x24 */ JUtility::TColor mColorTL; + /* 0x28 */ JUtility::TColor mColorTR; + /* 0x2C */ JUtility::TColor mColorBR; + /* 0x30 */ JUtility::TColor mColorBL; + /* 0x34 */ u8 mLineWidth; + /* 0x38 */ JGeometry::TVec2<f32> mPrevPos; + /* 0x40 */ Mtx44 mMtx44; + /* 0x80 */ Mtx mPosMtx; + /* 0xB0 */ Blend field_0xb0; + /* 0xB3 */ Blend mLinePart; + /* 0xB6 */ Blend mBoxPart; +}; + +#endif /* J2DGRAFCONTEXT_H */ diff --git a/include/JSystem/J2DGraph/J2DOrthoGraph.h b/include/JSystem/J2DGraph/J2DOrthoGraph.h new file mode 100644 index 00000000..bebf56ba --- /dev/null +++ b/include/JSystem/J2DGraph/J2DOrthoGraph.h @@ -0,0 +1,39 @@ +#ifndef J2DORTHOGRAPH_H +#define J2DORTHOGRAPH_H + +#include "JSystem/J2DGraph/J2DGrafContext.h" + +class J2DOrthoGraph : public J2DGrafContext { +public: + J2DOrthoGraph(); + J2DOrthoGraph(f32 x, f32 y, f32 width, f32 height, f32 far, f32 near); + void setOrtho(JGeometry::TBox2<f32> const& bounds, f32 far, f32 near); + void scissorBounds(JGeometry::TBox2<f32>*, JGeometry::TBox2<f32> const*); + + virtual ~J2DOrthoGraph() {} + virtual void setPort(); + virtual s32 getGrafType() const { return 1; } + virtual void setLookat(); + + f32 getWidthPower() const { return mBounds.getWidth() / mOrtho.getWidth(); } + f32 getHeightPower() const { return mBounds.getHeight() / mOrtho.getHeight(); } + + void setOrtho(f32 x, f32 y, f32 width, f32 height, f32 far, f32 near) { + JGeometry::TBox2<f32> ortho(x, y, x + width, y + height); + setOrtho(ortho, far, near); + } + +private: + /* 0xBC */ JGeometry::TBox2<f32> mOrtho; + /* 0xCC */ f32 mNear; + /* 0xD0 */ f32 mFar; +}; + +void J2DDrawLine(f32 x1, f32 y1, f32 x2, f32 y2, JUtility::TColor color, + int line_width); +void J2DFillBox(f32 x, f32 y, f32 width, f32 height, JUtility::TColor color); +void J2DFillBox(JGeometry::TBox2<f32> const& box, JUtility::TColor color); +void J2DDrawFrame(f32 x, f32 y, f32 width, f32 height, JUtility::TColor color, u8 line_width); +void J2DDrawFrame(JGeometry::TBox2<f32> const& box, JUtility::TColor color, u8 line_width); + +#endif /* J2DORTHOGRAPH_H */ |
