### SetupPixelFog function for enabling pixel fog Source: https://learn.microsoft.com/en-us/windows/win32/direct3d9/pixel-fog This example shows how to enable fog blending, set the fog color, and configure fog parameters for linear or exponential modes. It uses IDirect3DDevice9::SetRenderState and casts floating-point values to DWORD pointers for the fog start, end, and density parameters. The code assumes g_pDevice is a valid pointer to an IDirect3DDevice9 interface. ```cpp // For brevity, error values in this example are not checked // after each call. A real-world application should check // these values appropriately. // // For the purposes of this example, g_pDevice is a valid // pointer to an IDirect3DDevice9 interface. void SetupPixelFog(DWORD Color, DWORD Mode) { float Start = 0.5f; // For linear mode float End = 0.8f; float Density = 0.66f; // For exponential modes // Enable fog blending. g_pDevice->SetRenderState(D3DRS_FOGENABLE, TRUE); // Set the fog color. g_pDevice->SetRenderState(D3DRS_FOGCOLOR, Color); // Set fog parameters. if( Mode == D3DFOG_LINEAR ) { g_pDevice->SetRenderState(D3DRS_FOGTABLEMODE, Mode); g_pDevice->SetRenderState(D3DRS_FOGSTART, *(DWORD *)(&Start)); g_pDevice->SetRenderState(D3DRS_FOGEND, *(DWORD *)(&End)); } else { g_pDevice->SetRenderState(D3DRS_FOGTABLEMODE, Mode); g_pDevice->SetRenderState(D3DRS_FOGDENSITY, *(DWORD *)(&Density)); } } ``` -------------------------------- ### Work comparison between Example 5c and 5d Source: https://learn.microsoft.com/en-us/windows/win32/direct3d9/accurately-profiling-direct3d-api-calls Shows the total work done (runtime + driver work) for both examples, illustrating the reduction in driver work when SetTexture is moved outside the loop. ```text total work done = runtime + driver work Example 5c: with SetTexture in the loop: runtime work = 1500 SetTextures + 1500 DrawPrimitives driver work = 1500 SetTextures + 1500 DrawPrimitives Example 5d: with SetTexture outside of the loop: runtime work = 1 SetTexture + 1 DrawPrimitive + 1499 Concatenated DrawPrimitives driver work = 1 SetTexture + 1 DrawPrimitive ``` -------------------------------- ### Example: Saving a mesh to a .x file Source: https://learn.microsoft.com/en-us/windows/win32/direct3d9/d3dxsavemeshtox A typical code example showing how to use D3DXSaveMeshToX to save a mesh to a .x file, with comments on binary and text formats. ```cpp ID3DXMesh* m_pMesh; // Mesh object to be saved to a .x file D3DXMATERIAL* m_pMaterials; // Array of material structs in the mesh DWORD m_dwNumMaterials; // Number of material structs in the mesh DWORD dwFormat = D3DXF_FILEFORMAT_BINARY; // Binary-format .x file (default) // DWORD dwFormat = D3DXF_FILEFORMAT_TEXT; // Text-format .x file // Load mesh into m_pMesh and determine values of m_pMaterials and // m_dwNumMaterials with calls to D3DXLoadMeshxxx or other D3DX functions // ... D3DXSaveMeshToX( L"outputxfilename.x", m_pMesh, NULL, m_pMaterials, NULL, m_dwNumMaterials, dwFormat ); ``` -------------------------------- ### Interpolation example between Q1 and Q2 Source: https://learn.microsoft.com/en-us/windows/win32/direct3d9/d3dxquaternionsquadsetup Example code that sets up quaternion keys and uses D3DXQuaternionSquadSetup and D3DXQuaternionSquad to interpolate between Q1 and Q2, resulting in a 45-degree rotation around the z-axis for time = 0.5. ```cpp // Rotation about the z-axis D3DXQUATERNION Q0 = D3DXQUATERNION(0, 0, 0.707f, -.707f); D3DXQUATERNION Q1 = D3DXQUATERNION(0, 0, 0.000f, 1.000f); D3DXQUATERNION Q2 = D3DXQUATERNION(0, 0, 0.707f, 0.707f); D3DXQUATERNION Q3 = D3DXQUATERNION(0, 0, 1.000f, 0.000f); D3DXQUATERNION A, B, C, Qt; FLOAT time = 0.5f; D3DXQuaternionSquadSetup(&A, &B, &C, &Q0, &Q1, &Q2, &Q3); D3DXQuaternionSquad(&Qt, &Q1, &A, &B, &C, time); ``` -------------------------------- ### Set up device with multisampling render surface using D3DPRESENT_PARAMETERS Source: https://learn.microsoft.com/en-us/windows/win32/direct3d9/full-scene-antialiasing After confirming support, fill D3DPRESENT_PARAMETERS with Windowed set to FALSE, SwapEffect set to D3DSWAPEFFECT_DISCARD, and MultiSampleType set to D3DMULTISAMPLE_2_SAMPLES, then call CreateDevice. The SwapEffect member must be D3DSWAPEFFECT_DISCARD for multisampling. ```cpp /* * The example below assumes that pD3D is a valid pointer * to a IDirect3D9 interface, d3dDevice is a pointer to a * IDirect3DDevice9 interface, and hWnd is a valid handle * to a window. */ D3DPRESENT_PARAMETER d3dPP ZeroMemory( &d3dPP, sizeof( d3dPP ) ); d3dPP.Windowed = FALSE d3dPP.SwapEffect = D3DSWAPEFFECT_DISCARD; d3dPP.MultiSampleType = D3DMULTISAMPLE_2_SAMPLES; pD3D->CreateDevice(D3DADAPTER_DEFAULT, D3DDEVTYPE_HAL, hWnd, D3DCREATE_SOFTWARE_VERTEXPROCESSING, &d3dpp, &d3dDevice) ``` -------------------------------- ### Calling IDirectXFileSaveObject::SaveTemplates with GUID array Source: https://learn.microsoft.com/en-us/windows/win32/direct3d9/idirectxfilesaveobject--savetemplates Example call to SaveTemplates, showing the array of GUIDs for templates to save. The method is deprecated; after saving templates, use CreateDataObject to create a data object. ```cpp IDirectXFileSaveObject * pDXFileSaveObject; const GUID *aIds[] = { &DXFILEOBJ_SimpleData, &DXFILEOBJ_ArrayData, &DXFILEOBJ_RestrictedData}; hr = pDXFileSaveObject->SaveTemplates(3, aIds); ``` -------------------------------- ### Convert ticks to cycles for toggling state example Source: https://learn.microsoft.com/en-us/windows/win32/direct3d9/accurately-profiling-direct3d-api-calls These calculations convert the measured tick counts (start, stop, freq) into cycles and then derive the average cost per state change. The example uses a 2 GHz machine and a QPF of 3,579,545, with 1500 iterations and an assumed 1100 cycles per draw call. ```text # ticks = (stop - start) = 1792998861740 - 1792998845000 = 15,120 ticks # cycles = machine speed * number of ticks / QPF 9,300,000 = 2 GHz * 16,740 / 3,579,545 ``` ```text 9,300,000 cycles / 1500 iterations = 6200 cycles for one iteration ``` ```text 6200 - 1100 - 1100 = 4000 cycles for both state changes ``` ```text 4000 / 2 = 2000 cycles for each state change ``` -------------------------------- ### Guid template definition Source: https://learn.microsoft.com/en-us/windows/win32/direct3d9/guid Defines a GUID template with fields data1, data2, data3, and data4. The template is used to represent a GUID in DirectX 9 templates. ```unknown template Guid { < a42790e0-7810-11cf-8f52-0040333594a3 > DWORD data1; WORD data2; WORD data3; array UCHAR data4[8]; } ``` -------------------------------- ### Set up specular light mapping in C++ Source: https://learn.microsoft.com/en-us/windows/win32/direct3d9/specular-light-maps This C++ example sets up three texture stages: base texture, specular light map, and RGB light map. It assumes valid pointers to IDirect3DDevice9 and textures. The base texture is modulated with diffuse color, the specular light map is added, and the RGB light map is modulated with the current color. ```cpp // This example assumes that d3dDevice is a valid pointer to an // IDirect3DDevice9 interface. // lptexBaseTexture is a valid pointer to a texture. // lptexSpecLightMap is a valid pointer to a texture that contains RGB // specular light map data. // lptexLightMap is a valid pointer to a texture that contains RGB // light map data. // Set the base texture. d3dDevice->SetTexture(0, lptexBaseTexture ); // Set the base texture operation and arguments. d3dDevice->SetTextureStageState(0, D3DTSS_COLOROP, D3DTOP_MODULATE ); d3dDevice->SetTextureStageState(0, D3DTSS_COLORARG1, D3DTA_TEXTURE ); d3dDevice->SetTextureStageState(0, D3DTSS_COLORARG2, D3DTA_DIFFUSE ); // Set the specular light map. d3dDevice->SetTexture(1, lptexSpecLightMap); // Set the specular light map operation and args. d3dDevice->SetTextureStageState(1, D3DTSS_COLOROP, D3DTOP_ADD ); d3dDevice->SetTextureStageState(1, D3DTSS_COLORARG1, D3DTA_TEXTURE ); d3dDevice->SetTextureStageState(1, D3DTSS_COLORARG2, D3DTA_CURRENT ); // Set the RGB light map. d3dDevice->SetTexture(2, lptexLightMap); // Set the RGB light map operation and arguments. d3dDevice->SetTextureStageState(2,D3DTSS_COLOROP, D3DTOP_MODULATE); d3dDevice->SetTextureStageState(2,D3DTSS_COLORARG1, D3DTA_TEXTURE ); d3dDevice->SetTextureStageState(2,D3DTSS_COLORARG2, D3DTA_CURRENT ); ``` -------------------------------- ### D3DRENDERSTATE_WRAPBIAS Usage Example Source: https://learn.microsoft.com/en-us/windows/win32/direct3d9/d3drenderstatetype Example showing how to use D3DRENDERSTATE_WRAPBIAS to enable texture wrapping for a specific texture coordinate set. ```APIDOC ## D3DRENDERSTATE_WRAPBIAS ### Description D3DRENDERSTATE_WRAPBIAS is a constant used to calculate the D3DRS_WRAPn render state value for a given texture coordinate set. Add this constant to the zero-based index of a texture coordinate set to get the corresponding D3DRS_WRAPn value. ### Usage Add D3DRENDERSTATE_WRAPBIAS to the zero-based index of a texture coordinate set to calculate the D3DRS_WRAPn value. ### Example ```cpp // Enable U/V wrapping for textures that use the texture // coordinate set at the index within the dwIndex variable HRESULT hr = pd3dDevice->SetRenderState( dwIndex + D3DRENDERSTATE_WRAPBIAS, D3DWRAPCOORD_0 | D3DWRAPCOORD_1); // If dwIndex is 3, the value that results from // the addition equals D3DRS_WRAP3 (131) ``` ### Remarks - Direct3D defines D3DRENDERSTATE_WRAPBIAS as a convenience for applications to enable or disable texture wrapping. - The constant is used with the IDirect3DDevice9::SetRenderState method. ### Requirements - Header: D3D9Types.h ### See Also - [Direct3D Enumerations](https://learn.microsoft.com/en-us/windows/win32/direct3d9/dx9-graphics-reference-d3d-enums) - [IDirect3DDevice9::GetRenderState](https://learn.microsoft.com/en-us/windows/win32/api/d3d9helper/nf-d3d9helper-idirect3ddevice9-getrenderstate) - [IDirect3DDevice9::SetRenderState](https://learn.microsoft.com/en-us/windows/win32/api/d3d9helper/nf-d3d9helper-idirect3ddevice9-setrenderstate) ``` -------------------------------- ### ID3DXEffect::Begin Source: https://learn.microsoft.com/en-us/windows/win32/direct3d9/id3dxeffect Starts an active technique. ```APIDOC ## ID3DXEffect::Begin ### Description Starts an active technique. ### Method Begin ### Parameters - **pPasses** (pointer) - Required - Pointer to a value that will be set to the number of passes in the technique. - **Flags** (DWORD) - Required - Flags that control the behavior of the begin operation. ### Return Value Returns S_OK if successful; otherwise, returns an error code. ``` -------------------------------- ### SasNormalize example with float3 UpNormal Source: https://learn.microsoft.com/en-us/windows/win32/direct3d9/casting-and-conversion Example effect parameter declaration using the SasNormalize annotation to mark the UpNormal vector as normalized. ```hlsl float3 UpNormal < bool SasNormalize = "True"; >; ``` -------------------------------- ### ID3DXSprite::Begin Source: https://learn.microsoft.com/en-us/windows/win32/direct3d9/id3dxsprite Prepares a device for drawing sprites. ```APIDOC ## ID3DXSprite::Begin ### Description Prepares a device for drawing sprites. ### Method Begin ### Interface ID3DXSprite ### Remarks This method is typically called first before drawing sprites. It allows control over the device render state, alpha blending, and sprite transformation and sorting. ``` -------------------------------- ### ID3DXAnimationSet Methods Source: https://learn.microsoft.com/en-us/windows/win32/direct3d9/id3dxanimationset The ID3DXAnimationSet interface provides methods to manage animation sets, including retrieving animation indices by name, getting animation names by index, accessing callbacks, getting the animation set name, counting animations, getting the period, computing periodic positions, and retrieving scale, rotation, and translation values. ```APIDOC ## ID3DXAnimationSet Interface ### Description This interface encapsulates the minimum functionality required of an animation set by an animation controller. Advanced users might want to implement this interface themselves to suit their specialized needs; for most users, however, the derived ID3DXCompressedAnimationSet and ID3DXKeyframedAnimationSet interfaces should suffice. ### Methods #### GetAnimationIndexByName ##### Description Gets the index of an animation, given its name. #### GetAnimationNameByIndex ##### Description Gets the name of an animation, given its index. #### GetCallback ##### Description Gets information about a specific callback in the animation set. #### GetName ##### Description Gets the animation set name. #### GetNumAnimations ##### Description Gets the number of animations in the animation set. #### GetPeriod ##### Description Gets the period of the animation set. #### GetPeriodicPosition ##### Description Returns time position in the local timeframe of an animation set. #### GetSRT ##### Description Gets the scale, rotation, and translation values of the animation set. ### Remarks An animation set consists of animations for many nodes for the same animation. The LPD3DXANIMATIONSET type is defined as a pointer to this interface. ```cpp typedef interface ID3DXAnimationSet ID3DXAnimationSet; typedef interface ID3DXAnimationSet *LPD3DXANIMATIONSET; ``` ### Requirements | Requirement | Value | | --- | --- | | Header | D3dx9anim.h | | Library | D3dx9.lib | ``` -------------------------------- ### Handle Generation Examples Source: https://learn.microsoft.com/en-us/windows/win32/direct3d9/handles Examples of using GetParameter, GetParameterElement, GetParameterByName, GetAnnotation, and GetAnnotationByName to generate handles for effect parameters, struct members, array elements, and annotations. ```APIDOC ## Handle Generation Examples ### Description These examples demonstrate how to generate handles for effect parameters, struct members, array elements, and annotations using the Get[Parameter|Annotation|Function|Technique|Pass][ByName|BySemantic|Element] functions. ### Functions Used - GetParameter - GetParameterElement - GetParameterByName - GetAnnotation - GetAnnotationByName ### Examples ```cpp // 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"); ``` ### Notes - Handles are generated dynamically and are consistent within a single program run, but may differ between runs and between different instances of ID3DXEffect and ID3DXEffectCompiler. - Handles can be passed as returned handles, strings, or NULL. - Passing NULL as the first parameter to GetParameter[ByName|Element|BySemantic] returns a top-level parameter. - Passing NULL as the first argument to ValidateTechnique or the second argument to IsParameterUsed validates the current technique. - Passing NULL as the first argument to FindNextValidTechnique starts the search at the first technique. - Performance tip: Generate handles from strings once at startup and use only handles thereafter for better performance. ``` -------------------------------- ### Pseudocode for version format encoding Source: https://learn.microsoft.com/en-us/windows/win32/direct3d9/d3dadapter-identifier9 Shows how to extract Product, Version, SubVersion, and Build from the DriverVersion members using HIWORD and LOWORD macros. ```pseudocode Product = HIWORD(DriverVersion.HighPart) Version = LOWORD(DriverVersion.HighPart) SubVersion = HIWORD(DriverVersion.LowPart) Build = LOWORD(DriverVersion.LowPart) ``` -------------------------------- ### ID3DXSprite::Begin Source: https://learn.microsoft.com/en-us/windows/win32/direct3d9/id3dxsprite--begin Prepares a device for drawing sprites. Must be called inside a IDirect3DDevice9::BeginScene/EndScene sequence. ```APIDOC ## ID3DXSprite::Begin ### Description Prepares a device for drawing sprites. This method must be called from inside a IDirect3DDevice9::BeginScene ... IDirect3DDevice9::EndScene sequence. It sets various render states, texture stage states, and sampler states on the device. ### Method Begin ### Syntax HRESULT Begin( [in] DWORD Flags ); ### Parameters #### Flags (DWORD) - Required Combination of zero or more flags that describe sprite rendering options. Valid flags are: - D3DXSPRITE_ALPHABLEND - D3DXSPRITE_BILLBOARD - D3DXSPRITE_DONOTMODIFY_RENDERSTATE - D3DXSPRITE_DONOTSAVESTATE - D3DXSPRITE_OBJECTSPACE - D3DXSPRITE_SORT_DEPTH_BACKTOFRONT - D3DXSPRITE_SORT_DEPTH_FRONTTOBACK - D3DXSPRITE_SORT_TEXTURE ### Return Value Type: HRESULT If the method succeeds, the return value is S_OK. If the method fails, the return value can be one of the following: D3DERR_INVALIDCALL, D3DERR_OUTOFVIDEOMEMORY, D3DXERR_INVALIDDATA, E_OUTOFMEMORY. ### Remarks This method must be called from inside a IDirect3DDevice9::BeginScene ... IDirect3DDevice9::EndScene sequence. ID3DXSprite::Begin cannot be used as a substitute for either IDirect3DDevice9::BeginScene or ID3DXRenderToSurface::BeginScene. This method sets the following states on the device: Render States: - D3DRS_ALPHABLENDENABLE: TRUE - D3DRS_ALPHAFUNC: D3DCMP_GREATER - D3DRS_ALPHAREF: 0x00 - D3DRS_ALPHATESTENABLE: AlphaCmpCaps - D3DRS_BLENDOP: D3DBLENDOP_ADD - D3DRS_CLIPPING: TRUE - D3DRS_CLIPPLANEENABLE: FALSE - D3DRS_COLORWRITEENABLE: D3DCOLORWRITEENABLE_ALPHA | D3DCOLORWRITEENABLE_BLUE | D3DCOLORWRITEENABLE_GREEN | D3DCOLORWRITEENABLE_RED - D3DRS_CULLMODE: D3DCULL_NONE - D3DRS_DESTBLEND: D3DBLEND_INVSRCALPHA - D3DRS_DIFFUSEMATERIALSOURCE: D3DMCS_COLOR1 - D3DRS_ENABLEADAPTIVETESSELLATION: FALSE - D3DRS_FILLMODE: D3DFILL_SOLID - D3DRS_FOGENABLE: FALSE - D3DRS_INDEXEDVERTEXBLENDENABLE: FALSE - D3DRS_LIGHTING: FALSE - D3DRS_RANGEFOGENABLE: FALSE - D3DRS_SEPARATEALPHABLENDENABLE: FALSE - D3DRS_SHADEMODE: D3DSHADE_GOURAUD - D3DRS_SPECULARENABLE: FALSE - D3DRS_SRCBLEND: D3DBLEND_SRCALPHA - D3DRS_SRGBWRITEENABLE: FALSE - D3DRS_STENCILENABLE: FALSE - D3DRS_VERTEXBLEND: FALSE - D3DRS_WRAP0: 0 Texture Stage States: - Stage 0, D3DTSS_ALPHAARG1: D3DTA_TEXTURE - Stage 0, D3DTSS_ALPHAARG2: D3DTA_DIFFUSE - Stage 0, D3DTSS_ALPHAOP: D3DTOP_MODULATE - Stage 0, D3DTSS_COLORARG1: D3DTA_TEXTURE - Stage 0, D3DTSS_COLORARG2: D3DTA_DIFFUSE - Stage 0, D3DTSS_COLOROP: D3DTOP_MODULATE - Stage 0, D3DTSS_TEXCOORDINDEX: 0 - Stage 0, D3DTSS_TEXTURETRANSFORMFLAGS: D3DTTFF_DISABLE - Stage 1, D3DTSS_ALPHAOP: D3DTOP_DISABLE - Stage 1, D3DTSS_COLOROP: D3DTOP_DISABLE Sampler States: - Stage 0, D3DSAMP_ADDRESSU: D3DTADDRESS_CLAMP - Stage 0, D3DSAMP_ADDRESSV: D3DTADDRESS_CLAMP - Stage 0, D3DSAMP_MAGFILTER: D3DTEXF_ANISOTROPIC if TextureFilterCaps includes D3DPTFILTERCAPS_MAGFANISOTROPIC; otherwise D3DTEXF_LINEAR - Stage 0, D3DSAMP_MAXMIPLEVEL: 0 - Stage 0, D3DSAMP_MAXANISOTROPY: MaxAnisotropy - Stage 0, D3DSAMP_MINFILTER: D3DTEXF_ANISOTROPIC if TextureFilterCaps includes D3DPTFILTERCAPS_MINFANISOTROPIC; otherwise D3DTEXF_LINEAR - Stage 0, D3DSAMP_MIPFILTER: D3DTEXF_LINEAR if TextureFilterCaps includes D3DPTFILTERCAPS_MIPFLINEAR; otherwise D3DTEXF_POINT - Stage 0, D3DSAMP_MIPMAPLODBIAS: 0 - Stage 0, D3DSAMP_SRGBTEXTURE: 0 Note: This method disables N-patches. ### Requirements - Header: D3dx9core.h - Library: D3dx9.lib ``` -------------------------------- ### Initialize vertex buffer with degenerate triangles for triangle strip Source: https://learn.microsoft.com/en-us/windows/win32/direct3d9/triangle-lists Shows how to render only the first and last triangle from the previous example by inserting degenerate triangles (zero-size) into the vertex buffer. The degenerate triangles create lines that are not rendered. ```cpp CUSTOMVERTEX Vertices[] = { {-5.0, -5.0, 0.0}, { 0.0, 5.0, 0.0}, { 5.0, -5.0, 0.0}, { 5.0, -5.0, 0.0}, // degenerate triangle {10.0, 5.0, 0.0}, // degenerate triangle {10.0, 5.0, 0.0}, {15.0, -5.0, 0.0}, {20.0, 5.0, 0.0} }; ``` -------------------------------- ### ColorVolumeFill example for D3DXFillVolumeTexture Source: https://learn.microsoft.com/en-us/windows/win32/direct3d9/d3dxfillvolumetexture Example of a user-provided fill function that matches the LPD3DXFILL3D prototype, and its usage with D3DXFillVolumeTexture. The function sets the output color based on texture coordinates. ```cpp // Define a function that matches the prototype of LPD3DXFILL3D VOID WINAPI ColorVolumeFill (D3DXVECTOR4* pOut, const D3DXVECTOR3* pTexCoord, const D3DXVECTOR3* pTexelSize, LPVOID pData) { *pOut = D3DXVECTOR4(pTexCoord->x, pTexCoord->y, pTexCoord->z, 0.0f); } // Fill volume texture if (FAILED (hr = D3DXFillVolumeTexture (m_pTexture, ColorVolumeFill, NULL))) { return hr; } ``` -------------------------------- ### X file with Material and TextureFilename objects Source: https://learn.microsoft.com/en-us/windows/win32/direct3d9/adding-textures Shows the X file format for two materials, each with a TextureFilename data object. The example includes RedMaterial with tex1.ppm and GreenMaterial with win95.ppm. ```x Material RedMaterial { 1.000000;0.000000;0.000000;1.000000;; // R = 1.0, G = 0.0, B = 0.0 0.000000; 0.000000;0.000000;0.000000;; 0.000000;0.000000;0.000000;; TextureFilename { "tex1.ppm"; } } Material GreenMaterial { 0.000000;1.000000;0.000000;1.000000;; // R = 0.0, G = 1.0, B = 0.0 0.000000; 0.000000;0.000000;0.000000;; 0.000000;0.000000;0.000000;; TextureFilename { "win95.ppm"; } } ``` -------------------------------- ### GetVector Source: https://learn.microsoft.com/en-us/windows/win32/direct3d9/id3dxbaseeffect Gets a vector. ```APIDOC ## GetVector ### Description Gets a vector. ### Method GetVector ### Parameters None documented. ### Returns Vector value. ``` -------------------------------- ### Prepare and set view matrix for cube map face rendering Source: https://learn.microsoft.com/en-us/windows/win32/direct3d9/creating-cubic-environment-map-surfaces Initializes the cube map and device pointers, then saves the current view and projection matrices and the current render target and depth-stencil surfaces. This is the first step before rendering to any cube map face. ```cpp // Init pCubeMap to point to an IDirect3DCubeTexture9 interface // Init d3dDevice to point to an IDirect3DDevice9 interface void RenderFaces() { // Save transformation matrices of the device D3DXMATRIX matProjSave, matViewSave; d3dDevice->GetTransform(D3DTS_VIEW, &matViewSave ; d3dDevice->GetTransform(D3DTS_PROJECTION, &matProjSave); // Store the current back buffer and z-buffer LPDIRECT3DSURFACE9 pBackBuffer, pZBuffer; d3dDevice->GetRenderTarget(&pBackBuffer); d3dDevice->GetDepthStencilSurface(&pZBuffer); ``` -------------------------------- ### GetTexture Source: https://learn.microsoft.com/en-us/windows/win32/direct3d9/id3dxbaseeffect Gets a texture. ```APIDOC ## GetTexture ### Description Gets a texture. ### Method GetTexture ### Parameters None documented. ### Returns Texture. ``` -------------------------------- ### D3DXQuaternionMultiply usage example Source: https://learn.microsoft.com/en-us/windows/win32/direct3d9/d3dxquaternionmultiply Shows how to multiply quaternions with D3DXQuaternionMultiply, and compares it to D3DXMatrixMultiply for equivalent rotations. ```cpp D3DXMatrixMultiply(&m, &mX, &mY); D3DXQuaternionMultiply(&q, &qX, &qY); ```