Option to remove FreeType dependency ?

What it says on the tin: a place to discuss proposed new features.
Post Reply
User avatar
sebarnolds
Greenskin
Posts: 111
Joined: Thu Jun 22, 2006 12:55 pm
Location: Belgium
Contact:

Option to remove FreeType dependency ?

Post by sebarnolds » Fri Feb 06, 2009 11:02 am

Hi everybody !

I would like to know if it would be interesting to others to have an option to build Ogre without the FreeType dependency ?

I am considering building Ogre from source when upgrading from 1.4 to 1.6 (I previously used SDK versions) and I don't need FreeType support as I will have my own GUI library with font support. Would it be feasible to add an option to build Ogre without font support (just as it is possible to build it without DevIl or FreeImage and to have to provide our image loaders) ?

I am not asking for someone to do it, I can look at that myself and provide a patch once I managed to do it. However, as I don't really know all the Ogre internals (who does ?) and I am only a beginner with Ogre, I would like to know if it would be feasible without too much hassle and if it would be interesting for other Ogre users.

Thank you forward,
Seb
0 x

User avatar
Noman
OGRE Retired Team Member
OGRE Retired Team Member
Posts: 714
Joined: Mon Jan 31, 2005 7:21 pm
Location: Israel
Contact:

Re: Option to remove FreeType dependency ?

Post by Noman » Sat Feb 07, 2009 12:15 pm

From OgreConfig.h :

Code: Select all

/** Disables use of the FreeImage image library for loading images.
WARNING: Use only when you want to provide your own image loading code via codecs.
*/
#ifndef OGRE_NO_FREEIMAGE
#define OGRE_NO_FREEIMAGE 0
#endif
0 x

User avatar
sebarnolds
Greenskin
Posts: 111
Joined: Thu Jun 22, 2006 12:55 pm
Location: Belgium
Contact:

Re: Option to remove FreeType dependency ?

Post by sebarnolds » Sat Feb 07, 2009 12:35 pm

Yeah, I know it is possible to disable FreeImage. I am just asking if it would be feasible and interesting for any other than me to be able to disable FreeType dependency (and disable Ogre fonts).

Seb
0 x

reptor
Ogre Magi
Posts: 1120
Joined: Wed Nov 15, 2006 7:41 pm
Location: Finland

Re: Option to remove FreeType dependency ?

Post by reptor » Sat Feb 07, 2009 6:33 pm

Actually the FreeImage switch in the OgreConfig.h isn't enough to disable it from getting compiled into the library. The code will still go into the DLL. I solve this by removing the FreeImageCodec files from the project.

Then if you only want to use DDS files and don't provide a codec for PNG, it won't compile.

I provide here a diff file which shows the changes I made to version 1.6, revision 8111, to remove FreeImage and to make it work without a PNG codec:

Code: Select all

Index: H:/Projects/ogre-v1.6/OgreMain/include/OgreConfig.h
===================================================================
--- H:/Projects/ogre-v1.6/OgreMain/include/OgreConfig.h	(revision 8111)
+++ H:/Projects/ogre-v1.6/OgreMain/include/OgreConfig.h	(working copy)
@@ -133,7 +133,7 @@
 WARNING: Use only when you want to provide your own image loading code via codecs.
 */
 #ifndef OGRE_NO_FREEIMAGE
-#define OGRE_NO_FREEIMAGE 0
+#define OGRE_NO_FREEIMAGE 1
 #endif
 
 /** Disables use of the DevIL image library for loading images.
Index: H:/Projects/ogre-v1.6/OgreMain/scripts/OgreMain_vc9.vcproj
===================================================================
--- H:/Projects/ogre-v1.6/OgreMain/scripts/OgreMain_vc9.vcproj	(revision 8111)
+++ H:/Projects/ogre-v1.6/OgreMain/scripts/OgreMain_vc9.vcproj	(working copy)
@@ -1,7 +1,7 @@
 <?xml version="1.0" encoding="Windows-1252"?>
 <VisualStudioProject
 	ProjectType="Visual C++"
-	Version="9.00"
+	Version="9,00"
 	Name="OgreMain"
 	ProjectGUID="{35AFBABB-DF05-43DE-91A7-BB828A874015}"
 	RootNamespace="OgreMain"
@@ -565,10 +565,6 @@
 				>
 			</File>
 			<File
-				RelativePath="..\src\OgreFreeImageCodec.cpp"
-				>
-			</File>
-			<File
 				RelativePath="..\src\OgreFrustum.cpp"
 				>
 			</File>
@@ -1386,10 +1382,6 @@
 				>
 			</File>
 			<File
-				RelativePath="..\include\OgreFreeImageCodec.h"
-				>
-			</File>
-			<File
 				RelativePath="..\include\OgreFrustum.h"
 				>
 			</File>
Index: H:/Projects/ogre-v1.6/OgreMain/src/OgreSceneManager.cpp
===================================================================
--- H:/Projects/ogre-v1.6/OgreMain/src/OgreSceneManager.cpp	(revision 8111)
+++ H:/Projects/ogre-v1.6/OgreMain/src/OgreSceneManager.cpp	(working copy)
@@ -4412,7 +4412,7 @@
         }
     }
 
-    // Set up spot shadow fade texture (loaded from code data block)
+    /*// Set up spot shadow fade texture (loaded from code data block)
     TexturePtr spotShadowFadeTex = 
         TextureManager::getSingleton().getByName("spot_shadow_fade.png");
     if (spotShadowFadeTex.isNull())
@@ -4426,7 +4426,7 @@
             TextureManager::getSingleton().loadImage(
 			"spot_shadow_fade.png", ResourceGroupManager::INTERNAL_RESOURCE_GROUP_NAME, 
 			img, TEX_TYPE_2D);
-    }
+    }*/
 
     mShadowMaterialInitDone = true;
 }

I support the movement to make it easier to pick which components get included when Ogre3D is compiled. For example, this work to remove the FreeImage completely could be handled automatically in the official Ogre3D source code. And the fact that it requires a PNG codec to compile is a bit disturbing, isn't there some way around that.
0 x

User avatar
Noman
OGRE Retired Team Member
OGRE Retired Team Member
Posts: 714
Joined: Mon Jan 31, 2005 7:21 pm
Location: Israel
Contact:

Re: Option to remove FreeType dependency ?

Post by Noman » Sat Feb 07, 2009 8:08 pm

Ah I see what you're getting at.
I think there has been some talks about making Ogre more pluggable at the core, mainly to reduce the dll's fairly large footprint.
There are two ways to do it, the way I see it :
1) Have all library dependencies determined by the code and not by the project files (IE #pragma calls). I think sinbad explicitly said that he doesn't like that.
2) Have a premake system that can create the neccesary projects with the necessary dependencies. Since Ogre is cross platform, this means CMake or similar becoming the official build system. The downside of this is that to switch settings, you'd have to recreate the project files.

I don't have an answer to the fact that Ogre relies on its ability to load .png files.
0 x

reptor
Ogre Magi
Posts: 1120
Joined: Wed Nov 15, 2006 7:41 pm
Location: Finland

Re: Option to remove FreeType dependency ?

Post by reptor » Sat Feb 07, 2009 9:19 pm

By the way, I might be wrong about the missing PNG codec being a compile-time problem; it looks more like it will crash at runtime if the PNG codec is not found when the code tries to load the PNG image. Actually I am quite sure now that's what it does. I think Ogre3D always automatically runs that code on startup so it can only be avoided by either having the PNG codec or changing the image type to something else that is supported (DDS in my case).

I guess I'll have to do some work to figure out if the PNG can be replaced with DDS. It's not a big problem anyways, certainly not serious. Just wanted to point out that the requirement for the PNG codec is hardcoded into Ogre3D and I think it would be better if it wasn't. At least for projects in which DDS textures are enough and no other formats are needed. Then there is no need for image libraries as Ogre3D has its own code to load DDS.
0 x

User avatar
Azgur
Goblin
Posts: 264
Joined: Thu Aug 21, 2008 4:48 pm

Re: Option to remove FreeType dependency ?

Post by Azgur » Sun Feb 08, 2009 11:30 am

I wonder if I should point out the difference between FreeImage and FreeType...
Na, I'll just leave you guys misunderstand each other :)
0 x

User avatar
sebarnolds
Greenskin
Posts: 111
Joined: Thu Jun 22, 2006 12:55 pm
Location: Belgium
Contact:

Re: Option to remove FreeType dependency ?

Post by sebarnolds » Sun Feb 08, 2009 4:47 pm

Well, I would probably prefer that everyone here realize that I am talking about FreeType which is about fonts and text rendering and not about FreeImage which is about image loading.

About your PNG problem, my guess would be that you should create a patch for it and release it on the patch tracker or create a separate thread to talk about it as it does not relate much to my original question.

So anybody any thoughts on the option to remove the FreeType dependency ?
0 x

reptor
Ogre Magi
Posts: 1120
Joined: Wed Nov 15, 2006 7:41 pm
Location: Finland

Re: Option to remove FreeType dependency ?

Post by reptor » Sun Feb 08, 2009 6:08 pm

I do know the difference between the two libraries but since it looked like the issue is very much related I thought why not post about FreeImage here also. And I think I wasn't the one who brought FreeImage to this thread :)

Of course I noticed that the thread starter is interested in FreeType and not in FreeImage.

What I posted does relate to the FreeType question as well, both are discussing how to remove a dependency. It should be in general made easier in Ogre3D to remove dependencies, no matter if it is FreeType or FreeImage.
0 x

User avatar
Noman
OGRE Retired Team Member
OGRE Retired Team Member
Posts: 714
Joined: Mon Jan 31, 2005 7:21 pm
Location: Israel
Contact:

Re: Option to remove FreeType dependency ?

Post by Noman » Sun Feb 08, 2009 7:03 pm

Genuine oops on my side :) Sorry :)

I still think that this is a discussion that has been made. Again, mainly to reduce code footprint and not dependencies, but the required measures are the same.
There have been talks about the possibility to compile without things like shadows (or just stencil shadows), compositors, overlays and the likes. I think it was on the general forums...

Many #ifdef chunks need to be added etc.
Its an option, even not too hard IMO. Just a few hours (maybe 1-2 days) of dirty work, #ifdef'ing, compiling and testing...
0 x

reptor
Ogre Magi
Posts: 1120
Joined: Wed Nov 15, 2006 7:41 pm
Location: Finland

Re: Option to remove FreeType dependency ?

Post by reptor » Sun Feb 08, 2009 10:28 pm

Actually I did quite a lot of #ifdef work some months ago.

I started to look at what functionality of Ogre3D I definitely don't want to use, and then took it out by inserting #ifdef and added switches to the OgreConfig.h file.

So it would be easy to remove the functionality just by toggling a switch in the config file.

You need to check the whole Ogre3D project if it is using the functionality or not, then add #ifdef lines where needed, and ensure that the config file is included in all of the files that need it. I did this work per cpp file.

It is mechanical work. Actually it can get a bit difficult to recognize the subsections, some subsections are difficult to remove as they are spread a bit here and a bit there. Can't recall now what systems were like that but there were some with which this started to be a problem. It's basicly a question of identifying each "component", or "feature". With some things this can get a bit difficult. But many things are easy to remove this way.

All the functionality which isn't used by Ogre3D core itself can be removed this way rather easily. Ideally we should be able to remove such functionality by just toggling a switch in the config file.

I am not convinced that this is worth it to do for the whole Ogre3D project. I started it as a personal project to see how much I can trim down the size of Ogre3D, when I realized that there are many many things which are of no use to me.
0 x

reptor
Ogre Magi
Posts: 1120
Joined: Wed Nov 15, 2006 7:41 pm
Location: Finland

Re: Option to remove FreeType dependency ?

Post by reptor » Thu Feb 12, 2009 5:16 pm

Sebarnolds, please forgive us for not helping you much with your question. I took it to a more general level as I have been looking, and at least partly solved, the problem, with the other dependency.

I hope it is clear that I am supporting what you are proposing. I think it is a good idea.

Maybe this should be better answered by sinbad but I guess he has been busy lately with the server rebuild. So maybe wait a little and bring this thread up when you see him being more active in the forums.
0 x

User avatar
sinbad
OGRE Retired Team Member
OGRE Retired Team Member
Posts: 19265
Joined: Sun Oct 06, 2002 11:19 pm
Location: Guernsey, Channel Islands
x 2
Contact:

Re: Option to remove FreeType dependency ?

Post by sinbad » Thu Feb 12, 2009 5:28 pm

I can see where people are coming from here. I would like to make some core components more optional, and I hope that I'll eventually find some time to look at CMake ;)

Originally, there were a few more things in the core that were plugin DLLs, but it just ended up getting far too messy, and hugely confusing, especially when it came to making the whole thing compatible with both static linking and dynamic linking (it's bad enough when you have to load a zillion plugins, it's worse when you have to connect them all up in code when you make a static library version).

Therefore, even though it limits what you can do with prebuilt SDKs, I would personally prefer a pre-build system that people could pick the options they wanted, and CMake would fit this bill. The only downside with that compared to binary separation is that you have to rebuild to change the options, but I think on balance it's much tidier. And it's open source after all, custom builds should be bread-and-butter for our kind of project ;)

One day I'll finally get time to break out CMake. One day. If hackers would stop wasting my time ;)
0 x

User avatar
sebarnolds
Greenskin
Posts: 111
Joined: Thu Jun 22, 2006 12:55 pm
Location: Belgium
Contact:

Re: Option to remove FreeType dependency ?

Post by sebarnolds » Thu Feb 12, 2009 8:35 pm

Hello everybody.

Thanks for all your answers. Sorry if I sounded like I completely didn't care about your answers about FreeImage. This is something that interest me too because in the end I will probably try to remove the FreeImage dependency too. The FreeType dependency was however my main concern.

It's good to have an official position about this. I'll probably try to remove it myself cleanly when I'll have the time. I guess I'll need to modify the configure script to add an option and also check the OgreConfig.h. Switching later to CMake shouldn't change anything as it can output that OgreConfig.h file based on the options. As soon as I find some time to do this, I'll get back to you with, hopefully, a patch.

Thank you everybody,
Sebastien
0 x

User avatar
jacmoe
OGRE Retired Moderator
OGRE Retired Moderator
Posts: 20570
Joined: Thu Jan 22, 2004 10:13 am
Location: Denmark
Contact:

Re: Option to remove FreeType dependency ?

Post by jacmoe » Thu Feb 12, 2009 10:20 pm

sinbad wrote:One day I'll finally get time to break out CMake. One day. If hackers would stop wasting my time ;)
Maybe Cabalistic beats you to it. ? :)
0 x
/* 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
Contact:

Re: Option to remove FreeType dependency ?

Post by CABAListic » Thu Feb 12, 2009 11:11 pm

jacmoe wrote:
sinbad wrote:One day I'll finally get time to break out CMake. One day. If hackers would stop wasting my time ;)
Maybe Cabalistic beats you to it. ? :)
Er, I think I already did ;)
Seriously though, the CMake build system needs an official assessment to determine if it can become the official build system and what specifically might still need to be done before that. I think that's what sinbad means.
0 x

User avatar
jacmoe
OGRE Retired Moderator
OGRE Retired Moderator
Posts: 20570
Joined: Thu Jan 22, 2004 10:13 am
Location: Denmark
Contact:

Re: Option to remove FreeType dependency ?

Post by jacmoe » Thu Feb 12, 2009 11:16 pm

CABAListic wrote:Er, I think I already did ;)
Er, yeah. That's why I mentioned you. :wink:
CABAListic wrote:Seriously though, the CMake build system needs an official assessment to determine if it can become the official build system and what specifically might still need to be done before that. I think that's what sinbad means.
Should be a whole lot easier thanks to your awesome job with the Ogre CMake script(s). :)
0 x
/* Less noise. More signal. */
Ogitor Scenebuilder - powered by Ogre, presented by Qt, fueled by Passion.
OgreAddons - the Ogre code suppository.

Post Reply