Created
October 28, 2013 21:42
-
-
Save sherief/7205359 to your computer and use it in GitHub Desktop.
Uniform extraction from the parse tree of a LiteGraph Shader after it's been translated to GLSL.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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.semantic = std::string(Node.type); | |
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); | |
} | |
} | |
private: | |
static bool is_uniform_node(const semparse::semantic_graph_node& Node) | |
{ | |
if((Node.name == "variable_definition") || (Node.name == "hoisted_function_uniform")) | |
{ | |
if(Node.has_child("modifiers")) | |
{ | |
if(Node["modifiers"].has_child("uniform_modifier")) | |
{ | |
return true; | |
} | |
} | |
} | |
return false; | |
} | |
}; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment