本文整理汇总了C++中LPDIRECT3DDEVICE8::GetRenderState方法的典型用法代码示例。如果您正苦于以下问题:C++ LPDIRECT3DDEVICE8::GetRenderState方法的具体用法?C++ LPDIRECT3DDEVICE8::GetRenderState怎么用?C++ LPDIRECT3DDEVICE8::GetRenderState使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类LPDIRECT3DDEVICE8
的用法示例。
在下文中一共展示了LPDIRECT3DDEVICE8::GetRenderState方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1:
bool RageDisplay_D3D::IsZWriteEnabled() const
{
DWORD b;
g_pd3dDevice->GetRenderState( D3DRS_ZWRITEENABLE, &b );
return b!=0;
}
示例2: render
void render()
{
static RECT rc = {0, 0, 320, 100}; // rectangular region.. used for text drawing
static DWORD frameCount = 0;
static DWORD startTime = clock();
char str[16];
DWORD val;
doMath(); // do the math.. :-P
frameCount++; // increment frame count
// Clear the back buffer to a black... values r g b are 0-256
lpD3DDevice8->Clear(0, NULL, D3DCLEAR_TARGET | D3DCLEAR_ZBUFFER, D3DCOLOR_XRGB(256, 256, 256), 1.0f, 0);
lpD3DDevice8->GetRenderState(D3DRS_LIGHTING, &val);
if (val)
{
D3DLIGHT8 light; // structure for light data
ZeroMemory( &light, sizeof(D3DLIGHT8) ); // zero the mem
light.Type = D3DLIGHT_POINT; // set type, either SPOT, DIRECTIONAL, or POINT
// light being put onto objects..
light.Diffuse.r = 1.0f;
light.Diffuse.g = 1.0f;
light.Diffuse.b = 1.0f;
// ambient light of the light source.. only on when light is on
light.Ambient.r = 0.25f;
light.Ambient.g = 0.25f;
light.Ambient.b = 0.25f;
// attenuation = Atten0 + Atten1 * d + Atten2 * d * d;
// where d is distance
// attenuation is decreasing brightness as
// a vertex is further away from the light source
light.Attenuation0 = .5f;
light.Attenuation1 = 0.10f;
light.Attenuation2 = 0.01f;
// spot lights and directional lights also have a direction
// but a POINT light shines in all directions.. kinda like a light bulb
light.Position = D3DXVECTOR3(0, 0, -2);
light.Range = 15; // after this range the light doesn't affect vertices
lpD3DDevice8->SetLight( 0, &light ); // set the light as index 0
lpD3DDevice8->LightEnable( 0, true ); // enable light at index 0
// ambient light.. for everything.. not attached to
// this light, just lighting in general
lpD3DDevice8->SetRenderState( D3DRS_AMBIENT, 0x00202020 );
}
// render the cubes
myRect1->render(clock());
myRect2->render(clock());
myRect3->render(clock());
myRect4->render(clock());
myRect5->render(clock());
// this function writes a formatted string to a character string
// in this case.. it will write "Avg fps" followed by the
// frames per second.. with 2 decimal places
sprintf(str, "Avg fps %.2f", (float) frameCount / ((clock() - startTime) / 1000.0f));
// draw the text string..
lpD3DXFont->Begin();
lpD3DXFont->DrawText(str, -1, &rc, DT_LEFT, 0xFFFFFFFF);
lpD3DXFont->End();
// present the back buffer.. or "flip" the page
lpD3DDevice8->Present( NULL, NULL, NULL, NULL ); // these options are for using rectangular
// regions for rendering/drawing...
// 3rd is which target window.. NULL makes it use the currently set one (default)
// last one is NEVER used.. that happens with DirectX often
}