CPP-TOOLBOX
Loading...
Searching...
No Matches
main Namespace Reference

Classes

class  BatcherCppClassCreator
 
class  DrawInfo
 
class  ShaderBatcherCppClass
 
class  ShaderBatcherCppStruct
 
class  ShaderRequest
 

Functions

 snake_to_camel_case (snake_str)
 
 get_draw_data_struct_name (ShaderType shader_type)
 
 list_available_shaders (shader_to_used_vertex_attribute_variables)
 
 wipe_generated_directory ()
 
List[ShaderRequestget_required_shaders (config_file)
 
List["ShaderRequest"] validate_shader_specs (List[str] shader_specs)
 
 extract_variables_from_shader (str shader_code)
 
 validate_types (shader_variables, verbose)
 
Tuple validate_shader (str shader_code, ShaderProgram shader_program, bool verbose)
 
 validate_all_shaders (shader_catalog, shader_directory, bool verbose, bool output_info)
 
 generate_cpp (shader_info)
 
 generate_py_shader_summary (shader_info)
 

Variables

str constructor_body_template
 
str destructor_body_template
 
str TAB = " "
 
dict draw_info_struct_hierarchy
 
dict shader_vertex_attribute_variables_to_valid_draw_info_structs
 
CppParameter ivp_param
 
CppParameter ivp_param_ref
 
CppParameter ivpn_param
 
CppParameter ivpn_param_ref = CppParameter("ivpn", DrawInfo.IVPNORMALS.value, "", True)
 
CppParameter ivpc_param
 
CppParameter ivpc_param_ref = CppParameter("ivpc", DrawInfo.IVPCOLOR.value, "", True)
 
CppParameter ivpnc_param
 
CppParameter ivpnc_param_ref
 
dict ivpX_struct_to_param_ref
 
dict ivpX_param_to_superclass_params
 
dict ivpX_param_ref_to_superclass_param_refs
 
 parser = argparse.ArgumentParser(description="Generate C++ shader batcher classes.")
 
 action
 
 help
 
 type
 
 default
 
 args = parser.parse_args()
 
 user_shader_requests
 
 config_file_path
 
 shader_name = str(shader).split(".")[-1].lower()
 
list constructed_class_names = []
 
list constructed_header_files = []
 
str script_directory = os.path.dirname(os.path.abspath(__file__)) + "/generated"
 
int num_elements_in_buffer = 100000
 
str header_file = f"{shader_type.name.lower()}_shader_batcher.hpp"
 
 header_filename
 
 source_filename
 
 shader_batcher_header_and_source
 
 shader_batcher
 
 batcher_class = shader_batcher.generate_cpp_class()
 
 source_content = shader_batcher_header_and_source.generate_source_content()
 
 header_content = shader_batcher_header_and_source.generate_header_content()
 
 batcher_cpp_class_creator = BatcherCppClassCreator(constructed_class_names)
 
tuple include_statements
 
 batcher_header_and_source = CppHeaderAndSource("batcher")
 
 shader_info = validate_all_shaders(shader_catalog, args.shader_directory, args.verbose, args.summary)
 

Function Documentation

◆ extract_variables_from_shader()

main.extract_variables_from_shader ( str shader_code)
Extracts uniforms and attributes from the shader code.
Returns a dictionary with uniforms and vertex attributes along with their types.

◆ generate_cpp()

main.generate_cpp ( shader_info)

◆ generate_py_shader_summary()

main.generate_py_shader_summary ( shader_info)

◆ get_draw_data_struct_name()

main.get_draw_data_struct_name ( ShaderType shader_type)

◆ get_required_shaders()

List[ShaderRequest] main.get_required_shaders ( config_file)
Read the configuration file and return a list of ShaderRequest objects after validation.

◆ list_available_shaders()

main.list_available_shaders ( shader_to_used_vertex_attribute_variables)

◆ snake_to_camel_case()

main.snake_to_camel_case ( snake_str)

◆ validate_all_shaders()

main.validate_all_shaders ( shader_catalog,
shader_directory,
bool verbose,
bool output_info )
Iterates over all shaders in the shader catalog and validates them.
:param shader_catalog: Dictionary mapping ShaderType to ShaderProgram instances.
:param shader_directory: The directory where shader files are located.
:param output_info: Whether to output shader variable information.

◆ validate_shader()

Tuple main.validate_shader ( str shader_code,
ShaderProgram shader_program,
bool verbose )
Validates a shader file by logging issues if found.

◆ validate_shader_specs()

List["ShaderRequest"] main.validate_shader_specs ( List[str] shader_specs)
Validate shader specs and return a list of ShaderRequest objects (shader + buffer size).

◆ validate_types()

main.validate_types ( shader_variables,
verbose )
Validates the types of uniforms and attributes against expected types from dictionaries.

◆ wipe_generated_directory()

main.wipe_generated_directory ( )

Variable Documentation

◆ action

main.action

◆ args

main.args = parser.parse_args()

◆ batcher_class

main.batcher_class = shader_batcher.generate_cpp_class()

◆ batcher_cpp_class_creator

main.batcher_cpp_class_creator = BatcherCppClassCreator(constructed_class_names)

◆ batcher_header_and_source

main.batcher_header_and_source = CppHeaderAndSource("batcher")

◆ config_file_path

main.config_file_path
Initial value:
1= os.path.join(
2 args.config_file_output_dir, ".all_required_shader_batchers.txt"
3 )

◆ constructed_class_names

list main.constructed_class_names = []

◆ constructed_header_files

list main.constructed_header_files = []

◆ constructor_body_template

str main.constructor_body_template
Initial value:
1= """
2glGenVertexArrays(1, &vertex_attribute_object);
3glBindVertexArray(vertex_attribute_object);
4
5REPLACE_ME
6
7glBindVertexArray(0);
8"""

◆ default

main.default

◆ destructor_body_template

str main.destructor_body_template
Initial value:
1= """
2glGenVertexArrays(1, &vertex_attribute_object);
3glBindVertexArray(vertex_attribute_object);
4
5REPLACE_ME
6
7glBindVertexArray(0);
8"""

◆ draw_info_struct_hierarchy

dict main.draw_info_struct_hierarchy
Initial value:
1= {
2 DrawInfo.INDEXED_VERTEX_POSITIONS: {
3 DrawInfo.IVPNORMALS: {DrawInfo.IVPNCOLOR: {}, DrawInfo.IVPNTEXTURED: {}},
4 DrawInfo.IVPTEXTURED: {},
5 DrawInfo.IVPCOLOR: {},
6 }
7}

◆ header_content

main.header_content = shader_batcher_header_and_source.generate_header_content()

◆ header_file

str main.header_file = f"{shader_type.name.lower()}_shader_batcher.hpp"

◆ header_filename

main.header_filename
Initial value:
1= os.path.join(
2 script_directory, f"{shader_type.name.lower()}_shader_batcher.hpp"
3 )

◆ help

main.help

◆ include_statements

tuple main.include_statements
Initial value:
1= (
2 "\n".join(
3 [
4 f'#include "{header_file}"'
5 for header_file in constructed_header_files
6 ]
7 )
8 + "\n\n"
9 )

◆ ivp_param

CppParameter main.ivp_param
Initial value:
1= CppParameter(
2 "ivp",
3 DrawInfo.INDEXED_VERTEX_POSITIONS.value,
4 "",
5)

◆ ivp_param_ref

CppParameter main.ivp_param_ref
Initial value:
1= CppParameter(
2 "ivp", DrawInfo.INDEXED_VERTEX_POSITIONS.value, "", True
3)

◆ ivpc_param

CppParameter main.ivpc_param
Initial value:
1= CppParameter(
2 "ivpc",
3 DrawInfo.IVPCOLOR.value,
4 "",
5)

◆ ivpc_param_ref

CppParameter main.ivpc_param_ref = CppParameter("ivpc", DrawInfo.IVPCOLOR.value, "", True)

◆ ivpn_param

CppParameter main.ivpn_param
Initial value:
1= CppParameter(
2 "ivpn",
3 DrawInfo.IVPNORMALS.value,
4 "",
5)

◆ ivpn_param_ref

CppParameter main.ivpn_param_ref = CppParameter("ivpn", DrawInfo.IVPNORMALS.value, "", True)

◆ ivpnc_param

CppParameter main.ivpnc_param
Initial value:
1= CppParameter(
2 "ivpnc",
3 DrawInfo.IVPNCOLOR.value,
4 "",
5)

◆ ivpnc_param_ref

CppParameter main.ivpnc_param_ref
Initial value:
1= CppParameter(
2 "ivpnc", DrawInfo.IVPNCOLOR.value, "", True
3)

◆ ivpX_param_ref_to_superclass_param_refs

dict main.ivpX_param_ref_to_superclass_param_refs
Initial value:
1= {
2 ivp_param_ref: [ivp_param_ref, ivpn_param_ref, ivpc_param_ref, ivpnc_param_ref],
3 ivpn_param_ref: [ivpn_param_ref, ivpnc_param_ref],
4 ivpc_param_ref: [ivpc_param_ref, ivpnc_param_ref],
5 ivpnc_param_ref: [ivpnc_param_ref],
6}

◆ ivpX_param_to_superclass_params

dict main.ivpX_param_to_superclass_params
Initial value:
1= {
2 ivp_param: [ivp_param, ivpn_param, ivpc_param, ivpnc_param],
3 ivpn_param: [ivpn_param, ivpnc_param],
4 ivpc_param: [ivpc_param, ivpnc_param],
5 ivpnc_param: [ivpnc_param],
6}

◆ ivpX_struct_to_param_ref

dict main.ivpX_struct_to_param_ref
Initial value:
1= {
2 DrawInfo.INDEXED_VERTEX_POSITIONS: ivp_param_ref,
3 DrawInfo.IVPNORMALS: ivpn_param_ref,
4 DrawInfo.IVPCOLOR: ivpc_param_ref,
5 DrawInfo.IVPNCOLOR: ivpnc_param_ref,
6}

◆ num_elements_in_buffer

int main.num_elements_in_buffer = 100000

◆ parser

main.parser = argparse.ArgumentParser(description="Generate C++ shader batcher classes.")

◆ script_directory

str main.script_directory = os.path.dirname(os.path.abspath(__file__)) + "/generated"

◆ shader_batcher

main.shader_batcher
Initial value:
1= ShaderBatcherCppClass(
2 shader_type, num_elements_in_buffer, vertex_attributes
3 )

◆ shader_batcher_header_and_source

main.shader_batcher_header_and_source
Initial value:
1= CppHeaderAndSource(
2 f"{shader_type.name.lower()}_shader_batcher"
3 )

◆ shader_info

main.shader_info = validate_all_shaders(shader_catalog, args.shader_directory, args.verbose, args.summary)

◆ shader_name

main.shader_name = str(shader).split(".")[-1].lower()

◆ shader_vertex_attribute_variables_to_valid_draw_info_structs

dict main.shader_vertex_attribute_variables_to_valid_draw_info_structs
Initial value:
1= {
2 frozenset(
3 {ShaderVertexAttributeVariable.XYZ_POSITION}
4 ): DrawInfo.INDEXED_VERTEX_POSITIONS,
5 frozenset(
6 {
7 ShaderVertexAttributeVariable.XYZ_POSITION,
8 ShaderVertexAttributeVariable.PASSTHROUGH_NORMAL,
9 }
10 ): DrawInfo.IVPNORMALS,
11 frozenset(
12 {
13 ShaderVertexAttributeVariable.XYZ_POSITION,
14 ShaderVertexAttributeVariable.PASSTHROUGH_RGB_COLOR,
15 }
16 ): DrawInfo.IVPCOLOR,
17 frozenset(
18 {
19 ShaderVertexAttributeVariable.XYZ_POSITION,
20 ShaderVertexAttributeVariable.PASSTHROUGH_RGB_COLOR,
21 ShaderVertexAttributeVariable.PASSTHROUGH_NORMAL,
22 }
23 ): DrawInfo.IVPNCOLOR,
24}

◆ source_content

main.source_content = shader_batcher_header_and_source.generate_source_content()

◆ source_filename

main.source_filename
Initial value:
1= os.path.join(
2 script_directory, f"{shader_type.name.lower()}_shader_batcher.cpp"
3 )

◆ TAB

str main.TAB = " "

◆ type

main.type

◆ user_shader_requests

List main.user_shader_requests
Initial value:
1= list_available_shaders(
2 shader_to_used_vertex_attribute_variables
3 )