mirror of
https://github.com/blawar/GLideN64.git
synced 2024-07-04 10:03:36 +00:00
Update widescreen hack
This commit is contained in:
parent
3d67ac4630
commit
fe244c5560
|
@ -297,6 +297,8 @@ public:
|
|||
"uniform mediump vec2 uCacheShiftScale[2]; \n"
|
||||
"uniform mediump vec2 uVTrans; \n"
|
||||
"uniform mediump vec2 uVScale; \n"
|
||||
"uniform mediump vec2 uAdjustTrans; \n"
|
||||
"uniform mediump vec2 uAdjustScale; \n"
|
||||
"uniform lowp ivec2 uCacheFrameBuffer; \n"
|
||||
"OUT highp vec2 vTexCoord0; \n"
|
||||
"OUT highp vec2 vTexCoord1; \n"
|
||||
|
@ -337,6 +339,7 @@ public:
|
|||
" else { \n"
|
||||
" gl_Position.xy = gl_Position.xy * uVScale.xy + uVTrans.xy * gl_Position.ww; \n"
|
||||
" gl_Position.xy = floor(gl_Position.xy * vec2(4.0)) * vec2(0.25); \n"
|
||||
" gl_Position.xy = gl_Position.xy * uAdjustScale + gl_Position.ww * uAdjustTrans; \n"
|
||||
" } \n"
|
||||
" if ((aModify[1]) != 0.0) \n"
|
||||
" gl_Position.z *= gl_Position.w; \n"
|
||||
|
@ -377,6 +380,8 @@ public:
|
|||
"uniform mediump vec2 uScreenCoordsScale; \n"
|
||||
"uniform mediump vec2 uVTrans; \n"
|
||||
"uniform mediump vec2 uVScale; \n"
|
||||
"uniform mediump vec2 uAdjustTrans; \n"
|
||||
"uniform mediump vec2 uAdjustScale; \n"
|
||||
" \n"
|
||||
"OUT lowp float vNumLights; \n"
|
||||
"OUT lowp vec4 vShadeColor; \n"
|
||||
|
@ -399,6 +404,7 @@ public:
|
|||
" else { \n"
|
||||
" gl_Position.xy = gl_Position.xy * uVScale.xy + uVTrans.xy * gl_Position.ww; \n"
|
||||
" gl_Position.xy = floor(gl_Position.xy * vec2(4.0)) * vec2(0.25); \n"
|
||||
" gl_Position.xy = gl_Position.xy * uAdjustScale + gl_Position.ww * uAdjustTrans; \n"
|
||||
" } \n"
|
||||
" if ((aModify[1]) != 0.0) \n"
|
||||
" gl_Position.z *= gl_Position.w; \n"
|
||||
|
|
|
@ -609,17 +609,35 @@ public:
|
|||
UViewportInfo(GLuint _program) {
|
||||
LocateUniform(uVTrans);
|
||||
LocateUniform(uVScale);
|
||||
LocateUniform(uAdjustTrans);
|
||||
LocateUniform(uAdjustScale);
|
||||
}
|
||||
|
||||
void update(bool _force) override
|
||||
{
|
||||
const bool isOrthographicProjection = gSP.matrix.projection[3][2] == -1.f;
|
||||
float adjustTrans[2] = { 0.0f, 0.0f };
|
||||
float adjustScale[2] = { 1.0f, 1.0f };
|
||||
if (dwnd().isAdjustScreen() && (gDP.colorImage.width > VI.width * 98 / 100)) {
|
||||
if (isOrthographicProjection) {
|
||||
adjustScale[1] = 1.0f / dwnd().getAdjustScale();
|
||||
adjustTrans[1] = static_cast<f32>(gDP.colorImage.width) * 3.0f / 4.0f * (1.0f - adjustScale[1]) / 2.0f;
|
||||
} else {
|
||||
adjustScale[0] = dwnd().getAdjustScale();
|
||||
adjustTrans[0] = static_cast<f32>(gDP.colorImage.width) * (1.0f - adjustScale[0]) / 2.0f;
|
||||
}
|
||||
}
|
||||
uVTrans.set(gSP.viewport.vtrans[0], gSP.viewport.vtrans[1], _force);
|
||||
uVScale.set(gSP.viewport.vscale[0], -gSP.viewport.vscale[1], _force);
|
||||
uAdjustTrans.set(adjustTrans[0], adjustTrans[1], _force);
|
||||
uAdjustScale.set(adjustScale[0], adjustScale[1], _force);
|
||||
}
|
||||
|
||||
private:
|
||||
fv2Uniform uVTrans;
|
||||
fv2Uniform uVScale;
|
||||
fv2Uniform uAdjustTrans;
|
||||
fv2Uniform uAdjustScale;
|
||||
};
|
||||
|
||||
class UDepthScale : public UniformGroup
|
||||
|
|
|
@ -1035,8 +1035,11 @@ void GraphicsDrawer::drawRect(int _ulx, int _uly, int _lrx, int _lry)
|
|||
DisplayWindow & wnd = dwnd();
|
||||
if (wnd.isAdjustScreen() && (gDP.colorImage.width > VI.width * 98 / 100) && (static_cast<u32>(_lrx - _ulx) < VI.width * 9 / 10)) {
|
||||
const float scale = wnd.getAdjustScale();
|
||||
for (u32 i = 0; i < 4; ++i)
|
||||
const float offsetx = static_cast<f32>(gDP.colorImage.width) * (1.0f - scale) / 2.0f;
|
||||
for (u32 i = 0; i < 4; ++i) {
|
||||
m_rect[i].x *= scale;
|
||||
m_rect[i].x += offsetx;
|
||||
}
|
||||
}
|
||||
|
||||
Context::DrawRectParameters rectParams;
|
||||
|
@ -1414,8 +1417,11 @@ void GraphicsDrawer::drawTexturedRect(const TexturedRectParams & _params)
|
|||
((gDP.colorImage.width > VI.width * 98 / 100) && (static_cast<u32>(_params.lrx - _params.ulx) < VI.width * 9 / 10))))
|
||||
{
|
||||
const float scale = wnd.getAdjustScale();
|
||||
for (u32 i = 0; i < 4; ++i)
|
||||
const float offsetx = static_cast<f32>(gDP.colorImage.width) * (1.0f-scale) / 2.0f;
|
||||
for (u32 i = 0; i < 4; ++i) {
|
||||
m_rect[i].x *= scale;
|
||||
m_rect[i].x += offsetx;
|
||||
}
|
||||
}
|
||||
|
||||
m_rect[0].bc0 = 0.0f;
|
||||
|
|
12
src/gSP.cpp
12
src/gSP.cpp
|
@ -819,16 +819,6 @@ void gSPProcessVertex(u32 v, SPVertex * spVtx)
|
|||
|
||||
gSPTransformVertex<VNUM>(v, spVtx, gSP.matrix.combined );
|
||||
|
||||
if (dwnd().isAdjustScreen() && (gDP.colorImage.width > VI.width * 98 / 100)) {
|
||||
const f32 adjustScale = dwnd().getAdjustScale();
|
||||
for(int i = 0; i < VNUM; ++i) {
|
||||
SPVertex & vtx = spVtx[v+i];
|
||||
vtx.x *= adjustScale;
|
||||
if (gSP.matrix.projection[3][2] == -1.f)
|
||||
vtx.w *= adjustScale;
|
||||
}
|
||||
}
|
||||
|
||||
if (gSP.matrix.billboard)
|
||||
gSPBillboardVertex<VNUM>(v, spVtx);
|
||||
|
||||
|
@ -1665,7 +1655,9 @@ void gSPModifyVertex( u32 _vtx, u32 _where, u32 _val )
|
|||
if ((config.generalEmulation.hacks & hack_ModifyVertexXyInShader) == 0) {
|
||||
if (dwnd().isAdjustScreen()) {
|
||||
const f32 adjustScale = dwnd().getAdjustScale();
|
||||
const f32 adjustOffset = static_cast<f32>(VI.width) * (1.0f - adjustScale) / 2.0f;
|
||||
vtx0.x *= adjustScale;
|
||||
vtx0.x += adjustOffset;
|
||||
if (gSP.matrix.projection[3][2] == -1.f)
|
||||
vtx0.w *= adjustScale;
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue
Block a user