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中的很多属性还是没有搞清楚。其中的是否选择全屏幕的问题。总之,好好在研究研究。
    
    
  • 相关阅读:
    容器技术之Dockerfile(一)
    容器技术之Docker常用命令说明
    容器技术之Docker数据卷
    Cypress与TestCafe WebUI端到端测试框架简介
    API测试之Postman使用全指南(原来使用 Postman测试API如此简单)
    【PyMuPDF和pdf2image】Python将PDF转成图片
    2020 | 可替代Selenium的测试框架Top15
    AWS EC2+Docker+JMeter构建分布式负载测试基础架构
    Appium移动端自动化测试--元素操作与触摸动作
    Appium移动端自动化测试--使用IDE编辑并强化脚本
  • 原文地址:https://www.cnblogs.com/chateldon/p/2411702.html
Copyright © 2011-2022 走看看