IDirect3DDevice9::SetLight 메서드(d3d9helper.h)

이 디바이스에 대한 조명 속성 집합을 할당합니다.

구문

HRESULT SetLight(
  [in] DWORD           Index,
  [in] const D3DLIGHT9 *unnamedParam2
);

매개 변수

[in] Index

형식: DWORD

설정할 조명 속성 집합의 인덱스(0부터 시작)입니다. 이 인덱스에 조명 속성 집합이 있는 경우 pLight에 지정된 새 속성으로 덮어씁니다.

[in] unnamedParam2

형식: const D3DLIGHT9*

설정할 조명 매개 변수를 포함하는 D3DLIGHT9 구조체에 대한 포인터입니다.

반환 값

형식: HRESULT

메서드가 성공하면 반환 값이 D3D_OK. 메서드가 실패하면 반환 값을 D3DERR_INVALIDCALL 수 있습니다.

설명

D3DLIGHT9 구조를 준비한 다음 IDirect3DDevice9::SetLight 메서드를 호출하여 조명 속성을 설정합니다. IDirect3DDevice9::SetLight 메서드는 디바이스가 조명 속성의 내부 목록에 조명 속성 집합을 배치해야 하는 인덱스와 해당 속성을 정의하는 준비된 D3DLIGHT9 구조체의 주소를 허용합니다. 필요에 따라 새 정보로 IDirect3DDevice9::SetLight 를 호출하여 조명의 조명 속성을 업데이트할 수 있습니다.

시스템은 속성이 할당되지 않은 인덱스를 사용하여 IDirect3DDevice9::SetLight 메서드를 호출할 때마다 조명 속성 집합을 수용하도록 메모리를 할당합니다. 애플리케이션은 할당된 조명의 하위 집합만 한 번에 사용하도록 설정하여 여러 조명을 설정할 수 있습니다. 디바이스 기능을 검색할 때 D3DCAPS9 구조체의 MaxActiveLights 멤버를 확인하여 해당 디바이스에서 지원하는 최대 활성 조명 수를 확인합니다. 조명이 더 이상 필요하지 않은 경우 조명을 사용하지 않도록 설정하거나 새 조명 속성 집합으로 덮어쓸 수 있습니다.

다음 예제에서는 내보낸 조명이 멀리서 감쇠되지 않는 흰색 점등에 대한 속성을 준비하고 설정합니다.


// Assume d3dDevice is a valid pointer to an IDirect3DDevice9 interface.
D3DLIGHT9 d3dLight;
HRESULT   hr;
    
// Initialize the structure.
ZeroMemory(&d3dLight, sizeof(d3dLight));
    
// Set up a white point light.
d3dLight.Type = D3DLIGHT_POINT;
d3dLight.Diffuse.r  = 1.0f;
d3dLight.Diffuse.g  = 1.0f;
d3dLight.Diffuse.b  = 1.0f;
d3dLight.Ambient.r  = 1.0f;
d3dLight.Ambient.g  = 1.0f;
d3dLight.Ambient.b  = 1.0f;
d3dLight.Specular.r = 1.0f;
d3dLight.Specular.g = 1.0f;
d3dLight.Specular.b = 1.0f;
    
// Position it high in the scene and behind the user.
// Remember, these coordinates are in world space, so
// the user could be anywhere in world space, too. 
// For the purposes of this example, assume the user
// is at the origin of world space.
d3dLight.Position.x = 0.0f;
d3dLight.Position.y = 1000.0f;
d3dLight.Position.z = -100.0f;
    
// Don't attenuate.
d3dLight.Attenuation0 = 1.0f; 
d3dLight.Range        = 1000.0f;
    
// Set the property information for the first light.
hr = d3dDevice->SetLight(0, &d3dLight);
if (SUCCEEDED(hr))
    // Handle Success
else
    // Handle failure

디바이스에 대한 IDirect3DDevice9::LightEnable 메서드를 호출하여 광원을 사용하도록 설정합니다.

요구 사항

요구 사항
대상 플랫폼 Windows
헤더 d3d9helper.h(D3D9.h 포함)
라이브러리 D3D9.lib

추가 정보

IDirect3DDevice9

IDirect3DDevice9::GetLight

IDirect3DDevice9::GetLightEnable

IDirect3DDevice9::LightEnable