forked from codam-coding-college/MLX42
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathcompile_shader.bat
executable file
·47 lines (38 loc) · 1.5 KB
/
compile_shader.bat
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
:: -----------------------------------------------------------------------------
:: Codam Coding College, Amsterdam @ 2022-2023 by W2Wizard.
:: See README in the root project for more information.
:: -----------------------------------------------------------------------------
@echo off
SETLOCAL DisableDelayedExpansion
:: go to usage function if no arguments have been given to the script
IF [%1]==[] GOTO usage
:: check if input file exists before continuing
IF NOT EXIST %1 GOTO fnotfound
SET SHADERTYPE=%~x1
SET SHADERTYPE=%SHADERTYPE:~1%
echo // -----------------------------------------------------------------------------
echo // Codam Coding College, Amsterdam @ <2022-2023> by W2Wizard.
echo // See README in the root project for more information.
echo // -----------------------------------------------------------------------------
echo.
echo // If you wish to modify this file edit the .vert or .frag file!
echo.
echo #include "MLX42/MLX42_Int.h"
echo.
FOR /F "delims=" %%A IN (%1) DO IF NOT DEFINED VERSIONLINE set "VERSIONLINE=%%A"
echo const char* %SHADERTYPE%_shader = "%VERSIONLINE%\n"
FOR /F "skip=1 delims=" %%A IN (%1) DO (
IF "%%A" == "}" (echo "%%A";) ELSE (echo "%%A")
)
ENDLOCAL
EXIT /B 0
:: usage function exits the script with exit code 3 (path not found)
:usage
echo ERROR: missing arguments, use as follows: %0 ^<ShaderFile^> 1>&2
ENDLOCAL
EXIT /B 3
:: fnotfound function exits the script with exit code 2 (file not found)
:fnotfound
echo ERROR: shader file not found: %1 1>&2
ENDLOCAL
EXIT /B 2