mirror of
https://github.com/blawar/GLideN64.git
synced 2024-07-07 03:13:49 +00:00
Replace FrameBufferList::isFboMode() check by FrameBufferList::getCurrent() != NULL
This commit is contained in:
parent
ea4d320809
commit
dfabb7d105
|
@ -243,7 +243,6 @@ void FrameBufferList::init()
|
||||||
void FrameBufferList::destroy() {
|
void FrameBufferList::destroy() {
|
||||||
m_list.clear();
|
m_list.clear();
|
||||||
m_pCurrent = NULL;
|
m_pCurrent = NULL;
|
||||||
m_drawBuffer = GL_BACK;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void FrameBufferList::setBufferChanged()
|
void FrameBufferList::setBufferChanged()
|
||||||
|
@ -327,7 +326,6 @@ void FrameBufferList::saveBuffer(u32 _address, u16 _format, u16 _size, u16 _widt
|
||||||
if (VI.width == 0 || VI.height == 0 || _height == 0) // H width is zero. Don't save
|
if (VI.width == 0 || VI.height == 0 || _height == 0) // H width is zero. Don't save
|
||||||
return;
|
return;
|
||||||
OGLVideo & ogl = video();
|
OGLVideo & ogl = video();
|
||||||
m_drawBuffer = GL_FRAMEBUFFER;
|
|
||||||
if (m_pCurrent != NULL && gDP.colorImage.height > 0) {
|
if (m_pCurrent != NULL && gDP.colorImage.height > 0) {
|
||||||
if (m_pCurrent->m_width == VI.width)
|
if (m_pCurrent->m_width == VI.width)
|
||||||
gDP.colorImage.height = min(gDP.colorImage.height, VI.height);
|
gDP.colorImage.height = min(gDP.colorImage.height, VI.height);
|
||||||
|
|
|
@ -54,7 +54,6 @@ public:
|
||||||
FrameBuffer * findTmpBuffer(u32 _address);
|
FrameBuffer * findTmpBuffer(u32 _address);
|
||||||
FrameBuffer * getCurrent() const {return m_pCurrent;}
|
FrameBuffer * getCurrent() const {return m_pCurrent;}
|
||||||
void renderBuffer(u32 _address);
|
void renderBuffer(u32 _address);
|
||||||
bool isFboMode() const {return m_drawBuffer == GL_FRAMEBUFFER;}
|
|
||||||
void setBufferChanged();
|
void setBufferChanged();
|
||||||
void setNeedHeightCorrection(bool _needCorrection);
|
void setNeedHeightCorrection(bool _needCorrection);
|
||||||
void correctHeight();
|
void correctHeight();
|
||||||
|
@ -67,7 +66,7 @@ public:
|
||||||
}
|
}
|
||||||
|
|
||||||
private:
|
private:
|
||||||
FrameBufferList() : m_pCurrent(NULL), m_drawBuffer(GL_BACK) {}
|
FrameBufferList() : m_pCurrent(NULL) {}
|
||||||
FrameBufferList(const FrameBufferList &);
|
FrameBufferList(const FrameBufferList &);
|
||||||
|
|
||||||
FrameBuffer * _findBuffer(u32 _startAddress, u32 _endAddress, u32 _width);
|
FrameBuffer * _findBuffer(u32 _startAddress, u32 _endAddress, u32 _width);
|
||||||
|
@ -75,7 +74,6 @@ private:
|
||||||
typedef std::list<FrameBuffer> FrameBuffers;
|
typedef std::list<FrameBuffer> FrameBuffers;
|
||||||
FrameBuffers m_list;
|
FrameBuffers m_list;
|
||||||
FrameBuffer * m_pCurrent;
|
FrameBuffer * m_pCurrent;
|
||||||
GLenum m_drawBuffer;
|
|
||||||
};
|
};
|
||||||
|
|
||||||
struct PBOBinder {
|
struct PBOBinder {
|
||||||
|
|
56
OpenGL.cpp
56
OpenGL.cpp
|
@ -575,14 +575,15 @@ void OGLRender::_updateCullFace() const
|
||||||
void OGLRender::_updateViewport() const
|
void OGLRender::_updateViewport() const
|
||||||
{
|
{
|
||||||
OGLVideo & ogl = video();
|
OGLVideo & ogl = video();
|
||||||
if (!frameBufferList().isFboMode()) {
|
FrameBuffer * pCurrentBuffer = frameBufferList().getCurrent();
|
||||||
|
if (pCurrentBuffer == NULL) {
|
||||||
const GLint X = gSP.viewport.vscale[0] < 0 ? (GLint)((gSP.viewport.x + gSP.viewport.vscale[0] * 2.0f) * ogl.getScaleX()) : (GLint)(gSP.viewport.x * ogl.getScaleX());
|
const GLint X = gSP.viewport.vscale[0] < 0 ? (GLint)((gSP.viewport.x + gSP.viewport.vscale[0] * 2.0f) * ogl.getScaleX()) : (GLint)(gSP.viewport.x * ogl.getScaleX());
|
||||||
const GLint Y = gSP.viewport.vscale[1] < 0 ? (GLint)((gSP.viewport.y + gSP.viewport.vscale[1] * 2.0f) * ogl.getScaleY()) : (GLint)((VI.height - (gSP.viewport.y + gSP.viewport.height)) * ogl.getScaleY());
|
const GLint Y = gSP.viewport.vscale[1] < 0 ? (GLint)((gSP.viewport.y + gSP.viewport.vscale[1] * 2.0f) * ogl.getScaleY()) : (GLint)((VI.height - (gSP.viewport.y + gSP.viewport.height)) * ogl.getScaleY());
|
||||||
glViewport( X, Y + ogl.getHeightOffset(),
|
glViewport( X, Y + ogl.getHeightOffset(),
|
||||||
max((GLint)(gSP.viewport.width * ogl.getScaleX()), 0), max((GLint)(gSP.viewport.height * ogl.getScaleY()), 0) );
|
max((GLint)(gSP.viewport.width * ogl.getScaleX()), 0), max((GLint)(gSP.viewport.height * ogl.getScaleY()), 0) );
|
||||||
} else {
|
} else {
|
||||||
const GLint X = gSP.viewport.vscale[0] < 0 ? (GLint)((gSP.viewport.x + gSP.viewport.vscale[0] * 2.0f) * ogl.getScaleX()) : (GLint)(gSP.viewport.x * ogl.getScaleX());
|
const GLint X = gSP.viewport.vscale[0] < 0 ? (GLint)((gSP.viewport.x + gSP.viewport.vscale[0] * 2.0f) * ogl.getScaleX()) : (GLint)(gSP.viewport.x * ogl.getScaleX());
|
||||||
const GLint Y = gSP.viewport.vscale[1] < 0 ? (GLint)((gSP.viewport.y + gSP.viewport.vscale[1] * 2.0f) * ogl.getScaleY()) : (GLint)((frameBufferList().getCurrent()->m_height - (gSP.viewport.y + gSP.viewport.height)) * ogl.getScaleY());
|
const GLint Y = gSP.viewport.vscale[1] < 0 ? (GLint)((gSP.viewport.y + gSP.viewport.vscale[1] * 2.0f) * ogl.getScaleY()) : (GLint)((pCurrentBuffer->m_height - (gSP.viewport.y + gSP.viewport.height)) * ogl.getScaleY());
|
||||||
glViewport(X, Y,
|
glViewport(X, Y,
|
||||||
max((GLint)(gSP.viewport.width * ogl.getScaleX()), 0), max((GLint)(gSP.viewport.height * ogl.getScaleY()), 0) );
|
max((GLint)(gSP.viewport.width * ogl.getScaleX()), 0), max((GLint)(gSP.viewport.height * ogl.getScaleY()), 0) );
|
||||||
}
|
}
|
||||||
|
@ -653,9 +654,9 @@ void OGLRender::_updateStates() const
|
||||||
}
|
}
|
||||||
|
|
||||||
if (gDP.changed & CHANGED_SCISSOR) {
|
if (gDP.changed & CHANGED_SCISSOR) {
|
||||||
FrameBufferList & fbList = frameBufferList();
|
FrameBuffer * pCurrentBuffer = frameBufferList().getCurrent();
|
||||||
const u32 screenHeight = (fbList.getCurrent() == NULL || fbList.getCurrent()->m_height == 0 || !fbList.isFboMode()) ? VI.height : fbList.getCurrent()->m_height;
|
const u32 screenHeight = (pCurrentBuffer == NULL || pCurrentBuffer->m_height == 0) ? VI.height : pCurrentBuffer->m_height;
|
||||||
glScissor( (GLint)(gDP.scissor.ulx * ogl.getScaleX()), (GLint)((screenHeight - gDP.scissor.lry) * ogl.getScaleY() + (fbList.isFboMode() ? 0 : ogl.getHeightOffset())),
|
glScissor((GLint)(gDP.scissor.ulx * ogl.getScaleX()), (GLint)((screenHeight - gDP.scissor.lry) * ogl.getScaleY() + (pCurrentBuffer != NULL ? 0 : ogl.getHeightOffset())),
|
||||||
max((GLint)((gDP.scissor.lrx - gDP.scissor.ulx) * ogl.getScaleX()), 0), max((GLint)((gDP.scissor.lry - gDP.scissor.uly) * ogl.getScaleY()), 0) );
|
max((GLint)((gDP.scissor.lrx - gDP.scissor.ulx) * ogl.getScaleX()), 0), max((GLint)((gDP.scissor.lry - gDP.scissor.uly) * ogl.getScaleY()), 0) );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -773,16 +774,15 @@ void OGLRender::drawLLETriangle(u32 _numVtx)
|
||||||
_prepareDrawTriangle(false);
|
_prepareDrawTriangle(false);
|
||||||
glDisable(GL_CULL_FACE);
|
glDisable(GL_CULL_FACE);
|
||||||
|
|
||||||
FrameBufferList & fbList = frameBufferList();
|
|
||||||
FrameBuffer* pBuffer = fbList.getCurrent();
|
|
||||||
OGLVideo & ogl = video();
|
OGLVideo & ogl = video();
|
||||||
if (!fbList.isFboMode())
|
FrameBuffer * pCurrentBuffer = frameBufferList().getCurrent();
|
||||||
|
if (pCurrentBuffer == NULL)
|
||||||
glViewport( 0, ogl.getHeightOffset(), ogl.getScreenWidth(), ogl.getScreenHeight());
|
glViewport( 0, ogl.getHeightOffset(), ogl.getScreenWidth(), ogl.getScreenHeight());
|
||||||
else
|
else
|
||||||
glViewport(0, 0, pBuffer->m_width*pBuffer->m_scaleX, pBuffer->m_height*pBuffer->m_scaleY);
|
glViewport(0, 0, pCurrentBuffer->m_width*pCurrentBuffer->m_scaleX, pCurrentBuffer->m_height*pCurrentBuffer->m_scaleY);
|
||||||
|
|
||||||
const float scaleX = fbList.isFboMode() ? 1.0f / pBuffer->m_width : VI.rwidth;
|
const float scaleX = pCurrentBuffer != NULL ? 1.0f / pCurrentBuffer->m_width : VI.rwidth;
|
||||||
const float scaleY = fbList.isFboMode() ? 1.0f / pBuffer->m_height : VI.rheight;
|
const float scaleY = pCurrentBuffer != NULL ? 1.0f / pCurrentBuffer->m_height : VI.rheight;
|
||||||
|
|
||||||
for (u32 i = 0; i < _numVtx; ++i) {
|
for (u32 i = 0; i < _numVtx; ++i) {
|
||||||
SPVertex & vtx = triangles.vertices[i];
|
SPVertex & vtx = triangles.vertices[i];
|
||||||
|
@ -875,18 +875,17 @@ void OGLRender::drawRect(int _ulx, int _uly, int _lrx, int _lry, float *_pColor)
|
||||||
currentCombiner()->updateRenderState();
|
currentCombiner()->updateRenderState();
|
||||||
}
|
}
|
||||||
|
|
||||||
FrameBufferList & fbList = frameBufferList();
|
FrameBuffer * pCurrentBuffer = frameBufferList().getCurrent();
|
||||||
FrameBuffer* pBuffer = fbList.getCurrent();
|
|
||||||
OGLVideo & ogl = video();
|
OGLVideo & ogl = video();
|
||||||
if (!fbList.isFboMode())
|
if (pCurrentBuffer == NULL)
|
||||||
glViewport( 0, ogl.getHeightOffset(), ogl.getScreenWidth(), ogl.getScreenHeight());
|
glViewport( 0, ogl.getHeightOffset(), ogl.getScreenWidth(), ogl.getScreenHeight());
|
||||||
else {
|
else {
|
||||||
glViewport( 0, 0, pBuffer->m_width*pBuffer->m_scaleX, pBuffer->m_height*pBuffer->m_scaleY );
|
glViewport(0, 0, pCurrentBuffer->m_width*pCurrentBuffer->m_scaleX, pCurrentBuffer->m_height*pCurrentBuffer->m_scaleY);
|
||||||
}
|
}
|
||||||
glDisable(GL_CULL_FACE);
|
glDisable(GL_CULL_FACE);
|
||||||
|
|
||||||
const float scaleX = fbList.isFboMode() ? 1.0f/pBuffer->m_width : VI.rwidth;
|
const float scaleX = pCurrentBuffer != NULL ? 1.0f / pCurrentBuffer->m_width : VI.rwidth;
|
||||||
const float scaleY = fbList.isFboMode() ? 1.0f/pBuffer->m_height : VI.rheight;
|
const float scaleY = pCurrentBuffer != NULL ? 1.0f / pCurrentBuffer->m_height : VI.rheight;
|
||||||
const float Z = (gDP.otherMode.depthSource == G_ZS_PRIM) ? gDP.primDepth.z : gSP.viewport.nearz;
|
const float Z = (gDP.otherMode.depthSource == G_ZS_PRIM) ? gDP.primDepth.z : gSP.viewport.nearz;
|
||||||
const float W = 1.0f;
|
const float W = 1.0f;
|
||||||
m_rect[0].x = (float)_ulx * (2.0f * scaleX) - 1.0;
|
m_rect[0].x = (float)_ulx * (2.0f * scaleX) - 1.0;
|
||||||
|
@ -914,10 +913,10 @@ void OGLRender::drawRect(int _ulx, int _uly, int _lrx, int _lry, float *_pColor)
|
||||||
static
|
static
|
||||||
bool texturedRectShadowMap(const OGLRender::TexturedRectParams &)
|
bool texturedRectShadowMap(const OGLRender::TexturedRectParams &)
|
||||||
{
|
{
|
||||||
FrameBufferList & fb = frameBufferList();
|
FrameBuffer * pCurrentBuffer = frameBufferList().getCurrent();
|
||||||
if (fb.isFboMode()) {
|
if (pCurrentBuffer != NULL) {
|
||||||
if (gDP.textureImage.size == 2 && gDP.textureImage.address >= gDP.depthImageAddress && gDP.textureImage.address < (gDP.depthImageAddress + gDP.colorImage.width*gDP.colorImage.width * 6 / 4)) {
|
if (gDP.textureImage.size == 2 && gDP.textureImage.address >= gDP.depthImageAddress && gDP.textureImage.address < (gDP.depthImageAddress + gDP.colorImage.width*gDP.colorImage.width * 6 / 4)) {
|
||||||
fb.getCurrent()->m_pDepthBuffer->activateDepthBufferTexture(fb.getCurrent());
|
pCurrentBuffer->m_pDepthBuffer->activateDepthBufferTexture(pCurrentBuffer);
|
||||||
SetDepthFogCombiner();
|
SetDepthFogCombiner();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1006,9 +1005,9 @@ bool texturedRectMonochromeBackground(const OGLRender::TexturedRectParams & _par
|
||||||
{
|
{
|
||||||
if (gDP.textureImage.address >= gDP.colorImage.address && gDP.textureImage.address <= (gDP.colorImage.address + gDP.colorImage.width*gDP.colorImage.height * 2)) {
|
if (gDP.textureImage.address >= gDP.colorImage.address && gDP.textureImage.address <= (gDP.colorImage.address + gDP.colorImage.width*gDP.colorImage.height * 2)) {
|
||||||
#ifdef GL_IMAGE_TEXTURES_SUPPORT
|
#ifdef GL_IMAGE_TEXTURES_SUPPORT
|
||||||
FrameBufferList & fb = frameBufferList();
|
FrameBuffer * pCurrentBuffer = frameBufferList().getCurrent();
|
||||||
if (fb.isFboMode()) {
|
if (pCurrentBuffer != NULL) {
|
||||||
FrameBuffer_ActivateBufferTexture(0, fb.getCurrent());
|
FrameBuffer_ActivateBufferTexture(0, pCurrentBuffer);
|
||||||
SetMonochromeCombiner();
|
SetMonochromeCombiner();
|
||||||
return false;
|
return false;
|
||||||
} else
|
} else
|
||||||
|
@ -1048,17 +1047,16 @@ void OGLRender::drawTexturedRect(const TexturedRectParams & _params)
|
||||||
if (RSP.cmd == 0xE4 && texturedRectSpecial != NULL && texturedRectSpecial(_params))
|
if (RSP.cmd == 0xE4 && texturedRectSpecial != NULL && texturedRectSpecial(_params))
|
||||||
return;
|
return;
|
||||||
|
|
||||||
FrameBufferList & fbList = frameBufferList();
|
FrameBuffer * pCurrentBuffer = frameBufferList().getCurrent();
|
||||||
FrameBuffer* pBuffer = fbList.getCurrent();
|
|
||||||
OGLVideo & ogl = video();
|
OGLVideo & ogl = video();
|
||||||
if (!fbList.isFboMode())
|
if (pCurrentBuffer == NULL)
|
||||||
glViewport( 0, ogl.getHeightOffset(), ogl.getScreenWidth(), ogl.getScreenHeight());
|
glViewport( 0, ogl.getHeightOffset(), ogl.getScreenWidth(), ogl.getScreenHeight());
|
||||||
else
|
else
|
||||||
glViewport( 0, 0, pBuffer->m_width*pBuffer->m_scaleX, pBuffer->m_height*pBuffer->m_scaleY );
|
glViewport(0, 0, pCurrentBuffer->m_width*pCurrentBuffer->m_scaleX, pCurrentBuffer->m_height*pCurrentBuffer->m_scaleY);
|
||||||
glDisable( GL_CULL_FACE );
|
glDisable( GL_CULL_FACE );
|
||||||
|
|
||||||
const float scaleX = fbList.isFboMode() ? 1.0f/pBuffer->m_width : VI.rwidth;
|
const float scaleX = pCurrentBuffer != NULL ? 1.0f / pCurrentBuffer->m_width : VI.rwidth;
|
||||||
const float scaleY = fbList.isFboMode() ? 1.0f/pBuffer->m_height : VI.rheight;
|
const float scaleY = pCurrentBuffer != NULL ? 1.0f / pCurrentBuffer->m_height : VI.rheight;
|
||||||
const float Z = (gDP.otherMode.depthSource == G_ZS_PRIM) ? gDP.primDepth.z : gSP.viewport.nearz;
|
const float Z = (gDP.otherMode.depthSource == G_ZS_PRIM) ? gDP.primDepth.z : gSP.viewport.nearz;
|
||||||
const float W = 1.0f;
|
const float W = 1.0f;
|
||||||
m_rect[0].x = (float)_params.ulx * (2.0f * scaleX) - 1.0f;
|
m_rect[0].x = (float)_params.ulx * (2.0f * scaleX) - 1.0f;
|
||||||
|
|
8
gDP.cpp
8
gDP.cpp
|
@ -875,10 +875,10 @@ void gDPFillRDRAM(u32 address, s32 ulx, s32 uly, s32 lrx, s32 lry, u32 width, u3
|
||||||
{
|
{
|
||||||
if (g_bDepthClearOnly && color != DepthClearColor)
|
if (g_bDepthClearOnly && color != DepthClearColor)
|
||||||
return;
|
return;
|
||||||
FrameBufferList & fbList = frameBufferList();
|
FrameBuffer * pCurrentBuffer = frameBufferList().getCurrent();
|
||||||
if (fbList.isFboMode()) {
|
if (pCurrentBuffer != NULL) {
|
||||||
fbList.getCurrent()->m_cleared = true;
|
pCurrentBuffer->m_cleared = true;
|
||||||
fbList.getCurrent()->m_fillcolor = color;
|
pCurrentBuffer->m_fillcolor = color;
|
||||||
}
|
}
|
||||||
if (scissor) {
|
if (scissor) {
|
||||||
ulx = min(max((float)ulx, gDP.scissor.ulx), gDP.scissor.lrx);
|
ulx = min(max((float)ulx, gDP.scissor.ulx), gDP.scissor.lrx);
|
||||||
|
|
Loading…
Reference in New Issue
Block a user