mirror of
https://github.com/blawar/GLideN64.git
synced 2024-07-02 09:03:37 +00:00
Invert y coordinate to align image origin with frame origin.
This commit is contained in:
parent
6b4ae04f5e
commit
bca21ed071
|
@ -99,7 +99,7 @@ bool _copyBufferFromRdram(u32 _address, u32* _dst, u32(*converter)(TSrc _c, bool
|
|||
const u32 y1 = _y0 + _height;
|
||||
for (u32 y = _y0; y < y1; ++y) {
|
||||
for (u32 x = _x0; x < _width; ++x) {
|
||||
idx = (x + (_height - y - 1)*_width) ^ _xor;
|
||||
idx = (x + y *_width) ^ _xor;
|
||||
if (idx >= bound)
|
||||
break;
|
||||
col = src[idx];
|
||||
|
@ -133,7 +133,7 @@ bool _copyPixelsFromRdram(u32 _address, const std::vector<u32> & _vecAddress, u3
|
|||
return false;
|
||||
col = src[idx];
|
||||
summ += col;
|
||||
_dst[(w + (_height - h)*_width) ^ _xor] = converter(col, _bCFB);
|
||||
_dst[(w + h * _width) ^ _xor] = converter(col, _bCFB);
|
||||
}
|
||||
|
||||
return summ != 0;
|
||||
|
@ -255,8 +255,8 @@ void RDRAMtoColorBuffer::copyFromRDRAM(u32 _address, bool _bCFB)
|
|||
m_pTexture->scaleT = 1.0f / (float)m_pTexture->realHeight;
|
||||
m_pTexture->shiftScaleS = 1.0f;
|
||||
m_pTexture->shiftScaleT = 1.0f;
|
||||
m_pTexture->offsetS = 0;
|
||||
m_pTexture->offsetT = (float)m_pTexture->height;
|
||||
m_pTexture->offsetS = 0.0f;
|
||||
m_pTexture->offsetT = 0.0f;
|
||||
textureCache().activateTexture(0, m_pTexture);
|
||||
|
||||
gDPTile tile0;
|
||||
|
|
|
@ -31,7 +31,7 @@ void writeToRdram(TSrc* _src, TDst* _dst, TDst(*converter)(TSrc _c), TSrc _testV
|
|||
u32 dsty = 0;
|
||||
for (; y < _height; ++y) {
|
||||
for (u32 x = 0; x < _width && numStored < _numPixels; ++x) {
|
||||
c = _src[x + (_height - y - 1)*_width];
|
||||
c = _src[x + y *_width];
|
||||
if (c != _testValue)
|
||||
_dst[(x + dsty*_width) ^ _xor] = converter(c);
|
||||
++numStored;
|
||||
|
|
|
@ -355,7 +355,7 @@ bool FrameBuffer::_initSubTexture(u32 _t)
|
|||
m_pSubTexture->clampS = pTile->clamps;
|
||||
m_pSubTexture->clampT = pTile->clampt;
|
||||
m_pSubTexture->offsetS = 0.0f;
|
||||
m_pSubTexture->offsetT = m_pSubTexture->clampHeight;
|
||||
m_pSubTexture->offsetT = 0.0f;
|
||||
|
||||
|
||||
_setAndAttachTexture(m_SubFBO, m_pSubTexture, _t, false);
|
||||
|
@ -372,7 +372,7 @@ CachedTexture * FrameBuffer::_getSubTexture(u32 _t)
|
|||
return m_pTexture;
|
||||
|
||||
s32 x0 = (s32)(m_pTexture->offsetS * m_scaleX);
|
||||
s32 y0 = (s32)(m_pTexture->offsetT * m_scaleY) - m_pSubTexture->realHeight;
|
||||
s32 y0 = (s32)(m_pTexture->offsetT * m_scaleY);
|
||||
s32 copyWidth = m_pSubTexture->realWidth;
|
||||
if (x0 + copyWidth > m_pTexture->realWidth)
|
||||
copyWidth = m_pTexture->realWidth - x0;
|
||||
|
@ -422,10 +422,10 @@ CachedTexture * FrameBuffer::getTexture(u32 _t)
|
|||
const u32 factor = m_width;
|
||||
if (m_loadType == LOADTYPE_TILE) {
|
||||
pTexture->offsetS = (float)(m_loadTileOrigin.uls + (shift % factor));
|
||||
pTexture->offsetT = (float)(m_height - (m_loadTileOrigin.ult + shift / factor));
|
||||
pTexture->offsetT = (float)(m_loadTileOrigin.ult + shift / factor);
|
||||
} else {
|
||||
pTexture->offsetS = (float)(shift % factor);
|
||||
pTexture->offsetT = (float)(m_height - shift / factor);
|
||||
pTexture->offsetT = (float)(shift / factor);
|
||||
}
|
||||
|
||||
if (!getDepthTexture && (gSP.textureTile[_t]->clamps == 0 || gSP.textureTile[_t]->clampt == 0))
|
||||
|
@ -460,7 +460,7 @@ CachedTexture * FrameBuffer::getTextureBG(u32 _t)
|
|||
m_pTexture->shiftScaleT = 1.0f;
|
||||
|
||||
m_pTexture->offsetS = gSP.bgImage.imageX;
|
||||
m_pTexture->offsetT = (float)m_height - gSP.bgImage.imageY;
|
||||
m_pTexture->offsetT = gSP.bgImage.imageY;
|
||||
return m_pTexture;
|
||||
}
|
||||
|
||||
|
@ -862,9 +862,9 @@ void FrameBufferList::_renderScreenSizeBuffer()
|
|||
|
||||
GraphicsDrawer::BlitOrCopyRectParams blitParams;
|
||||
blitParams.srcX0 = srcCoord[0];
|
||||
blitParams.srcY0 = srcCoord[1];
|
||||
blitParams.srcY0 = srcCoord[3];
|
||||
blitParams.srcX1 = srcCoord[2];
|
||||
blitParams.srcY1 = srcCoord[3];
|
||||
blitParams.srcY1 = srcCoord[1];
|
||||
blitParams.srcWidth = pBufferTexture->realWidth;
|
||||
blitParams.srcHeight = pBufferTexture->realHeight;
|
||||
blitParams.dstX0 = dstCoord[0];
|
||||
|
@ -1028,9 +1028,9 @@ void FrameBufferList::renderBuffer(u32 _address)
|
|||
|
||||
GraphicsDrawer::BlitOrCopyRectParams blitParams;
|
||||
blitParams.srcX0 = srcCoord[0];
|
||||
blitParams.srcY0 = srcCoord[1];
|
||||
blitParams.srcY0 = srcCoord[3];
|
||||
blitParams.srcX1 = srcCoord[2];
|
||||
blitParams.srcY1 = srcCoord[3];
|
||||
blitParams.srcY1 = srcCoord[1];
|
||||
blitParams.srcWidth = pBufferTexture->realWidth;
|
||||
blitParams.srcHeight = pBufferTexture->realHeight;
|
||||
blitParams.dstX0 = dstCoord[0];
|
||||
|
|
|
@ -251,8 +251,6 @@ public:
|
|||
"{ \n"
|
||||
" vec2 texCoordOut = texCoord*uCacheShiftScale[idx]; \n"
|
||||
" texCoordOut -= uTexOffset[idx]; \n"
|
||||
" if (uCacheFrameBuffer[idx] != 0) \n"
|
||||
" texCoordOut.t = -texCoordOut.t; \n"
|
||||
" return (uCacheOffset[idx] + texCoordOut)* uCacheScale[idx];\n"
|
||||
"} \n"
|
||||
" \n"
|
||||
|
@ -277,6 +275,7 @@ public:
|
|||
" if ((aModify[3]) != 0.0) \n"
|
||||
" vNumLights = 0.0; \n"
|
||||
" } \n"
|
||||
" gl_Position.y = -gl_Position.y; \n"
|
||||
" if (uFogUsage == 1) { \n"
|
||||
" lowp vec4 shadeColor = aColor; \n"
|
||||
" if (aPosition.z < -aPosition.w && aModify[1] == 0.0) \n"
|
||||
|
@ -331,6 +330,7 @@ public:
|
|||
" if ((aModify[3]) != 0.0) \n"
|
||||
" vNumLights = 0.0; \n"
|
||||
" } \n"
|
||||
" gl_Position.y = -gl_Position.y; \n"
|
||||
" if (uFogUsage == 1) { \n"
|
||||
" lowp float fp; \n"
|
||||
" if (aPosition.z < -aPosition.w && aModify[1] == 0.0) \n"
|
||||
|
@ -369,6 +369,7 @@ public:
|
|||
"{ \n"
|
||||
" gl_Position = aRectPosition; \n"
|
||||
" vShadeColor = uRectColor; \n"
|
||||
" gl_Position.y = -gl_Position.y; \n"
|
||||
" vTexCoord0 = aTexCoord0; \n"
|
||||
" vTexCoord1 = aTexCoord1; \n"
|
||||
;
|
||||
|
@ -397,6 +398,7 @@ public:
|
|||
"{ \n"
|
||||
" gl_Position = aRectPosition; \n"
|
||||
" vShadeColor = uRectColor; \n"
|
||||
" gl_Position.y = -gl_Position.y; \n"
|
||||
;
|
||||
if (!_glinfo.isGLESX) {
|
||||
m_part +=
|
||||
|
|
|
@ -93,8 +93,8 @@ namespace graphics {
|
|||
}
|
||||
|
||||
namespace cullMode {
|
||||
CullModeParam FRONT(GL_FRONT);
|
||||
CullModeParam BACK(GL_BACK);
|
||||
CullModeParam FRONT(GL_BACK);
|
||||
CullModeParam BACK(GL_FRONT);
|
||||
}
|
||||
|
||||
namespace compare {
|
||||
|
|
|
@ -186,11 +186,14 @@ void GraphicsDrawer::updateScissor(FrameBuffer * _pBuffer) const
|
|||
|
||||
f32 SX0 = gDP.scissor.ulx;
|
||||
f32 SX1 = gDP.scissor.lrx;
|
||||
f32 SY0 = gDP.scissor.uly;
|
||||
f32 SY1 = gDP.scissor.lry;
|
||||
if (_needAdjustCoordinate(wnd))
|
||||
_adjustScissorX(SX0, SX1, wnd.getAdjustScale());
|
||||
|
||||
gfxContext.setScissor((s32)(SX0 * scaleX), (s32)((screenHeight - gDP.scissor.lry) * scaleY),
|
||||
std::max((s32)((SX1 - SX0) * scaleX), 0), std::max((s32)((gDP.scissor.lry - gDP.scissor.uly) * scaleY), 0));
|
||||
gfxContext.setScissor((s32)(SX0 * scaleX), (s32)(SY0 * scaleY),
|
||||
std::max((s32)((SX1 - SX0) * scaleX), 0), std::max((s32)((SY1 - SY0) * scaleY), 0));
|
||||
|
||||
gDP.changed &= ~CHANGED_SCISSOR;
|
||||
}
|
||||
|
||||
|
@ -213,7 +216,8 @@ void GraphicsDrawer::_updateViewport() const
|
|||
if (_needAdjustCoordinate(wnd))
|
||||
Xf = _adjustViewportX(Xf);
|
||||
const s32 X = (s32)(Xf * scaleX);
|
||||
const s32 Y = gSP.viewport.vscale[1] < 0 ? (s32)((gSP.viewport.y + gSP.viewport.vscale[1] * 2.0f) * scaleY) : (s32)((VI.height - (gSP.viewport.y + gSP.viewport.height)) * scaleY);
|
||||
// const s32 Y = gSP.viewport.vscale[1] < 0 ? (s32)((gSP.viewport.y + gSP.viewport.vscale[1] * 2.0f) * scaleY) : (s32)((VI.height - (gSP.viewport.y + gSP.viewport.height)) * scaleY);
|
||||
const s32 Y = (s32)(gSP.viewport.y * scaleY);
|
||||
gfxContext.setViewport(X, Y,
|
||||
std::max((s32)(gSP.viewport.width * scaleX), 0), std::max((s32)(gSP.viewport.height * scaleY), 0));
|
||||
} else {
|
||||
|
@ -223,7 +227,8 @@ void GraphicsDrawer::_updateViewport() const
|
|||
if (_needAdjustCoordinate(wnd))
|
||||
Xf = _adjustViewportX(Xf);
|
||||
const s32 X = (s32)(Xf * scaleX);
|
||||
const s32 Y = gSP.viewport.vscale[1] < 0 ? (s32)((gSP.viewport.y + gSP.viewport.vscale[1] * 2.0f) * scaleY) : (s32)((pCurrentBuffer->m_height - (gSP.viewport.y + gSP.viewport.height)) * scaleY);
|
||||
// const s32 Y = gSP.viewport.vscale[1] < 0 ? (s32)((gSP.viewport.y + gSP.viewport.vscale[1] * 2.0f) * scaleY) : (s32)((pCurrentBuffer->m_height - (gSP.viewport.y + gSP.viewport.height)) * scaleY);
|
||||
const s32 Y = (s32)(gSP.viewport.y * scaleY);
|
||||
gfxContext.setViewport(X, Y,
|
||||
std::max((s32)(gSP.viewport.width * scaleX), 0), std::max((s32)(gSP.viewport.height * scaleY), 0));
|
||||
}
|
||||
|
@ -1094,7 +1099,7 @@ void GraphicsDrawer::drawTexturedRect(const TexturedRectParams & _params)
|
|||
lry = (float)_params.lry * (2.0f * scaleY) - 1.0f;
|
||||
} else {
|
||||
uly = (float)_params.uly * (-2.0f * scaleY) + 1.0f;
|
||||
lry = (float)(_params.lry) * (-2.0f * scaleY) + 1.0f;
|
||||
lry = (float)_params.lry * (-2.0f * scaleY) + 1.0f;
|
||||
// Flush text drawer
|
||||
if (m_texrectDrawer.draw())
|
||||
_updateStates(DrawingState::TexRect);
|
||||
|
@ -1143,9 +1148,9 @@ void GraphicsDrawer::drawTexturedRect(const TexturedRectParams & _params)
|
|||
|
||||
if (cache.current[t]->frameBufferTexture != CachedTexture::fbNone) {
|
||||
texST[t].s0 = cache.current[t]->offsetS + texST[t].s0;
|
||||
texST[t].t0 = cache.current[t]->offsetT - texST[t].t0;
|
||||
texST[t].t0 = cache.current[t]->offsetT + texST[t].t0;
|
||||
texST[t].s1 = cache.current[t]->offsetS + texST[t].s1;
|
||||
texST[t].t1 = cache.current[t]->offsetT - texST[t].t1;
|
||||
texST[t].t1 = cache.current[t]->offsetT + texST[t].t1;
|
||||
}
|
||||
|
||||
if (cache.current[t]->frameBufferTexture != CachedTexture::fbMultiSample) {
|
||||
|
@ -1383,9 +1388,9 @@ void GraphicsDrawer::copyTexturedRect(const CopyRectParams & _params)
|
|||
const float scaleX = 1.0f / _params.dstWidth;
|
||||
const float scaleY = 1.0f / _params.dstHeight;
|
||||
const float X0 = _params.dstX0 * (2.0f * scaleX) - 1.0f;
|
||||
const float Y0 = _params.dstY0 * (2.0f * scaleY) - 1.0f;
|
||||
const float Y0 = _params.dstY0 * (-2.0f * scaleY) + 1.0f;
|
||||
const float X1 = _params.dstX1 * (2.0f * scaleX) - 1.0f;
|
||||
const float Y1 = _params.dstY1 * (2.0f * scaleY) - 1.0f;
|
||||
const float Y1 = _params.dstY1 * (-2.0f * scaleY) + 1.0f;
|
||||
const float Z = 0.0f;
|
||||
const float W = 1.0f;
|
||||
|
||||
|
|
Loading…
Reference in New Issue
Block a user