[fixed]Textures flipped when re-used
[fixed]Textures flipped when re-used
I draw my game menu using drawImage from the driver class.
If I Load again same image files, so the engine won't load them but take them directly from the cache...
It's OK most of the time, however it append sometimes that all textures are flipped! Take a look :
Normal textures :
And sometimes, it happends really RANDOMLY :
If I Load again same image files, so the engine won't load them but take them directly from the cache...
It's OK most of the time, however it append sometimes that all textures are flipped! Take a look :
Normal textures :
And sometimes, it happends really RANDOMLY :
It's not a problem of power of 2.
Some of the images have a size like 1280x1024, but it's flipped too.
All images are PNGs.
I'm using Irrlicht 1.4.2
I'm using the function draw2DImage from IVideoDriver to display all images, and the function draw from IGUIFont to display texts.
EDIT : The text from IGUIStaticText is flipped too.
I imagine it's because it use a texture as font which would be flipped too as the draw function from IGUIFont.
This is really strange, but this is happening only if I remove the skybox
skybox->remove(); -> textures are flipped
And this is happening when I'm removing all my nodes from the scene :
myNode->remove();
Using the clear function from sceneManager instead of remove from ISceneNode don't change anything, textures are flipped.
Some of the images have a size like 1280x1024, but it's flipped too.
All images are PNGs.
I'm using Irrlicht 1.4.2
I'm using the function draw2DImage from IVideoDriver to display all images, and the function draw from IGUIFont to display texts.
EDIT : The text from IGUIStaticText is flipped too.
I imagine it's because it use a texture as font which would be flipped too as the draw function from IGUIFont.
This is really strange, but this is happening only if I remove the skybox
skybox->remove(); -> textures are flipped
And this is happening when I'm removing all my nodes from the scene :
myNode->remove();
Using the clear function from sceneManager instead of remove from ISceneNode don't change anything, textures are flipped.
Yesssss!
I'm using some RTTs ingame, and OpenGL Renderer!
Thank you very much, I was testing everything in my code to find out where was my mistake without any sucess
Sorry for not using the last Irrlicht version which would have avoid this thread, however I'm using multiple libs which are running on 1.4.2 and maybe not on younger versions.
I'm going to try to port my application to Irlicht 1.6, however, if I don't manage to do it (if there is too much dependencies), could you tell me if the fix is simple to do? I could change that in the 1.4.2 Irrlicht engine myself if not to hard to do
Thank again!
Stef.
I'm using some RTTs ingame, and OpenGL Renderer!
Thank you very much, I was testing everything in my code to find out where was my mistake without any sucess
Sorry for not using the last Irrlicht version which would have avoid this thread, however I'm using multiple libs which are running on 1.4.2 and maybe not on younger versions.
I'm going to try to port my application to Irlicht 1.6, however, if I don't manage to do it (if there is too much dependencies), could you tell me if the fix is simple to do? I could change that in the 1.4.2 Irrlicht engine myself if not to hard to do
Thank again!
Stef.
Thanks, I found the area to fix
However after having changed the code, my images are still flipped.
I decided to trace things with std::cout and :
The draw2DImage function is called (yes, I wanted to be sure )
The isRTT is set to false This is the main problem.
So you are testing if the texture is an RTT. I'm using RTT in my game, however textures which are flipped are NOT RTT, so checking with : isRTT=texture->isRenderTarget() won't change anything, no?
I don't know why textures are flipped, but it seems that's because I'm using RTT in my game. So I probably should add a parameter to the draw2DImage function which would be "bool flipTexture" and which would flip the texture if set to true. Then I would put this parameter to true after having used at least 1time some RTT textures, but before to false.
Because for the moment, the isRTT boolean is all the time FALSE, that mean the texture->isRenderTarget() is false. And I don't know why it would be true, because textures used which are flipped are not RTTs
HOWEVER : note that in-game, when I have some models using RTT textures, images drawed using the draw2DImage from the driver are NOT flipped! (and the isRTT is false too)
However after having changed the code, my images are still flipped.
I decided to trace things with std::cout and :
The draw2DImage function is called (yes, I wanted to be sure )
The isRTT is set to false This is the main problem.
So you are testing if the texture is an RTT. I'm using RTT in my game, however textures which are flipped are NOT RTT, so checking with : isRTT=texture->isRenderTarget() won't change anything, no?
I don't know why textures are flipped, but it seems that's because I'm using RTT in my game. So I probably should add a parameter to the draw2DImage function which would be "bool flipTexture" and which would flip the texture if set to true. Then I would put this parameter to true after having used at least 1time some RTT textures, but before to false.
Because for the moment, the isRTT boolean is all the time FALSE, that mean the texture->isRenderTarget() is false. And I don't know why it would be true, because textures used which are flipped are not RTTs
HOWEVER : note that in-game, when I have some models using RTT textures, images drawed using the draw2DImage from the driver are NOT flipped! (and the isRTT is false too)
I really don't know.
Important : before an image is flipped, I can see clearly an image not flipped for 1 frame, then it's flipped.
I will definitly try to understand where does it come, maybe make a little piece of code to reproduce the thing if I manage to do it...
I will up this post when I'll be done with that.
Edit :
Without using ANY RTT, textures are NEVER flipped.
It's not the fact to create an RTT which flip textures.
It's the fact to put it as a texture for a model like the following :
And images in game are not flipped.
So what I think is :
Before using any RTT everything is normal.
Then in-game, an RTT is used as texture for a model : while the model is in the scene, images are not flipped.
Then return to menu, the model using RTT texture is deleted (node->remove) so the RTT is not used any more, however it had been used , images are flipped.
So we could think that :
in game, both condition are true, so images are not flipped.
In menu, the second condition is false, so the image is flipped :Indeed an RTT had been created and applyed to a model, however the model is not anymore on the scene, so...
There must be something which act like this in Irrlicht code
Could you tell me what does flip texture when using RTT texture ?
I mean the bug which made you change the draw2DImage function from the driver, in OpenGL. I could probably look at the code too see if I can find something wrong...
Important : before an image is flipped, I can see clearly an image not flipped for 1 frame, then it's flipped.
I will definitly try to understand where does it come, maybe make a little piece of code to reproduce the thing if I manage to do it...
I will up this post when I'll be done with that.
Edit :
Without using ANY RTT, textures are NEVER flipped.
It's not the fact to create an RTT which flip textures.
It's the fact to put it as a texture for a model like the following :
Code: Select all
node->setMaterialTexture(0, RTTTex);
So what I think is :
Before using any RTT everything is normal.
Then in-game, an RTT is used as texture for a model : while the model is in the scene, images are not flipped.
Then return to menu, the model using RTT texture is deleted (node->remove) so the RTT is not used any more, however it had been used , images are flipped.
So we could think that :
Code: Select all
bool inverse(bool value) {
return(value?false:true);
}
bool textures_are_flipped=false;
if(an_rtt_have_been_applyed_to_a_model) inverse(textures_are_flipped);
if(an_rtt_is_currently_allpyed_to_a_model) inverse(textures_are_flipped);
In menu, the second condition is false, so the image is flipped :Indeed an RTT had been created and applyed to a model, however the model is not anymore on the scene, so...
There must be something which act like this in Irrlicht code
Could you tell me what does flip texture when using RTT texture ?
I mean the bug which made you change the draw2DImage function from the driver, in OpenGL. I could probably look at the code too see if I can find something wrong...
Ha! I'm happy, I managed to reproduce the bug in a code sample
I'm so happy this doesn't come from my own code
So here is my bug report application :
-code to reproduce the bug
-binary compiled + irrlicht Dll to try it without compiling it
http://www.megaupload.com/?d=RK8E21GK
If you don't like megaupload I uploaded here too :
FREE : http://dl.free.fr/uqxKeXfyV
rapidshare : http://rapidshare.com/files/300226658/B ... t.rar.html
MediaFire : http://www.mediafire.com/download.php?dimjnmyzzny
2shared : http://www.2shared.com/file/8797357/749 ... eport.html?
mega file : http://www.megafileupload.com/en/file/1 ... t-rar.html
send space : http://www.sendspace.com/file/qbry5b
Stef
I'm so happy this doesn't come from my own code
So here is my bug report application :
-code to reproduce the bug
-binary compiled + irrlicht Dll to try it without compiling it
http://www.megaupload.com/?d=RK8E21GK
If you don't like megaupload I uploaded here too :
FREE : http://dl.free.fr/uqxKeXfyV
rapidshare : http://rapidshare.com/files/300226658/B ... t.rar.html
MediaFire : http://www.mediafire.com/download.php?dimjnmyzzny
2shared : http://www.2shared.com/file/8797357/749 ... eport.html?
mega file : http://www.megafileupload.com/en/file/1 ... t-rar.html
send space : http://www.sendspace.com/file/qbry5b
Stef
That's great. Ideally, you'd be able to reduce your testcase down to something small so that you could just post the source here inside
Code: Select all
tags. That way we don't have to deal with megaupload, we don't have to install a utility to decompress rar archives, and we don't have to debug a bunch of unnecessary code to find the problem.
I'm not at home, and it wouldn't be polite to install a RAR client on my in-laws PC, so I didn't get to see the contents of your archive. I'm _assuming_ that the testcase is fairly complicated, otherwise you wouldn't have needed to make an archive from it.
Travis
Oh no, that's just to provide you the texture used and the exe to make your life better
Here is the bug report code :
EDIT : this bug is occuring in the Irrlicht 1.6 version too (in the archive I tested the 1.4.2 version )
Oh! if it's a real bug, could I give my name to the bug like Astronomers are giving their name to planets ?
Stef.
Here is the bug report code :
Code: Select all
#include <IRR/irrlicht.h>
using namespace irr;
using namespace video;
using namespace scene;
IrrlichtDevice *device;
IVideoDriver *driver;
ISceneManager *smgr;
ITexture *image;
ITexture *RTT_texture;
IMesh *modelMesh;
ISceneNode *modelNode;
ICameraSceneNode *camera;
int main(int argc, char *argv[]) {
device=createDevice(video::EDT_OPENGL, core::dimension2d<s32>(1280, 1024), 32, true, false, true);
device->setWindowCaption(L"Irrlicht - RTT Bug report");
driver = device->getVideoDriver();
smgr = device->getSceneManager();
image=driver->getTexture("IrrlichtLogo.png");
RTT_texture=driver->createRenderTargetTexture(core::dimension2d<s32>(512,512));
camera=smgr->addCameraSceneNode(0, core::vector3df(100,100,100), core::vector3df(0,0,0));
/*to reproduce the bug :
-draw the image : it's normal
-apply an RTT texture to a model
-remove the model
-draw the image again : it's flipped
*/
//draw the image :
driver->beginScene(true, true, video::SColor(255,200,200,200));
driver->draw2DImage(image, core::rect<s32>(1280/2-image->getSize().Width/2,1024/2-image->getSize().Height/2,1280/2+image->getSize().Width/2,1024/2+image->getSize().Height/2), core::rect<s32>(0,0,image->getSize().Width,image->getSize().Height), 0,0,true);
driver->endScene();
//then create a model and apply to it the RTT Texture
//rendering the model is important, if not rendered 1 time, bug won't appear.
//after the render, we remove the node : important, if not done, bug won't appear too.
modelMesh=smgr->getMesh("simpleSphere.3ds");
modelNode=smgr->addMeshSceneNode(modelMesh);
modelNode->setMaterialTexture(0, RTT_texture);
driver->beginScene(true, true, video::SColor(255,200,200,200));
smgr->drawAll();
driver->endScene();
modelNode->remove();
while(device->run()) {
//then we render the image normaly
//it's now fliped...
driver->beginScene(true, true, video::SColor(255,200,200,200));
//draw img
driver->draw2DImage(image, core::rect<s32>(1280/2-image->getSize().Width/2,1024/2-image->getSize().Height/2,1280/2+image->getSize().Width/2,1024/2+image->getSize().Height/2), core::rect<s32>(0,0,image->getSize().Width,image->getSize().Height), 0,0,true);
//call this is important :
//if not called, the bug won't appear
smgr->drawAll();
driver->endScene();
}
return EXIT_SUCCESS;
}
Oh! if it's a real bug, could I give my name to the bug like Astronomers are giving their name to planets ?
Stef.
-
- Admin
- Posts: 14143
- Joined: Wed Apr 19, 2006 9:20 pm
- Location: Oldenburg(Oldb), Germany
- Contact:
Ok, this looks like jsut another bug with cached values in the driver. Since the draw2d methods don't use the usual setMaterial calls, the render states and texture states need to be updated manually. I guess that some pointer is not properly overwritten and the check uses the texture from the model, not the one used by draw2dImage. I'll have to look into this, but I guess we can fix this easily.
I put a new entry to the bug tracker :
https://sourceforge.net/tracker/index.p ... tid=540676#
stef.
https://sourceforge.net/tracker/index.p ... tid=540676#
stef.