#define GLUT_DISABLE_ATEXIT_HACK
#pragma comment(lib,"glew32.lib")
#include<stdlib.h>
#include<gl/glew.h>
#include<gl/glut.h>
#include<CEGUI/CEGUI.h>
#include<CEGUI/RendererModules/OpenGL/GL3Renderer.h>
#include <CEGUI/RendererModules/OpenGL/GLRenderer.h>
#include<GL/glfw.h>
#include<CEGuiOpenGL3BaseApplication.h>
#include <CEGuiOpenGLBaseApplication.h>
#include<CEGUI/WindowManager.h>
void render(void);
void keyFunc(unsigned char , int , int );
int resource_group(void);
int load_data_files(void);
int create_window(void);
void Reshape(int w, int h);
int window_id;
bool keep_running = true;

int main(int argc, char *argv[])
{
glutInit(&argc, argv);

glutInitDisplayMode(GLUT_DEPTH | GLUT_DOUBLE | GLUT_RGBA);
glutInitWindowSize(640, 480);
glutCreateWindow(argv[0]);
// glutSetCursor(GLUT_CURSOR_NONE); //隐藏原有光标

glutReshapeFunc(Reshape);
GLenum err = glewInit();
CEGUI::OpenGL3Renderer& myRenderer = CEGUI::OpenGL3Renderer::create();
CEGUI::System::create(myRenderer);

resource_group();
load_data_files();
glutDisplayFunc(render);
glutMainLoop();
return 0;
}

void Reshape(int w, int h)
{
glViewport(0, 0, (GLsizei)w, (GLsizei)h);
glMatrixMode(GL_PROJECTION);
glLoadIdentity();
gluPerspective(40.0, (GLfloat)w / (GLfloat)h, 1.0, 20.0);
glMatrixMode(GL_MODELVIEW);
glLoadIdentity();
}
void render(void)
{
glLoadIdentity();
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
create_window();
CEGUI::System::getSingleton().renderAllGUIContexts();
glutSwapBuffers();
}

void keyFunc(unsigned char key, int x, int y)
{
switch (key)
{
case 113:
case 81:
case 27:
keep_running = false;
break;
}
}

int resource_group(void) //设置默认资源组
{
CEGUI::DefaultResourceProvider *rp = static_cast<CEGUI::DefaultResourceProvider*>
(CEGUI::System::getSingleton().getResourceProvider());

rp->setResourceGroupDirectory("schemes", "E:\\VTK\\CEGUI\\example\\datafiles\\schemes/");
rp->setResourceGroupDirectory("imagesets", "E:\\VTK\\CEGUI\\example\\datafiles\\imagesets/");
rp->setResourceGroupDirectory("fonts","E:\\VTK\\CEGUI\\example\\datafiles\\fonts/");
rp->setResourceGroupDirectory("layouts","E:\\VTK\\CEGUI\\example\\datafiles\\layouts/");
rp->setResourceGroupDirectory("looknfeels","E:\\VTK\\CEGUI\\example\\datafiles\\looknfeel/");

//rp->setResourceGroupDirectory("schemas","E:\\VTK\\CEGUI\\example\\datafiles\\XMLRefSchema/");

CEGUI::ImageManager::setImagesetDefaultResourceGroup("imagesets");
rp->setDefaultResourceGroup("E:\\VTK\\CEGUI\\example\\datafiles/");
CEGUI::Font::setDefaultResourceGroup("fonts");
CEGUI::Scheme::setDefaultResourceGroup("schemes");
CEGUI::WidgetLookManager::setDefaultResourceGroup("looknfeels");
CEGUI::WindowManager::setDefaultResourceGroup("layouts");
// CEGUI::XercesParser::setSchemaDefaultResourceGroup("schemas");
CEGUI::XMLParser* parser = CEGUI::System::getSingleton().getXMLParser();
if (parser->isPropertyPresent("SchemaDefaultResourceGroup"))
parser->setProperty("SchemaDefaultResourceGroup", "schemas");
return 1;

}

int load_data_files(void) //载入资源文件
{
CEGUI::SchemeManager::getSingleton().createFromFile( "TaharezLook.scheme" );

CEGUI::FontManager::getSingleton().createFromFile( "DejaVuSans-10.font" );

CEGUI::System::getSingleton().getDefaultGUIContext().setDefaultFont( "DejaVuSans-10" );

CEGUI::System::getSingleton().getDefaultGUIContext().getMouseCursor().setDefaultImage( "TaharezLook/MouseArrow" );

CEGUI::System::getSingleton().getDefaultGUIContext().setDefaultTooltipType( "WindowsLook/Tooltip" );

return 1;
}

int create_window(void) //创建一个窗口
{
using namespace CEGUI;

WindowManager &wmgr = WindowManager::getSingleton();

Window* myRoot = wmgr.createWindow("DefaultWindow", "root");
System::getSingleton().getDefaultGUIContext().setRootWindow( myRoot );

FrameWindow *fWnd = (FrameWindow*)wmgr.createWindow("TaharezLook/FrameWindow", "testWindow");
myRoot->addChild(fWnd);

// position a quarter of the way in from the top-left of parent.
fWnd->setPosition( UVector2( UDim( 0.25f, 0.0f ), UDim( 0.25f, 0.0f ) ) );
// set size to be half the size of the parent
fWnd->setSize( USize( UDim( 0.5f, 0.0f ), UDim( 0.5f, 0.0f ) ) );

fWnd->setText("Hello World!!");
/*Window* myRoot = WindowManager::getSingleton().loadLayoutFromFile( "1.layout" );
System::getSingleton().getDefaultGUIContext().setRootWindow( myRoot );*/
return 1;
}

CEGUI0.8.4例子的更多相关文章

  1. CEGUI0.8.4引入到自己工程中

    首先要确定你的CEGUI已经完全编译好,若未进行这一步请参照http://www.cnblogs.com/wenguang1996/p/5027522.html 打开VS2012新建C++工程,然后添 ...

  2. SQLServer地址搜索性能优化例子

    这是一个很久以前的例子,现在在整理资料时无意发现,就拿出来再改写分享. 1.需求 1.1 基本需求: 根据输入的地址关键字,搜索出完整的地址路径,耗时要控制在几十毫秒内. 1.2 数据库地址表结构和数 ...

  3. C#+HtmlAgilityPack+XPath带你采集数据(以采集天气数据为例子)

    第一次接触HtmlAgilityPack是在5年前,一些意外,让我从技术部门临时调到销售部门,负责建立一些流程和寻找潜在客户,最后在阿里巴巴找到了很多客户信息,非常全面,刚开始是手动复制到Excel, ...

  4. REGEX例子

    作为REGEX的例子,代码9.3显示了一个给定的文件有多少行,具有给定的模式,通过命令行输入(注:有更有效率的方式来实现这个功能,如Unix下的grep命令,在这里只是给出了另一种方式).这个程序像下 ...

  5. CSharpGL(25)一个用raycast实现体渲染VolumeRender的例子

    CSharpGL(25)一个用raycast实现体渲染VolumeRender的例子 本文涉及的VolumeRendering相关的C#代码是从(https://github.com/toolchai ...

  6. 简单例子了解View的事件分发

    什么是事件分发 我们在写自定义ViewGroup或者自定义View的时候经常要处理用户的点击事件,如果我们的View在最底层,他在很多ViewGroup里面,我们如何让我们的点击事件准确传递到View ...

  7. 简单的例子了解自定义ViewGroup(一)

    在Android中,控件可以分为ViewGroup控件与View控件.自定义View控件,我之前的文章已经说过.这次我们主要说一下自定义ViewGroup控件.ViewGroup是作为父控件可以包含多 ...

  8. kqueue例子

    网络服务器通常都使用epoll进行异步IO处理,而开发者通常使用mac,为了方便开发,我把自己的handy库移植到了mac平台上.移植过程中,网上居然没有搜到kqueue的使用例子,让我惊讶不已.为了 ...

  9. 今天有群友不是很清楚htm直接存数据库的危害,我简单举个例子

     通过这个案例就知道为什么不要把原生的html放数据库了  常见的几种转码  常用的几种显示方法 只有原生html和最下面一种弹框了,变成了持久xss 如果是Ajax的方式,请用@Ajax.JavaS ...

随机推荐

  1. <九>JDBC_获取插入记录的主键值

  2. HDU2438 数学+三分

    Turn the corner Time Limit: 3000/1000 MS (Java/Others)    Memory Limit: 32768/32768 K (Java/Others)T ...

  3. js--敏感词屏蔽

    <!doctype html><html><head><meta charset="utf-8"><meta name=&qu ...

  4. MongoDB学习记录

    一.操作符 "$lt" :"<""$lte" :"<=""$gt" :"> ...

  5. java并发编程-基础

    线程带来的风险 安全性:多线程操作执行顺序的不可预测性 -- 永远不发生糟糕的事情: 活跃性:代码无法得到执行,死锁.饥饿问题 -- 某件正确的事情最终会发生: 性能问题:活跃性只意味着某件事最终会发 ...

  6. iOS开发之XCode模拟器不能连接网络

    新装的Xcode7 编译程序 出现 #warning: 获取app配置信息失败: The resource could not be loaded because the App Transport ...

  7. goaccess的安装和使用

    一.简介1.goaccess用于分析apache和nginx日志的强大工具 2.官网:https://goaccess.io 二.安装1.下载goaccess的安装包wget http://tar.g ...

  8. EJB之Timer

    EJB Timer 要么: Annotation @Schedule 或者方法前声明@Timeout 要么: 在部署描述中定义timeout-method 如果是使用@Schedule, Timer在 ...

  9. windows核心编程 - 线程同步机制

    线程同步机制 常用的线程同步机制有很多种,主要分为用户模式和内核对象两类:其中 用户模式包括:原子操作.关键代码段 内核对象包括:时间内核对象(Event).等待定时器内核对象(WaitableTim ...

  10. CSS特异性(CSS Specificity)的细节之CSS样式权重的计算与理解(CSS样式覆盖规则)

    本篇讲解CSS特异性(CSS Specificity)的细节,也就是CSS样式选择器的权重计算 通过计算选择器的权重(weight)最终决定哪个选择器将获得优先权去覆盖其他选择器的样式设定,即“优先原 ...