Change API of IVideoDriver drawStencilShadowVolume method to take an array of vectors instead of just the pointer and the number of vertices. We have this information anyway, so make us of it.

git-svn-id: svn://svn.code.sf.net/p/irrlicht/code/trunk@3957 dfc29bdd-3216-0410-991c-e03cc46cb475
master
hybrid 2011-10-22 11:28:39 +00:00
parent 8bd1f77c03
commit c7ea807729
12 changed files with 29 additions and 26 deletions

View File

@ -984,7 +984,7 @@ namespace video
\param count Amount of triangles in the array.
\param zfail If set to true, zfail method is used, otherwise
zpass. */
virtual void drawStencilShadowVolume(const core::vector3df* triangles, s32 count, bool zfail=true) =0;
virtual void drawStencilShadowVolume(const core::array<core::vector3df>& triangles, bool zfail=true) =0;
//! Fills the stencil shadow with color.
/** After the shadow volume has been drawn into the stencil

View File

@ -2017,8 +2017,9 @@ const wchar_t* CD3D8Driver::getName() const
//! Draws a shadow volume into the stencil buffer. To draw a stencil shadow, do
//! this: Frist, draw all geometry. Then use this method, to draw the shadow
//! volume. Then, use IVideoDriver::drawStencilShadow() to visualize the shadow.
void CD3D8Driver::drawStencilShadowVolume(const core::vector3df* triangles, s32 count, bool zfail)
void CD3D8Driver::drawStencilShadowVolume(const core::array<core::vector3df>& triangles, bool zfail)
{
const u32 count = triangles.size();
if (!StencilBuffer || !count)
return;
@ -2031,12 +2032,12 @@ void CD3D8Driver::drawStencilShadowVolume(const core::vector3df* triangles, s32
// Draw front-side of shadow volume in stencil/z only
pID3DDevice->SetRenderState(D3DRS_CULLMODE, D3DCULL_CCW );
pID3DDevice->SetRenderState(D3DRS_STENCILPASS, D3DSTENCILOP_INCRSAT);
pID3DDevice->DrawPrimitiveUP(D3DPT_TRIANGLELIST, count / 3, triangles, sizeof(core::vector3df));
pID3DDevice->DrawPrimitiveUP(D3DPT_TRIANGLELIST, count / 3, triangles.const_pointer(), sizeof(core::vector3df));
// Now reverse cull order so front sides of shadow volume are written.
pID3DDevice->SetRenderState( D3DRS_CULLMODE, D3DCULL_CW );
pID3DDevice->SetRenderState( D3DRS_STENCILPASS, D3DSTENCILOP_DECRSAT);
pID3DDevice->DrawPrimitiveUP(D3DPT_TRIANGLELIST, count / 3, triangles, sizeof(core::vector3df));
pID3DDevice->DrawPrimitiveUP(D3DPT_TRIANGLELIST, count / 3, triangles.const_pointer(), sizeof(core::vector3df));
}
else
{
@ -2045,12 +2046,12 @@ void CD3D8Driver::drawStencilShadowVolume(const core::vector3df* triangles, s32
// Draw front-side of shadow volume in stencil/z only
pID3DDevice->SetRenderState(D3DRS_CULLMODE, D3DCULL_CW );
pID3DDevice->SetRenderState(D3DRS_STENCILZFAIL, D3DSTENCILOP_INCRSAT );
pID3DDevice->DrawPrimitiveUP(D3DPT_TRIANGLELIST, count / 3, triangles, sizeof(core::vector3df));
pID3DDevice->DrawPrimitiveUP(D3DPT_TRIANGLELIST, count / 3, triangles.const_pointer(), sizeof(core::vector3df));
// Now reverse cull order so front sides of shadow volume are written.
pID3DDevice->SetRenderState( D3DRS_CULLMODE, D3DCULL_CCW );
pID3DDevice->SetRenderState( D3DRS_STENCILZFAIL, D3DSTENCILOP_DECRSAT );
pID3DDevice->DrawPrimitiveUP(D3DPT_TRIANGLELIST, count / 3, triangles, sizeof(core::vector3df));
pID3DDevice->DrawPrimitiveUP(D3DPT_TRIANGLELIST, count / 3, triangles.const_pointer(), sizeof(core::vector3df));
}
}

View File

@ -138,7 +138,7 @@ namespace video
//! Draws a shadow volume into the stencil buffer. To draw a stencil shadow, do
//! this: Frist, draw all geometry. Then use this method, to draw the shadow
//! volume. Then, use IVideoDriver::drawStencilShadow() to visualize the shadow.
virtual void drawStencilShadowVolume(const core::vector3df* triangles, s32 count, bool zfail);
virtual void drawStencilShadowVolume(const core::array<core::vector3df>& triangles, bool zfail);
//! Fills the stencil shadow with color. After the shadow volume has been drawn
//! into the stencil buffer using IVideoDriver::drawStencilShadowVolume(), use this

View File

@ -2760,8 +2760,9 @@ const wchar_t* CD3D9Driver::getName() const
//! Draws a shadow volume into the stencil buffer. To draw a stencil shadow, do
//! this: Frist, draw all geometry. Then use this method, to draw the shadow
//! volume. Then, use IVideoDriver::drawStencilShadow() to visualize the shadow.
void CD3D9Driver::drawStencilShadowVolume(const core::vector3df* triangles, s32 count, bool zfail)
void CD3D9Driver::drawStencilShadowVolume(const core::array<core::vector3df>& triangles, bool zfail)
{
const u32 count = triangles.size();
if (!Params.Stencilbuffer || !count)
return;
@ -2774,12 +2775,12 @@ void CD3D9Driver::drawStencilShadowVolume(const core::vector3df* triangles, s32
// Draw front-side of shadow volume in stencil/z only
pID3DDevice->SetRenderState(D3DRS_CULLMODE, D3DCULL_CCW);
pID3DDevice->SetRenderState(D3DRS_STENCILPASS, D3DSTENCILOP_INCR);
pID3DDevice->DrawPrimitiveUP(D3DPT_TRIANGLELIST, count / 3, triangles, sizeof(core::vector3df));
pID3DDevice->DrawPrimitiveUP(D3DPT_TRIANGLELIST, count / 3, triangles.const_pointer(), sizeof(core::vector3df));
// Now reverse cull order so front sides of shadow volume are written.
pID3DDevice->SetRenderState(D3DRS_CULLMODE, D3DCULL_CW);
pID3DDevice->SetRenderState(D3DRS_STENCILPASS, D3DSTENCILOP_DECR);
pID3DDevice->DrawPrimitiveUP(D3DPT_TRIANGLELIST, count / 3, triangles, sizeof(core::vector3df));
pID3DDevice->DrawPrimitiveUP(D3DPT_TRIANGLELIST, count / 3, triangles.const_pointer(), sizeof(core::vector3df));
}
else
{
@ -2788,12 +2789,12 @@ void CD3D9Driver::drawStencilShadowVolume(const core::vector3df* triangles, s32
// Draw front-side of shadow volume in stencil/z only
pID3DDevice->SetRenderState(D3DRS_CULLMODE, D3DCULL_CW);
pID3DDevice->SetRenderState(D3DRS_STENCILZFAIL, D3DSTENCILOP_INCR);
pID3DDevice->DrawPrimitiveUP(D3DPT_TRIANGLELIST, count / 3, triangles, sizeof(core::vector3df));
pID3DDevice->DrawPrimitiveUP(D3DPT_TRIANGLELIST, count / 3, triangles.const_pointer(), sizeof(core::vector3df));
// Now reverse cull order so front sides of shadow volume are written.
pID3DDevice->SetRenderState( D3DRS_CULLMODE, D3DCULL_CCW);
pID3DDevice->SetRenderState( D3DRS_STENCILZFAIL, D3DSTENCILOP_DECR);
pID3DDevice->DrawPrimitiveUP(D3DPT_TRIANGLELIST, count / 3, triangles, sizeof(core::vector3df));
pID3DDevice->DrawPrimitiveUP(D3DPT_TRIANGLELIST, count / 3, triangles.const_pointer(), sizeof(core::vector3df));
}
}

View File

@ -219,7 +219,7 @@ namespace video
virtual void setAmbientLight(const SColorf& color);
//! Draws a shadow volume into the stencil buffer.
virtual void drawStencilShadowVolume(const core::vector3df* triangles, s32 count, bool zfail);
virtual void drawStencilShadowVolume(const core::array<core::vector3df>& triangles, bool zfail);
//! Fills the stencil shadow with color.
virtual void drawStencilShadow(bool clearStencilBuffer=false,

View File

@ -915,7 +915,7 @@ const wchar_t* CNullDriver::getName() const
//! Draws a shadow volume into the stencil buffer. To draw a stencil shadow, do
//! this: Frist, draw all geometry. Then use this method, to draw the shadow
//! volume. Then, use IVideoDriver::drawStencilShadow() to visualize the shadow.
void CNullDriver::drawStencilShadowVolume(const core::vector3df* triangles, s32 count, bool zfail)
void CNullDriver::drawStencilShadowVolume(const core::array<core::vector3df>& triangles, bool zfail)
{
}

View File

@ -284,7 +284,7 @@ namespace video
//! Draws a shadow volume into the stencil buffer. To draw a stencil shadow, do
//! this: Frist, draw all geometry. Then use this method, to draw the shadow
//! volume. Then, use IVideoDriver::drawStencilShadow() to visualize the shadow.
virtual void drawStencilShadowVolume(const core::vector3df* triangles, s32 count, bool zfail=true);
virtual void drawStencilShadowVolume(const core::array<core::vector3df>& triangles, bool zfail=true);
//! Fills the stencil shadow with color. After the shadow volume has been drawn
//! into the stencil buffer using IVideoDriver::drawStencilShadowVolume(), use this

View File

@ -3502,8 +3502,9 @@ void COpenGLDriver::setViewPort(const core::rect<s32>& area)
//! Draws a shadow volume into the stencil buffer. To draw a stencil shadow, do
//! this: First, draw all geometry. Then use this method, to draw the shadow
//! volume. Next use IVideoDriver::drawStencilShadow() to visualize the shadow.
void COpenGLDriver::drawStencilShadowVolume(const core::vector3df* triangles, s32 count, bool zfail)
void COpenGLDriver::drawStencilShadowVolume(const core::array<core::vector3df>& triangles, bool zfail)
{
const u32 count=triangles.size();
if (!StencilBuffer || !count)
return;
@ -3523,11 +3524,12 @@ void COpenGLDriver::drawStencilShadowVolume(const core::vector3df* triangles, s3
glDisable(GL_FOG);
glDepthFunc(GL_LEQUAL);
glDepthMask(GL_FALSE); // no depth buffer writing
// glPolygonMode(GL_FRONT_AND_BACK, GL_LINE);
glColorMask(GL_FALSE, GL_FALSE, GL_FALSE, GL_FALSE); // no color buffer drawing
glEnable(GL_STENCIL_TEST);
glEnableClientState(GL_VERTEX_ARRAY);
glVertexPointer(3,GL_FLOAT,sizeof(core::vector3df),&triangles[0]);
glVertexPointer(3,GL_FLOAT,sizeof(core::vector3df),triangles.const_pointer());
glStencilMask(~0);
glStencilFunc(GL_ALWAYS, 0, ~0);
glPolygonOffset(-1.f,-1.f);

View File

@ -238,7 +238,7 @@ namespace video
//! Draws a shadow volume into the stencil buffer. To draw a stencil shadow, do
//! this: First, draw all geometry. Then use this method, to draw the shadow
//! volume. Then, use IVideoDriver::drawStencilShadow() to visualize the shadow.
virtual void drawStencilShadowVolume(const core::vector3df* triangles, s32 count, bool zfail);
virtual void drawStencilShadowVolume(const core::array<core::vector3df>& triangles, bool zfail);
//! Fills the stencil shadow with color. After the shadow volume has been drawn
//! into the stencil buffer using IVideoDriver::drawStencilShadowVolume(), use this

View File

@ -292,7 +292,7 @@ void CShadowVolumeSceneNode::render()
for (u32 i=0; i<ShadowVolumesUsed; ++i)
{
driver->drawStencilShadowVolume(ShadowVolumes[i].pointer(),ShadowVolumes[i].size(), UseZFailMethod);
driver->drawStencilShadowVolume(ShadowVolumes[i], UseZFailMethod);
}
}

View File

@ -2625,8 +2625,9 @@ u32 CBurningVideoDriver::getMaximalPrimitiveCount() const
//! Draws a shadow volume into the stencil buffer. To draw a stencil shadow, do
//! this: First, draw all geometry. Then use this method, to draw the shadow
//! volume. Next use IVideoDriver::drawStencilShadow() to visualize the shadow.
void CBurningVideoDriver::drawStencilShadowVolume(const core::vector3df* triangles, s32 count, bool zfail)
void CBurningVideoDriver::drawStencilShadowVolume(const core::array<core::vector3df>& triangles, bool zfail)
{
const u32 count = triangles.size();
IBurningShader *shader = BurningShader [ ETR_STENCIL_SHADOW ];
CurrentShader = shader;
@ -2641,14 +2642,14 @@ void CBurningVideoDriver::drawStencilShadowVolume(const core::vector3df* triangl
//glStencilMask(~0);
//glStencilFunc(GL_ALWAYS, 0, ~0);
if (zfail)
if (true)// zpass does not work yet
{
Material.org.BackfaceCulling = true;
Material.org.FrontfaceCulling = false;
shader->setParam ( 0, 0 );
shader->setParam ( 1, 1 );
shader->setParam ( 2, 0 );
drawVertexPrimitiveList ( triangles, count, 0, count/3, (video::E_VERTEX_TYPE) 4, scene::EPT_TRIANGLES, (video::E_INDEX_TYPE) 4 );
drawVertexPrimitiveList (triangles.const_pointer(), count, 0, count/3, (video::E_VERTEX_TYPE) 4, scene::EPT_TRIANGLES, (video::E_INDEX_TYPE) 4 );
//glStencilOp(GL_KEEP, incr, GL_KEEP);
//glDrawArrays(GL_TRIANGLES,0,count);
@ -2657,7 +2658,7 @@ void CBurningVideoDriver::drawStencilShadowVolume(const core::vector3df* triangl
shader->setParam ( 0, 0 );
shader->setParam ( 1, 2 );
shader->setParam ( 2, 0 );
drawVertexPrimitiveList ( triangles, count, 0, count/3, (video::E_VERTEX_TYPE) 4, scene::EPT_TRIANGLES, (video::E_INDEX_TYPE) 4 );
drawVertexPrimitiveList (triangles.const_pointer(), count, 0, count/3, (video::E_VERTEX_TYPE) 4, scene::EPT_TRIANGLES, (video::E_INDEX_TYPE) 4 );
//glStencilOp(GL_KEEP, decr, GL_KEEP);
//glDrawArrays(GL_TRIANGLES,0,count);
}
@ -2679,8 +2680,6 @@ void CBurningVideoDriver::drawStencilShadowVolume(const core::vector3df* triangl
//glStencilOp(GL_KEEP, GL_KEEP, decr);
//glDrawArrays(GL_TRIANGLES,0,count);
}
}
//! Fills the stencil shadow with color. After the shadow volume has been drawn

View File

@ -146,7 +146,7 @@ namespace video
//! Draws a shadow volume into the stencil buffer. To draw a stencil shadow, do
//! this: First, draw all geometry. Then use this method, to draw the shadow
//! volume. Then, use IVideoDriver::drawStencilShadow() to visualize the shadow.
virtual void drawStencilShadowVolume(const core::vector3df* triangles, s32 count, bool zfail);
virtual void drawStencilShadowVolume(const core::array<core::vector3df>& triangles, bool zfail);
//! Fills the stencil shadow with color. After the shadow volume has been drawn
//! into the stencil buffer using IVideoDriver::drawStencilShadowVolume(), use this