mirror of
https://github.com/borgesdan/xn65
synced 2024-12-29 21:54:47 +01:00
Implementa EffectTechnique
This commit is contained in:
parent
75e7a7273d
commit
d7583015a2
@ -262,4 +262,62 @@ namespace xna {
|
||||
|
||||
impl->dxPass->Apply(0, impl->graphicsDevice->impl->_context);
|
||||
}
|
||||
|
||||
EffectTechnique::EffectTechnique(sptr<GraphicsDevice> const& device) {
|
||||
impl = unew<PlatformImplementation>();
|
||||
impl->graphicsDevice = device;
|
||||
}
|
||||
|
||||
String EffectTechnique::Name() const {
|
||||
D3DX11_TECHNIQUE_DESC desc;
|
||||
impl->dxTechnique->GetDesc(&desc);
|
||||
|
||||
return String(desc.Name);
|
||||
}
|
||||
|
||||
PEffectAnnotationCollection EffectTechnique::Annotations() const {
|
||||
D3DX11_TECHNIQUE_DESC desc;
|
||||
impl->dxTechnique->GetDesc(&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->dxTechnique->GetAnnotationByIndex(i);
|
||||
auto annotation = snew<EffectAnnotation>();
|
||||
annotation->impl->dxVariable = current;
|
||||
|
||||
list[i] = annotation;
|
||||
}
|
||||
|
||||
auto collection = snew<EffectAnnotationCollection>(list);
|
||||
return collection;
|
||||
}
|
||||
|
||||
PEffectPassCollection EffectTechnique::Passes() const {
|
||||
D3DX11_TECHNIQUE_DESC desc;
|
||||
impl->dxTechnique->GetDesc(&desc);
|
||||
|
||||
auto passCount = desc.Passes;
|
||||
|
||||
if (passCount == 0)
|
||||
return snew<EffectPassCollection>();
|
||||
|
||||
std::vector<PEffectPass> list(passCount);
|
||||
|
||||
for (size_t i = 0; i < passCount; ++i) {
|
||||
auto current = impl->dxTechnique->GetPassByIndex(i);
|
||||
auto pass = snew<EffectPass>(impl->graphicsDevice);
|
||||
pass->impl->dxPass = current;
|
||||
|
||||
list[i] = pass;
|
||||
}
|
||||
|
||||
auto collection = snew<EffectPassCollection>(list);
|
||||
return collection;
|
||||
}
|
||||
}
|
@ -35,7 +35,7 @@ namespace xna {
|
||||
|
||||
class EffectAnnotationCollection {
|
||||
public:
|
||||
EffectAnnotationCollection();
|
||||
EffectAnnotationCollection(){}
|
||||
|
||||
EffectAnnotationCollection(std::vector<PEffectAnnotation> const& data) : data(data)
|
||||
{
|
||||
@ -94,6 +94,58 @@ namespace xna {
|
||||
uptr<PlatformImplementation> impl;
|
||||
};
|
||||
|
||||
using PEffectPass = sptr<EffectPass>;
|
||||
|
||||
class EffectPassCollection {
|
||||
public:
|
||||
EffectPassCollection(){}
|
||||
|
||||
EffectPassCollection(std::vector<PEffectPass> const& data) : data(data)
|
||||
{
|
||||
}
|
||||
|
||||
constexpr size_t Count() const {
|
||||
return data.size();
|
||||
}
|
||||
|
||||
PEffectPass operator[](size_t index) {
|
||||
if (index >= data.size())
|
||||
return nullptr;
|
||||
|
||||
return data[index];
|
||||
}
|
||||
|
||||
PEffectPass operator[](String const& name) {
|
||||
for (size_t i = 0; i < data.size(); ++i) {
|
||||
const auto& p = data[i];
|
||||
|
||||
if (p->Name() == name)
|
||||
return p;
|
||||
}
|
||||
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
public:
|
||||
std::vector<PEffectPass> data;
|
||||
};
|
||||
|
||||
using PEffectPassCollection = sptr<EffectPassCollection>;
|
||||
|
||||
class EffectTechnique {
|
||||
public:
|
||||
PEffectAnnotationCollection Annotations() const;
|
||||
String Name() const;
|
||||
PEffectPassCollection Passes() const;
|
||||
|
||||
public:
|
||||
struct PlatformImplementation;
|
||||
uptr<PlatformImplementation> impl;
|
||||
|
||||
public:
|
||||
EffectTechnique(sptr<GraphicsDevice> const& device);
|
||||
};
|
||||
|
||||
class IEffectMatrices {
|
||||
virtual Matrix World() const = 0;
|
||||
virtual Matrix View() const = 0;
|
||||
|
@ -969,6 +969,18 @@ namespace xna {
|
||||
PGraphicsDevice graphicsDevice = nullptr;
|
||||
};
|
||||
|
||||
struct EffectTechnique::PlatformImplementation {
|
||||
~PlatformImplementation() {
|
||||
if (dxTechnique) {
|
||||
dxTechnique->Release();
|
||||
dxTechnique = nullptr;
|
||||
}
|
||||
}
|
||||
|
||||
ID3DX11EffectTechnique* dxTechnique = nullptr;
|
||||
PGraphicsDevice graphicsDevice = nullptr;
|
||||
};
|
||||
|
||||
template <typename T>
|
||||
inline bool IndexBuffer::Initialize(std::vector<T> const& data, xna_error_ptr_arg) {
|
||||
if (!impl || !m_device || !m_device->impl->_device || data.empty()) {
|
||||
|
Loading…
x
Reference in New Issue
Block a user