Cpper
C/C++高级工程师 Android高级软件工程师 IT集成工程师 音频工程师 熟悉c,c++,java,c#,py,js,asp等多种语言 程序猿
先上一个使用例子
#include <BGE/All>

using namespace bge;

Window
* createButton(const std::string& name,const String& text)
{
    Button
* button = new Button(0,text);
    button
->setName(name);
    button
->setSize(Vector2f(92,42));
    
return button;
}

int main(int argc, char* argv[])
{
    FileSystem::instance().initial(argv[
0]);
    FileSystem::instance().setResourcePackage(
"data.zip");
    WindowManager::instance().initialize(
"simkai.ttf",false);

    Device
* device = Device::create();
    device
->initial();
    device
->createWindow(640,480,bge::String("BGE Window"));

    Panel
* panel = new Panel(FloatRect(30,30,192,180),0);
    GridLayout
* layout = new GridLayout();
    panel
->setLayout(layout);
    std::vector
<float> widths;
    widths.push_back(
0.0f);
    layout
->setColumnWidths(widths);

    std::vector
<float> heights;
    
for(int k = 0; k < 3++k)
        heights.push_back(
48.0f);
    heights.push_back(
0.0f);
    layout
->setRowHeights(heights);

    GridCellInfo info;
    info.columnIndex_ 
= 0; info.rowIndex_ = 0; layout->addWindow(createButton("button1",L"按键"),info);
    info.columnIndex_ 
= 1; info.rowIndex_ = 0; layout->addWindow(createButton("button2",L"按键"),info);
    info.columnIndex_ 
= 0; info.rowIndex_ = 1; layout->addWindow(createButton("button3",L"按键"),info);
    info.columnIndex_ 
= 1; info.rowIndex_ = 1; layout->addWindow(createButton("button4",L"按键"),info);
    info.columnIndex_ 
= 0;
    info.rowIndex_ 
= 2;
    info.horizontalSpan_ 
= 2;
    Window
* edit = new EditField(NULL,L"Edit Text");
    edit
->setSize(Vector2f(196,36));
    layout
->addWindow(edit,info);
    info.columnIndex_ 
= 0;
    info.rowIndex_ 
= 3;
    info.horizontalSpan_ 
= 3;
    layout
->arrangeWithin();

    FrameWindow
* window = new FrameWindow();
    window
->enableMovement();
    window
->setText(L"BGE窗体");
    window
->setClientPanel(panel);

    WindowManager::instance().addWindow(window);

    
while(device->isRunning())
    {
        device
->preRender();
        WindowManager::instance().update();
        device
->swapBuffers();
        device
->pollEvents();
    }

    WindowManager::instance().terminate();
    device
->closeWindow();
    device
->terminate();
    device
->deleteLater();
    
return 0;
}

在开发上参考了Qt等软件,当前支持常见控件 支持控件序列化 整体换肤 控件换肤
上面的代码显示的截图如下:
http://images2015.cnblogs.com/blog/676118/201601/676118-20160120092402484-466039328.png
不过当前还有一点小问题 修改完了再上代码
做这个不为什么 就是几年前一直想做个
posted on 2016-01-20 09:34 ccsdu2009 阅读(1944) 评论(3)  编辑 收藏 引用 所属分类: Game引擎
Comments
  • # re: 新做的一个基于OPENGL的gui库 起名BGE
    天下
    Posted @ 2016-01-20 18:19
    good ,最近也在写DirectUI,后期考虑用SDL 做跨平台的UI。
      回复  更多评论   
  • # re: 新做的一个基于OPENGL的gui库 起名BGE
    ccsdu2009
    Posted @ 2016-01-21 09:23
    @天下
    那还不如我们一起做
    GUI还是很费精力的  回复  更多评论   
  • # re: 新做的一个基于OPENGL的gui库 起名BGE
    天下
    Posted @ 2016-01-30 16:56
    @ccsdu2009
    加油,GUI确实费力,期望还要加入脚本语言支持,如LUA。

      回复  更多评论   

只有注册用户登录后才能发表评论。
网站导航: 博客园   IT新闻   BlogJava   知识库   博问   管理