3 * Copyright (c) 2007-2010 SlimDX Group
\r
5 * Permission is hereby granted, free of charge, to any person obtaining a copy
\r
6 * of this software and associated documentation files (the "Software"), to deal
\r
7 * in the Software without restriction, including without limitation the rights
\r
8 * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
\r
9 * copies of the Software, and to permit persons to whom the Software is
\r
10 * furnished to do so, subject to the following conditions:
\r
12 * The above copyright notice and this permission notice shall be included in
\r
13 * all copies or substantial portions of the Software.
\r
15 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
\r
16 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
\r
17 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
\r
18 * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
\r
19 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
\r
20 * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
\r
26 #include "Direct3D9Exception.h"
\r
29 #include "Texture.h"
\r
30 #include "RenderToEnvMap.h"
\r
32 using namespace System;
\r
38 RenderToEnvironmentMap::RenderToEnvironmentMap( SlimDX::Direct3D9::Device^ device, int size, int mipLevels, Format format, Format depthStencilFormat )
\r
40 ID3DXRenderToEnvMap *result;
\r
42 HRESULT hr = D3DXCreateRenderToEnvMap( device->InternalPointer, size, mipLevels, static_cast<D3DFORMAT>( format ),
\r
43 true, static_cast<D3DFORMAT>( depthStencilFormat ), &result );
\r
45 if( RECORD_D3D9( hr ).IsFailure )
\r
46 throw gcnew Direct3D9Exception( Result::Last );
\r
51 RenderToEnvironmentMap::RenderToEnvironmentMap( SlimDX::Direct3D9::Device^ device, int size, int mipLevels, Format format )
\r
53 ID3DXRenderToEnvMap *result;
\r
55 HRESULT hr = D3DXCreateRenderToEnvMap( device->InternalPointer, size, mipLevels, static_cast<D3DFORMAT>( format ),
\r
56 false, D3DFMT_UNKNOWN, &result );
\r
58 if( RECORD_D3D9( hr ).IsFailure )
\r
59 throw gcnew Direct3D9Exception( Result::Last );
\r
64 Result RenderToEnvironmentMap::BeginCube( CubeTexture^ texture )
\r
66 HRESULT hr = InternalPointer->BeginCube( texture->InternalPointer );
\r
67 return RECORD_D3D9( hr );
\r
70 Result RenderToEnvironmentMap::BeginHemisphere( Texture^ positiveZTexture, Texture^ negativeZTexture )
\r
72 HRESULT hr = InternalPointer->BeginHemisphere( positiveZTexture->InternalPointer, negativeZTexture->InternalPointer );
\r
73 return RECORD_D3D9( hr );
\r
76 Result RenderToEnvironmentMap::BeginParabolic( Texture^ positiveZTexture, Texture^ negativeZTexture )
\r
78 HRESULT hr = InternalPointer->BeginParabolic( positiveZTexture->InternalPointer, negativeZTexture->InternalPointer );
\r
79 return RECORD_D3D9( hr );
\r
82 Result RenderToEnvironmentMap::BeginSphere( Texture^ texture )
\r
84 HRESULT hr = InternalPointer->BeginSphere( texture->InternalPointer );
\r
85 return RECORD_D3D9( hr );
\r
88 Result RenderToEnvironmentMap::End( Filter mipFilter )
\r
90 HRESULT hr = InternalPointer->End( static_cast<DWORD>( mipFilter ) );
\r
91 return RECORD_D3D9( hr );
\r
94 Result RenderToEnvironmentMap::Face( CubeMapFace face, Filter mipFilter )
\r
96 HRESULT hr = InternalPointer->Face( static_cast<D3DCUBEMAP_FACES>( face ), static_cast<DWORD>( mipFilter ) );
\r
97 return RECORD_D3D9( hr );
\r
100 SlimDX::Direct3D9::Device^ RenderToEnvironmentMap::Device::get()
\r
102 IDirect3DDevice9* device;
\r
104 HRESULT hr = InternalPointer->GetDevice( &device );
\r
106 if( RECORD_D3D9( hr ).IsFailure )
\r
109 return SlimDX::Direct3D9::Device::FromPointer( device );
\r
112 Result RenderToEnvironmentMap::OnLostDevice()
\r
114 HRESULT hr = InternalPointer->OnLostDevice();
\r
115 return RECORD_D3D9( hr );
\r
118 Result RenderToEnvironmentMap::OnResetDevice()
\r
120 HRESULT hr = InternalPointer->OnResetDevice();
\r
121 return RECORD_D3D9( hr );
\r
124 RenderToEnvironmentMapDescription RenderToEnvironmentMap::Description::get()
\r
126 D3DXRTE_DESC description = {0};
\r
128 HRESULT hr = InternalPointer->GetDesc( &description );
\r
130 if( RECORD_D3D9( hr ).IsFailure )
\r
131 return RenderToEnvironmentMapDescription();
\r
133 RenderToEnvironmentMapDescription outDesc;
\r
134 outDesc.Size = description.Size;
\r
135 outDesc.MipLevels = description.MipLevels;
\r
136 outDesc.Format = static_cast<Format>( description.Format );
\r
137 outDesc.DepthStencil = description.DepthStencil > 0;
\r
138 outDesc.DepthStencilFormat = static_cast<Format>( description.DepthStencilFormat );
\r