feat: forge #include in sentences glsl
This commit is contained in:
@@ -86,7 +86,7 @@ uv-run-sample-%: .venv ## uv run (project) sample/(xxx)
|
||||
--sets sample/$*_sets.csv \
|
||||
--sentences-input sample/$*_sentences.txt \
|
||||
--functions \
|
||||
--forge-include \
|
||||
--includes \
|
||||
|
||||
.PHONY: ruff
|
||||
ruff: .venv ## ruff check
|
||||
|
||||
@@ -9,7 +9,7 @@
|
||||
```txt
|
||||
usage: glsl-glyphs [-h] [-i INPUT_FILE] [-n NAME] [-o OUTPUT_FILE] [-g NAMES_FILE] [-s SETS_FILE] [-f | --functions | --no-functions]
|
||||
[--sentences-input SENTENCES_FILE] [--sentences-output OUTPUT_FILE] [--sentences-only | --no-sentences-only]
|
||||
[-v | --verbose | --no-verbose] [-q | --quiet | --no-quiet]
|
||||
[--includes | --no-includes] [-v | --verbose | --no-verbose] [-q | --quiet | --no-quiet]
|
||||
|
||||
options:
|
||||
-h, --help show this help message and exit
|
||||
@@ -29,6 +29,8 @@ options:
|
||||
output sentences glsl file (default: build/{name}_sentences.glsl)
|
||||
--sentences-only, --no-sentences-only
|
||||
generate only sentences from names (does not read input image)
|
||||
--includes, --no-includes
|
||||
use #include preprocessor in GLSL (forge)
|
||||
-v, --verbose, --no-verbose
|
||||
more verbose logging
|
||||
-q, --quiet, --no-quiet
|
||||
|
||||
@@ -27,13 +27,14 @@ class Generator:
|
||||
self.target_path = pathlib.Path("build") / f"{params.target_name}.glsl"
|
||||
else:
|
||||
self.target_path = pathlib.Path(params.target_path)
|
||||
self.with_functions = params.functions
|
||||
if params.target_sentences_path is None:
|
||||
self.target_sentences_path = (
|
||||
pathlib.Path("build") / f"{params.target_name}_sentences.glsl"
|
||||
)
|
||||
else:
|
||||
self.target_sentences_path = pathlib.Path(params.target_sentences_path)
|
||||
self.with_includes = params.includes
|
||||
self.with_functions = params.functions
|
||||
self.log = logging.getLogger(__name__)
|
||||
|
||||
def generate_glsl_glyphs(self, glyphs: list[Glyph], sets: list[GlyphSet]) -> None:
|
||||
@@ -75,7 +76,15 @@ class Generator:
|
||||
sys.exit(1)
|
||||
|
||||
def generate_glsl_sentences(self, sentences: list[Sentence]) -> None:
|
||||
lines = [
|
||||
lines = []
|
||||
|
||||
if self.with_includes and self.with_functions:
|
||||
lines += [
|
||||
f"#include {self.target_path.name}",
|
||||
""
|
||||
]
|
||||
|
||||
lines += [
|
||||
GLSL_SENTENCES_PREFIX.format(self.target_name.upper()),
|
||||
"",
|
||||
*Sentence.export_glsl(self.target_name, sentences),
|
||||
|
||||
@@ -15,6 +15,7 @@ class Parameters:
|
||||
functions: bool = False
|
||||
source_sentences_path: str | None = None
|
||||
target_sentences_path: str | None = None
|
||||
includes: bool = False
|
||||
sentences_only: bool = False
|
||||
verbose: bool = False
|
||||
quiet: bool = False
|
||||
@@ -91,6 +92,12 @@ def parse_parameters(args: typing.Sequence[str]) -> Parameters:
|
||||
default=default_values.verbose,
|
||||
help="generate only sentences from names (does not read input image)",
|
||||
)
|
||||
parser.add_argument(
|
||||
"--includes",
|
||||
action=argparse.BooleanOptionalAction,
|
||||
default=default_values.verbose,
|
||||
help="use #include preprocessor in GLSL (forge)",
|
||||
)
|
||||
parser.add_argument(
|
||||
"-v",
|
||||
"--verbose",
|
||||
|
||||
Reference in New Issue
Block a user