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)
全栈程序员-站长的头像全栈程序员-站长


相关推荐

  • app漏洞检测方法有哪些_安卓app漏洞挖掘

    app漏洞检测方法有哪些_安卓app漏洞挖掘根据国内专业PP漏洞检测平台爱内测(www.detect.cn)介绍,目前关于APP漏洞检测有以下6种功能检测方法: 组件安全检测对四大组件和WebView的规范使用检测分析,发现因为程序中不规范使用导致的组件漏洞。 代码安全检测对dex和so库以及第三方加载库的代码的安全处理进行检测分析,发现代码被反编译和激活成功教程的漏洞。 内存安全检测检测APP运行过程中的内存处理和保护机制进行检测分析…

    2025年7月10日
    5
  • kafka批量删除topic_kafka清空数据

    kafka批量删除topic_kafka清空数据一般情况下,是不会删除数据的。到达一定时间后,kafka会自动删除。如果一定要删除可以删除topic在重建topic了No.1:如果需要被删除topic此时正在被程序produce和consume,则这些生产和消费程序需要停止。因为如果有程序正在生产或者消费该topic,则该topic的offset信息一致会在broker更新。调用kafkadelete命令则无法删除该topi…

    2022年10月17日
    2
  • 第五十二篇:Cascade Classifier Training详解

    第五十二篇:Cascade Classifier Training详解这是转自官方的 http opencv itseez com master dc d88 tutorial traincascade html 收了 以后方便看 Introduction trainingandd Detectionsta

    2025年12月10日
    3
  • JAVA数组的定义及用法

    JAVA数组的定义及用法

    2021年12月5日
    51
  • ssh后端框架结构

    ssh后端框架结构ssh框架SSH是struts+spring+hibernate的一个集成框架,是16年之前较为流行的一种Web应用程序开源框架。——摘自百度集成SSH框架的系统从职责上分为四层:表示层、业务逻辑层、数据持久层和域模块层,以帮助开发人员在短期内搭建结构清晰、可复用性好、维护方便的Web应用程序。其中使用Struts作为系统的整体基础架构,负责MVC的分离,在Struts框架的模型部分,控制业务跳转,利用Hibernate框架对持久层提供支持,Spring做管理,管理struts和hiberna

    2022年5月29日
    37
  • android之SeekBar和RatingBar

    今天在看一个音乐播放器的源代码时候用到了SeekBar,就翻出来mars老师的视频复习了一下,然后综合使用了一下.首先先看下运行效果:下来我们看看布局文件的设计:main.xml: 1 2

    2022年3月9日
    40

发表回复

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

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