< 山东大学软件学院项目实训 > 渲染引擎系统(六)

目录

前言

主要工作

一、具体代码

二、结果展示


前言

本节的主要内容为点击下拉菜单选项后的功能实现。

主要工作

掌握信息显示的方法,并结合UI选项尝试实现了文本信息窗口。

一、具体代码

            auto help = m.dropdown("Help");
            if (help.item("Shortcuts")) shortcuts();
            help.separator();
            if (help.item("About")) about();

在上文的代码中实现了下拉菜单的UI布局,并编写了与之对应的功能函数shortcuts(快捷键提示)、about(相关信息提示)。

代码主要使用msgBox函数生成消息显示框,具体参数如下:

FALCOR_API MsgBoxButton msgBox(const std::string& msg, MsgBoxType type = MsgBoxType::Ok, MsgBoxIcon icon = MsgBoxIcon::None);

在shortcut是函数中,需要访问系统框架中自带的快捷键内容,例如退出界面、隐藏全部UI、捕捉当前相机位置等(这些信息为系统自定义,需要使用函数访问)。

    void shortcuts()
        {
            constexpr char help[] =
                "F1   - Show the help message\n"
                "F9   - Show/hide the time\n"
                "F6   - Show/hide the graph UI\n"
                "F10  - Show/hide the FPS\n"
                "F11  - Enable/disable main menu auto-hiding\n"
                "`    - Show the consle\n"
                "ps. If you want to use the consle,any input\n"
                "    will be unvaild as shortcuts except 'ESC'.\n"
                "\n";
            msgBox(help + gpFramework->getKeyboardShortcutsStr());
        }

        void about()
        {
            std::string s = Renderer::getVersionString() + "\n";
            s += "Powered by Falcor ";
            s += FALCOR_VERSION_STRING;
            s += "\nTeam Member:\n";
            s += "ChenXiang\n";
            s += "HuangYu\n";
            s += "ChenRan\n";
            s += "LiJiaze\n";
            msgBox(s);
        }

二、结果展示

在msgBox函数中传入字符串后,在点击shortcuts或about选项后,就能看到以下场景:

 

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值