OSDN Git Service

DTXMania089リリースに際してのtag付け。
[dtxmania/dtxmania.git] / 110401(DTXMania089) / SlimDXc_Jun2010(VC++2008) / source / direct3d9 / RenderToEnvMap.cpp
1 #include "stdafx.h"\r
2 /*\r
3 * Copyright (c) 2007-2010 SlimDX Group\r
4\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
11\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
14\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
21 * THE SOFTWARE.\r
22 */\r
23 #include <d3d9.h>\r
24 #include <d3dx9.h>\r
25 \r
26 #include "Direct3D9Exception.h"\r
27 \r
28 #include "Device.h"\r
29 #include "Texture.h"\r
30 #include "RenderToEnvMap.h"\r
31 \r
32 using namespace System;\r
33 \r
34 namespace SlimDX\r
35 {\r
36 namespace Direct3D9\r
37 {\r
38         RenderToEnvironmentMap::RenderToEnvironmentMap( SlimDX::Direct3D9::Device^ device, int size, int mipLevels, Format format, Format depthStencilFormat )\r
39         {\r
40                 ID3DXRenderToEnvMap *result;\r
41 \r
42                 HRESULT hr = D3DXCreateRenderToEnvMap( device->InternalPointer, size, mipLevels, static_cast<D3DFORMAT>( format ),\r
43                         true, static_cast<D3DFORMAT>( depthStencilFormat ), &result );\r
44                 \r
45                 if( RECORD_D3D9( hr ).IsFailure )\r
46                         throw gcnew Direct3D9Exception( Result::Last );\r
47 \r
48                 Construct(result);\r
49         }\r
50 \r
51         RenderToEnvironmentMap::RenderToEnvironmentMap( SlimDX::Direct3D9::Device^ device, int size, int mipLevels, Format format )\r
52         {\r
53                 ID3DXRenderToEnvMap *result;\r
54 \r
55                 HRESULT hr = D3DXCreateRenderToEnvMap( device->InternalPointer, size, mipLevels, static_cast<D3DFORMAT>( format ),\r
56                         false, D3DFMT_UNKNOWN, &result );\r
57 \r
58                 if( RECORD_D3D9( hr ).IsFailure )\r
59                         throw gcnew Direct3D9Exception( Result::Last );\r
60 \r
61                 Construct(result);\r
62         }\r
63 \r
64         Result RenderToEnvironmentMap::BeginCube( CubeTexture^ texture )\r
65         {\r
66                 HRESULT hr = InternalPointer->BeginCube( texture->InternalPointer );\r
67                 return RECORD_D3D9( hr );\r
68         }\r
69 \r
70         Result RenderToEnvironmentMap::BeginHemisphere( Texture^ positiveZTexture, Texture^ negativeZTexture )\r
71         {\r
72                 HRESULT hr = InternalPointer->BeginHemisphere( positiveZTexture->InternalPointer, negativeZTexture->InternalPointer );\r
73                 return RECORD_D3D9( hr );\r
74         }\r
75 \r
76         Result RenderToEnvironmentMap::BeginParabolic( Texture^ positiveZTexture, Texture^ negativeZTexture )\r
77         {\r
78                 HRESULT hr = InternalPointer->BeginParabolic( positiveZTexture->InternalPointer, negativeZTexture->InternalPointer );\r
79                 return RECORD_D3D9( hr );\r
80         }\r
81 \r
82         Result RenderToEnvironmentMap::BeginSphere( Texture^ texture )\r
83         {\r
84                 HRESULT hr = InternalPointer->BeginSphere( texture->InternalPointer );\r
85                 return RECORD_D3D9( hr );\r
86         }\r
87 \r
88         Result RenderToEnvironmentMap::End( Filter mipFilter )\r
89         {\r
90                 HRESULT hr = InternalPointer->End( static_cast<DWORD>( mipFilter ) );\r
91                 return RECORD_D3D9( hr );\r
92         }\r
93 \r
94         Result RenderToEnvironmentMap::Face( CubeMapFace face, Filter mipFilter )\r
95         {\r
96                 HRESULT hr = InternalPointer->Face( static_cast<D3DCUBEMAP_FACES>( face ), static_cast<DWORD>( mipFilter ) );\r
97                 return RECORD_D3D9( hr );\r
98         }\r
99 \r
100         SlimDX::Direct3D9::Device^ RenderToEnvironmentMap::Device::get()\r
101         {\r
102                 IDirect3DDevice9* device;\r
103 \r
104                 HRESULT hr = InternalPointer->GetDevice( &device );\r
105                 \r
106                 if( RECORD_D3D9( hr ).IsFailure )\r
107                         return nullptr;\r
108 \r
109                 return SlimDX::Direct3D9::Device::FromPointer( device );\r
110         }\r
111 \r
112         Result RenderToEnvironmentMap::OnLostDevice()\r
113         {\r
114                 HRESULT hr = InternalPointer->OnLostDevice();\r
115                 return RECORD_D3D9( hr );\r
116         }\r
117 \r
118         Result RenderToEnvironmentMap::OnResetDevice()\r
119         {\r
120                 HRESULT hr = InternalPointer->OnResetDevice();\r
121                 return RECORD_D3D9( hr );\r
122         }\r
123 \r
124         RenderToEnvironmentMapDescription RenderToEnvironmentMap::Description::get()\r
125         {\r
126                 D3DXRTE_DESC description = {0};\r
127 \r
128                 HRESULT hr = InternalPointer->GetDesc( &description );\r
129                 \r
130                 if( RECORD_D3D9( hr ).IsFailure )\r
131                         return RenderToEnvironmentMapDescription();\r
132 \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
139 \r
140                 return outDesc;\r
141         }\r
142 }\r
143 }