Fix getViewPort returning incorrect results

This commit is contained in:
Vincent Robinson 2021-06-21 14:16:38 -07:00 committed by GitHub
parent b43f9b96e0
commit 78d1a3f73e
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
6 changed files with 38 additions and 8 deletions

@ -2099,6 +2099,13 @@ COGLES2Driver::~COGLES2Driver()
} }
void COGLES2Driver::setViewPortRaw(u32 width, u32 height)
{
CacheHandler->setViewport(0, 0, width, height);
ViewPort = core::recti(0, 0, width, height);
}
//! Draws a shadow volume into the stencil buffer. //! Draws a shadow volume into the stencil buffer.
void COGLES2Driver::drawStencilShadowVolume(const core::array<core::vector3df>& triangles, bool zfail, u32 debugDataVisible) void COGLES2Driver::drawStencilShadowVolume(const core::array<core::vector3df>& triangles, bool zfail, u32 debugDataVisible)
{ {
@ -2460,7 +2467,7 @@ COGLES2Driver::~COGLES2Driver()
destRenderTargetSize = renderTarget->getSize(); destRenderTargetSize = renderTarget->getSize();
CacheHandler->setViewport(0, 0, destRenderTargetSize.Width, destRenderTargetSize.Height); setViewPortRaw(destRenderTargetSize.Width, destRenderTargetSize.Height);
} }
else else
{ {
@ -2468,7 +2475,7 @@ COGLES2Driver::~COGLES2Driver()
destRenderTargetSize = core::dimension2d<u32>(0, 0); destRenderTargetSize = core::dimension2d<u32>(0, 0);
CacheHandler->setViewport(0, 0, ScreenSize.Width, ScreenSize.Height); setViewPortRaw(ScreenSize.Width, ScreenSize.Height);
} }
if (CurrentRenderTargetSize != destRenderTargetSize) if (CurrentRenderTargetSize != destRenderTargetSize)

@ -379,6 +379,9 @@ namespace video
bool setMaterialTexture(irr::u32 layerIdx, const irr::video::ITexture* texture); bool setMaterialTexture(irr::u32 layerIdx, const irr::video::ITexture* texture);
//! Same as `CacheHandler->setViewport`, but also sets `ViewPort`
virtual void setViewPortRaw(u32 width, u32 height);
COGLES2CacheHandler* CacheHandler; COGLES2CacheHandler* CacheHandler;
core::stringw Name; core::stringw Name;
core::stringc VendorName; core::stringc VendorName;

@ -2330,6 +2330,13 @@ void COGLES1Driver::setViewPort(const core::rect<s32>& area)
} }
void COGLES1Driver::setViewPortRaw(u32 width, u32 height)
{
CacheHandler->setViewport(0, 0, width, height);
ViewPort = core::recti(0, 0, width, height);
}
//! Draws a shadow volume into the stencil buffer. //! Draws a shadow volume into the stencil buffer.
void COGLES1Driver::drawStencilShadowVolume(const core::array<core::vector3df>& triangles, bool zfail, u32 debugDataVisible) void COGLES1Driver::drawStencilShadowVolume(const core::array<core::vector3df>& triangles, bool zfail, u32 debugDataVisible)
{ {
@ -2779,7 +2786,7 @@ bool COGLES1Driver::setRenderTargetEx(IRenderTarget* target, u16 clearFlag, SCol
destRenderTargetSize = renderTarget->getSize(); destRenderTargetSize = renderTarget->getSize();
CacheHandler->setViewport(0, 0, destRenderTargetSize.Width, destRenderTargetSize.Height); setViewPortRaw(destRenderTargetSize.Width, destRenderTargetSize.Height);
} }
else else
{ {
@ -2805,7 +2812,7 @@ bool COGLES1Driver::setRenderTargetEx(IRenderTarget* target, u16 clearFlag, SCol
destRenderTargetSize = core::dimension2d<u32>(0, 0); destRenderTargetSize = core::dimension2d<u32>(0, 0);
CacheHandler->setViewport(0, 0, ScreenSize.Width, ScreenSize.Height); setViewPortRaw(ScreenSize.Width, ScreenSize.Height);
} }
if (CurrentRenderTargetSize != destRenderTargetSize) if (CurrentRenderTargetSize != destRenderTargetSize)

@ -342,6 +342,9 @@ namespace video
//! \param[in] lightIndex: the index of the requesting light //! \param[in] lightIndex: the index of the requesting light
void assignHardwareLight(u32 lightIndex); void assignHardwareLight(u32 lightIndex);
//! Same as `CacheHandler->setViewport`, but also sets `ViewPort`
virtual void setViewPortRaw(u32 width, u32 height);
COGLES1CacheHandler* CacheHandler; COGLES1CacheHandler* CacheHandler;
core::stringw Name; core::stringw Name;

@ -3240,6 +3240,13 @@ void COpenGLDriver::setViewPort(const core::rect<s32>& area)
} }
void COpenGLDriver::setViewPortRaw(u32 width, u32 height)
{
CacheHandler->setViewport(0, 0, width, height);
ViewPort = core::recti(0, 0, width, height);
}
//! Draws a shadow volume into the stencil buffer. To draw a stencil shadow, do //! Draws a shadow volume into the stencil buffer. To draw a stencil shadow, do
//! this: First, draw all geometry. Then use this method, to draw the shadow //! this: First, draw all geometry. Then use this method, to draw the shadow
//! volume. Next use IVideoDriver::drawStencilShadow() to visualize the shadow. //! volume. Next use IVideoDriver::drawStencilShadow() to visualize the shadow.
@ -3872,7 +3879,7 @@ bool COpenGLDriver::setRenderTargetEx(IRenderTarget* target, u16 clearFlag, SCol
destRenderTargetSize = renderTarget->getSize(); destRenderTargetSize = renderTarget->getSize();
CacheHandler->setViewport(0, 0, destRenderTargetSize.Width, destRenderTargetSize.Height); setViewPortRaw(destRenderTargetSize.Width, destRenderTargetSize.Height);
} }
else else
{ {
@ -3898,7 +3905,7 @@ bool COpenGLDriver::setRenderTargetEx(IRenderTarget* target, u16 clearFlag, SCol
destRenderTargetSize = core::dimension2d<u32>(0, 0); destRenderTargetSize = core::dimension2d<u32>(0, 0);
CacheHandler->setViewport(0, 0, ScreenSize.Width, ScreenSize.Height); setViewPortRaw(ScreenSize.Width, ScreenSize.Height);
} }
if (CurrentRenderTargetSize != destRenderTargetSize) if (CurrentRenderTargetSize != destRenderTargetSize)
@ -3972,7 +3979,7 @@ IImage* COpenGLDriver::createScreenShot(video::ECOLOR_FORMAT format, video::E_RE
if (format==video::ECF_UNKNOWN) if (format==video::ECF_UNKNOWN)
format=getColorFormat(); format=getColorFormat();
// TODO: Maybe we could support more formats (floating point and some of those beyond ECF_R8), didn't really try yet // TODO: Maybe we could support more formats (floating point and some of those beyond ECF_R8), didn't really try yet
if (IImage::isCompressedFormat(format) || IImage::isDepthFormat(format) || IImage::isFloatingPointFormat(format) || format >= ECF_R8) if (IImage::isCompressedFormat(format) || IImage::isDepthFormat(format) || IImage::isFloatingPointFormat(format) || format >= ECF_R8)
return 0; return 0;

@ -428,7 +428,7 @@ namespace video
virtual ITexture* createDeviceDependentTexture(const io::path& name, IImage* image) _IRR_OVERRIDE_; virtual ITexture* createDeviceDependentTexture(const io::path& name, IImage* image) _IRR_OVERRIDE_;
virtual ITexture* createDeviceDependentTextureCubemap(const io::path& name, const core::array<IImage*>& image) _IRR_OVERRIDE_; virtual ITexture* createDeviceDependentTextureCubemap(const io::path& name, const core::array<IImage*>& image) _IRR_OVERRIDE_;
//! creates a transposed matrix in supplied GLfloat array to pass to OpenGL //! creates a transposed matrix in supplied GLfloat array to pass to OpenGL
inline void getGLMatrix(GLfloat gl_matrix[16], const core::matrix4& m); inline void getGLMatrix(GLfloat gl_matrix[16], const core::matrix4& m);
inline void getGLTextureMatrix(GLfloat gl_matrix[16], const core::matrix4& m); inline void getGLTextureMatrix(GLfloat gl_matrix[16], const core::matrix4& m);
@ -456,6 +456,9 @@ namespace video
void renderArray(const void* indexList, u32 primitiveCount, void renderArray(const void* indexList, u32 primitiveCount,
scene::E_PRIMITIVE_TYPE pType, E_INDEX_TYPE iType); scene::E_PRIMITIVE_TYPE pType, E_INDEX_TYPE iType);
//! Same as `CacheHandler->setViewport`, but also sets `ViewPort`
virtual void setViewPortRaw(u32 width, u32 height);
COpenGLCacheHandler* CacheHandler; COpenGLCacheHandler* CacheHandler;
core::stringw Name; core::stringw Name;