Hi elvman,
Thirst of all you did a very nice work
, i've tried out different water shaders and your's is fitting best to my project. Unfortunately i got a problem with it. When i am using Opengl in linux and windows, respectively GLSL, everything is running fine. When i am using direct3d, respectively HLSL in windows, i am getting a effect of blackened water. Only a circle around the camera has the correct colour. This circle is getting bigger when i am zooming back with the camera and smaller when i zoom to the water. Sorry for the noobish description without technical terms, i don't know anything about shaders...
Besides of this i was running a valgrind check over my game in linux with the result of getting memory leaks from the water scene node. The valgrind output i am getting looks like this:
Invalid write of size 8
==26429== at 0x42E565: irr::scene::ISceneNode::removeAll() (ISceneNode.h:323)
==26429== by 0x42DAC0: irr::scene::ISceneNode::~ISceneNode() (ISceneNode.h:65)
==26429== by 0x42CA00: RealisticWaterSceneNode::~RealisticWaterSceneNode() (RealisticWater.cpp:51)
==26429== by 0x42CB29: RealisticWaterSceneNode::~RealisticWaterSceneNode() (RealisticWater.cpp:82)
==26429== by 0x421378: RunGame::~RunGame() (RunGame.cpp:126)
==26429== by 0x4214D3: RunGame::~RunGame() (RunGame.cpp:138)
==26429== by 0x43C9EE: main (main.cpp:38)
==26429== Address 0xde44ca8 is 136 bytes inside a block of size 504 free'd
==26429== at 0x4C27FF2: operator delete(void*) (vg_replace_malloc.c:387)
==26429== by 0x424C1B: irr::IReferenceCounted::drop() const (IReferenceCounted.h:124)
==26429== by 0x42C971: RealisticWaterSceneNode::~RealisticWaterSceneNode() (RealisticWater.cpp:73)
==26429== by 0x42CB29: RealisticWaterSceneNode::~RealisticWaterSceneNode() (RealisticWater.cpp:82)
==26429== by 0x421378: RunGame::~RunGame() (RunGame.cpp:126)
==26429== by 0x4214D3: RunGame::~RunGame() (RunGame.cpp:138)
==26429== by 0x43C9EE: main (main.cpp:38)
==26429==
==26429== Invalid read of size 8
==26429== at 0x42E57F: irr::scene::ISceneNode::removeAll() (ISceneNode.h:324)
==26429== by 0x42DAC0: irr::scene::ISceneNode::~ISceneNode() (ISceneNode.h:65)
==26429== by 0x42CA00: RealisticWaterSceneNode::~RealisticWaterSceneNode() (RealisticWater.cpp:51)
==26429== by 0x42CB29: RealisticWaterSceneNode::~RealisticWaterSceneNode() (RealisticWater.cpp:82)
==26429== by 0x421378: RunGame::~RunGame() (RunGame.cpp:126)
==26429== by 0x4214D3: RunGame::~RunGame() (RunGame.cpp:138)
==26429== by 0x43C9EE: main (main.cpp:38)
==26429== Address 0xde44c20 is 0 bytes inside a block of size 504 free'd
==26429== at 0x4C27FF2: operator delete(void*) (vg_replace_malloc.c:387)
==26429== by 0x424C1B: irr::IReferenceCounted::drop() const (IReferenceCounted.h:124)
==26429== by 0x42C971: RealisticWaterSceneNode::~RealisticWaterSceneNode() (RealisticWater.cpp:73)
==26429== by 0x42CB29: RealisticWaterSceneNode::~RealisticWaterSceneNode() (RealisticWater.cpp:82)
==26429== by 0x421378: RunGame::~RunGame() (RunGame.cpp:126)
==26429== by 0x4214D3: RunGame::~RunGame() (RunGame.cpp:138)
==26429== by 0x43C9EE: main (main.cpp:38)
==26429==
==26429== Invalid read of size 4
==26429== at 0x424BE6: irr::IReferenceCounted::drop() const (IReferenceCounted.h:121)
==26429== by 0x42E593: irr::scene::ISceneNode::removeAll() (ISceneNode.h:324)
==26429== by 0x42DAC0: irr::scene::ISceneNode::~ISceneNode() (ISceneNode.h:65)
==26429== by 0x42CA00: RealisticWaterSceneNode::~RealisticWaterSceneNode() (RealisticWater.cpp:51)
==26429== by 0x42CB29: RealisticWaterSceneNode::~RealisticWaterSceneNode() (RealisticWater.cpp:82)
==26429== by 0x421378: RunGame::~RunGame() (RunGame.cpp:126)
==26429== by 0x4214D3: RunGame::~RunGame() (RunGame.cpp:138)
==26429== by 0x43C9EE: main (main.cpp:38)
==26429== Address 0xde44e10 is 496 bytes inside a block of size 504 free'd
==26429== at 0x4C27FF2: operator delete(void*) (vg_replace_malloc.c:387)
==26429== by 0x424C1B: irr::IReferenceCounted::drop() const (IReferenceCounted.h:124)
==26429== by 0x42C971: RealisticWaterSceneNode::~RealisticWaterSceneNode() (RealisticWater.cpp:73)
==26429== by 0x42CB29: RealisticWaterSceneNode::~RealisticWaterSceneNode() (RealisticWater.cpp:82)
==26429== by 0x421378: RunGame::~RunGame() (RunGame.cpp:126)
==26429== by 0x4214D3: RunGame::~RunGame() (RunGame.cpp:138)
==26429== by 0x43C9EE: main (main.cpp:38)
==26429==
==26429== Invalid write of size 4
==26429== at 0x424BF0: irr::IReferenceCounted::drop() const (IReferenceCounted.h:121)
==26429== by 0x42E593: irr::scene::ISceneNode::removeAll() (ISceneNode.h:324)
==26429== by 0x42DAC0: irr::scene::ISceneNode::~ISceneNode() (ISceneNode.h:65)
==26429== by 0x42CA00: RealisticWaterSceneNode::~RealisticWaterSceneNode() (RealisticWater.cpp:51)
==26429== by 0x42CB29: RealisticWaterSceneNode::~RealisticWaterSceneNode() (RealisticWater.cpp:82)
==26429== by 0x421378: RunGame::~RunGame() (RunGame.cpp:126)
==26429== by 0x4214D3: RunGame::~RunGame() (RunGame.cpp:138)
==26429== by 0x43C9EE: main (main.cpp:38)
==26429== Address 0xde44e10 is 496 bytes inside a block of size 504 free'd
==26429== at 0x4C27FF2: operator delete(void*) (vg_replace_malloc.c:387)
==26429== by 0x424C1B: irr::IReferenceCounted::drop() const (IReferenceCounted.h:124)
==26429== by 0x42C971: RealisticWaterSceneNode::~RealisticWaterSceneNode() (RealisticWater.cpp:73)
==26429== by 0x42CB29: RealisticWaterSceneNode::~RealisticWaterSceneNode() (RealisticWater.cpp:82)
==26429== by 0x421378: RunGame::~RunGame() (RunGame.cpp:126)
==26429== by 0x4214D3: RunGame::~RunGame() (RunGame.cpp:138)
==26429== by 0x43C9EE: main (main.cpp:38)
==26429==
==26429== Invalid read of size 4
==26429== at 0x424BF7: irr::IReferenceCounted::drop() const (IReferenceCounted.h:122)
==26429== by 0x42E593: irr::scene::ISceneNode::removeAll() (ISceneNode.h:324)
==26429== by 0x42DAC0: irr::scene::ISceneNode::~ISceneNode() (ISceneNode.h:65)
==26429== by 0x42CA00: RealisticWaterSceneNode::~RealisticWaterSceneNode() (RealisticWater.cpp:51)
==26429== by 0x42CB29: RealisticWaterSceneNode::~RealisticWaterSceneNode() (RealisticWater.cpp:82)
==26429== by 0x421378: RunGame::~RunGame() (RunGame.cpp:126)
==26429== by 0x4214D3: RunGame::~RunGame() (RunGame.cpp:138)
==26429== by 0x43C9EE: main (main.cpp:38)
==26429== Address 0xde44e10 is 496 bytes inside a block of size 504 free'd
==26429== at 0x4C27FF2: operator delete(void*) (vg_replace_malloc.c:387)
==26429== by 0x424C1B: irr::IReferenceCounted::drop() const (IReferenceCounted.h:124)
==26429== by 0x42C971: RealisticWaterSceneNode::~RealisticWaterSceneNode() (RealisticWater.cpp:73)
==26429== by 0x42CB29: RealisticWaterSceneNode::~RealisticWaterSceneNode() (RealisticWater.cpp:82)
==26429== by 0x421378: RunGame::~RunGame() (RunGame.cpp:126)
==26429== by 0x4214D3: RunGame::~RunGame() (RunGame.cpp:138)
==26429== by 0x43C9EE: main (main.cpp:38)
These lines (126 - 138) are located at my RunGame.cpp destructor, 126 shows where i am deleting the object:
Code: Select all
if (m_pWater != NULL) {
delete m_pWater;
m_pWater = NULL;
}
I used a member pointer for RealicWaterSceneNode since it has to be allocated on the heap as as showed in the example:
Code: Select all
m_pWater = new RealisticWaterSceneNode(m_pSceneMgr, (MAP_SCALE * MAP_CHUNK_SIZE) * 3, (MAP_SCALE * MAP_CHUNK_SIZE) * 3, m_pDriver->getTexture("./graphics/data/waterbump.png"),
dimension2du(m_pGameData->WaterQuality, m_pGameData->WaterQuality), m_pSceneMgr->getRootSceneNode(), -1);
If i take a look at the decumentation of the functions in RealisticWater.cpp i see following:
This pointer should not be dropped. See IReferenceCounted::drop() for more information.
When i empty the destructor of RealisticWater.cpp i am getting no erros from valgrind anymore.
Sorry for my potentially bad english and nice work anyways
Greets Sinsemilla