Skip to content

Instantly share code, notes, and snippets.

@sherief
Created May 5, 2013 18:28
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save sherief/5521687 to your computer and use it in GitHub Desktop.
Save sherief/5521687 to your computer and use it in GitHub Desktop.
struct uniform_info
{
std::string name;
std::string type;
int component_count;
bool is_matrix;
int array_count;
GLint location;
pfn_void parameter_setting_function;
uniform_info()
{
array_count = 0;
location = INVALID_UNIFORM_LOCATION;
parameter_setting_function = NULL;
}
};
class uniform_extractor
{
public:
std::vector<uniform_info> uniforms;
void operator()(const semparse::semantic_graph_node& Node)
{
if(is_uniform_node(Node))
{
//Extract info
uniform_info Info;
Info.name = std::string(Node["variable_name"]);
Info.type = std::string(Node["type_name"]["type_name_identifier"]);
Info.component_count = component_count(Info.type);
Info.is_matrix = is_matrix(Info.type);
if(Node.has_child("array_count"))
{
Info.array_count = lexical_cast<int>(string(Node["array_count"]["count"]));
}
Info.parameter_setting_function = function_pointer_for_parameter_setting(Info.type);
assert(Info.parameter_setting_function != NULL);
uniforms.push_back(Info);
}
}
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment