VS2008环境下CEGUI 0.7.1及相关工具的编译(转载 + 额外的注意事项)

原文地址:http://blog.sina.com.cn/s/blog_6841a32d0100jtcw.html

作者:孩儿他爹

一、概述

    对于游戏的界面开发而言,CEGUI是一个不错的选择。但是CEGUI及其相关工具用到了很多第三方库,从而导致编译步骤比较复杂,让新人无从下手。所以我在这里介绍一下CEGUI 0.7.1 以及 CEImagesetEditor 和 CELayoutEditor 的编译。希望能够对准备学习CEGUI的童鞋们有所帮助:)

二、准备

我们需要用到

0. DirectX 9 SDK,这个自己找

1. CEGUI 0.7.1,下载地址:http://prdownloads.sourceforge.net/crayzedsgui/CEGUI-0.7.1.zip?download

2. CEGUI 0.7.1 precompiled dependencies for VC++ 2008,因为CEGUI用到了很多第三方库,自己编译很麻烦,而且一般情况下我们又不会对这些库做修改,所以借用编译好的文件就可以了。
下载地址:
http://prdownloads.sourceforge.net/crayzedsgui/CEGUI-DEPS-0.7.x-r1-vc9.zip?download

也可以使用CEGUI 0.7.1 precompiled SDK for MSVC++ 2008, 下载地址:
http://prdownloads.sourceforge.net/crayzedsgui/CEGUI-SDK-0.7.1-vc9.zip?download

3. wxWidgets 2.8.11,开源跨平台的GUI库,CEImagesetEditor和CELayoutEditor用到它了。
下载地址:
http://prdownloads.sourceforge.net/wxwindows/wxMSW-2.8.11-Setup.exe

4. CEImagesetEditor 0.7.1,下载地址:
http://prdownloads.sourceforge.net/crayzedsgui/CEImagesetEditor-0.7.1.tar.gz?download

5. CELayoutEditor 0.7.1,下载地址:
http://prdownloads.sourceforge.net/crayzedsgui/CELayoutEditor-0.7.1.tar.gz?download

三、编译CEGUI

0. 准备好CEGUI、CEGUI-SDK和DirectX9 SDK
1. 将下载的CEGUI、CEGUI-SDK(dependencies)解压缩
2. 将CEGUI-SDK(dependencies)中的dependencies文件夹拷贝到CEGUI的目录中(与datafiles同级)。其中有许多的.h、.lib和.dll文件我们用不到,可以酌情删除
3. 将DirectX9 SDK中的include 和 lib文件拷贝到dependencies文件夹中,我这里dx相关的目录层次如下
 CEGUI-0.7.1
  dependencies
   dx90sdk
    include
    lib
3. 修改CEGUI中的config.lua文件,我这里只使用freeimage,所以将其它编码器设为了false
 ----------------
 -- Image Codecs
 -- this controls which image codecs are built
 TGA_IMAGE_CODEC = false
 SILLY_IMAGE_CODEC = false
 DEVIL_IMAGE_CODEC = false
 FREEIMAGE_IMAGE_CODEC = true
 CORONA_IMAGE_CODEC = false
 
 -- this setting selects the default image codec module
 -- can be either "tga", "silly", "devil", "freeimage" or "corona"
 -- SILLY was written for CEGUI
 DEFAULT_IMAGE_CODEC = "freeimage"
4. 修改helpers.lua文件,添加directx的包含路径和lib路径
 4.1 添加dx9的include路径
 -- defaults
 package.includepaths =
 {
  rootdir.."cegui/include",
  rootdir.."dependencies/include",
  rootdir.."dependencies/dx90sdk/include", -- 添加dx9的include路径
 }
 4.2 添加dx9的lib路径
 --4.2.1-------------------------
 debug.libpaths =
 {
  rootdir.."dependencies/lib/dynamic",
  rootdir.."dependencies/dx90sdk/lib",
 }
 --4.2.2-------------------------
 debug.libpaths =
 {
  rootdir.."dependencies/lib/dynamic",
  rootdir.."dependencies/dx90sdk/lib",
 }
 --4.2.3-------------------------
 debug_static.libpaths =
 {
  rootdir.."dependencies/lib/static",
  rootdir.."dependencies/dx90sdk/lib",
 }
 --4.2.4-------------------------
 release_sym.libpaths =
 {
  rootdir.."dependencies/lib/dynamic",
  rootdir.."dependencies/dx90sdk/lib",
 }
 --4.2.5-------------------------
 release.libpaths =
 {
  rootdir.."dependencies/lib/dynamic",
  rootdir.."dependencies/dx90sdk/lib",
 }
 --4.2.6-------------------------
 release_static.libpaths =
 {
  rootdir.."dependencies/lib/static",
  rootdir.."dependencies/dx90sdk/lib",
 }

 4.3 修改链接器所用到的lib文件(原来的制定为dxerr.lib,实际上应该为dxerr9.lib)
 --4.2.7-------------------------
    if DIRECT3D9_RENDERER then
        library_static("dxguid")
        library_static("d3dx9")
        library_static("dxerr9")
    end
5. 修改projectspremakeRendererModulesDirect3D9premake.lua
 library("dxerr9") -- 原来为dxerr
 library("d3dx9", "d")

6. 运行build_vs2008.bat,以生成sln和vcproj文件
7. 打开CEGUI.sln,生成即可

四、编译CELayoutEditor

0. 运行wxMSW-2.8.11-Setup.exe,安装wxWidgets;
   将CELayoutEditor-0.7.1.tar.gz解压缩
1. 添加环境变量CEGUI_7、CE_LAYOUT_EDITOR_7和WXWIDGETS_7,内容分别为CEGUI、CELayoutEditor和wxWidgits的路径
2. 修改wxWidgits下includewxmswsetup.h中的以下语句,以开启wxWidgets的OpenGL支持(CELayoutEditor需要用到):
 #define wxUSE_GLCANVAS       0
 修改为
 #define wxUSE_GLCANVAS       1
3. 使用VS2008打开wxWidgits下buildmsw中的wx.dsw,转换成功后,分别生成Unicode Debug和Unicode Release,这会自动生成libvc_libmswudwxmsw和libvc_libmswuwxmsw两个目录以及相关的文件。之所以选择生成Unicode,是因为默认情况下CELayoutEditor的字符集使用的是UNICODE,如果我们修改了CELayoutEditor的字符集,那么就需要使用相应的配置来生成wxWidgits。
4. 修改CELayoutEditor目录下srcEditorFrame.cpp中EditorFrame::InitializeCEGUI函数中的以下语句:
    // Setup support for TGA,JPG and PNG
    CEGUI::System::setDefaultImageCodecName("SILLYImageCodec");

修改为
    // Setup support for TGA,JPG and PNG
    CEGUI::System::setDefaultImageCodecName("FreeImageImageCodec");
5. 修改CELayoutEditor项目属性中的生成事件==>生成后事件中的以下语句:
Debug属性中:
我们使用FreeImage作为图片解码器,所以将
copy $(CEGUI_7)inCEGUISILLYImageCodec_d.dll $(CE_LAYOUT_EDITOR_7)indebug /Y
copy $(CEGUI_7)inCEGUITGAImageCodec_d.dll $(CE_LAYOUT_EDITOR_7)indebug /Y
修改为
copy $(CEGUI_7)inCEGUIFreeImageImageCodec_d.dll $(CE_LAYOUT_EDITOR_7)indebug /Y
copy $(CEGUI_7)dependenciesinFreeImaged.dll $(CE_IMAGESET_EDITOR)indebug /Y             --------------------(error_1) 
我们不再使用SILLY作为图片解码器,所以将下面这一行删掉
copy $(CEGUI_7)dependenciesinSILLY_d.dll $(CE_LAYOUT_EDITOR_7)indebug /Y
原来的路径写错了,所以将
copy $(CE_LAYOUT_EDITOR_7)srcitmapssplash.png "$(CE_LAYOUT_EDITOR_7)vc++7.1" /Y
修改为
copy $(CE_LAYOUT_EDITOR_7)srcitmapssplash.png "$(CE_LAYOUT_EDITOR_7)vc++9" /Y

Release属性中:
我们使用FreeImage作为图片解码器,所以将
copy $(CEGUI_7)inCEGUISILLYImageCodec.dll $(CE_LAYOUT_EDITOR_7)in elease /Y
copy $(CEGUI_7)inCEGUITGAImageCodec.dll $(CE_LAYOUT_EDITOR_7)in elease /Y
修改为
copy $(CEGUI_7)inCEGUIFreeImageImageCodec.dll $(CE_LAYOUT_EDITOR_7)in elease /Y
copy $(CEGUI_7)dependenciesinFreeImage.dll $(CE_IMAGESET_EDITOR)indebug /Y                  --------------------(error_2)  
我们不再使用SILLY作为图片解码器,所以将下面这一行删掉
copy $(CEGUI_7)dependenciesinSILLY.dll $(CE_LAYOUT_EDITOR_7)in elease /Y
原来的路径写错了,所以将
copy $(CE_LAYOUT_EDITOR_7)srcitmapssplash.png "$(CE_LAYOUT_EDITOR_7)vc++7.1" /Y
修改为
copy $(CE_LAYOUT_EDITOR_7)srcitmapssplash.png "$(CE_LAYOUT_EDITOR_7)vc++9" /Y

6. 在CELayoutEditor的VC++9目录下建立一个新的resource.h文件内容为空。否则会提示找不到这个文件
7. 编译CELayoutEditor即可
8. 如果需要运行,请在生成的目录中新建CELayoutEditor.ini,内容如下:
[SETTINGS]
BigKeyStep=10
SmallKeyStep=1
DefaultFont=
CurrentBackground=
BackgroundVisible=0
CurrentLayout=
ViewWidth=1024
ViewHeight=768
SnapMode=2
GridSize=10
GridVisible=0
ConfigsPath=
FontsPath=
ImagesetsPath=
LookNFeelsPath=
ScriptsPath=
SchemesPath=
LayoutsPath=
SupportedProperties=Alpha,float;ClickStepSize,float;MaximumValue,float;Visible,bool;AlwaysOnTop,bool;ClippedByParent,bool;InheritsAlpha,bool;Selected,bool;ReadOnly,bool;CloseButtonEnabled,bool;DragMovingEnabled,bool;FrameEnabled,bool;SizingEnabled,bool;TitlebarEnabled,bool;MultiSelect,bool;Sort,bool;DraggingEnabled,bool;BackgroundEnabled,bool;InheritsTooltipText,bool;HoverImage,text;PushedImage,text;DisabledImage,text;NormalImage,text;Font,font;TitlebarFont,font;VerticalAlignment,vert_align;HorizontalAlignment,horz_align;VertFormatting,vert_text_format;HorzFormatting,horz_text_format;Tooltip,text;Image,text;TextColours,text;

五、生成CEImageEditor

1. 假设你已经按照第四节中介绍的方式设置好了环境变量;
   解压缩CELayoutEditor-0.7.1.tar.gz
2. 添加环境变量CE_IMAGESET_EDITOR,内容为CEImagesetEditor解压缩后的路径
3. 用文本编辑器打开CEImagesetEditor下vc++9中的CEImagesetEditor.vcproj文件,将 $(CEGUI) 全部替换为 $(CEGUI_7) ,将 $(WXWIDGETS) 全部替换为 $(WXWIDGETS_7)
4. 用VS2008打开vc++9下的.sln文件,修改CEImagesetEditor项目的生成后事件
Debug下
copy $(CEGUI_7)inCEGUISILLYImageCodec_d.dll $(CE_IMAGESET_EDITOR)indebug /Y
copy $(CEGUI_7)inCEGUITGAImageCodec_d.dll $(CE_IMAGESET_EDITOR)indebug /Y
修改为
copy $(CEGUI_7)inCEGUIFreeImageImageCodec_d.dll $(CE_IMAGESET_EDITOR)indebug /Y
copy $(CEGUI_7)dependenciesinFreeImaged.dll $(CE_IMAGESET_EDITOR)indebug /Y

Release下
copy $(CEGUI_7)inCEGUISILLYImageCodec.dll $(CE_IMAGESET_EDITOR)in elease /Y
copy $(CEGUI_7)inCEGUITGAImageCodec.dll $(CE_IMAGESET_EDITOR)in elease /Y
修改为
copy $(CEGUI_7)inCEGUIFreeImageImageCodec.dll $(CE_IMAGESET_EDITOR)in elease /Y
copy $(CEGUI_7)dependenciesinFreeImage.dll $(CE_IMAGESET_EDITOR)indebug /Y   --------------------(error_3) 
5. 生成即可

六、其它

如果要生成多字节版本的CELayoutEditor:

首先要修改project属性的字符集设置(这个估计大家都知道);

然后需要将StringHelper.h中的

    static wxString ToWXString(const wxString& str)
    {
        return str;
    }

    static CEGUI::String ToCEGUIString(const CEGUI::String& str)
    {
        return str;
    }

这两个函数注释掉,否则将会导致函数调用不明确的错误。

好了,就说这些吧。

 

参照上面的步骤时需要注意的事项:

1. 在第三节步骤4.1中,由于dxsdk(june 2010版)的lib分x86和x64两个版本,需要把lib的子路径补充完整,如 %DX_SDK_DIR%/lib/x86

2.第四节步骤中我用玫瑰红标注的错误可能为原作者手误,应当如下:
(error_1):copy $(CEGUI_7)dependenciesinFreeImaged.dll $(CE_IMAGESET_EDITOR)indebug /Y  

改为:copy $(CEGUI_7)dependenciesinFreeImaged.dll $(CE_LAYOUT_EDITOR_7)indebug /Y

(error_2): copy $(CEGUI_7)dependenciesinFreeImage.dll $(CE_IMAGESET_EDITOR)indebug /Y  

改为:copy $(CEGUI_7)dependenciesinFreeImage.dll $(CE_LAYOUT_EDITOR_7)inrelease /Y 

(error_3):copy $(CEGUI_7)dependenciesinFreeImage.dll $(CE_IMAGESET_EDITOR)indebug /Y  Y  

改为:copy $(CEGUI_7)dependenciesinFreeImage.dll $(CE_IMAGESET_EDITOR)inrelease/Y  

  

按照原作者提供的编译步骤可以成功编译出 0.7.1版的CEGUI以及相应的工具软件。

原文地址:https://www.cnblogs.com/moniza/p/4329343.html