More stuff done at Project Ultra
- Added renderspace - Revision System (to not always update pRenderspace - added some test scene
This commit is contained in:
+38
-2
@@ -2,9 +2,9 @@
|
||||
|
||||
namespace PD {
|
||||
namespace Ultra {
|
||||
PD_API Canvas::Canvas() {}
|
||||
PD_API Canvas::Canvas() { pRev = 0; }
|
||||
|
||||
PD_API Canvas::Canvas(const PD::fvec2& size) : pViewport(size) {}
|
||||
PD_API Canvas::Canvas(const PD::fvec2& size) : pViewport(size) { pRev = 0; }
|
||||
|
||||
PD_API Canvas::~Canvas() {}
|
||||
|
||||
@@ -15,9 +15,11 @@ PD_API void Canvas::SetVirtualViewport(const PD::fvec2& size) {
|
||||
pViewport.y / pVirtualViewPort.y);
|
||||
pVoff = (pViewport - (pVirtualViewPort * pVfactor)) * 0.5f;
|
||||
}
|
||||
pRev++;
|
||||
}
|
||||
|
||||
PD_API void Canvas::SetViewport(const PD::fvec2& size) {
|
||||
if (pViewport == size) return;
|
||||
pViewport = size;
|
||||
SetVirtualViewport(pVirtualViewPort); // recalculate Vfactor
|
||||
}
|
||||
@@ -55,6 +57,8 @@ PD_API PD::Li::Rect Canvas::VTranslateObject(const PD::fvec2& pos,
|
||||
final.x = pos.x * pVfactor;
|
||||
} else if (align & UltraAlignment_Right) {
|
||||
final.x = pViewport.x - (pos.x * pVfactor) - nsize.x;
|
||||
} else if (align & UltraAlignment_CenterHorizontal) {
|
||||
final.x = pViewport.x * 0.5 - nsize.x * 0.5 + pos.x * pVfactor;
|
||||
} else {
|
||||
final.x = pVoff.x + (pos.x * pVfactor) - nsize.x * 0.5;
|
||||
}
|
||||
@@ -62,17 +66,49 @@ PD_API PD::Li::Rect Canvas::VTranslateObject(const PD::fvec2& pos,
|
||||
final.y = pos.y * pVfactor;
|
||||
} else if (align & UltraAlignment_Bot) {
|
||||
final.y = pViewport.y - (pos.y * pVfactor) - nsize.y;
|
||||
} else if (align & UltraAlignment_CenterVertical) {
|
||||
final.y = pViewport.y * 0.5 - nsize.y * 0.5 + pos.y * pVfactor;
|
||||
} else {
|
||||
final.y = pVoff.y + (pos.y * pVfactor) - nsize.y * 0.5;
|
||||
}
|
||||
return PD::fvec4(final, final + nsize);
|
||||
}
|
||||
|
||||
PD_API PD::Li::Rect Canvas::TranslateObject(const PD::fvec2& pos,
|
||||
const PD::fvec2& size,
|
||||
UltraAlignment align,
|
||||
bool size_modified) const {
|
||||
PD::fvec2 nsize = size;
|
||||
if (!size_modified) nsize *= pViewport;
|
||||
PD::fvec2 final;
|
||||
if (align & UltraAlignment_Left) {
|
||||
final.x = pos.x * pViewport.x;
|
||||
} else if (align & UltraAlignment_Right) {
|
||||
final.x = pViewport.x - (pos.x * pViewport.x) - nsize.x;
|
||||
} else if (align & UltraAlignment_CenterHorizontal) {
|
||||
final.x = pViewport.x * 0.5 - nsize.x * 0.5 + pos.x * pViewport.x;
|
||||
} else {
|
||||
final.x = pVoff.x + (pos.x * pViewport.x) - nsize.x * 0.5;
|
||||
}
|
||||
if (align & UltraAlignment_Top) {
|
||||
final.y = pos.y * pViewport.y;
|
||||
} else if (align & UltraAlignment_Bot) {
|
||||
final.y = pViewport.y - (pos.y * pViewport.y) - nsize.y;
|
||||
} else if (align & UltraAlignment_CenterVertical) {
|
||||
final.y = pViewport.y * 0.5 - nsize.y * 0.5 + pos.y * pViewport.y;
|
||||
} else {
|
||||
final.y = pVoff.y + (pos.y * pViewport.y) - nsize.y * 0.5;
|
||||
}
|
||||
return PD::fvec4(final, final + nsize);
|
||||
}
|
||||
|
||||
PD_API PD::fvec2 Canvas::VTranslateAlignPos(const PD::fvec2& pos,
|
||||
const PD::fvec2& size,
|
||||
UltraAlignment align) const {
|
||||
return VTranslateObject(pos, size, align).TopLeft();
|
||||
}
|
||||
|
||||
PD_API const PD::u32& Canvas::GetRevision() const { return pRev; }
|
||||
|
||||
} // namespace Ultra
|
||||
} // namespace PD
|
||||
Reference in New Issue
Block a user