Create ogre overlay code

Source: Internet
Author: User
Tags addchild

You can directly use the code to create an overlay. It is not displayed on the interface until the overlay is created. Later, you find that you have not set the size correctly... Fainted

There are three controls on overlay. Today, I tried to run the Panel and textarea Based on the online example. The boardpanel will be used later, so I can directly paste the code.

Note: the code in the article can be directly added to the ogre samplebrowser CPP file and changed to run. The brow in samplebrowser CPP can be used. go comments and replace them with some of my earliest code to become code.

Note that you can change the cfg file path to the correct path, and then insert the following code into the middle to run.

 

Ogre: overlaymanager & om = ogre: overlaymanager: getsingleton ();
Ogre: overlay * OL = om. Create ("test ");
Ogre: overlaycontainer * testpanel = (Ogre: overlaycontainer *) om. createoverlayelement ("Panel", "testpanel ");
Testpanel-> setposition (0, 0 );
Testpanel-> setdimensions (100,100 );
// Testpanel-> setmaterialname ("basewhite ");
 
// Create a text area
Ogre: textareaoverlayelement * textarea = static_cast <ogre: textareaoverlayelement *> (
Om. createoverlayelement ("textarea", "textareaname "));
Textarea-> setmetricsmode (Ogre: gmm_pixels );
Textarea-> setposition (0, 0 );
Textarea-> setdimensions (40, 40 );
Textarea-> setcaption ("Hello, world! ");
Textarea-> setcharheight (16 );
Textarea-> setfontname ("starwars2 ");//
Textarea-> setcolour (Ogre: colourvalue (0.6, 0.7, 0.8 ));
// Textarea-> setcolourbottom (Ogre: colourvalue (0.3, 0.5, 0.3 ));
// Textarea-> setcolourtop (Ogre: colourvalue (0.5, 0.7, 0.5 ));
 
// Add the text area to the Panel
Testpanel-> addchild (textarea );


// Create a text area 2
Ogre: textareaoverlayelement * textarea2 = static_cast <ogre: textareaoverlayelement *> (
Om. createoverlayelement ("textarea", "textareaname2 "));
Textarea2-> setmetricsmode (Ogre: gmm_pixels );
Textarea2-> setposition (40, 40 );
Textarea2-> setdimensions (40, 40 );
Textarea2-> setcaption ("Hello, world! ");
Textarea2-> setcharheight (16 );
Textarea2-> setfontname ("starwars ");//
Textarea2-> setcolour (Ogre: colourvalue (0.6, 0.7, 0.8 ));
// Textarea-> setcolourbottom (Ogre: colourvalue (0.3, 0.5, 0.3 ));
// Textarea-> setcolourtop (Ogre: colourvalue (0.5, 0.7, 0.5 ));

Testpanel-> addchild (textarea2 );

Ol-> add2d (testpanel );
Ol-> setzorder (10 );

Ol-> show ();

 

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.