热门标签 | HotTags
当前位置:  开发笔记 > 编程语言 > 正文

CEGUIWindow环境编译

CEGUI编译平台:WindowCEGUI版本:0.8.7前提:VisualStudio任意版本(本文为2013ÿ

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
#include
#include #include
#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&#39;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&#39;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;
}

推荐阅读
  • 通过Anaconda安装tensorflow,并安装运行spyder编译器的完整教程
    本文提供了一个完整的教程,介绍了如何通过Anaconda安装tensorflow,并安装运行spyder编译器。文章详细介绍了安装Anaconda、创建tensorflow环境、安装GPU版本tensorflow、安装和运行Spyder编译器以及安装OpenCV等步骤。该教程适用于Windows 8操作系统,并提供了相关的网址供参考。通过本教程,读者可以轻松地安装和配置tensorflow环境,以及运行spyder编译器进行开发。 ... [详细]
  • 第一步:PyQt4Designer设计程序界面该部分设计类同VisvalStudio内的设计,改下各部件的objectName!设计 ... [详细]
  • 微软头条实习生分享深度学习自学指南
    本文介绍了一位微软头条实习生自学深度学习的经验分享,包括学习资源推荐、重要基础知识的学习要点等。作者强调了学好Python和数学基础的重要性,并提供了一些建议。 ... [详细]
  • Spring源码解密之默认标签的解析方式分析
    本文分析了Spring源码解密中默认标签的解析方式。通过对命名空间的判断,区分默认命名空间和自定义命名空间,并采用不同的解析方式。其中,bean标签的解析最为复杂和重要。 ... [详细]
  • 向QTextEdit拖放文件的方法及实现步骤
    本文介绍了在使用QTextEdit时如何实现拖放文件的功能,包括相关的方法和实现步骤。通过重写dragEnterEvent和dropEvent函数,并结合QMimeData和QUrl等类,可以轻松实现向QTextEdit拖放文件的功能。详细的代码实现和说明可以参考本文提供的示例代码。 ... [详细]
  • Android Studio Bumblebee | 2021.1.1(大黄蜂版本使用介绍)
    本文介绍了Android Studio Bumblebee | 2021.1.1(大黄蜂版本)的使用方法和相关知识,包括Gradle的介绍、设备管理器的配置、无线调试、新版本问题等内容。同时还提供了更新版本的下载地址和启动页面截图。 ... [详细]
  • CF:3D City Model(小思维)问题解析和代码实现
    本文通过解析CF:3D City Model问题,介绍了问题的背景和要求,并给出了相应的代码实现。该问题涉及到在一个矩形的网格上建造城市的情景,每个网格单元可以作为建筑的基础,建筑由多个立方体叠加而成。文章详细讲解了问题的解决思路,并给出了相应的代码实现供读者参考。 ... [详细]
  • 本文介绍了在Windows环境下如何配置php+apache环境,包括下载php7和apache2.4、安装vc2015运行时环境、启动php7和apache2.4等步骤。希望对需要搭建php7环境的读者有一定的参考价值。摘要长度为169字。 ... [详细]
  • C++字符字符串处理及字符集编码方案
    本文介绍了C++中字符字符串处理的问题,并详细解释了字符集编码方案,包括UNICODE、Windows apps采用的UTF-16编码、ASCII、SBCS和DBCS编码方案。同时说明了ANSI C标准和Windows中的字符/字符串数据类型实现。文章还提到了在编译时需要定义UNICODE宏以支持unicode编码,否则将使用windows code page编译。最后,给出了相关的头文件和数据类型定义。 ... [详细]
  • 本文介绍了在CentOS上安装Python2.7.2的详细步骤,包括下载、解压、编译和安装等操作。同时提供了一些注意事项,以及测试安装是否成功的方法。 ... [详细]
  • 本文介绍了在Mac上安装Xamarin并使用Windows上的VS开发iOS app的方法,包括所需的安装环境和软件,以及使用Xamarin.iOS进行开发的步骤。通过这种方法,即使没有Mac或者安装苹果系统,程序员们也能轻松开发iOS app。 ... [详细]
  • GreenDAO快速入门
    前言之前在自己做项目的时候,用到了GreenDAO数据库,其实对于数据库辅助工具库从OrmLite,到litePal再到GreenDAO,总是在不停的切换,但是没有真正去了解他们的 ... [详细]
  • 本文介绍了pack布局管理器在Perl/Tk中的使用方法及注意事项。通过调用pack()方法,可以控制部件在显示窗口中的位置和大小。同时,本文还提到了在使用pack布局管理器时,应注意将部件分组以便在水平和垂直方向上进行堆放。此外,还介绍了使用Frame部件或Toplevel部件来组织部件在窗口内的方法。最后,本文强调了在使用pack布局管理器时,应避免在中间切换到grid布局管理器,以免造成混乱。 ... [详细]
  • 如何优化Webpack打包后的代码分割
    本文介绍了如何通过优化Webpack的代码分割来减小打包后的文件大小。主要包括拆分业务逻辑代码和引入第三方包的代码、配置Webpack插件、异步代码的处理、代码分割重命名、配置vendors和cacheGroups等方面的内容。通过合理配置和优化,可以有效减小打包后的文件大小,提高应用的加载速度。 ... [详细]
  • [翻译]PyCairo指南裁剪和masking
    裁剪和masking在PyCairo指南的这个部分,我么将讨论裁剪和masking操作。裁剪裁剪就是将图形的绘制限定在一定的区域内。这样做有一些效率的因素࿰ ... [详细]
author-avatar
冠凯雅友9
这个家伙很懒,什么也没留下!
PHP1.CN | 中国最专业的PHP中文社区 | DevBox开发工具箱 | json解析格式化 |PHP资讯 | PHP教程 | 数据库技术 | 服务器技术 | 前端开发技术 | PHP框架 | 开发工具 | 在线工具
Copyright © 1998 - 2020 PHP1.CN. All Rights Reserved | 京公网安备 11010802041100号 | 京ICP备19059560号-4 | PHP1.CN 第一PHP社区 版权所有