本文整理汇总了C++中LPDIRECT3DDEVICE9::LightEnable方法的典型用法代码示例。如果您正苦于以下问题:C++ LPDIRECT3DDEVICE9::LightEnable方法的具体用法?C++ LPDIRECT3DDEVICE9::LightEnable怎么用?C++ LPDIRECT3DDEVICE9::LightEnable使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类LPDIRECT3DDEVICE9
的用法示例。
在下文中一共展示了LPDIRECT3DDEVICE9::LightEnable方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: InitLight
void InitLight()
{
D3DMATERIAL9 material; // create the material struct
D3DLIGHT9 light; // create the light struct
ZeroMemory(&light, sizeof(light)); // clear out the light struct for use
light.Type = D3DLIGHT_DIRECTIONAL; // make the light type 'directional light'
light.Diffuse = D3DXCOLOR(0.7f, 0.7f, 0.7f, 1.0f); // set the light's color
light.Position = D3DXVECTOR3(0.0f, 1.0f, 0.0f);
light.Direction = D3DXVECTOR3(0.5f, -1.0f, -1.0f);
d3ddev->SetLight(0, &light); // send the light struct properties to light #0
d3ddev->LightEnable(0, TRUE); // turn on light #0
D3DLIGHT9 pointLight; // create the light struct
ZeroMemory(&pointLight, sizeof(pointLight)); // clear out the light struct for use
pointLight.Type = D3DLIGHT_POINT; // make the light type 'point light'
pointLight.Diffuse = D3DXCOLOR(1.0f, 1.0f, 1.0f, 1.0f); // set the light's color
pointLight.Position = D3DXVECTOR3(0.0f, 7.0f, 5.0f);
//pointLight.Direction = D3DXVECTOR3(0.5f, -1.0f, -1.0f);
pointLight.Range = 100.0f;
pointLight.Attenuation0 = 0.0f; // no constant inverse attenuation
pointLight.Attenuation1 = 0.125f; // only .125 inverse attenuation
pointLight.Attenuation2 = 0.0f; // no square inverse attenuation
d3ddev->SetLight(1, &pointLight); // send the light struct properties to light #0
d3ddev->LightEnable(1, TRUE); // turn on light #1
ZeroMemory(&material, sizeof(D3DMATERIAL9)); // clear out the struct for use
material.Diffuse = D3DXCOLOR(1.0f, 1.0f, 1.0f, 1.0f); // set diffuse color to white
material.Ambient = D3DXCOLOR(1.0f, 1.0f, 1.0f, 1.0f); // set ambient color to white
d3ddev->SetMaterial(&material); // set the globably-used material to &material
}
示例2: SetupLights
VOID SetupLights()
{
D3DMATERIAL9 mtrl;
ZeroMemory(&mtrl, sizeof(D3DMATERIAL9));
mtrl.Diffuse.r = mtrl.Ambient.r = 1.0f;
mtrl.Diffuse.g = mtrl.Ambient.g = 1.0f;
mtrl.Diffuse.b = mtrl.Ambient.b = 1.0f;
mtrl.Diffuse.a = mtrl.Ambient.a = 1.0f;
g_pD3DDevice->SetMaterial(&mtrl);
D3DXVECTOR3 vecDir0;
D3DLIGHT9 light0;
ZeroMemory(&light0, sizeof(D3DLIGHT9));
light0.Type = D3DLIGHT_DIRECTIONAL;
light0.Diffuse.r = 1.f;
light0.Diffuse.g = 1.f;
light0.Diffuse.b = 1.f;
vecDir0 = D3DXVECTOR3(-1.f, 1.f, 0.f );
D3DXVec3Normalize((D3DXVECTOR3*) &light0.Direction, &vecDir0);
light0.Range = 1000.f;
D3DXVECTOR3 vecDir1;
D3DLIGHT9 light1;
ZeroMemory(&light1, sizeof(D3DLIGHT9));
light1.Type = D3DLIGHT_DIRECTIONAL;
light1.Diffuse.r = 1.f;
light1.Diffuse.g = 1.f;
light1.Diffuse.b = 1.f;
vecDir1 = D3DXVECTOR3(1.f, 1.f, 0.f);
D3DXVec3Normalize((D3DXVECTOR3*) &light1.Direction, &vecDir1);
light1.Range = 1000.f;
g_pD3DDevice->SetLight(0, &light0);
g_pD3DDevice->SetLight(1, &light1);
g_pD3DDevice->SetRenderState(D3DRS_LIGHTING, TRUE);
g_pD3DDevice->SetRenderState(D3DRS_AMBIENT, 0x00808080);
if (5<(g_tick%31))
{
g_pD3DDevice->LightEnable(0, TRUE);
g_pD3DDevice->LightEnable(1, FALSE);
}
else
{
g_pD3DDevice->LightEnable(0, FALSE);
g_pD3DDevice->LightEnable(1, TRUE);
}
}
示例3: WndProc
//
// 윈도우 프로시져 함수 ( 메시지 큐에서 받아온 메시지를 처리한다 )
//
LRESULT CALLBACK WndProc( HWND hWnd, UINT msg, WPARAM wParam, LPARAM lParam )
{
switch (msg)
{
case WM_KEYDOWN:
if (wParam == VK_ESCAPE)
::DestroyWindow(hWnd);
else if (wParam == VK_TAB)
{
static bool flag = false;
g_pDevice->SetRenderState(D3DRS_CULLMODE, flag? D3DCULL_CCW : D3DCULL_NONE);
g_pDevice->SetRenderState(D3DRS_FILLMODE, flag? D3DFILL_SOLID : D3DFILL_WIREFRAME);
flag = !flag;
}
else if (VK_SPACE == wParam)
{
static bool flag = false;
g_pDevice->SetLight(0, &global->light); // 광원 설정.
g_pDevice->LightEnable(0, flag);
flag = !flag;
}
break;
case WM_DESTROY: //윈도우가 파괴된다면..
PostQuitMessage(0); //프로그램 종료 요청 ( 메시지 루프를 빠져나가게 된다 )
break;
}
return DefWindowProc( hWnd, msg, wParam, lParam );
}
示例4: SetupLightingDX9
void SetupLightingDX9(void)
{
// 取得Direct3D 9裝置
LPDIRECT3DDEVICE9 device = GutGetGraphicsDeviceDX9();
device->SetRenderState(D3DRS_LIGHTING, TRUE);
// 設定環境光
device->SetRenderState(D3DRS_AMBIENT, ConvertToD3DCOLOR(g_vAmbientLight));
// 設定光源
device->LightEnable(0, TRUE);
D3DLIGHT9 light;
ZeroMemory( &light, sizeof(light) );
light.Type = D3DLIGHT_POINT;
light.Position = *(D3DVECTOR *) &g_Light.m_Position;
light.Diffuse = *(D3DCOLORVALUE*) &g_Light.m_Diffuse;
light.Specular = *(D3DCOLORVALUE*) &g_Light.m_Specular;
light.Range = 100.0f;
light.Attenuation0 = 1.0f;
light.Attenuation1 = 0.0f;
light.Attenuation2 = 0.0f;
device->SetLight(0, &light);
}
示例5:
// @brief : 描画が有効のときの挙動
//--------------------------------------------------------------------
void DirectionalLightDx9::OnEnable( void )
{
LPDIRECT3DDEVICE9 device = DirectX9::Instance().Device;
device->SetRenderState(D3DRS_LIGHTING,TRUE);
device->SetRenderState(D3DRS_AMBIENT,TRUE);
device->LightEnable(m_Index,TRUE);
}
示例6: SetupLights
//-----------------------------------------------------------------------------
// Name: SetupLights()
// Desc: Sets up the lights and materials for the scene.
//-----------------------------------------------------------------------------
VOID SetupLights()
{
// Set up a material. The material here just has the diffuse and ambient
// colors set to yellow. Note that only one material can be used at a time.
D3DMATERIAL9 mtrl;
ZeroMemory( &mtrl, sizeof(D3DMATERIAL9) );
mtrl.Diffuse.r = mtrl.Ambient.r = 1.0f;
mtrl.Diffuse.g = mtrl.Ambient.g = 1.0f;
mtrl.Diffuse.b = mtrl.Ambient.b = 0.0f;
mtrl.Diffuse.a = mtrl.Ambient.a = 1.0f;
g_pd3dDevice->SetMaterial( &mtrl );
// Set up a white, directional light, with an oscillating direction.
// Note that many lights may be active at a time (but each one slows down
// the rendering of our scene). However, here we are just using one. Also,
// we need to set the D3DRS_LIGHTING renderstate to enable lighting
D3DXVECTOR3 vecDir;
D3DLIGHT9 light;
ZeroMemory( &light, sizeof(D3DLIGHT9) );
light.Type = D3DLIGHT_DIRECTIONAL;
light.Diffuse.r = 1.0f;
light.Diffuse.g = 1.0f;
light.Diffuse.b = 1.0f;
vecDir = D3DXVECTOR3(cosf(timeGetTime()/350.0f),
1.0f,
sinf(timeGetTime()/350.0f) );
D3DXVec3Normalize( (D3DXVECTOR3*)&light.Direction, &vecDir );
light.Range = 1000.0f;
g_pd3dDevice->SetLight( 0, &light );
g_pd3dDevice->LightEnable( 0, TRUE );
g_pd3dDevice->SetRenderState( D3DRS_LIGHTING, TRUE );
// Finally, turn on some ambient light.
g_pd3dDevice->SetRenderState( D3DRS_AMBIENT, 0x00202020 );
}
示例7: sizeof
// デフォルトコンストラクタ
Light::Light()
{
// ライトの設定
ZeroMemory(&light, sizeof(D3DLIGHT9));
light.Type = D3DLIGHT_DIRECTIONAL;
light.Diffuse.r = 1.0f;
light.Diffuse.g = 1.0f;
light.Diffuse.b = 1.0f;
light.Ambient.r = 1.0f;
light.Ambient.g = 1.0f;
light.Ambient.b = 1.0f;
light.Specular.r = 1.0f;
light.Specular.g = 1.0f;
light.Specular.b = 1.0f;
D3DXVECTOR3 lightAngle;
lightAngle = D3DXVECTOR3(1.0f, -1.0f, 1.0f);
D3DXVec3Normalize((D3DXVECTOR3*)&light.Direction, &lightAngle);
d3dDevice->SetLight(0, &light);
d3dDevice->LightEnable(0, true);
d3dDevice->SetRenderState(D3DRS_LIGHTING, true);
d3dDevice->SetRenderState(D3DRS_AMBIENT, 0x00111111);
d3dDevice->SetRenderState(D3DRS_SPECULARENABLE, true);
// 霧の発生
d3dDevice->SetRenderState(D3DRS_FOGENABLE, true);
d3dDevice->SetRenderState(D3DRS_FOGCOLOR, 0xff000033);
d3dDevice->SetRenderState(D3DRS_FOGSTART, FtoDW(100.0f));
d3dDevice->SetRenderState(D3DRS_FOGEND, FtoDW(315.0f));
d3dDevice->SetRenderState(D3DRS_FOGVERTEXMODE, D3DFOG_LINEAR);
}
示例8: sizeof
void RageDisplay_D3D::SetLightDirectional(
int index,
const RageColor &ambient,
const RageColor &diffuse,
const RageColor &specular,
const RageVector3 &dir )
{
g_pd3dDevice->LightEnable( index, true );
D3DLIGHT9 light;
ZERO( light );
light.Type = D3DLIGHT_DIRECTIONAL;
/* Z for lighting is flipped for D3D compared to OpenGL.
* XXX: figure out exactly why this is needed. Our transforms
* are probably goofed up, but the Z test is the same for both
* API's, so I'm not sure why we don't see other weirdness. -Chris */
float position[] = { dir.x, dir.y, -dir.z };
memcpy( &light.Direction, position, sizeof(position) );
memcpy( &light.Diffuse, diffuse, sizeof(diffuse) );
memcpy( &light.Ambient, ambient, sizeof(ambient) );
memcpy( &light.Specular, specular, sizeof(specular) );
// Same as OpenGL defaults. Not used in directional lights.
// light.Attenuation0 = 1;
// light.Attenuation1 = 0;
// light.Attenuation2 = 0;
g_pd3dDevice->SetLight( index, &light );
}
示例9: SetupLights
VOID SetupLights()
{
// 初始化一个材料
D3DMATERIAL9 mtrl;
ZeroMemory( &mtrl, sizeof(D3DMATERIAL9) );
mtrl.Diffuse = mtrl.Ambient = D3DXCOLOR(1.0f,1.0f,0.0f,1.0f); //材质有漫射和环境光的设置,都为黄色
g_pd3dDevice->SetMaterial( &mtrl );
// 初始化一个白色的方向光
///*
D3DXVECTOR3 vecDir;
D3DLIGHT9 light;
ZeroMemory( &light, sizeof(D3DLIGHT9) );
light.Type = D3DLIGHT_DIRECTIONAL;//方向光
light.Diffuse = D3DXCOLOR(1.0f,1.0f,1.0f,1.0f);//设置光源的漫射光颜色为白色
light.Direction = D3DXVECTOR3(0.0f,0.0f,1.0f);//光的传播方向平行z轴
light.Range = 1000.0f;
g_pd3dDevice->SetLight( 0, &light );
g_pd3dDevice->LightEnable( 0, TRUE );
g_pd3dDevice->SetRenderState( D3DRS_LIGHTING, TRUE );
// Finally, turn on some ambient light.
g_pd3dDevice->SetRenderState( D3DRS_AMBIENT, 0x00202020 );
}
示例10: InitLight
HRESULT Game::InitLight()
{
D3DLIGHT9 light;
ZeroMemory(&light, sizeof(D3DLIGHT9));
light.Type = D3DLIGHT_DIRECTIONAL;
//ライトの向きの調整
light.Direction = D3DXVECTOR3(1.0f, -1.0f, 1.0f);
//ディフューズを設定する
light.Diffuse.r = 1.0f;
light.Diffuse.g = 1.0f;
light.Diffuse.b = 1.0f;
//アンビエント(間接光)を追加する
light.Ambient.r = 0.4f;
light.Ambient.g = 0.4f;
light.Ambient.b = 0.4f;
if (FAILED(g_pDevice->SetLight(0, &light)))
{
MessageBox(0, "ライトをセットできませんでした", "Game", MB_OK);
return E_FAIL;
}
if (FAILED(g_pDevice->LightEnable(0, TRUE)))
{
MessageBox(0, "ライトを有効にできませんでした", "Game", MB_OK);
return E_FAIL;
}
return S_OK;
}
示例11: sizeof
//デフォルトコンストラクタ
Light::Light()
{
//ライトの設定
ZeroMemory(&light, sizeof(D3DLIGHT9));
light.Type = D3DLIGHT_DIRECTIONAL;
light.Diffuse.r = 1.0f;
light.Diffuse.g = 1.0f;
light.Diffuse.b = 1.0f;
light.Ambient.r = 1.0f;
light.Ambient.g = 1.0f;
light.Ambient.b = 1.0f;
light.Specular.r = 1.0f;
light.Specular.g = 1.0f;
light.Specular.b = 1.0f;
D3DXVECTOR3 lightAngle;
lightAngle = D3DXVECTOR3(0.0f, -1.0f, 1.0f);
D3DXVec3Normalize((D3DXVECTOR3 *)&light.Direction, &lightAngle);
d3dDevice->SetLight(0, &light);
d3dDevice->LightEnable(0, true);
d3dDevice->SetRenderState(D3DRS_LIGHTING, true);
d3dDevice->SetRenderState(D3DRS_AMBIENT, 0x00111111);
d3dDevice->SetRenderState(D3DRS_SPECULARENABLE, true);
}
示例12: SetLight
//-----------------------------------------------------------------------------
// Desc: 设置材质和灯光
//-----------------------------------------------------------------------------
VOID SetLight()
{
//设置材质
D3DMATERIAL9 mtrl;
ZeroMemory( &mtrl, sizeof(D3DMATERIAL9) );
mtrl.Diffuse.r = mtrl.Ambient.r = 1.0f;
mtrl.Diffuse.g = mtrl.Ambient.g = 1.0f;
mtrl.Diffuse.b = mtrl.Ambient.b = 0.0f;
mtrl.Diffuse.a = mtrl.Ambient.a = 1.0f;
g_pd3dDevice->SetMaterial( &mtrl );
//设置灯光
D3DXVECTOR3 vecDir;
D3DLIGHT9 light;
ZeroMemory( &light, sizeof(D3DLIGHT9) );
light.Type = D3DLIGHT_DIRECTIONAL;
light.Diffuse.r = 1.0f;
light.Diffuse.g = 1.0f;
light.Diffuse.b = 1.0f;
vecDir = D3DXVECTOR3(
cosf(timeGetTime()/350.0f),
1.0f,
sinf(timeGetTime()/350.0f) );
vecDir = D3DXVECTOR3(1.0f, 1.0f, 0.0f);
D3DXVec3Normalize( (D3DXVECTOR3*)&light.Direction, &vecDir );
light.Range = 1000.0f;
g_pd3dDevice->SetLight( 0, &light );
g_pd3dDevice->LightEnable( 0, TRUE );
g_pd3dDevice->SetRenderState( D3DRS_LIGHTING, TRUE );
//设置环境光
g_pd3dDevice->SetRenderState( D3DRS_AMBIENT, 0x00505050);
}
示例13:
HRESULT HookIDirect3DDevice9::LightEnable(LPVOID _this,
DWORD Index,
BOOL Enable)
{
LOG_API();
return pD3Dev->LightEnable(Index, Enable);
}
示例14: SetupLights
/**-----------------------------------------------------------------------------
* 광원 설정
*------------------------------------------------------------------------------
*/
VOID SetupLights()
{
/// 재질(material)설정
/// 재질은 디바이스에 단 하나만 설정될 수 있다.
D3DMATERIAL9 mtrl;
ZeroMemory( &mtrl, sizeof(D3DMATERIAL9) );
mtrl.Diffuse.r = mtrl.Ambient.r = 1.0f;
mtrl.Diffuse.g = mtrl.Ambient.g = 1.0f;
mtrl.Diffuse.b = mtrl.Ambient.b = 1.0f;
mtrl.Diffuse.a = mtrl.Ambient.a = 1.0f;
g_pd3dDevice->SetMaterial( &mtrl );
/// 광원 설정
D3DXVECTOR3 vecDir; /// 방향성 광원(directional light)이 향할 빛의 방향
D3DLIGHT9 light; /// 광원 구조체
ZeroMemory( &light, sizeof(D3DLIGHT9) ); /// 구조체를 0으로 지운다.
light.Type = D3DLIGHT_DIRECTIONAL; /// 광원의 종류(점 광원,방향성 광원,스포트라이트)
light.Diffuse.r = 1.0f; /// 광원의 색깔과 밝기
light.Diffuse.g = 1.0f;
light.Diffuse.b = 0.0f;
vecDir = D3DXVECTOR3( 1, 1, 1 ); /// 광원 고정
vecDir = D3DXVECTOR3(cosf(GetTickCount()/350.0f), /// 광원 회전
1.0f,
sinf(GetTickCount()/350.0f) );
D3DXVec3Normalize( (D3DXVECTOR3*)&light.Direction, &vecDir ); /// 광원의 방향을 단위벡터로 만든다.
light.Range = 1000.0f; /// 광원이 다다를수 있는 최대거리
g_pd3dDevice->SetLight( 0, &light ); /// 디바이스에 0번 광원 설치
g_pd3dDevice->LightEnable( 0, TRUE ); /// 0번 광원을 켠다
g_pd3dDevice->SetRenderState( D3DRS_LIGHTING, TRUE ); /// 광원설정을 켠다
g_pd3dDevice->SetRenderState( D3DRS_AMBIENT, 0x00909090 ); /// 환경광원(ambient light)의 값 설정
}
示例15: SetupLights
VOID SetupLights()
{
D3DMATERIAL9 mtrl;
ZeroMemory( &mtrl, sizeof( D3DMATERIAL9 ) );
mtrl.Diffuse.r = mtrl.Ambient.r = 1.0f;
mtrl.Diffuse.g = mtrl.Ambient.g = 1.0f;
mtrl.Diffuse.b = mtrl.Ambient.b = 1.0f;
mtrl.Diffuse.a = mtrl.Ambient.a = 1.0f;
g_pd3dDevice->SetMaterial( &mtrl );
D3DXVECTOR3 vecDir;
D3DLIGHT9 light;
ZeroMemory( &light, sizeof( D3DLIGHT9 ) );
light.Type = D3DLIGHT_DIRECTIONAL;
light.Diffuse.r = 1.0f;
light.Diffuse.g = 1.0f;
light.Diffuse.b = 1.0f;
vecDir = D3DXVECTOR3( 0.0f, 0.0f, 1.0f );
D3DXVec3Normalize( (D3DXVECTOR3*)&light.Direction, &vecDir );
light.Range = 1000.0f;
g_pd3dDevice->SetLight( 0, &light );
g_pd3dDevice->LightEnable( 0, true );
g_pd3dDevice->SetRenderState( D3DRS_LIGHTING, TRUE );
g_pd3dDevice->SetRenderState( D3DRS_AMBIENT, 0xFFA0A0A0 );
}