コード例 #1
0
void CDxtexDoc::OnFormatChangeCubeMapFaces() 
{
    HRESULT hr;
    LPDIRECT3DDEVICE9 pd3ddev = PDxtexApp()->Pd3ddev();
    D3DSURFACE_DESC sd;
    LPDIRECT3DCUBETEXTURE9 ptexCube;
    DWORD iLevel;
    LPDIRECT3DSURFACE9 psurfSrc;
    LPDIRECT3DSURFACE9 psurfDest;

    CCubeMapDlg cubeMapDlg;
    if (IDCANCEL == cubeMapDlg.DoModal())
        return;
    
    // Change m_ptexOrig into a cubemap
    ((LPDIRECT3DTEXTURE9)m_ptexOrig)->GetLevelDesc(0, &sd);
    hr = D3DXCreateCubeTexture(pd3ddev, m_dwWidth, m_numMips, 0, sd.Format, D3DPOOL_MANAGED, &ptexCube);
    for (iLevel = 0; iLevel < m_numMips; iLevel++)
    {
        hr = ((LPDIRECT3DTEXTURE9)m_ptexOrig)->GetSurfaceLevel(iLevel, &psurfSrc);
        hr = ptexCube->GetCubeMapSurface((D3DCUBEMAP_FACES)cubeMapDlg.m_iFace, iLevel, &psurfDest);
        hr = D3DXLoadSurfaceFromSurface(psurfDest, NULL, NULL, 
            psurfSrc, NULL, NULL, D3DX_DEFAULT, 0);
        ReleasePpo(&psurfSrc);
        ReleasePpo(&psurfDest);
    }
    ReleasePpo(&m_ptexOrig);
    m_ptexOrig = ptexCube;

    // Change m_ptexNew into a cubemap too
    if (m_ptexNew != NULL)
    {
        ((LPDIRECT3DTEXTURE9)m_ptexNew)->GetLevelDesc(0, &sd);
        hr = D3DXCreateCubeTexture(pd3ddev, m_dwWidth, m_numMips, 0, sd.Format, D3DPOOL_MANAGED, &ptexCube);
        for (iLevel = 0; iLevel < m_numMips; iLevel++)
        {
            hr = ((LPDIRECT3DTEXTURE9)m_ptexNew)->GetSurfaceLevel(iLevel, &psurfSrc);
            hr = ptexCube->GetCubeMapSurface((D3DCUBEMAP_FACES)cubeMapDlg.m_iFace, iLevel, &psurfDest);
            hr = D3DXLoadSurfaceFromSurface(psurfDest, NULL, NULL, 
                psurfSrc, NULL, NULL, D3DX_DEFAULT, 0);
            ReleasePpo(&psurfSrc);
            ReleasePpo(&psurfDest);
        }
        ReleasePpo(&m_ptexNew);
        m_ptexNew = ptexCube;
    }
    m_dwCubeMapFlags = DDS_CUBEMAP_ALLFACES;
    SetModifiedFlag();
    UpdateAllViews(NULL, 1); // tell CView to pick up new surface pointers
}
コード例 #2
0
////////////////////////////////////////////////////////////////
//
// CFileTextureItem::CreateUnderlyingData
//
// Blank sized
//
////////////////////////////////////////////////////////////////
void CFileTextureItem::CreateUnderlyingData(bool bMipMaps, uint uiSizeX, uint uiSizeY, ERenderFormat format, ETextureType textureType, uint uiVolumeDepth)
{
    assert(!m_pD3DTexture);

    D3DFORMAT D3DFormat = (D3DFORMAT)format;
    int       iMipMaps = bMipMaps ? D3DX_DEFAULT : 1;

    m_uiSizeX = uiSizeX;
    m_uiSizeY = uiSizeY;
    m_uiSurfaceSizeX = uiSizeX;
    m_uiSurfaceSizeY = uiSizeY;

    if (textureType == D3DRTYPE_VOLUMETEXTURE)
    {
        if (FAILED(D3DXCreateVolumeTexture(m_pDevice,                  //__in   LPDIRECT3DDEVICE9 pDevice,
                                           uiSizeX,                    //__in   UINT Width,
                                           uiSizeY,                    //__in   UINT Height,
                                           uiVolumeDepth,              //__in   UINT Depth,
                                           iMipMaps,                   //__in   UINT MipLevels,
                                           0,                          //__in   DWORD Usage,
                                           D3DFormat,                  //__in   D3DFORMAT Format,
                                           D3DPOOL_MANAGED,            //__in   D3DPOOL Pool,
                                           (IDirect3DVolumeTexture9**)&m_pD3DTexture)))
            return;
    }
    else if (textureType == D3DRTYPE_CUBETEXTURE)
    {
        if (FAILED(D3DXCreateCubeTexture(m_pDevice,                  //__in   LPDIRECT3DDEVICE9 pDevice,
                                         uiSizeX,                    //__in   UINT Width,
                                         iMipMaps,                   //__in   UINT MipLevels,
                                         0,                          //__in   DWORD Usage,
                                         D3DFormat,                  //__in   D3DFORMAT Format,
                                         D3DPOOL_MANAGED,            //__in   D3DPOOL Pool,
                                         (IDirect3DCubeTexture9**)&m_pD3DTexture)))
            return;
    }
    else
    {
        if (FAILED(D3DXCreateTexture(m_pDevice,                  //__in   LPDIRECT3DDEVICE9 pDevice,
                                     uiSizeX,                    //__in   UINT Width,
                                     uiSizeY,                    //__in   UINT Height,
                                     iMipMaps,                   //__in   UINT MipLevels,
                                     0,                          //__in   DWORD Usage,
                                     D3DFormat,                  //__in   D3DFORMAT Format,
                                     D3DPOOL_MANAGED,            //__in   D3DPOOL Pool,
                                     (IDirect3DTexture9**)&m_pD3DTexture)))
            return;

        // Update surface size if it's a normal texture
        D3DSURFACE_DESC desc;
        ((IDirect3DTexture9*)m_pD3DTexture)->GetLevelDesc(0, &desc);
        m_uiSurfaceSizeX = desc.Width;
        m_uiSurfaceSizeY = desc.Height;
    }

    // Calc memory usage
    m_iMemoryKBUsed = CRenderItemManager::CalcD3DResourceMemoryKBUsage(m_pD3DTexture);
}
コード例 #3
0
ファイル: OvRenderer.cpp プロジェクト: ultrano/OliveEngine
OvCubeTextureSPtr OvRenderer::CreateRenderCubeTexture( unsigned size, unsigned level, D3DFORMAT format )
{
	OvCubeTextureSPtr return_texture = NULL;
	OvDevice device = GetDevice();
	if ( device )
	{
		LPDIRECT3DCUBETEXTURE9 cube_texture = NULL;
		HRESULT hs = E_FAIL;
		hs = D3DXCreateCubeTexture( device, size,level, D3DUSAGE_RENDERTARGET, format, D3DPOOL_DEFAULT, &cube_texture );
		if ( SUCCEEDED( hs ) )
		{
			return_texture = OvNew OvCubeTexture( cube_texture, eTexUsage_RenderTarget );
		}
	}
	return return_texture;
}
コード例 #4
0
ファイル: LocalDeformablePRT.cpp プロジェクト: KNeal/Oculus
//--------------------------------------------------------------------------------------
// This function loads a new technique and all device objects it requires.
//--------------------------------------------------------------------------------------
HRESULT LoadTechniqueObjects( const char* szMedia )
{
    HRESULT hr = S_OK;

    if( NULL == g_pEffect )
        return D3DERR_INVALIDCALL;

    IDirect3DTexture9* pTexture = NULL;
    IDirect3DCubeTexture9* pCubeTexture = NULL;

    IDirect3DDevice9* pDevice = DXUTGetD3D9Device();

    WCHAR strFileName[MAX_PATH+1] = {0};
    WCHAR strPath[MAX_PATH+1] = {0};
    char strTechnique[MAX_PATH] = {0};

    // Make sure the technique works
    char* strComboTech = ( char* )g_SampleUI.GetComboBox( IDC_TECHNIQUE )->GetSelectedData();
    strcpy_s( strTechnique, MAX_PATH, strComboTech );
    bool bLDPRT = ( strTechnique && ( 0 == strcmp( strTechnique, "LDPRT" ) ) );

    // If we're not a signed format, make sure we use a technnique that will unbias
    if( D3DFMT_Q16W16V16U16 != g_fmtTexture && D3DFMT_Q8W8V8U8 != g_fmtTexture )
        strcat_s( strTechnique, MAX_PATH, "_Unbias" );

    D3DXHANDLE hTechnique = g_pEffect->GetTechniqueByName( strTechnique );
    V_RETURN( g_pEffect->SetTechnique( hTechnique ) );

    // Enable/disable LDPRT-only items
    g_SampleUI.GetStatic( IDC_ENV_LABEL )->SetEnabled( bLDPRT );
    g_SampleUI.GetSlider( IDC_ENV_SLIDER )->SetEnabled( bLDPRT );
    g_SampleUI.GetSlider( IDC_RED_TRANSMIT_SLIDER )->SetEnabled( bLDPRT );
    g_SampleUI.GetSlider( IDC_GREEN_TRANSMIT_SLIDER )->SetEnabled( bLDPRT );
    g_SampleUI.GetSlider( IDC_BLUE_TRANSMIT_SLIDER )->SetEnabled( bLDPRT );
    g_SampleUI.GetStatic( IDC_RED_TRANSMIT_LABEL )->SetEnabled( bLDPRT );
    g_SampleUI.GetStatic( IDC_GREEN_TRANSMIT_LABEL )->SetEnabled( bLDPRT );
    g_SampleUI.GetStatic( IDC_BLUE_TRANSMIT_LABEL )->SetEnabled( bLDPRT );

    // Load the mesh
    swprintf_s( strFileName, MAX_PATH, TEXT( "media\\%S" ), szMedia );
    V_RETURN( LoadLDPRTData( pDevice, strFileName ) );

    // Albedo texture
    swprintf_s( strFileName, MAX_PATH, TEXT( "media\\%SAlbedo.dds" ), szMedia );
    DXUTFindDXSDKMediaFileCch( strPath, MAX_PATH, strFileName );
    V( D3DXCreateTextureFromFile( pDevice, strPath, &pTexture ) );
    g_pEffect->SetTexture( "Albedo", pTexture );
    SAFE_RELEASE( pTexture );

    // Normal map 
    swprintf_s( strFileName, MAX_PATH, TEXT( "media\\%SNormalMap.dds" ), szMedia );
    DXUTFindDXSDKMediaFileCch( strPath, MAX_PATH, strFileName );
    V( D3DXCreateTextureFromFileEx( pDevice, strPath, D3DX_DEFAULT, D3DX_DEFAULT, D3DX_DEFAULT, 0,
                                    g_fmtTexture, D3DPOOL_MANAGED, D3DX_DEFAULT, D3DX_DEFAULT, 0,
                                    NULL, NULL, &pTexture ) );
    g_pEffect->SetTexture( "NormalMap", pTexture );
    SAFE_RELEASE( pTexture );

    // Spherical harmonic basic functions
    char* pNames[4] = {"YlmCoeff0","YlmCoeff4","YlmCoeff8","YlmCoeff12"};
    for( int i = 0; i < 4; i++ )
    {
        D3DXCreateCubeTexture( pDevice, 32, 1, 0, g_fmtCubeMap, D3DPOOL_MANAGED, &pCubeTexture );
        D3DXFillCubeTexture( pCubeTexture, myFillBF, ( LPVOID )( INT_PTR )( i * 4 ) );
        g_pEffect->SetTexture( pNames[i], pCubeTexture );
        SAFE_RELEASE( pCubeTexture );
    }

    return S_OK;
}
コード例 #5
0
ファイル: LocalDeformablePRT.cpp プロジェクト: KNeal/Oculus
//--------------------------------------------------------------------------------------
// This callback function will be called immediately after the Direct3D device has been 
// created, which will happen during application initialization and windowed/full screen 
// toggles. This is the best location to create D3DPOOL_MANAGED resources since these 
// resources need to be reloaded whenever the device is destroyed. Resources created  
// here should be released in the OnDestroyDevice callback. 
//--------------------------------------------------------------------------------------
HRESULT CALLBACK OnCreateDevice( IDirect3DDevice9* pd3dDevice, const D3DSURFACE_DESC* pBackBufferSurfaceDesc,
                                 void* pUserContext )
{
    HRESULT hr;


    V_RETURN( g_DialogResourceManager.OnD3D9CreateDevice( pd3dDevice ) );
    V_RETURN( g_SettingsDlg.OnD3D9CreateDevice( pd3dDevice ) );
    // Initialize the font
    V_RETURN( D3DXCreateFont( pd3dDevice, 15, 0, FW_BOLD, 1, FALSE, DEFAULT_CHARSET,
                              OUT_DEFAULT_PRECIS, DEFAULT_QUALITY, DEFAULT_PITCH | FF_DONTCARE,
                              L"Arial", &g_pFont ) );

    // Define DEBUG_VS and/or DEBUG_PS to debug vertex and/or pixel shaders with the 
    // shader debugger. Debugging vertex shaders requires either REF or software vertex 
    // processing, and debugging pixel shaders requires REF.  The 
    // D3DXSHADER_FORCE_*_SOFTWARE_NOOPT flag improves the debug experience in the 
    // shader debugger.  It enables source level debugging, prevents instruction 
    // reordering, prevents dead code elimination, and forces the compiler to compile 
    // against the next higher available software target, which ensures that the 
    // unoptimized shaders do not exceed the shader model limitations.  Setting these 
    // flags will cause slower rendering since the shaders will be unoptimized and 
    // forced into software.  See the DirectX documentation for more information about 
    // using the shader debugger.
    DWORD dwShaderFlags = D3DXFX_NOT_CLONEABLE;

#if defined( DEBUG ) || defined( _DEBUG )
    // Set the D3DXSHADER_DEBUG flag to embed debug information in the shaders.
    // Setting this flag improves the shader debugging experience, but still allows 
    // the shaders to be optimized and to run exactly the way they will run in 
    // the release configuration of this program.
    dwShaderFlags |= D3DXSHADER_DEBUG;
    #endif

#ifdef DEBUG_VS
    dwShaderFlags |= D3DXSHADER_FORCE_VS_SOFTWARE_NOOPT;
#endif
#ifdef DEBUG_PS
    dwShaderFlags |= D3DXSHADER_FORCE_PS_SOFTWARE_NOOPT;
#endif

    // Determine which LDPRT texture and SH coefficient cubemap formats are supported
    IDirect3D9* pD3D = DXUTGetD3D9Object();
    D3DCAPS9 Caps;
    pd3dDevice->GetDeviceCaps( &Caps );
    D3DDISPLAYMODE DisplayMode;
    pd3dDevice->GetDisplayMode( 0, &DisplayMode );

    GetSupportedTextureFormat( pD3D, &Caps, DisplayMode.Format, &g_fmtTexture, &g_fmtCubeMap );
    if( D3DFMT_UNKNOWN == g_fmtTexture || D3DFMT_UNKNOWN == g_fmtCubeMap )
        return E_FAIL;

    // Create the skybox
    g_Skybox.OnCreateDevice( pd3dDevice, 50, L"Light Probes\\rnl_cross.dds", L"SkyBox.fx" );
    V( D3DXSHProjectCubeMap( 6, g_Skybox.GetEnvironmentMap(), g_fSkyBoxLightSH[0], g_fSkyBoxLightSH[1],
                             g_fSkyBoxLightSH[2] ) );

    // Now compute the SH projection of the skybox...
    LPDIRECT3DCUBETEXTURE9 pSHCubeTex = NULL;
    V( D3DXCreateCubeTexture( pd3dDevice, 256, 1, 0, D3DFMT_A16B16G16R16F, D3DPOOL_MANAGED, &pSHCubeTex ) );

    SHCubeProj projData;
    projData.Init( g_fSkyBoxLightSH[0], g_fSkyBoxLightSH[1], g_fSkyBoxLightSH[2] );

    V( D3DXFillCubeTexture( pSHCubeTex, SHCubeFill, &projData ) );
    g_Skybox.InitSH( pSHCubeTex );

    // Read the D3DX effect file
    WCHAR str[MAX_PATH];
    V_RETURN( DXUTFindDXSDKMediaFileCch( str, MAX_PATH, TEXT( "LocalDeformablePRT.fx" ) ) );

    // If this fails, there should be debug output as to they the .fx file failed to compile
    V_RETURN( D3DXCreateEffectFromFile( pd3dDevice, str, NULL, NULL, dwShaderFlags, NULL, &g_pEffect, NULL ) );

    V_RETURN( LoadTechniqueObjects( "bat" ) );

    V_RETURN( g_LightControl.StaticOnD3D9CreateDevice( pd3dDevice ) );
    g_LightControl.SetRadius( 2.0f );

    // Setup the camera's view parameters
    D3DXVECTOR3 vecEye( 0.0f, 0.0f, -5.0f );
    D3DXVECTOR3 vecAt ( 0.0f, 0.0f, 0.0f );
    g_Camera.SetViewParams( &vecEye, &vecAt );

    // Set the model's initial orientation
    D3DXQUATERNION quatRotation;
    D3DXQuaternionRotationYawPitchRoll( &quatRotation, -0.5f, 0.7f, 0.0f );
    g_Camera.SetWorldQuat( quatRotation );

    return hr;
}
コード例 #6
0
ファイル: render.cpp プロジェクト: Thyfate/melax
void initcube()
{
	D3DXCreateCubeTexture( g_pd3dDevice, 256, 1,D3DUSAGE_RENDERTARGET, D3DFMT_X8R8G8B8  , D3DPOOL_DEFAULT, &CubeMap ) && VERIFY_RESULT;
	D3DXCreateRenderToEnvMap( g_pd3dDevice, 256, 1, D3DFMT_X8R8G8B8, TRUE, D3DFMT_D24S8, &RenderToEnvMap )  && VERIFY_RESULT;

}
コード例 #7
0
ファイル: CWaterApp.cpp プロジェクト: grakidov/Render3D
//-----------------------------------------------------------------------------
// Name: InitDeviceObjects
// Desc:
//-----------------------------------------------------------------------------
HRESULT CMyD3DApplication::InitDeviceObjects()
{
    HRESULT hr;
    TCHAR sz[512];

    m_bDrawWater        = TRUE;
    m_bDrawCaustics     = TRUE;
    m_bDrawEnvironment  = TRUE;


    // Initialize the font's internal textures
    m_pFont->InitDeviceObjects( m_pd3dDevice );
    m_pFontSmall->InitDeviceObjects( m_pd3dDevice );

    // Floor
    DXUtil_FindMediaFile(sz, _T("Water.bmp"));
    D3DXCreateTextureFromFileEx(m_pd3dDevice, sz, D3DX_DEFAULT, D3DX_DEFAULT, 
        D3DX_DEFAULT, 0, D3DFMT_UNKNOWN, D3DPOOL_MANAGED, D3DX_DEFAULT, 
        D3DX_DEFAULT, 0, NULL, NULL, &m_pFloorTex);


    // Sky
    TCHAR* szSkyTex[6] =
    {
        _T("lobbyxpos.bmp"), _T("lobbyxneg.bmp"),
        _T("lobbyypos.bmp"), _T("lobbyyneg.bmp"),
        _T("lobbyzneg.bmp"), _T("lobbyzpos.bmp")
    };

    for(UINT i = 0; i < 6; i++)
    {
        DXUtil_FindMediaFile(sz, szSkyTex[i]);
        D3DXCreateTextureFromFileEx(m_pd3dDevice, sz, D3DX_DEFAULT, D3DX_DEFAULT, 
            1, 0, D3DFMT_UNKNOWN, D3DPOOL_MANAGED, D3DX_DEFAULT, D3DX_DEFAULT, 
            0, NULL, NULL, &m_pSkyTex[i]);
    }

    if(SUCCEEDED(D3DXCreateCubeTexture(m_pd3dDevice, 128, D3DX_DEFAULT, 0, D3DFMT_UNKNOWN, D3DPOOL_MANAGED, &m_pSkyCubeTex)))
    {
        for(UINT i = 0; i < 6; i++)
        {
            if(m_pSkyTex[i])
            {
                IDirect3DSurface8 *pSrc;
                IDirect3DSurface8 *pDest;

                m_pSkyTex[i]->GetSurfaceLevel(0, &pSrc);
                m_pSkyCubeTex->GetCubeMapSurface((D3DCUBEMAP_FACES) i, 0, &pDest);

                if(pSrc && pDest)
                    D3DXLoadSurfaceFromSurface(pDest, NULL, NULL, pSrc, NULL, NULL, D3DX_DEFAULT, 0);

                SAFE_RELEASE(pDest);
                SAFE_RELEASE(pSrc);
            }
        }

        D3DXFilterCubeTexture(m_pSkyCubeTex, NULL, 0, D3DX_DEFAULT);
    }



    // OnCreateDevice
    if(FAILED(hr = m_Water.OnCreateDevice(m_pd3dDevice)))
        return hr;

    if(FAILED(hr = m_Environment.OnCreateDevice(m_pd3dDevice)))
        return hr;

    return S_OK;
}
コード例 #8
0
void CRenderLib::m_BuildNormalizationCubemap(int32 pixelDim, int32 mipmapLevels)
{
  HRESULT hr;
  uint32 i, y, x;

  /*hr = p_Device->CreateCubeTexture(pixelDim, mipmapLevels, 0,
	                               D3DFMT_X8R8G8B8, D3DPOOL_MANAGED,
								   &p_NormalizationCubeMapTexture);*/
  hr=D3DXCreateCubeTexture(p_Device, pixelDim, mipmapLevels,
	                    0, D3DFMT_X8R8G8B8, D3DPOOL_MANAGED,
						&p_NormalizationCubeMapTexture);

  if (hr != D3D_OK)
    m_D3DError(hr, "Normalization CubeMap can't be created!");


  for (i=0; i<6; i++)
  {
     D3DLOCKED_RECT Locked;
     AD_Vect3D Normal;
     float4 w, h;
     D3DSURFACE_DESC ddsdDesc;
		
     p_NormalizationCubeMapTexture->GetLevelDesc(0, &ddsdDesc);
     p_NormalizationCubeMapTexture->LockRect((D3DCUBEMAP_FACES)i, 0, &Locked, NULL, 0);

     for (y=0; y<ddsdDesc.Height; y++)
	 {
        h = (float4)y / ((float4)(ddsdDesc.Height - 1));
        h *= 2.0f;
        h -= 1.0f;

        for (x=0; x<ddsdDesc.Width; x++)
		{
           w = (float4)x / ((float4)(ddsdDesc.Width - 1));
           w *= 2.0f;
           w -= 1.0f;
           DWORD* pBits = (DWORD*)((BYTE*)Locked.pBits + (y * Locked.Pitch));
           pBits += x;
           switch((D3DCUBEMAP_FACES)i)
		   {
              case D3DCUBEMAP_FACE_POSITIVE_X:
                        vect_set(&Normal, 1.0f, -h, -w);
						break;
              case D3DCUBEMAP_FACE_NEGATIVE_X:
						vect_set(&Normal, -1.0f, -h, w);
						break;
              case D3DCUBEMAP_FACE_POSITIVE_Y:
                        vect_set(&Normal, w, 1.0f, h);
						break;
              case D3DCUBEMAP_FACE_NEGATIVE_Y:
                        vect_set(&Normal, w, -1.0f, -h);
						break;
              case D3DCUBEMAP_FACE_POSITIVE_Z:
                        vect_set(&Normal, w, -h, 1.0f);
						break;
              case D3DCUBEMAP_FACE_NEGATIVE_Z:
                        vect_set(&Normal, -w, -h, -1.0f);
						break;
		   }
           vect_auto_normalize(&Normal);
           // Scale to be a color from 0 to 255 (127 is 0)
		   Normal.x=(Normal.x+1)*127.0f;
		   Normal.y=(Normal.y+1)*127.0f;
		   Normal.z=(Normal.z+1)*127.0f;
           *pBits = (DWORD)(((DWORD)Normal.x << 16) | ((DWORD)Normal.y << 8) | ((DWORD)Normal.z));
		}
	 }
     p_NormalizationCubeMapTexture->UnlockRect((D3DCUBEMAP_FACES)i, 0);
     
	 if (mipmapLevels>1)
	   hr=D3DXFilterTexture(p_NormalizationCubeMapTexture, NULL, 0, D3DX_FILTER_TRIANGLE);
  }
}
コード例 #9
0
ファイル: ScalingEffect.cpp プロジェクト: magicseb/fbanext
HRESULT ScalingEffect::ParseParameters(LPD3DXEFFECTCOMPILER lpEffectCompiler)
{
    HRESULT hr = S_OK;

    if(m_pEffect == NULL)
        return E_FAIL;

    // Look at parameters for semantics and annotations that we know how to interpret
    D3DXPARAMETER_DESC ParamDesc;
    D3DXPARAMETER_DESC AnnotDesc;
    D3DXHANDLE hParam;
    D3DXHANDLE hAnnot;
    LPDIRECT3DBASETEXTURE9 pTex = NULL;

    for(UINT iParam = 0; iParam < m_EffectDesc.Parameters; iParam++) {
        LPCSTR pstrName = NULL;
        LPCSTR pstrFunction = NULL;
        LPCSTR pstrTarget = NULL;
        LPCSTR pstrTextureType = NULL;
        INT Width = D3DX_DEFAULT;
        INT Height= D3DX_DEFAULT;
        INT Depth = D3DX_DEFAULT;

        hParam = m_pEffect->GetParameter(NULL, iParam);
        m_pEffect->GetParameterDesc(hParam, &ParamDesc);

	if(ParamDesc.Semantic != NULL) {
	    if(ParamDesc.Class == D3DXPC_MATRIX_ROWS || ParamDesc.Class == D3DXPC_MATRIX_COLUMNS) {
		if(strcmpi(ParamDesc.Semantic, "world") == 0)
		    m_MatWorldEffectHandle = hParam;
		else if(strcmpi(ParamDesc.Semantic, "view") == 0)
		    m_MatViewEffectHandle = hParam;
		else if(strcmpi(ParamDesc.Semantic, "projection") == 0)
		    m_MatProjEffectHandle = hParam;
		else if(strcmpi(ParamDesc.Semantic, "worldview") == 0)
		    m_MatWorldViewEffectHandle = hParam;
		else if(strcmpi(ParamDesc.Semantic, "viewprojection") == 0)
		    m_MatViewProjEffectHandle = hParam;
		else if(strcmpi(ParamDesc.Semantic, "worldviewprojection") == 0)
		    m_MatWorldViewProjEffectHandle = hParam;
	    }

	    else if(ParamDesc.Class == D3DXPC_VECTOR && ParamDesc.Type == D3DXPT_FLOAT) {
		if(strcmpi(ParamDesc.Semantic, "sourcedims") == 0)
		    m_SourceDimsEffectHandle = hParam;
		else if(strcmpi(ParamDesc.Semantic, "texelsize") == 0)
		    m_TexelSizeEffectHandle = hParam;
	    }

	    else if(ParamDesc.Class == D3DXPC_SCALAR && ParamDesc.Type == D3DXPT_FLOAT) {
		if(strcmpi(ParamDesc.Semantic, "SCALING") == 0)
		    m_pEffect->GetFloat(hParam, &m_scale);
	    }

		else if (ParamDesc.Class == D3DXPC_STRUCT) {
		if(strcmpi(ParamDesc.Semantic, "VIDPARAMS") == 0)
		{
		    m_VideoInputHandle = hParam;
			m_VideoSizeHandle = m_pEffect->GetParameterByName(m_VideoInputHandle,"video_size");
			m_TextureSizeHandle = m_pEffect->GetParameterByName(m_VideoInputHandle,"texture_size");
			m_OutputSizeHandle = m_pEffect->GetParameterByName(m_VideoInputHandle,"output_size");
			m_FrameCount = m_pEffect->GetParameterByName(m_VideoInputHandle,"frame_count");
		}

	    }
	


	    else if(ParamDesc.Class == D3DXPC_OBJECT && ParamDesc.Type == D3DXPT_TEXTURE) {
		if(strcmpi(ParamDesc.Semantic, "SOURCETEXTURE") == 0)
		    m_SourceTextureEffectHandle = hParam;
		if(strcmpi(ParamDesc.Semantic, "WORKINGTEXTURE") == 0)
		    m_WorkingTexture1EffectHandle = hParam;
		if(strcmpi(ParamDesc.Semantic, "WORKINGTEXTURE1") == 0)
		    m_WorkingTexture2EffectHandle = hParam;
		if(strcmpi(ParamDesc.Semantic, "HQ2XLOOKUPTEXTURE") == 0)
		    m_Hq2xLookupTextureHandle = hParam;
	    }

	    else if(ParamDesc.Class == D3DXPC_OBJECT && ParamDesc.Type == D3DXPT_STRING) {
	        LPCSTR pstrTechnique = NULL;

		if(strcmpi(ParamDesc.Semantic, "COMBINETECHNIQUE") == 0) {
		    m_pEffect->GetString(hParam, &pstrTechnique);
		    m_CombineTechniqueEffectHandle = m_pEffect->GetTechniqueByName(pstrTechnique);
		}
		else if(strcmpi(ParamDesc.Semantic, "PREPROCESSTECHNIQUE") == 0) {
		    m_pEffect->GetString(hParam, &pstrTechnique);
		    m_PreprocessTechnique1EffectHandle = m_pEffect->GetTechniqueByName(pstrTechnique);
		}
		else if(strcmpi(ParamDesc.Semantic, "PREPROCESSTECHNIQUE1") == 0) {
		    m_pEffect->GetString(hParam, &pstrTechnique);
		    m_PreprocessTechnique2EffectHandle = m_pEffect->GetTechniqueByName(pstrTechnique);
		}
		else if(strcmpi(ParamDesc.Semantic, "NAME") == 0)
		    m_pEffect->GetString(hParam, &m_strName);

	    }
		


	}

	for(UINT iAnnot = 0; iAnnot < ParamDesc.Annotations; iAnnot++) {
            hAnnot = m_pEffect->GetAnnotation (hParam, iAnnot);
            m_pEffect->GetParameterDesc(hAnnot, &AnnotDesc);
            if(strcmpi(AnnotDesc.Name, "name") == 0)
                m_pEffect->GetString(hAnnot, &pstrName);
            else if(strcmpi(AnnotDesc.Name, "function") == 0)
                m_pEffect->GetString(hAnnot, &pstrFunction);
            else if(strcmpi(AnnotDesc.Name, "target") == 0)
                m_pEffect->GetString(hAnnot, &pstrTarget);
            else if(strcmpi(AnnotDesc.Name, "width") == 0)
                m_pEffect->GetInt(hAnnot, &Width);
            else if(strcmpi(AnnotDesc.Name, "height") == 0)
                m_pEffect->GetInt(hAnnot, &Height);
            else if(strcmpi(AnnotDesc.Name, "depth") == 0)
                m_pEffect->GetInt(hAnnot, &Depth);
            else if(strcmpi(AnnotDesc.Name, "type") == 0)
                m_pEffect->GetString(hAnnot, &pstrTextureType);

        }
 
	if(pstrFunction != NULL) {
	    LPD3DXBUFFER pTextureShader = NULL;
	    LPD3DXBUFFER lpErrors = 0;

	    if(pstrTarget == NULL || strcmp(pstrTarget,"tx_1_1"))
                pstrTarget = "tx_1_0";

	    if(SUCCEEDED(hr = lpEffectCompiler->CompileShader(
				hAnnot, pstrTarget,
				0, &pTextureShader, &lpErrors, NULL))) {
		SAFE_RELEASE(lpErrors);

		if(Width == D3DX_DEFAULT)
                    Width = 64;
		if(Height == D3DX_DEFAULT)
                    Height = 64;
		if(Depth == D3DX_DEFAULT)
                    Depth = 64;

#if D3DX_SDK_VERSION >= 22
		LPD3DXTEXTURESHADER ppTextureShader;
		D3DXCreateTextureShader((DWORD *)pTextureShader->GetBufferPointer(), &ppTextureShader);
#endif

		if(pstrTextureType != NULL) {
                    if(strcmpi(pstrTextureType, "volume") == 0) {
                        LPDIRECT3DVOLUMETEXTURE9 pVolumeTex = NULL;
                        if(SUCCEEDED(hr = D3DXCreateVolumeTexture(m_pd3dDevice,
                        	Width, Height, Depth, 1, 0, D3DFMT_A8R8G8B8, D3DPOOL_MANAGED, &pVolumeTex))) {
#if D3DX_SDK_VERSION >= 22
                    	    if(SUCCEEDED(hr = D3DXFillVolumeTextureTX(pVolumeTex, ppTextureShader))) {
#else
                    	    if(SUCCEEDED(hr = D3DXFillVolumeTextureTX(pVolumeTex,
					(DWORD *)pTextureShader->GetBufferPointer(), NULL, 0))) {
#endif
                                pTex = pVolumeTex;
                            }
                        }
                    } else if(strcmpi(pstrTextureType, "cube") == 0) {
                        LPDIRECT3DCUBETEXTURE9 pCubeTex = NULL;
                        if(SUCCEEDED(hr = D3DXCreateCubeTexture(m_pd3dDevice,
                        	Width, D3DX_DEFAULT, 0, D3DFMT_A8R8G8B8, D3DPOOL_MANAGED, &pCubeTex))) {
#if D3DX_SDK_VERSION >= 22
                            if(SUCCEEDED(hr = D3DXFillCubeTextureTX(pCubeTex, ppTextureShader))) {
#else
                            if(SUCCEEDED(hr = D3DXFillCubeTextureTX(pCubeTex,
					(DWORD *)pTextureShader->GetBufferPointer(), NULL, 0))) {
#endif
                                pTex = pCubeTex;
                            }
                        }
                    }
		} else {
                    LPDIRECT3DTEXTURE9 p2DTex = NULL;
                    if(SUCCEEDED(hr = D3DXCreateTexture(m_pd3dDevice, Width, Height,
                    	    D3DX_DEFAULT, 0, D3DFMT_A8R8G8B8, D3DPOOL_MANAGED, &p2DTex))) {
#if D3DX_SDK_VERSION >= 22
                        if(SUCCEEDED(hr = D3DXFillTextureTX(p2DTex, ppTextureShader))) {
#else
                        if(SUCCEEDED(hr = D3DXFillTextureTX(p2DTex,
				(DWORD *)pTextureShader->GetBufferPointer(), NULL, 0))) {
#endif
                            pTex = p2DTex;
                        }
                    }
		}
		m_pEffect->SetTexture(m_pEffect->GetParameter(NULL, iParam), pTex);
		SAFE_RELEASE(pTex);
		SAFE_RELEASE(pTextureShader);
#if D3DX_SDK_VERSION >= 22
		SAFE_RELEASE(ppTextureShader);
#endif
	    } else {
		if(lpErrors) {
		    m_strErrors += (char*) lpErrors->GetBufferPointer();
		}

		m_strErrors += "Could not compile texture shader ";
		m_strErrors += pstrFunction;

		SAFE_RELEASE(lpErrors);
		return hr;
	    }
        }
    }

    return S_OK;
}
コード例 #10
0
HRESULT ScalingEffect::ParseParameters(LPD3DXEFFECTCOMPILER lpEffectCompiler)
{
    HRESULT hr = S_OK;

    if(m_pEffect == NULL)
        return E_FAIL;

    // Look at parameters for semantics and annotations that we know how to interpret
    D3DXPARAMETER_DESC ParamDesc;
    D3DXPARAMETER_DESC AnnotDesc;
    D3DXHANDLE hParam;
    D3DXHANDLE hAnnot;
    LPDIRECT3DBASETEXTURE9 pTex = NULL;

    for(UINT iParam = 0; iParam < m_EffectDesc.Parameters; iParam++) {
        LPCSTR pstrName = NULL;
        LPCSTR pstrFunction = NULL;
        LPCSTR pstrTarget = NULL;
        LPCSTR pstrTextureType = NULL;
        INT Width = D3DX_DEFAULT;
        INT Height= D3DX_DEFAULT;
        INT Depth = D3DX_DEFAULT;

        hParam = m_pEffect->GetParameter(NULL, iParam);
        m_pEffect->GetParameterDesc(hParam, &ParamDesc);

	if(ParamDesc.Semantic != NULL) {
	    if(ParamDesc.Class == D3DXPC_MATRIX_ROWS || ParamDesc.Class == D3DXPC_MATRIX_COLUMNS) {
		if(strcmpi(ParamDesc.Semantic, "world") == 0)
		    m_MatWorldEffectHandle = hParam;
		else if(strcmpi(ParamDesc.Semantic, "view") == 0)
		    m_MatViewEffectHandle = hParam;
		else if(strcmpi(ParamDesc.Semantic, "projection") == 0)
		    m_MatProjEffectHandle = hParam;
		else if(strcmpi(ParamDesc.Semantic, "worldview") == 0)
		    m_MatWorldViewEffectHandle = hParam;
		else if(strcmpi(ParamDesc.Semantic, "viewprojection") == 0)
		    m_MatViewProjEffectHandle = hParam;
		else if(strcmpi(ParamDesc.Semantic, "worldviewprojection") == 0)
		    m_MatWorldViewProjEffectHandle = hParam;
	    }

	    else if(ParamDesc.Class == D3DXPC_VECTOR && ParamDesc.Type == D3DXPT_FLOAT) {
		if(strcmpi(ParamDesc.Semantic, "sourcedims") == 0)
		    m_SourceDimsEffectHandle = hParam;
		else if(strcmpi(ParamDesc.Semantic, "texelsize") == 0)
		    m_TexelSizeEffectHandle = hParam;
		else if(strcmpi(ParamDesc.Semantic, "inputdims") == 0) {
		    if(m_iDim[0] && m_iDim[1] && ((hr = m_pEffect->SetFloatArray(hParam, m_iDim, 2)) != D3D_OK)) {
			m_strErrors += "Could not set inputdims parameter!";
			return hr;
		    }
		}
	    }

	    else if(ParamDesc.Class == D3DXPC_SCALAR && ParamDesc.Type == D3DXPT_FLOAT) {
		if(strcmpi(ParamDesc.Semantic, "SCALING") == 0)
		    m_pEffect->GetFloat(hParam, &m_scale);
	    }

	    else if(ParamDesc.Class == D3DXPC_SCALAR && ParamDesc.Type == D3DXPT_BOOL) {
		if(strcmpi(ParamDesc.Semantic, "FORCEUPDATE") == 0)
		    m_pEffect->GetBool(hParam, &m_forceupdate);
	    }

	    else if(ParamDesc.Class == D3DXPC_OBJECT && ParamDesc.Type == D3DXPT_TEXTURE) {
		if(strcmpi(ParamDesc.Semantic, "SOURCETEXTURE") == 0)
		    m_SourceTextureEffectHandle = hParam;
		if(strcmpi(ParamDesc.Semantic, "WORKINGTEXTURE") == 0)
		    m_WorkingTexture1EffectHandle = hParam;
		if(strcmpi(ParamDesc.Semantic, "WORKINGTEXTURE1") == 0)
		    m_WorkingTexture2EffectHandle = hParam;
		if(strcmpi(ParamDesc.Semantic, "HQ2XLOOKUPTEXTURE") == 0)
		    m_Hq2xLookupTextureHandle = hParam;
	    }

	    else if(ParamDesc.Class == D3DXPC_OBJECT && ParamDesc.Type == D3DXPT_STRING) {
	        LPCSTR pstrTechnique = NULL;

		if(strcmpi(ParamDesc.Semantic, "COMBINETECHNIQUE") == 0) {
		    m_pEffect->GetString(hParam, &pstrTechnique);
		    m_CombineTechniqueEffectHandle = m_pEffect->GetTechniqueByName(pstrTechnique);
		}
		else if(strcmpi(ParamDesc.Semantic, "PREPROCESSTECHNIQUE") == 0) {
		    m_pEffect->GetString(hParam, &pstrTechnique);
		    m_PreprocessTechnique1EffectHandle = m_pEffect->GetTechniqueByName(pstrTechnique);
		}
		else if(strcmpi(ParamDesc.Semantic, "PREPROCESSTECHNIQUE1") == 0) {
		    m_pEffect->GetString(hParam, &pstrTechnique);
		    m_PreprocessTechnique2EffectHandle = m_pEffect->GetTechniqueByName(pstrTechnique);
		}
		else if(strcmpi(ParamDesc.Semantic, "NAME") == 0)
		    m_pEffect->GetString(hParam, &m_strName);

	    }


	}

	for(UINT iAnnot = 0; iAnnot < ParamDesc.Annotations; iAnnot++) {
            hAnnot = m_pEffect->GetAnnotation (hParam, iAnnot);
            m_pEffect->GetParameterDesc(hAnnot, &AnnotDesc);
            if(strcmpi(AnnotDesc.Name, "name") == 0)
                m_pEffect->GetString(hAnnot, &pstrName);
            else if(strcmpi(AnnotDesc.Name, "function") == 0)
                m_pEffect->GetString(hAnnot, &pstrFunction);
            else if(strcmpi(AnnotDesc.Name, "target") == 0)
                m_pEffect->GetString(hAnnot, &pstrTarget);
            else if(strcmpi(AnnotDesc.Name, "width") == 0)
                m_pEffect->GetInt(hAnnot, &Width);
            else if(strcmpi(AnnotDesc.Name, "height") == 0)
                m_pEffect->GetInt(hAnnot, &Height);
            else if(strcmpi(AnnotDesc.Name, "depth") == 0)
                m_pEffect->GetInt(hAnnot, &Depth);
            else if(strcmpi(AnnotDesc.Name, "type") == 0)
                m_pEffect->GetString(hAnnot, &pstrTextureType);

        }

	// Not used in DOSBox
/*	if(pstrName != NULL) {
            pTex = NULL;
            DXUtil_ConvertAnsiStringToGenericCch(strPath, pstrName, MAX_PATH);
            if(pstrTextureType != NULL) {
                if(strcmpi(pstrTextureType, "volume") == 0) {
                    LPDIRECT3DVOLUMETEXTURE9 pVolumeTex = NULL;
                    if(SUCCEEDED(hr = D3DXCreateVolumeTextureFromFileEx(m_pd3dDevice, strPath,
                            Width, Height, Depth, 1, 0, D3DFMT_UNKNOWN, D3DPOOL_MANAGED,
                            D3DX_DEFAULT, D3DX_DEFAULT, 0, NULL, NULL, &pVolumeTex))) {
                        pTex = pVolumeTex;
                    }
                    else {
                        m_strErrors += "Could not load volume texture ";
                        m_strErrors += pstrName;
                    }
                }
                else if(strcmpi(pstrTextureType, "cube") == 0) {
                    LPDIRECT3DCUBETEXTURE9 pCubeTex = NULL;
                    if(SUCCEEDED(hr = D3DXCreateCubeTextureFromFileEx(m_pd3dDevice, strPath,
                            Width, D3DX_DEFAULT, 0, D3DFMT_UNKNOWN, D3DPOOL_MANAGED,
                            D3DX_DEFAULT, D3DX_DEFAULT, 0, NULL, NULL, &pCubeTex))) {
                        pTex = pCubeTex;
                    }
                    else {
                        m_strErrors += "Could not load cube texture ";
                        m_strErrors += pstrName;
                    }
                }
            }
            else {
                LPDIRECT3DTEXTURE9 p2DTex = NULL;
                if(SUCCEEDED(hr = D3DXCreateTextureFromFileEx(m_pd3dDevice, strPath,
                        Width, Height, D3DX_DEFAULT, 0, D3DFMT_UNKNOWN, D3DPOOL_MANAGED,
                        D3DX_DEFAULT, D3DX_DEFAULT, 0, NULL, NULL, &p2DTex))) {
                    pTex = p2DTex;
                }
                else {
                    m_strErrors += "Could not load texture ";
                    m_strErrors += pstrName;
                    m_strErrors += "\n";
                }
            }

            // Apply successfully loaded texture to effect
            if(SUCCEEDED(hr) && pTex != NULL) {
                m_pEffect->SetTexture(m_pEffect->GetParameter(NULL, iParam), pTex);
                SAFE_RELEASE(pTex);
            }
        }
	else */
	if(pstrFunction != NULL) {
	    LPD3DXBUFFER pTextureShader = NULL;
	    LPD3DXBUFFER lpErrors = 0;

	    if(pstrTarget == NULL || strcmp(pstrTarget,"tx_1_1"))
                pstrTarget = "tx_1_0";

	    if(SUCCEEDED(hr = lpEffectCompiler->CompileShader(
				pstrFunction, pstrTarget,
				0, &pTextureShader, &lpErrors, NULL))) {
		SAFE_RELEASE(lpErrors);

		if((UINT)Width == D3DX_DEFAULT)
                    Width = 64;
		if((UINT)Height == D3DX_DEFAULT)
                    Height = 64;
		if((UINT)Depth == D3DX_DEFAULT)
                    Depth = 64;

#if D3DX_SDK_VERSION >= 22
		LPD3DXTEXTURESHADER ppTextureShader;
		D3DXCreateTextureShader((DWORD *)pTextureShader->GetBufferPointer(), &ppTextureShader);
#endif

		if(pstrTextureType != NULL) {
                    if(strcmpi(pstrTextureType, "volume") == 0) {
                        LPDIRECT3DVOLUMETEXTURE9 pVolumeTex = NULL;
                        if(SUCCEEDED(hr = D3DXCreateVolumeTexture(m_pd3dDevice,
                                Width, Height, Depth, 1, 0, D3DFMT_A8R8G8B8, D3DPOOL_MANAGED, &pVolumeTex))) {
#if D3DX_SDK_VERSION >= 22
                           if(SUCCEEDED(hr = D3DXFillVolumeTextureTX(pVolumeTex, ppTextureShader))) {
#else
                           if(SUCCEEDED(hr = D3DXFillVolumeTextureTX(pVolumeTex,
					(DWORD *)pTextureShader->GetBufferPointer(), NULL, 0))) {
#endif
                                pTex = pVolumeTex;
                            }
                        }
                    } else if(strcmpi(pstrTextureType, "cube") == 0) {
                        LPDIRECT3DCUBETEXTURE9 pCubeTex = NULL;
                        if(SUCCEEDED(hr = D3DXCreateCubeTexture(m_pd3dDevice,
                                Width, D3DX_DEFAULT, 0, D3DFMT_A8R8G8B8, D3DPOOL_MANAGED, &pCubeTex))) {
#if D3DX_SDK_VERSION >= 22
                            if(SUCCEEDED(hr = D3DXFillCubeTextureTX(pCubeTex, ppTextureShader))) {
#else
                            if(SUCCEEDED(hr = D3DXFillCubeTextureTX(pCubeTex,
                                (DWORD *)pTextureShader->GetBufferPointer(), NULL, 0))) {
#endif
                                pTex = pCubeTex;
                            }
                        }
                    }
		} else {
                    LPDIRECT3DTEXTURE9 p2DTex = NULL;
                    if(SUCCEEDED(hr = D3DXCreateTexture(m_pd3dDevice, Width, Height,
                                D3DX_DEFAULT, 0, D3DFMT_A8R8G8B8, D3DPOOL_MANAGED, &p2DTex))) {
#if D3DX_SDK_VERSION >= 22
                        if(SUCCEEDED(hr = D3DXFillTextureTX(p2DTex, ppTextureShader))) {
#else
                        if(SUCCEEDED(hr = D3DXFillTextureTX(p2DTex,
				(DWORD *)pTextureShader->GetBufferPointer(), NULL, 0))) {
#endif
                            pTex = p2DTex;
                        }
                    }
		}
		m_pEffect->SetTexture(m_pEffect->GetParameter(NULL, iParam), pTex);
		SAFE_RELEASE(pTex);
		SAFE_RELEASE(pTextureShader);
#if D3DX_SDK_VERSION >= 22
		SAFE_RELEASE(ppTextureShader);
#endif
	    } else {
		if(lpErrors) {
		    m_strErrors += (char*) lpErrors->GetBufferPointer();
		}

		m_strErrors += "Could not compile texture shader ";
		m_strErrors += pstrFunction;

		SAFE_RELEASE(lpErrors);
		return hr;
	    }
        }
    }

    return S_OK;
}
コード例 #11
0
void CD3D9Texture::createCubeTexture(int nSize, int nLevels, bool bPoolManaged)
{
	D3DXCreateCubeTexture(DXUTGetD3DDevice(), nSize, nLevels, 0, D3DFMT_A8R8G8B8,
		bPoolManaged?D3DPOOL_MANAGED:D3DPOOL_DEFAULT, (LPDIRECT3DCUBETEXTURE9*)&m_pd3dTexture);
}
コード例 #12
0
bool CCubeTexture::Create(const std::string &Name, unsigned int Size, unsigned int MipMaps, TUsageType UsageType, TPoolType PoolType, TFormatType FormatType)
{
	D3DPOOL l_Pool=D3DPOOL_DEFAULT;
	DWORD l_UsageType=D3DUSAGE_DYNAMIC;
	D3DFORMAT l_Format=D3DFMT_A8R8G8B8;
	bool l_CreateDepthStencilSurface=false;
	
	switch(UsageType)
	{
		case DYNAMIC:
			l_UsageType=D3DUSAGE_DYNAMIC;
			break;
		case RENDERTARGET:
			l_CreateDepthStencilSurface=true;
			l_UsageType=D3DUSAGE_RENDERTARGET;
			break;
	}
	
	switch(PoolType)
	{
		case DEFAULT:
			l_Pool=D3DPOOL_DEFAULT;
			break;
		case SYSTEMMEM:
			l_Pool=D3DPOOL_SYSTEMMEM;
			break;
	}

	switch(FormatType)
	{
		case A8R8G8B8:
			l_Format=D3DFMT_A8R8G8B8;
			break;
		case A16B16G16R16F:
			l_Format=D3DFMT_A16B16G16R16F;
			break;
		case R8G8B8:
			l_Format=D3DFMT_R8G8B8;
			break;
		case X8R8G8B8:
			l_Format=D3DFMT_X8R8G8B8;
			break;
		case R32F:
			l_Format=D3DFMT_R32F;
			break;
		case RG32F:
			l_Format=D3DFMT_G32R32F;
			break;
	}
	
	// creating depth cube
	if (FAILED(D3DXCreateCubeTexture(CORE->GetRenderManager()->GetDevice(), Size, 1, l_UsageType, l_Format, l_Pool, &m_CubeTexture)))
		return false;
	
	if(l_CreateDepthStencilSurface)
	{
		CORE->GetRenderManager()->GetDevice()->CreateDepthStencilSurface(Size, Size, D3DFMT_D24S8,D3DMULTISAMPLE_NONE, 0, TRUE,&m_DepthStencilRenderTargetTexture, NULL);
		assert(m_DepthStencilRenderTargetTexture!=NULL);
	}

	// getting each six surfaces of the cubic depth map
	if (FAILED(m_CubeTexture->GetCubeMapSurface(D3DCUBEMAP_FACE_POSITIVE_X, 0, &cubeFacePX)))
		return false;
	if (FAILED(m_CubeTexture->GetCubeMapSurface(D3DCUBEMAP_FACE_POSITIVE_Y, 0, &cubeFacePY)))
		return false;
	if (FAILED(m_CubeTexture->GetCubeMapSurface(D3DCUBEMAP_FACE_POSITIVE_Z, 0, &cubeFacePZ)))
		return false;
	if (FAILED(m_CubeTexture->GetCubeMapSurface(D3DCUBEMAP_FACE_NEGATIVE_X, 0, &cubeFaceNX)))
		return false;
	if (FAILED(m_CubeTexture->GetCubeMapSurface(D3DCUBEMAP_FACE_NEGATIVE_Y, 0, &cubeFaceNY)))
		return false;
	if (FAILED(m_CubeTexture->GetCubeMapSurface(D3DCUBEMAP_FACE_NEGATIVE_Z, 0, &cubeFaceNZ)))
		return false;

	return true;
}