CEGUI编译

  • 平台:Window
  • CEGUI版本:0.8.7
  • 前提:Visual Studio任意版本(本文为2013)

CEGUI源码下载

登录CEGUI官网网站:
http://cegui.org.uk/download
下载CEGUI0.8.7源码+ 0.8.X Dependencies

  • 下载完成后,解压(例:这里我解压到了D:/Myproject/Coding/CEGUI)
  • cegui-0.8.7是cegui的源码。cegui-dependencies-0.8.x 是cegui 0.8.x版本所需要的编译运行依赖环境。

编译cegui-dependicies-0.8.x

  • 使用CMake编译起来非常方便,由于之后要编译为Visual Studio 2013可用项目。所以需要前安装 vs 2013。当然安装其他任意版本的vs也可以。
  • 打开CMake,讲source和build目录设置为,cegui-dependicies-0.8.x目录。然后点击 “Configure”,在弹出的对话框选择“visual studio 2013对应的版本”,再次点击 configure。
  • 点击“Generate”
  • 点击open project,使用vs 2013打开项目 ,然后“生成解决方案”(release版)。然后将cegui-dependencies-0.8.x目录下的“dependecies”拷贝到“D:\Myproject\Coding\CEGUI\cegui-0.8.7”目录下面。

编译CEGUI

  • 该步骤,与编译cegui-dependicies-0.8.x一致。使用CMake将,Source和Build设置为“D:\Myproject\Coding\CEGUI\cegui-0.8.7”。然后使用 VS2013打开,生成解决项目。
  • 将dependecies目录设置为Path环境变量(例:"D:\Myproject\Coding\CEGUI\cegui-0.8.7\dependencies\bin"目录)。
  • 重启或注销电脑。

使用CEGUI自带SampleFramework

  • CEGUI写了一套Sample框架,用一套框架运行多个SampleDemo。
  • 将“CEGUISampleFramework-0.8”设置为启动项目,编译然后运行,如下图。
  • 由于CEGUI提供了,SampleFrameWork,要花一定时间分析单个Demo是如何启动的。下面分析完成后,参考sampleFrameWork写的一段,可以运行的Demo.
#include "CEGUI/RendererModules/OpenGL/GL.h"
#include "CEGUI/CEGUI.h"
#include "CEGUI/RenderTarget.h"
#include <GL/glfw.h>
#include <stdexcept>
#include <sstream>#include <iostream>
#include "CEGUI/RendererModules/OpenGL/GLRenderer.h"/*************************************************************************Sample specific initialisation goes here.
*************************************************************************/
bool HelloWorldDemo::initialise(CEGUI::GUIContext* guiContext)
{using namespace CEGUI;d_usedFiles = CEGUI::String(__FILE__);// CEGUI relies on various systems being set-up, so this is what we do// here first.//// The first thing to do is load a CEGUI 'scheme' this is basically a file// that groups all the required resources and definitions for a particular// skin so they can be loaded / initialised easily//// So, we use the SchemeManager singleton to load in a scheme that loads the// imagery and registers widgets for the TaharezLook skin.  This scheme also// loads in a font that gets used as the system default.SchemeManager::getSingleton().createFromFile("TaharezLook.scheme");// The next thing we do is to set a default mouse cursor image.  This is// not strictly essential, although it is nice to always have a visible// cursor if a window or widget does not explicitly set one of its own.//// The TaharezLook Imageset contains an Image named "MouseArrow" which is// the ideal thing to have as a defult mouse cursor image.guiContext->getMouseCursor().setDefaultImage("TaharezLook/MouseArrow");// Now the system is initialised, we can actually create some UI elements, for// this first example, a full-screen 'root' window is set as the active GUI// sheet, and then a simple frame window will be created and attached to it.// All windows and widgets are created via the WindowManager singleton.WindowManager& winMgr = WindowManager::getSingleton();// Here we create a "DefaultWindow".  This is a native type, that is, it does// not have to be loaded via a scheme, it is always available.  One common use// for the DefaultWindow is as a generic container for other windows.  Its// size defaults to 1.0f x 1.0f using the Relative metrics mode, which means// when it is set as the root GUI sheet window, it will cover the entire display.// The DefaultWindow does not perform any rendering of its own, so is invisible.//// Create a DefaultWindow called 'Root'.d_root = (DefaultWindow*)winMgr.createWindow("DefaultWindow", "Root");// load font and setup default if not loaded via schemeFont& defaultFont = FontManager::getSingleton().createFromFile("DejaVuSans-12.font");// Set default font for the gui contextguiContext->setDefaultFont(&defaultFont);// Set the root window as root of our GUI ContextguiContext->setRootWindow(d_root);// A FrameWindow is a window with a frame and a titlebar which may be moved around// and resized.//// Create a FrameWindow in the TaharezLook style, and name it 'Demo Window'FrameWindow* wnd = (FrameWindow*)winMgr.createWindow("TaharezLook/FrameWindow", "Demo Window");// Here we attach the newly created FrameWindow to the previously created// DefaultWindow which we will be using as the root of the displayed gui.d_root->addChild(wnd);// Windows are in Relative metrics mode by default.  This means that we can// specify sizes and positions without having to know the exact pixel size// of the elements in advance.  The relative metrics mode co-ordinates are// relative to the parent of the window where the co-ordinates are being set.// This means that if 0.5f is specified as the width for a window, that window// will be half as its parent window.//// Here we set the FrameWindow so that it is half the size of the display,// and centered within the display.wnd->setPosition(UVector2(cegui_reldim(0.0f), cegui_reldim( 0.0f)));wnd->setSize(USize(cegui_reldim(1.0f), cegui_reldim(1.0f)));// now we set the maximum and minum sizes for the new window.  These are// specified using relative co-ordinates, but the important thing to note// is that these settings are aways relative to the display rather than the// parent window.//// here we set a maximum size for the FrameWindow which is equal to the size// of the display, and a minimum size of one tenth of the display.wnd->setMaxSize(USize(cegui_reldim(1.0f), cegui_reldim( 1.0f)));wnd->setMinSize(USize(cegui_reldim(0.1f), cegui_reldim( 0.1f)));// As a final step in the initialisation of our sample window, we set the window's// text to "Hello World!", so that this text will appear as the caption in the// FrameWindow's titlebar.wnd->setText("Hello World Linduo!");wnd->subscribeEvent(CEGUI::Window::EventMouseClick,  Event::Subscriber(&HelloWorldDemo::handleHelloWorldClicked, this));// return true so that the samples framework knows that initialisation was a// success, and that it should now run the sample.return true;
}/*************************************************************************Cleans up resources allocated in the initialiseSample call.
*************************************************************************/
void HelloWorldDemo::deinitialise()
{}bool HelloWorldDemo::handleHelloWorldClicked(const CEGUI::EventArgs&)
{std::cout << "Hello World!" << std::endl;std::cout << "Test For me" << std::endl;return false;
}/*************************************************************************Define the module function that returns an instance of the sample
*************************************************************************/
extern "C" SAMPLE_EXPORT Sample& getSampleInstance()
{static HelloWorldDemo sample;return sample;
}
const char d_windowTitle[] = "Crazy Eddie's GUI Mk-2 - Sample Application";void initCEGUI()
{using namespace CEGUI;// create renderer and enable extra statesOpenGLRenderer& cegui_renderer = OpenGLRenderer::create(Sizef(800.f, 600.f));cegui_renderer.enableExtraStateSettings(true);// create CEGUI system objectCEGUI::System::create(cegui_renderer);// setup resource directoriesDefaultResourceProvider* rp = static_cast<DefaultResourceProvider*>(System::getSingleton().getResourceProvider());rp->setResourceGroupDirectory("schemes", "../../datafiles/schemes/");rp->setResourceGroupDirectory("imagesets", "../../datafiles/imagesets/");rp->setResourceGroupDirectory("fonts", "../../datafiles/fonts/");rp->setResourceGroupDirectory("layouts", "../../datafiles/layouts/");rp->setResourceGroupDirectory("looknfeels", "../../datafiles/looknfeel/");rp->setResourceGroupDirectory("lua_scripts", "../../datafiles/lua_scripts/");rp->setResourceGroupDirectory("schemas", "../../datafiles/xml_schemas/");// set default resource groupsImageManager::setImagesetDefaultResourceGroup("imagesets");Font::setDefaultResourceGroup("fonts");Scheme::setDefaultResourceGroup("schemes");WidgetLookManager::setDefaultResourceGroup("looknfeels");WindowManager::setDefaultResourceGroup("layouts");ScriptModule::setDefaultResourceGroup("lua_scripts");XMLParser* parser = System::getSingleton().getXMLParser();if (parser->isPropertyPresent("SchemaDefaultResourceGroup"))parser->setProperty("SchemaDefaultResourceGroup", "schemas");// load TaharezLook scheme and DejaVuSans-10 fontSchemeManager::getSingleton().createFromFile("TaharezLook.scheme", "schemes");FontManager::getSingleton().createFromFile("DejaVuSans-10.font");// set default font and cursor image and tooltip typeSystem::getSingleton().getDefaultGUIContext().setDefaultFont("DejaVuSans-10");System::getSingleton().getDefaultGUIContext().getMouseCursor().setDefaultImage("TaharezLook/MouseArrow");System::getSingleton().getDefaultGUIContext().setDefaultTooltipType("TaharezLook/Tooltip");
}void initWindows()
{using namespace CEGUI;/// Add your gui initialisation code in here.// You should preferably use layout loading because you won't// have to recompile everytime you change the layout. But you// can also use static window creation code here, of course./// load layoutWindow* root = WindowManager::getSingleton().loadLayoutFromFile("application_templates.layout");System::getSingleton().getDefaultGUIContext().setRootWindow(root);
}static void GLFWCALL glfwWindowResizeCallback(int width, int height)
{CEGUI::System::getSingleton().notifyDisplaySizeChanged(CEGUI::Sizef(static_cast<float>(width), static_cast<float>(height)));glViewport(0, 0, width, height);
}int main()
{//Init fw initif (glfwInit() != GL_TRUE)CEGUI_THROW(RendererException("Failed to initialise GLFW."));glfwOpenWindowHint(GLFW_OPENGL_VERSION_MAJOR, 1);glfwOpenWindowHint(GLFW_OPENGL_VERSION_MINOR, 2);if (glfwOpenWindow(800, 600, 0, 0, 0, 0,24, 8, GLFW_WINDOW) != GL_TRUE){CEGUI_THROW(RendererException("Failed to open GLFW window."));glfwTerminate();}glfwEnable (GLFW_KEY_REPEAT);glfwSetWindowTitle(d_windowTitle);//Deactivate VSYNCglfwSwapInterval(0);// Disable the mouse position in Non_Debug mode
#ifndef DEBUGglfwDisable(GLFW_MOUSE_CURSOR);
#endif// Clear Errors by GLFW, even if Setup is correct.glGetError();initCEGUI();#if 0// Input callbacks of glfw for CEGUIglfwSetKeyCallback(glfwKeyCallback);glfwSetCharCallback(glfwCharCallback);glfwSetMouseButtonCallback(glfwMouseButtonCallback);glfwSetMouseWheelCallback(glfwMouseWheelCallback);glfwSetMousePosCallback(glfwMousePosCallback);//Window callbacksglfwSetWindowCloseCallback(glfwWindowCloseCallback);#endifglfwSetWindowSizeCallback(glfwWindowResizeCallback);CEGUI::System::getSingleton().notifyDisplaySizeChanged(CEGUI::Sizef(800.f, 600.f));glViewport(0, 0, 800, 600);glClearColor(0.0f, 0.0f, 0.0f, 0.0f);// initWindows();HelloWorldDemo demo;CEGUI::GUIContext* conext = &CEGUI::System::getSingleton().getDefaultGUIContext();demo.initialise(conext);float time = glfwGetTime();CEGUI::OpenGLRenderer* renderer = static_cast<CEGUI::OpenGLRenderer*>(CEGUI::System::getSingleton().getRenderer());while (true && glfwGetWindowParam(GLFW_OPENED)){glClear(GL_COLOR_BUFFER_BIT);// inject time pulsesconst float newtime = glfwGetTime();const float time_elapsed = newtime - time;CEGUI::System::getSingleton().injectTimePulse(time_elapsed);CEGUI::System::getSingleton().getDefaultGUIContext().injectTimePulse(time_elapsed);time = newtime;// render guirenderer->beginRendering();CEGUI::System::getSingleton().renderAllGUIContexts();renderer->endRendering();glfwSwapBuffers();}return 0;
}

【CEGUI】 Window环境编译相关推荐

  1. window环境编译在linux环境运行的golang程序

    1.打开windows命令行界面进入项目根目录,执行如下命令: SET CGO_ENABLED=0 SET GOOS=linux SET GOARCH=amd64 2.编译golang程序,得到与目录 ...

  2. window环境搭建go语言运行环境

    研究区块链,一直在纠结是研究比原链还是研究比特币链, 现在准备研究比原链,因为 ①比原链也是基于比特币开发的, ②我也在比原社区群里,有问题的话可以向比原技术老师请教 ③我是从事交易所工作的,最近对接 ...

  3. go安装-window环境

    go安装-window环境 #---------------------------------------------- 一.安装地址: https://golang.org/dl/ 如果不能访问换 ...

  4. Window环境下配置MySQL 5.6的主从复制、备份恢复

    Window环境下配置MySQL 5.6的主从复制.备份恢复 1.环境准备 Windows 7 64位 MySQL 5.6 主库:192.168.103.207 从库:192.168.103.208 ...

  5. QtCreator集成开发环境编译调试VLC

    QtCreator集成开发环境编译调试VLC 作者:lovey599 本文讨论如何用QtCreator编译并调试VLC源代码.你可以点击此处下载vlc-1.1.12.tar.gz源代码,也可以自行去官 ...

  6. 成功解决:将后缀.pyx格式文件(linux环境)编译成pyd文件(windows环境下)实现python编程加载或导入

    成功解决:将后缀.pyx格式文件(linux环境)编译成pyd文件(windows环境下)实现python编程加载或导入 目录 解决问题 解决思路 解决方法 解决问题 .pyx格式文件,在window ...

  7. 记一次失败的Windows环境编译Nginx源码

    最近想学习下nginx的源码,之前在linux环境编译安装过多次,在windows环境还是第一次尝试,遇到了不少问题,记录一下.可惜的是编译成功后,在最后运行的时候还是会报错,如果有人遇到类似的问题希 ...

  8. shell文件管理jenkins构建过程---window环境下报错:找不到shell文件

    window环境下报错:找不到shell文件.查看jenkins本地文件,可以查看到shell文件: 检查job配置: 发现使用的是Execute shell; 这个项目只能在liunx下使用,在wi ...

  9. 【数据库】Window环境安装MySQL Server 5.7.21

    正常我们在mysql官网下载安装的MySQL比较大,因为它集成了好多东西,尽管方便,但是东西比较多,有些我们可能不想要,这时我们可以直接下载单个MySQL Server安装,所以这篇文章主要介绍的就是 ...

最新文章

  1. 传阿里腾讯即将大裁员,最高涉及30%员工
  2. Java类之File记录
  3. 深度学习之基于Tensorflow2.0实现AlexNet网络
  4. Taro+react开发(21)--注意参数格式
  5. Js中Date的应用
  6. Type safety: The method add(Object) belongs to the raw type List. References to generic type List<E>
  7. 实现一个基于主存的虚拟块设备驱动程序_存储器的层次结构:寄存器、高速缓存、主存、本地磁盘...
  8. python lncrna_分析指令备份.sh
  9. python: 使用正则表达式的时候,传递参数的方法:
  10. 我的博客也是男的(还好)
  11. tomcat7下载安装
  12. 浅谈设备驱动的作用与本质,有无操作系统Linux设备驱动的区别
  13. 饥荒联机版你的服务器无响应,饥荒联机版为什么每次创建世界都会无响应 | 手游网游页游攻略大全...
  14. Photo Album: 2008年5月-三亚爱琴海岸康年度假村-day1
  15. 联想a366t 刷android4,联想A366t线刷刷机教程(刷官方rom)
  16. java 公历 农历_Java给定公历日期计算相应农历/阴历日期
  17. 微信小程序 图片左右滑动 swiper
  18. 【前端学习笔记 CSS系列二十二】justify
  19. 机器学习:线性模型通过python创建机器模型最终预测出儿童身高
  20. 从long到varchar2到clob。和sql该怎么保存clob

热门文章

  1. 公共关系礼仪实务章节测试题——社会关系和公共关系(一)
  2. 【Redis学习笔记(十)】之 Redis服务器详解
  3. Android so文件引用问题
  4. 矩阵论 内积空间几何表示图解
  5. 浪潮服务器NF5280M5配置RAID1【详细步骤】
  6. 【3D建模学习参考】写实女角色 游戏美术
  7. 简洁的一键SSH脚本
  8. 反射型XSS靶场练习
  9. 基于vue和ElementUI时间选择控件的封装
  10. 常识-天文历法-为什么1900年不是闰年