핸들(Direct3D 9)

핸들은 ID3DXEffectCompiler 또는 ID3DXEffect를 사용하여 기술, 패스, 주석 및 매개 변수를 참조하는 효율적인 수단을 제공합니다. Get[Parameter| 형식의 함수를 호출할 때 동적으로 생성됩니다. 주석| 함수| 기술| Pass][ByName| BySemantic| 요소].

프로그램을 실행하는 동안 동일한 개체에 대한 핸들을 여러 번 생성하면 매번 동일한 핸들이 반환됩니다. 그러나 프로그램을 여러 번 실행할 때는 핸들 유지 상수에 의존하지 마세요. 또한 ID3DXEffect 및 ID3DXEffectCompiler의 다른 인스턴스 에서 생성된 핸들은 서로 다릅니다.

헤더 파일을 보면 핸들(D3DXHANDLLE)이 기술적으로 문자열 포인터임을 알 수 있습니다.

GetParameter[ByName| 같은 함수에 전달하는 핸들입니다. 요소| BySemantic] 또는 GetAnnotation[ByName]은 다음과 같은 세 가지 형식일 수 있습니다.

  1. GetParameter[ByName| 같은 함수에서 반환된 핸들 요소| BySemantic].
  2. MyVariableName, MyTechniqueName 또는 MyArray[0]과 같은 문자열입니다.
  3. Handle = NULL입니다. 네 가지 경우가 있습니다.
    • 메서드 반환 값인 경우 메서드가 핸들을 찾지 못했습니다.
    • NULL 핸들이 GetParameter[ByName| 의 첫 번째 매개 변수로 전달되는 경우 요소| BySemantic], 함수는 최상위 매개 변수를 반환합니다. 반대로 핸들이 NULL이 아닌 경우 함수는 핸들로 식별된 구조체 멤버 또는 요소를 반환합니다.
    • NULL 핸들이 ValidateTechnique의 첫 번째 인수 또는 IsParameterUsed의 두 번째 인수로 전달되면 현재 기술의 유효성이 검사됩니다.
    • NULL 핸들이 FindNextValidTechnique의 첫 번째 인수로 전달되는 경우 유효한 기술에 대한 검색은 효과의 첫 번째 기술에서 시작됩니다.

성능 팁 애플리케이션 시작 시 초기화 패스를 수행하여 문자열에서 핸들을 생성합니다. 이때부터 핸들만 사용합니다. 생성된 핸들 대신 문자열을 전달하는 속도가 느립니다.

예제

다음은 Get[Parameter| 를 사용하는 몇 가지 예입니다. 주석| 함수| 기술| Pass][ByName| BySemantic| Element] 핸들을 생성하는 함수입니다.

// Gets handle of second top-level parameter handle in the effect file
h1 = GetParameter(NULL, 1);    

// Gets handle of the third struct member of MyStruct
h2 = GetParameter("MyStruct", 2); 

// Gets handle of the third array element handle of MyArray
h3 = GetParameterElement("MyArray", 2); 

// Gets handle of first member of h1 (that is, the second top-level param)
h4 = GetParameter(h1, 0);    

// Gets handle of MyStruct.Data
h5 = GetParameterByName("MyStruct", "Data");    
// or 
h6 = GetParameterByName(NULL, "MyStruct.Data");    

// Gets handle of MyStruct.Data.SubData
h7 = GetParameterByName("MyStruct.Data", "SubData"); 
// or 
h8 = GetParameterByName(NULL, "MyStruct.Data.SubData");

// Gets handle of fifth annotation of h1 (that is, second top-level param)
h9 = GetAnnotation(h1, 4);    

// Gets handle of MyStruct's annotation, called Author
h10 = GetAnnotationByName("MyStruct", "Author");  
// or
h11 = GetParameterByName(NULL, "MyStruct@Author"); 

효과 형식