本文整理汇总了C++中LPDIRECT3DDEVICE7::SetTexture方法的典型用法代码示例。如果您正苦于以下问题:C++ LPDIRECT3DDEVICE7::SetTexture方法的具体用法?C++ LPDIRECT3DDEVICE7::SetTexture怎么用?C++ LPDIRECT3DDEVICE7::SetTexture使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类LPDIRECT3DDEVICE7
的用法示例。
在下文中一共展示了LPDIRECT3DDEVICE7::SetTexture方法的13个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: DrawSmooth
void CSprite::DrawSmooth(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;
}
const D3DVECTOR n=D3DVECTOR(0,0,0);
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_ZWRITEENABLE,FALSE);
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_SRCCOLOR);
lpDevice->SetRenderState(D3DRENDERSTATE_DESTBLEND,D3DBLEND_INVSRCCOLOR);
lpDevice->SetRenderState(D3DRENDERSTATE_ALPHATESTENABLE,TRUE);
lpDevice->SetRenderState(D3DRENDERSTATE_ALPHAREF,0x08);
}
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);
lpDevice->SetRenderState(D3DRENDERSTATE_ZWRITEENABLE,TRUE);
}
}
示例2: 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 );
}
示例3: 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);
}
示例4: 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);
}
示例5: Draw
void CGolfer::Draw(LPDIRECT3DDEVICE7 lpDevice)
{
if ((parent==NULL)&&(!box->IsVisible()))return;
D3DMATRIX m=BerechneSchlag();
lpDevice->SetTexture(0,NULL);
lpDevice->SetTransform(D3DTRANSFORMSTATE_WORLD,&m);
mesh->Render(lpDevice,FALSE);
}
示例6: DrawBillBoard
HRESULT CImageHandler::DrawBillBoard(LPDIRECT3DDEVICE7 lpDevice, D3DVECTOR vTrans, D3DVECTOR vScale, /*D3DVECTOR vRot, */D3DMATERIAL7 mtrl, /*FLOAT fRotRad, */LPDIRECTDRAWSURFACE7 lpddsTextr)
{
if ( lpDevice )
{
if( SUCCEEDED(lpDevice->BeginScene()) )
{
D3DMATRIX matTrans;
D3DMATRIX matScale;
D3DMATRIX matRot;
D3DMATRIX matWorld;
D3DMATRIX matTempWorld;
D3DMATRIX matWorldOriginal;
lpDevice->GetTransform(D3DTRANSFORMSTATE_WORLD, &matWorldOriginal);
vTrans.x = vTrans.x+vScale.x/2-400;
vTrans.y = -vTrans.y-vScale.y/2+300;
D3DUtil_SetTranslateMatrix(matTrans, vTrans);
D3DUtil_SetScaleMatrix(matScale, vScale.x, vScale.y, vScale.z);
// D3DUtil_SetRotationMatrix(matRot, vRot, fRotRad);
D3DMath_MatrixMultiply(/*matTempWorld*/matWorld, matScale, matTrans);
// D3DMath_MatrixMultiply(matWorld, matRot, matTempWorld);
lpDevice->SetTransform(D3DTRANSFORMSTATE_WORLD, &matWorld);
SetBlendRenderState(lpDevice, _BLEND_NORMAL, mtrl);
lpDevice->SetMaterial(&mtrl);
lpDevice->SetTexture(0, lpddsTextr);
lpDevice->DrawPrimitive(D3DPT_TRIANGLESTRIP, D3DFVF_VERTEX, m_avBillBoard, 4, NULL);
// 원상복귀.
ZeroMemory(&mtrl, sizeof(mtrl));
mtrl.diffuse.r = mtrl.diffuse.g = mtrl.diffuse.b = 0.1f;
mtrl.ambient.r = mtrl.ambient.g = mtrl.ambient.b = 1.0f;
lpDevice->SetMaterial(&mtrl);
ResetBlendenderState(lpDevice);
lpDevice->SetTransform(D3DTRANSFORMSTATE_WORLD, &matWorldOriginal);
}
lpDevice->EndScene();
return S_OK;
}
return E_FAIL;
}
示例7: Draw
void CDrescher::Draw(LPDIRECT3DDEVICE7 lpDevice)
{
if (!box2->IsVisible())return;
lpDevice->SetTexture(0,NULL);
D3DMATRIX matrix,m;
D3DUtil_SetTranslateMatrix(matrix,pos.x,pos.y+hoehe,pos.z);
{ // Mähdrescher gemäß Steigung kippen
D3DUtil_SetRotateYMatrix(m,beta);
D3DMath_MatrixMultiply(matrix,m,matrix);
D3DUtil_SetRotateXMatrix(m,alpha);
D3DMath_MatrixMultiply(matrix,m,matrix);
D3DUtil_SetRotateYMatrix(m,-beta);
D3DMath_MatrixMultiply(matrix,m,matrix);
}
D3DUtil_SetRotateYMatrix(m,ang.y);
D3DMath_MatrixMultiply(matrix,m,matrix);
if (schaukelphase>0.0f)
{ // schaukeln
const float mittelpunkt=2.0f;
D3DUtil_SetTranslateMatrix(m,0,0,-mittelpunkt);
D3DMath_MatrixMultiply(matrix,m,matrix);
D3DUtil_SetRotateXMatrix(m,schaukelwinkel());
D3DMath_MatrixMultiply(matrix,m,matrix);
D3DUtil_SetTranslateMatrix(m,0,0,mittelpunkt);
D3DMath_MatrixMultiply(matrix,m,matrix);
}
lpDevice->SetTransform(D3DTRANSFORMSTATE_WORLD,&matrix);
mesh1->Render(lpDevice,FALSE);
// Rolle
D3DUtil_SetRotateXMatrix(m,rolle);
D3DMath_MatrixMultiply(matrix,m,matrix);
lpDevice->SetTransform(D3DTRANSFORMSTATE_WORLD,&matrix);
mesh2->Render(lpDevice,FALSE);
}
示例8: Draw
void CEi::Draw(LPDIRECT3DDEVICE7 lpDevice)
{
if (!CBoundingTube::IsSphereVisible(pos,EGG_SIZE))return;
D3DMATRIX m,m2;
D3DUtil_SetTranslateMatrix(m,pos);
D3DUtil_SetRotateYMatrix(m2,ang.y);
D3DMath_MatrixMultiply(m,m2,m);
D3DUtil_SetRotateXMatrix(m2,-ang.x+g_PI*0.5f);
D3DMath_MatrixMultiply(m,m2,m);
lpDevice->SetTexture(0,NULL);
lpDevice->SetTransform(D3DTRANSFORMSTATE_WORLD,&m);
lpMesh->Render(lpDevice,FALSE);
}
示例9: wSetTexture
/// <summary>
/// <c>wSetTexture</c>
/// </summary>
/// <remarks>
/// </remarks>
/// <param name="d3dDevice7"></param>
/// <param name="dwStage"></param>
/// <param name="lpTexture"></param>
/// <returns></returns>
HRESULT __stdcall wSetTexture(
LPDIRECT3DDEVICE7 d3dDevice7, ULONG dwStage, LPDIRECTDRAWSURFACE7 lpTexture)
{
PSTR pszErrorMessage;
HRESULT hResult;
InternalFunctionSpew("GameOS_Direct3D", "SetTexture(%d,0x%x)", dwStage, lpTexture);
hResult = d3dDevice7->SetTexture(dwStage, lpTexture);
if (FAILED(hResult))
{
if ( hResult != DDERR_SURFACELOST)
{
pszErrorMessage = ErrorNumberToMessage(hResult);
if ( InternalFunctionPause("FAILED (0x%x - %s) - SetTexture(%d,0x%x)",
hResult, pszErrorMessage, dwStage, lpTexture) )
ENTER_DEBUGGER;
}
}
return hResult;
}
示例10: Render
//.........这里部分代码省略.........
if ((j != -1) && (!ARXPausedTimer))
{
ParticleCount++;
particle[j].exist = 1;
particle[j].zdec = 0;
float a = rnd() * 360.f;
float b = rin * rnd();
particle[j].ov.x = pos.x + b * EEcos(a);
particle[j].ov.y = pos.y + 70.f;
particle[j].ov.z = pos.z + b * EEsin(a);
particle[j].move.x = 0.f;
particle[j].move.y = -(5.f + 10.f * rnd());
particle[j].move.z = 0.f;
particle[j].siz = 10.f + 20.f * rnd();
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 = tp2;
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;
}
}
break;
case 1:
D3DTLVERTEX d3dvs2;
rin = 1.f + (puissance * scale);
vertex = disquevertex;
d3dv = disqued3d;
nb = disquenbvertex >> 1;
float a = 1.f - scale;
col = RGBA_MAKE((int)(255.f * a), (int)(200.f * a), 0, 255);
col2 = RGBA_MAKE((int)(255.f * a * rnd()), 0, 0, 0);
while (nb--)
{
d3dvs.sx = pos.x + vertex->x * rin;
d3dvs.sy = pos.y;
d3dvs.sz = pos.z + vertex->z * rin;
vertex++;
d3dvs2.sx = pos.x + vertex->x * rin;
d3dvs2.sy = pos.y;
d3dvs2.sz = pos.z + vertex->z * rin;
vertex++;
if (tactif[nb] >= 0)
{
EERIE_3D pos, dir;
pos.x = d3dvs2.sx;
pos.y = d3dvs2.sy;
pos.z = d3dvs2.sz;
dir.x = d3dvs.sx;
dir.y = d3dvs.sy;
dir.z = d3dvs.sz;
DynLight[tactif[nb]].pos.x = dir.x;
DynLight[tactif[nb]].pos.y = dir.y;
DynLight[tactif[nb]].pos.z = dir.z;
DynLight[tactif[nb]].intensity = .7f + 2.f * rnd();
Collision(nb, &pos, &dir);
ExplosionAddParticule(nb, &d3dvs, tp);
}
EE_RTP(&d3dvs, d3dv);
if (!ARXPausedTimer) d3dv->color = col;
d3dv++;
EE_RTP(&d3dvs2, d3dv);
if (!ARXPausedTimer) d3dv->color = col2;
d3dv++;
}
break;
}
//tracé du disque
SETCULL(device, D3DCULL_NONE);
device->SetTexture(0, NULL);
device->DrawIndexedPrimitive(D3DPT_TRIANGLESTRIP, D3DFVF_TLVERTEX, disqued3d, disquenbvertex, (unsigned short *)disqueind, disquenbvertex + 2, 0);
device->SetRenderState(D3DRENDERSTATE_SRCBLEND, D3DBLEND_ONE);
device->SetRenderState(D3DRENDERSTATE_DESTBLEND, D3DBLEND_ZERO);
SETALPHABLEND(device, FALSE);
SETZWRITE(device, TRUE);
return 0;
}
示例11: Render
//.........这里部分代码省略.........
ParticleCount++;
particle[j].exist = 1;
particle[j].zdec = 0;
float a = DEG2RAD(360.f * rnd());
particle[j].ov.x = this->pos.x + this->rbase * EEcos(a);
particle[j].ov.y = this->pos.y;
particle[j].ov.z = this->pos.z + this->rbase * EEsin(a);
float t = EEDistance3D(&particle[j].ov, &this->pos);
particle[j].move.x = (5.f + 5.f * rnd()) * ((particle[j].ov.x - this->pos.x) / t);
particle[j].move.y = 3.f * rnd();
particle[j].move.z = (5.f + 5.f * rnd()) * ((particle[j].ov.z - this->pos.z) / t);
particle[j].siz = 30.f + 30.f * rnd();
particle[j].tolive = 3000;
particle[j].scale.x = 1.f;
particle[j].scale.y = 1.f;
particle[j].scale.z = 1.f;
particle[j].timcreation = -(long)(ARXTime + 3000);
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;
}
}
break;
}
//tracé du cone back
device->SetRenderState(D3DRENDERSTATE_SRCBLEND, D3DBLEND_ONE);
device->SetRenderState(D3DRENDERSTATE_DESTBLEND, D3DBLEND_ONE);
SETALPHABLEND(device, TRUE);
SETTEXTUREWRAPMODE(device, D3DTADDRESS_MIRROR);
if (this->tsouffle) device->SetTexture(0, this->tsouffle->m_pddsSurface);
else device->SetTexture(0, NULL);
SETCULL(device, D3DCULL_CW);
int i = cone[1].conenbfaces - 2;
int j = 0;
while (i--)
{
ARX_DrawPrimitive_SoftClippZ(&cone[1].coned3d[j],
&cone[1].coned3d[j+1],
&cone[1].coned3d[j+2]);
j++;
}
i = cone[0].conenbfaces - 2;
j = 0;
while (i--)
{
ARX_DrawPrimitive_SoftClippZ(&cone[0].coned3d[j],
&cone[0].coned3d[j+1],
&cone[0].coned3d[j+2]);
j++;
}
//tracé du cone front
SETCULL(device, D3DCULL_CCW);
i = cone[1].conenbfaces - 2;
j = 0;
while (i--)
{
ARX_DrawPrimitive_SoftClippZ(&cone[1].coned3d[j],
&cone[1].coned3d[j+1],
&cone[1].coned3d[j+2]);
j++;
}
i = cone[0].conenbfaces - 2;
j = 0;
while (i--)
{
ARX_DrawPrimitive_SoftClippZ(&cone[0].coned3d[j],
&cone[0].coned3d[j+1],
&cone[0].coned3d[j+2]);
j++;
}
//tracé des pierres
device->SetRenderState(D3DRENDERSTATE_SRCBLEND, D3DBLEND_SRCALPHA);
device->SetRenderState(D3DRENDERSTATE_DESTBLEND, D3DBLEND_INVSRCALPHA);
this->DrawStone(device);
device->SetRenderState(D3DRENDERSTATE_SRCBLEND, D3DBLEND_ONE);
device->SetRenderState(D3DRENDERSTATE_DESTBLEND, D3DBLEND_ZERO);
SETALPHABLEND(device, FALSE);
SETZWRITE(device, TRUE);
return 0;
}
示例12: 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;
//.........这里部分代码省略.........
示例13: Prog_Init
//////////////////////////////////////////////////////////////////////////////
//INITIALIZATION
//////////////////////////////////////////////////////////////////////////////
bool Prog_Init()
{
lpdd=LPDD_Create(hWndMain,DDSCL_EXCLUSIVE | DDSCL_FULLSCREEN | DDSCL_ALLOWREBOOT);
//set the display mode
lpdd->SetDisplayMode(SCREENWIDTH,SCREENHEIGHT,SCREENBPP,0,0);
//create primary surface
DDSURFACEDESC2 ddsd;
memset(&ddsd,0,sizeof(DDSURFACEDESC2));
ddsd.dwSize=sizeof(DDSURFACEDESC2);
ddsd.dwFlags=DDSD_CAPS | DDSD_BACKBUFFERCOUNT;
ddsd.dwBackBufferCount=1;
ddsd.ddsCaps.dwCaps=DDSCAPS_PRIMARYSURFACE | DDSCAPS_FLIP | DDSCAPS_COMPLEX | DDSCAPS_3DDEVICE;
lpdd->CreateSurface(&ddsd,&lpddsPrime,NULL);
//create back buffer
DDSCAPS2 ddscaps;
memset(&ddscaps,0,sizeof(DDSCAPS2));
ddscaps.dwCaps=DDSCAPS_BACKBUFFER | DDSCAPS_3DDEVICE;
lpddsPrime->GetAttachedSurface(&ddscaps,&lpddsBack);
//create the texture surface
memset(&ddsd,0,sizeof(DDSURFACEDESC2));
ddsd.dwSize=sizeof(DDSURFACEDESC2);
ddsd.dwFlags=DDSD_CAPS | DDSD_WIDTH | DDSD_HEIGHT;
ddsd.dwWidth=64;
ddsd.dwHeight=64;
ddsd.ddsCaps.dwCaps=DDSCAPS_TEXTURE;
lpdd->CreateSurface(&ddsd,&lpddsTex,NULL);
//used ddfuncs to load a bitmap onto the texture
LPDDS_ReloadFromFile(lpddsTex,"texture.bmp");
//get the idirect3d pointer
lpdd->QueryInterface(IID_IDirect3D7,(void**)&lpd3d);//ICKY COM STUFF!
//create the idirect3ddevice(hack method)
if(FAILED(lpd3d->CreateDevice(IID_IDirect3DTnLHalDevice,lpddsBack,&lpd3ddev)))//try tnl
if(FAILED(lpd3d->CreateDevice(IID_IDirect3DHALDevice,lpddsBack,&lpd3ddev)))//no tnl, try hal
if(FAILED(lpd3d->CreateDevice(IID_IDirect3DMMXDevice,lpddsBack,&lpd3ddev)))//no hal, try mmp
if(FAILED(lpd3d->CreateDevice(IID_IDirect3DRGBDevice,lpddsBack,&lpd3ddev)))//no mmx, resort to rgb
return(false);//problem, return false
//set up viewport
D3DVIEWPORT7 vp;
vp.dwX=0;
vp.dwY=0;
vp.dwWidth=SCREENWIDTH;
vp.dwHeight=SCREENHEIGHT;
vp.dvMinZ=0.0;
vp.dvMaxZ=1.0;
//set viewport for device
lpd3ddev->SetViewport(&vp);
//initialize the vertices(partially, anyway)
vert[0].color=D3DRGB(0.25,0.25,0.25);//set the color for this vertex
vert[0].specular=0;//zero for specular
vert[0].rhw=1.0;//rhw is 1.0
vert[0].tu=0.0;//0.0 for both texture coordinates
vert[0].tv=0.0;
vert[0].sz=0.5;//static z value
vert[1].color=D3DRGB(0.5,0.5,0.5);//set the color for this vertex
vert[1].specular=0;//zero for specular
vert[1].rhw=1.0;//rhw is 1.0
vert[1].tu=1.0;//0.0 for both texture coordinates
vert[1].tv=0.0;
vert[1].sz=0.5;//static z value
vert[2].color=D3DRGB(0.5,0.5,0.5);//set the color for this vertex
vert[2].specular=0;//zero for specular
vert[2].rhw=1.0;//rhw is 1.0
vert[2].tu=0.0;//0.0 for both texture coordinates
vert[2].tv=1.0;
vert[2].sz=0.5;//static z value
vert[3].color=D3DRGB(1.0,1.0,1.0);//set the color for this vertex
vert[3].specular=0;//zero for specular
vert[3].rhw=1.0;//rhw is 1.0
vert[3].tu=1.0;//0.0 for both texture coordinates
vert[3].tv=1.0;
vert[3].sz=0.5;//static z value
//set the texture
lpd3ddev->SetTexture(0,lpddsTex);
return(true);//return success
}