How to add D3D11 vertex and fragment shaders to material that is created by Ogre::Font::load()?

Problems building or running the engine, queries about how to use features etc.
Knitschi
Gnoblar
Posts: 2
Joined: Tue May 19, 2026 2:10 pm
x 1

How to add D3D11 vertex and fragment shaders to material that is created by Ogre::Font::load()?

Post by Knitschi »

Ogre Version: 14.5.2
Operating System: Windows 10 (VMWare virtual machine)
Render System: D3D11

Hi everybody,

I am new to Ogre and I am currently trying to migrate a small application from Ogre 1.10 using the D3D9 rendersystem to 14.5 using the D3D11 rendersystem.
The application uses the Ogre::OverlayManager, Ogre::PanelOverlayElement and Ogre::TextAreaOverlayElement to render some text overlay.
I already made basic rendering work for the non-overlay part of the scene but for the text overlay I run into the runtime exception

Code: Select all

Ogre: Ogre::InvalidStateException::InvalidStateException:
 RenderSystem does not support FixedFunction, but technique of 'Fonts/Arial' has no Vertex Shader.
  Use the RTSS or write custom shaders. in SceneManager::_setPass at 
  OgreSceneManager.cpp (line 682)

The error mentions the RTSS but I have no clue how I can use that to add shaders to the material.
Or is there another way to make this work for example adding a material for that font?
Does anybody have a short example how I can make this work for the D3D11 Rendersystem?

Maybe this is relevant, so here is the code that creates the font. Note that we do not read a .fontdef file

Code: Select all

// Add the system fonts directory to the resources
auto resourceManager = Ogre::ResourceGroupManager::getSingletonPtr();
auto systemFontDir = QProcessEnvironment::systemEnvironment().value( "SYSTEMROOT" ) + "\\Fonts";
resourceManager->addResourceLocation( systemFontDir.toStdString(), "FileSystem", "FontGroup" );

auto fontManager = Ogre::FontManager::getSingletonPtr();
auto font = fontManager->create( "Arial", "FontGroup" );
// Specifying values manually since .fontdef could not be made working
font->setSource( "arial.ttf" );
font->setTrueTypeSize( 24 );
font->setTrueTypeResolution( 64 );
font->setType( Ogre::FT_TRUETYPE );
font->load();
Knitschi
Gnoblar
Posts: 2
Joined: Tue May 19, 2026 2:10 pm
x 1

Re: How to add D3D11 vertex and fragment shaders to material that is created by Ogre::Font::load()?

Post by Knitschi »

I finally made it work hooray!

I managed to make the EndlessTerrain example work and could derive a fix for our code from that.

First I had to make the RTSS work. That required adding the following lines of code:

Code: Select all

auto rtsInizialized = Ogre::RTShader::ShaderGenerator::initialize();
auto shaderGenerator = Ogre::RTShader::ShaderGenerator::getSingletonPtr();
shaderGenerator->addSceneManager(odc->getSceneManager());
shaderGenerator->setTargetLanguage("hlsl");
auto mMaterialMgrListener = new OgreBites::SGTechniqueResolverListener(shaderGenerator);
Ogre::MaterialManager::getSingleton().addListener(mMaterialMgrListener);

I also removed the manual font creation code by adding a .fontdef file and the arial.ttf file to the resource directory

Code: Select all

font TextOverlay/Arial
{
	type 		truetype
	source 		arial.ttf
	size 		20
	resolution  96
}