Make it easy to disable ZIP and FreeImage

What it says on the tin: a place to discuss proposed new features.
Post Reply
reptor
Ogre Magi
Posts: 1120
Joined: Wed Nov 15, 2006 7:41 pm
Location: Finland
x 5

Make it easy to disable ZIP and FreeImage

Post by reptor »

Hello

I have these feature requests. I can imagine other people could also benefit from this.

1) Make it easy to disable the ZIP support completely from Ogre3D.

2) Make it easy to disable FreeImage completely from Ogre3D.


This is a situation in which:

- I use only DDS textures, hence, no need for FreeImage, because Ogre3D has its own DDS Codec for loading.

- I do not use ZIP archives, hence, no need for the libraries that are needed in Ogre3D for it.


I've been doing it manually and I have to say it's getting rather unpleasant. You see, as I compile Ogre3D from source, if I don't manually remove those, then I need to prepare the FreeImage and ZIP support libraries. This I find useless as I don't use them. So it is a waste of my time everytime I end up doing it.

I've done it with #ifdef blocks at appropriate places, and I have the settings OGRE_NO_ZIP and OGRE_NO_PNG (because of FreeImage) in OgreConfig.h. I think there is a problem with removing the FreeImage as there is a soft shadow set up in OgreSceneManager.cpp, which uses a PNG texture, and when only DDS Codec is available, then that shadow texture cannot be used. So my solution was just to #ifdef that block of code away. It has not been a problem for me, but I thought someone in the Ogre3D team should think about this - perhaps the PNG can be replaced with a DDS?

I develop on both Windows and Linux. But if this feature request is implemented into Ogre3D then it should concern all platforms.

Thanks in advance for seriously considering this feature request!
User avatar
steven
Gnoll
Posts: 657
Joined: Mon Feb 28, 2005 1:53 pm
Location: Australia - Canberra (ex - Switzerland - Geneva)
Contact:

Re: Make it easy to disable ZIP and FreeImage

Post by steven »

If you already have the code the simplest and fastest to have this change would be to submit a patch on the patch tracker. Although I would use OGE_NO_FREEIMAGE

I support the idea of removing the freeimage if possible.
reptor
Ogre Magi
Posts: 1120
Joined: Wed Nov 15, 2006 7:41 pm
Location: Finland
x 5

Re: Make it easy to disable ZIP and FreeImage

Post by reptor »

Well, yes, I had that in mind.

But as I mentioned, there is the problem with the shadow texture being a PNG instead of a DDS and that's a problem. While it is fine for me to take that code out of Ogre3D completely, I am sure that kind of a patch cannot go as-is to the official version.

And changes need to be done to the build scripts on Linux - it wasn't as straightforward as on Windows, I noticed recently. Which was in fact what triggered me to start this thread.

There should be --disable-zip in addition to --disable-freeimage. I just commented out some lines from some configure script and that's hardly a solution that can be applied to the official version of Ogre3D.

So, no, I don't think I have it ready to be submitted to the patch tracker. I will try to do more work on this. I think there are potentially a lot of people who are using custom archives instead of ZIP archives and they could appreciate if it was easy to get the ZIP support out of Ogre3D easily.
CABAListic
OGRE Retired Team Member
OGRE Retired Team Member
Posts: 2903
Joined: Thu Jan 18, 2007 2:48 pm
x 58
Contact:

Re: Make it easy to disable ZIP and FreeImage

Post by CABAListic »

I don't exactly understand your problem with the shadow texture. Is there a hardcoded reference to a .png file in the media, or what?

Anyway, don't bother with adding this to Shoggoth, as this will not get committed to Shoggoth, anyway. And in trunk, CMake is the place to do this. In fact, CMake can already disable FreeImage, and I guess we can disable ZIP archive support, too. I'll look into it.
reptor
Ogre Magi
Posts: 1120
Joined: Wed Nov 15, 2006 7:41 pm
Location: Finland
x 5

Re: Make it easy to disable ZIP and FreeImage

Post by reptor »

CABAListic wrote:I don't exactly understand your problem with the shadow texture. Is there a hardcoded reference to a .png file in the media, or what?
Yes, there is, in OgreSceneManager.cpp. That's the problem. If you don't have a PNG Codec available, then it will just crash the program (if that code isn't edited out). The PNG Codec will of course not be available if FreeImage is disabled and nothing else is provided to handle PNG textures.

I show you the block of code that I edit out from OgreSceneManager.cpp:

Code: Select all

#if OGRE_NO_PNG == 0
    // Set up spot shadow fade texture (loaded from code data block)
    TexturePtr spotShadowFadeTex =
        TextureManager::getSingleton().getByName("spot_shadow_fade.png");
    if (spotShadowFadeTex.isNull())
    {
        // Load the manual buffer into an image (don't destroy memory!
        DataStreamPtr stream(
			OGRE_NEW MemoryDataStream(SPOT_SHADOW_FADE_PNG, SPOT_SHADOW_FADE_PNG_SIZE, false));
        Image img;
        img.load(stream, "png");
        spotShadowFadeTex =
            TextureManager::getSingleton().loadImage(
			"spot_shadow_fade.png", ResourceGroupManager::INTERNAL_RESOURCE_GROUP_NAME,
			img, TEX_TYPE_2D);
    }
#endif
It is from branch 1.6, revision 9007 (latest). The #if OGRE_NO_PNG == 0 and #endif were added by me.

So the situation in the official version of Ogre3D 1.6 is that it is not possible to disable FreeImage if you do not provide something else to deal with the PNG textures.

As I was asking, I was wondering whether the spot_shadow_fade.png could be spot_shadow_fade.dds? If it can be a DDS instead of a PNG, then it wouldn't matter if people would have all image libraries disabled, as Ogre3D provides its own DDS loading codec. I disqualify myself from answering that question.

In my own application all this doesn't matter as I don't use it and I can just take that block of code out. But I am sure it matters for someone else.

The spot_shadow_fade.png is hard-coded, it is stored in an array in a source code file. I don't remember in which one - but it is easy to find in an IDE (which I can't use now, sorry).
User avatar
Kojack
OGRE Moderator
OGRE Moderator
Posts: 7157
Joined: Sun Jan 25, 2004 7:35 am
Location: Brisbane, Australia
x 534

Re: Make it easy to disable ZIP and FreeImage

Post by Kojack »

It's in OgreSpotShadowFadePng.h

It's only used for loading in (via a memory stream) a texture for soft shadow edges with spotlights, so the actual file format of the data shouldn't matter as long as Ogre can read it. It definitely should be a built in type like dds, or just raw.

The DirectX10 renderer also uses an explicit png, in OgreD3D10Texture.cpp. It tries to load Missing.png if a texture can't be found. But there's no missing.png in the ogre resources directories.
User avatar
jacmoe
OGRE Retired Moderator
OGRE Retired Moderator
Posts: 20570
Joined: Thu Jan 22, 2004 10:13 am
Location: Denmark
x 179
Contact:

Re: Make it easy to disable ZIP and FreeImage

Post by jacmoe »

Kojack wrote:But there's no missing.png in the ogre resources directories.
Would be nice if there were one. :)
/* Less noise. More signal. */
Ogitor Scenebuilder - powered by Ogre, presented by Qt, fueled by Passion.
OgreAddons - the Ogre code suppository.
User avatar
Kojack
OGRE Moderator
OGRE Moderator
Posts: 7157
Joined: Sun Jan 25, 2004 7:35 am
Location: Brisbane, Australia
x 534

Re: Make it easy to disable ZIP and FreeImage

Post by Kojack »

I guess if missing.png is missing then it just uses missing.png instead.
Umm, hang on...
:)
progmars
Halfling
Posts: 60
Joined: Fri Jun 17, 2005 10:47 am

Re: Make it easy to disable ZIP and FreeImage

Post by progmars »

.. and then it finally throws some "Infinite loop exception while loading missing.png" :D
(some time ago I had a problem with ATI driver ati2dvag - got BSODs because "driver has stuck in an infinite loop" so this sentence has pissed me off and I won't forget it for some time)


I too vote for being able to disable any external dependencies completely. Or it would be even better to have Zip and Freeimage format support as some completely separate plugins - they are just utilities and not really related to Ogre's core job - 3d graphics rendering.

But as I saw in some other old thread, this could lead to some philosophical questions what should be in Ogre core and what should not and that is not my intention, so I'll just shut up now :D
User avatar
_tommo_
Gnoll
Posts: 677
Joined: Tue Sep 19, 2006 6:09 pm
x 5
Contact:

Re: Make it easy to disable ZIP and FreeImage

Post by _tommo_ »

Jumping in with an unrelated request :D

Why ogre's only-used-in-the-samples libs are in the Ogre/lib folder in the SDK?
To use a newer OIS or ODE for example you always have to remember to delete the ones in the Ogre folder, or to replace them with your versions.
This isn't a big deal, but caused me some problems...

also this makes everyone expect that ogre isn't "a 3d rendering engine" because it includes in its libs input and physics.
That aren't even used, but who knows at first?
I would at least put them in a samples/lib folder along with their headers...
Last edited by _tommo_ on Fri Sep 18, 2009 4:48 pm, edited 1 time in total.
OverMindGames Blog
IndieVault.it: Il nuovo portale italiano su Game Dev & Indie Games
User avatar
jacmoe
OGRE Retired Moderator
OGRE Retired Moderator
Posts: 20570
Joined: Thu Jan 22, 2004 10:13 am
Location: Denmark
x 179
Contact:

Re: Make it easy to disable ZIP and FreeImage

Post by jacmoe »

Somewhere we have to cut the line between practicality and ... :wink:
/* Less noise. More signal. */
Ogitor Scenebuilder - powered by Ogre, presented by Qt, fueled by Passion.
OgreAddons - the Ogre code suppository.
CABAListic
OGRE Retired Team Member
OGRE Retired Team Member
Posts: 2903
Joined: Thu Jan 18, 2007 2:48 pm
x 58
Contact:

Re: Make it easy to disable ZIP and FreeImage

Post by CABAListic »

For what it's worth, I added the option to disable ZIP archive support via CMake, you can find the change in trunk. I have only tested it briefly, but it seems to do its job. I'm not touching the hardcoded resources, though; I know too little about their purpose.
Post Reply