Linux fixes

Kali

29-01-2008 13:56:25

- Updated the cmake build files
- gcc needs to include the full header when it accesses members. The forward declaration will not do, so I included a few headers.


Index: QuickGUI/include/CMakeLists.txt
===================================================================
--- QuickGUI/include/CMakeLists.txt (revision 328)
+++ QuickGUI/include/CMakeLists.txt (working copy)
@@ -25,7 +25,6 @@
QuickGUIPanel.h
QuickGUIPoint.h
QuickGUIPrecompiledHeaders.h
- QuickGUIPrerequisites.h
QuickGUIProgressBar.h
QuickGUIQuad.h
QuickGUIQuadContainer.h
@@ -42,13 +41,15 @@
QuickGUIText.h
QuickGUITitleBar.h
QuickGUITree.h
- QuickGUIUtility.h
QuickGUIVertexBuffer.h
QuickGUIVertex.h
QuickGUIVerticalScrollBar.h
QuickGUIVerticalTrackBar.h
QuickGUIWidget.h
QuickGUIWindow.h
+ QuickGUIForwardDeclarations.h
+ QuickGUITypedef.h
+ QuickGUIVector4.h
)

INSTALL (FILES ${QUICKGUI_INCLUDES} DESTINATION ${INCLUDE_INSTALL_DIR}/QuickGUI)
Index: QuickGUI/src/QuickGUISkinSet.cpp
===================================================================
--- QuickGUI/src/QuickGUISkinSet.cpp (revision 328)
+++ QuickGUI/src/QuickGUISkinSet.cpp (working copy)
@@ -7,6 +7,9 @@
#include "OgreImage.h"
#include "OgreStringConverter.h"

+#include "OgreRoot.h"
+#include "OgreRenderSystem.h"
+
namespace QuickGUI
{
SkinSet::SkinSet(const std::string& skinName, ImageType t, const std::string &resourceGroup) :
Index: QuickGUI/src/CMakeLists.txt
===================================================================
--- QuickGUI/src/CMakeLists.txt (revision 328)
+++ QuickGUI/src/CMakeLists.txt (working copy)
@@ -35,12 +35,12 @@
QuickGUIText.cpp
QuickGUITitleBar.cpp
QuickGUITree.cpp
- QuickGUIUtility.cpp
QuickGUIVertexBuffer.cpp
QuickGUIVerticalScrollBar.cpp
QuickGUIVerticalTrackBar.cpp
QuickGUIWidget.cpp
QuickGUIWindow.cpp
+ QuickGUIVector4.cpp
)

INCLUDE_DIRECTORIES (../include ${OGRE_INCLUDEDIR})
Index: QuickGUI/src/QuickGUITextHelper.cpp
===================================================================
--- QuickGUI/src/QuickGUITextHelper.cpp (revision 328)
+++ QuickGUI/src/QuickGUITextHelper.cpp (working copy)
@@ -2,6 +2,9 @@

#include "QuickGUITextHelper.h"

+#include "OgreTextureManager.h"
+#include "OgreTechnique.h"
+
namespace QuickGUI
{
TextHelper::TextHelper() :

Kali

29-01-2008 14:29:26

And there is an issue with clicking buttons. When you hover over buttons/checkboxes/drop down boxes, they often doesn't seem to light up any more and the button can no longer be clicked. Not always thought, it's very erratic.

libolt

29-01-2008 16:10:46

I have committed fixes for the build issues.

Mike

kungfoomasta

29-01-2008 16:55:01

I'm betting its the new transparency culling I added in. I'll have to debug it some time, its hard to track where the issue lies.

kungfoomasta

29-01-2008 18:18:34

Does linux not like forward declarations?

I had planned to forward declare all non-QuickGUI classes in every header file.. will this not work in Linux?

The reason for this is that projects that include QuickGUI won't have to include QuickGUI's dependencies, ie Ogre. Imagine an engine class, and your project has the engine as its dependency. It shouldn't also have the engine's dependencies..

CABAListic

29-01-2008 18:45:38

I'm not aware of any significant differences in the treatment of forward declarations between GCC and Visual C++. So long as a forward declared class only appears as a pointer type or as a function argument, there's nothing wrong with it.
However, as soon as you begin to use a type, it must be fully defined, no matter what. But this usually only affects your cpp files (and the changes above only seem to affect cpp files), the headers should be fine unless you have inlined code or non-pointer member variables.

kungfoomasta

29-01-2008 18:51:50

Thanks for the clarification, I will proceed as I planned. :twisted:

The only issue I have is when QuickGUI classes inherit from Ogre ones. I'll have to do some awkward wrapping and defining of classes in .cpp files to get around this. It doesn't happen often, but I believe one class inherits from Ogre::ScriptParser class. And for some classes that are not pointers, I'll have to make simplified versions of them, for example the Ogre::ColourValue -> QuickGUI::ColourValue.

CABAListic

29-01-2008 19:50:23

Personally, I wouldn't do that unless you planned to completely decouple QuickGUI from Ogre (meaning to provide possibilities for other render engines besides Ogre). But as I see it, QuickGUI is only useful with Ogre, so where it is appropriate, do use Ogre's types (ColourValue, Vector3) and include the appropriate headers. There's nothing wrong with including headers in a header, just only include as much as you need ;)

Even more so with inheritance: Any type you inherit from must be fully defined, there's no way around it.

Kali

30-01-2008 00:35:19

Well I wasn't aware of any differences either.

It's obvious that when a member function or member variable is accessed that availabilety and type checking for these functions/variables must occur and that a forward declaration is not sufficiënt.

But since such errors do occur in svn occasionally, I can only deduct that that visual c++, assuming this is the compiler you use, is more forgiving in certain circumstances.

To use the example above in QuickGUISkinset.cpp in the last revision seemed to compile on visual c++ with only a forward declaration of Ogre::Root, allthough it contains this part.


mHorizontalTexelOffset = Ogre::Root::getSingleton().getRenderSystem()->getHorizontalTexelOffset();
mVerticalTexelOffset = Ogre::Root::getSingleton().getRenderSystem()->getVerticalTexelOffset();


Which clearly needs Ogre::Root to be fully defined. And gcc flagged this error so I thought I'd mention it.

Anyway using forward declarations where you don't access members is fine and can significantly reduce compile time.

CABAListic

30-01-2008 00:48:07

Assumably one of the Ogre headers that were already included might have pulled in OgreRoot.h via conditional compilation under Windows. I'm pretty certain that Visual C++ could not have compiled that piece of code with just a forward declaration of Ogre::Root.

Kali

30-01-2008 01:06:49

I must say, I hadn't considered conditional compilation. And looking through the code I think I found the problem.

QuickGUIPrecompiledHeaders.h has header inclusions between #ifdef _PRECOMP. _PRECOMP is probably defined by your build system but not by CMake.

Seems I jumped to the wrong conclusions, you were right CABAListic.