CGraphics: Viewport fixes

This commit is contained in:
Phillip Stephens 2022-02-27 14:46:15 -08:00
parent fb69d3fdba
commit 44f9d6648a
Signed by: Antidote
GPG Key ID: F8BEE4C83DACA60D
30 changed files with 340 additions and 333 deletions

View File

@ -767,7 +767,7 @@ void CNESEmulator::Draw(const zeus::CColor& mulColor, bool filtering) {
if (!EmulatorInst) if (!EmulatorInst)
return; return;
float widthFac = NESAspect / g_Viewport.aspect; float widthFac = NESAspect / CGraphics::GetViewportAspect();
Uniform uniform = {zeus::CMatrix4f{}, mulColor}; Uniform uniform = {zeus::CMatrix4f{}, mulColor};
uniform.m_matrix[0][0] = widthFac; uniform.m_matrix[0][0] = widthFac;

View File

@ -821,7 +821,7 @@ void CAutoMapper::ProcessMapScreenInput(const CFinalInput& input, CStateManager&
} else { } else {
m_mouseDelta = mouseCoord - *m_lastMouseCoord; m_mouseDelta = mouseCoord - *m_lastMouseCoord;
m_lastMouseCoord.emplace(mouseCoord); m_lastMouseCoord.emplace(mouseCoord);
m_mouseDelta.x() *= g_Viewport.aspect; m_mouseDelta.x() *= CGraphics::GetViewportAspect();
m_mouseDelta *= 100.f; m_mouseDelta *= 100.f;
} }
} }
@ -902,14 +902,14 @@ std::pair<int, int> CAutoMapper::FindClosestVisibleWorld(const zeus::CVector3f&
} }
zeus::CVector2i CAutoMapper::GetMiniMapViewportSize() { zeus::CVector2i CAutoMapper::GetMiniMapViewportSize() {
float scaleX = g_Viewport.x8_width / 640.f; float scaleX = CGraphics::GetViewportWidth() / 640.f;
float scaleY = g_Viewport.xc_height / 480.f; float scaleY = CGraphics::GetViewportHeight() / 480.f;
return {int(scaleX * g_tweakAutoMapper->GetMiniMapViewportWidth()), return {int(scaleX * g_tweakAutoMapper->GetMiniMapViewportWidth()),
int(scaleY * g_tweakAutoMapper->GetMiniMapViewportHeight())}; int(scaleY * g_tweakAutoMapper->GetMiniMapViewportHeight())};
} }
zeus::CVector2i CAutoMapper::GetMapScreenViewportSize() { zeus::CVector2i CAutoMapper::GetMapScreenViewportSize() {
return {int(g_Viewport.x8_width), int(g_Viewport.xc_height)}; return {int(CGraphics::GetViewportWidth()), int(CGraphics::GetViewportHeight())};
} }
float CAutoMapper::GetMapAreaMaxDrawDepth(const CStateManager&, TAreaId aid) const { float CAutoMapper::GetMapAreaMaxDrawDepth(const CStateManager&, TAreaId aid) const {
@ -1170,7 +1170,7 @@ void CAutoMapper::Update(float dt, CStateManager& mgr) {
x320_bottomPanePos = std::max(0.f, std::min(x320_bottomPanePos, 1.f)); x320_bottomPanePos = std::max(0.f, std::min(x320_bottomPanePos, 1.f));
if (x30c_basewidget_leftPane) { if (x30c_basewidget_leftPane) {
float vpAspectRatio = std::max(1.78f, g_Viewport.aspect); float vpAspectRatio = std::max(1.78f, CGraphics::GetViewportAspect());
x30c_basewidget_leftPane->SetLocalTransform( x30c_basewidget_leftPane->SetLocalTransform(
zeus::CTransform::Translate(x318_leftPanePos * vpAspectRatio * -9.f, 0.f, 0.f) * zeus::CTransform::Translate(x318_leftPanePos * vpAspectRatio * -9.f, 0.f, 0.f) *
x30c_basewidget_leftPane->GetTransform()); x30c_basewidget_leftPane->GetTransform());

View File

@ -504,8 +504,8 @@ void CStateManager::DrawReflection(const zeus::CVector3f& reflectPoint) {
CGraphics::SetViewPointMatrix(look); CGraphics::SetViewPointMatrix(look);
const CGraphics::CProjectionState backupProj = CGraphics::GetProjectionState(); const CGraphics::CProjectionState backupProj = CGraphics::GetProjectionState();
const CGameCamera* cam = x870_cameraManager->GetCurrentCamera(*this); const CGameCamera* cam = x870_cameraManager->GetCurrentCamera(*this);
g_Renderer->SetPerspective(cam->GetFov(), g_Viewport.x8_width, g_Viewport.xc_height, cam->GetNearClipDistance(), g_Renderer->SetPerspective(cam->GetFov(), CGraphics::GetViewportWidth(), CGraphics::GetViewportHeight(),
cam->GetFarClipDistance()); cam->GetNearClipDistance(), cam->GetFarClipDistance());
x84c_player->RenderReflectedPlayer(*this); x84c_player->RenderReflectedPlayer(*this);
@ -707,18 +707,18 @@ void CStateManager::ResetViewAfterDraw(const SViewport& backupViewport,
const CGameCamera* cam = x870_cameraManager->GetCurrentCamera(*this); const CGameCamera* cam = x870_cameraManager->GetCurrentCamera(*this);
zeus::CFrustum frustum; zeus::CFrustum frustum;
frustum.updatePlanes(backupViewMatrix, zeus::SProjPersp(zeus::degToRad(cam->GetFov()), g_Viewport.aspect, frustum.updatePlanes(backupViewMatrix, zeus::SProjPersp(zeus::degToRad(cam->GetFov()), CGraphics::GetViewportAspect(),
cam->GetNearClipDistance(), cam->GetFarClipDistance())); cam->GetNearClipDistance(), cam->GetFarClipDistance()));
g_Renderer->SetClippingPlanes(frustum); g_Renderer->SetClippingPlanes(frustum);
g_Renderer->SetPerspective(cam->GetFov(), g_Viewport.x8_width, g_Viewport.xc_height, cam->GetNearClipDistance(), g_Renderer->SetPerspective(cam->GetFov(), CGraphics::GetViewportWidth(), CGraphics::GetViewportHeight(),
cam->GetFarClipDistance()); cam->GetNearClipDistance(), cam->GetFarClipDistance());
} }
void CStateManager::DrawWorld() { void CStateManager::DrawWorld() {
SCOPED_GRAPHICS_DEBUG_GROUP("CStateManager::DrawWorld", zeus::skBlue); SCOPED_GRAPHICS_DEBUG_GROUP("CStateManager::DrawWorld", zeus::skBlue);
const CTimeProvider timeProvider(xf14_curTimeMod900); const CTimeProvider timeProvider(xf14_curTimeMod900);
const SViewport backupViewport = g_Viewport; const SViewport backupViewport = CGraphics::g_Viewport;
/* Area camera is in (not necessarily player) */ /* Area camera is in (not necessarily player) */
const TAreaId visAreaId = GetVisAreaId(); const TAreaId visAreaId = GetVisAreaId();
@ -727,7 +727,7 @@ void CStateManager::DrawWorld() {
DrawWorldCubeFaces(); DrawWorldCubeFaces();
const zeus::CFrustum frustum = SetupViewForDraw(g_Viewport); const zeus::CFrustum frustum = SetupViewForDraw(CGraphics::g_Viewport);
const zeus::CTransform backupViewMatrix = CGraphics::g_ViewMatrix; const zeus::CTransform backupViewMatrix = CGraphics::g_ViewMatrix;
int areaCount = 0; int areaCount = 0;
@ -1196,7 +1196,7 @@ void CStateManager::PreRender() {
} }
SCOPED_GRAPHICS_DEBUG_GROUP("CStateManager::PreRender", zeus::skBlue); SCOPED_GRAPHICS_DEBUG_GROUP("CStateManager::PreRender", zeus::skBlue);
const zeus::CFrustum frustum = SetupDrawFrustum(g_Viewport); const zeus::CFrustum frustum = SetupDrawFrustum(CGraphics::g_Viewport);
x86c_stateManagerContainer->xf370_.clear(); x86c_stateManagerContainer->xf370_.clear();
x86c_stateManagerContainer->xf39c_renderLast.clear(); x86c_stateManagerContainer->xf39c_renderLast.clear();
xf7c_projectedShadow = nullptr; xf7c_projectedShadow = nullptr;

View File

@ -52,8 +52,6 @@ struct SViewport {
float aspect; float aspect;
}; };
extern SViewport g_Viewport;
struct SClipScreenRect { struct SClipScreenRect {
bool x0_valid = false; bool x0_valid = false;
int x4_left = 0; int x4_left = 0;
@ -262,6 +260,23 @@ public:
static void SetClearColor(const zeus::CColor& color); static void SetClearColor(const zeus::CColor& color);
static void SetCopyClear(const zeus::CColor& color, float depth); static void SetCopyClear(const zeus::CColor& color, float depth);
static void SetIsBeginSceneClearFb(bool clear); static void SetIsBeginSceneClearFb(bool clear);
static u32 GetViewportLeft() { return g_Viewport.x0_left; }
static u32 GetViewportTop() { return g_Viewport.x4_top; }
static u32 GetViewportWidth() { return g_Viewport.x8_width; }
static u32 GetViewportHeight() { return g_Viewport.xc_height; }
static float GetViewportHalfWidth() { return g_Viewport.x10_halfWidth; }
static float GetViewportHalfHeight() { return g_Viewport.x14_halfHeight; }
static float GetViewportAspect() { return g_Viewport.aspect; }
static bool IsCroppedViewportValid() { return g_CroppedViewport.x0_valid; }
static int GetCroppedViewportLeft() { return g_CroppedViewport.x4_left; }
static int GetCroppedViewportTop() { return g_CroppedViewport.x8_top; }
static int GetCroppedViewportWidth() { return g_CroppedViewport.xc_width; }
static int GetCroppedViewportHeight() { return g_CroppedViewport.x10_height; }
static float GetCroppedViewportDstWidth() { return g_CroppedViewport.x14_dstWidth; }
static float GetCroppedViewportUVXMin() { return g_CroppedViewport.x18_uvXMin; }
static float GetCroppedViewportUVXMax() { return g_CroppedViewport.x1c_uvXMax; }
static float GetCroppedViewportUVYMin() { return g_CroppedViewport.x20_uvYMin; }
static float GetCroppedViewportUVYMax() { return g_CroppedViewport.x24_uvYMax; }
// static boo::IGraphicsDataFactory::Platform g_BooPlatform; // static boo::IGraphicsDataFactory::Platform g_BooPlatform;
// static const char* g_BooPlatformName; // static const char* g_BooPlatformName;

View File

@ -244,53 +244,39 @@ enum BlendFactor : uint16_t {
BL_INVDSTALPHA BL_INVDSTALPHA
}; };
//struct Color : athena::io::DNA<athena::Endian::Big> { struct Color {
// union { union {
// uint8_t color[4]; uint8_t color[4];
// uint32_t num = 0; uint32_t num = 0;
// }; };
// Color() = default; Color() = default;
// Color& operator=(const atVec4f& vec) { Color(uint8_t r, uint8_t g, uint8_t b, uint8_t a = 255) {
// athena::simd_floats f(vec.simd); color[0] = r;
// color[0] = uint8_t(std::min(std::max(f[0] * 255.f, 0.f), 255.f)); color[1] = g;
// color[1] = uint8_t(std::min(std::max(f[1] * 255.f, 0.f), 255.f)); color[2] = b;
// color[2] = uint8_t(std::min(std::max(f[2] * 255.f, 0.f), 255.f)); color[3] = a;
// color[3] = uint8_t(std::min(std::max(f[3] * 255.f, 0.f), 255.f)); }
// return *this;
// } Color(float r, float g, float b, float a = 1.f) {
// Color& operator=(const atVec3f& vec) { color[0] = r * 255;
// athena::simd_floats f(vec.simd); color[1] = g * 255;
// color[0] = uint8_t(std::min(std::max(f[0] * 255.f, 0.f), 255.f)); color[2] = b * 255;
// color[1] = uint8_t(std::min(std::max(f[1] * 255.f, 0.f), 255.f)); color[3] = a * 255;
// color[2] = uint8_t(std::min(std::max(f[2] * 255.f, 0.f), 255.f)); }
// color[3] = 0xff;
// return *this; Color& operator=(uint8_t val) {
// } color[0] = val;
// Color& operator=(uint8_t val) { color[1] = val;
// color[0] = val; color[2] = val;
// color[1] = val; color[3] = val;
// color[2] = val; return *this;
// color[3] = val; }
// return *this;
// } explicit Color(uint8_t val) { *this = val; }
// atVec4f toVec4f() const { bool operator==(const Color& other) const { return num == other.num; }
// atVec4f out; bool operator!=(const Color& other) const { return num != other.num; }
// athena::simd_floats f; uint8_t operator[](size_t idx) const { return color[idx]; }
// f[0] = color[0] / 255.f; uint8_t& operator[](size_t idx) { return color[idx]; }
// f[1] = color[1] / 255.f; };
// f[2] = color[2] / 255.f;
// f[3] = color[3] / 255.f;
// out.simd.copy_from(f);
// return out;
// }
// Color(const atVec4f& vec) { *this = vec; }
// Color(const atVec3f& vec) { *this = vec; }
// Color(uint8_t val) { *this = val; }
// bool operator==(const Color& other) const { return num == other.num; }
// bool operator!=(const Color& other) const { return num != other.num; }
// uint8_t operator[](size_t idx) const { return color[idx]; }
// uint8_t& operator[](size_t idx) { return color[idx]; }
// AT_DECL_EXPLICIT_DNA
//};
} // namespace GX } // namespace GX

View File

@ -47,14 +47,14 @@ void CCameraBlurFilter::draw(float amount, bool clearDepth) {
SCOPED_GRAPHICS_DEBUG_GROUP("CCameraBlurFilter::draw", zeus::skMagenta); SCOPED_GRAPHICS_DEBUG_GROUP("CCameraBlurFilter::draw", zeus::skMagenta);
const SClipScreenRect clipRect(g_Viewport); const SClipScreenRect clipRect(CGraphics::g_Viewport);
CGraphics::ResolveSpareTexture(clipRect, 0, clearDepth); CGraphics::ResolveSpareTexture(clipRect, 0, clearDepth);
const float aspect = float(CGraphics::g_CroppedViewport.xc_width) / float(CGraphics::g_CroppedViewport.x10_height); const float aspect = float(CGraphics::g_CroppedViewport.xc_width) / float(CGraphics::g_CroppedViewport.x10_height);
const float xFac = float(CGraphics::g_CroppedViewport.xc_width) / float(g_Viewport.x8_width); const float xFac = float(CGraphics::GetCroppedViewportWidth()) / float(CGraphics::GetViewportWidth());
const float yFac = float(CGraphics::g_CroppedViewport.x10_height) / float(g_Viewport.xc_height); const float yFac = float(CGraphics::GetCroppedViewportHeight()) / float(CGraphics::GetViewportHeight());
const float xBias = float(CGraphics::g_CroppedViewport.x4_left) / float(g_Viewport.x8_width); const float xBias = float(CGraphics::GetCroppedViewportLeft()) / float(CGraphics::GetViewportWidth());
const float yBias = float(CGraphics::g_CroppedViewport.x8_top) / float(g_Viewport.xc_height); const float yBias = float(CGraphics::GetCroppedViewportTop()) / float(CGraphics::GetViewportHeight());
const std::array<Vert, 4> verts{{ const std::array<Vert, 4> verts{{
{{-1.0, -1.0}, {xBias, yBias}}, {{-1.0, -1.0}, {xBias, yBias}},

View File

@ -9,57 +9,58 @@
namespace metaforce { namespace metaforce {
//static boo::ObjToken<boo::IShaderPipeline> s_AlphaPipeline; // static boo::ObjToken<boo::IShaderPipeline> s_AlphaPipeline;
//static boo::ObjToken<boo::IShaderPipeline> s_AddPipeline; // static boo::ObjToken<boo::IShaderPipeline> s_AddPipeline;
//static boo::ObjToken<boo::IShaderPipeline> s_MultPipeline; // static boo::ObjToken<boo::IShaderPipeline> s_MultPipeline;
void CColoredQuadFilter::Initialize() { void CColoredQuadFilter::Initialize() {
// s_AlphaPipeline = hecl::conv->convert(Shader_CColoredQuadFilter{}); // s_AlphaPipeline = hecl::conv->convert(Shader_CColoredQuadFilter{});
// s_AddPipeline = hecl::conv->convert(Shader_CColoredQuadFilterAdd{}); // s_AddPipeline = hecl::conv->convert(Shader_CColoredQuadFilterAdd{});
// s_MultPipeline = hecl::conv->convert(Shader_CColoredQuadFilterMul{}); // s_MultPipeline = hecl::conv->convert(Shader_CColoredQuadFilterMul{});
} }
void CColoredQuadFilter::Shutdown() { void CColoredQuadFilter::Shutdown() {
// s_AlphaPipeline.reset(); // s_AlphaPipeline.reset();
// s_AddPipeline.reset(); // s_AddPipeline.reset();
// s_MultPipeline.reset(); // s_MultPipeline.reset();
} }
//static boo::ObjToken<boo::IShaderPipeline> SelectPipeline(EFilterType type) { // static boo::ObjToken<boo::IShaderPipeline> SelectPipeline(EFilterType type) {
// switch (type) { // switch (type) {
// case EFilterType::Blend: // case EFilterType::Blend:
// return s_AlphaPipeline; // return s_AlphaPipeline;
// case EFilterType::Add: // case EFilterType::Add:
// return s_AddPipeline; // return s_AddPipeline;
// case EFilterType::Multiply: // case EFilterType::Multiply:
// return s_MultPipeline; // return s_MultPipeline;
// default: // default:
// return s_AlphaPipeline; // return s_AlphaPipeline;
// } // }
//} // }
CColoredQuadFilter::CColoredQuadFilter(EFilterType type) { CColoredQuadFilter::CColoredQuadFilter(EFilterType type) {
// CGraphics::CommitResources([this, type](boo::IGraphicsDataFactory::Context& ctx) { // CGraphics::CommitResources([this, type](boo::IGraphicsDataFactory::Context& ctx) {
// struct Vert { // struct Vert {
// zeus::CVector2f m_pos; // zeus::CVector2f m_pos;
// }; // };
// //
// const std::array<Vert, 4> verts{{ // const std::array<Vert, 4> verts{{
// {{0.0, 0.0}}, // {{0.0, 0.0}},
// {{0.0, 1.0}}, // {{0.0, 1.0}},
// {{1.0, 0.0}}, // {{1.0, 0.0}},
// {{1.0, 1.0}}, // {{1.0, 1.0}},
// }}; // }};
// //
// m_vbo = ctx.newStaticBuffer(boo::BufferUse::Vertex, verts.data(), 16, verts.size()); // m_vbo = ctx.newStaticBuffer(boo::BufferUse::Vertex, verts.data(), 16, verts.size());
// m_uniBuf = ctx.newDynamicBuffer(boo::BufferUse::Uniform, sizeof(Uniform), 1); // m_uniBuf = ctx.newDynamicBuffer(boo::BufferUse::Uniform, sizeof(Uniform), 1);
// //
// const std::array<boo::ObjToken<boo::IGraphicsBuffer>, 1> bufs{m_uniBuf.get()}; // const std::array<boo::ObjToken<boo::IGraphicsBuffer>, 1> bufs{m_uniBuf.get()};
// constexpr std::array<boo::PipelineStage, 1> stages{boo::PipelineStage::Vertex}; // constexpr std::array<boo::PipelineStage, 1> stages{boo::PipelineStage::Vertex};
// m_dataBind = ctx.newShaderDataBinding(SelectPipeline(type), m_vbo.get(), nullptr, nullptr, bufs.size(), bufs.data(), // m_dataBind = ctx.newShaderDataBinding(SelectPipeline(type), m_vbo.get(), nullptr, nullptr, bufs.size(),
// stages.data(), nullptr, nullptr, 0, nullptr, nullptr, nullptr); // bufs.data(),
// return true; // stages.data(), nullptr, nullptr, 0, nullptr, nullptr, nullptr);
// } BooTrace); // return true;
// } BooTrace);
} }
void CColoredQuadFilter::draw(const zeus::CColor& color, const zeus::CRectangle& rect) { void CColoredQuadFilter::draw(const zeus::CColor& color, const zeus::CRectangle& rect) {
@ -70,17 +71,17 @@ void CColoredQuadFilter::draw(const zeus::CColor& color, const zeus::CRectangle&
m_uniform.m_matrix[3][0] = rect.position.x() * 2.f - 1.f; m_uniform.m_matrix[3][0] = rect.position.x() * 2.f - 1.f;
m_uniform.m_matrix[3][1] = rect.position.y() * 2.f - 1.f; m_uniform.m_matrix[3][1] = rect.position.y() * 2.f - 1.f;
m_uniform.m_color = color; m_uniform.m_color = color;
// m_uniBuf->load(&m_uniform, sizeof(m_uniform)); // m_uniBuf->load(&m_uniform, sizeof(m_uniform));
// //
// CGraphics::SetShaderDataBinding(m_dataBind); // CGraphics::SetShaderDataBinding(m_dataBind);
// CGraphics::DrawArray(0, 4); // CGraphics::DrawArray(0, 4);
} }
void CWideScreenFilter::draw(const zeus::CColor& color, float t) { void CWideScreenFilter::draw(const zeus::CColor& color, float t) {
if (g_Viewport.aspect < 1.7777f) { if (CGraphics::GetViewportAspect() < 1.7777f) {
float targetHeight = g_Viewport.x8_width / 1.7777f; float targetHeight = CGraphics::GetViewportWidth() / 1.7777f;
float delta = (g_Viewport.xc_height - targetHeight) * t / 2.f; float delta = (CGraphics::GetViewportHeight() - targetHeight) * t / 2.f;
delta /= float(g_Viewport.xc_height); delta /= float(CGraphics::GetViewportHeight());
zeus::CRectangle rect(0.f, 0.f, 1.f, delta); zeus::CRectangle rect(0.f, 0.f, 1.f, delta);
m_bottom.draw(color, rect); m_bottom.draw(color, rect);
rect.position.y() = 1.f - delta; rect.position.y() = 1.f - delta;
@ -89,28 +90,28 @@ void CWideScreenFilter::draw(const zeus::CColor& color, float t) {
} }
float CWideScreenFilter::SetViewportToMatch(float t) { float CWideScreenFilter::SetViewportToMatch(float t) {
if (g_Viewport.aspect < 1.7777f) { if (CGraphics::GetViewportAspect() < 1.7777f) {
float targetHeight = g_Viewport.x8_width / 1.7777f; float targetHeight = CGraphics::GetViewportWidth() / 1.7777f;
float delta = (g_Viewport.xc_height - targetHeight) * t / 2.f; float delta = (CGraphics::GetViewportHeight() - targetHeight) * t / 2.f;
// boo::SWindowRect rect = {}; // boo::SWindowRect rect = {};
// rect.size[0] = g_Viewport.x8_width; // rect.size[0] = g_Viewport.x8_width;
// rect.size[1] = g_Viewport.xc_height - delta * 2.f; // rect.size[1] = g_Viewport.xc_height - delta * 2.f;
// rect.location[1] = delta; // rect.location[1] = delta;
// CGraphics::g_CroppedViewport = rect; // CGraphics::g_CroppedViewport = rect;
// CGraphics::g_BooMainCommandQueue->setViewport(rect); // CGraphics::g_BooMainCommandQueue->setViewport(rect);
return 1.7777f; return 1.7777f;
} else {
SetViewportToFull();
return g_Viewport.aspect;
} }
SetViewportToFull();
return CGraphics::GetViewportAspect();
} }
void CWideScreenFilter::SetViewportToFull() { void CWideScreenFilter::SetViewportToFull() {
// boo::SWindowRect rect = {}; // boo::SWindowRect rect = {};
// rect.size[0] = g_Viewport.x8_width; // rect.size[0] = g_Viewport.x8_width;
// rect.size[1] = g_Viewport.xc_height; // rect.size[1] = g_Viewport.xc_height;
// CGraphics::g_CroppedViewport = rect; // CGraphics::g_CroppedViewport = rect;
// CGraphics::g_BooMainCommandQueue->setViewport(rect); // CGraphics::g_BooMainCommandQueue->setViewport(rect);
} }
} // namespace metaforce } // namespace metaforce

View File

@ -15,126 +15,127 @@
namespace metaforce { namespace metaforce {
//static boo::ObjToken<boo::IShaderPipeline> s_IndPipeline; // static boo::ObjToken<boo::IShaderPipeline> s_IndPipeline;
//static boo::ObjToken<boo::IShaderPipeline> s_Pipeline; // static boo::ObjToken<boo::IShaderPipeline> s_Pipeline;
//static boo::ObjToken<boo::IShaderPipeline> s_BlurPipeline; // static boo::ObjToken<boo::IShaderPipeline> s_BlurPipeline;
void CPhazonSuitFilter::Initialize() { void CPhazonSuitFilter::Initialize() {
// s_IndPipeline = hecl::conv->convert(Shader_CPhazonSuitFilterInd{}); // s_IndPipeline = hecl::conv->convert(Shader_CPhazonSuitFilterInd{});
// s_Pipeline = hecl::conv->convert(Shader_CPhazonSuitFilterNoInd{}); // s_Pipeline = hecl::conv->convert(Shader_CPhazonSuitFilterNoInd{});
// s_BlurPipeline = hecl::conv->convert(Shader_CPhazonSuitFilterBlur{}); // s_BlurPipeline = hecl::conv->convert(Shader_CPhazonSuitFilterBlur{});
} }
void CPhazonSuitFilter::Shutdown() { void CPhazonSuitFilter::Shutdown() {
// s_IndPipeline.reset(); // s_IndPipeline.reset();
// s_Pipeline.reset(); // s_Pipeline.reset();
// s_BlurPipeline.reset(); // s_BlurPipeline.reset();
} }
void CPhazonSuitFilter::drawBlurPasses(float radius, const CTexture* indTex) { void CPhazonSuitFilter::drawBlurPasses(float radius, const CTexture* indTex) {
SCOPED_GRAPHICS_DEBUG_GROUP("CPhazonSuitFilter::drawBlurPasses", zeus::skMagenta); SCOPED_GRAPHICS_DEBUG_GROUP("CPhazonSuitFilter::drawBlurPasses", zeus::skMagenta);
// if (!m_dataBind || indTex != m_indTex) { // if (!m_dataBind || indTex != m_indTex) {
// m_indTex = indTex; // m_indTex = indTex;
// CGraphics::CommitResources([this](boo::IGraphicsDataFactory::Context& ctx) { // CGraphics::CommitResources([this](boo::IGraphicsDataFactory::Context& ctx) {
// m_uniBufBlurX = ctx.newDynamicBuffer(boo::BufferUse::Uniform, sizeof(zeus::CVector4f), 1); // m_uniBufBlurX = ctx.newDynamicBuffer(boo::BufferUse::Uniform, sizeof(zeus::CVector4f), 1);
// m_uniBufBlurY = ctx.newDynamicBuffer(boo::BufferUse::Uniform, sizeof(zeus::CVector4f), 1); // m_uniBufBlurY = ctx.newDynamicBuffer(boo::BufferUse::Uniform, sizeof(zeus::CVector4f), 1);
// m_uniBuf = ctx.newDynamicBuffer(boo::BufferUse::Uniform, sizeof(zeus::CVector4f) * 2, 1); // m_uniBuf = ctx.newDynamicBuffer(boo::BufferUse::Uniform, sizeof(zeus::CVector4f) * 2, 1);
// //
// struct BlurVert { // struct BlurVert {
// zeus::CVector3f pos; // zeus::CVector3f pos;
// zeus::CVector2f uv; // zeus::CVector2f uv;
// }; // };
// const std::array<BlurVert, 4> blurVerts{{ // const std::array<BlurVert, 4> blurVerts{{
// {{-1.f, 1.f, 0.f}, {0.f, 1.f}}, // {{-1.f, 1.f, 0.f}, {0.f, 1.f}},
// {{-1.f, -1.f, 0.f}, {0.f, 0.f}}, // {{-1.f, -1.f, 0.f}, {0.f, 0.f}},
// {{1.f, 1.f, 0.f}, {1.f, 1.f}}, // {{1.f, 1.f, 0.f}, {1.f, 1.f}},
// {{1.f, -1.f, 0.f}, {1.f, 0.f}}, // {{1.f, -1.f, 0.f}, {1.f, 0.f}},
// }}; // }};
// m_blurVbo = ctx.newStaticBuffer(boo::BufferUse::Vertex, blurVerts.data(), sizeof(BlurVert), blurVerts.size()); // m_blurVbo = ctx.newStaticBuffer(boo::BufferUse::Vertex, blurVerts.data(), sizeof(BlurVert), blurVerts.size());
// //
// struct Vert { // struct Vert {
// zeus::CVector3f pos; // zeus::CVector3f pos;
// zeus::CVector2f screenUv; // zeus::CVector2f screenUv;
// zeus::CVector2f indUv; // zeus::CVector2f indUv;
// zeus::CVector2f maskUv; // zeus::CVector2f maskUv;
// }; // };
// const std::array<Vert, 4> verts{{ // const std::array<Vert, 4> verts{{
// {{-1.f, 1.f, 0.f}, {0.01f, 0.99f}, {0.f, 4.f}, {0.f, 1.f}}, // {{-1.f, 1.f, 0.f}, {0.01f, 0.99f}, {0.f, 4.f}, {0.f, 1.f}},
// {{-1.f, -1.f, 0.f}, {0.01f, 0.01f}, {0.f, 0.f}, {0.f, 0.f}}, // {{-1.f, -1.f, 0.f}, {0.01f, 0.01f}, {0.f, 0.f}, {0.f, 0.f}},
// {{1.f, 1.f, 0.f}, {0.99f, 0.99f}, {g_Viewport.aspect * 4.f, 4.f}, {1.f, 1.f}}, // {{1.f, 1.f, 0.f}, {0.99f, 0.99f}, {g_Viewport.aspect * 4.f, 4.f}, {1.f, 1.f}},
// {{1.f, -1.f, 0.f}, {0.99f, 0.01f}, {g_Viewport.aspect * 4.f, 0.f}, {1.f, 0.f}}, // {{1.f, -1.f, 0.f}, {0.99f, 0.01f}, {g_Viewport.aspect * 4.f, 0.f}, {1.f, 0.f}},
// }}; // }};
// m_vbo = ctx.newStaticBuffer(boo::BufferUse::Vertex, verts.data(), sizeof(Vert), verts.size()); // m_vbo = ctx.newStaticBuffer(boo::BufferUse::Vertex, verts.data(), sizeof(Vert), verts.size());
// //
// std::array<boo::ObjToken<boo::IGraphicsBuffer>, 1> bufs{m_uniBufBlurX.get()}; // std::array<boo::ObjToken<boo::IGraphicsBuffer>, 1> bufs{m_uniBufBlurX.get()};
// constexpr std::array<boo::PipelineStage, 1> stages{boo::PipelineStage::Vertex}; // constexpr std::array<boo::PipelineStage, 1> stages{boo::PipelineStage::Vertex};
// std::array<boo::ObjToken<boo::ITexture>, 4> texs; // std::array<boo::ObjToken<boo::ITexture>, 4> texs;
// std::array<int, 4> texBindIdxs; // std::array<int, 4> texBindIdxs;
// //
// texs[0] = CGraphics::g_SpareTexture.get(); // texs[0] = CGraphics::g_SpareTexture.get();
// texBindIdxs[0] = 1; // texBindIdxs[0] = 1;
// m_dataBindBlurX = // m_dataBindBlurX =
// ctx.newShaderDataBinding(s_BlurPipeline, m_blurVbo.get(), nullptr, nullptr, bufs.size(), bufs.data(), // ctx.newShaderDataBinding(s_BlurPipeline, m_blurVbo.get(), nullptr, nullptr, bufs.size(), bufs.data(),
// stages.data(), nullptr, nullptr, 1, texs.data(), texBindIdxs.data(), nullptr); // stages.data(), nullptr, nullptr, 1, texs.data(), texBindIdxs.data(), nullptr);
// //
// bufs[0] = m_uniBufBlurY.get(); // bufs[0] = m_uniBufBlurY.get();
// texs[0] = CGraphics::g_SpareTexture.get(); // texs[0] = CGraphics::g_SpareTexture.get();
// texBindIdxs[0] = 2; // texBindIdxs[0] = 2;
// m_dataBindBlurY = // m_dataBindBlurY =
// ctx.newShaderDataBinding(s_BlurPipeline, m_blurVbo.get(), nullptr, nullptr, bufs.size(), bufs.data(), // ctx.newShaderDataBinding(s_BlurPipeline, m_blurVbo.get(), nullptr, nullptr, bufs.size(), bufs.data(),
// stages.data(), nullptr, nullptr, 1, texs.data(), texBindIdxs.data(), nullptr); // stages.data(), nullptr, nullptr, 1, texs.data(), texBindIdxs.data(), nullptr);
// //
// bufs[0] = m_uniBuf.get(); // bufs[0] = m_uniBuf.get();
// size_t texCount; // size_t texCount;
// if (m_indTex) { // if (m_indTex) {
// texs[0] = CGraphics::g_SpareTexture.get(); // texs[0] = CGraphics::g_SpareTexture.get();
// texBindIdxs[0] = 0; // texBindIdxs[0] = 0;
// texs[1] = m_indTex->GetBooTexture(); // texs[1] = m_indTex->GetBooTexture();
// texBindIdxs[1] = 0; // texBindIdxs[1] = 0;
// texs[2] = CGraphics::g_SpareTexture.get(); // texs[2] = CGraphics::g_SpareTexture.get();
// texBindIdxs[2] = 1; // texBindIdxs[2] = 1;
// texs[3] = CGraphics::g_SpareTexture.get(); // texs[3] = CGraphics::g_SpareTexture.get();
// texBindIdxs[3] = 2; // texBindIdxs[3] = 2;
// texCount = 4; // texCount = 4;
// } else { // } else {
// texs[0] = CGraphics::g_SpareTexture.get(); // texs[0] = CGraphics::g_SpareTexture.get();
// texBindIdxs[0] = 0; // texBindIdxs[0] = 0;
// texs[1] = CGraphics::g_SpareTexture.get(); // texs[1] = CGraphics::g_SpareTexture.get();
// texBindIdxs[1] = 1; // texBindIdxs[1] = 1;
// texs[2] = CGraphics::g_SpareTexture.get(); // texs[2] = CGraphics::g_SpareTexture.get();
// texBindIdxs[2] = 2; // texBindIdxs[2] = 2;
// texCount = 3; // texCount = 3;
// } // }
// //
// m_dataBind = ctx.newShaderDataBinding(m_indTex ? s_IndPipeline : s_Pipeline, m_vbo.get(), nullptr, nullptr, // m_dataBind = ctx.newShaderDataBinding(m_indTex ? s_IndPipeline : s_Pipeline, m_vbo.get(), nullptr, nullptr,
// bufs.size(), bufs.data(), stages.data(), nullptr, nullptr, texCount, // bufs.size(), bufs.data(), stages.data(), nullptr, nullptr, texCount,
// texs.data(), texBindIdxs.data(), nullptr); // texs.data(), texBindIdxs.data(), nullptr);
// return true; // return true;
// } BooTrace); // } BooTrace);
// } // }
SClipScreenRect rect; SClipScreenRect rect;
rect.x4_left = g_Viewport.x0_left; rect.x4_left = CGraphics::GetViewportLeft();
rect.x8_top = g_Viewport.x4_top; rect.x8_top = CGraphics::GetViewportTop();
rect.xc_width = g_Viewport.x8_width; rect.xc_width = CGraphics::GetViewportWidth();
rect.x10_height = g_Viewport.xc_height; rect.x10_height = CGraphics::GetViewportTop();
constexpr float blurScale = 1.0f / 128.0f; constexpr float blurScale = 1.0f / 128.0f;
/* X Pass */ /* X Pass */
auto blurDir = zeus::CVector4f{g_Viewport.xc_height / float(g_Viewport.x8_width) * radius * blurScale, 0.f, 0.f, 0.f}; auto blurDir = zeus::CVector4f{
// m_uniBufBlurX->load(&blurDir, sizeof(zeus::CVector4f)); CGraphics::GetViewportHeight() / float(CGraphics::GetViewportWidth()) * radius * blurScale, 0.f, 0.f, 0.f};
// m_uniBufBlurX->load(&blurDir, sizeof(zeus::CVector4f));
// CGraphics::SetShaderDataBinding(m_dataBindBlurX); // CGraphics::SetShaderDataBinding(m_dataBindBlurX);
// CGraphics::DrawArray(0, 4); // CGraphics::DrawArray(0, 4);
CGraphics::ResolveSpareTexture(rect, 2); CGraphics::ResolveSpareTexture(rect, 2);
/* Y Pass */ /* Y Pass */
blurDir = zeus::CVector4f{0.f, radius * blurScale, 0.f, 0.f}; blurDir = zeus::CVector4f{0.f, radius * blurScale, 0.f, 0.f};
// m_uniBufBlurY->load(&blurDir, sizeof(zeus::CVector4f)); // m_uniBufBlurY->load(&blurDir, sizeof(zeus::CVector4f));
// CGraphics::SetShaderDataBinding(m_dataBindBlurY); // CGraphics::SetShaderDataBinding(m_dataBindBlurY);
// CGraphics::DrawArray(0, 4); // CGraphics::DrawArray(0, 4);
CGraphics::ResolveSpareTexture(rect, 2); CGraphics::ResolveSpareTexture(rect, 2);
} }
@ -145,9 +146,9 @@ void CPhazonSuitFilter::draw(const zeus::CColor& color, float indScale, float in
zeus::CVector4f indScaleOff; zeus::CVector4f indScaleOff;
} uniform = {color, zeus::CVector4f(indScale, indScale, indOffX, indOffY)}; } uniform = {color, zeus::CVector4f(indScale, indScale, indOffX, indOffY)};
// m_uniBuf->load(&uniform, sizeof(Uniform)); // m_uniBuf->load(&uniform, sizeof(Uniform));
// CGraphics::SetShaderDataBinding(m_dataBind); // CGraphics::SetShaderDataBinding(m_dataBind);
// CGraphics::DrawArray(0, 4); // CGraphics::DrawArray(0, 4);
} }
} // namespace metaforce } // namespace metaforce

View File

@ -157,7 +157,7 @@ void CSpaceWarpFilter::draw(const zeus::CVector3f& pt) {
clipRect.x4_left += CGraphics::g_CroppedViewport.x4_left; clipRect.x4_left += CGraphics::g_CroppedViewport.x4_left;
clipRect.x8_top += CGraphics::g_CroppedViewport.x8_top; clipRect.x8_top += CGraphics::g_CroppedViewport.x8_top;
clipRect.x8_top = g_Viewport.xc_height - clipRect.x10_height - clipRect.x8_top; clipRect.x8_top = CGraphics::GetViewportHeight() - clipRect.x10_height - clipRect.x8_top;
CGraphics::ResolveSpareTexture(clipRect); CGraphics::ResolveSpareTexture(clipRect);
m_uniform.m_strength.x() = m_uniform.m_strength.x() =

View File

@ -238,10 +238,10 @@ void CTexturedQuadFilter::draw(const zeus::CColor& color, float uvScale, const z
void CTexturedQuadFilter::drawCropped(const zeus::CColor& color, float uvScale) { void CTexturedQuadFilter::drawCropped(const zeus::CColor& color, float uvScale) {
SCOPED_GRAPHICS_DEBUG_GROUP("CTexturedQuadFilter::drawCropped", zeus::skMagenta); SCOPED_GRAPHICS_DEBUG_GROUP("CTexturedQuadFilter::drawCropped", zeus::skMagenta);
const float xFac = CGraphics::g_CroppedViewport.xc_width / float(g_Viewport.x8_width); const float xFac = CGraphics::GetCroppedViewportWidth() / float(CGraphics::GetViewportWidth());
const float yFac = CGraphics::g_CroppedViewport.x10_height / float(g_Viewport.xc_height); const float yFac = CGraphics::GetCroppedViewportHeight() / float(CGraphics::GetViewportHeight());
const float xBias = CGraphics::g_CroppedViewport.x4_left / float(g_Viewport.x8_width); const float xBias = CGraphics::GetCroppedViewportLeft() / float(CGraphics::GetViewportWidth());
const float yBias = CGraphics::g_CroppedViewport.x8_top / float(g_Viewport.xc_height); const float yBias = CGraphics::GetCroppedViewportTop() / float(CGraphics::GetViewportHeight());
const std::array<Vert, 4> verts{{ const std::array<Vert, 4> verts{{
{{-1.f, -1.f, 0.f}, {xBias * uvScale, yBias * uvScale}}, {{-1.f, -1.f, 0.f}, {xBias * uvScale, yBias * uvScale}},

View File

@ -76,17 +76,18 @@ void CGuiSys::OnViewportResize() {
void CGuiSys::ViewportResizeFrame(CGuiFrame* frame) { void CGuiSys::ViewportResizeFrame(CGuiFrame* frame) {
if (frame->m_aspectConstraint > 0.f) { if (frame->m_aspectConstraint > 0.f) {
float hPad, vPad; float hPad, vPad;
if (g_Viewport.aspect >= frame->m_aspectConstraint) { if (CGraphics::GetViewportAspect() >= frame->m_aspectConstraint) {
hPad = frame->m_aspectConstraint / g_Viewport.aspect; hPad = frame->m_aspectConstraint / CGraphics::GetViewportAspect();
vPad = frame->m_aspectConstraint / 1.38f; vPad = frame->m_aspectConstraint / 1.38f;
} else { } else {
hPad = 1.f; hPad = 1.f;
vPad = g_Viewport.aspect / 1.38f; vPad = CGraphics::GetViewportAspect() / 1.38f;
} }
frame->m_aspectTransform = zeus::CTransform::Scale({hPad, 1.f, vPad}); frame->m_aspectTransform = zeus::CTransform::Scale({hPad, 1.f, vPad});
} else if (frame->m_maxAspect > 0.f) { } else if (frame->m_maxAspect > 0.f) {
if (g_Viewport.aspect > frame->m_maxAspect) if (CGraphics::GetViewportAspect() > frame->m_maxAspect)
frame->m_aspectTransform = zeus::CTransform::Scale({frame->m_maxAspect / g_Viewport.aspect, 1.f, 1.f}); frame->m_aspectTransform =
zeus::CTransform::Scale({frame->m_maxAspect / CGraphics::GetViewportAspect(), 1.f, 1.f});
else else
frame->m_aspectTransform = zeus::CTransform(); frame->m_aspectTransform = zeus::CTransform();
} }

View File

@ -73,10 +73,11 @@ void COrbitPointMarker::Draw(const CStateManager& mgr) const {
const CGameCamera* curCam = mgr.GetCameraManager()->GetCurrentCamera(mgr); const CGameCamera* curCam = mgr.GetCameraManager()->GetCurrentCamera(mgr);
zeus::CTransform camXf = mgr.GetCameraManager()->GetCurrentCameraTransform(mgr); zeus::CTransform camXf = mgr.GetCameraManager()->GetCurrentCameraTransform(mgr);
CGraphics::SetViewPointMatrix(camXf); CGraphics::SetViewPointMatrix(camXf);
zeus::CFrustum frustum = mgr.SetupDrawFrustum(g_Viewport); zeus::CFrustum frustum = mgr.SetupDrawFrustum(CGraphics::g_Viewport);
frustum.updatePlanes(camXf, zeus::SProjPersp(zeus::degToRad(curCam->GetFov()), g_Viewport.aspect, 1.f, 100.f)); frustum.updatePlanes(
camXf, zeus::SProjPersp(zeus::degToRad(curCam->GetFov()), CGraphics::GetViewportAspect(), 1.f, 100.f));
g_Renderer->SetClippingPlanes(frustum); g_Renderer->SetClippingPlanes(frustum);
g_Renderer->SetPerspective(curCam->GetFov(), g_Viewport.x8_width, g_Viewport.xc_height, g_Renderer->SetPerspective(curCam->GetFov(), CGraphics::GetViewportWidth(), CGraphics::GetViewportHeight(),
curCam->GetNearClipDistance(), curCam->GetFarClipDistance()); curCam->GetNearClipDistance(), curCam->GetFarClipDistance());
float scale; float scale;
if (x1c_lastFreeOrbit) if (x1c_lastFreeOrbit)

View File

@ -381,7 +381,7 @@ void CScanDisplay::Update(float dt, float scanningTime) {
case CDataDot::EDotState::Hold: { case CDataDot::EDotState::Hold: {
float tmp = dot.GetTransitionFactor(); float tmp = dot.GetTransitionFactor();
if (tmp == 0.f) { if (tmp == 0.f) {
float vpRatio = g_Viewport.xc_height / 480.f; float vpRatio = CGraphics::GetViewportHeight() / 480.f;
float posRand = g_tweakGui->GetScanDataDotPosRandMagnitude() * vpRatio; float posRand = g_tweakGui->GetScanDataDotPosRandMagnitude() * vpRatio;
float durMin = dot.GetDotState() == CDataDot::EDotState::Hold ? g_tweakGui->GetScanDataDotHoldDurationMin() float durMin = dot.GetDotState() == CDataDot::EDotState::Hold ? g_tweakGui->GetScanDataDotHoldDurationMin()
: g_tweakGui->GetScanDataDotSeekDurationMin(); : g_tweakGui->GetScanDataDotSeekDurationMin();
@ -403,8 +403,8 @@ void CScanDisplay::Update(float dt, float scanningTime) {
case CDataDot::EDotState::Done: { case CDataDot::EDotState::Done: {
const zeus::CVector3f& panePos = x170_paneStates[i].second->GetWorldPosition(); const zeus::CVector3f& panePos = x170_paneStates[i].second->GetWorldPosition();
zeus::CVector3f screenPos = xa0_selHud.GetFrameCamera()->ConvertToScreenSpace(panePos); zeus::CVector3f screenPos = xa0_selHud.GetFrameCamera()->ConvertToScreenSpace(panePos);
zeus::CVector2f viewportCoords(screenPos.x() * g_Viewport.x8_width * 0.5f, zeus::CVector2f viewportCoords(screenPos.x() * CGraphics::GetViewportWidth() * 0.5f,
screenPos.y() * g_Viewport.xc_height * 0.5f); screenPos.y() * CGraphics::GetViewportHeight() * 0.5f);
dot.SetDestPosition(viewportCoords); dot.SetDestPosition(viewportCoords);
break; break;
} }
@ -449,7 +449,7 @@ void CScanDisplay::Draw() {
g_Renderer->SetViewportOrtho(true, -4096.f, 4096.f); g_Renderer->SetViewportOrtho(true, -4096.f, 4096.f);
// Additive alpha // Additive alpha
const float vpRatio = g_Viewport.xc_height / 480.f; const float vpRatio = CGraphics::GetViewportHeight() / 480.f;
for (CDataDot& dot : xbc_dataDots) { for (CDataDot& dot : xbc_dataDots) {
dot.Draw(g_tweakGuiColors->GetScanDataDotColor(), g_tweakGui->GetScanDataDotRadius() * vpRatio); dot.Draw(g_tweakGuiColors->GetScanDataDotColor(), g_tweakGui->GetScanDataDotRadius() * vpRatio);
} }

View File

@ -83,7 +83,7 @@ void CSplashScreen::Draw() {
} }
zeus::CRectangle rect; zeus::CRectangle rect;
rect.size.x() = width / (480.f * g_Viewport.aspect); rect.size.x() = width / (480.f * CGraphics::GetViewportAspect());
rect.size.y() = height / 480.f; rect.size.y() = height / 480.f;
rect.position.x() = 0.5f - rect.size.x() / 2.f; rect.position.x() = 0.5f - rect.size.x() / 2.f;
rect.position.y() = 0.5f - rect.size.y() / 2.f; rect.position.y() = 0.5f - rect.size.y() / 2.f;

View File

@ -26,10 +26,11 @@ void CTargetingManager::Draw(const CStateManager& mgr, bool hideLockon) {
zeus::CTransform camXf = mgr.GetCameraManager()->GetCurrentCameraTransform(mgr); zeus::CTransform camXf = mgr.GetCameraManager()->GetCurrentCameraTransform(mgr);
CGraphics::SetViewPointMatrix(camXf); CGraphics::SetViewPointMatrix(camXf);
zeus::CFrustum frustum; zeus::CFrustum frustum;
frustum.updatePlanes(camXf, zeus::SProjPersp(zeus::degToRad(curCam->GetFov()), g_Viewport.aspect, 1.f, 100.f)); frustum.updatePlanes(camXf,
zeus::SProjPersp(zeus::degToRad(curCam->GetFov()), CGraphics::GetViewportAspect(), 1.f, 100.f));
g_Renderer->SetClippingPlanes(frustum); g_Renderer->SetClippingPlanes(frustum);
g_Renderer->SetPerspective(curCam->GetFov(), g_Viewport.x8_width, g_Viewport.xc_height, curCam->GetNearClipDistance(), g_Renderer->SetPerspective(curCam->GetFov(), CGraphics::GetViewportWidth(), CGraphics::GetViewportHeight(),
curCam->GetFarClipDistance()); curCam->GetNearClipDistance(), curCam->GetFarClipDistance());
x0_targetReticule.Draw(mgr, hideLockon); x0_targetReticule.Draw(mgr, hideLockon);
} }

View File

@ -94,7 +94,7 @@ void CArtifactDoll::Draw(float alpha, const CStateManager& mgr, bool inArtifactC
SCOPED_GRAPHICS_DEBUG_GROUP("CArtifactDoll::Draw", zeus::skPurple); SCOPED_GRAPHICS_DEBUG_GROUP("CArtifactDoll::Draw", zeus::skPurple);
alpha *= x24_fader; alpha *= x24_fader;
g_Renderer->SetPerspective(55.f, g_Viewport.x8_width, g_Viewport.xc_height, 0.2f, 4096.f); g_Renderer->SetPerspective(55.f, CGraphics::GetViewportWidth(), CGraphics::GetViewportHeight(), 0.2f, 4096.f);
CGraphics::SetViewPointMatrix(zeus::CTransform::Translate(0.f, -10.f, 0.f)); CGraphics::SetViewPointMatrix(zeus::CTransform::Translate(0.f, -10.f, 0.f));
float angle = CGraphics::GetSecondsMod900() * 2.f * M_PIF * 0.25f; float angle = CGraphics::GetSecondsMod900() * 2.f * M_PIF * 0.25f;

View File

@ -60,7 +60,7 @@ CIOWin::EMessageReturn CCredits::Update(float dt, CArchitectureQueue& queue) {
g_ResFactory->GetResourceIdByName(g_tweakGui->GetCreditsFont())->id, g_ResFactory->GetResourceIdByName(g_tweakGui->GetCreditsFont())->id,
CGuiTextProperties(true, true, EJustification::Center, EVerticalJustification::Top), CGuiTextProperties(true, true, EJustification::Center, EVerticalJustification::Top),
g_tweakGui->GetCreditsTextFontColor(), g_tweakGui->GetCreditsTextBorderColor(), g_tweakGui->GetCreditsTextFontColor(), g_tweakGui->GetCreditsTextBorderColor(),
zeus::skWhite, g_Viewport.x8_width - 64, 0, g_SimplePool, zeus::skWhite, CGraphics::GetViewportWidth() - 64, 0, g_SimplePool,
CGuiWidget::EGuiModelDrawFlags::Alpha), CGuiWidget::EGuiModelDrawFlags::Alpha),
zeus::CVector2i(0, 0)); zeus::CVector2i(0, 0));
x30_text.back().first->SetText(x18_creditsTable->GetString(i)); x30_text.back().first->SetText(x18_creditsTable->GetString(i));
@ -96,12 +96,12 @@ CIOWin::EMessageReturn CCredits::Update(float dt, CArchitectureQueue& queue) {
auto bounds = text->GetBounds(); auto bounds = text->GetBounds();
offset.y = (bounds.second.y - bounds.first.y); offset.y = (bounds.second.y - bounds.first.y);
offset.x = scaleY; offset.x = scaleY;
text->SetExtentX(g_Viewport.x8_width - 1280); text->SetExtentX(CGraphics::GetViewportWidth() - 1280);
text->SetExtentY((bounds.second.y - bounds.first.y)); text->SetExtentY((bounds.second.y - bounds.first.y));
scaleY += (bounds.second.y - bounds.first.y); scaleY += (bounds.second.y - bounds.first.y);
} }
x4c_ = float(scaleY + g_Viewport.xc_height - 896); // * 0.5f; x4c_ = float(scaleY + CGraphics::GetViewportHeight() - 896); // * 0.5f;
const float divVal = std::max(g_tweakGui->x310_, g_tweakGui->x30c_); const float divVal = std::max(g_tweakGui->x310_, g_tweakGui->x30c_);
x50_ = x4c_ / (g_tweakGui->x308_ - divVal); x50_ = x4c_ / (g_tweakGui->x308_ - divVal);
x14_ = 1; x14_ = 1;
@ -202,12 +202,12 @@ CIOWin::EMessageReturn CCredits::ProcessUserInput(const CFinalInput& input) {
void CCredits::DrawVideo() { void CCredits::DrawVideo() {
/* Correct movie aspect ratio */ /* Correct movie aspect ratio */
float hPad, vPad; float hPad, vPad;
if (g_Viewport.aspect >= 1.78f) { if (CGraphics::GetViewportAspect() >= 1.78f) {
hPad = 1.78f / g_Viewport.aspect; hPad = 1.78f / CGraphics::GetViewportAspect();
vPad = 1.78f / 1.33f; vPad = 1.78f / 1.33f;
} else { } else {
hPad = 1.f; hPad = 1.f;
vPad = g_Viewport.aspect / 1.33f; vPad = CGraphics::GetViewportAspect() / 1.33f;
} }
if (x28_ && x28_->GetIsFullyCached()) { if (x28_ && x28_->GetIsFullyCached()) {
@ -230,7 +230,7 @@ void CCredits::DrawVideo() {
} }
void CCredits::DrawText() { void CCredits::DrawText() {
float width = 896.f * g_Viewport.aspect; float width = 896.f * CGraphics::GetViewportAspect();
CGraphics::SetOrtho(0.f, width, 896.f, 0.f, -4096.f, 4096.f); CGraphics::SetOrtho(0.f, width, 896.f, 0.f, -4096.f, 4096.f);
auto region = auto region =
std::make_pair<zeus::CVector2f, zeus::CVector2f>(zeus::CVector2f{0.f, 0.f}, zeus::CVector2f{width, 896.f}); std::make_pair<zeus::CVector2f, zeus::CVector2f>(zeus::CVector2f{0.f, 0.f}, zeus::CVector2f{width, 896.f});

View File

@ -1481,7 +1481,7 @@ void CFrontEndUI::SNesEmulatorFrame::Draw(CSaveGameScreen* saveUi) const {
if (x10_remTime <= 0.f) if (x10_remTime <= 0.f)
return; return;
if (xc_textSupport->GetIsTextSupportFinishedLoading()) { if (xc_textSupport->GetIsTextSupportFinishedLoading()) {
float aspect = g_Viewport.aspect / 1.33f; float aspect = CGraphics::GetViewportAspect() / 1.33f;
CGraphics::SetOrtho(-320.f * aspect, 320.f * aspect, 240.f, -240.f, -4096.f, 4096.f); CGraphics::SetOrtho(-320.f * aspect, 320.f * aspect, 240.f, -240.f, -4096.f, 4096.f);
CGraphics::SetViewPointMatrix(zeus::CTransform()); CGraphics::SetViewPointMatrix(zeus::CTransform());
CGraphics::SetModelMatrix(zeus::CTransform::Translate(-220.f, 0.f, -200.f)); CGraphics::SetModelMatrix(zeus::CTransform::Translate(-220.f, 0.f, -200.f));
@ -2013,15 +2013,15 @@ void CFrontEndUI::Draw() {
/* Correct movie aspect ratio */ /* Correct movie aspect ratio */
float hPad, vPad; float hPad, vPad;
if (g_Viewport.aspect >= 1.78f) { if (CGraphics::GetViewportAspect() >= 1.78f) {
hPad = 1.78f / g_Viewport.aspect; hPad = 1.78f / CGraphics::GetViewportAspect();
vPad = 1.78f / 1.33f; vPad = 1.78f / 1.33f;
} else { } else {
hPad = 1.f; hPad = 1.f;
vPad = g_Viewport.aspect / 1.33f; vPad = CGraphics::GetViewportAspect() / 1.33f;
} }
if (xcc_curMoviePtr && xcc_curMoviePtr->GetIsFullyCached()) { if ((xcc_curMoviePtr != nullptr) && xcc_curMoviePtr->GetIsFullyCached()) {
/* Render movie */ /* Render movie */
xcc_curMoviePtr->SetFrame(hPad, vPad); xcc_curMoviePtr->SetFrame(hPad, vPad);
xcc_curMoviePtr->DrawFrame(); xcc_curMoviePtr->DrawFrame();

View File

@ -31,7 +31,7 @@ void CGameCubeDoll::Draw(float alpha) {
return; return;
SCOPED_GRAPHICS_DEBUG_GROUP("CGameCubeDoll::Draw", zeus::skPurple); SCOPED_GRAPHICS_DEBUG_GROUP("CGameCubeDoll::Draw", zeus::skPurple);
g_Renderer->SetPerspective(55.f, g_Viewport.x8_width, g_Viewport.xc_height, 0.2f, 4096.f); g_Renderer->SetPerspective(55.f, CGraphics::GetViewportWidth(), CGraphics::GetViewportHeight(), 0.2f, 4096.f);
CGraphics::SetViewPointMatrix(zeus::CTransform::Translate(0.f, -2.f, 0.f)); CGraphics::SetViewPointMatrix(zeus::CTransform::Translate(0.f, -2.f, 0.f));
x18_actorLights->ActivateLights(); x18_actorLights->ActivateLights();
CGraphics::SetModelMatrix(zeus::CTransform::RotateZ(zeus::degToRad(360.f * CGraphics::GetSecondsMod900() * -0.25f)) * CGraphics::SetModelMatrix(zeus::CTransform::RotateZ(zeus::degToRad(360.f * CGraphics::GetSecondsMod900() * -0.25f)) *

View File

@ -473,15 +473,15 @@ void CInGameGuiManager::Draw(CStateManager& stateMgr) {
// No depth read/write // No depth read/write
// Alpha blend // Alpha blend
int w = int w = (CGraphics::GetViewportLeft() + (x1c4_onScreenTex.x4_origin.x - CGraphics::GetViewportWidth()) / 2 +
(g_Viewport.x0_left + (x1c4_onScreenTex.x4_origin.x - g_Viewport.x8_width) / 2 + x1c4_onScreenTex.xc_extent.x) - x1c4_onScreenTex.xc_extent.x) -
x1c4_onScreenTex.x4_origin.x; x1c4_onScreenTex.x4_origin.x;
int h = int h = (CGraphics::GetViewportTop() + (x1c4_onScreenTex.x4_origin.y - CGraphics::GetViewportHeight()) / 2 -
(g_Viewport.x4_top + (x1c4_onScreenTex.x4_origin.y - g_Viewport.xc_height) / 2 - x1c4_onScreenTex.xc_extent.y) - x1c4_onScreenTex.xc_extent.y) -
x1c4_onScreenTex.x4_origin.y; x1c4_onScreenTex.x4_origin.y;
zeus::CRectangle rect(x1c4_onScreenTex.x4_origin.x / float(g_Viewport.x8_width), zeus::CRectangle rect(x1c4_onScreenTex.x4_origin.x / float(CGraphics::GetViewportWidth()),
x1c4_onScreenTex.x4_origin.y / float(g_Viewport.xc_height), w / float(g_Viewport.x8_width), x1c4_onScreenTex.x4_origin.y / float(CGraphics::GetViewportHeight()),
h / float(g_Viewport.xc_height)); w / float(CGraphics::GetViewportWidth()), h / float(CGraphics::GetViewportHeight()));
m_onScreenQuad->draw(zeus::CColor(1.f, x1d8_onScreenTexAlpha), 1.f, rect); m_onScreenQuad->draw(zeus::CColor(1.f, x1d8_onScreenTexAlpha), 1.f, rect);
} }
@ -501,7 +501,7 @@ void CInGameGuiManager::Draw(CStateManager& stateMgr) {
x34_samusHud->GetTargetingManager().Draw(stateMgr, true); x34_samusHud->GetTargetingManager().Draw(stateMgr, true);
CGraphics::SetDepthRange(DEPTH_SCREEN_ACTORS, DEPTH_GUN); CGraphics::SetDepthRange(DEPTH_SCREEN_ACTORS, DEPTH_GUN);
bool scanVisor = stateMgr.GetPlayerState()->GetActiveVisor(stateMgr) == CPlayerState::EPlayerVisor::Scan; bool scanVisor = stateMgr.GetPlayerState()->GetActiveVisor(stateMgr) == CPlayerState::EPlayerVisor::Scan;
if (drawVisor && x1f0_enablePlayerVisor) { if (drawVisor && (x1f0_enablePlayerVisor != 0u)) {
if (stateMgr.GetPlayer().GetCameraState() == CPlayer::EPlayerCameraState::FirstPerson) if (stateMgr.GetPlayer().GetCameraState() == CPlayer::EPlayerCameraState::FirstPerson)
x20_faceplateDecor.Draw(stateMgr); x20_faceplateDecor.Draw(stateMgr);
CTargetingManager* tgtMgr = nullptr; CTargetingManager* tgtMgr = nullptr;
@ -594,11 +594,11 @@ void CInGameGuiManager::Draw(CStateManager& stateMgr) {
float zT = 1.f - zeus::clamp(0.f, (stateMgr.GetPlayer().GetDeathTime() - zStart) / 0.5f, 1.f); float zT = 1.f - zeus::clamp(0.f, (stateMgr.GetPlayer().GetDeathTime() - zStart) / 0.5f, 1.f);
float xT = 1.f - zeus::clamp(0.f, (stateMgr.GetPlayer().GetDeathTime() - xStart) / 0.5f, 1.f); float xT = 1.f - zeus::clamp(0.f, (stateMgr.GetPlayer().GetDeathTime() - xStart) / 0.5f, 1.f);
float colT = 1.f - zeus::clamp(0.f, (stateMgr.GetPlayer().GetDeathTime() - colStart) / 0.5f, 1.f); float colT = 1.f - zeus::clamp(0.f, (stateMgr.GetPlayer().GetDeathTime() - colStart) / 0.5f, 1.f);
SClipScreenRect rect(g_Viewport); SClipScreenRect rect(CGraphics::g_Viewport);
CGraphics::ResolveSpareTexture(rect); CGraphics::ResolveSpareTexture(rect);
m_deathBlackout.draw(zeus::skBlack); m_deathBlackout.draw(zeus::skBlack);
float z = 0.5f * (zT * zT * zT * zT * zT * (g_Viewport.xc_height - 12.f) + 12.f); float z = 0.5f * (zT * zT * zT * zT * zT * (CGraphics::GetViewportHeight()- 12.f) + 12.f);
float x = 0.5f * (xT * (g_Viewport.x8_width - 12.f) + 12.f); float x = 0.5f * (xT * (CGraphics::GetViewportWidth() - 12.f) + 12.f);
const std::array<CTexturedQuadFilter::Vert, 4> verts{{ const std::array<CTexturedQuadFilter::Vert, 4> verts{{
{{-x, 0.f, z}, {0.f, 0.f}}, {{-x, 0.f, z}, {0.f, 0.f}},
@ -607,9 +607,9 @@ void CInGameGuiManager::Draw(CStateManager& stateMgr) {
{{x, 0.f, -z}, {1.f, 1.f}}, {{x, 0.f, -z}, {1.f, 1.f}},
}}; }};
// if (!m_deathRenderTexQuad) // if (!m_deathRenderTexQuad)
// m_deathRenderTexQuad.emplace(EFilterType::Blend, CGraphics::g_SpareTexture.get()); // m_deathRenderTexQuad.emplace(EFilterType::Blend, CGraphics::g_SpareTexture.get());
// m_deathRenderTexQuad->drawVerts(zeus::CColor(1.f, colT), verts); // m_deathRenderTexQuad->drawVerts(zeus::CColor(1.f, colT), verts);
if (!m_deathDotQuad) if (!m_deathDotQuad)
m_deathDotQuad.emplace(EFilterType::Multiply, x50_deathDot); m_deathDotQuad.emplace(EFilterType::Multiply, x50_deathDot);

View File

@ -165,7 +165,7 @@ void CInventoryScreen::ProcessControllerInput(const CFinalInput& input) {
zeus::CVector2f mouseCoord = zeus::CVector2f(kbm->m_mouseCoord.norm[0], kbm->m_mouseCoord.norm[1]); zeus::CVector2f mouseCoord = zeus::CVector2f(kbm->m_mouseCoord.norm[0], kbm->m_mouseCoord.norm[1]);
zeus::CVector2f mouseDelta = mouseCoord - m_lastMouseCoord; zeus::CVector2f mouseDelta = mouseCoord - m_lastMouseCoord;
m_lastMouseCoord = mouseCoord; m_lastMouseCoord = mouseCoord;
mouseDelta.x() *= g_Viewport.aspect; mouseDelta.x() *= CGraphics::GetViewportAspect();
mouseDelta *= 100.f; mouseDelta *= 100.f;
if (kbm->m_mouseButtons[size_t(EMouseButton::Middle)] || if (kbm->m_mouseButtons[size_t(EMouseButton::Middle)] ||
kbm->m_mouseButtons[size_t(EMouseButton::Secondary)]) { kbm->m_mouseButtons[size_t(EMouseButton::Secondary)]) {

View File

@ -65,7 +65,7 @@ bool CPlayerVisor::DrawScanObjectIndicators(const CStateManager& mgr) const {
CGraphics::SetDepthRange(DEPTH_WORLD, DEPTH_FAR); CGraphics::SetDepthRange(DEPTH_WORLD, DEPTH_FAR);
g_Renderer->SetViewportOrtho(true, 0.f, 4096.f); g_Renderer->SetViewportOrtho(true, 0.f, 4096.f);
float vpScale = g_Viewport.xc_height / 448.f; float vpScale = CGraphics::GetViewportHeight() / 448.f;
CGraphics::SetModelMatrix(zeus::CTransform::Scale(x48_interpWindowDims.x() * 17.f * vpScale, 1.f, CGraphics::SetModelMatrix(zeus::CTransform::Scale(x48_interpWindowDims.x() * 17.f * vpScale, 1.f,
x48_interpWindowDims.y() * 17.f * vpScale)); x48_interpWindowDims.y() * 17.f * vpScale));
@ -75,11 +75,12 @@ bool CPlayerVisor::DrawScanObjectIndicators(const CStateManager& mgr) const {
zeus::CTransform camMtx = mgr.GetCameraManager()->GetCurrentCameraTransform(mgr); zeus::CTransform camMtx = mgr.GetCameraManager()->GetCurrentCameraTransform(mgr);
CGraphics::SetViewPointMatrix(camMtx); CGraphics::SetViewPointMatrix(camMtx);
zeus::CFrustum frustum; zeus::CFrustum frustum;
frustum.updatePlanes(camMtx, zeus::CProjection(zeus::SProjPersp( frustum.updatePlanes(
cam->GetFov(), g_Viewport.x8_width / float(g_Viewport.xc_height), 1.f, 100.f))); camMtx, zeus::CProjection(zeus::SProjPersp(
cam->GetFov(), CGraphics::GetViewportWidth() / float(CGraphics::GetViewportHeight()), 1.f, 100.f)));
g_Renderer->SetClippingPlanes(frustum); g_Renderer->SetClippingPlanes(frustum);
g_Renderer->SetPerspective(cam->GetFov(), g_Viewport.x8_width, g_Viewport.xc_height, cam->GetNearClipDistance(), g_Renderer->SetPerspective(cam->GetFov(), CGraphics::GetViewportWidth(), CGraphics::GetViewportHeight(),
cam->GetFarClipDistance()); cam->GetNearClipDistance(), cam->GetFarClipDistance());
for (const SScanTarget& tgt : x13c_scanTargets) { for (const SScanTarget& tgt : x13c_scanTargets) {
if (tgt.x4_timer == 0.f) if (tgt.x4_timer == 0.f)
@ -150,8 +151,8 @@ void CPlayerVisor::UpdateScanObjectIndicators(const CStateManager& mgr, float dt
const CGameCamera* cam = mgr.GetCameraManager()->GetCurrentCamera(mgr); const CGameCamera* cam = mgr.GetCameraManager()->GetCurrentCamera(mgr);
zeus::CVector3f orbitPos = act->GetOrbitPosition(mgr); zeus::CVector3f orbitPos = act->GetOrbitPosition(mgr);
orbitPos = cam->ConvertToScreenSpace(orbitPos); orbitPos = cam->ConvertToScreenSpace(orbitPos);
orbitPos.x() = orbitPos.x() * g_Viewport.x8_width / 2.f + g_Viewport.x8_width / 2.f; orbitPos.x() = orbitPos.x() * CGraphics::GetViewportWidth() / 2.f + CGraphics::GetViewportWidth() / 2.f;
orbitPos.y() = orbitPos.y() * g_Viewport.xc_height / 2.f + g_Viewport.xc_height / 2.f; orbitPos.y() = orbitPos.y() * CGraphics::GetViewportHeight() / 2.f + CGraphics::GetViewportHeight() / 2.f;
bool inBox = mgr.GetPlayer().WithinOrbitScreenBox(orbitPos, mgr.GetPlayer().GetOrbitZone(), bool inBox = mgr.GetPlayer().WithinOrbitScreenBox(orbitPos, mgr.GetPlayer().GetOrbitZone(),
mgr.GetPlayer().GetOrbitType()); mgr.GetPlayer().GetOrbitType());
if (inBox != tgt.xc_inBox) { if (inBox != tgt.xc_inBox) {
@ -344,7 +345,7 @@ void CPlayerVisor::DrawScanEffect(const CStateManager& mgr, CTargetingManager* t
t = (x3c_windowInterpTimer > scanSidesStart) ? 1.f : x3c_windowInterpTimer / scanSidesStart; t = (x3c_windowInterpTimer > scanSidesStart) ? 1.f : x3c_windowInterpTimer / scanSidesStart;
} }
const float vpScale = g_Viewport.xc_height / 448.f; const float vpScale = CGraphics::GetViewportHeight() / 448.f;
float divisor = (transFactor * ((1.f - t) * x58_scanMagInterp + t * g_tweakGui->GetScanWindowScanningAspect()) + float divisor = (transFactor * ((1.f - t) * x58_scanMagInterp + t * g_tweakGui->GetScanWindowScanningAspect()) +
(1.f - transFactor)); (1.f - transFactor));
divisor = 1.f / divisor; divisor = 1.f / divisor;
@ -354,8 +355,8 @@ void CPlayerVisor::DrawScanEffect(const CStateManager& mgr, CTargetingManager* t
vpH = zeus::clamp(0.f, vpH, 448.f) * vpScale; vpH = zeus::clamp(0.f, vpH, 448.f) * vpScale;
SClipScreenRect rect; SClipScreenRect rect;
rect.x4_left = int((g_Viewport.x8_width - vpW) / 2.f); rect.x4_left = int((CGraphics::GetViewportWidth() - vpW) / 2.f);
rect.x8_top = int((g_Viewport.xc_height - vpH) / 2.f); rect.x8_top = int((CGraphics::GetViewportHeight() - vpH) / 2.f);
rect.xc_width = int(vpW); rect.xc_width = int(vpW);
rect.x10_height = int(vpH); rect.x10_height = int(vpH);
CGraphics::ResolveSpareTexture(rect); CGraphics::ResolveSpareTexture(rect);
@ -368,23 +369,23 @@ void CPlayerVisor::DrawScanEffect(const CStateManager& mgr, CTargetingManager* t
const zeus::CTransform seventeenScale = zeus::CTransform::Scale(17.f * vpScale, 1.f, 17.f * vpScale); const zeus::CTransform seventeenScale = zeus::CTransform::Scale(17.f * vpScale, 1.f, 17.f * vpScale);
CGraphics::SetModelMatrix(seventeenScale * windowScale); CGraphics::SetModelMatrix(seventeenScale * windowScale);
const float uvX0 = float(rect.x4_left) / float(g_Viewport.x8_width); const float uvX0 = float(rect.x4_left) / float(CGraphics::GetViewportWidth());
const float uvX1 = float(rect.x4_left + rect.xc_width) / float(g_Viewport.x8_width); const float uvX1 = float(rect.x4_left + rect.xc_width) / float(CGraphics::GetViewportWidth());
const float uvY0 = float(rect.x8_top) / float(g_Viewport.xc_height); const float uvY0 = float(rect.x8_top) / float(CGraphics::GetViewportHeight());
const float uvY1 = float(rect.x8_top + rect.x10_height) / float(g_Viewport.xc_height); const float uvY1 = float(rect.x8_top + rect.x10_height) / float(CGraphics::GetViewportHeight());
std::array<CTexturedQuadFilter::Vert, 4> rttVerts{{ std::array<CTexturedQuadFilter::Vert, 4> rttVerts{{
{{-5.f, 0.f, 4.45f}, {uvX0, uvY0}}, {{-5.f, 0.f, 4.45f}, {uvX0, uvY0}},
{{5.f, 0.f, 4.45f}, {uvX1, uvY0}}, {{5.f, 0.f, 4.45f}, {uvX1, uvY0}},
{{-5.f, 0.f, -4.45f}, {uvX0, uvY1}}, {{-5.f, 0.f, -4.45f}, {uvX0, uvY1}},
{{5.f, 0.f, -4.45f}, {uvX1, uvY1}}, {{5.f, 0.f, -4.45f}, {uvX1, uvY1}},
}}; }};
// if (CGraphics::g_BooPlatform == boo::IGraphicsDataFactory::Platform::OpenGL) { // if (CGraphics::g_BooPlatform == boo::IGraphicsDataFactory::Platform::OpenGL) {
// rttVerts[0].m_uv.y() = uvY1; // rttVerts[0].m_uv.y() = uvY1;
// rttVerts[1].m_uv.y() = uvY1; // rttVerts[1].m_uv.y() = uvY1;
// rttVerts[2].m_uv.y() = uvY0; // rttVerts[2].m_uv.y() = uvY0;
// rttVerts[3].m_uv.y() = uvY0; // rttVerts[3].m_uv.y() = uvY0;
// } // }
// x108_newScanPane.drawVerts(zeus::CColor(1.f, transFactor), rttVerts); // x108_newScanPane.drawVerts(zeus::CColor(1.f, transFactor), rttVerts);
// No cull faces // No cull faces

View File

@ -317,7 +317,7 @@ void CSamusDoll::Draw(const CStateManager& mgr, float alpha) {
float itemPulse = zeus::clamp(0.f, (std::sin(5.f * CGraphics::GetSecondsMod900()) + 1.f) * 0.5f, 1.f) * float itemPulse = zeus::clamp(0.f, (std::sin(5.f * CGraphics::GetSecondsMod900()) + 1.f) * 0.5f, 1.f) *
(1.f - std::fabs(xc4_viewInterp)); (1.f - std::fabs(xc4_viewInterp));
g_Renderer->SetPerspective(55.f, g_Viewport.x8_width, g_Viewport.xc_height, 0.2f, 4096.f); g_Renderer->SetPerspective(55.f, CGraphics::GetViewportWidth(), CGraphics::GetViewportHeight(), 0.2f, 4096.f);
CGraphics::SetViewPointMatrix(zeus::CTransform(xb0_userRot, xa4_offset) * CGraphics::SetViewPointMatrix(zeus::CTransform(xb0_userRot, xa4_offset) *
zeus::CTransform::Translate(0.f, xc0_userZoom, 0.f)); zeus::CTransform::Translate(0.f, xc0_userZoom, 0.f));

View File

@ -1136,7 +1136,7 @@ void CSamusHud::Update(float dt, const CStateManager& mgr, CInGameGuiManager::EH
break; break;
} }
float scaleMul = 1.f - zeus::clamp(0.f, (g_Viewport.aspect - 1.33f) / (1.77f - 1.33f), 1.f); float scaleMul = 1.f - zeus::clamp(0.f, (CGraphics::GetViewportAspect() - 1.33f) / (1.77f - 1.33f), 1.f);
x500_viewportScale.y() = 1.f - scaleMul * morphT * g_tweakGui->GetBallViewportYReduction() * 1.2f; x500_viewportScale.y() = 1.f - scaleMul * morphT * g_tweakGui->GetBallViewportYReduction() * 1.2f;
if (x2b0_ballIntf) if (x2b0_ballIntf)
x2b0_ballIntf->SetBallModeFactor(morphT); x2b0_ballIntf->SetBallModeFactor(morphT);

View File

@ -184,7 +184,7 @@ void CPhazonBeam::Draw(bool drawSuitArm, const CStateManager& mgr, const zeus::C
bool drawIndirect = visor == CPlayerState::EPlayerVisor::Combat || visor == CPlayerState::EPlayerVisor::Scan; bool drawIndirect = visor == CPlayerState::EPlayerVisor::Combat || visor == CPlayerState::EPlayerVisor::Scan;
if (drawIndirect) { if (drawIndirect) {
CGraphics::ResolveSpareTexture(g_Viewport); CGraphics::ResolveSpareTexture(CGraphics::g_Viewport);
CModelFlags tmpFlags = flags; CModelFlags tmpFlags = flags;
// TODO tmpFlags.m_extendedShader = EExtendedShader::SolidColorBackfaceCullLEqualAlphaOnly; // TODO tmpFlags.m_extendedShader = EExtendedShader::SolidColorBackfaceCullLEqualAlphaOnly;
CGunWeapon::Draw(drawSuitArm, mgr, xf, tmpFlags, lights); CGunWeapon::Draw(drawSuitArm, mgr, xf, tmpFlags, lights);

View File

@ -2133,7 +2133,7 @@ zeus::CVector3f CPlayerGun::ConvertToScreenSpace(const zeus::CVector3f& pos, con
void CPlayerGun::CopyScreenTex() { void CPlayerGun::CopyScreenTex() {
// Copy lower right quadrant to gpCopyTexBuf as RGBA8 // Copy lower right quadrant to gpCopyTexBuf as RGBA8
CGraphics::ResolveSpareTexture(g_Viewport); CGraphics::ResolveSpareTexture(CGraphics::g_Viewport);
} }
void CPlayerGun::DrawScreenTex(float z) { void CPlayerGun::DrawScreenTex(float z) {

View File

@ -34,7 +34,7 @@ void CMorphBallShadow::RenderIdBuffer(const zeus::CAABox& aabb, const CStateMana
GatherAreas(mgr); GatherAreas(mgr);
SViewport backupVp = g_Viewport; SViewport backupVp = CGraphics::g_Viewport;
// g_Renderer->BindBallShadowIdTarget(); // g_Renderer->BindBallShadowIdTarget();
// CGraphics::g_BooMainCommandQueue->clearTarget(); // CGraphics::g_BooMainCommandQueue->clearTarget();

View File

@ -191,27 +191,27 @@ CModelData MakePlayerAnimRes(CAssetId resId, const zeus::CVector3f& scale) {
} }
uint32_t GetOrbitScreenBoxHalfExtentXScaled(int zone) { uint32_t GetOrbitScreenBoxHalfExtentXScaled(int zone) {
return g_tweakPlayer->GetOrbitScreenBoxHalfExtentX(zone) * g_Viewport.x8_width / 640; return g_tweakPlayer->GetOrbitScreenBoxHalfExtentX(zone) * CGraphics::GetViewportWidth() / 640;
} }
uint32_t GetOrbitScreenBoxHalfExtentYScaled(int zone) { uint32_t GetOrbitScreenBoxHalfExtentYScaled(int zone) {
return g_tweakPlayer->GetOrbitScreenBoxHalfExtentY(zone) * g_Viewport.xc_height / 448; return g_tweakPlayer->GetOrbitScreenBoxHalfExtentY(zone) * CGraphics::GetViewportHeight() / 448;
} }
uint32_t GetOrbitScreenBoxCenterXScaled(int zone) { uint32_t GetOrbitScreenBoxCenterXScaled(int zone) {
return g_tweakPlayer->GetOrbitScreenBoxCenterX(zone) * g_Viewport.x8_width / 640; return g_tweakPlayer->GetOrbitScreenBoxCenterX(zone) * CGraphics::GetViewportWidth() / 640;
} }
uint32_t GetOrbitScreenBoxCenterYScaled(int zone) { uint32_t GetOrbitScreenBoxCenterYScaled(int zone) {
return g_tweakPlayer->GetOrbitScreenBoxCenterY(zone) * g_Viewport.xc_height / 448; return g_tweakPlayer->GetOrbitScreenBoxCenterY(zone) * CGraphics::GetViewportHeight() / 448;
} }
uint32_t GetOrbitZoneIdealXScaled(int zone) { uint32_t GetOrbitZoneIdealXScaled(int zone) {
return g_tweakPlayer->GetOrbitZoneIdealX(zone) * g_Viewport.x8_width / 640; return g_tweakPlayer->GetOrbitZoneIdealX(zone) * CGraphics::GetViewportWidth() / 640;
} }
uint32_t GetOrbitZoneIdealYScaled(int zone) { uint32_t GetOrbitZoneIdealYScaled(int zone) {
return g_tweakPlayer->GetOrbitZoneIdealY(zone) * g_Viewport.xc_height / 448; return g_tweakPlayer->GetOrbitZoneIdealY(zone) * CGraphics::GetViewportHeight() / 448;
} }
} // Anonymous namespace } // Anonymous namespace
@ -4138,8 +4138,8 @@ bool CPlayer::ValidateAimTargetId(TUniqueId uid, CStateManager& mgr) {
if (act->GetMaterialList().HasMaterial(EMaterialTypes::Target) && uid != kInvalidUniqueId && if (act->GetMaterialList().HasMaterial(EMaterialTypes::Target) && uid != kInvalidUniqueId &&
ValidateObjectForMode(uid, mgr)) { ValidateObjectForMode(uid, mgr)) {
const float vpWHalf = g_Viewport.x8_width / 2; const float vpWHalf = CGraphics::GetViewportWidth() / 2;
const float vpHHalf = g_Viewport.xc_height / 2; const float vpHHalf = CGraphics::GetViewportHeight() / 2;
const zeus::CVector3f aimPos = act->GetAimPosition(mgr, 0.f); const zeus::CVector3f aimPos = act->GetAimPosition(mgr, 0.f);
const zeus::CVector3f eyePos = GetEyePosition(); const zeus::CVector3f eyePos = GetEyePosition();
zeus::CVector3f eyeToAim = aimPos - eyePos; zeus::CVector3f eyeToAim = aimPos - eyePos;
@ -4249,8 +4249,8 @@ TUniqueId CPlayer::CheckEnemiesAgainstOrbitZone(const EntityList& list, EPlayerZ
float minEyeToAimMag = 10000.f; float minEyeToAimMag = 10000.f;
float minPosInBoxMagSq = 10000.f; float minPosInBoxMagSq = 10000.f;
TUniqueId bestId = kInvalidUniqueId; TUniqueId bestId = kInvalidUniqueId;
const float vpWHalf = g_Viewport.x8_width / 2; const float vpWHalf = CGraphics::GetViewportWidth() / 2;
const float vpHHalf = g_Viewport.xc_height / 2; const float vpHHalf = CGraphics::GetViewportHeight() / 2;
const float boxLeft = (GetOrbitZoneIdealXScaled(int(info)) - vpWHalf) / vpWHalf; const float boxLeft = (GetOrbitZoneIdealXScaled(int(info)) - vpWHalf) / vpWHalf;
const float boxTop = (GetOrbitZoneIdealYScaled(int(info)) - vpHHalf) / vpHHalf; const float boxTop = (GetOrbitZoneIdealYScaled(int(info)) - vpHHalf) / vpHHalf;
const CFirstPersonCamera* fpCam = mgr.GetCameraManager()->GetFirstPersonCamera(); const CFirstPersonCamera* fpCam = mgr.GetCameraManager()->GetFirstPersonCamera();
@ -4346,8 +4346,8 @@ TUniqueId CPlayer::FindBestOrbitableObject(const std::vector<TUniqueId>& ids, EP
float minEyeToOrbitMag = 10000.f; float minEyeToOrbitMag = 10000.f;
float minPosInBoxMagSq = 10000.f; float minPosInBoxMagSq = 10000.f;
TUniqueId bestId = kInvalidUniqueId; TUniqueId bestId = kInvalidUniqueId;
const float vpWidthHalf = g_Viewport.x8_width / 2; const float vpWidthHalf = CGraphics::GetViewportWidth() / 2;
const float vpHeightHalf = g_Viewport.xc_height / 2; const float vpHeightHalf = CGraphics::GetViewportHeight() / 2;
const float boxLeft = (GetOrbitZoneIdealXScaled(int(info)) - vpWidthHalf) / vpWidthHalf; const float boxLeft = (GetOrbitZoneIdealXScaled(int(info)) - vpWidthHalf) / vpWidthHalf;
const float boxTop = (GetOrbitZoneIdealYScaled(int(info)) - vpHeightHalf) / vpHeightHalf; const float boxTop = (GetOrbitZoneIdealYScaled(int(info)) - vpHeightHalf) / vpHeightHalf;
@ -4497,8 +4497,8 @@ void CPlayer::FindOrbitableObjects(const EntityList& nearObjects, std::vector<TU
} }
const zeus::CVector3f orbitPos = act->GetOrbitPosition(mgr); const zeus::CVector3f orbitPos = act->GetOrbitPosition(mgr);
zeus::CVector3f screenPos = fpCam->ConvertToScreenSpace(orbitPos); zeus::CVector3f screenPos = fpCam->ConvertToScreenSpace(orbitPos);
screenPos.x() = g_Viewport.x8_width * screenPos.x() / 2.f + g_Viewport.x8_width / 2.f; screenPos.x() = CGraphics::GetViewportWidth() * screenPos.x() / 2.f + CGraphics::GetViewportWidth() / 2.f;
screenPos.y() = g_Viewport.xc_height * screenPos.y() / 2.f + g_Viewport.xc_height / 2.f; screenPos.y() = CGraphics::GetViewportHeight() * screenPos.y() / 2.f + CGraphics::GetViewportHeight() / 2.f;
bool pass = false; bool pass = false;
if (onScreenTest) { if (onScreenTest) {

View File

@ -63,7 +63,7 @@ void CWorldShadow::BuildLightShadowTexture(const CStateManager& mgr, TAreaId aid
frustum.updatePlanes(x4_view, zeus::SProjPersp(zeus::degToRad(fov), 1.f, 0.1f, distance + x64_objHalfExtent)); frustum.updatePlanes(x4_view, zeus::SProjPersp(zeus::degToRad(fov), 1.f, 0.1f, distance + x64_objHalfExtent));
g_Renderer->SetClippingPlanes(frustum); g_Renderer->SetClippingPlanes(frustum);
g_Renderer->SetPerspective(fov, m_shader.GetWidth(), m_shader.GetHeight(), 0.1f, 1000.f); g_Renderer->SetPerspective(fov, m_shader.GetWidth(), m_shader.GetHeight(), 0.1f, 1000.f);
SViewport backupVp = g_Viewport; SViewport backupVp = CGraphics::g_Viewport;
zeus::CVector2f backupDepthRange = CGraphics::g_CachedDepthRange; zeus::CVector2f backupDepthRange = CGraphics::g_CachedDepthRange;
m_shader.bindRenderTarget(); m_shader.bindRenderTarget();
g_Renderer->SetViewport(0, 0, m_shader.GetWidth(), m_shader.GetHeight()); g_Renderer->SetViewport(0, 0, m_shader.GetWidth(), m_shader.GetHeight());

View File

@ -289,7 +289,7 @@ void CWorldTransManager::DrawEnabled() {
else { else {
float t = zeus::clamp(0.f, (x0_curTime - x4_modelData->x1d0_dissolveStartTime) / 2.f, 1.f); float t = zeus::clamp(0.f, (x0_curTime - x4_modelData->x1d0_dissolveStartTime) / 2.f, 1.f);
DrawFirstPass(&lights); DrawFirstPass(&lights);
SClipScreenRect rect(g_Viewport); SClipScreenRect rect(CGraphics::g_Viewport);
CGraphics::ResolveSpareTexture(rect); CGraphics::ResolveSpareTexture(rect);
// CGraphics::g_BooMainCommandQueue->clearTarget(true, true); // CGraphics::g_BooMainCommandQueue->clearTarget(true, true);
DrawSecondPass(&lights); DrawSecondPass(&lights);
@ -317,7 +317,7 @@ void CWorldTransManager::DrawDisabled() {
void CWorldTransManager::DrawText() { void CWorldTransManager::DrawText() {
SCOPED_GRAPHICS_DEBUG_GROUP("CWorldTransManager::DrawText", zeus::skPurple); SCOPED_GRAPHICS_DEBUG_GROUP("CWorldTransManager::DrawText", zeus::skPurple);
float width = 448.f * g_Viewport.aspect; float width = 448.f * CGraphics::GetViewportAspect();
CGraphics::SetOrtho(0.f, width, 448.f, 0.f, -4096.f, 4096.f); CGraphics::SetOrtho(0.f, width, 448.f, 0.f, -4096.f, 4096.f);
CGraphics::SetViewPointMatrix(zeus::CTransform()); CGraphics::SetViewPointMatrix(zeus::CTransform());
CGraphics::SetModelMatrix(zeus::CTransform::Translate((width - 640.f) / 2.f, 0.f, 448.f)); CGraphics::SetModelMatrix(zeus::CTransform::Translate((width - 640.f) / 2.f, 0.f, 448.f));