anyway rendering worked fine..until i wanted to display the FPS via the IGUIFont::draw() method.
That made my app crash under dx9, but not under dx8 or OpenGL.
in general my code looked like this:
Code: Select all
// my custom scene node whooray
COceanSceneNode* ocean = new COceanSceneNode(smgr->getRootSceneNode(), smgr, -1, 128, scale, video::EVT_TANGENTS);
ocean->setMaterialType(video::EMT_NORMAL_MAP_SOLID);
...set other material stuff...add light..do this and that...
gui::IGUIFont* font2 = env->getBuiltInFont();
while(device->run())
{
driver->beginScene(paras here);
smgr->drawAll();
...
fps = driver->getFPS(); // bla foo tralalla
...
if (font2)
font2->draw(str.c_str(), rect<s32>(1, 1, 300, 60), video::SColor(255,255,255,255)); // CRASH! here in DX9:(
driver->endScene();
}
reason:
the variable OldVertexShader never got initalized.
but was being used here:
Code: Select all
void CD3D9ShaderMaterialRenderer::OnUnsetMaterial()
{
if (VertexShader)
pID3DDevice->SetVertexShader(OldVertexShader);
I probably didn't initialize my scene node correctly or maybe i have to unset the material in OnPostRender()?
anyway, it seems that its not guaranteed that OldVertexShader gets initialized, so I propose a simple fix:
initalize OldVertexShader at the CD3D9ShaderMaterialRenderer constructors to 0.