OSDN Git Service

フォーラム[#56172] SlimDX(改)のフォルダ内容が不完全だったので再UP。
[dtxmania/dtxmania.git] / SlimDXc_Jun2010(VC++2008) / source / direct3d10 / EffectPass.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 \r
24 #include <d3d10.h>\r
25 #include <d3dx10.h>\r
26 #include <vcclr.h>\r
27 \r
28 #include "Direct3D10Exception.h"\r
29 \r
30 #include "EffectPass.h"\r
31 #include "EffectPassDescription.h"\r
32 #include "EffectPassShaderDescription.h"\r
33 #include "EffectVariable.h"\r
34 \r
35 using namespace System;\r
36 using namespace System::Globalization;\r
37 \r
38 namespace SlimDX\r
39 {\r
40 namespace Direct3D10\r
41\r
42         EffectPass::EffectPass( ID3D10EffectPass* pointer )\r
43         {\r
44                 if( pointer == 0 )\r
45                         throw gcnew ArgumentNullException( "pointer" );\r
46                         \r
47                 m_Pointer = pointer;\r
48         }\r
49         \r
50         EffectPass::EffectPass( IntPtr pointer )\r
51         {\r
52                 if( pointer == IntPtr::Zero )\r
53                         throw gcnew ArgumentNullException( "pointer" );\r
54                         \r
55                 m_Pointer = reinterpret_cast<ID3D10EffectPass*>( pointer.ToPointer() );\r
56         }\r
57         \r
58         EffectPassDescription EffectPass::Description::get()\r
59         {\r
60                 D3D10_PASS_DESC nativeDescription;\r
61                 if ( RECORD_D3D10( m_Pointer->GetDesc( &nativeDescription ) ).IsFailure )\r
62                         return EffectPassDescription();\r
63 \r
64                 return EffectPassDescription( nativeDescription );\r
65         }\r
66         \r
67         bool EffectPass::IsValid::get()\r
68         {\r
69                 return m_Pointer->IsValid() ? true : false;\r
70         }\r
71         \r
72         EffectPassShaderDescription EffectPass::GeometryShaderDescription::get()\r
73         {\r
74                 D3D10_PASS_SHADER_DESC description;\r
75                 \r
76                 if( RECORD_D3D10( m_Pointer->GetGeometryShaderDesc( &description ) ).IsFailure )\r
77                         return EffectPassShaderDescription();\r
78                 else\r
79                         return EffectPassShaderDescription( description );\r
80         }\r
81         \r
82         EffectPassShaderDescription EffectPass::VertexShaderDescription::get()\r
83         {\r
84                 D3D10_PASS_SHADER_DESC description;\r
85                 \r
86                 if( RECORD_D3D10( m_Pointer->GetVertexShaderDesc( &description ) ).IsFailure )\r
87                         return EffectPassShaderDescription();\r
88                 else\r
89                         return EffectPassShaderDescription( description );\r
90         }\r
91         \r
92         EffectPassShaderDescription EffectPass::PixelShaderDescription::get()\r
93         {\r
94                 D3D10_PASS_SHADER_DESC description;\r
95                 \r
96                 if( RECORD_D3D10( m_Pointer->GetPixelShaderDesc( &description ) ).IsFailure )\r
97                         return EffectPassShaderDescription();\r
98                 else\r
99                         return EffectPassShaderDescription( description );\r
100         }\r
101         \r
102         EffectVariable^ EffectPass::GetAnnotationByIndex( int index )\r
103         {\r
104                 ID3D10EffectVariable* variable = m_Pointer->GetAnnotationByIndex( index );\r
105                 if( variable == 0 )\r
106                         return nullptr;\r
107                 return gcnew EffectVariable( variable );\r
108         }\r
109         \r
110         EffectVariable^ EffectPass::GetAnnotationByName( String^ name )\r
111         {\r
112                 array<unsigned char>^ nameBytes = System::Text::ASCIIEncoding::ASCII->GetBytes( name );\r
113                 pin_ptr<unsigned char> pinnedName = &nameBytes[ 0 ];\r
114                 ID3D10EffectVariable* variable = m_Pointer->GetAnnotationByName( reinterpret_cast<LPCSTR>( pinnedName ) );\r
115                 if( variable == 0 )\r
116                         return nullptr;\r
117                 return gcnew EffectVariable( variable );\r
118         }\r
119         \r
120         Result EffectPass::Apply()\r
121         {\r
122                 return RECORD_D3D10( m_Pointer->Apply( 0 ) );\r
123         }\r
124 }\r
125 }\r