home *** CD-ROM | disk | FTP | other *** search
/ Visual Basic Game Programming for Teens / VBGPFT.cdr / DirectX8 / dx8a_sdk.exe / samples / multimedia / direct3d / envmapping / cubemap / cubemap.cpp next >
Encoding:
C/C++ Source or Header  |  2000-11-04  |  18.0 KB  |  515 lines

  1. //-----------------------------------------------------------------------------
  2. // File: CubeMap.cpp
  3. //
  4. // Desc: Example code showing how to do environment cube-mapping.
  5. //
  6. // Copyright (c) 1997-2000 Microsoft Corporation. All rights reserved.
  7. //-----------------------------------------------------------------------------
  8. #define STRICT
  9. #include <tchar.h>
  10. #include <math.h>
  11. #include <stdio.h>
  12. #include <D3DX8.h>
  13. #include "D3DApp.h"
  14. #include "D3DFile.h"
  15. #include "D3DFont.h"
  16. #include "D3DUtil.h"
  17. #include "DXUtil.h"
  18.  
  19.  
  20.  
  21.  
  22. //-----------------------------------------------------------------------------
  23. // Name: struct ENVMAPPEDVERTEX
  24. // Desc: D3D vertex type for environment-mapped objects
  25. //-----------------------------------------------------------------------------
  26. struct ENVMAPPEDVERTEX
  27. {
  28.     D3DXVECTOR3 p; // Position
  29.     D3DXVECTOR3 n; // Normal
  30. };
  31.  
  32. #define D3DFVF_ENVMAPVERTEX (D3DFVF_XYZ|D3DFVF_NORMAL)
  33.  
  34. // CUBEMAP_RESOLUTION indicates how big to make the cubemap texture.  Larger
  35. // textures will generate a better-looking reflection.
  36. #define CUBEMAP_RESOLUTION 256
  37.  
  38.  
  39.  
  40. //-----------------------------------------------------------------------------
  41. // Name: class CMyD3DApplication
  42. // Desc: Application class. The base class (CD3DApplication) provides the 
  43. //       generic functionality needed in all Direct3D samples. CMyD3DApplication 
  44. //       adds functionality specific to this sample program.
  45. //-----------------------------------------------------------------------------
  46. class CMyD3DApplication : public CD3DApplication
  47. {
  48.     CD3DFont*     m_pFont;
  49.  
  50.     LPDIRECT3DCUBETEXTURE8 m_pCubeMap;
  51.  
  52.     CD3DMesh*     m_pShinyTeapot;
  53.     CD3DMesh*     m_pSkyBox;
  54.     CD3DMesh*     m_pAirplane;
  55.     D3DXMATRIX    m_matAirplane;
  56.     IDirect3DSurface8* m_pCubeFaceZBuffer;
  57.  
  58.     HRESULT RenderScene( BOOL bRenderTeapot );
  59.     HRESULT RenderSceneIntoCubeMap();
  60.  
  61.     HRESULT ConfirmDevice( D3DCAPS8*, DWORD, D3DFORMAT );
  62.  
  63. protected:
  64.     HRESULT OneTimeSceneInit();
  65.     HRESULT InitDeviceObjects();
  66.     HRESULT RestoreDeviceObjects();
  67.     HRESULT InvalidateDeviceObjects();
  68.     HRESULT DeleteDeviceObjects();
  69.     HRESULT Render();
  70.     HRESULT FrameMove();
  71.     HRESULT FinalCleanup();
  72.  
  73. public:
  74.     CMyD3DApplication();
  75. };
  76.  
  77.  
  78.  
  79.  
  80. //-----------------------------------------------------------------------------
  81. // Name: WinMain()
  82. // Desc: Entry point to the program. Initializes everything, and goes into a
  83. //       message-processing loop. Idle time is used to render the scene.
  84. //-----------------------------------------------------------------------------
  85. INT WINAPI WinMain( HINSTANCE hInst, HINSTANCE, LPSTR, INT )
  86. {
  87.     CMyD3DApplication d3dApp;
  88.  
  89.     if( FAILED( d3dApp.Create( hInst ) ) )
  90.         return 0;
  91.  
  92.     return d3dApp.Run();
  93. }
  94.  
  95.  
  96.  
  97.  
  98. //-----------------------------------------------------------------------------
  99. // Name: CMyD3DApplication()
  100. // Desc: Application constructor. Sets attributes for the app.
  101. //-----------------------------------------------------------------------------
  102. CMyD3DApplication::CMyD3DApplication()
  103. {
  104.     m_strWindowTitle    = _T("CubeMap: Environment cube-mapping");
  105.     m_bUseDepthBuffer   = TRUE;
  106.  
  107.     m_pFont             = new CD3DFont( _T("Arial"), 12, D3DFONT_BOLD );
  108.     m_pShinyTeapot      = new CD3DMesh();
  109.     m_pSkyBox           = new CD3DMesh();
  110.     m_pAirplane         = new CD3DMesh();
  111.     m_pCubeMap          = NULL;
  112.     m_pCubeFaceZBuffer  = NULL;
  113. }
  114.  
  115.  
  116.  
  117.  
  118. //-----------------------------------------------------------------------------
  119. // Name: OneTimeSceneInit()
  120. // Desc: Called during initial app startup, this function performs all the
  121. //       permanent initialization.
  122. //-----------------------------------------------------------------------------
  123. HRESULT CMyD3DApplication::OneTimeSceneInit()
  124. {
  125.     return S_OK;
  126. }
  127.  
  128.  
  129.  
  130.  
  131. //-----------------------------------------------------------------------------
  132. // Name: FrameMove()
  133. // Desc: Called once per frame, the call is the entry point for animating
  134. //       the scene.
  135. //-----------------------------------------------------------------------------
  136. HRESULT CMyD3DApplication::FrameMove()
  137. {
  138.     // Animate file object
  139.     D3DXMATRIX  mat1;
  140.     D3DXMatrixScaling( &m_matAirplane, 0.2f, 0.2f, 0.2f );
  141.     D3DXMatrixTranslation( &mat1, 0.0f, 2.0f, 0.0f );
  142.     D3DXMatrixMultiply( &m_matAirplane, &m_matAirplane, &mat1 );
  143.     D3DXMatrixRotationX( &mat1, -2.9f*m_fTime );
  144.     D3DXMatrixMultiply( &m_matAirplane, &m_matAirplane, &mat1 );
  145.     D3DXMatrixRotationY( &mat1, 1.055f*m_fTime );
  146.     D3DXMatrixMultiply( &m_matAirplane, &m_matAirplane, &mat1 );
  147.  
  148.     // When the window has focus, let the mouse adjust the camera view
  149.     if( GetFocus() )
  150.     {
  151.         D3DXMATRIX matTrackBall, matTrans, matView;
  152.         D3DXQUATERNION quat = D3DUtil_GetRotationFromCursor( m_hWnd );
  153.         D3DXMatrixRotationQuaternion( &matTrackBall, &quat );
  154.         D3DXMatrixTranslation( &matTrans, 0.0f, 0.0f, 5.0f );
  155.         D3DXMatrixMultiply( &matView, &matTrackBall, &matTrans );
  156.         m_pd3dDevice->SetTransform( D3DTS_VIEW, &matView );
  157.     }
  158.  
  159.     // Render the scene into the surfaces of the cubemap
  160.     if( FAILED( RenderSceneIntoCubeMap() ) )
  161.         return E_FAIL;
  162.  
  163.     return S_OK;
  164. }
  165.  
  166.  
  167.  
  168.  
  169. //-----------------------------------------------------------------------------
  170. // Name: RenderSceneIntoCubeMap()
  171. // Desc: Renders the scene to each of the 6 faces of the cube map
  172. //-----------------------------------------------------------------------------
  173. HRESULT CMyD3DApplication::RenderSceneIntoCubeMap()
  174. {
  175.     // Save transformation matrices of the device
  176.     D3DXMATRIX   matProjSave, matViewSave;
  177.     m_pd3dDevice->GetTransform( D3DTS_VIEW,       &matViewSave );
  178.     m_pd3dDevice->GetTransform( D3DTS_PROJECTION, &matProjSave );
  179.  
  180.     // Set the projection matrix for a field of view of 90 degrees
  181.     D3DXMATRIX matProj;
  182.     D3DXMatrixPerspectiveFovLH( &matProj, D3DX_PI/2, 1.0f, 0.5f, 100.0f );
  183.     m_pd3dDevice->SetTransform( D3DTS_PROJECTION, &matProj );
  184.  
  185.     // Get the current view matrix, to concat it with the cubemap view vectors
  186.     D3DXMATRIX matViewDir;
  187.     m_pd3dDevice->GetTransform( D3DTS_VIEW, &matViewDir );
  188.     matViewDir._41 = 0.0f; matViewDir._42 = 0.0f; matViewDir._43 = 0.0f;
  189.  
  190.     // Store the current backbuffer and zbuffer
  191.     LPDIRECT3DSURFACE8 pBackBuffer, pZBuffer;
  192.     m_pd3dDevice->GetRenderTarget( &pBackBuffer );
  193.     m_pd3dDevice->GetDepthStencilSurface( &pZBuffer );
  194.  
  195.     // Render to the six faces of the cube map
  196.     for( DWORD i=0; i<6; i++ )
  197.     {
  198.         // Set the view transform for this cubemap surface
  199.         D3DXMATRIX matView;
  200.         matView = D3DUtil_GetCubeMapViewMatrix( (D3DCUBEMAP_FACES)i );
  201.         D3DXMatrixMultiply( &matView, &matViewDir, &matView );
  202.         m_pd3dDevice->SetTransform( D3DTS_VIEW, &matView );
  203.  
  204.         // Set the rendertarget to the i'th cubemap surface
  205.         LPDIRECT3DSURFACE8 pCubeMapFace;
  206.         m_pCubeMap->GetCubeMapSurface( (D3DCUBEMAP_FACES)i, 0, &pCubeMapFace );
  207.         m_pd3dDevice->SetRenderTarget( pCubeMapFace, m_pCubeFaceZBuffer);
  208.         pCubeMapFace->Release();
  209.  
  210.         // Render the scene (except for the teapot)
  211.         m_pd3dDevice->BeginScene();
  212.         RenderScene( FALSE );
  213.         m_pd3dDevice->EndScene();
  214.     }
  215.  
  216.     // Change the rendertarget back to the main backbuffer
  217.     m_pd3dDevice->SetRenderTarget( pBackBuffer, pZBuffer );
  218.     pBackBuffer->Release();
  219.     pZBuffer->Release();
  220.  
  221.     // Restore the original transformation matrices
  222.     m_pd3dDevice->SetTransform( D3DTS_VIEW,       &matViewSave );
  223.     m_pd3dDevice->SetTransform( D3DTS_PROJECTION, &matProjSave );
  224.  
  225.     return S_OK;
  226. }
  227.  
  228.  
  229.  
  230.  
  231. //-----------------------------------------------------------------------------
  232. // Name: RenderScene()
  233. // Desc: Renders all visual elements in the scene. This is called by the main
  234. //       Render() function, and also by the RenderIntoCubeMap() function.
  235. //-----------------------------------------------------------------------------
  236. HRESULT CMyD3DApplication::RenderScene( BOOL bRenderTeapot )
  237. {
  238.     // Clear the viewport
  239.     m_pd3dDevice->Clear( 0L, NULL, D3DCLEAR_ZBUFFER, 0x000000ff, 1.0f, 0L );
  240.  
  241.     // Set the texture stage states
  242.     m_pd3dDevice->SetTextureStageState( 0, D3DTSS_COLORARG1, D3DTA_TEXTURE );
  243.     m_pd3dDevice->SetTextureStageState( 0, D3DTSS_COLOROP,   D3DTOP_SELECTARG1 );
  244.     m_pd3dDevice->SetTextureStageState( 0, D3DTSS_MINFILTER, D3DTEXF_LINEAR );
  245.     m_pd3dDevice->SetTextureStageState( 0, D3DTSS_MAGFILTER, D3DTEXF_LINEAR );
  246.     m_pd3dDevice->SetTextureStageState( 0, D3DTSS_ADDRESSU,  D3DTADDRESS_MIRROR );
  247.     m_pd3dDevice->SetTextureStageState( 0, D3DTSS_ADDRESSV,  D3DTADDRESS_MIRROR );
  248.  
  249.     // Render the Skybox
  250.     {
  251.         // Save the current matrix set
  252.         D3DXMATRIX matViewSave, matProjSave;
  253.         m_pd3dDevice->GetTransform( D3DTS_VIEW,       &matViewSave );
  254.         m_pd3dDevice->GetTransform( D3DTS_PROJECTION, &matProjSave );
  255.  
  256.         // Disable zbuffer, center view matrix, and set FOV to 90 degrees
  257.         D3DXMATRIX matView = matViewSave;
  258.         D3DXMATRIX matProj = matViewSave;
  259.         matView._41 = matView._42 = matView._43 = 0.0f;
  260.         D3DXMatrixPerspectiveFovLH( &matProj, D3DX_PI/2, 1.0f, 0.5f, 10000.0f );
  261.         m_pd3dDevice->SetTransform( D3DTS_PROJECTION, &matProj );
  262.         m_pd3dDevice->SetTransform( D3DTS_VIEW,       &matView );
  263.         m_pd3dDevice->SetRenderState( D3DRS_ZENABLE,  FALSE );
  264.  
  265.         // Render the skybox
  266.         D3DXMATRIX matWorld;
  267.         D3DXMatrixIdentity( &matWorld );
  268.         m_pd3dDevice->SetTransform( D3DTS_WORLD, &matWorld );
  269.         m_pSkyBox->Render( m_pd3dDevice );
  270.  
  271.         // Restore the render states
  272.         m_pd3dDevice->SetTransform( D3DTS_VIEW,       &matViewSave );
  273.         m_pd3dDevice->SetTransform( D3DTS_PROJECTION, &matProjSave );
  274.         m_pd3dDevice->SetRenderState( D3DRS_ZENABLE,  TRUE );
  275.     }
  276.  
  277.     // Render the main file-based object
  278.     {
  279.         m_pd3dDevice->SetTransform( D3DTS_WORLD, &m_matAirplane );
  280.         m_pAirplane->Render( m_pd3dDevice );
  281.     }
  282.  
  283.     // Render the object with the environment-mapped body
  284.     if( bRenderTeapot )
  285.     {
  286.         D3DXMATRIX matWorld;
  287.         D3DXMatrixIdentity( &matWorld );
  288.         m_pd3dDevice->SetTransform( D3DTS_WORLD, &matWorld );
  289.  
  290.         // Turn on texture-coord generation for cubemapping
  291.         m_pd3dDevice->SetTextureStageState( 0, D3DTSS_TEXCOORDINDEX, D3DTSS_TCI_CAMERASPACEREFLECTIONVECTOR );
  292.         m_pd3dDevice->SetTextureStageState( 0, D3DTSS_TEXTURETRANSFORMFLAGS, D3DTTFF_COUNT3 );
  293.  
  294.         // Render the object with the environment-mapped body
  295.         m_pd3dDevice->SetTexture( 0, m_pCubeMap );
  296.         m_pShinyTeapot->Render( m_pd3dDevice );
  297.  
  298.         // Restore the render states
  299.         m_pd3dDevice->SetTextureStageState( 0, D3DTSS_TEXCOORDINDEX, D3DTSS_TCI_PASSTHRU );
  300.         m_pd3dDevice->SetTextureStageState( 0, D3DTSS_TEXTURETRANSFORMFLAGS, D3DTTFF_DISABLE );
  301.     }
  302.  
  303.     return S_OK;
  304. }
  305.  
  306.  
  307.  
  308.  
  309. //-----------------------------------------------------------------------------
  310. // Name: Render()
  311. // Desc: Called once per frame, the call is the entry point for 3d
  312. //       rendering. This function sets up render states, clears the
  313. //       viewport, and renders the scene.
  314. //-----------------------------------------------------------------------------
  315. HRESULT CMyD3DApplication::Render()
  316. {
  317.     // Begin the scene
  318.     if( SUCCEEDED( m_pd3dDevice->BeginScene() ) )
  319.     {
  320.         // Render the scene, including the teapot
  321.         RenderScene( TRUE );
  322.  
  323.         // Output statistics
  324.         m_pFont->DrawText( 2,  0, D3DCOLOR_ARGB(255,255,255,0), m_strFrameStats );
  325.         m_pFont->DrawText( 2, 20, D3DCOLOR_ARGB(255,255,255,0), m_strDeviceStats );
  326.  
  327.         // End the scene.
  328.         m_pd3dDevice->EndScene();
  329.     }
  330.  
  331.     return S_OK;
  332. }
  333.  
  334.  
  335.  
  336.  
  337. //-----------------------------------------------------------------------------
  338. // Name: InitDeviceObjects()
  339. // Desc: Initialize scene objects.
  340. //-----------------------------------------------------------------------------
  341. HRESULT CMyD3DApplication::InitDeviceObjects()
  342. {
  343.     // Load the file objects
  344.     if( FAILED( m_pShinyTeapot->Create( m_pd3dDevice, _T("teapot.x") ) ) )
  345.         return D3DAPPERR_MEDIANOTFOUND;
  346.     if( FAILED( m_pSkyBox->Create( m_pd3dDevice, _T("lobby_skybox.x") ) ) )
  347.         return D3DAPPERR_MEDIANOTFOUND;
  348.     if( FAILED( m_pAirplane->Create( m_pd3dDevice, _T("airplane 2.x") ) ) )
  349.         return D3DAPPERR_MEDIANOTFOUND;
  350.  
  351.     // Set mesh properties
  352.     m_pAirplane->SetFVF( m_pd3dDevice, D3DFVF_XYZ|D3DFVF_NORMAL|D3DFVF_TEX1 );
  353.     m_pShinyTeapot->SetFVF( m_pd3dDevice, D3DFVF_ENVMAPVERTEX );
  354.     m_pShinyTeapot->UseMeshMaterials( FALSE );
  355.  
  356.     // Restore the device-dependent objects
  357.     m_pFont->InitDeviceObjects( m_pd3dDevice );
  358.  
  359.     return S_OK;
  360. }
  361.  
  362.  
  363.  
  364.  
  365. //-----------------------------------------------------------------------------
  366. // Name: RestoreDeviceObjects()
  367. // Desc: Restore device-memory objects and state after a device is created or
  368. //       resized.
  369. //-----------------------------------------------------------------------------
  370. HRESULT CMyD3DApplication::RestoreDeviceObjects()
  371. {
  372.     HRESULT hr;
  373.  
  374.     // InitDeviceObjects for file objects (build textures and vertex buffers)
  375.     m_pShinyTeapot->RestoreDeviceObjects( m_pd3dDevice );
  376.     m_pSkyBox->RestoreDeviceObjects( m_pd3dDevice );
  377.     m_pAirplane->RestoreDeviceObjects( m_pd3dDevice );
  378.     m_pFont->RestoreDeviceObjects();
  379.  
  380.     // Create the cubemap, with a format that matches the backbuffer, since
  381.     // we'll be rendering into it
  382.     if( FAILED( hr = m_pd3dDevice->CreateCubeTexture( CUBEMAP_RESOLUTION, 1, D3DUSAGE_RENDERTARGET,
  383.                                                       m_d3dsdBackBuffer.Format,
  384.                                                       D3DPOOL_DEFAULT, &m_pCubeMap ) ) )
  385.         return E_FAIL;
  386.  
  387.     // We create a separate Z buffer for the cube faces, because user could 
  388.     // resize rendering window so that it is smaller than a cube face. In 
  389.     // this case we cannot use the rendering window Z buffer for cube faces.
  390.     if( FAILED( hr = m_pd3dDevice->CreateDepthStencilSurface(
  391.                 CUBEMAP_RESOLUTION, CUBEMAP_RESOLUTION, 
  392.                 D3DFMT_D16, D3DMULTISAMPLE_NONE, &m_pCubeFaceZBuffer) ) )
  393.         return E_FAIL;
  394.  
  395.     // Set default render states
  396.     m_pd3dDevice->SetRenderState( D3DRS_ZENABLE,  TRUE );
  397.     m_pd3dDevice->SetRenderState( D3DRS_AMBIENT,  0x00aaaaaa );
  398.     m_pd3dDevice->SetRenderState( D3DRS_LIGHTING, TRUE );
  399.  
  400.     // Set the transform matrices
  401.     D3DXMATRIX matProj;
  402.     FLOAT fAspect = m_d3dsdBackBuffer.Width / (FLOAT)m_d3dsdBackBuffer.Height;
  403.     D3DXMatrixPerspectiveFovLH( &matProj, D3DX_PI/4, fAspect, 0.5f, 100.0f );
  404.     m_pd3dDevice->SetTransform( D3DTS_PROJECTION, &matProj );
  405.  
  406.     // Setup a material
  407.     D3DMATERIAL8 mtrl;
  408.     D3DUtil_InitMaterial( mtrl, 1.0f, 1.0f, 1.0f, 1.0f );
  409.     m_pd3dDevice->SetMaterial( &mtrl );
  410.  
  411.     // Set up a light
  412.     if( m_d3dCaps.VertexProcessingCaps & D3DVTXPCAPS_DIRECTIONALLIGHTS )
  413.     {
  414.         D3DLIGHT8 light;
  415.         D3DUtil_InitLight( light, D3DLIGHT_DIRECTIONAL, 0.0f, 0.0f, 1.0f );
  416.         light.Ambient.r = 0.3f;
  417.         light.Ambient.g = 0.3f;
  418.         light.Ambient.b = 0.3f;
  419.         m_pd3dDevice->SetLight( 0, &light );
  420.         m_pd3dDevice->LightEnable( 0, TRUE );
  421.         m_pd3dDevice->SetRenderState( D3DRS_LIGHTING, TRUE );
  422.     }
  423.  
  424.     return S_OK;
  425. }
  426.  
  427.  
  428.  
  429.  
  430. //-----------------------------------------------------------------------------
  431. // Name: InvalidateDeviceObjects()
  432. // Desc: Called when the device-dependent objects are about to be lost.
  433. //-----------------------------------------------------------------------------
  434. HRESULT CMyD3DApplication::InvalidateDeviceObjects()
  435. {
  436.     m_pShinyTeapot->InvalidateDeviceObjects();
  437.     m_pSkyBox->InvalidateDeviceObjects();
  438.     m_pAirplane->InvalidateDeviceObjects();
  439.     m_pFont->InvalidateDeviceObjects();
  440.  
  441.     SAFE_RELEASE( m_pCubeMap );
  442.     SAFE_RELEASE( m_pCubeFaceZBuffer );
  443.  
  444.     return S_OK;
  445. }
  446.  
  447.  
  448.  
  449.  
  450. //-----------------------------------------------------------------------------
  451. // Name: DeleteDeviceObjects()
  452. // Desc: Called when the app is exiting, or the device is being changed,
  453. //       this function deletes any device dependent objects.
  454. //-----------------------------------------------------------------------------
  455. HRESULT CMyD3DApplication::DeleteDeviceObjects()
  456. {
  457.     m_pFont->DeleteDeviceObjects();
  458.  
  459.     m_pShinyTeapot->Destroy();
  460.     m_pSkyBox->Destroy();
  461.     m_pAirplane->Destroy();
  462.  
  463.     return S_OK;
  464. }
  465.  
  466.  
  467.  
  468.  
  469. //-----------------------------------------------------------------------------
  470. // Name: FinalCleanup()
  471. // Desc: Called before the app exits, this function gives the app the chance
  472. //       to cleanup after itself.
  473. //-----------------------------------------------------------------------------
  474. HRESULT CMyD3DApplication::FinalCleanup()
  475. {
  476.     SAFE_DELETE( m_pFont );
  477.     SAFE_DELETE( m_pShinyTeapot );
  478.     SAFE_DELETE( m_pSkyBox );
  479.     SAFE_DELETE( m_pAirplane );
  480.  
  481.     return S_OK;
  482. }
  483.  
  484.  
  485.  
  486.  
  487. //-----------------------------------------------------------------------------
  488. // Name: ConfirmDevice()
  489. // Desc: Called during device intialization, this code checks the device
  490. //       for some minimum set of capabilities
  491. //-----------------------------------------------------------------------------
  492. HRESULT CMyD3DApplication::ConfirmDevice( D3DCAPS8* pCaps, DWORD dwBehavior,
  493.                                           D3DFORMAT Format )
  494. {
  495.     if( dwBehavior & D3DCREATE_PUREDEVICE )
  496.         return E_FAIL; // GetTransform doesn't work on PUREDEVICE
  497.  
  498.     // Check for cubemapping devices
  499.     if( 0 == ( pCaps->TextureCaps & D3DPTEXTURECAPS_CUBEMAP ) )
  500.         return E_FAIL;
  501.  
  502.     // Check that we can create a cube texture that we can render into
  503.     if( FAILED( m_pD3D->CheckDeviceFormat( pCaps->AdapterOrdinal, 
  504.         pCaps->DeviceType, Format, D3DUSAGE_RENDERTARGET,
  505.         D3DRTYPE_CUBETEXTURE, Format ) ) )
  506.     {
  507.        return E_FAIL;
  508.     }
  509.  
  510.     return S_OK;
  511. }
  512.  
  513.  
  514.  
  515.