Changeset 116

Show
Ignore:
Timestamp:
08/13/10 22:27:00 (18 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.

Location:
cafu/branches/cafu_to_wx
Files:
8 added
4 modified

Legend:

Unmodified
Added
Removed
  • cafu/branches/cafu_to_wx/Ca3DE/Client/ClientStateInGame.cpp

    r48 r116  
    2222*/ 
    2323 
     24#include "../AppCafu.hpp" 
     25#include "../MainCanvas.hpp" 
     26#include "../MainFrame.hpp" 
     27#include "../NetConst.hpp" 
     28 
    2429#include "ClientStateInGame.hpp" 
    2530#include "Client.hpp" 
     
    2732#include "PathRecorder.hpp" 
    2833 
    29 #include "../NetConst.hpp" 
    3034#include "GuiSys/Gui.hpp" 
    3135#include "GuiSys/GuiMan.hpp" 
     
    359363void ClientStateInGameT::Render(float FrameTime) 
    360364{ 
     365    const wxSize FrameSize=wxGetApp().GetMainFrame()->GetClientSize(); 
     366 
    361367    Graphs.ClearForFrame(ClientFrameNr); 
    362368 
     
    383389            static ConVarT ShowPosition("showPos", false, ConVarT::FLAG_MAIN_EXE, "Toggles whether the current players position is shown."); 
    384390 
    385             if (ShowFrameRate.GetValueBool()) Font_f.Print(SingleOpenGLWindow->GetWidth()-100, SingleOpenGLWindow->GetHeight()-16, 0x00FFFFFF, "FPS %5.1f", 1.0f/FrameTime); 
     391            if (ShowFrameRate.GetValueBool()) Font_f.Print(FrameSize.GetWidth()-100, FrameSize.GetHeight()-16, FrameSize.GetWidth(), FrameSize.GetHeight(), 0x00FFFFFF, "FPS %5.1f", 1.0f/FrameTime); 
    386392 
    387393            if (ShowPosition.GetValueBool()) 
     
    393399                //     LeafContents=World->GetCa3DEWorldP()->Map.Leaves[LeafNr].IsWaterLeaf ? 'w' : 'i'; 
    394400 
    395                 Font_f.Print(SingleOpenGLWindow->GetWidth()-130, 15, 0x00FFFFFF, "X %10.1f", OurEntityCurrentState->Origin.x); 
    396                 Font_f.Print(SingleOpenGLWindow->GetWidth()-130, 35, 0x00FFFFFF, "Y %10.1f", OurEntityCurrentState->Origin.y); 
    397                 Font_f.Print(SingleOpenGLWindow->GetWidth()-130, 55, 0x00FFFFFF, "Z %10.1f", OurEntityCurrentState->Origin.z); 
    398                 Font_f.Print(SingleOpenGLWindow->GetWidth()-130, 75, 0x00FFFFFF, "Hdg %8u", OurEntityCurrentState->Heading); 
    399              // Font_f.Print(SingleOpenGLWindow->GetWidth()-100, SingleOpenGLWindow->GetHeight()-32, 0x00FFFFFF, "L %4u %c", LeafNr, LeafContents); 
     401                Font_f.Print(FrameSize.GetWidth()-130, 15, FrameSize.GetWidth(), FrameSize.GetHeight(), 0x00FFFFFF, "X %10.1f", OurEntityCurrentState->Origin.x); 
     402                Font_f.Print(FrameSize.GetWidth()-130, 35, FrameSize.GetWidth(), FrameSize.GetHeight(), 0x00FFFFFF, "Y %10.1f", OurEntityCurrentState->Origin.y); 
     403                Font_f.Print(FrameSize.GetWidth()-130, 55, FrameSize.GetWidth(), FrameSize.GetHeight(), 0x00FFFFFF, "Z %10.1f", OurEntityCurrentState->Origin.z); 
     404                Font_f.Print(FrameSize.GetWidth()-130, 75, FrameSize.GetWidth(), FrameSize.GetHeight(), 0x00FFFFFF, "Hdg %8u", OurEntityCurrentState->Heading); 
     405             // Font_f.Print(FrameSize.GetWidth()-100, FrameSize.GetHeight()-32, FrameSize.GetWidth(), FrameSize.GetHeight(), 0x00FFFFFF, "L %4u %c", LeafNr, LeafContents); 
    400406            } 
    401407 
     
    412418        else 
    413419        { 
    414             Font_f.Print(30, SingleOpenGLWindow->GetHeight()*2/3, 0x00004080, "Receiving entity baselines..."); 
     420            Font_f.Print(30, FrameSize.GetHeight()*2/3, FrameSize.GetWidth(), FrameSize.GetHeight(), 0x00004080, "Receiving entity baselines..."); 
    415421        } 
    416422    } 
     
    426432            MatSys::Renderer->SetMatrix(MatSys::RendererI::MODEL_TO_WORLD, MatrixT()); 
    427433            MatSys::Renderer->SetMatrix(MatSys::RendererI::WORLD_TO_VIEW,  MatrixT()); 
    428             MatSys::Renderer->SetMatrix(MatSys::RendererI::PROJECTION,     MatrixT::GetProjOrthoMatrix(0.0f, float(SingleOpenGLWindow->GetWidth()), float(SingleOpenGLWindow->GetHeight()), 0.0f, -1.0f, 1.0f)); 
     434            MatSys::Renderer->SetMatrix(MatSys::RendererI::PROJECTION,     MatrixT::GetProjOrthoMatrix(0.0f, float(FrameSize.GetWidth()), float(FrameSize.GetHeight()), 0.0f, -1.0f, 1.0f)); 
    429435 
    430436            MatSys::Renderer->SetCurrentRenderAction(MatSys::RendererI::AMBIENT); 
     
    442448                // The coordinates have also been tested with a hor. and ver. stripe pattern texture for making sure that there is no 
    443449                // inadvertent scaling by plus or minus one pixel. 
    444                 M.Vertices[0].SetOrigin(SingleOpenGLWindow->GetWidth()/2.0f-512.0f, SingleOpenGLWindow->GetHeight()/2.0f-256.0f-20.0f); // links  oben 
    445                 M.Vertices[1].SetOrigin(SingleOpenGLWindow->GetWidth()/2.0f+512.0f, SingleOpenGLWindow->GetHeight()/2.0f-256.0f-20.0f); // rechts oben 
    446                 M.Vertices[2].SetOrigin(SingleOpenGLWindow->GetWidth()/2.0f+512.0f, SingleOpenGLWindow->GetHeight()/2.0f+256.0f-20.0f); // rechts unten 
    447                 M.Vertices[3].SetOrigin(SingleOpenGLWindow->GetWidth()/2.0f-512.0f, SingleOpenGLWindow->GetHeight()/2.0f+256.0f-20.0f); // links  unten 
     450                M.Vertices[0].SetOrigin(FrameSize.GetWidth()/2.0f-512.0f, FrameSize.GetHeight()/2.0f-256.0f-20.0f); // links  oben 
     451                M.Vertices[1].SetOrigin(FrameSize.GetWidth()/2.0f+512.0f, FrameSize.GetHeight()/2.0f-256.0f-20.0f); // rechts oben 
     452                M.Vertices[2].SetOrigin(FrameSize.GetWidth()/2.0f+512.0f, FrameSize.GetHeight()/2.0f+256.0f-20.0f); // rechts unten 
     453                M.Vertices[3].SetOrigin(FrameSize.GetWidth()/2.0f-512.0f, FrameSize.GetHeight()/2.0f+256.0f-20.0f); // links  unten 
    448454 
    449455                MatSys::Renderer->SetCurrentMaterial(LogoRenderMat); 
     
    453459 
    454460        #if 0 
    455             const unsigned long BarHalfWidth=SingleOpenGLWindow->GetWidth()/2-40; 
     461            const unsigned long BarHalfWidth=FrameSize.GetWidth()/2-40; 
    456462 
    457463            // Render the left end of the loading bar. 
    458464            { 
    459                 M.Vertices[0].SetOrigin(SingleOpenGLWindow->GetWidth()/2-BarHalfWidth-16, SingleOpenGLWindow->GetHeight()*9/10-20   ); 
    460                 M.Vertices[1].SetOrigin(SingleOpenGLWindow->GetWidth()/2-BarHalfWidth   , SingleOpenGLWindow->GetHeight()*9/10-20   ); 
    461                 M.Vertices[2].SetOrigin(SingleOpenGLWindow->GetWidth()/2-BarHalfWidth   , SingleOpenGLWindow->GetHeight()*9/10-20+32); 
    462                 M.Vertices[3].SetOrigin(SingleOpenGLWindow->GetWidth()/2-BarHalfWidth-16, SingleOpenGLWindow->GetHeight()*9/10-20+32); 
     465                M.Vertices[0].SetOrigin(FrameSize.GetWidth()/2-BarHalfWidth-16, FrameSize.GetHeight()*9/10-20   ); 
     466                M.Vertices[1].SetOrigin(FrameSize.GetWidth()/2-BarHalfWidth   , FrameSize.GetHeight()*9/10-20   ); 
     467                M.Vertices[2].SetOrigin(FrameSize.GetWidth()/2-BarHalfWidth   , FrameSize.GetHeight()*9/10-20+32); 
     468                M.Vertices[3].SetOrigin(FrameSize.GetWidth()/2-BarHalfWidth-16, FrameSize.GetHeight()*9/10-20+32); 
    463469 
    464470                MatSys::Renderer->SetCurrentMaterial(LoadingBarLMat); 
     
    468474            // Render the center left (filled) part of the loading bar. 
    469475            { 
    470                 M.Vertices[0].SetOrigin(SingleOpenGLWindow->GetWidth()/2-BarHalfWidth                               , SingleOpenGLWindow->GetHeight()*9/10-20   ); 
    471                 M.Vertices[1].SetOrigin(SingleOpenGLWindow->GetWidth()/2-BarHalfWidth+2*BarHalfWidth*ProgressPercent, SingleOpenGLWindow->GetHeight()*9/10-20   ); 
    472                 M.Vertices[2].SetOrigin(SingleOpenGLWindow->GetWidth()/2-BarHalfWidth+2*BarHalfWidth*ProgressPercent, SingleOpenGLWindow->GetHeight()*9/10-20+32); 
    473                 M.Vertices[3].SetOrigin(SingleOpenGLWindow->GetWidth()/2-BarHalfWidth                               , SingleOpenGLWindow->GetHeight()*9/10-20+32); 
     476                M.Vertices[0].SetOrigin(FrameSize.GetWidth()/2-BarHalfWidth                               , FrameSize.GetHeight()*9/10-20   ); 
     477                M.Vertices[1].SetOrigin(FrameSize.GetWidth()/2-BarHalfWidth+2*BarHalfWidth*ProgressPercent, FrameSize.GetHeight()*9/10-20   ); 
     478                M.Vertices[2].SetOrigin(FrameSize.GetWidth()/2-BarHalfWidth+2*BarHalfWidth*ProgressPercent, FrameSize.GetHeight()*9/10-20+32); 
     479                M.Vertices[3].SetOrigin(FrameSize.GetWidth()/2-BarHalfWidth                               , FrameSize.GetHeight()*9/10-20+32); 
    474480 
    475481                MatSys::Renderer->SetCurrentMaterial(LoadingBar1Mat); 
     
    479485            // Render the center right (not yet filled) part of the loading bar. 
    480486            { 
    481                 M.Vertices[0].SetOrigin(SingleOpenGLWindow->GetWidth()/2-BarHalfWidth+2*BarHalfWidth*ProgressPercent, SingleOpenGLWindow->GetHeight()*9/10-20   ); 
    482                 M.Vertices[1].SetOrigin(SingleOpenGLWindow->GetWidth()/2+BarHalfWidth                               , SingleOpenGLWindow->GetHeight()*9/10-20   ); 
    483                 M.Vertices[2].SetOrigin(SingleOpenGLWindow->GetWidth()/2+BarHalfWidth                               , SingleOpenGLWindow->GetHeight()*9/10-20+32); 
    484                 M.Vertices[3].SetOrigin(SingleOpenGLWindow->GetWidth()/2-BarHalfWidth+2*BarHalfWidth*ProgressPercent, SingleOpenGLWindow->GetHeight()*9/10-20+32); 
     487                M.Vertices[0].SetOrigin(FrameSize.GetWidth()/2-BarHalfWidth+2*BarHalfWidth*ProgressPercent, FrameSize.GetHeight()*9/10-20   ); 
     488                M.Vertices[1].SetOrigin(FrameSize.GetWidth()/2+BarHalfWidth                               , FrameSize.GetHeight()*9/10-20   ); 
     489                M.Vertices[2].SetOrigin(FrameSize.GetWidth()/2+BarHalfWidth                               , FrameSize.GetHeight()*9/10-20+32); 
     490                M.Vertices[3].SetOrigin(FrameSize.GetWidth()/2-BarHalfWidth+2*BarHalfWidth*ProgressPercent, FrameSize.GetHeight()*9/10-20+32); 
    485491 
    486492                MatSys::Renderer->SetCurrentMaterial(LoadingBar0Mat); 
     
    490496            // Render the right end of the loading bar. 
    491497            { 
    492                 M.Vertices[0].SetOrigin(SingleOpenGLWindow->GetWidth()/2+BarHalfWidth   , SingleOpenGLWindow->GetHeight()*9/10-20   ); 
    493                 M.Vertices[1].SetOrigin(SingleOpenGLWindow->GetWidth()/2+BarHalfWidth+16, SingleOpenGLWindow->GetHeight()*9/10-20   ); 
    494                 M.Vertices[2].SetOrigin(SingleOpenGLWindow->GetWidth()/2+BarHalfWidth+16, SingleOpenGLWindow->GetHeight()*9/10-20+32); 
    495                 M.Vertices[3].SetOrigin(SingleOpenGLWindow->GetWidth()/2+BarHalfWidth   , SingleOpenGLWindow->GetHeight()*9/10-20+32); 
     498                M.Vertices[0].SetOrigin(FrameSize.GetWidth()/2+BarHalfWidth   , FrameSize.GetHeight()*9/10-20   ); 
     499                M.Vertices[1].SetOrigin(FrameSize.GetWidth()/2+BarHalfWidth+16, FrameSize.GetHeight()*9/10-20   ); 
     500                M.Vertices[2].SetOrigin(FrameSize.GetWidth()/2+BarHalfWidth+16, FrameSize.GetHeight()*9/10-20+32); 
     501                M.Vertices[3].SetOrigin(FrameSize.GetWidth()/2+BarHalfWidth   , FrameSize.GetHeight()*9/10-20+32); 
    496502 
    497503                MatSys::Renderer->SetCurrentMaterial(LoadingBarRMat); 
     
    507513 
    508514            #ifdef DEBUG 
    509                 LoadingFont->Print(SingleOpenGLWindow->GetWidth()/2-34*CharWidth/2, SingleOpenGLWindow->GetHeight()*9/10+12, 0x00800000, "Version: %s [Debug build], %s", __DATE__, LoadingProgressText.c_str()); 
     515                LoadingFont->Print(FrameSize.GetWidth()/2-34*CharWidth/2, FrameSize.GetHeight()*9/10+12, FrameSize.GetWidth(), FrameSize.GetHeight(), 0x00800000, "Version: %s [Debug build], %s", __DATE__, LoadingProgressText.c_str()); 
    510516            #else 
    511                 LoadingFont->Print(SingleOpenGLWindow->GetWidth()/2-20*CharWidth/2, SingleOpenGLWindow->GetHeight()*9/10+12, 0x00800000, "Version: %s", __DATE__); 
     517                LoadingFont->Print(FrameSize.GetWidth()/2-20*CharWidth/2, FrameSize.GetHeight()*9/10+12, FrameSize.GetWidth(), FrameSize.GetHeight(), 0x00800000, "Version: %s", __DATE__); 
    512518            #endif 
    513519 
    514520            if (LoadingProgressPercent>0) 
    515                 LoadingFont->Print(SingleOpenGLWindow->GetWidth()/2-10*CharWidth/2, SingleOpenGLWindow->GetHeight()*9/10+30, 0x00800000, "Loading... %.0f%%", LoadingProgressPercent*100.0f); 
     521                LoadingFont->Print(FrameSize.GetWidth()/2-10*CharWidth/2, FrameSize.GetHeight()*9/10+30, FrameSize.GetWidth(), FrameSize.GetHeight(), 0x00800000, "Loading... %.0f%%", LoadingProgressPercent*100.0f); 
    516522            else 
    517                 LoadingFont->Print(SingleOpenGLWindow->GetWidth()/2-10*CharWidth/2, SingleOpenGLWindow->GetHeight()*9/10+30, 0x00800000, "Loading..."); 
     523                LoadingFont->Print(FrameSize.GetWidth()/2-10*CharWidth/2, FrameSize.GetHeight()*9/10+30, FrameSize.GetWidth(), FrameSize.GetHeight(), 0x00800000, "Loading..."); 
    518524        } 
    519525        else 
     
    521527            // We have no world yet, and are currently not loading one, 
    522528            // which means that we're still waiting for a SC1_WorldInfo message. 
    523             Font_f.Print(5, 200, 0x00DDFFBB, "Waiting for SC1_WorldInfo message..."); 
     529            Font_f.Print(5, 200, FrameSize.GetWidth(), FrameSize.GetHeight(), 0x00DDFFBB, "Waiting for SC1_WorldInfo message..."); 
    524530        } 
    525531    } 
     
    536542    } 
    537543 
    538     ChatScrollInfo  .Draw(Font_v, 5, SingleOpenGLWindow->GetHeight()-10-140); 
     544    ChatScrollInfo  .Draw(Font_v, 5, FrameSize.GetHeight()-10-140, FrameSize.GetWidth(), FrameSize.GetHeight()); 
    539545    ChatScrollInfo  .AdvanceTime(FrameTime); 
    540     SystemScrollInfo.Draw(Font_v, 5, 15); 
     546    SystemScrollInfo.Draw(Font_v, 5, 15, FrameSize.GetWidth(), FrameSize.GetHeight()); 
    541547    SystemScrollInfo.AdvanceTime(FrameTime); 
    542548 
     
    589595 
    590596    MatSys::Renderer->EndFrame(); 
    591     SingleOpenGLWindow->SwapBuffers(); 
     597    wxGetApp().GetMainFrame()->GetMainCanvas()->SwapBuffers(); 
    592598 
    593599    SoundSystem->Update(); 
     
    809815 
    810816        // This is unfortunately needed, because the users last click (in the GUI) that brought us here may still have the "LMB up" event pending. 
     817#if 0 
    811818        WasLMBOnceUp|=(SingleOpenGLWindow->GetMouseButtonState() & 0x1)==0; 
    812819 
     
    843850            if (SingleOpenGLWindow->GetKeyboardState()[CaKeyboardEventT::CK_END        ]) PlayerCommand.Keys|=PCK_CenterView; 
    844851        } 
     852#endif 
    845853 
    846854 
  • cafu/branches/cafu_to_wx/Ca3DE/Client/Graphs.cpp

    r36 r116  
    2626/****************************/ 
    2727 
     28#include "../AppCafu.hpp" 
     29#include "../MainFrame.hpp" 
    2830#include "Graphs.hpp" 
    2931#include "MaterialSystem/MaterialManager.hpp" 
     
    3133#include "MaterialSystem/Renderer.hpp" 
    3234#include "Math3D/Matrix.hpp" 
    33 #include "OpenGL/OpenGLWindow.hpp"      // OpenGL Window 
    3435 
    3536 
     
    8182void GraphsT::Draw(unsigned long ClientFrameNr) 
    8283{ 
     84    const wxSize  FrameSize=wxGetApp().GetMainFrame()->GetClientSize(); 
    8385    unsigned long FrameNr=512; 
    8486 
     
    8991    MatSys::Renderer->SetMatrix(MatSys::RendererI::MODEL_TO_WORLD, MatrixT()); 
    9092    MatSys::Renderer->SetMatrix(MatSys::RendererI::WORLD_TO_VIEW,  MatrixT()); 
    91     MatSys::Renderer->SetMatrix(MatSys::RendererI::PROJECTION,     MatrixT::GetProjOrthoMatrix(0.0f, float(SingleOpenGLWindow->GetWidth()), float(SingleOpenGLWindow->GetHeight()), 0.0f, -1.0f, 1.0f)); 
     93    MatSys::Renderer->SetMatrix(MatSys::RendererI::PROJECTION,     MatrixT::GetProjOrthoMatrix(0.0f, float(FrameSize.GetWidth()), float(FrameSize.GetHeight()), 0.0f, -1.0f, 1.0f)); 
    9294 
    9395    static MatSys::MeshT LinesMesh (MatSys::MeshT::Lines ); LinesMesh .Vertices.Overwrite(); 
     
    100102        LinesMesh.Vertices.PushBackEmpty(); 
    101103        LinesMesh.Vertices[LinesMesh.Vertices.Size()-1].SetColor(0.5, 0.5, 0.5); 
    102         LinesMesh.Vertices[LinesMesh.Vertices.Size()-1].SetOrigin((SingleOpenGLWindow->GetWidth()-512)/2+FrameNr, SingleOpenGLWindow->GetHeight()-10); 
     104        LinesMesh.Vertices[LinesMesh.Vertices.Size()-1].SetOrigin((FrameSize.GetWidth()-512)/2+FrameNr, FrameSize.GetHeight()-10); 
    103105 
    104106        LinesMesh.Vertices.PushBackEmpty(); 
    105107        LinesMesh.Vertices[LinesMesh.Vertices.Size()-1].SetColor(0.5, 0.5, 0.5); 
    106         LinesMesh.Vertices[LinesMesh.Vertices.Size()-1].SetOrigin((SingleOpenGLWindow->GetWidth()-512)/2+FrameNr, SingleOpenGLWindow->GetHeight()-10-FPS[FrameIndex]); 
     108        LinesMesh.Vertices[LinesMesh.Vertices.Size()-1].SetOrigin((FrameSize.GetWidth()-512)/2+FrameNr, FrameSize.GetHeight()-10-FPS[FrameIndex]); 
    107109 
    108110 
    109111        PointsMesh.Vertices.PushBackEmpty(); 
    110112        PointsMesh.Vertices[PointsMesh.Vertices.Size()-1].SetColor(1.0, 0.0, 1.0); 
    111         PointsMesh.Vertices[PointsMesh.Vertices.Size()-1].SetOrigin((SingleOpenGLWindow->GetWidth()-512)/2+FrameNr, SingleOpenGLWindow->GetHeight()-10-Heading[FrameIndex]); 
     113        PointsMesh.Vertices[PointsMesh.Vertices.Size()-1].SetOrigin((FrameSize.GetWidth()-512)/2+FrameNr, FrameSize.GetHeight()-10-Heading[FrameIndex]); 
    112114 
    113115        PointsMesh.Vertices.PushBackEmpty(); 
    114116        PointsMesh.Vertices[PointsMesh.Vertices.Size()-1].SetColor(0.0, 1.0, 0.0); 
    115         PointsMesh.Vertices[PointsMesh.Vertices.Size()-1].SetOrigin((SingleOpenGLWindow->GetWidth()-512)/2+FrameNr, SingleOpenGLWindow->GetHeight()-10-PosY[FrameIndex]); 
     117        PointsMesh.Vertices[PointsMesh.Vertices.Size()-1].SetOrigin((FrameSize.GetWidth()-512)/2+FrameNr, FrameSize.GetHeight()-10-PosY[FrameIndex]); 
    116118 
    117119        PointsMesh.Vertices.PushBackEmpty(); 
    118120        PointsMesh.Vertices[PointsMesh.Vertices.Size()-1].SetColor(0.0, 0.0, 1.0); 
    119         PointsMesh.Vertices[PointsMesh.Vertices.Size()-1].SetOrigin((SingleOpenGLWindow->GetWidth()-512)/2+FrameNr, SingleOpenGLWindow->GetHeight()-10-PosZ[FrameIndex]); 
     121        PointsMesh.Vertices[PointsMesh.Vertices.Size()-1].SetOrigin((FrameSize.GetWidth()-512)/2+FrameNr, FrameSize.GetHeight()-10-PosZ[FrameIndex]); 
    120122 
    121123        ClientFrameNr--; 
  • cafu/branches/cafu_to_wx/CompilerSetup.py.tmpl

    r104 r116  
    2727#   # Print all valid values for MSVC_VERSION on your system. 
    2828#   envCommon=Environment(MSVC_VERSION="XXX"); 
    29 #      
     29# 
    3030#   # Use Visual C/C++ version 9 (2008), Express Edition. 
    3131#   envCommon=Environment(MSVC_VERSION="9.0Exp"); 
    32 #      
     32# 
    3333#   # Use the latest Visual C/C++ version for creating 32 bit binaries. 
    3434#   envCommon=Environment(TARGET_ARCH="x86"); 
    35 #      
     35# 
    3636#   # Use Visual C/C++ version 9 (2008) for creating 32 bit binaries. 
    3737#   envCommon=Environment(MSVC_VERSION="9.0", TARGET_ARCH="x86"); 
     
    5050# Example: scons -Q bv=dpr 
    5151buildVariants="dr"; 
    52  
    53  
    54 # These settings specify where the wxWidgets toolkit is found under Windows and 
    55 # Linux. If you followed the instructions in the Cafu documentation at 
    56 # http://www.cafu.de/wiki/, the given default value should be OK for both 
    57 # wxMSW (Windows) and wxGTK (Linux), so there is no need to change it. 
    58 wxMSW_Path="#/ExtLibs/wxWidgets";     # The given value should be OK. 
    59 wxGTK_Path="#/ExtLibs/wxWidgets";     # The given value should be OK. 
  • 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)