mirror of
https://github.com/borgesdan/xn65
synced 2024-12-29 21:54:47 +01:00
Implementações em Effect
This commit is contained in:
parent
2fc10f79e1
commit
8007a41690
@ -21,7 +21,7 @@ namespace xna {
|
|||||||
device->impl->_device,
|
device->impl->_device,
|
||||||
//ID3DX11Effect * *ppEffect
|
//ID3DX11Effect * *ppEffect
|
||||||
&impl->dxEffect
|
&impl->dxEffect
|
||||||
);
|
);
|
||||||
|
|
||||||
if FAILED(result)
|
if FAILED(result)
|
||||||
throw std::runtime_error("Effect::Effect: Unable to create an effect with memory data.");
|
throw std::runtime_error("Effect::Effect: Unable to create an effect with memory data.");
|
||||||
@ -32,7 +32,7 @@ namespace xna {
|
|||||||
impl->dxEffect->GetDesc(&desc);
|
impl->dxEffect->GetDesc(&desc);
|
||||||
|
|
||||||
auto tech = impl->dxEffect->GetTechniqueByIndex(0);
|
auto tech = impl->dxEffect->GetTechniqueByIndex(0);
|
||||||
|
|
||||||
auto technique = snew<EffectTechnique>();
|
auto technique = snew<EffectTechnique>();
|
||||||
technique->impl->dxContext = m_device->impl->_context;
|
technique->impl->dxContext = m_device->impl->_context;
|
||||||
technique->impl->dxContext->AddRef();
|
technique->impl->dxContext->AddRef();
|
||||||
@ -50,33 +50,42 @@ namespace xna {
|
|||||||
Int EffectAnnotation::ColumCount() const {
|
Int EffectAnnotation::ColumCount() const {
|
||||||
auto type = impl->dxVariable->GetType();
|
auto type = impl->dxVariable->GetType();
|
||||||
D3DX11_EFFECT_TYPE_DESC desc{};
|
D3DX11_EFFECT_TYPE_DESC desc{};
|
||||||
type->GetDesc(&desc);
|
const auto hr = type->GetDesc(&desc);
|
||||||
|
|
||||||
type->Release();
|
type->Release();
|
||||||
type = nullptr;
|
type = nullptr;
|
||||||
|
|
||||||
|
if FAILED(hr)
|
||||||
|
throw std::runtime_error("EffectAnnotation::ColumCount: error getting D3DX11_EFFECT_TYPE_DESC");
|
||||||
|
|
||||||
return static_cast<Int>(desc.Columns);
|
return static_cast<Int>(desc.Columns);
|
||||||
}
|
}
|
||||||
|
|
||||||
String EffectAnnotation::Name() const {
|
String EffectAnnotation::Name() const {
|
||||||
auto type = impl->dxVariable->GetType();
|
auto type = impl->dxVariable->GetType();
|
||||||
D3DX11_EFFECT_TYPE_DESC desc{};
|
D3DX11_EFFECT_TYPE_DESC desc{};
|
||||||
type->GetDesc(&desc);
|
const auto hr = type->GetDesc(&desc);
|
||||||
|
|
||||||
type->Release();
|
type->Release();
|
||||||
type = nullptr;
|
type = nullptr;
|
||||||
|
|
||||||
|
if FAILED(hr)
|
||||||
|
throw std::runtime_error("EffectAnnotation::Name: error getting D3DX11_EFFECT_TYPE_DESC");
|
||||||
|
|
||||||
return String(desc.TypeName);
|
return String(desc.TypeName);
|
||||||
}
|
}
|
||||||
|
|
||||||
EffectParameterClass EffectAnnotation::ParameterClass() const {
|
EffectParameterClass EffectAnnotation::ParameterClass() const {
|
||||||
auto type = impl->dxVariable->GetType();
|
auto type = impl->dxVariable->GetType();
|
||||||
D3DX11_EFFECT_TYPE_DESC desc{};
|
D3DX11_EFFECT_TYPE_DESC desc{};
|
||||||
type->GetDesc(&desc);
|
const auto hr = type->GetDesc(&desc);
|
||||||
|
|
||||||
type->Release();
|
type->Release();
|
||||||
type = nullptr;
|
type = nullptr;
|
||||||
|
|
||||||
|
if FAILED(hr)
|
||||||
|
throw std::runtime_error("EffectAnnotation::ParameterClass: error getting D3DX11_EFFECT_TYPE_DESC");
|
||||||
|
|
||||||
switch (desc.Class)
|
switch (desc.Class)
|
||||||
{
|
{
|
||||||
case D3D_SHADER_VARIABLE_CLASS::D3D_SVC_MATRIX_COLUMNS:
|
case D3D_SHADER_VARIABLE_CLASS::D3D_SVC_MATRIX_COLUMNS:
|
||||||
@ -91,18 +100,21 @@ namespace xna {
|
|||||||
case D3D_SHADER_VARIABLE_CLASS::D3D_SVC_VECTOR:
|
case D3D_SHADER_VARIABLE_CLASS::D3D_SVC_VECTOR:
|
||||||
return EffectParameterClass::Vector;
|
return EffectParameterClass::Vector;
|
||||||
default:
|
default:
|
||||||
throw std::runtime_error(" EffectAnnotation::ParameterClass: invalid EffectParameterClass.");
|
throw std::runtime_error("EffectAnnotation::ParameterClass: invalid EffectParameterClass.");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
Int EffectAnnotation::Rowcount() const {
|
Int EffectAnnotation::RowCount() const {
|
||||||
auto type = impl->dxVariable->GetType();
|
auto type = impl->dxVariable->GetType();
|
||||||
D3DX11_EFFECT_TYPE_DESC desc{};
|
D3DX11_EFFECT_TYPE_DESC desc{};
|
||||||
type->GetDesc(&desc);
|
const auto hr = type->GetDesc(&desc);
|
||||||
|
|
||||||
type->Release();
|
type->Release();
|
||||||
type = nullptr;
|
type = nullptr;
|
||||||
|
|
||||||
|
if FAILED(hr)
|
||||||
|
throw std::runtime_error("EffectAnnotation::RowCount: error getting D3DX11_EFFECT_TYPE_DESC");
|
||||||
|
|
||||||
return static_cast<Int>(desc.Rows);
|
return static_cast<Int>(desc.Rows);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -118,31 +130,31 @@ namespace xna {
|
|||||||
|
|
||||||
bool EffectAnnotation::GetValueBoolean() const {
|
bool EffectAnnotation::GetValueBoolean() const {
|
||||||
auto scalar = impl->dxVariable->AsScalar();
|
auto scalar = impl->dxVariable->AsScalar();
|
||||||
|
|
||||||
bool value = false;
|
|
||||||
auto hr = scalar->GetBool(&value);
|
|
||||||
|
|
||||||
if FAILED(hr)
|
bool value;
|
||||||
throw std::runtime_error("EffectAnnotation::GetValueBoolean: Unable to get boolean value.");
|
auto hr = scalar->GetBool(&value);
|
||||||
|
|
||||||
scalar->Release();
|
scalar->Release();
|
||||||
scalar = nullptr;
|
scalar = nullptr;
|
||||||
|
|
||||||
|
if FAILED(hr)
|
||||||
|
throw std::runtime_error("EffectAnnotation::GetValueBoolean: Unable to get boolean value.");
|
||||||
|
|
||||||
return value;
|
return value;
|
||||||
}
|
}
|
||||||
|
|
||||||
Int EffectAnnotation::GetValueInt32() const {
|
Int EffectAnnotation::GetValueInt32() const {
|
||||||
auto scalar = impl->dxVariable->AsScalar();
|
auto scalar = impl->dxVariable->AsScalar();
|
||||||
|
|
||||||
int value = 0;
|
int value;
|
||||||
auto hr = scalar->GetInt(&value);
|
auto hr = scalar->GetInt(&value);
|
||||||
|
|
||||||
if FAILED(hr)
|
|
||||||
throw std::runtime_error("EffectAnnotation::GetValueInt32: Unable to get interger value.");
|
|
||||||
|
|
||||||
scalar->Release();
|
scalar->Release();
|
||||||
scalar = nullptr;
|
scalar = nullptr;
|
||||||
|
|
||||||
|
if FAILED(hr)
|
||||||
|
throw std::runtime_error("EffectAnnotation::GetValueInt32: Unable to get interger value.");
|
||||||
|
|
||||||
return static_cast<Int>(value);
|
return static_cast<Int>(value);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -151,6 +163,8 @@ namespace xna {
|
|||||||
|
|
||||||
float values[16];
|
float values[16];
|
||||||
auto hr = matrix->GetMatrix(values);
|
auto hr = matrix->GetMatrix(values);
|
||||||
|
matrix->Release();
|
||||||
|
matrix = nullptr;
|
||||||
|
|
||||||
if FAILED(hr)
|
if FAILED(hr)
|
||||||
throw std::runtime_error("EffectAnnotation::GetValueMatrix: Unable to get matrix value.");
|
throw std::runtime_error("EffectAnnotation::GetValueMatrix: Unable to get matrix value.");
|
||||||
@ -173,36 +187,36 @@ namespace xna {
|
|||||||
m.M43 = values[14];
|
m.M43 = values[14];
|
||||||
m.M44 = values[15];
|
m.M44 = values[15];
|
||||||
|
|
||||||
matrix->Release();
|
|
||||||
matrix = nullptr;
|
|
||||||
|
|
||||||
return m;
|
return m;
|
||||||
}
|
}
|
||||||
|
|
||||||
float EffectAnnotation::GetValueSingle() const {
|
float EffectAnnotation::GetValueSingle() const {
|
||||||
auto scalar = impl->dxVariable->AsScalar();
|
auto scalar = impl->dxVariable->AsScalar();
|
||||||
|
|
||||||
float value = 0;
|
float value;
|
||||||
auto hr = scalar->GetFloat(&value);
|
auto hr = scalar->GetFloat(&value);
|
||||||
|
|
||||||
if FAILED(hr)
|
|
||||||
throw std::runtime_error("EffectAnnotation::GetValueSingle: Unable to get float value.");
|
|
||||||
|
|
||||||
scalar->Release();
|
scalar->Release();
|
||||||
scalar = nullptr;
|
scalar = nullptr;
|
||||||
|
|
||||||
|
if FAILED(hr)
|
||||||
|
throw std::runtime_error("EffectAnnotation::GetValueSingle: Unable to get float value.");
|
||||||
|
|
||||||
return value;
|
return value;
|
||||||
}
|
}
|
||||||
|
|
||||||
String EffectAnnotation::GetValueString() const {
|
String EffectAnnotation::GetValueString() const {
|
||||||
auto str = impl->dxVariable->AsString();
|
auto str = impl->dxVariable->AsString();
|
||||||
|
|
||||||
LPCSTR data;
|
LPCSTR data;
|
||||||
str->GetString(&data);
|
const auto hr = str->GetString(&data);
|
||||||
|
|
||||||
str->Release();
|
str->Release();
|
||||||
str = nullptr;
|
str = nullptr;
|
||||||
|
|
||||||
|
if FAILED(hr)
|
||||||
|
throw std::runtime_error("EffectAnnotation::GetValueString: Unable to get string value.");
|
||||||
|
|
||||||
return String(data);
|
return String(data);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -212,6 +226,9 @@ namespace xna {
|
|||||||
float values[2];
|
float values[2];
|
||||||
auto hr = scalar->GetFloatArray(values, 0, 2);
|
auto hr = scalar->GetFloatArray(values, 0, 2);
|
||||||
|
|
||||||
|
scalar->Release();
|
||||||
|
scalar = nullptr;
|
||||||
|
|
||||||
if FAILED(hr)
|
if FAILED(hr)
|
||||||
throw std::runtime_error("EffectAnnotation::GetValueVector2: Unable to get Vector2 value.");
|
throw std::runtime_error("EffectAnnotation::GetValueVector2: Unable to get Vector2 value.");
|
||||||
|
|
||||||
@ -219,18 +236,18 @@ namespace xna {
|
|||||||
v.X = values[0];
|
v.X = values[0];
|
||||||
v.Y = values[1];
|
v.Y = values[1];
|
||||||
|
|
||||||
scalar->Release();
|
|
||||||
scalar = nullptr;
|
|
||||||
|
|
||||||
return v;
|
return v;
|
||||||
}
|
}
|
||||||
|
|
||||||
Vector3 EffectAnnotation::GetValueVector3() const {
|
Vector3 EffectAnnotation::GetValueVector3() const {
|
||||||
auto scalar = impl->dxVariable->AsScalar();
|
auto scalar = impl->dxVariable->AsScalar();
|
||||||
|
|
||||||
float values[3];
|
float values[3];
|
||||||
auto hr = scalar->GetFloatArray(values, 0, 3);
|
auto hr = scalar->GetFloatArray(values, 0, 3);
|
||||||
|
|
||||||
|
scalar->Release();
|
||||||
|
scalar = nullptr;
|
||||||
|
|
||||||
if FAILED(hr)
|
if FAILED(hr)
|
||||||
throw std::runtime_error("EffectAnnotation::GetValueVector3: Unable to get Vector3 value.");
|
throw std::runtime_error("EffectAnnotation::GetValueVector3: Unable to get Vector3 value.");
|
||||||
|
|
||||||
@ -239,20 +256,20 @@ namespace xna {
|
|||||||
v.Y = values[1];
|
v.Y = values[1];
|
||||||
v.Z = values[2];
|
v.Z = values[2];
|
||||||
|
|
||||||
scalar->Release();
|
|
||||||
scalar = nullptr;
|
|
||||||
|
|
||||||
return v;
|
return v;
|
||||||
}
|
}
|
||||||
|
|
||||||
Vector4 EffectAnnotation::GetValueVector4() const {
|
Vector4 EffectAnnotation::GetValueVector4() const {
|
||||||
auto scalar = impl->dxVariable->AsScalar();
|
auto scalar = impl->dxVariable->AsScalar();
|
||||||
|
|
||||||
float values[4];
|
float values[4];
|
||||||
auto hr = scalar->GetFloatArray(values, 0, 4);
|
auto hr = scalar->GetFloatArray(values, 0, 4);
|
||||||
|
|
||||||
|
scalar->Release();
|
||||||
|
scalar = nullptr;
|
||||||
|
|
||||||
if FAILED(hr)
|
if FAILED(hr)
|
||||||
throw std::runtime_error("EffectAnnotation::GetValueVector4: Unable to get Vector4 value.");
|
throw std::runtime_error("EffectAnnotation::GetValueVector4: Unable to get Vector4 value.");
|
||||||
|
|
||||||
Vector4 v;
|
Vector4 v;
|
||||||
v.X = values[0];
|
v.X = values[0];
|
||||||
@ -260,9 +277,6 @@ namespace xna {
|
|||||||
v.Z = values[2];
|
v.Z = values[2];
|
||||||
v.W = values[3];
|
v.W = values[3];
|
||||||
|
|
||||||
scalar->Release();
|
|
||||||
scalar = nullptr;
|
|
||||||
|
|
||||||
return v;
|
return v;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -285,19 +299,22 @@ namespace xna {
|
|||||||
throw std::runtime_error("EffectPass::Annotations: The class was not initialized correctly");
|
throw std::runtime_error("EffectPass::Annotations: The class was not initialized correctly");
|
||||||
|
|
||||||
D3DX11_PASS_DESC desc{};
|
D3DX11_PASS_DESC desc{};
|
||||||
impl->dxPass->GetDesc(&desc);
|
const auto hr = impl->dxPass->GetDesc(&desc);
|
||||||
|
|
||||||
|
if FAILED(hr)
|
||||||
|
throw std::runtime_error("EffectPass::Annotations: error getting D3DX11_PASS_DESC");
|
||||||
|
|
||||||
auto annotCount = desc.Annotations;
|
auto annotCount = desc.Annotations;
|
||||||
|
|
||||||
if (annotCount == 0)
|
if (annotCount == 0)
|
||||||
return snew<EffectAnnotationCollection>();
|
return snew<EffectAnnotationCollection>();
|
||||||
|
|
||||||
std::vector<PEffectAnnotation> list(annotCount);
|
std::vector<PEffectAnnotation> list(annotCount);
|
||||||
|
|
||||||
for (size_t i = 0; i < annotCount; ++i) {
|
for (size_t i = 0; i < annotCount; ++i) {
|
||||||
auto current = impl->dxPass->GetAnnotationByIndex(i);
|
auto current = impl->dxPass->GetAnnotationByIndex(i);
|
||||||
auto annotation = snew<EffectAnnotation>();
|
auto annotation = snew<EffectAnnotation>();
|
||||||
annotation->impl->dxVariable = current;
|
annotation->impl->dxVariable = current;
|
||||||
annotation->impl->dxVariable->AddRef();
|
annotation->impl->dxVariable->AddRef();
|
||||||
|
|
||||||
current->Release();
|
current->Release();
|
||||||
@ -309,12 +326,15 @@ namespace xna {
|
|||||||
auto collection = snew<EffectAnnotationCollection>(list);
|
auto collection = snew<EffectAnnotationCollection>(list);
|
||||||
return collection;
|
return collection;
|
||||||
}
|
}
|
||||||
|
|
||||||
void EffectPass::Apply() {
|
void EffectPass::Apply() {
|
||||||
if (!impl->dxPass)
|
if (!impl->dxPass)
|
||||||
throw std::runtime_error("EffectPass::Apply: The class was not initialized correctly");
|
throw std::runtime_error("EffectPass::Apply: The class was not initialized correctly");
|
||||||
|
|
||||||
impl->dxPass->Apply(0, impl->dxContext);
|
const auto hr = impl->dxPass->Apply(0, impl->dxContext);
|
||||||
|
|
||||||
|
if FAILED(hr)
|
||||||
|
throw std::runtime_error("EffectPass::Apply: error to call Apply");
|
||||||
}
|
}
|
||||||
|
|
||||||
EffectTechnique::EffectTechnique() {
|
EffectTechnique::EffectTechnique() {
|
||||||
@ -323,14 +343,20 @@ namespace xna {
|
|||||||
|
|
||||||
String EffectTechnique::Name() const {
|
String EffectTechnique::Name() const {
|
||||||
D3DX11_TECHNIQUE_DESC desc;
|
D3DX11_TECHNIQUE_DESC desc;
|
||||||
impl->dxTechnique->GetDesc(&desc);
|
const auto hr = impl->dxTechnique->GetDesc(&desc);
|
||||||
|
|
||||||
|
if FAILED(hr)
|
||||||
|
throw std::runtime_error("EffectTechnique::Name: error getting D3DX11_TECHNIQUE_DESC");
|
||||||
|
|
||||||
return String(desc.Name);
|
return String(desc.Name);
|
||||||
}
|
}
|
||||||
|
|
||||||
PEffectAnnotationCollection EffectTechnique::Annotations() const {
|
PEffectAnnotationCollection EffectTechnique::Annotations() const {
|
||||||
D3DX11_TECHNIQUE_DESC desc;
|
D3DX11_TECHNIQUE_DESC desc;
|
||||||
impl->dxTechnique->GetDesc(&desc);
|
const auto hr = impl->dxTechnique->GetDesc(&desc);
|
||||||
|
|
||||||
|
if FAILED(hr)
|
||||||
|
throw std::runtime_error("EffectTechnique::Annotations: error getting D3DX11_TECHNIQUE_DESC");
|
||||||
|
|
||||||
auto annotCount = desc.Annotations;
|
auto annotCount = desc.Annotations;
|
||||||
|
|
||||||
@ -357,7 +383,10 @@ namespace xna {
|
|||||||
|
|
||||||
PEffectPassCollection EffectTechnique::Passes() const {
|
PEffectPassCollection EffectTechnique::Passes() const {
|
||||||
D3DX11_TECHNIQUE_DESC desc;
|
D3DX11_TECHNIQUE_DESC desc;
|
||||||
impl->dxTechnique->GetDesc(&desc);
|
const auto hr = impl->dxTechnique->GetDesc(&desc);
|
||||||
|
|
||||||
|
if FAILED(hr)
|
||||||
|
throw std::runtime_error("EffectTechnique::Passes: error getting D3DX11_TECHNIQUE_DESC");
|
||||||
|
|
||||||
auto passCount = desc.Passes;
|
auto passCount = desc.Passes;
|
||||||
|
|
||||||
@ -368,7 +397,7 @@ namespace xna {
|
|||||||
|
|
||||||
for (size_t i = 0; i < passCount; ++i) {
|
for (size_t i = 0; i < passCount; ++i) {
|
||||||
auto current = impl->dxTechnique->GetPassByIndex(i);
|
auto current = impl->dxTechnique->GetPassByIndex(i);
|
||||||
|
|
||||||
auto pass = snew<EffectPass>();
|
auto pass = snew<EffectPass>();
|
||||||
pass->impl->dxPass = current;
|
pass->impl->dxPass = current;
|
||||||
pass->impl->dxPass->AddRef();
|
pass->impl->dxPass->AddRef();
|
||||||
@ -385,4 +414,368 @@ namespace xna {
|
|||||||
auto collection = snew<EffectPassCollection>(list);
|
auto collection = snew<EffectPassCollection>(list);
|
||||||
return collection;
|
return collection;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
EffectParameter::EffectParameter() {
|
||||||
|
impl = unew<PlatformImplementation>();
|
||||||
|
}
|
||||||
|
|
||||||
|
PEffectAnnotationCollection EffectParameter::Annotations() const {
|
||||||
|
D3DX11_EFFECT_VARIABLE_DESC desc;
|
||||||
|
const auto hr = impl->dxVariable->GetDesc(&desc);
|
||||||
|
|
||||||
|
if FAILED(hr)
|
||||||
|
throw std::runtime_error("EffectParameter::Annotations: error getting D3DX11_EFFECT_VARIABLE_DESC");
|
||||||
|
|
||||||
|
auto annotCount = desc.Annotations;
|
||||||
|
|
||||||
|
if (annotCount == 0)
|
||||||
|
return snew<EffectAnnotationCollection>();
|
||||||
|
|
||||||
|
std::vector<PEffectAnnotation> list(annotCount);
|
||||||
|
|
||||||
|
for (size_t i = 0; i < annotCount; ++i) {
|
||||||
|
auto current = impl->dxVariable->GetAnnotationByIndex(i);
|
||||||
|
auto annotation = snew<EffectAnnotation>();
|
||||||
|
annotation->impl->dxVariable = current;
|
||||||
|
annotation->impl->dxVariable->AddRef();
|
||||||
|
|
||||||
|
current->Release();
|
||||||
|
current = nullptr;
|
||||||
|
|
||||||
|
list[i] = annotation;
|
||||||
|
}
|
||||||
|
|
||||||
|
auto collection = snew<EffectAnnotationCollection>(list);
|
||||||
|
return collection;
|
||||||
|
}
|
||||||
|
|
||||||
|
Int EffectParameter::ColumnCount() const {
|
||||||
|
auto type = impl->dxVariable->GetType();
|
||||||
|
D3DX11_EFFECT_TYPE_DESC desc{};
|
||||||
|
const auto hr = type->GetDesc(&desc);
|
||||||
|
|
||||||
|
type->Release();
|
||||||
|
type = nullptr;
|
||||||
|
|
||||||
|
if FAILED(hr)
|
||||||
|
throw std::runtime_error("EffectParameter::ColumnCount: error getting D3DX11_EFFECT_VARIABLE_DESC");
|
||||||
|
|
||||||
|
return static_cast<Int>(desc.Columns);
|
||||||
|
}
|
||||||
|
|
||||||
|
Int EffectParameter::RowCount() const {
|
||||||
|
auto type = impl->dxVariable->GetType();
|
||||||
|
D3DX11_EFFECT_TYPE_DESC desc{};
|
||||||
|
const auto hr = type->GetDesc(&desc);
|
||||||
|
|
||||||
|
type->Release();
|
||||||
|
type = nullptr;
|
||||||
|
|
||||||
|
if FAILED(hr)
|
||||||
|
throw std::runtime_error("EffectParameter::RowCount: error getting D3DX11_EFFECT_TYPE_DESC");
|
||||||
|
|
||||||
|
return static_cast<Int>(desc.Rows);
|
||||||
|
}
|
||||||
|
|
||||||
|
String EffectParameter::Semantic() const {
|
||||||
|
auto type = impl->dxVariable->GetType();
|
||||||
|
auto semantic = type->GetMemberSemantic(0);
|
||||||
|
|
||||||
|
type->Release();
|
||||||
|
type = nullptr;
|
||||||
|
|
||||||
|
return std::string(semantic);
|
||||||
|
}
|
||||||
|
|
||||||
|
EffectParameterType EffectParameter::ParameterType() const {
|
||||||
|
auto type = impl->dxVariable->GetType();
|
||||||
|
D3DX11_EFFECT_TYPE_DESC desc{};
|
||||||
|
const auto hr = type->GetDesc(&desc);
|
||||||
|
|
||||||
|
type->Release();
|
||||||
|
type = nullptr;
|
||||||
|
|
||||||
|
if FAILED(hr)
|
||||||
|
throw std::runtime_error("EffectParameter::ParameterType: error getting D3DX11_EFFECT_TYPE_DESC");
|
||||||
|
|
||||||
|
switch (desc.Type)
|
||||||
|
{
|
||||||
|
case D3D_SHADER_VARIABLE_TYPE::D3D_SVT_BOOL:
|
||||||
|
return EffectParameterType::Bool;
|
||||||
|
case D3D_SHADER_VARIABLE_TYPE::D3D_SVT_INT:
|
||||||
|
return EffectParameterType::Int32;
|
||||||
|
case D3D_SHADER_VARIABLE_TYPE::D3D_SVT_FLOAT:
|
||||||
|
return EffectParameterType::Single;
|
||||||
|
case D3D_SHADER_VARIABLE_TYPE::D3D_SVT_STRING:
|
||||||
|
return EffectParameterType::String;
|
||||||
|
case D3D_SHADER_VARIABLE_TYPE::D3D_SVT_TEXTURE:
|
||||||
|
return EffectParameterType::Texture;
|
||||||
|
case D3D_SHADER_VARIABLE_TYPE::D3D_SVT_TEXTURE1D:
|
||||||
|
return EffectParameterType::Texture1D;
|
||||||
|
case D3D_SHADER_VARIABLE_TYPE::D3D_SVT_TEXTURE2D:
|
||||||
|
return EffectParameterType::Texture2D;
|
||||||
|
case D3D_SHADER_VARIABLE_TYPE::D3D_SVT_TEXTURE3D:
|
||||||
|
return EffectParameterType::Texture3D;
|
||||||
|
case D3D_SHADER_VARIABLE_TYPE::D3D_SVT_TEXTURECUBE:
|
||||||
|
return EffectParameterType::TextureCube;
|
||||||
|
case D3D_SHADER_VARIABLE_TYPE::D3D_SVT_VOID:
|
||||||
|
return EffectParameterType::Void;
|
||||||
|
default:
|
||||||
|
throw std::runtime_error("EffectParameter::ParameterType: invalid EffectParameterType.");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
EffectParameterClass EffectParameter::ParameterClass() const {
|
||||||
|
auto type = impl->dxVariable->GetType();
|
||||||
|
D3DX11_EFFECT_TYPE_DESC desc{};
|
||||||
|
const auto hr = type->GetDesc(&desc);
|
||||||
|
|
||||||
|
type->Release();
|
||||||
|
type = nullptr;
|
||||||
|
|
||||||
|
if FAILED(hr)
|
||||||
|
throw std::runtime_error("EffectParameter::ParameterClass: error getting D3DX11_EFFECT_TYPE_DESC");
|
||||||
|
|
||||||
|
switch (desc.Class)
|
||||||
|
{
|
||||||
|
case D3D_SHADER_VARIABLE_CLASS::D3D_SVC_MATRIX_COLUMNS:
|
||||||
|
case D3D_SHADER_VARIABLE_CLASS::D3D_SVC_MATRIX_ROWS:
|
||||||
|
return EffectParameterClass::Matrix;
|
||||||
|
case D3D_SHADER_VARIABLE_CLASS::D3D_SVC_OBJECT:
|
||||||
|
return EffectParameterClass::Object;
|
||||||
|
case D3D_SHADER_VARIABLE_CLASS::D3D_SVC_SCALAR:
|
||||||
|
return EffectParameterClass::Scalar;
|
||||||
|
case D3D_SHADER_VARIABLE_CLASS::D3D_SVC_STRUCT:
|
||||||
|
return EffectParameterClass::Struct;
|
||||||
|
case D3D_SHADER_VARIABLE_CLASS::D3D_SVC_VECTOR:
|
||||||
|
return EffectParameterClass::Vector;
|
||||||
|
default:
|
||||||
|
throw std::runtime_error("EffectParameter::ParameterClass: invalid EffectParameterClass.");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
String EffectParameter::Name() const {
|
||||||
|
auto type = impl->dxVariable->GetType();
|
||||||
|
D3DX11_EFFECT_TYPE_DESC desc{};
|
||||||
|
const auto hr = type->GetDesc(&desc);
|
||||||
|
|
||||||
|
type->Release();
|
||||||
|
type = nullptr;
|
||||||
|
|
||||||
|
if FAILED(hr)
|
||||||
|
throw std::runtime_error("EffectParameter::Name: error getting D3DX11_EFFECT_TYPE_DESC");
|
||||||
|
|
||||||
|
return String(desc.TypeName);
|
||||||
|
}
|
||||||
|
|
||||||
|
sptr<EffectParameterCollection> EffectParameter::Elements() const {
|
||||||
|
uint32_t index = 0;
|
||||||
|
|
||||||
|
auto collection = snew<EffectParameterCollection>();
|
||||||
|
|
||||||
|
while (true) {
|
||||||
|
auto el = impl->dxVariable->GetElement(index);
|
||||||
|
|
||||||
|
if (!el)
|
||||||
|
break;
|
||||||
|
|
||||||
|
auto efparam = snew<EffectParameter>();
|
||||||
|
efparam->impl->dxVariable = el;
|
||||||
|
efparam->impl->dxVariable->AddRef();
|
||||||
|
|
||||||
|
el->Release();
|
||||||
|
el = nullptr;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
return collection;
|
||||||
|
}
|
||||||
|
|
||||||
|
sptr<EffectParameterCollection> EffectParameter::StructureMembers() const {
|
||||||
|
uint32_t index = 0;
|
||||||
|
|
||||||
|
auto collection = snew<EffectParameterCollection>();
|
||||||
|
|
||||||
|
while (true) {
|
||||||
|
auto member = impl->dxVariable->GetMemberByIndex(index);
|
||||||
|
|
||||||
|
if (!member)
|
||||||
|
break;
|
||||||
|
|
||||||
|
auto efparam = snew<EffectParameter>();
|
||||||
|
efparam->impl->dxVariable = member;
|
||||||
|
efparam->impl->dxVariable->AddRef();
|
||||||
|
|
||||||
|
member->Release();
|
||||||
|
member = nullptr;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
return collection;
|
||||||
|
}
|
||||||
|
|
||||||
|
bool EffectParameter::GetValueBoolean() const {
|
||||||
|
auto scalar = impl->dxVariable->AsScalar();
|
||||||
|
|
||||||
|
bool value;
|
||||||
|
const auto hr = scalar->GetBool(&value);
|
||||||
|
scalar->Release();
|
||||||
|
scalar = nullptr;
|
||||||
|
|
||||||
|
if FAILED(hr)
|
||||||
|
throw std::runtime_error("EffectParameter::GetValueBoolean: Unable to get boolean value.");
|
||||||
|
|
||||||
|
return value;
|
||||||
|
}
|
||||||
|
|
||||||
|
std::vector<bool> EffectParameter::GetValueBooleanArray(size_t count) const {
|
||||||
|
auto scalar = impl->dxVariable->AsScalar();
|
||||||
|
auto arr = std::make_unique<bool[]>(count);
|
||||||
|
|
||||||
|
const auto hr = scalar->GetBoolArray(arr.get(), 0, count);
|
||||||
|
scalar->Release();
|
||||||
|
scalar = nullptr;
|
||||||
|
|
||||||
|
if FAILED(hr)
|
||||||
|
throw std::runtime_error("EffectParameter::GetValueBooleanArray: Unable to get boolean value.");
|
||||||
|
|
||||||
|
std::vector<bool> data(count);
|
||||||
|
|
||||||
|
for (size_t i = 0; i < count; ++i) {
|
||||||
|
data[i] = arr[i];
|
||||||
|
}
|
||||||
|
|
||||||
|
return data;
|
||||||
|
}
|
||||||
|
|
||||||
|
Int EffectParameter::GetValueInt32() const {
|
||||||
|
auto scalar = impl->dxVariable->AsScalar();
|
||||||
|
|
||||||
|
Int value;
|
||||||
|
const auto hr = scalar->GetInt(&value);
|
||||||
|
scalar->Release();
|
||||||
|
scalar = nullptr;
|
||||||
|
|
||||||
|
if FAILED(hr)
|
||||||
|
throw std::runtime_error("EffectParameter::GetValueInt32: Unable to get int value.");
|
||||||
|
|
||||||
|
return value;
|
||||||
|
}
|
||||||
|
|
||||||
|
std::vector<Int> EffectParameter::GetValueInt32Array(size_t count) const {
|
||||||
|
auto scalar = impl->dxVariable->AsScalar();
|
||||||
|
std::vector<Int> data(count);
|
||||||
|
|
||||||
|
const auto hr = scalar->GetIntArray(data.data(), 0, count);
|
||||||
|
scalar->Release();
|
||||||
|
scalar = nullptr;
|
||||||
|
|
||||||
|
if FAILED(hr)
|
||||||
|
throw std::runtime_error("EffectParameter::GetValueInt32Array: Unable to get int value.");
|
||||||
|
|
||||||
|
return data;
|
||||||
|
}
|
||||||
|
|
||||||
|
Matrix EffectParameter::GetValueMatrix() const {
|
||||||
|
auto matrix = impl->dxVariable->AsMatrix();
|
||||||
|
float values[16];
|
||||||
|
auto hr = matrix->GetMatrix(values);
|
||||||
|
matrix->Release();
|
||||||
|
matrix = nullptr;
|
||||||
|
|
||||||
|
if FAILED(hr)
|
||||||
|
throw std::runtime_error("EffectParameter::GetValueIntMatrix: Unable to get matrix value.");
|
||||||
|
|
||||||
|
Matrix m;
|
||||||
|
m.M11 = values[0];
|
||||||
|
m.M12 = values[1];
|
||||||
|
m.M13 = values[2];
|
||||||
|
m.M14 = values[3];
|
||||||
|
m.M21 = values[4];
|
||||||
|
m.M22 = values[5];
|
||||||
|
m.M23 = values[6];
|
||||||
|
m.M24 = values[7];
|
||||||
|
m.M31 = values[8];
|
||||||
|
m.M32 = values[9];
|
||||||
|
m.M33 = values[10];
|
||||||
|
m.M34 = values[11];
|
||||||
|
m.M41 = values[12];
|
||||||
|
m.M42 = values[13];
|
||||||
|
m.M43 = values[14];
|
||||||
|
m.M44 = values[15];
|
||||||
|
|
||||||
|
return m;
|
||||||
|
}
|
||||||
|
|
||||||
|
std::vector<Matrix> EffectParameter::GetValueMatrixArray(size_t count) const {
|
||||||
|
auto matrix = impl->dxVariable->AsMatrix();
|
||||||
|
const auto elements = count * 16;
|
||||||
|
auto arr = std::make_unique<float[]>(count * elements);
|
||||||
|
|
||||||
|
auto hr = matrix->GetMatrixArray(arr.get(), 0, elements);
|
||||||
|
matrix->Release();
|
||||||
|
matrix = nullptr;
|
||||||
|
|
||||||
|
if FAILED(hr)
|
||||||
|
throw std::runtime_error("EffectParameter::GetValuetMatrixArray: Unable to get matrix value.");
|
||||||
|
|
||||||
|
auto index = 0;
|
||||||
|
std::vector<Matrix> data(count);
|
||||||
|
|
||||||
|
for (size_t i = 0; i < elements; ++i) {
|
||||||
|
Matrix m;
|
||||||
|
m.M11 = arr[i];
|
||||||
|
m.M12 = arr[++i];
|
||||||
|
m.M13 = arr[++i];
|
||||||
|
m.M14 = arr[++i];
|
||||||
|
m.M21 = arr[++i];
|
||||||
|
m.M22 = arr[++i];
|
||||||
|
m.M23 = arr[++i];
|
||||||
|
m.M24 = arr[++i];
|
||||||
|
m.M31 = arr[++i];
|
||||||
|
m.M32 = arr[++i];
|
||||||
|
m.M33 = arr[++i];
|
||||||
|
m.M34 = arr[++i];
|
||||||
|
m.M41 = arr[++i];
|
||||||
|
m.M42 = arr[++i];
|
||||||
|
m.M43 = arr[++i];
|
||||||
|
m.M44 = arr[++i];
|
||||||
|
|
||||||
|
data[index] = m;
|
||||||
|
++index;
|
||||||
|
}
|
||||||
|
|
||||||
|
return data;
|
||||||
|
}
|
||||||
|
|
||||||
|
Matrix EffectParameter::GetValueMatrixTranspose() const {
|
||||||
|
auto matrix = impl->dxVariable->AsMatrix();
|
||||||
|
float values[16];
|
||||||
|
auto hr = matrix->GetMatrixTranspose(values);
|
||||||
|
matrix->Release();
|
||||||
|
matrix = nullptr;
|
||||||
|
|
||||||
|
if FAILED(hr)
|
||||||
|
throw std::runtime_error("EffectParameter::GetValueIntMatrix: Unable to get matrix value.");
|
||||||
|
|
||||||
|
Matrix m;
|
||||||
|
m.M11 = values[0];
|
||||||
|
m.M12 = values[1];
|
||||||
|
m.M13 = values[2];
|
||||||
|
m.M14 = values[3];
|
||||||
|
m.M21 = values[4];
|
||||||
|
m.M22 = values[5];
|
||||||
|
m.M23 = values[6];
|
||||||
|
m.M24 = values[7];
|
||||||
|
m.M31 = values[8];
|
||||||
|
m.M32 = values[9];
|
||||||
|
m.M33 = values[10];
|
||||||
|
m.M34 = values[11];
|
||||||
|
m.M41 = values[12];
|
||||||
|
m.M42 = values[13];
|
||||||
|
m.M43 = values[14];
|
||||||
|
m.M44 = values[15];
|
||||||
|
|
||||||
|
return m;
|
||||||
|
}
|
||||||
}
|
}
|
@ -70,6 +70,8 @@ namespace xna {
|
|||||||
class SwapChain;
|
class SwapChain;
|
||||||
class Texture;
|
class Texture;
|
||||||
class Texture2D;
|
class Texture2D;
|
||||||
|
class Texture3D;
|
||||||
|
class TextureCube;
|
||||||
class RasterizerState;
|
class RasterizerState;
|
||||||
class SamplerState;
|
class SamplerState;
|
||||||
class Shader;
|
class Shader;
|
||||||
|
@ -5,189 +5,296 @@
|
|||||||
#include "../default.hpp"
|
#include "../default.hpp"
|
||||||
#include "gresource.hpp"
|
#include "gresource.hpp"
|
||||||
|
|
||||||
namespace xna {
|
namespace xna {
|
||||||
//Represents an annotation to an EffectParameter.
|
//Represents an annotation to an EffectParameter.
|
||||||
class EffectAnnotation {
|
class EffectAnnotation {
|
||||||
public:
|
public:
|
||||||
Int ColumCount() const;
|
Int ColumCount() const;
|
||||||
String Name() const;
|
String Name() const;
|
||||||
EffectParameterClass ParameterClass() const;
|
EffectParameterClass ParameterClass() const;
|
||||||
Int Rowcount() const;
|
Int RowCount() const;
|
||||||
String Semantic() const;
|
String Semantic() const;
|
||||||
bool GetValueBoolean() const;
|
bool GetValueBoolean() const;
|
||||||
Int GetValueInt32() const;
|
Int GetValueInt32() const;
|
||||||
Matrix GetValueMatrix() const;
|
Matrix GetValueMatrix() const;
|
||||||
float GetValueSingle() const;
|
float GetValueSingle() const;
|
||||||
String GetValueString() const;
|
String GetValueString() const;
|
||||||
Vector2 GetValueVector2() const;
|
Vector2 GetValueVector2() const;
|
||||||
Vector3 GetValueVector3() const;
|
Vector3 GetValueVector3() const;
|
||||||
Vector4 GetValueVector4() const;
|
Vector4 GetValueVector4() const;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
struct PlatformImplementation;
|
struct PlatformImplementation;
|
||||||
uptr<PlatformImplementation> impl;
|
uptr<PlatformImplementation> impl;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
EffectAnnotation();
|
EffectAnnotation();
|
||||||
};
|
};
|
||||||
|
using PEffectAnnotation = sptr<EffectAnnotation>;
|
||||||
|
|
||||||
using PEffectAnnotation = sptr<EffectAnnotation>;
|
class EffectAnnotationCollection {
|
||||||
|
public:
|
||||||
|
EffectAnnotationCollection() {}
|
||||||
|
|
||||||
class EffectAnnotationCollection {
|
EffectAnnotationCollection(std::vector<PEffectAnnotation> const& data) : data(data)
|
||||||
public:
|
{
|
||||||
EffectAnnotationCollection(){}
|
}
|
||||||
|
|
||||||
EffectAnnotationCollection(std::vector<PEffectAnnotation> const& data) : data(data)
|
|
||||||
{
|
|
||||||
}
|
|
||||||
|
|
||||||
constexpr size_t Count() const {
|
constexpr size_t Count() const {
|
||||||
return data.size();
|
return data.size();
|
||||||
}
|
}
|
||||||
|
|
||||||
PEffectAnnotation operator[](size_t index) {
|
PEffectAnnotation operator[](size_t index) {
|
||||||
if (index >= data.size())
|
if (index >= data.size())
|
||||||
return nullptr;
|
return nullptr;
|
||||||
|
|
||||||
return data[index];
|
return data[index];
|
||||||
}
|
}
|
||||||
|
|
||||||
PEffectAnnotation operator[](String const& name) {
|
PEffectAnnotation operator[](String const& name) {
|
||||||
for (size_t i = 0; i < data.size(); ++i) {
|
for (size_t i = 0; i < data.size(); ++i) {
|
||||||
const auto& p = data[i];
|
const auto& p = data[i];
|
||||||
|
|
||||||
if (p->Name() == name)
|
if (p->Name() == name)
|
||||||
return p;
|
return p;
|
||||||
}
|
}
|
||||||
|
|
||||||
return nullptr;
|
return nullptr;
|
||||||
}
|
}
|
||||||
|
|
||||||
public:
|
public:
|
||||||
std::vector<PEffectAnnotation> data;
|
std::vector<PEffectAnnotation> data;
|
||||||
};
|
};
|
||||||
|
using PEffectAnnotationCollection = sptr<EffectAnnotationCollection>;
|
||||||
|
|
||||||
using PEffectAnnotationCollection = sptr<EffectAnnotationCollection>;
|
class EffectPass {
|
||||||
|
public:
|
||||||
|
//Gets the name of this pass.
|
||||||
|
String Name() const;
|
||||||
|
//The EffectAnnotationCollection containing EffectAnnotation objects for this EffectPass.
|
||||||
|
PEffectAnnotationCollection Annotations() const;
|
||||||
|
|
||||||
class EffectPass {
|
//Begins this pass.
|
||||||
public:
|
void Apply();
|
||||||
//Gets the name of this pass.
|
public:
|
||||||
String Name() const;
|
struct PlatformImplementation;
|
||||||
//The EffectAnnotationCollection containing EffectAnnotation objects for this EffectPass.
|
uptr<PlatformImplementation> impl;
|
||||||
PEffectAnnotationCollection Annotations() const;
|
|
||||||
|
|
||||||
//Begins this pass.
|
public:
|
||||||
void Apply();
|
EffectPass();
|
||||||
public:
|
};
|
||||||
struct PlatformImplementation;
|
using PEffectPass = sptr<EffectPass>;
|
||||||
uptr<PlatformImplementation> impl;
|
|
||||||
|
|
||||||
public:
|
class EffectPassCollection {
|
||||||
EffectPass();
|
public:
|
||||||
};
|
EffectPassCollection() {}
|
||||||
|
|
||||||
using PEffectPass = sptr<EffectPass>;
|
EffectPassCollection(std::vector<PEffectPass> const& data) : data(data)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
class EffectPassCollection {
|
constexpr size_t Count() const {
|
||||||
public:
|
return data.size();
|
||||||
EffectPassCollection(){}
|
}
|
||||||
|
|
||||||
EffectPassCollection(std::vector<PEffectPass> const& data) : data(data)
|
PEffectPass operator[](size_t index) {
|
||||||
{
|
if (index >= data.size())
|
||||||
}
|
return nullptr;
|
||||||
|
|
||||||
constexpr size_t Count() const {
|
return data[index];
|
||||||
return data.size();
|
}
|
||||||
}
|
|
||||||
|
|
||||||
PEffectPass operator[](size_t index) {
|
PEffectPass operator[](String const& name) {
|
||||||
if (index >= data.size())
|
for (size_t i = 0; i < data.size(); ++i) {
|
||||||
return nullptr;
|
const auto& p = data[i];
|
||||||
|
|
||||||
return data[index];
|
if (p->Name() == name)
|
||||||
}
|
return p;
|
||||||
|
}
|
||||||
|
|
||||||
PEffectPass operator[](String const& name) {
|
return nullptr;
|
||||||
for (size_t i = 0; i < data.size(); ++i) {
|
}
|
||||||
const auto& p = data[i];
|
|
||||||
|
|
||||||
if (p->Name() == name)
|
public:
|
||||||
return p;
|
std::vector<PEffectPass> data;
|
||||||
}
|
};
|
||||||
|
using PEffectPassCollection = sptr<EffectPassCollection>;
|
||||||
|
|
||||||
return nullptr;
|
class EffectTechnique {
|
||||||
}
|
public:
|
||||||
|
PEffectAnnotationCollection Annotations() const;
|
||||||
|
String Name() const;
|
||||||
|
PEffectPassCollection Passes() const;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
std::vector<PEffectPass> data;
|
struct PlatformImplementation;
|
||||||
};
|
uptr<PlatformImplementation> impl;
|
||||||
|
|
||||||
using PEffectPassCollection = sptr<EffectPassCollection>;
|
public:
|
||||||
|
EffectTechnique();
|
||||||
|
};
|
||||||
|
using PEffectTechnique = sptr<EffectTechnique>;
|
||||||
|
|
||||||
class EffectTechnique {
|
class EffectParameterCollection;
|
||||||
public:
|
|
||||||
PEffectAnnotationCollection Annotations() const;
|
|
||||||
String Name() const;
|
|
||||||
PEffectPassCollection Passes() const;
|
|
||||||
|
|
||||||
public:
|
class EffectParameter {
|
||||||
struct PlatformImplementation;
|
public:
|
||||||
uptr<PlatformImplementation> impl;
|
//Gets the collection of EffectAnnotation objects for this parameter.
|
||||||
|
PEffectAnnotationCollection Annotations() const;
|
||||||
|
//Gets the number of columns in the parameter description.
|
||||||
|
Int ColumnCount() const;
|
||||||
|
//Gets the number of rows in the parameter description.
|
||||||
|
Int RowCount() const;
|
||||||
|
//Gets the semantic meaning, or usage, of the parameter.
|
||||||
|
String Semantic() const;
|
||||||
|
//Gets the type of the parameter.
|
||||||
|
EffectParameterType ParameterType() const;
|
||||||
|
//Gets the class of the parameter.
|
||||||
|
EffectParameterClass ParameterClass() const;
|
||||||
|
//Gets the name of the parameter.
|
||||||
|
String Name() const;
|
||||||
|
//Gets the collection of effect parameters.
|
||||||
|
sptr<EffectParameterCollection> Elements() const;
|
||||||
|
//Gets the collection of structure members.
|
||||||
|
sptr<EffectParameterCollection> StructureMembers() const;
|
||||||
|
|
||||||
public:
|
bool GetValueBoolean() const;
|
||||||
EffectTechnique();
|
std::vector<bool> GetValueBooleanArray(size_t count) const;
|
||||||
};
|
Int GetValueInt32() const;
|
||||||
|
std::vector <Int> GetValueInt32Array(size_t count) const;
|
||||||
|
Matrix GetValueMatrix() const;
|
||||||
|
std::vector <Matrix> GetValueMatrixArray(size_t count) const;
|
||||||
|
Matrix GetValueMatrixTranspose() const;
|
||||||
|
std::vector <Matrix> GetValueMatrixTransposeArray(size_t count) const;
|
||||||
|
Quaternion GetValueQuaternion() const;
|
||||||
|
std::vector <Quaternion> GetValueQuaternionArray() const;
|
||||||
|
float GetValueSingle() const;
|
||||||
|
std::vector<float> GetValueSingleArray() const;
|
||||||
|
String GetValueString() const;
|
||||||
|
sptr<Texture2D> GetValueTexture2D() const;
|
||||||
|
sptr<Texture3D> GetValueTexture3D() const;
|
||||||
|
sptr<TextureCube> GetValueTextureCube() const;
|
||||||
|
Vector2 GetValueVector2() const;
|
||||||
|
std::vector <Vector2> GetValueVector2Array() const;
|
||||||
|
Vector3 GetValueVector3() const;
|
||||||
|
std::vector <Vector3> GetValueVector3Array() const;
|
||||||
|
Vector4 GetValueVector4() const;
|
||||||
|
std::vector <Vector4> GetValueVector4Array() const;
|
||||||
|
|
||||||
using PEffectTechnique = sptr<EffectTechnique>;
|
void SetValue(bool value);
|
||||||
|
void SetValue(std::vector<bool> const& value);
|
||||||
|
void SetValue(Int value);
|
||||||
|
void SetValue(std::vector<Int> const& value);
|
||||||
|
void SetValue(float value);
|
||||||
|
void SetValue(std::vector<float> const& value);
|
||||||
|
void SetValue(Matrix const& value);
|
||||||
|
void SetValue(std::vector<Matrix> const& value);
|
||||||
|
void SetValue(Quaternion const& value);
|
||||||
|
void SetValue(std::vector<Quaternion> const& value);
|
||||||
|
void SetValue(Vector2 const& value);
|
||||||
|
void SetValue(std::vector<Vector2> const& value);
|
||||||
|
void SetValue(Vector3 const& value);
|
||||||
|
void SetValue(std::vector<Vector3> const& value);
|
||||||
|
void SetValue(Vector4 const& value);
|
||||||
|
void SetValue(std::vector<Vector4> const& value);
|
||||||
|
void SetValue(String const& value);
|
||||||
|
void SetValue(sptr<Texture> const& value);
|
||||||
|
|
||||||
class Effect : public GraphicsResource {
|
void SetValueTranspose(Matrix const& value);
|
||||||
Effect(sptr<GraphicsDevice> const& device, std::vector<Byte> const& effectCode);
|
void SetValueTranspose(std::vector<Matrix> const& value);
|
||||||
|
|
||||||
PEffectTechnique CurrentTechnique() const;
|
public:
|
||||||
|
struct PlatformImplementation;
|
||||||
|
uptr<PlatformImplementation> impl;
|
||||||
|
|
||||||
public:
|
public:
|
||||||
struct PlatformImplementation;
|
EffectParameter();
|
||||||
uptr<PlatformImplementation> impl;
|
};
|
||||||
};
|
using PEffectParameter = sptr<EffectParameter>;
|
||||||
|
|
||||||
class IEffectMatrices {
|
class EffectParameterCollection {
|
||||||
virtual Matrix World() const = 0;
|
public:
|
||||||
virtual Matrix View() const = 0;
|
EffectParameterCollection() {}
|
||||||
virtual Matrix Projection() const = 0;
|
|
||||||
|
|
||||||
virtual void World(Matrix const& value) = 0;
|
EffectParameterCollection(std::vector<PEffectParameter> const& data) : data(data)
|
||||||
virtual void View(Matrix const& value) = 0;
|
{
|
||||||
virtual void Projection(Matrix const& value) = 0;
|
}
|
||||||
};
|
|
||||||
|
|
||||||
class DirectionalLight;
|
constexpr size_t Count() const {
|
||||||
|
return data.size();
|
||||||
|
}
|
||||||
|
|
||||||
class IEffectLights {
|
PEffectParameter operator[](size_t index) {
|
||||||
virtual DirectionalLight DirectionalLight0() const = 0;
|
if (index >= data.size())
|
||||||
virtual DirectionalLight DirectionalLight1() const = 0;
|
return nullptr;
|
||||||
virtual DirectionalLight DirectionalLight2() const = 0;
|
|
||||||
|
|
||||||
virtual Vector3 AmbientLightColor() const = 0;
|
return data[index];
|
||||||
virtual void AmbientLightColor(Vector3 const& value) = 0;
|
}
|
||||||
|
|
||||||
virtual bool LightingEnabled() const = 0;
|
PEffectParameter operator[](String const& name) {
|
||||||
virtual void LightingEnabled(bool value) = 0;
|
for (size_t i = 0; i < data.size(); ++i) {
|
||||||
|
const auto& p = data[i];
|
||||||
|
|
||||||
virtual void EnableDefaultLighting() = 0;
|
if (p->Name() == name)
|
||||||
};
|
return p;
|
||||||
|
}
|
||||||
|
|
||||||
class IEffectFog
|
return nullptr;
|
||||||
{
|
}
|
||||||
virtual bool FogEnabled() const = 0;
|
|
||||||
virtual float FogStart() const = 0;
|
|
||||||
virtual float FogEnd() const = 0;
|
|
||||||
virtual Vector3 FogColor() const = 0;
|
|
||||||
|
|
||||||
virtual void FogEnabled(bool value) const = 0;
|
public:
|
||||||
virtual void FogStart(float value) const = 0;
|
std::vector<PEffectParameter> data;
|
||||||
virtual void FogEnd(float value) const = 0;
|
};
|
||||||
virtual void FogColor(Vector3 const& value) const = 0;
|
using PEffectPassCollection = sptr<EffectPassCollection>;
|
||||||
};
|
|
||||||
|
class Effect : public GraphicsResource {
|
||||||
|
Effect(sptr<GraphicsDevice> const& device, std::vector<Byte> const& effectCode);
|
||||||
|
|
||||||
|
PEffectTechnique CurrentTechnique() const;
|
||||||
|
|
||||||
|
public:
|
||||||
|
struct PlatformImplementation;
|
||||||
|
uptr<PlatformImplementation> impl;
|
||||||
|
};
|
||||||
|
|
||||||
|
class IEffectMatrices {
|
||||||
|
virtual Matrix World() const = 0;
|
||||||
|
virtual Matrix View() const = 0;
|
||||||
|
virtual Matrix Projection() const = 0;
|
||||||
|
|
||||||
|
virtual void World(Matrix const& value) = 0;
|
||||||
|
virtual void View(Matrix const& value) = 0;
|
||||||
|
virtual void Projection(Matrix const& value) = 0;
|
||||||
|
};
|
||||||
|
|
||||||
|
class DirectionalLight;
|
||||||
|
|
||||||
|
class IEffectLights {
|
||||||
|
virtual DirectionalLight DirectionalLight0() const = 0;
|
||||||
|
virtual DirectionalLight DirectionalLight1() const = 0;
|
||||||
|
virtual DirectionalLight DirectionalLight2() const = 0;
|
||||||
|
|
||||||
|
virtual Vector3 AmbientLightColor() const = 0;
|
||||||
|
virtual void AmbientLightColor(Vector3 const& value) = 0;
|
||||||
|
|
||||||
|
virtual bool LightingEnabled() const = 0;
|
||||||
|
virtual void LightingEnabled(bool value) = 0;
|
||||||
|
|
||||||
|
virtual void EnableDefaultLighting() = 0;
|
||||||
|
};
|
||||||
|
|
||||||
|
class IEffectFog
|
||||||
|
{
|
||||||
|
virtual bool FogEnabled() const = 0;
|
||||||
|
virtual float FogStart() const = 0;
|
||||||
|
virtual float FogEnd() const = 0;
|
||||||
|
virtual Vector3 FogColor() const = 0;
|
||||||
|
|
||||||
|
virtual void FogEnabled(bool value) const = 0;
|
||||||
|
virtual void FogStart(float value) const = 0;
|
||||||
|
virtual void FogEnd(float value) const = 0;
|
||||||
|
virtual void FogColor(Vector3 const& value) const = 0;
|
||||||
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
#endif
|
#endif
|
@ -963,6 +963,11 @@ namespace xna {
|
|||||||
dxPass->Release();
|
dxPass->Release();
|
||||||
dxPass = nullptr;
|
dxPass = nullptr;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (dxContext) {
|
||||||
|
dxContext->Release();
|
||||||
|
dxContext = nullptr;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
ID3DX11EffectPass* dxPass = nullptr;
|
ID3DX11EffectPass* dxPass = nullptr;
|
||||||
@ -975,12 +980,35 @@ namespace xna {
|
|||||||
dxTechnique->Release();
|
dxTechnique->Release();
|
||||||
dxTechnique = nullptr;
|
dxTechnique = nullptr;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (dxContext) {
|
||||||
|
dxContext->Release();
|
||||||
|
dxContext = nullptr;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
ID3DX11EffectTechnique* dxTechnique = nullptr;
|
ID3DX11EffectTechnique* dxTechnique = nullptr;
|
||||||
ID3D11DeviceContext* dxContext = nullptr;
|
ID3D11DeviceContext* dxContext = nullptr;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
struct EffectParameter::PlatformImplementation {
|
||||||
|
PlatformImplementation(){}
|
||||||
|
|
||||||
|
PlatformImplementation(ID3DX11EffectVariable* value) {
|
||||||
|
dxVariable = value;
|
||||||
|
dxVariable->AddRef();
|
||||||
|
}
|
||||||
|
|
||||||
|
~PlatformImplementation() {
|
||||||
|
if (dxVariable) {
|
||||||
|
dxVariable->Release();
|
||||||
|
dxVariable = nullptr;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
ID3DX11EffectVariable* dxVariable = nullptr;
|
||||||
|
};
|
||||||
|
|
||||||
template <typename T>
|
template <typename T>
|
||||||
inline bool IndexBuffer::Initialize(std::vector<T> const& data, xna_error_ptr_arg) {
|
inline bool IndexBuffer::Initialize(std::vector<T> const& data, xna_error_ptr_arg) {
|
||||||
if (!impl || !m_device || !m_device->impl->_device || data.empty()) {
|
if (!impl || !m_device || !m_device->impl->_device || data.empty()) {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user