A new OpenGL-based GUI library

Source: Internet
Author: User

#include <BGE/All>

usingnamespaceBge

window* Createbutton (ConstSTD::string& Name,Conststring& text)
{
button* button =NewButton (0, text);
Button->setname (name);
Button->setsize (VECTOR2F ( the, the));
returnbutton
}

intMainintargcChar* 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 =NewPanel (Floatrect ( -, -,192, the),0);
gridlayout* layout =NewGridLayout ();
Panel->setlayout (layout);
std::vector<float> widths;
Widths.push_back (0.0f);
Layout->setcolumnwidths (widths);

std::vector<float> Heights;
for(intK =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"Key"), info);
Info.columnindex_ =1; Info.rowindex_ =0; Layout->addwindow (Createbutton ("Button2", L"Key"), info);
Info.columnindex_ =0; Info.rowindex_ =1; Layout->addwindow (Createbutton ("Button3", L"Key"), info);
Info.columnindex_ =1; Info.rowindex_ =1; Layout->addwindow (Createbutton ("Button4", L"Key"), info);
Info.columnindex_ =0;
Info.rowindex_ =2;
Info.horizontalspan_ =2;
window* edit =NewEditField (null,l"Edit Text");
Edit->setsize (VECTOR2F (196, $));
Layout->addwindow (Edit,info);
Info.columnindex_ =0;
Info.rowindex_ =3;
Info.horizontalspan_ =3;
Layout->arrangewithin ();

framewindow* window =NewFrameWindow ();
Window->enablemovement ();
Window->settext (L"BGE Form");
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 ();
return0;
}

Shown below:

in the development of reference to software such as QT, support common controls, control serialization, the whole skin, control skin Change

The above code to write quite verbose actually can write like this:

intMainintargcChar* 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"));

window* window = Windowmanager::instance (). CreateWindow ("Ui.xml");
if(window)
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 ();
return0;
}

It's not something else to do.

Now a little bit of a problem, modified I will be on the source

A drink of advice ~

A new OpenGL-based GUI library

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.