Show
Ignore:
Timestamp:
08/13/10 22:27:00 (22 months ago)
Author:
Carsten
Message:

This revision implements (much of) the big step of replacing the previous OS layer with wxWidgets, achieving a good deal of the objective of ticket #34:
The Cafu engine runs now as a wxWidgets application! ;-)
The most important loose ends have already been tied up, such as app initialization and mouse and keyboard event forwarding, but there are also many details left that for clarity have been scheduled for separate revisions.

Files:
1 modified

Legend:

Unmodified
Added
Removed
  • cafu/branches/cafu_to_wx/SConscript

    r107 r116  
    4949    # glu32 is only needed for the TerrainViewerOld... 
    5050    envTools.Append(LIBS=Split("SceneGraph MatSys cfsCoreLib cfsLib ClipSys cfs_png cfs_jpeg bulletcollision lua minizip lightwave z") 
    51                        + Split("gdi32 glu32 opengl32 user32") + ['dinput', 'dxguid']) 
     51                       + Split("gdi32 glu32 opengl32 user32") + ['cfsOpenGL', 'dinput', 'dxguid']) 
    5252elif sys.platform=="linux2": 
    5353    # envTools.Append(LINKFLAGS = ['-Wl,--export-dynamic'])     # Not needed any more, .so libs now link to the required .a libs directly, just as under Windows. 
    5454    # GLU is needed for the TerrainViewerOld *and* for e.g. gluBuild2DMipmaps() in the renderers... 
    5555    envTools.Append(CPPPATH=['/usr/include/freetype2'])         # As of 2009-09-10, this line is to become unnecessary in the future, see /usr/include/ftbuild.h for details. 
    56     envTools.Append(LIBS=Split("SceneGraph MatSys cfsLib cfsCoreLib cfsLib ClipSys cfs_png cfs_jpeg bulletcollision lua minizip lightwave z") 
     56    envTools.Append(LIBS=Split("SceneGraph MatSys cfsOpenGL cfsLib cfsCoreLib cfsLib ClipSys cfs_png cfs_jpeg bulletcollision lua minizip lightwave z") 
    5757                       + Split("GL GLU")) 
    5858 
     
    7676 
    7777 
    78 envCafu = env.Clone() 
    79 envCafu.Append(CPPPATH=['ExtLibs/lua/src']) 
    80  
    81 CafuMainObj     = envCafu.StaticObject("Ca3DE/Ca3DE",      "Ca3DE/Cafu.cpp") 
    82 CafuMainDediObj = envCafu.StaticObject("Ca3DE/Ca3DE-dedi", "Ca3DE/Cafu.cpp", CPPDEFINES=env['CPPDEFINES']+['CAFU_DEDICATED_SERVER']) 
    83  
    84 EngineCommonAndServerObjs = envCafu.StaticObject(Split(""" 
    85     Ca3DE/Both/Ca3DEWorld.cpp Ca3DE/Both/EntityManager.cpp Ca3DE/Both/EngineEntity.cpp 
    86     Ca3DE/Server/Server.cpp Ca3DE/Server/ServerWorld.cpp Ca3DE/Server/ClientInfo.cpp""")) 
     78# Create a common construction environment for our wxWidgets-based programs (Cafu and CaWE). 
     79wxEnv = env.Clone() 
    8780 
    8881if sys.platform=="win32": 
    89     envCafu.Append(LIBPATH=['ExtLibs/DirectX7/lib']) 
    90     envCafu.Append(LIBS=Split("SceneGraph MatSys SoundSys cfsLib cfsCoreLib cfs_png cfs_jpeg bulletcollision minizip z lua ClipSys GuiSysNullEditor")) 
    91     envCafu.Append(LIBS=Split("lightwave"))    # For the GuiSys::ModelWindowT class. 
    92     envCafu.Append(LIBS=Split("gdi32 opengl32 user32 wsock32") + ['dinput', 'dxguid']) 
    93     WinResource=envCafu.RES("Ca3DE/Dialog1.rc") + envCafu.RES("Ca3DE/Cafu.rc", CPPPATH=[CompilerSetup.wxMSW_Path+'/include']) 
    94  
    95 elif sys.platform=="linux2": 
    96     WinResource=[] 
    97     # -Wl,-rpath,.           is so that also the . directory is searched for dynamic libraries when they're opened. 
    98     # -Wl,--export-dynamic   is so that the exe exports its symbols so that the MatSys, SoundSys and game .so libs can in turn resolve theirs. 
    99     envCafu.Append(LINKFLAGS = ['-Wl,-rpath,.', '-Wl,--export-dynamic']) 
    100     envCafu.Append(LIBS=Split("MatSys SoundSys SceneGraph cfsLib cfsCoreLib cfs_png cfs_jpeg bulletdynamics bulletcollision bulletmath openal alut mpg123 ogg vorbis vorbisfile minizip z lua lightwave ClipSys GuiSysNullEditor")) 
    101     # We need GLU for e.g. gluBuild2DMipmaps() in the renderers. 
    102     # pthread is needed because some libraries that we load (possibly indirectly), e.g. the libCg.so and libopenal.so, use functions 
    103     # from the pthread library, but have not been linked themselves against it. They rely on the executable to be linked appropriately 
    104     # in order to resolve the pthread symbols. Paul Pluzhnikov states in a newsgroup posting (see [1]) that even if the .so libs were 
    105     # linked against libpthread.so, the main exe still *must* link with -lpthread, too, because: 
    106     # "Note that dlopen()ing an MT library from non-MT executable is not supported on most platforms, certainly not on Linux." 
    107     # [1] http://groups.google.de/group/gnu.gcc.help/browse_thread/thread/1e8f8dfd6027d7fa/ 
    108     # rt is required in order to resolve clock_gettime() in openal-soft. 
    109     envCafu.Append(LIBS=Split("GL GLU rt pthread")) 
    110     # Wrapping -lcfsLib in --whole-archive and --no-whole-archive is required so that the linker puts all symbols that are in libcfsLib.a 
    111     # into the executable, because otherwise, it would omit e.g. some ParticleEngine-related stuff that is not referenced by the engine, 
    112     # and when the game DLL later needs it, we get an "undefined symbol" error from dlopen(). 
    113     # See my post "Having the GNU linker *not* remove unused symbols..." to the gnu.g++.help newsgroup on 2006-04-07, 
    114     # and the replies by Maett and Paul Pluzhnikov. 
    115     # Implementing this by appending to LINKCOM and using --allow-multiple-definition is a SCons-specific hack though, 
    116     # because SCons currently does not support such kind of "wrapping". See my post to the scons-users mailing list on 2006-04-09 
    117     # at http://scons.tigris.org/servlets/BrowseList?list=users&by=thread&from=455553. 
    118     # The "-llightwave, ..." are all needed as a direct consequence of the forced --whole-archive for cfsLib, 
    119     # which in turn requires these... 
    120     # Note that this (using --whole-archive) is actually the proper strategy under Linux (vs. Windows), because this is *the* way 
    121     # in order to make sure that the -fPIC can be handled correctly - otherwise we had to link .so libs with non-fPIC object files... 
    122     envCafu.Append(LINKCOM=" -Wl,--allow-multiple-definition -Wl,--whole-archive -lcfsLib -lbulletdynamics -lbulletcollision -lbulletmath -lopenal -lalut -lmpg123 -logg -lvorbis -lvorbisfile -Wl,--no-whole-archive -llightwave -lz") 
    123  
    124 envCafu.Program('Ca3DE/Cafu', 
    125     CafuMainObj + EngineCommonAndServerObjs + CommonWorldObject + ["Common/WorldMan.cpp"] + WinResource + 
    126     Glob("Ca3DE/Client/*.cpp")) 
    127  
    128 # Build an explicit dedicated server currently only under Linux. 
    129 # Build it with env.Program() instead of envCafu.Program()?  I used env before, and lazily fixed link problems by switching to envCafu... 
    130 if sys.platform=="linux2": 
    131     envCafu.Program('Ca3DE/Cafu-dedicated', CafuMainDediObj + EngineCommonAndServerObjs + CommonWorldObject + ["Common/WorldMan.cpp"]) 
    132  
    133  
    134  
    135 SourceFilesList=(Glob("CaWE/*.cpp") 
    136     +Glob("CaWE/FontWizard/*.cpp") 
    137     +Glob("CaWE/GuiEditor/*.cpp")+Glob("CaWE/GuiEditor/Commands/*.cpp")+Glob("CaWE/GuiEditor/EditorData/*.cpp") 
    138     +Glob("CaWE/MapCommands/*.cpp") 
    139     +Glob("CaWE/MaterialBrowser/*.cpp") 
    140     +Glob("CaWE/ModelEditor/*.cpp") 
    141     +Glob("CaWE/wxExt/*.cpp") 
    142     +Glob("CaWE/wxFB/*.cpp")) 
    143  
    144 wxEnv = env.Clone() 
    145 wxEnv.Append(CPPPATH=['ExtLibs/lua/src', 
    146                       'ExtLibs/noise/src']) 
    147  
    148 if sys.platform=="win32": 
    149     wxPath=CompilerSetup.wxMSW_Path; 
     82    wxPath="#/ExtLibs/wxWidgets"; 
    15083 
    15184    wxEnv.Append(CPPPATH = [wxPath+'/include']) 
     
    16396    LibPath += "_lib" 
    16497 
    165     wxEnv.Append(CPPPATH=['ExtLibs/freetype/include'])      # Linux builds (must) use the systems freetype library instead. 
    16698    wxEnv.Append(LIBPATH = [wxPath+LibPath]) 
    167     wxEnv.Append(LIBS = Split("SceneGraph MatSys cfsLib cfsCoreLib ClipSys cfs_png cfs_jpeg bulletcollision noise lua minizip lightwave z")) 
    168     wxEnv.Append(LIBS = Split("freetype")) 
    169     wxEnv.Append(LIBS = Split("advapi32 comctl32 comdlg32 gdi32 ole32 oleaut32 opengl32 rpcrt4 shell32 user32 winspool wsock32")) 
    17099 
    171100    if buildMode=="dbg": 
     
    176105        wxEnv.Append(LIBS = Split("wxbase29u wxbase29u_net wxjpeg wxmsw29u_adv wxmsw29u_core wxmsw29u_gl wxmsw29u_aui wxmsw29u_propgrid wxregexu")) 
    177106 
    178     WinResource=wxEnv.RES("CaWE/CaWE.rc") 
     107elif sys.platform=="linux2": 
     108    # Geht es auch ohne die naechste Zeile? Woher weiss es, dass es freetype linken soll??? 
     109    wxEnv.Append(LIBS = Split("wx_gtk2u_gl-2.9 wx_gtk2u_aui-2.9 wx_gtk2u_propgrid-2.9 wx_gtk2u_xrc-2.9 wx_gtk2u_qa-2.9 wx_gtk2u_html-2.9 wx_gtk2u_adv-2.9 wx_gtk2u_core-2.9 wx_baseu_xml-2.9 wx_baseu_net-2.9 wx_baseu-2.9")) 
     110    wxEnv.ParseConfig(Dir("#/ExtLibs/wxWidgets").abspath + "/build-gtk/wx-config --cxxflags --libs std,gl") 
     111 
     112 
     113 
     114envCafu = wxEnv.Clone() 
     115envCafu.Append(CPPPATH=['ExtLibs/lua/src']) 
     116 
     117if sys.platform=="win32": 
     118    envCafu.Append(LIBS=Split("SceneGraph MatSys SoundSys cfsLib cfsCoreLib cfs_png cfs_jpeg bulletcollision minizip z lua ClipSys GuiSysNullEditor")) 
     119    envCafu.Append(LIBS=Split("lightwave"))    # For the GuiSys::ModelWindowT class. 
     120    envCafu.Append(LIBS=Split("advapi32 comctl32 comdlg32 gdi32 ole32 oleaut32 opengl32 rpcrt4 shell32 user32 winspool wsock32")) 
     121 
     122    WinResource=envCafu.RES("Ca3DE/Cafu.rc")    # + envCafu.RES("Ca3DE/Dialog1.rc") 
    179123 
    180124elif sys.platform=="linux2": 
    181     wxPath=Dir(CompilerSetup.wxGTK_Path).abspath; 
     125    # -Wl,-rpath,.           is so that also the . directory is searched for dynamic libraries when they're opened. 
     126    # -Wl,--export-dynamic   is so that the exe exports its symbols so that the MatSys, SoundSys and game .so libs can in turn resolve theirs. 
     127    envCafu.Append(LINKFLAGS = ['-Wl,-rpath,.', '-Wl,--export-dynamic']) 
     128    envCafu.Append(LIBS=Split("MatSys SoundSys SceneGraph cfsLib cfsCoreLib cfs_png cfs_jpeg bulletdynamics bulletcollision bulletmath openal alut mpg123 ogg vorbis vorbisfile minizip z lua lightwave ClipSys GuiSysNullEditor")) 
    182129 
    183     wxEnv.Append(CPPPATH=['/usr/include/freetype2'])        # As of 2009-09-10, this line is to become unnecessary in the future, see /usr/include/ftbuild.h for details. 
    184     wxEnv.Append(LINKFLAGS = ['-Wl,--export-dynamic'])      # Need this so that the Renderer DLLs can have their unresolved symbols dynamically resolved at load time. 
    185     wxEnv.Append(LIBS = Split("SceneGraph MatSys cfsCoreLib cfsLib ClipSys cfs_png cfs_jpeg bulletcollision noise lua minizip lightwave z")) 
     130    # We need GLU for e.g. gluBuild2DMipmaps() in the renderers. 
     131    # pthread is needed because some libraries that we load (possibly indirectly), e.g. the libCg.so and libopenal.so, use functions 
     132    # from the pthread library, but have not been linked themselves against it. They rely on the executable to be linked appropriately 
     133    # in order to resolve the pthread symbols. Paul Pluzhnikov states in a newsgroup posting (see [1]) that even if the .so libs were 
     134    # linked against libpthread.so, the main exe still *must* link with -lpthread, too, because: 
     135    # "Note that dlopen()ing an MT library from non-MT executable is not supported on most platforms, certainly not on Linux." 
     136    # [1] http://groups.google.de/group/gnu.gcc.help/browse_thread/thread/1e8f8dfd6027d7fa/ 
     137    # rt is required in order to resolve clock_gettime() in openal-soft. 
     138    envCafu.Append(LIBS=Split("GL GLU rt pthread")) 
    186139 
    187     wxEnv.Append(LIBS = Split("wx_gtk2u_gl-2.9 wx_gtk2u_aui-2.9 wx_gtk2u_propgrid-2.9 wx_gtk2u_xrc-2.9 wx_gtk2u_qa-2.9 wx_gtk2u_html-2.9 wx_gtk2u_adv-2.9 wx_gtk2u_core-2.9 wx_baseu_xml-2.9 wx_baseu_net-2.9 wx_baseu-2.9")) 
    188     wxEnv.ParseConfig(wxPath + "/build-gtk/wx-config --cxxflags --libs std,gl") 
     140    # Wrapping -lcfsLib in --whole-archive and --no-whole-archive is required so that the linker puts all symbols that are in libcfsLib.a 
     141    # into the executable, because otherwise, it would omit e.g. some ParticleEngine-related stuff that is not referenced by the engine, 
     142    # and when the game DLL later needs it, we get an "undefined symbol" error from dlopen(). 
     143    # See my post "Having the GNU linker *not* remove unused symbols..." to the gnu.g++.help newsgroup on 2006-04-07, 
     144    # and the replies by Maett and Paul Pluzhnikov. 
     145    # Implementing this by appending to LINKCOM and using --allow-multiple-definition is a SCons-specific hack though, 
     146    # because SCons currently does not support such kind of "wrapping". See my post to the scons-users mailing list on 2006-04-09 
     147    # at http://scons.tigris.org/servlets/BrowseList?list=users&by=thread&from=455553. 
     148    # The "-llightwave, ..." are all needed as a direct consequence of the forced --whole-archive for cfsLib, 
     149    # which in turn requires these... 
     150    # Note that this (using --whole-archive) is actually the proper strategy under Linux (vs. Windows), because this is *the* way 
     151    # in order to make sure that the -fPIC can be handled correctly - otherwise we had to link .so libs with non-fPIC object files... 
     152    envCafu.Append(LINKCOM=" -Wl,--allow-multiple-definition -Wl,--whole-archive -lcfsLib -lbulletdynamics -lbulletcollision -lbulletmath -lopenal -lalut -lmpg123 -logg -lvorbis -lvorbisfile -Wl,--no-whole-archive -llightwave -lz") 
    189153 
    190154    WinResource=[] 
    191155 
    192 wxEnv.Program('CaWE/CaWE', SourceFilesList + WinResource + CommonWorldObject) 
     156EngineCommonAndServerObjs = envCafu.StaticObject(Split("""Ca3DE/AppCafu.cpp Ca3DE/MainCanvas.cpp Ca3DE/MainFrame.cpp Ca3DE/ConDefs.cpp 
     157    Ca3DE/Both/Ca3DEWorld.cpp Ca3DE/Both/EntityManager.cpp Ca3DE/Both/EngineEntity.cpp 
     158    Ca3DE/Server/Server.cpp Ca3DE/Server/ServerWorld.cpp Ca3DE/Server/ClientInfo.cpp""")) 
     159 
     160envCafu.Program('Ca3DE/Cafu', 
     161    EngineCommonAndServerObjs + CommonWorldObject + ["Common/WorldMan.cpp"] + WinResource + 
     162    Glob("Ca3DE/Client/*.cpp")) 
     163 
     164 
     165 
     166envCaWE = wxEnv.Clone() 
     167envCaWE.Append(CPPPATH=['ExtLibs/lua/src', 'ExtLibs/noise/src']) 
     168envCaWE.Append(LIBS = Split("SceneGraph MatSys cfsCoreLib cfsLib ClipSys cfs_png cfs_jpeg bulletcollision noise lua minizip lightwave z")) 
     169 
     170if sys.platform=="win32": 
     171    envCaWE.Append(CPPPATH=['ExtLibs/freetype/include'])    # Windows builds use our local copy, Linux builds (must) use the systems freetype library instead. 
     172    envCaWE.Append(LIBS = Split("freetype")) 
     173    envCaWE.Append(LIBS = Split("advapi32 comctl32 comdlg32 gdi32 ole32 oleaut32 opengl32 rpcrt4 shell32 user32 winspool wsock32")) 
     174 
     175    WinResource=envCaWE.RES("CaWE/CaWE.rc") 
     176 
     177elif sys.platform=="linux2": 
     178    envCaWE.Append(CPPPATH=['/usr/include/freetype2'])      # As of 2009-09-10, this line is to become unnecessary in the future, see /usr/include/ftbuild.h for details. 
     179    envCaWE.Append(LINKFLAGS = ['-Wl,--export-dynamic'])    # Need this so that the Renderer DLLs can have their unresolved symbols dynamically resolved at load time. 
     180 
     181    WinResource=[] 
     182 
     183SourceFilesList=(Glob("CaWE/*.cpp") 
     184    +Glob("CaWE/FontWizard/*.cpp") 
     185    +Glob("CaWE/GuiEditor/*.cpp")+Glob("CaWE/GuiEditor/Commands/*.cpp")+Glob("CaWE/GuiEditor/EditorData/*.cpp") 
     186    +Glob("CaWE/MapCommands/*.cpp") 
     187    +Glob("CaWE/MaterialBrowser/*.cpp") 
     188    +Glob("CaWE/ModelEditor/*.cpp") 
     189    +Glob("CaWE/wxExt/*.cpp") 
     190    +Glob("CaWE/wxFB/*.cpp")) 
     191 
     192envCaWE.Program('CaWE/CaWE', SourceFilesList + WinResource + CommonWorldObject)