Commit 884ede4e authored by hybrid's avatar hybrid

Fix transformation matrices for OpenGL rendering after setRenderTarget.

Fix draw2DImage into RTT in BurningsVideo
Let ViewPorts unchanged if illegal viewport was given.

git-svn-id: svn://svn.code.sf.net/p/irrlicht/code/trunk@3490 dfc29bdd-3216-0410-991c-e03cc46cb475
parent 014272f2
......@@ -985,7 +985,8 @@ void CD3D9Driver::setViewPort(const core::rect<s32>& area)
core::rect<s32> vp = area;
core::rect<s32> rendert(0,0, getCurrentRenderTargetSize().Width, getCurrentRenderTargetSize().Height);
vp.clipAgainst(rendert);
if (vp.getHeight()>0 && vp.getWidth()>0)
{
D3DVIEWPORT9 viewPort;
viewPort.X = vp.UpperLeftCorner.X;
viewPort.Y = vp.UpperLeftCorner.Y;
......@@ -994,14 +995,12 @@ void CD3D9Driver::setViewPort(const core::rect<s32>& area)
viewPort.MinZ = 0.0f;
viewPort.MaxZ = 1.0f;
HRESULT hr = D3DERR_INVALIDCALL;
if (vp.getHeight()>0 && vp.getWidth()>0)
hr = pID3DDevice->SetViewport(&viewPort);
HRESULT hr = pID3DDevice->SetViewport(&viewPort);
if (FAILED(hr))
os::Printer::log("Failed setting the viewport.", ELL_WARNING);
else
ViewPort = vp;
}
}
......@@ -1576,12 +1575,12 @@ void CD3D9Driver::draw2DImage(const video::ITexture* texture,
s16 indices[6] = {0,1,2,0,2,3};
setActiveTexture(0, const_cast<video::ITexture*>(texture));
setRenderStates2DMode(useColor[0].getAlpha()<255 || useColor[1].getAlpha()<255 ||
useColor[2].getAlpha()<255 || useColor[3].getAlpha()<255,
true, useAlphaChannelOfTexture);
setActiveTexture(0, const_cast<video::ITexture*>(texture));
setVertexShader(EVT_STANDARD);
if (clipRect)
......
......@@ -3313,16 +3313,20 @@ void COpenGLDriver::setAmbientLight(const SColorf& color)
// method just a bit.
void COpenGLDriver::setViewPort(const core::rect<s32>& area)
{
if (area == ViewPort)
return;
core::rect<s32> vp = area;
core::rect<s32> rendert(0,0, getCurrentRenderTargetSize().Width, getCurrentRenderTargetSize().Height);
vp.clipAgainst(rendert);
if (vp.getHeight()>0 && vp.getWidth()>0)
{
glViewport(vp.UpperLeftCorner.X,
getCurrentRenderTargetSize().Height - vp.UpperLeftCorner.Y - vp.getHeight(),
vp.getWidth(), vp.getHeight());
ViewPort = vp;
}
}
......@@ -3863,6 +3867,8 @@ bool COpenGLDriver::setRenderTarget(video::ITexture* texture, bool clearBackBuff
CurrentTarget=ERT_FRAME_BUFFER;
glDrawBuffer(Doublebuffer?GL_BACK_LEFT:GL_FRONT_LEFT);
}
// we need to update the matrices due to the rendersize change.
Transformation3DChanged=true;
}
clearBuffers(clearBackBuffer, clearZBuffer, false, color);
......
......@@ -2241,10 +2241,10 @@ void CBurningVideoDriver::draw2DImage(const video::ITexture* texture, const core
#endif
if (useAlphaChannelOfTexture)
((CSoftwareTexture2*)texture)->getImage()->copyToWithAlpha(
BackBuffer, destPos, sourceRect, color, clipRect);
RenderTargetSurface, destPos, sourceRect, color, clipRect);
else
((CSoftwareTexture2*)texture)->getImage()->copyTo(
BackBuffer, destPos, sourceRect, clipRect);
RenderTargetSurface, destPos, sourceRect, clipRect);
}
}
......
......@@ -22,7 +22,7 @@ static bool testWithRenderTarget(video::E_DRIVER_TYPE driverType)
//draw the 256x256 water image on the rendertarget:
driver->setRenderTarget(RenderTarget,true,true,video::SColor(255,0,0,255));//Rendertarget background is blue
driver->draw2DImage(Image, core::position2d<s32>(0,0), core::recti(0,0,32,32));
driver->setRenderTarget(0);
driver->setRenderTarget(0, false);
//draw the rendertarget on screen:
//this should normally draw a 64x64 image containing a 32x32 image in the top left corner
......@@ -41,6 +41,9 @@ static bool testWithRenderTarget(video::E_DRIVER_TYPE driverType)
bool draw2DImage()
{
bool result = testWithRenderTarget(video::EDT_DIRECT3D9);
result &= testWithRenderTarget(video::EDT_DIRECT3D8);
result &= testWithRenderTarget(video::EDT_OPENGL);
result &= testWithRenderTarget(video::EDT_BURNINGSVIDEO);
result &= testWithRenderTarget(video::EDT_SOFTWARE);
return result;
}
tests/media/OpenGL-draw2DImageRTT.png

2.31 KB | W: | H:

tests/media/OpenGL-draw2DImageRTT.png

2.41 KB | W: | H:

tests/media/OpenGL-draw2DImageRTT.png
tests/media/OpenGL-draw2DImageRTT.png
tests/media/OpenGL-draw2DImageRTT.png
tests/media/OpenGL-draw2DImageRTT.png
  • 2-up
  • Swipe
  • Onion skin
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment