CEGUI0.8.4例子

CEGUI0.8.4例子#defineGLUT_DISABLE_ATEXIT_HACK#pragmacomment(lib,”glew32.lib”)#include<stdlib.h>#include<gl/glew.h>#include<gl/glut.h>#include<CEGUI/CEGUI.h>#include<CEGUI/RendererM…

大家好,又见面了,我是你们的朋友全栈君。

#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;
}

 

转载于:https://www.cnblogs.com/wenguang1996/p/5086832.html

版权声明:本文内容由互联网用户自发贡献,该文观点仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请联系我们举报,一经查实,本站将立刻删除。

发布者:全栈程序员-站长,转载请注明出处:https://javaforall.net/163747.html原文链接:https://javaforall.net

(0)
全栈程序员-站长的头像全栈程序员-站长


相关推荐

  • uri与url的区别简单理解(uri和url有什么区别)

    一、URI<1>什么是URIURI,通一资源标志符(UniformResourceIdentifier,URI),表示的是web上每一种可用的资源,如HTML文档、图像、视频片段、程序等都由一个URI进行定位的。<2>URI的结构组成URI通常由三部分组成:①访问资源的命名机制;②存放资源的主机名;③资源自身的名称。<3>…

    2022年4月14日
    61
  • python找出肇事者_python100例详解

    python找出肇事者_python100例详解抓交通肇事犯1.问题描述一辆卡车违反交通规则,撞人后逃跑。现场有三人目击该事件,但都没有记住车号,只记下了车号的一些特征。甲说:牌照的前两位数字是相同的:乙说:牌照的后两位数字是相同的,但与前两位

    2022年7月29日
    9
  • 电脑很大,电脑内存很大为什么还是很卡「建议收藏」

    电脑很大,电脑内存很大为什么还是很卡「建议收藏」2019-10-09阅读(121)”电脑反应慢原因:1.电脑反应太慢,第一我们打开任务管理器,检查CPU资源的使用,若某个程序的CPU资源占用一直比较高(比如占到50%以上),系统速度就会明显变慢。因一般情况下,除大型游戏程序之外,应用程序在运行过程中只是瞬间占用较高,而不会一直持续2019-10-09阅读(132)一.清理垃圾在Windows在安装和使用过程中都会产生相当多的垃圾文件,包括临时文…

    2022年5月5日
    332
  • 统计电影票房排名前10的电影并存入还有一个文件

    统计电影票房排名前10的电影并存入还有一个文件

    2022年1月24日
    75
  • SQLPLUS登陆命令「建议收藏」

    一.SQLPLUS登陆命令:使用sqlplus:10G之前的版本登陆时需要加引号(单、双引号皆可)如:sqlplus"/assysdba"sqlplus-prelim/assysdba&nbsp;&nbsp;&nbsp;&nbsp;从Oracle10g开始,sqlplus提供了一个参数选项-prelim,用这个参数,在系统已经hang的时候可以连接到SGA而不是数据库,也就…

    2022年4月10日
    69
  • 《王道计算机网络》学习笔记总目录+思维导图

    本篇文章是对《2021王道计算机网络》所有知识点的笔记总结归档,会一直更新下去之后我也会写操作系统、计算机网络、数据结构与算法、Java、Linux等底层和应用层的技术文章,并总结目录希望在自己可以复习的同时,也能将这些知识点总结归纳分享给大家欢迎大家关注我的个人博客网站:www.bithachi.cn,一起交流学习。文章总目录:第1章计算机网络体系结构1.1计算机网络概述1….

    2022年4月6日
    103

发表回复

您的邮箱地址不会被公开。 必填项已用 * 标注

关注全栈程序员社区公众号