gs-effect: Provide parameter count and index access

This commit is contained in:
Michael Fabian 'Xaymar' Dirks 2017-11-05 16:46:28 +01:00
parent f766a23019
commit a9b13787be
2 changed files with 20 additions and 9 deletions

View file

@ -62,17 +62,27 @@ gs_effect_t* GS::Effect::GetObject() {
return m_effect;
}
std::vector<GS::EffectParameter> GS::Effect::GetParameters() {
size_t GS::Effect::CountParameters() {
return (size_t)gs_effect_get_num_params(m_effect);
}
std::list<GS::EffectParameter> GS::Effect::GetParameters() {
size_t num = gs_effect_get_num_params(m_effect);
std::vector<GS::EffectParameter> ps;
ps.reserve(num);
std::list<GS::EffectParameter> ps;
for (size_t idx = 0; idx < num; idx++) {
ps.emplace_back(EffectParameter(gs_effect_get_param_by_idx(m_effect, idx)));
ps.emplace_back(GetParameter(idx));
}
return ps;
}
GS::EffectParameter GS::Effect::GetParameterByName(std::string name) {
GS::EffectParameter GS::Effect::GetParameter(size_t idx) {
gs_eparam_t* param = gs_effect_get_param_by_idx(m_effect, idx);
if (!param)
throw std::invalid_argument("parameter with index not found");
return EffectParameter(param);
}
GS::EffectParameter GS::Effect::GetParameter(std::string name) {
gs_eparam_t* param = gs_effect_get_param_by_name(m_effect, name.c_str());
if (!param)
throw std::invalid_argument("parameter with name not found");

View file

@ -22,7 +22,7 @@
#include <inttypes.h>
#include <memory>
#include <string>
#include <vector>
#include <list>
extern "C" {
#pragma warning( push )
#pragma warning( disable: 4201 )
@ -90,9 +90,10 @@ namespace GS {
gs_effect_t* GetObject();
std::vector<EffectParameter> GetParameters();
EffectParameter GetParameterByName(std::string name);
size_t CountParameters();
std::list<EffectParameter> GetParameters();
EffectParameter GetParameter(size_t idx);
EffectParameter GetParameter(std::string name);
protected:
gs_effect_t* m_effect;