zoukankan      html  css  js  c++  java
  • osg显示CEGUI界面

    百度和google的好多例子都不能运行,贴一个自己试出来的。借鉴了cegui的自带例子。
    #include "stdafx.h"
    #include "CEGUIFirstWindow.h"
    #include "CEGUI.h"
    #include <CEGUIDefaultResourceProvider.h>


    int main(int /*argc*/, char* /*argv*/[])
    {
    // This is a basic start-up for the sample application which is
    // object orientated in nature, so we just need an instance of
    // the CEGuiSample based object and then tell that sample application
    // to run. All of the samples will use code similar to this in the
    // main/WinMain function.
    FirstWindowSample app;
    return app.run();
    }

    /*************************************************************************
    Sample specific initialisation goes here.
    ************************************************************************
    */
    bool FirstWindowSample::initialiseSample()
    {
    using namespace CEGUI;
    // Window* myRoot = WindowManager::getSingleton().loadWindowLayout( "test.layout" );
    // System::getSingleton().setGUISheet( myRoot );
    WindowManager& winMgr = WindowManager::getSingleton();

    // load scheme and set up defaults
    SchemeManager::getSingleton().create("TaharezLook.scheme");
    System::getSingleton().setDefaultMouseCursor("TaharezLook", "MouseArrow");
    FontManager::getSingleton().create("DejaVuSans-10.font");

    // load an image to use as a background
    ImagesetManager::getSingleton().createFromImageFile("BackgroundImage", "GPN-2000-001437.tga");

    // here we will use a StaticImage as the root, then we can use it to place a background image
    Window* background = winMgr.createWindow("TaharezLook/StaticImage", "background_wnd");
    /*********************************************************
    * 设置地球背景
    ********************************************************
    */
    // set position and size
    background->setPosition(UVector2(cegui_reldim(0), cegui_reldim( 0)));
    background->setSize(UVector2(cegui_reldim(1), cegui_reldim( 1)));
    // disable frame and standard background
    background->setProperty("FrameEnabled", "false");
    background->setProperty("BackgroundEnabled", "false");
    // set the background image
    background->setProperty("Image", "set:BackgroundImage image:full_image");
    /*********************************************************
    * 设置地球背景
    ********************************************************
    */
    // install this as the root GUI sheet
    System::getSingleton().setGUISheet(background);

    // load the windows for Demo7 from the layout file.
    Window* sheet = winMgr.loadWindowLayout("bar_list.layout");
    // attach this to the 'real' root
    background->addChildWindow(sheet);
    }
    上一张截图

    
    
    代码中bar_list.layout即为自己用CEGUIEditor编辑的。
    其中要注意的是layout中的每个空间的属性要代码中设置的window的属性一致,不然会出错。layout中的很多属性还是没有搞清楚。其中的是否选择全屏幕的问题。总之,好好在研究研究。
    
    
  • 相关阅读:
    C# .NET 支付宝IOT小程序AES密钥解密
    aws平台中为ec2实例添加双网卡
    Python使用lxml模块和Requests模块抓取HTML页面的教程
    CentOS下安装PHP Oracle数据库扩展
    如何在Ubuntu 16.04上安装配置Redis
    zabbix参考文档
    docker学习网站
    设置Linux打开文件句柄/proc/sys/fs/file-max和ulimit -n的区别
    MySql按字段分组取最大值记录 [此博文包含图片]
    dokcer使用--link 让容器相连
  • 原文地址:https://www.cnblogs.com/chateldon/p/2411702.html
Copyright © 2011-2022 走看看