Revision | c974a42f23b7092a370d1c594eb1e782da9f61c8 (tree) |
---|---|
Time | 2010-04-24 23:47:06 |
Author | Steve Streeting <steve@stev...> |
Commiter | Steve Streeting |
Fix bug 240: TextAreaOverlayElement incorrectly loads Font in background thread (OGRE_THREAD_SUPPORT == 2)
@@ -70,6 +70,8 @@ | ||
70 | 70 | /** See OverlayElement. */ |
71 | 71 | virtual const String& getTypeName(void) const; |
72 | 72 | /** See Renderable. */ |
73 | + const MaterialPtr& getMaterial(void) const; | |
74 | + /** See Renderable. */ | |
73 | 75 | void getRenderOperation(RenderOperation& op); |
74 | 76 | /** Overridden from OverlayElement */ |
75 | 77 | void setMaterialName(const String& matName); |
@@ -359,10 +359,6 @@ | ||
359 | 359 | if (mpFont.isNull()) |
360 | 360 | OGRE_EXCEPT( Exception::ERR_ITEM_NOT_FOUND, "Could not find font " + font, |
361 | 361 | "TextAreaOverlayElement::setFontName" ); |
362 | - mpFont->load(); | |
363 | - mpMaterial = mpFont->getMaterial(); | |
364 | - mpMaterial->setDepthCheckEnabled(false); | |
365 | - mpMaterial->setLightingEnabled(false); | |
366 | 362 | |
367 | 363 | mGeomPositionsOutOfDate = true; |
368 | 364 | mGeomUVsOutOfDate = true; |
@@ -432,8 +428,23 @@ | ||
432 | 428 | return msTypeName; |
433 | 429 | } |
434 | 430 | //--------------------------------------------------------------------- |
431 | + const MaterialPtr& TextAreaOverlayElement::getMaterial(void) const | |
432 | + { | |
433 | + // On-demand load | |
434 | + // Moved from setFontName to avoid issues with background parsing of scripts | |
435 | + if (mpMaterial.isNull() && !mpFont.isNull()) | |
436 | + { | |
437 | + mpFont->load(); | |
438 | + // Ugly hack, but we need to override for lazy-load | |
439 | + *const_cast<MaterialPtr*>(&mpMaterial) = mpFont->getMaterial(); | |
440 | + mpMaterial->setDepthCheckEnabled(false); | |
441 | + mpMaterial->setLightingEnabled(false); | |
442 | + } | |
443 | + return mpMaterial; | |
444 | + } | |
445 | + //--------------------------------------------------------------------- | |
435 | 446 | void TextAreaOverlayElement::getRenderOperation(RenderOperation& op) |
436 | - { | |
447 | + { | |
437 | 448 | op = mRenderOp; |
438 | 449 | } |
439 | 450 | //--------------------------------------------------------------------- |