MyGUI_Orge官网教程_2.快速在工程中使用MyGUI
-1.工程配置:
包含目录:
(PathToMyGUI)\MyGUIEngine\include
(PathToMyGUI)\Platforms\Ogre\OgrePlatform\include
库目录:
(PathToMyGUI)\lib\Release
(PathToMyGUI)\lib\Debug
附加连接依赖库
MyGUIEngine.lib MyGUI.OgrePlatform.lib or MyGUIEngine_d.lib MyGUI.OgrePlatform_d.lib
下面是MyGUI 3.0+快速开始指南.
拷贝MyGUI_Media目录,然后在ogre的resources.cfg中添加该目录。
编译MyGUI,并把MyGUIEngine_d.dll拷贝的你程序的工作目录,并添加MyGUIEngine_d.lib到工程设置的附加依赖库。
你也需要编译MyGUI.OgrePlatform作为MyGUI库到ogre渲染引擎的一个接口,并添加MyGUI.OgrePlatform_d.lib到附加依赖库。
If MyGUI was built as a static library, freetype####(_d).lib is also required (#### - your freetype version).
Code
includes:
你需要添加包含目录,并在源文件里添加下面包含:
#include "MyGUI.h" #include "MyGUI_OgrePlatform.h"
在你初始化GUI前,确定创建了 一个视口viewport。因为这将被送到OgrePlatform类来存储它,之后调用initialize的时候用。
declaration:
MyGUI::Gui* mGUI;
initialisation:
MyGUI::OgrePlatform* mPlatform = new MyGUI::OgrePlatform(); mPlatform->initialise(mWindow, mSceneManager); // mWindow is Ogre::RenderWindow*, mSceneManager is Ogre::SceneManager* mGUI = new MyGUI::Gui(); mGUI->initialise();
Note: 确定在ogre的ResourceManager中初始化它的资源组resource group(或调用initializeResourceGroups如果你不关心资源组)后再初始化MyGUI。否则MyGUI不会显示任何东西,尽管MyGUI.log会显示所有的xml文件都找到了且工作正常。
mouse and keyboard input:
class CLASS_NAME : public OIS::MouseListener , public OIS::KeyListenerbool CLASS_NAME::mouseMoved( const OIS::MouseEvent &arg ) {MyGUI::InputManager::getInstance().injectMouseMove(arg.state.X.abs, arg.state.Y.abs, arg.state.Z.abs);//... }bool CLASS_NAME::mousePressed( const OIS::MouseEvent &arg, OIS::MouseButtonID id ) {MyGUI::InputManager::getInstance().injectMousePress(arg.state.X.abs, arg.state.Y.abs, MyGUI::MouseButton::Enum(id));//... }bool CLASS_NAME::mouseReleased( const OIS::MouseEvent &arg, OIS::MouseButtonID id ) {MyGUI::InputManager::getInstance().injectMouseRelease(arg.state.X.abs, arg.state.Y.abs, MyGUI::MouseButton::Enum(id));//... }bool CLASS_NAME::keyPressed( const OIS::KeyEvent &arg ) {MyGUI::InputManager::getInstance().injectKeyPress(MyGUI::KeyCode::Enum(arg.key), arg.text);//... }bool CLASS_NAME::keyReleased( const OIS::KeyEvent &arg ) {MyGUI::InputManager::getInstance().injectKeyRelease(MyGUI::KeyCode::Enum(arg.key));//... }
Note: For those who have used previous versions of MyGUI: you don't need to call injectFrameEntered every frame in MyGUI 3.0+ (the renderer does this now.)
Note: 如果你不能在渲染区域移动你的鼠标,你可能需要添加下面的代码到你的程序初始化处(也要到你的“窗口改变大小事件resize”的回调函数去):
If you can't move your cursor all over the rendering area, you may need to add the following code to your app's initialization (and also to your "window resize event" callback):
const OIS::MouseState &mouseState = mMouse->getMouseState(); // mMouse is type of OIS::Mouse* mouseState.width = 1024; // your rendering area width mouseState.height = 768; // your rendering area height
create button and set callback:
MyGUI::ButtonPtr button = mGUI->createWidget<MyGUI::Button>("Button", 10, 10, 300, 26, MyGUI::Align::Default, "Main"); button->setCaption("exit"); // set callback button->eventMouseButtonClick += MyGUI::newDelegate(CLASS_POINTER, &CLASS_NAME::METHOD_NAME); // CLASS_POINTER is pointer to instance of a CLASS_NAME (usually '''this''') // or //button->eventMouseButtonClick += MyGUI::newDelegate(STATIC_METHOD_NAME); //button->eventMouseButtonClick += MyGUI::newDelegate(GLOBAL_FUNC_NAME);
Another way of creating button and setting callback:
In sample.layout:
<?xml version="1.0" encoding="UTF-8"?><MyGUI type="Layout"><Widget type="Button" skin="Button" position="10 10 300 26" align="Default" layer="Main" name="MyFirstButton" ><Property key="Widget_Caption" value="exit" /></Widget></MyGUI>
code:
// load layout MyGUI::LayoutManager::getInstance().loadLayout("sample.layout"); //MyGUI::LayerManager::getInstancePtr()->resizeView(MyGUI::RenderManager::getInstancePtr()->getViewSize()); //Uncomment this line if you want to align worked immediately after loading layout // set callback MyGUI::ButtonPtr button = mGUI->findWidget<MyGUI::Button>("MyFirstButton"); button->eventMouseButtonClick += MyGUI::newDelegate(CLASS_POINTER, &CLASS_NAME::METHOD_NAME); // CLASS_POINTER is pointer to CLASS_NAME ('''this''') // or //button->eventMouseButtonClick += MyGUI::newDelegate(STATIC_METHOD_NAME); //button->eventMouseButtonClick += MyGUI::newDelegate(GLOBAL_FUNC_NAME);
method signature for eventMouseButtonClick:
void CLASS_NAME::METHOD_NAME(MyGUI::WidgetPtr _sender) {//... }void CLASS_NAME::STATIC_METHOD_NAME(MyGUI::WidgetPtr _sender) {//... }void GLOBAL_FUNC_NAME(MyGUI::WidgetPtr _sender) {//... }
destruction:
mGUI->shutdown(); delete mGUI; mGUI = 0; mPlatform->shutdown(); delete mPlatform; mPlatform = 0;
后记:
用最新版有问题的,看看这个链接吧:http://blog.csdn.net/augusdi/article/details/8868917
配套测试代码:http://download.csdn.net/detail/adfansong/5960819
MyGUI_Orge官网教程_2.快速在工程中使用MyGUI相关推荐
- java官网教程(基础篇)—— 基础的Java类 —— 基础 I / O
目录 基本 Java 类 基础 I/O I/O流 字节流 字符流 缓冲流 扫描和格式化 扫描 格式化 从命令行中进行IO操作 数据流 对象流 文件 I/O(采用 NIO.2) 什么是路径? Path类 ...
- Spring Cloud学习笔记—网关Spring Cloud Gateway官网教程实操练习
Spring Cloud学习笔记-网关Spring Cloud Gateway官网教程实操练习 1.Spring Cloud Gateway介绍 2.在Spring Tool Suite4或者IDEA ...
- CMake学习笔记(一)——CMake官网教程
CMake学习笔记(一)--CMake官网教程 前言: 经历了一星期痛苦的交叉编译,笔者深刻认知到Linux下make的重要性.所以准备放缓两三天自己的工作进度,并学习一下CMake与Makefile ...
- [pytorch] 官网教程+注释
pytorch官网教程+注释 Classifier import torch import torchvision import torchvision.transforms as transform ...
- MNE溯源fieldtrip官网教程
MNE溯源fieldtrip官网教程 Introduction 在本教程中,您可以找到有关如何使用最小范数估计进行源重构的信息,以重构单个主题的事件相关字段(MEG).我们将使用预处理教程中描述的数据 ...
- Gem5模拟器,详解官网教程Event-driven programming(五)
目录 一.解释一下gem5中的event-driven? 二.Creating a simple event callback (1)定义一个新的 C++ 类,并继承自 SimObject 抽象基类 ...
- Angular官网教程示例知识点总结
Angular官网教程示例知识点总结 1.背景 2.知识点 2.1 应用的外壳 2.1.1 使用 Angular CLI 创建初始的应用结构 2.1.2 启动应用服务器 2.1.3 双花括号表达式 2 ...
- Docker 官网教程实践 自定义 bridge 网络
前言 这篇笔记是 docker 官网教程 自定义 bridge 网络的实践. 用户自定义 bridge 网络是在生产环境中推荐到最佳方式,因此这篇教程要特别注意. 这个教程中,启动了2个 alpine ...
- Away3D 4.0官网教程(翻译)
使用Away3D 4.Stage3D 创建3D游戏和应用程序 (此帖每天都会更新,一定让大家完全的搞明白) 补充区: 'vase.awd' 可以使用 Prefab3D打开(在帖子后面回复 ...
- 新学Python之学习官网教程序言
大家好,我是 herosunly.985 院校硕士毕业,现担任算法研究员一职,热衷于机器学习算法研究与应用.曾获得阿里云天池安全恶意程序检测第一名,科大讯飞恶意软件分类挑战赛第三名,CCF 恶意软 ...
最新文章
- java 反射代价_Java反射机制
- python解决四舍五入问题
- asp.net UrlRewrite 技术的实现
- LeetCode Sum Root to Leaf Numbers (dfs)
- Python中pass、continue、break、exit()的区别
- 上海90后用优惠券薅羊毛45万被捕;华为再招201万元年薪“天才少年”;微软收购网络安全公司 RiskIQ|极客头条...
- 自考计算机应用技术题,全国自考计算机应用技术试题及答案解析-20210522014558.docx-原创力文档...
- 项目添加程序集的引用后老是报错
- 职称计算机 将计算机broad_1下的e盘映射为k盘网络驱动器,计算机职称考试题目(网络基础答案)...
- win10计算机名和计算机物理地址,Win10系统查询电脑MAC地址方法【图文】
- Markdown缩进控制
- mysql的建表赋权_mysql创建用户并赋权
- matlab中stract用法_matlab初学之strcat、num2str
- sigma-delta_Delta调试-简化失败的测试用例
- 用微分和差分方程描述的因果LIT系统
- [精品毕设]基于Python实现的飞机票销售系统订票系统
- 基于知识图谱的推荐系统(KGRS)综述
- 有关宾大1900页数学书笔记的更新说明
- vue+elementUI使用Wavesurfer.js音频可视化
- 笔记本电脑键盘无法使用的参考解决方案
热门文章
- 十一则:程序员冷“笑话”据说只有真正的程序员才看得懂
- 技术类—Java笔试题2018
- Additions HNUST 1713(矩阵快速幂模板 )
- Linux命令提示符显示格式的配置
- 二十二.基于国民MCU 的COMP模块的比较案例
- 弗兰克·盖里为华纳兄弟设计新总部,犹如漂浮在高速公路的‘冰山’
- 【Apache NIFI 操作】Apache NiFi源码目录结构--nifi-nar-bundles
- 用c语言屏蔽鼠标键盘,用VBS屏蔽键盘和鼠标
- 2018年新浪微博产品笔试题目
- win7共享中心服务器运行失败,win7网络共享中心打不开怎么办