Public API¶
Public package interface for CrossGL Translator.
High-level translation API and command-line entry point for CrossGL Translator.
- crosstl._crosstl.translate(file_path, backend='cgl', save_shader=None, format_output=True)[source]¶
Translate a shader file to another language.
- Parameters:
file_path (str) – The path to the shader file
backend (str, optional) – The target language to translate to. Defaults to “cgl”.
save_shader (str, optional) – The path to save the translated shader. Defaults to None.
format_output (bool, optional) – Whether to format the generated code. Defaults to True.
- Returns:
The translated shader code
- Return type:
str
Formatting helpers for generated shader and compute source code.
- class crosstl.formatter.CodeFormatter(clang_format_path=None, spirv_tools_path=None)[source]¶
Bases:
objectFormats shader code using appropriate external tools
- class crosstl.formatter.ShaderLanguage(value)[source]¶
Bases:
EnumSupported shader languages for formatting
- crosstl.formatter.format_code(code, language=None, file_path=None)[source]¶
Format code using the CodeFormatter
This is a convenience function used by format_shader_code
- Parameters:
code – The shader code to format
language – ShaderLanguage enum or string
file_path – Optional file path for language detection
- Returns:
Formatted code string