Commit b41385a3 authored by hybrid's avatar hybrid

Mem leak fixed in d3d RTT code identified by vitek. Some redundant code...

Mem leak fixed in d3d RTT code identified by vitek. Some redundant code removed and OpenGL shader materials fixed for changing number of textures.

git-svn-id: svn://svn.code.sf.net/p/irrlicht/code/trunk@807 dfc29bdd-3216-0410-991c-e03cc46cb475
parent 03df110f
...@@ -256,6 +256,7 @@ void* CD3D8Texture::lock() ...@@ -256,6 +256,7 @@ void* CD3D8Texture::lock()
return 0; return 0;
} }
hr = Device->CopyRects(surface, NULL, 0, RTTSurface, NULL); hr = Device->CopyRects(surface, NULL, 0, RTTSurface, NULL);
surface->Release();
if(FAILED(hr)) if(FAILED(hr))
{ {
os::Printer::log("Could not lock DIRECT3D8 Texture.", ELL_ERROR); os::Printer::log("Could not lock DIRECT3D8 Texture.", ELL_ERROR);
......
...@@ -458,6 +458,7 @@ void* CD3D9Texture::lock() ...@@ -458,6 +458,7 @@ void* CD3D9Texture::lock()
return 0; return 0;
} }
hr = Device->GetRenderTargetData(surface, RTTSurface); hr = Device->GetRenderTargetData(surface, RTTSurface);
surface->Release();
if(FAILED(hr)) if(FAILED(hr))
{ {
os::Printer::log("Could not lock DIRECT3D9 Texture.", ELL_ERROR); os::Printer::log("Could not lock DIRECT3D9 Texture.", ELL_ERROR);
......
...@@ -625,8 +625,6 @@ void CGUIEditBox::draw() ...@@ -625,8 +625,6 @@ void CGUIEditBox::draw()
if (!skin) if (!skin)
return; return;
irr::video::IVideoDriver* driver = Environment->getVideoDriver();
frameRect = AbsoluteRect; frameRect = AbsoluteRect;
// draw the border // draw the border
......
...@@ -291,7 +291,6 @@ void CGUIFont::readPositions32bit(video::IImage* image, s32& lowerRightPositions ...@@ -291,7 +291,6 @@ void CGUIFont::readPositions32bit(video::IImage* image, s32& lowerRightPositions
s32 colorLowerRight = *(p+1); s32 colorLowerRight = *(p+1);
s32 colorBackGround = *(p+2); s32 colorBackGround = *(p+2);
s32 colorBackGroundTransparent = 0; // 0x00FFFFFF & colorBackGround; s32 colorBackGroundTransparent = 0; // 0x00FFFFFF & colorBackGround;
s32 colorFont = 0xFFFFFFFF;
*(p+1) = colorBackGround; *(p+1) = colorBackGround;
...@@ -375,7 +374,6 @@ void CGUIFont::readPositions16bit(video::IImage* image, s32& lowerRightPositions ...@@ -375,7 +374,6 @@ void CGUIFont::readPositions16bit(video::IImage* image, s32& lowerRightPositions
s16 colorLowerRight = *(p+1); s16 colorLowerRight = *(p+1);
s16 colorBackGround = *(p+2); s16 colorBackGround = *(p+2);
s16 colorBackGroundTransparent = 0; // 0x7FFF & colorBackGround; s16 colorBackGroundTransparent = 0; // 0x7FFF & colorBackGround;
u16 colorFont = 0xFFFF;
*(p+1) = colorBackGround; *(p+1) = colorBackGround;
......
...@@ -156,9 +156,8 @@ bool COpenGLDriver::initDriver(const core::dimension2d<s32>& screenSize, ...@@ -156,9 +156,8 @@ bool COpenGLDriver::initDriver(const core::dimension2d<s32>& screenSize,
COpenGLDriver::COpenGLDriver(const core::dimension2d<s32>& screenSize, bool fullscreen, bool stencilBuffer, CIrrDeviceMacOSX *device, io::IFileSystem* io, bool vsync, bool antiAlias) COpenGLDriver::COpenGLDriver(const core::dimension2d<s32>& screenSize, bool fullscreen, bool stencilBuffer, CIrrDeviceMacOSX *device, io::IFileSystem* io, bool vsync, bool antiAlias)
: CNullDriver(io, screenSize), COpenGLExtensionHandler(), : CNullDriver(io, screenSize), COpenGLExtensionHandler(),
CurrentRenderMode(ERM_NONE), ResetRenderStates(true), Transformation3DChanged(true), CurrentRenderMode(ERM_NONE), ResetRenderStates(true), Transformation3DChanged(true),
AntiAlias(antiAlias), AntiAlias(antiAlias), RenderTargetTexture(0), LastSetLight(-1),
LastSetLight(-1), RenderTargetTexture(0), ClockwiseWinding(true), CurrentRendertargetSize(0,0), ClockwiseWinding(true), _device(device)
CurrentRendertargetSize(0,0), _device(device)
{ {
#ifdef _DEBUG #ifdef _DEBUG
setDebugName("COpenGLDriver"); setDebugName("COpenGLDriver");
...@@ -175,10 +174,10 @@ COpenGLDriver::COpenGLDriver(const core::dimension2d<s32>& screenSize, bool full ...@@ -175,10 +174,10 @@ COpenGLDriver::COpenGLDriver(const core::dimension2d<s32>& screenSize, bool full
//! Linux constructor and init code //! Linux constructor and init code
COpenGLDriver::COpenGLDriver(const core::dimension2d<s32>& screenSize, bool fullscreen, bool stencilBuffer, io::IFileSystem* io, bool vsync, bool antiAlias) COpenGLDriver::COpenGLDriver(const core::dimension2d<s32>& screenSize, bool fullscreen, bool stencilBuffer, io::IFileSystem* io, bool vsync, bool antiAlias)
: CNullDriver(io, screenSize), COpenGLExtensionHandler(), : CNullDriver(io, screenSize), COpenGLExtensionHandler(),
CurrentRenderMode(ERM_NONE), ResetRenderStates(true), Transformation3DChanged(true), CurrentRenderMode(ERM_NONE), ResetRenderStates(true),
AntiAlias(antiAlias), Transformation3DChanged(true), AntiAlias(antiAlias),
LastSetLight(-1), RenderTargetTexture(0), ClockwiseWinding(true), RenderTargetTexture(0), LastSetLight(-1), CurrentRendertargetSize(0,0),
CurrentRendertargetSize(0,0) ClockwiseWinding(true)
{ {
#ifdef _DEBUG #ifdef _DEBUG
setDebugName("COpenGLDriver"); setDebugName("COpenGLDriver");
...@@ -211,10 +210,10 @@ COpenGLDriver::COpenGLDriver(const core::dimension2d<s32>& screenSize, bool full ...@@ -211,10 +210,10 @@ COpenGLDriver::COpenGLDriver(const core::dimension2d<s32>& screenSize, bool full
//! SDL constructor and init code //! SDL constructor and init code
COpenGLDriver::COpenGLDriver(const core::dimension2d<s32>& screenSize, bool fullscreen, bool stencilBuffer, io::IFileSystem* io, bool vsync, bool antiAlias) COpenGLDriver::COpenGLDriver(const core::dimension2d<s32>& screenSize, bool fullscreen, bool stencilBuffer, io::IFileSystem* io, bool vsync, bool antiAlias)
: CNullDriver(io, screenSize), COpenGLExtensionHandler(), : CNullDriver(io, screenSize), COpenGLExtensionHandler(),
CurrentRenderMode(ERM_NONE), ResetRenderStates(true), Transformation3DChanged(true), CurrentRenderMode(ERM_NONE), ResetRenderStates(true),
AntiAlias(antiAlias), Transformation3DChanged(true), AntiAlias(antiAlias),
LastSetLight(-1), RenderTargetTexture(0), ClockwiseWinding(true), RenderTargetTexture(0), LastSetLight(-1), CurrentRendertargetSize(0,0),
CurrentRendertargetSize(0,0) ClockwiseWinding(true)
{ {
#ifdef _DEBUG #ifdef _DEBUG
setDebugName("COpenGLDriver"); setDebugName("COpenGLDriver");
......
...@@ -19,7 +19,7 @@ namespace video ...@@ -19,7 +19,7 @@ namespace video
// Irrlicht Engine OpenGL render path normal map vertex shader // Irrlicht Engine OpenGL render path normal map vertex shader
// I guess it could be optimized a lot, because I wrote it in D3D ASM and // I guess it could be optimized a lot, because I wrote it in D3D ASM and
// transfered it 1:1 to OpenGL // transferred it 1:1 to OpenGL
const char OPENGL_NORMAL_MAP_VSH[] = const char OPENGL_NORMAL_MAP_VSH[] =
"!!ARBvp1.0\n"\ "!!ARBvp1.0\n"\
"#input\n"\ "#input\n"\
......
...@@ -19,7 +19,7 @@ namespace video ...@@ -19,7 +19,7 @@ namespace video
// Irrlicht Engine OpenGL render path parallax map vertex shader // Irrlicht Engine OpenGL render path parallax map vertex shader
// I guess it could be optimized a lot, because I wrote it in D3D ASM and // I guess it could be optimized a lot, because I wrote it in D3D ASM and
// transfered it 1:1 to OpenGL // transferred it 1:1 to OpenGL
const char OPENGL_PARALLAX_MAP_VSH[] = const char OPENGL_PARALLAX_MAP_VSH[] =
"!!ARBvp1.0\n"\ "!!ARBvp1.0\n"\
"#input\n"\ "#input\n"\
......
...@@ -132,13 +132,6 @@ void COpenGLSLMaterialRenderer::OnSetMaterial(video::SMaterial& material, ...@@ -132,13 +132,6 @@ void COpenGLSLMaterialRenderer::OnSetMaterial(video::SMaterial& material,
bool resetAllRenderstates, bool resetAllRenderstates,
video::IMaterialRendererServices* services) video::IMaterialRendererServices* services)
{ {
Driver->setTexture(3, material.Textures[3]);
Driver->setTexture(2, material.Textures[2]);
Driver->setTexture(1, material.Textures[1]);
Driver->setTexture(0, material.Textures[0]);
Driver->setBasicRenderStates(material, lastMaterial, resetAllRenderstates);
if (material.MaterialType != lastMaterial.MaterialType || resetAllRenderstates) if (material.MaterialType != lastMaterial.MaterialType || resetAllRenderstates)
{ {
if(Program) if(Program)
...@@ -148,7 +141,9 @@ void COpenGLSLMaterialRenderer::OnSetMaterial(video::SMaterial& material, ...@@ -148,7 +141,9 @@ void COpenGLSLMaterialRenderer::OnSetMaterial(video::SMaterial& material,
BaseMaterial->OnSetMaterial(material, material, true, this); BaseMaterial->OnSetMaterial(material, material, true, this);
} }
setBasicRenderStates(material, lastMaterial, resetAllRenderstates); for (u32 i=0; i<MATERIAL_MAX_TEXTURES; ++i)
Driver->setTexture(i, material.Textures[i]);
Driver->setBasicRenderStates(material, lastMaterial, resetAllRenderstates);
} }
......
...@@ -97,13 +97,6 @@ bool COpenGLShaderMaterialRenderer::OnRender(IMaterialRendererServices* service, ...@@ -97,13 +97,6 @@ bool COpenGLShaderMaterialRenderer::OnRender(IMaterialRendererServices* service,
void COpenGLShaderMaterialRenderer::OnSetMaterial(video::SMaterial& material, const video::SMaterial& lastMaterial, void COpenGLShaderMaterialRenderer::OnSetMaterial(video::SMaterial& material, const video::SMaterial& lastMaterial,
bool resetAllRenderstates, video::IMaterialRendererServices* services) bool resetAllRenderstates, video::IMaterialRendererServices* services)
{ {
Driver->setTexture(3, material.Textures[3]);
Driver->setTexture(2, material.Textures[2]);
Driver->setTexture(1, material.Textures[1]);
Driver->setTexture(0, material.Textures[0]);
Driver->setBasicRenderStates(material, lastMaterial, resetAllRenderstates);
if (material.MaterialType != lastMaterial.MaterialType || resetAllRenderstates) if (material.MaterialType != lastMaterial.MaterialType || resetAllRenderstates)
{ {
#ifdef GL_ARB_vertex_program #ifdef GL_ARB_vertex_program
...@@ -127,6 +120,10 @@ void COpenGLShaderMaterialRenderer::OnSetMaterial(video::SMaterial& material, co ...@@ -127,6 +120,10 @@ void COpenGLShaderMaterialRenderer::OnSetMaterial(video::SMaterial& material, co
if (BaseMaterial) if (BaseMaterial)
BaseMaterial->OnSetMaterial(material, material, true, services); BaseMaterial->OnSetMaterial(material, material, true, services);
} }
for (u32 i=0; i<MATERIAL_MAX_TEXTURES; ++i)
Driver->setTexture(i, material.Textures[i]);
Driver->setBasicRenderStates(material, lastMaterial, resetAllRenderstates);
} }
......
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