MCPcopy Create free account
hub / github.com/OGRECave/ogre / loadImpl

Method loadImpl

Components/Overlay/src/OgreFont.cpp:252–304  ·  view source on GitHub ↗

---------------------------------------------------------------------

Source from the content-addressed store, hash-verified

250
251 //---------------------------------------------------------------------
252 void Font::loadImpl()
253 {
254 // Create a new material
255 mMaterial = MaterialManager::getSingleton().create(
256 "Fonts/" + mName, mGroup);
257
258 if (!mMaterial)
259 {
260 OGRE_EXCEPT(Exception::ERR_INTERNAL_ERROR,
261 "Error creating new material!", "Font::load" );
262 }
263
264 if (mType == FT_TRUETYPE)
265 {
266 createTextureFromFont();
267 }
268 else
269 {
270 // Manually load since we need to load to get alpha
271 mTexture = TextureManager::getSingleton().load(mSource, mGroup, TEX_TYPE_2D, 0);
272 }
273
274 // Make sure material is aware of colour per vertex.
275 auto pass = mMaterial->getTechnique(0)->getPass(0);
276 pass->setVertexColourTracking(TVC_DIFFUSE);
277
278 // lighting and culling also do not make much sense
279 pass->setCullingMode(CULL_NONE);
280 pass->setLightingEnabled(false);
281 mMaterial->setReceiveShadows(false);
282 // font quads should not occlude things
283 pass->setDepthWriteEnabled(false);
284
285 TextureUnitState *texLayer = mMaterial->getTechnique(0)->getPass(0)->createTextureUnitState();
286 texLayer->setTexture(mTexture);
287 // Clamp to avoid fuzzy edges
288 texLayer->setTextureAddressingMode( TextureUnitState::TAM_CLAMP );
289 // Allow min/mag filter, but no mip
290 texLayer->setTextureFiltering(FO_LINEAR, FO_LINEAR, FO_NONE);
291
292
293 // Set up blending
294 if (mTexture->hasAlpha())
295 {
296 mMaterial->setSceneBlending(mAntialiasColour ? SBF_ONE : SBF_SOURCE_ALPHA, SBF_ONE_MINUS_SOURCE_ALPHA);
297 mMaterial->getTechnique(0)->getPass(0)->setTransparentSortingEnabled(false);
298 }
299 else
300 {
301 // Use add if no alpha (assume black background)
302 mMaterial->setSceneBlending(SBT_ADD);
303 }
304 }
305 //---------------------------------------------------------------------
306 void Font::unloadImpl()
307 {

Callers

nothing calls this directly

Calls 12

getPassMethod · 0.80
setTextureMethod · 0.80
createMethod · 0.45
loadMethod · 0.45
getTechniqueMethod · 0.45
setCullingModeMethod · 0.45
setLightingEnabledMethod · 0.45
setDepthWriteEnabledMethod · 0.45
setTextureFilteringMethod · 0.45
hasAlphaMethod · 0.45
setSceneBlendingMethod · 0.45

Tested by

no test coverage detected