本文整理汇总了C++中LPDIRECT3DDEVICE7::SetRenderState方法的典型用法代码示例。如果您正苦于以下问题:C++ LPDIRECT3DDEVICE7::SetRenderState方法的具体用法?C++ LPDIRECT3DDEVICE7::SetRenderState怎么用?C++ LPDIRECT3DDEVICE7::SetRenderState使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类LPDIRECT3DDEVICE7
的用法示例。
在下文中一共展示了LPDIRECT3DDEVICE7::SetRenderState方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: DrawUI
void CGras::DrawUI(LPDIRECT3DDEVICE7 lpDevice)
{
if (lpVertices==NULL)return;
if (game->lpTexture[40]==NULL)
{ // Gras Textur nachladen
game->lpTexture[40]=CreateTextureFromResource(lpDevice,game->lpDD,NULL,"grass.bmp",4,FALSE,TRUE);
MakeTransparent(game->lpTexture[40],FALSE); // Gras
}
lpDevice->SetRenderState(D3DRENDERSTATE_LIGHTING,FALSE);
DWORD old;
lpDevice->GetRenderState(D3DRENDERSTATE_CULLMODE,&old);
lpDevice->SetRenderState(D3DRENDERSTATE_CULLMODE,D3DCULL_NONE);
if (Config.alpha)
{
lpDevice->SetTextureStageState(0,D3DTSS_ALPHAARG1,D3DTA_TEXTURE);
lpDevice->SetRenderState(D3DRENDERSTATE_ALPHATESTENABLE,TRUE);
lpDevice->SetRenderState(D3DRENDERSTATE_ALPHAREF,192);
lpDevice->SetRenderState(D3DRENDERSTATE_ALPHAFUNC,D3DCMP_GREATEREQUAL);
}
lpDevice->SetTexture(0,game->lpTexture[40]);
D3DMATRIX m;
D3DUtil_SetIdentityMatrix(m);
lpDevice->SetTransform(D3DTRANSFORMSTATE_WORLD,&m);
for (int i=0;i<vertexbuffers;i++)
lpDevice->DrawIndexedPrimitiveVB(D3DPT_TRIANGLELIST,lpVertices[i],0,vertexnum[i],Indices,vertexnum[i]/4*6,0);
lpDevice->SetRenderState(D3DRENDERSTATE_ALPHATESTENABLE,0);
lpDevice->SetRenderState(D3DRENDERSTATE_LIGHTING,TRUE);
lpDevice->SetRenderState(D3DRENDERSTATE_CULLMODE,old);
}
示例2: ResetBlendenderState
/******************************************************************************************************************
함수명 : ResetBlendenderState()
작성자 :
작성일 :
목적 : 렌더링스테이트를 기본상태로 복구한다.
입력 : LPDIRECT3DDEVICE7 pd3dDevice
출력 : void
[일자][수정자] : 수정내용
*******************************************************************************************************************/
void ResetBlendenderState(LPDIRECT3DDEVICE7 pd3dDevice)
{
pd3dDevice->SetTextureStageState(0, D3DTSS_COLORARG1, D3DTA_TEXTURE);
pd3dDevice->SetTextureStageState(0, D3DTSS_COLOROP, D3DTOP_MODULATE);
pd3dDevice->SetTextureStageState(0, D3DTSS_COLORARG2, D3DTA_DIFFUSE);
pd3dDevice->SetTextureStageState(0, D3DTSS_ALPHAARG1, D3DTA_TEXTURE);
pd3dDevice->SetTextureStageState(0, D3DTSS_ALPHAOP, D3DTOP_SELECTARG1);
pd3dDevice->SetTextureStageState(0, D3DTSS_ALPHAARG2, D3DTA_DIFFUSE);
pd3dDevice->SetRenderState(D3DRENDERSTATE_ALPHABLENDENABLE, FALSE);
pd3dDevice->SetRenderState(D3DRENDERSTATE_COLORKEYENABLE, FALSE);
pd3dDevice->SetRenderState(D3DRENDERSTATE_SRCBLEND , D3DBLEND_ONE);
pd3dDevice->SetRenderState(D3DRENDERSTATE_DESTBLEND, D3DBLEND_ZERO);
}
示例3: Render
//-----------------------------------------------------------------------------
// rendu de la d�chirure spatio temporelle
float CSummonCreature::Render(LPDIRECT3DDEVICE7 m_pd3dDevice)
{
if (ulCurrentTime >= (ulDurationIntro + ulDurationRender + ulDurationOuttro)) return 0.f;
SETTC(m_pd3dDevice, NULL);
SETCULL(m_pd3dDevice, D3DCULL_NONE);
SETZWRITE(m_pd3dDevice, false);
SETTEXTUREWRAPMODE(m_pd3dDevice, D3DTADDRESS_CLAMP);
m_pd3dDevice->SetRenderState(D3DRENDERSTATE_SRCBLEND, D3DBLEND_ONE);
m_pd3dDevice->SetRenderState(D3DRENDERSTATE_DESTBLEND, D3DBLEND_ONE);
SETALPHABLEND(m_pd3dDevice, true);
//-------------------------------------------------------------------------
fTexWrap += 0.02f;
if (fTexWrap >= 1.0f)
{
fTexWrap -= 1.0f;
}
//-------------------------------------------------------------------------
// render intro (opening + rays)
if (ulCurrentTime < ulDurationIntro)
{
if (ulCurrentTime < ulDurationIntro * 0.666f)
{
fSizeIntro = (end + 2) * fOneOnDurationIntro * (1.5f) * ulCurrentTime;
sizeF = 1;
}
else
{
if (bIntro != false)
bIntro = false;
sizeF = (iSize) * (fOneOnDurationIntro * 3) * (ulCurrentTime - ulDurationIntro * 0.666f);
}
}
// do nothing just render
else if (ulCurrentTime < (ulDurationIntro + ulDurationRender))
{
}
// close it all
else if (ulCurrentTime < (ulDurationIntro + ulDurationRender + ulDurationOuttro))
{
//if (sizeF > 0)
{
sizeF = iSize - (iSize) * fOneOnDurationOuttro * (ulCurrentTime - (ulDurationIntro + ulDurationRender));
}
}
SETALPHABLEND(m_pd3dDevice, false);
RenderFissure(m_pd3dDevice);
SETZWRITE(m_pd3dDevice, true);
SETALPHABLEND(m_pd3dDevice, false);
SETTEXTUREWRAPMODE(m_pd3dDevice, D3DTADDRESS_WRAP);
return (fSizeIntro / end);
}
示例4: DrawAlpha
void CSprite::DrawAlpha(LPDIRECT3DDEVICE7 lpDevice,const D3DVECTOR pos,const float w,const float h,const DWORD color,const int spritenr)
{
D3DVECTOR rightVect,upVect;
D3DMATRIX mat;
{
lpDevice->GetTransform(D3DTRANSFORMSTATE_VIEW,&mat);
rightVect=Normalize(D3DVECTOR(mat._11,mat._21,mat._31))*w*0.5f;
upVect=Normalize(D3DVECTOR(mat._12,mat._22,mat._32))*h*0.5f;
}
D3DLVERTEX verts[4]=
{
D3DLVERTEX(pos-rightVect+upVect, color,0, 1.0f, 0.0f),
D3DLVERTEX(pos+rightVect+upVect, color,0, 0.0f, 0.0f),
D3DLVERTEX(pos-rightVect-upVect, color,0, 1.0f, 1.0f),
D3DLVERTEX(pos+rightVect-upVect, color,0, 0.0f, 1.0f)
};
D3DUtil_SetIdentityMatrix(mat);
lpDevice->SetTransform(D3DTRANSFORMSTATE_WORLD,&mat);
if (Config.alpha)
{
lpDevice->SetRenderState(D3DRENDERSTATE_ALPHABLENDENABLE, TRUE);
lpDevice->SetRenderState(D3DRENDERSTATE_LIGHTING,FALSE);
lpDevice->SetTextureStageState(0, D3DTSS_ALPHAARG1, D3DTA_TEXTURE);
lpDevice->SetTextureStageState(0, D3DTSS_ALPHAOP, D3DTOP_SELECTARG1);
lpDevice->SetTextureStageState(0,D3DTSS_COLOROP,D3DTOP_MODULATE);
lpDevice->SetRenderState(D3DRENDERSTATE_SRCBLEND,D3DBLEND_SRCALPHA);
lpDevice->SetRenderState(D3DRENDERSTATE_DESTBLEND,D3DBLEND_INVSRCALPHA);
lpDevice->SetRenderState(D3DRENDERSTATE_ALPHATESTENABLE,TRUE);
lpDevice->SetRenderState(D3DRENDERSTATE_ALPHAREF,8);
}
lpDevice->SetTexture(0,GetSurface(spritenr));
lpDevice->DrawPrimitive(D3DPT_TRIANGLESTRIP,D3DFVF_LVERTEX,verts,4,0);
lpDevice->SetTexture(0,NULL);
if (Config.alpha)
{
lpDevice->SetRenderState(D3DRENDERSTATE_ALPHABLENDENABLE, FALSE);
lpDevice->SetRenderState(D3DRENDERSTATE_LIGHTING,TRUE);
lpDevice->SetRenderState(D3DRENDERSTATE_ALPHATESTENABLE,FALSE);
}
}
示例5: DrawShadow
void DrawShadow(LPDIRECT3DDEVICE7 lpDevice)
{
lpDevice->SetRenderState( D3DRENDERSTATE_ZENABLE, FALSE );
lpDevice->SetRenderState( D3DRENDERSTATE_STENCILENABLE, TRUE );
// Turn on alphablending
lpDevice->SetRenderState( D3DRENDERSTATE_ALPHABLENDENABLE, TRUE );
lpDevice->SetRenderState( D3DRENDERSTATE_SRCBLEND, D3DBLEND_SRCALPHA );
lpDevice->SetRenderState( D3DRENDERSTATE_DESTBLEND, D3DBLEND_INVSRCALPHA );
lpDevice->SetTextureStageState(0,D3DTSS_ALPHAARG1,D3DTA_DIFFUSE);
// Only write where the stencil value == 1
lpDevice->SetRenderState( D3DRENDERSTATE_STENCILREF, 0x1 );
lpDevice->SetRenderState( D3DRENDERSTATE_STENCILFUNC, D3DCMP_EQUAL );
lpDevice->SetRenderState( D3DRENDERSTATE_STENCILPASS, D3DSTENCILOP_KEEP );
// Get viewport dimensions for big, gray square
D3DVIEWPORT7 vp;
lpDevice->GetViewport(&vp);
FLOAT sx = (FLOAT)vp.dwWidth;
FLOAT sy = (FLOAT)vp.dwHeight;
D3DCOLOR color=D3DRGBA(0,0,0,0.5f);
// Draw a big, gray square
D3DTLVERTEX vBigGraySquare[4];
vBigGraySquare[0] = D3DTLVERTEX( D3DVECTOR( 0,sy,0.0f),1.0f,color,0,0,0 );
vBigGraySquare[1] = D3DTLVERTEX( D3DVECTOR( 0, 0,0.0f),1.0f,color,0,0,0 );
vBigGraySquare[2] = D3DTLVERTEX( D3DVECTOR(sx,sy,0.0f),1.0f,color,0,0,0 );
vBigGraySquare[3] = D3DTLVERTEX( D3DVECTOR(sx, 0,0.0f),1.0f,color,0,0,0 );
lpDevice->DrawPrimitive( D3DPT_TRIANGLESTRIP, D3DFVF_TLVERTEX,
vBigGraySquare, 4, NULL );
// Restore render states
lpDevice->SetRenderState( D3DRENDERSTATE_ZENABLE, TRUE );
lpDevice->SetRenderState( D3DRENDERSTATE_STENCILENABLE, FALSE );
lpDevice->SetRenderState( D3DRENDERSTATE_ALPHABLENDENABLE, FALSE );
}
示例6: DrawUI
void CRadar::DrawUI(LPDIRECT3DDEVICE7 lpDevice)
{
if (!Enabled)return;
if ((lpSurface==NULL)||(lpSurface->IsLost()))
{
UpdateSurface();
Update();
}
const float w=130.0f*game->width/640.0f;
const float h=130.0f*game->width/640.0f;
const float x=game->width-20-w;
const float y=game->height-20-h;
const int c=D3DRGBA(1,1,1,0.45f);
const float r=0.9f;
D3DTLVERTEX v[4]={
D3DTLVERTEX(D3DVECTOR(x,y,0),r,c,0,0,0),
D3DTLVERTEX(D3DVECTOR(x+w,y,0),r,c,0,1,0),
D3DTLVERTEX(D3DVECTOR(x,y+h,0),r,c,0,0,1),
D3DTLVERTEX(D3DVECTOR(x+w,y+h,0),r,c,0,1,1)
};
if (Config.alpha)
{
// lpDevice->SetRenderState(D3DRENDERSTATE_ZENABLE,FALSE);
lpDevice->SetRenderState(D3DRENDERSTATE_ALPHABLENDENABLE,TRUE);
lpDevice->SetRenderState(D3DRENDERSTATE_SRCBLEND,D3DBLEND_SRCALPHA);
lpDevice->SetRenderState(D3DRENDERSTATE_DESTBLEND,D3DBLEND_INVSRCALPHA);
lpDevice->SetTextureStageState(0,D3DTSS_ALPHAOP,D3DTOP_MODULATE);
lpDevice->SetRenderState(D3DRENDERSTATE_ALPHATESTENABLE,TRUE);
lpDevice->SetRenderState(D3DRENDERSTATE_ALPHAREF,8);
lpDevice->SetRenderState(D3DRENDERSTATE_ALPHAFUNC,D3DCMP_GREATEREQUAL);
}
lpDevice->SetTexture(0,lpSurface);
lpDevice->DrawPrimitive(D3DPT_TRIANGLESTRIP,D3DFVF_TLVERTEX,v,4,0);
lpDevice->SetTexture(0,NULL);
lpDevice->SetRenderState(D3DRENDERSTATE_ALPHABLENDENABLE,0);
lpDevice->SetRenderState(D3DRENDERSTATE_ALPHATESTENABLE,0);
// lpDevice->SetRenderState(D3DRENDERSTATE_ZENABLE,TRUE);
}
示例7: wSetRenderState
/// <summary>
/// <c>wSetRenderState</c>
/// </summary>
/// <remarks>
/// </remarks>
/// <param name="d3dDevice7"></param>
/// <param name="dwRenderStateType"></param>
/// <param name="dwRenderState"></param>
/// <returns></returns>
HRESULT __stdcall wSetRenderState(
LPDIRECT3DDEVICE7 d3dDevice7, D3DRENDERSTATETYPE dwRenderStateType, ULONG dwRenderState)
{
PSTR pszRenderState;
PSTR pszErrorMessage;
HRESULT hResult;
++TotalRenderStateChanges;
pszRenderState = GetRenderState(dwRenderStateType, dwRenderState);
InternalFunctionSpew("GameOS_Direct3D", "SetRenderState(%s)", pszRenderState);
hResult = d3dDevice7->SetRenderState(dwRenderStateType, dwRenderState);
if (FAILED(hResult))
{
pszRenderState = GetRenderState(dwRenderStateType, dwRenderState);
pszErrorMessage = ErrorNumberToMessage(hResult);
if ( InternalFunctionPause("FAILED (0x%x - %s) - SetRenderState(%s)",
hResult, pszErrorMessage, pszRenderState) )
ENTER_DEBUGGER;
}
return hResult;
}
示例8: Render
//---------------------------------------------------------------------
float CRuneOfGuarding::Render(LPDIRECT3DDEVICE7 m_pd3dDevice)
{
float x = eSrc.x;
float y = eSrc.y - 20;
float z = eSrc.z;
SETZWRITE(m_pd3dDevice, FALSE);
m_pd3dDevice->SetRenderState(D3DRENDERSTATE_SRCBLEND, D3DBLEND_ONE);
m_pd3dDevice->SetRenderState(D3DRENDERSTATE_DESTBLEND, D3DBLEND_ONE);
SETALPHABLEND(m_pd3dDevice, TRUE);
//----------------------------
// long color = D3DRGB(1,1,1);
// int size = 100;
//----------------------------
EERIE_3D stiteangle;
EERIE_3D stitepos;
EERIE_3D stitescale;
EERIE_RGB stitecolor;
float stiteangleb = (float) ulCurrentTime * fOneOnDuration * 120;
stiteangle.a = 0;
stiteangle.g = 0;
stitepos.x = x;
stitepos.y = y;
stitepos.z = z;
float gtc = (float)ARX_TIME_Get();
float v = EEsin(gtc * DIV1000) * DIV10;
stiteangle.b = MAKEANGLE(gtc * DIV1000);
stitecolor.r = 0.4f - v;
stitecolor.g = 0.4f - v;
stitecolor.b = 0.6f - v;
stitescale.x = 1;
stitescale.y = -0.1f;
stitescale.z = 1;
if (slight)
DrawEERIEObjEx(m_pd3dDevice, slight, &stiteangle, &stitepos, &stitescale, &stitecolor);
stiteangle.b = stiteangleb;
stitecolor.r = 0.6f;
stitecolor.g = 0.f;
stitecolor.b = 0.f;
stitescale.x = 2;
stitescale.y = 2;
stitescale.z = 2;
if (ssol)
DrawEERIEObjEx(m_pd3dDevice, ssol, &stiteangle, &stitepos, &stitescale, &stitecolor);
stitecolor.r = 0.6f;
stitecolor.g = 0.3f;
stitecolor.b = 0.45f;
stitescale.z = 1.8f;
stitescale.y = 1.8f;
stitescale.x = 1.8f;
if (srune)
DrawEERIEObjEx(m_pd3dDevice, srune, &stiteangle, &stitepos, &stitescale, &stitecolor);
for (int n = 0; n < 4; n++)
{
int j = ARX_PARTICLES_GetFree();
if ((j != -1) && (!ARXPausedTimer))
{
ParticleCount++;
particle[j].exist = 1;
particle[j].zdec = 0;
particle[j].ov.x = x + frand2() * 40;
particle[j].ov.y = y;
particle[j].ov.z = z + frand2() * 40;
particle[j].move.x = 0.8f * frand2();
particle[j].move.y = -4.f * rnd();
particle[j].move.z = 0.8f * frand2();
particle[j].scale.x = -0.1f;
particle[j].scale.y = -0.1f;
particle[j].scale.z = -0.1f;
particle[j].timcreation = lARXTime;
particle[j].tolive = 2600 + (unsigned long)(rnd() * 600.f);
particle[j].tc = tex_p2;
particle[j].siz = 0.3f;
particle[j].r = 0.4f;
particle[j].g = 0.4f;
particle[j].b = 0.6f;
}
}
return 1.0f - rnd() * 0.3f;
}
示例9: DrawStone
/*--------------------------------------------------------------------------*/
void CLevitate::DrawStone(LPDIRECT3DDEVICE7 device)
{
device->SetRenderState(D3DRENDERSTATE_SRCBLEND, D3DBLEND_INVDESTCOLOR);
device->SetRenderState(D3DRENDERSTATE_DESTBLEND, D3DBLEND_ONE);
SETALPHABLEND(device, TRUE);
int nb = 256;
while (nb--)
{
if (this->tstone[nb].actif)
{
float a = (float)this->tstone[nb].currtime / (float)this->tstone[nb].time;
if (a > 1.f)
{
a = 1.f;
this->tstone[nb].actif = 0;
}
int col = RGBA_MAKE(255, 255, 255, (int)(255.f * (1.f - a)));
if (this->stone[this->tstone[nb].numstone])
DrawEERIEObjExEx(device, this->stone[this->tstone[nb].numstone], &this->tstone[nb].ang, &this->tstone[nb].pos, &this->tstone[nb].scale, col);
int j = ARX_PARTICLES_GetFree();
if ((j != -1) && (!ARXPausedTimer))
{
ParticleCount++;
particle[j].exist = 1;
particle[j].zdec = 0;
particle[j].ov = this->tstone[nb].pos;
particle[j].move.x = 0.f;
particle[j].move.y = 3.f * rnd();
particle[j].move.z = 0.f;
particle[j].siz = 3.f + 3.f * rnd();
particle[j].tolive = 1000;
particle[j].scale.x = 1.f;
particle[j].scale.y = 1.f;
particle[j].scale.z = 1.f;
particle[j].timcreation = -(long)(ARXTime + 1000);
particle[j].tc = NULL;
particle[j].special = FIRE_TO_SMOKE | FADE_IN_AND_OUT | ROTATING | MODULATE_ROTATION | DISSIPATING;
particle[j].fparam = 0.0000001f;
particle[j].r = 1.f;
particle[j].g = 1.f;
particle[j].b = 1.f;
}
//update mvt
if (!ARXPausedTimer)
{
a = (((float)this->currframetime) * 100.f) / (float)this->tstone[nb].time;
this->tstone[nb].pos.y += this->tstone[nb].yvel * a;
this->tstone[nb].ang.a += this->tstone[nb].angvel.a * a;
this->tstone[nb].ang.b += this->tstone[nb].angvel.b * a;
this->tstone[nb].ang.g += this->tstone[nb].angvel.g * a;
this->tstone[nb].yvel *= 1.f - (1.f / 100.f);
this->tstone[nb].currtime += this->currframetime;
}
}
}
SETALPHABLEND(device, FALSE);
}
示例10: Render
/*--------------------------------------------------------------------------*/
float CPortal::Render(LPDIRECT3DDEVICE7 device)
{
SETALPHABLEND(device, TRUE);
SETZWRITE(device, FALSE);
device->SetRenderState(D3DRENDERSTATE_SRCBLEND, D3DBLEND_ONE);
device->SetRenderState(D3DRENDERSTATE_DESTBLEND, D3DBLEND_ONE);
//calcul sphere
int nb = this->spherenbpt;
D3DTLVERTEX * v = this->sphered3d, d3dvs;
EERIE_3D * pt = this->spherevertex;
int col = RGBA_MAKE(0, (int)(200.f * this->spherealpha), (int)(255.f * this->spherealpha), 255);
while (nb)
{
d3dvs.sx = pt->x + this->pos.x; //pt du bas
d3dvs.sy = pt->y + this->pos.y;
d3dvs.sz = pt->z + this->pos.z;
EE_RTP(&d3dvs, v);
if (!ARXPausedTimer) v->color = col;
v++;
pt++;
nb--;
}
//update les couleurs aux impacts
nb = 256;
while (nb--)
{
if (this->tabeclair[nb].actif)
{
float a;
a = 1.f - ((float)this->tabeclair[nb].currduration / (float)this->tabeclair[nb].duration);
if (a < 0.f) a = 0.f;
if (this->tabeclair[nb].numpt >= 0)
{
int r = (int)((0.f + (255.f - 0.f) * a) * this->spherealpha * 3.f);
if (r > 255) r = 255;
int g = (int)((200.f + (255.f - 200.f) * a) * this->spherealpha * 3.f);
if (g > 255) g = 255;
int b = (int)(255.f * this->spherealpha * 3.f);
if (b > 255) b = 255;
if (!ARXPausedTimer) this->sphered3d[this->tabeclair[nb].numpt].color = RGBA_MAKE(r, g, b, 255);
}
}
}
//affichage de la sphere back
SETCULL(device, D3DCULL_CW);
device->SetTexture(0, NULL);
device->DrawIndexedPrimitive(D3DPT_TRIANGLELIST, D3DFVF_TLVERTEX, this->sphered3d, this->spherenbpt, (unsigned short *)this->sphereind, this->spherenbfaces * 3, 0);
//affichage eclair
this->DrawAllEclair(device);
//affichage des particules à l'interieur
if (rnd() > .25f)
{
int j = ARX_PARTICLES_GetFree();
if ((j != -1) && (!ARXPausedTimer))
{
ParticleCount++;
particle[j].exist = 1;
particle[j].zdec = 0;
float a = rnd() * 360.f;
float b = rnd() * 360.f;
float rr = this->r * (rnd() + .25f) * 0.05f;
particle[j].ov.x = this->pos.x;
particle[j].ov.y = this->pos.y;
particle[j].ov.z = this->pos.z;
particle[j].move.x = rr * EEsin(DEG2RAD(a)) * EEcos(DEG2RAD(b));
particle[j].move.y = rr * EEcos(DEG2RAD(a));
particle[j].move.z = rr * EEsin(DEG2RAD(a)) * EEsin(DEG2RAD(b));
particle[j].siz = 10.f;
particle[j].tolive = 1000 + (unsigned long)(float)(rnd() * 1000.f);
particle[j].scale.x = 1.f;
particle[j].scale.y = 1.f;
particle[j].scale.z = 1.f;
particle[j].timcreation = lARXTime;
particle[j].tc = tp;
particle[j].special = FADE_IN_AND_OUT | ROTATING | MODULATE_ROTATION | DISSIPATING;
//.........这里部分代码省略.........
示例11: ARXDRAW_DrawAllTransPolysPos
void ARXDRAW_DrawAllTransPolysPos( LPDIRECT3DDEVICE7 pd3dDevice, long MODIF )
{
int flg_NOCOUNT_USEVB = EERIE_NOCOUNT | (bSoftRender?EERIE_USEVB:0);
SetZBias( pd3dDevice, 1 );
SETALPHABLEND( pd3dDevice, TRUE );
long i, to = 0;
register EERIEPOLY * ep;
for ( i = 0 ; i < TRANSPOLYSPOS ; i++ )
{
ep = TransPol[i];
if ( ( !( Project.hide & HIDE_BACKGROUND ) ) )
{
if ( ep->type & POLY_DOUBLESIDED ) SETCULL( pd3dDevice, D3DCULL_NONE );
else SETCULL( pd3dDevice, D3DCULL_CW );
if ( ViewMode & VIEWMODE_FLAT ) SETTC( pd3dDevice, NULL );
else SETTC( pd3dDevice, ep->tex );
if ( ep->type & POLY_QUAD ) to = 4;
else to = 3;
float ttt = ep->transval;
if ( ttt >= 2.f ) //MULTIPLICATIVE
{
SETBLENDMODE( pd3dDevice, D3DBLEND_ONE, D3DBLEND_ONE );
ttt *= DIV2;
ttt += 0.5f;
ep->tv[3].color = ep->tv[2].color = ep->tv[1].color = ep->tv[0].color = _EERIERGB( ttt );
}
else if ( ttt >= 1.f ) //ADDITIVE
{
ttt -= 1.f;
SETBLENDMODE( pd3dDevice, D3DBLEND_ONE, D3DBLEND_ONE );
ep->tv[3].color = ep->tv[2].color = ep->tv[1].color = ep->tv[0].color = _EERIERGB( ttt );
}
else if ( ttt > 0.f ) //NORMAL TRANS
{
ttt = 1.f - ttt;
SETBLENDMODE( pd3dDevice, D3DBLEND_DESTCOLOR, D3DBLEND_SRCCOLOR );
ep->tv[3].color = ep->tv[2].color = ep->tv[1].color = ep->tv[0].color = _EERIERGBA(ttt);
}
else //SUBTRACTIVE
{
SETBLENDMODE( pd3dDevice, D3DBLEND_ZERO, D3DBLEND_INVSRCCOLOR );
ttt = 1.f - ttt;
ep->tv[3].color = ep->tv[2].color = ep->tv[1].color = ep->tv[0].color = _EERIERGB( ttt );
}
EERIEDRAWPRIM( pd3dDevice, D3DPT_TRIANGLESTRIP, D3DFVF_TLVERTEX | D3DFVF_DIFFUSE , ep->tv, to, 0, bSoftRender?EERIE_USEVB:0 );
if (ep->type & POLY_LAVA)
{
pd3dDevice->SetRenderState( D3DRENDERSTATE_SRCBLEND, D3DBLEND_DESTCOLOR );
pd3dDevice->SetRenderState( D3DRENDERSTATE_DESTBLEND, D3DBLEND_ONE );
SETALPHABLEND( pd3dDevice, TRUE );
D3DTLVERTEX verts[4];
SETTC( pd3dDevice, enviro );
ARX_CHECK(to > 0);
for ( long j = 0 ; j < to ; j++ )
{
verts[j].sx = ep->tv[j].sx;
verts[j].sy = ep->tv[j].sy;
verts[j].sz = ep->tv[j].sz;
verts[j].rhw = ep->tv[j].rhw;
verts[j].color = 0xFFFFFFFF;
verts[j].tu = ep->v[j].sx * DIV1000 + EEsin( ( ep->v[j].sx ) * DIV200 + (float) FrameTime * DIV2000 ) * DIV20;
verts[j].tv = ep->v[j].sz * DIV1000 + EEcos( (ep->v[j].sz) * DIV200 + (float) FrameTime * DIV2000 ) * DIV20;
}
EERIEDRAWPRIM(pd3dDevice, D3DPT_TRIANGLESTRIP, D3DFVF_TLVERTEX | D3DFVF_DIFFUSE, verts, to, 0, flg_NOCOUNT_USEVB );
for ( i = 0 ; i < to ; i++ )
{
verts[i].tu = ep->v[i].sx * DIV1000 + EEsin( ( ep->v[i].sx ) * DIV100 + (float)FrameTime * DIV2000 ) * DIV10;
verts[i].tv = ep->v[i].sz * DIV1000 + EEcos( ( ep->v[i].sz ) * DIV100 + (float)FrameTime * DIV2000 ) * DIV10;
}
EERIEDRAWPRIM(pd3dDevice, D3DPT_TRIANGLESTRIP, D3DFVF_TLVERTEX | D3DFVF_DIFFUSE, verts, to, 0, flg_NOCOUNT_USEVB );
for ( i = 0 ; i < to ; i++ )
{
verts[i].tu = ep->v[i].sx * DIV600 + EEsin ( ( ep->v[i].sx ) * DIV160 + (float)FrameTime * DIV2000 ) * DIV11;
verts[i].tv = ep->v[i].sz * DIV600 + EEcos ( ( ep->v[i].sz ) * DIV160 + (float)FrameTime * DIV2000 ) * DIV11;
verts[i].color = 0xFF666666;
}
pd3dDevice->SetRenderState( D3DRENDERSTATE_SRCBLEND, D3DBLEND_ZERO );
pd3dDevice->SetRenderState( D3DRENDERSTATE_DESTBLEND, D3DBLEND_INVSRCCOLOR );
EERIEDRAWPRIM(pd3dDevice, D3DPT_TRIANGLESTRIP, D3DFVF_TLVERTEX | D3DFVF_DIFFUSE, verts, to, 0, flg_NOCOUNT_USEVB );
}
}
//.........这里部分代码省略.........
示例12: Render
//-----------------------------------------------------------------------------
void CParticleSystem::Render(LPDIRECT3DDEVICE7 _lpD3DDevice, int _iSRCBLEND, int _iDESTBLEND)
{
SETCULL(_lpD3DDevice, D3DCULL_NONE);
SETZWRITE(_lpD3DDevice, false);
_lpD3DDevice->SetRenderState(D3DRENDERSTATE_SRCBLEND, iSrcBlend);
_lpD3DDevice->SetRenderState(D3DRENDERSTATE_DESTBLEND, iDstBlend);
SETALPHABLEND(_lpD3DDevice, true);
int inumtex = 0;
list<CParticle *>::iterator i;
for (i = listParticle.begin(); i != listParticle.end(); ++i)
{
CParticle * p = *i;
if (p->isAlive())
{
if (fParticleFlash > 0)
{
if (rnd() < fParticleFlash)
continue;
}
if (iNbTex > 0)
{
inumtex = p->iTexNum;
if (iTexTime == 0)
{
float fNbTex = (p->ulTime * p->fOneOnTTL) * (iNbTex);
ARX_CHECK_INT(fNbTex);
inumtex = ARX_CLEAN_WARN_CAST_INT(fNbTex);
if (inumtex >= iNbTex)
{
inumtex = iNbTex - 1;
}
}
else
{
if (p->iTexTime > iTexTime)
{
p->iTexTime -= iTexTime;
p->iTexNum++;
if (p->iTexNum > iNbTex - 1)
{
if (bTexLoop)
{
p->iTexNum = 0;
}
else
{
p->iTexNum = iNbTex - 1;
}
}
inumtex = p->iTexNum;
}
}
}
D3DTLVERTEX p3pos;
p3pos.sx = p->p3Pos.x;
p3pos.sy = p->p3Pos.y;
p3pos.sz = p->p3Pos.z;
if (bParticleFollow)
{
p3pos.sx += p3Pos.x;
p3pos.sy += p3Pos.y;
p3pos.sz += p3Pos.z;
}
float fRot = 0;
if (fParticleRotation != 0)
{
if (p->iRot == 1)
fRot = (fParticleRotation) * p->ulTime + p->fRotStart;
else
fRot = (-fParticleRotation) * p->ulTime + p->fRotStart;
if ((tex_tab[inumtex] && tex_tab[inumtex]->m_pddsSurface))
EERIEDrawRotatedSprite(_lpD3DDevice, &p3pos, p->fSize, tex_tab[inumtex], p->ulColor, 2, fRot);
}
else
{
if ((tex_tab[inumtex] && tex_tab[inumtex]->m_pddsSurface))
EERIEDrawSprite(_lpD3DDevice, &p3pos, p->fSize, tex_tab[inumtex], p->ulColor, 2);
}
}
}
}
示例13: Render
//-----------------------------------------------------------------------------
float CExplosion::Render(LPDIRECT3DDEVICE7 device)
{
if (this->key > 1) return 0;
SETALPHABLEND(device, TRUE);
SETZWRITE(device, FALSE);
device->SetRenderState(D3DRENDERSTATE_SRCBLEND, D3DBLEND_ONE);
device->SetRenderState(D3DRENDERSTATE_DESTBLEND, D3DBLEND_ONE);
//calcul du disque
D3DTLVERTEX d3dvs, *d3dv;
EERIE_3D * vertex;
int nb, col, col2;
float rin;
switch (key)
{
case 0:
rin = 255.f * scale;
vertex = disquevertex;
d3dv = disqued3d;
nb = disquenbvertex >> 1;
while (nb)
{
d3dvs.sx = pos.x + (vertex + 1)->x + ((vertex->x - (vertex + 1)->x) * scale);
d3dvs.sy = pos.y;
d3dvs.sz = pos.z + (vertex + 1)->z + ((vertex->z - (vertex + 1)->z) * scale);
EE_RTP(&d3dvs, d3dv);
d3dv->color = RGBA_MAKE(255, 200, 0, 255);
vertex++;
d3dv++;
d3dvs.sx = pos.x + vertex->x;
d3dvs.sy = pos.y;
d3dvs.sz = pos.z + vertex->z;
EE_RTP(&d3dvs, d3dv);
if (!ARXPausedTimer) d3dv->color = RGBA_MAKE((int)(rin * rnd()), 0, 0, 255);
vertex++;
d3dv++;
nb--;
}
if (rnd() > .25f)
{
int j = ARX_PARTICLES_GetFree();
if ((j != -1) && (!ARXPausedTimer))
{
ParticleCount++;
particle[j].exist = 1;
particle[j].zdec = 0;
float a = DEG2RAD(360.f * scale);
float b = rin;
particle[j].ov.x = pos.x + b * EEcos(a);
particle[j].ov.y = pos.y;
particle[j].ov.z = pos.z + b * EEsin(a);
particle[j].move.x = 0.f;
particle[j].move.y = rnd();
particle[j].move.z = 0.f;
particle[j].siz = 10.f + 10.f * rnd();
particle[j].tolive = 500 + (unsigned long)(float)(rnd() * 500.f);
particle[j].scale.x = 1.f;
particle[j].scale.y = 1.f;
particle[j].scale.z = 1.f;
particle[j].timcreation = lARXTime;
particle[j].tc = tp;
particle[j].special = FADE_IN_AND_OUT | ROTATING | MODULATE_ROTATION | DISSIPATING;
particle[j].fparam = 0.0000001f;
particle[j].r = 1.f;
particle[j].g = 1.f;
particle[j].b = 1.f;
}
j = ARX_PARTICLES_GetFree();
if ((j != -1) && (!ARXPausedTimer))
{
ParticleCount++;
particle[j].exist = 1;
particle[j].zdec = 0;
float a = DEG2RAD(-360.f * scale);
float b = this->rin;
particle[j].ov.x = pos.x + b * EEcos(a);
particle[j].ov.y = pos.y;
particle[j].ov.z = pos.z + b * EEsin(a);
particle[j].move.x = 0.f;
particle[j].move.y = rnd();
particle[j].move.z = 0.f;
particle[j].siz = 10.f + 10.f * rnd();
particle[j].tolive = 500 + (unsigned long)(float)(rnd() * 500.f);
particle[j].scale.x = 1.f;
//.........这里部分代码省略.........
示例14: SetBlendRenderState
/******************************************************************************************************************
함수명 : SetBlendRenderState()
작성자 :
작성일 :
목적 : 렌더링스테이트를 셋팅한다.
입력 : LPDIRECT3DDEVICE7 pd3dDevice
BYTE bBlendFlag
D3DMATERIAL7 mtrlGetMtrl
출력 : void
[일자][수정자] : 수정내용
*******************************************************************************************************************/
void SetBlendRenderState(LPDIRECT3DDEVICE7 pd3dDevice, BYTE bBlendFlag, D3DMATERIAL7 mtrlGetMtrl)
{
pd3dDevice->SetRenderState(D3DRENDERSTATE_ALPHABLENDENABLE, TRUE);
pd3dDevice->SetRenderState(D3DRENDERSTATE_COLORKEYENABLE, TRUE);
switch ( bBlendFlag )
{
case 0:
if ( mtrlGetMtrl.diffuse.a < 1.0f || mtrlGetMtrl.emissive.a < 1.0f )
{
pd3dDevice->SetTextureStageState(0, D3DTSS_ALPHAARG1, D3DTA_TEXTURE);
pd3dDevice->SetTextureStageState(0, D3DTSS_ALPHAOP, D3DTOP_MODULATE);
pd3dDevice->SetTextureStageState(0, D3DTSS_ALPHAARG2, D3DTA_DIFFUSE);
pd3dDevice->SetRenderState(D3DRENDERSTATE_SRCBLEND, D3DBLEND_ONE);
pd3dDevice->SetRenderState(D3DRENDERSTATE_DESTBLEND, D3DBLEND_INVSRCALPHA);
}
else
{
pd3dDevice->SetRenderState(D3DRENDERSTATE_DESTBLEND, D3DBLEND_INVSRCALPHA);
}
break;
case 1:
pd3dDevice->SetRenderState(D3DRENDERSTATE_DESTBLEND, D3DBLEND_ONE);
break;
case 2:
pd3dDevice->SetRenderState(D3DRENDERSTATE_DESTBLEND, D3DBLEND_INVSRCCOLOR);
break;
case 3:
if( mtrlGetMtrl.diffuse.a < 1.0f || mtrlGetMtrl.emissive.a < 1.0f )
{
pd3dDevice->SetTextureStageState(0, D3DTSS_COLORARG1, D3DTA_TEXTURE | D3DTA_COMPLEMENT);
pd3dDevice->SetTextureStageState(0, D3DTSS_COLOROP, D3DTOP_MODULATE);
pd3dDevice->SetTextureStageState(0, D3DTSS_COLORARG2, D3DTA_DIFFUSE);
pd3dDevice->SetTextureStageState(0, D3DTSS_ALPHAARG1, D3DTA_TEXTURE);
pd3dDevice->SetTextureStageState(0, D3DTSS_ALPHAOP, D3DTOP_MODULATE);
pd3dDevice->SetTextureStageState(0, D3DTSS_ALPHAARG2, D3DTA_DIFFUSE);
pd3dDevice->SetRenderState(D3DRENDERSTATE_SRCBLEND, D3DBLEND_ONE);
pd3dDevice->SetRenderState(D3DRENDERSTATE_DESTBLEND, D3DBLEND_INVSRCALPHA);
}
else
{
pd3dDevice->SetTextureStageState(0, D3DTSS_COLORARG1, D3DTA_TEXTURE | D3DTA_COMPLEMENT);
pd3dDevice->SetTextureStageState(0, D3DTSS_COLOROP, D3DTOP_MODULATE);
pd3dDevice->SetTextureStageState(0, D3DTSS_COLORARG2, D3DTA_DIFFUSE);
pd3dDevice->SetTextureStageState(0, D3DTSS_ALPHAARG1, D3DTA_TEXTURE);
pd3dDevice->SetTextureStageState(0, D3DTSS_ALPHAOP, D3DTOP_MODULATE);
pd3dDevice->SetTextureStageState(0, D3DTSS_ALPHAARG2, D3DTA_DIFFUSE);
pd3dDevice->SetRenderState(D3DRENDERSTATE_SRCBLEND, D3DBLEND_INVSRCALPHA);
pd3dDevice->SetRenderState(D3DRENDERSTATE_DESTBLEND, D3DBLEND_ZERO);
}
break;
case 4:
pd3dDevice->SetTextureStageState(0, D3DTSS_COLORARG1, D3DTA_TEXTURE | D3DTA_COMPLEMENT);
pd3dDevice->SetTextureStageState(0, D3DTSS_ALPHAARG1, D3DTA_TEXTURE|D3DTA_COMPLEMENT);
pd3dDevice->SetTextureStageState(0, D3DTSS_ALPHAOP, D3DTOP_SELECTARG1);
pd3dDevice->SetRenderState(D3DRENDERSTATE_DESTBLEND, D3DBLEND_INVDESTCOLOR);
break;
case 5:
pd3dDevice->SetTextureStageState(0, D3DTSS_ALPHAARG1, D3DTA_TEXTURE|D3DTA_COMPLEMENT);
pd3dDevice->SetTextureStageState(0, D3DTSS_ALPHAOP, D3DTOP_SELECTARG1);
pd3dDevice->SetTextureStageState(0, D3DTSS_COLORARG1, D3DTA_TEXTURE | D3DTA_COMPLEMENT);
pd3dDevice->SetRenderState(D3DRENDERSTATE_DESTBLEND, D3DBLEND_INVDESTCOLOR);
break;
}
}
示例15: RenderShadow
void RenderShadow(LPDIRECT3DDEVICE7 lpDevice,D3DVERTEX* vertices,int numvertices,WORD* indices,DWORD numindices)
{
// Turn depth buffer off, and stencil buffer on
lpDevice->SetRenderState( D3DRENDERSTATE_ZWRITEENABLE, FALSE );
lpDevice->SetRenderState( D3DRENDERSTATE_STENCILENABLE, TRUE );
// Set up stencil compare fuction, reference value, and masks
// Stencil test passes if ((ref & mask) cmpfn (stencil & mask)) is true
lpDevice->SetRenderState( D3DRENDERSTATE_STENCILFUNC, D3DCMP_ALWAYS );
lpDevice->SetRenderState( D3DRENDERSTATE_STENCILREF, 0x1 );
lpDevice->SetRenderState( D3DRENDERSTATE_STENCILMASK, 0xffffffff );
lpDevice->SetRenderState( D3DRENDERSTATE_STENCILWRITEMASK,0xffffffff );
// If ztest passes, write 1 into stencil buffer
lpDevice->SetRenderState( D3DRENDERSTATE_STENCILZFAIL, D3DSTENCILOP_KEEP );
lpDevice->SetRenderState( D3DRENDERSTATE_STENCILFAIL, D3DSTENCILOP_KEEP );
lpDevice->SetRenderState( D3DRENDERSTATE_STENCILPASS, D3DSTENCILOP_REPLACE );
// Make sure that no pixels get drawn to the frame buffer
lpDevice->SetRenderState( D3DRENDERSTATE_ALPHABLENDENABLE, TRUE );
lpDevice->SetRenderState( D3DRENDERSTATE_SRCBLEND, D3DBLEND_ZERO );
lpDevice->SetRenderState( D3DRENDERSTATE_DESTBLEND, D3DBLEND_ONE );
lpDevice->SetTexture(0,NULL);
// Draw front-side of shadow volume in stencil/z only
if (indices==NULL)
{
lpDevice->DrawPrimitive( D3DPT_TRIANGLELIST, D3DFVF_VERTEX,
vertices, numvertices,
NULL );
}
else
lpDevice->DrawIndexedPrimitive( D3DPT_TRIANGLELIST, D3DFVF_VERTEX,
vertices, numvertices,
indices, numindices, NULL );
// Now reverse cull order so back sides of shadow volume are written,
// writing 0's into stencil. Result will be any pixel which still has a bit
// set in the stencil buffer, is inside the shadow.
lpDevice->SetRenderState( D3DRENDERSTATE_STENCILREF, 0x0 );
// Draw back-side of shadow volume in stencil/z only
lpDevice->SetRenderState( D3DRENDERSTATE_CULLMODE, D3DCULL_CW );
if (indices==NULL)
{
lpDevice->DrawPrimitive( D3DPT_TRIANGLELIST, D3DFVF_VERTEX,
vertices, numvertices,
NULL );
}
else
lpDevice->DrawIndexedPrimitive( D3DPT_TRIANGLELIST, D3DFVF_VERTEX,
vertices, numvertices,
indices, numindices, NULL );
// Restore render states
lpDevice->SetRenderState( D3DRENDERSTATE_CULLMODE, D3DCULL_CCW );
lpDevice->SetRenderState( D3DRENDERSTATE_ZWRITEENABLE, TRUE );
lpDevice->SetRenderState( D3DRENDERSTATE_STENCILENABLE, FALSE );
lpDevice->SetRenderState( D3DRENDERSTATE_ALPHABLENDENABLE, FALSE );
}