Reading that part of API was where I got started. Problem is I can't derive new class from IMaterialRenderer. Eighter IDirect3DDevice9 or COpenGLDriver gave compiler error. I described problem at the begining of this post.
What do you mean by cast involved involved? I don't se casting there...
Thanks
Creating custom material renderer
I think you only need:arras wrote:I am trying to create custom material renderer. Since it's the firsth time, just to get started somewhere, I try to coppy one of the Irrlicht own material renderers.
Here's code:
...
...
Code: Select all
video::SExposedVideoData data = driver->getExposedVideoData();
...
if (material.MaterialType != lastMaterial.MaterialType || resetAllRenderstates)
{
data.D3D9.D3DDev9->SetTextureStageState (0, D3DTSS_COLOROP, D3DTOP_MODULATE);
data.D3D9.D3DDev9->Set...
...Well, this realy looked promising belfegor. And so I did:
Compiled and get errors:
Code: Select all
class MyMaterialRenderer : public video::IMaterialRenderer
{
public:
MyMaterialRenderer(video::IVideoDriver* driver)
{
Driver = driver;
}
virtual bool setVariable(bool vertexShader, const c8* name, const f32* floats, int count)
{
return false;
}
virtual void OnSetMaterial(video::SMaterial& material, const video::SMaterial& lastMaterial,
bool resetAllRenderstates, video::IMaterialRendererServices* services)
{
if (material.MaterialType != lastMaterial.MaterialType || resetAllRenderstates)
{
video::SExposedVideoData Data = Driver->getExposedVideoData();
Data.D3D9.D3DDev9->SetTextureStageState (0, D3DTSS_COLOROP, D3DTOP_MODULATE);
Data.D3D9.D3DDev9->SetTextureStageState (0, D3DTSS_COLORARG1, D3DTA_TEXTURE);
Data.D3D9.D3DDev9->SetTextureStageState (0, D3DTSS_COLORARG2, D3DTA_DIFFUSE);
Data.D3D9.D3DDev9->SetTextureStageState (0, D3DTSS_ALPHAOP, D3DTOP_SELECTARG1);
Data.D3D9.D3DDev9->SetTextureStageState (0, D3DTSS_ALPHAARG1, D3DTA_DIFFUSE);
Data.D3D9.D3DDev9->SetTextureStageState(1, D3DTSS_COLOROP, D3DTOP_DISABLE);
Data.D3D9.D3DDev9->SetTextureStageState(1, D3DTSS_ALPHAOP, D3DTOP_DISABLE);
Data.D3D9.D3DDev9->SetRenderState(D3DRS_ALPHABLENDENABLE, TRUE);
Data.D3D9.D3DDev9->SetRenderState(D3DRS_SRCBLEND, D3DBLEND_ONE);
Data.D3D9.D3DDev9->SetRenderState(D3DRS_DESTBLEND, D3DBLEND_INVSRCALPHA);
}
material.ZWriteEnable = false;
services->setBasicRenderStates(material, lastMaterial, resetAllRenderstates);
}
virtual bool isTransparent()
{
return true;
}
protected:
video::IVideoDriver* Driver;
};This is strange. Can you try to compile it on your computer just to weryfi it?main.cpp In member function `virtual void MyMaterialRenderer::OnSetMaterial(irr::video::SMaterial&, const irr::video::SMaterial&, bool, irr::video::IMaterialRendererServices*)':
75 main.cpp invalid use of undefined type `struct IDirect3DDevice9'
10 irrlicht-1.3\include\SExposedVideoData.h forward declaration of `struct IDirect3DDevice9'
75 main.cpp `D3DTSS_COLOROP' undeclared (first use this function)
...and so on...
arras you need to link and include the DirectX SDK because the device Irrlicht is returning is undefined normally.
ShadowMapping for Irrlicht!: Get it here
Need help? Come on the IRC!: #irrlicht on irc://irc.freenode.net
Need help? Come on the IRC!: #irrlicht on irc://irc.freenode.net