Skip to content

Commit 2b33414

Browse files
feat: add resource creation helpers to starter ext (v2.1.0)
1 parent 39758ca commit 2b33414

19 files changed

Lines changed: 1521 additions & 944 deletions

docs/version.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -71,7 +71,7 @@ the API is complete. It just means we won't break what currently exists.
7171
* Rectangle Packing v1.1.0 (pl_rect_pack_ext.h)
7272
* Screen Log v2.2.0 (pl_screen_log_ext.h)
7373
* Shader v2.0.0 (pl_shader_ext.h)
74-
* Starter v2.0.0 (pl_starter_ext.h)
74+
* Starter v2.1.0 (pl_starter_ext.h)
7575
* Stats v1.1.0 (pl_stats_ext.h)
7676
* String Interning v2.0.0 (pl_string_intern_ext.h)
7777
* UI Tools v1.1.0 (pl_tools_ext.h)

examples/README.md

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -97,19 +97,28 @@ Demonstrates:
9797
### Example 2 - Graphics Extension 2 With API Registry (example_gfx_2.c)
9898
Demonstrates:
9999
* bind groups
100+
* vertex, index
101+
* samplers, textures, bind groups
102+
* shaders
103+
* indexed drawing
104+
* image extension
105+
106+
### Example 3 - Graphics Extension 2 With API Registry (example_gfx_3.c)
107+
Demonstrates:
108+
* bind groups
100109
* vertex, index, staging buffers
101110
* samplers, textures, bind groups
102111
* shaders
103112
* indexed drawing
104113
* image extension
105114

106-
### Example 3 - Graphics Extension 3 With API Registry (example_gfx_3.c)
115+
### Example 4 - Graphics Extension 3 With API Registry (example_gfx_4.c)
107116
Demonstrates:
108117
* starter extension
109118
* camera extension
110119
* drawing extension (2D & 3D)
111120

112-
### Example 4 - Graphics Extension 4 With API Registry (example_gfx_4.c)
121+
### Example 5 - Graphics Extension 4 With API Registry (example_gfx_5.c)
113122
Demonstrates:
114123
* starter extension
115124
* camera extension

examples/build_linux.sh

Lines changed: 72 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -96,6 +96,8 @@ else
9696
rm -f ../out/example_gfx_3_*.so
9797
rm -f ../out/example_gfx_4.so
9898
rm -f ../out/example_gfx_4_*.so
99+
rm -f ../out/example_gfx_5.so
100+
rm -f ../out/example_gfx_5_*.so
99101

100102

101103
fi
@@ -473,6 +475,40 @@ fi
473475
echo ${CYAN}Results: ${NC} ${PL_RESULT}
474476
echo ${CYAN}~~~~~~~~~~~~~~~~~~~~~~${NC}
475477

478+
#~~~~~~~~~~~~~~~~~~~~~~~~~~~~ example_gfx_5 | debug ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
479+
480+
PL_RESULT=${BOLD}${GREEN}Successful.${NC}
481+
PL_DEFINES="-D_USE_MATH_DEFINES -DPL_PROFILING_ON -DPL_ALLOW_HOT_RELOAD -DPL_ENABLE_VALIDATION_LAYERS -DPL_CONFIG_DEBUG "
482+
PL_INCLUDE_DIRECTORIES="-I../examples -I../internal/sandbox -I../src -I../shaders -I../libs -I../extensions -I../out -I../internal/demo -I../thirdparty/stb -I../thirdparty/imgui "
483+
PL_LINK_DIRECTORIES="-L../out -Wl,-rpath,../out -L/usr/lib/x86_64-linux-gnu -Wl,-rpath,/usr/lib/x86_64-linux-gnu "
484+
PL_COMPILER_FLAGS="-std=gnu11 -fPIC --debug -g "
485+
PL_LINKER_FLAGS="-ldl -lm "
486+
PL_STATIC_LINK_LIBRARIES=""
487+
PL_DYNAMIC_LINK_LIBRARIES="-lpl_unity_ext -lpl_platform_ext "
488+
PL_SOURCES="example_gfx_5.c "
489+
490+
# run compiler (and linker)
491+
echo
492+
echo ${YELLOW}Step: example_gfx_5${NC}
493+
echo ${YELLOW}~~~~~~~~~~~~~~~~~~~${NC}
494+
echo ${CYAN}Compiling and Linking...${NC}
495+
gcc -shared $PL_SOURCES $PL_INCLUDE_DIRECTORIES $PL_DEFINES $PL_COMPILER_FLAGS $PL_INCLUDE_DIRECTORIES $PL_LINK_DIRECTORIES $PL_STATIC_LINK_LIBRARIES $PL_DYNAMIC_LINK_LIBRARIES $PL_LINKER_FLAGS -o "./../out/libexample_gfx_5.so"
496+
497+
# check build status
498+
if [ $? -ne 0 ]
499+
then
500+
PL_RESULT=${BOLD}${RED}Failed.${NC}
501+
PL_BUILD_STATUS=1
502+
echo ${CYAN}Results: ${NC} ${PL_RESULT}
503+
echo ${CYAN}~~~~~~~~~~~~~~~~~~~~~~${NC}
504+
popd >/dev/null
505+
exit 1
506+
fi
507+
508+
# print results
509+
echo ${CYAN}Results: ${NC} ${PL_RESULT}
510+
echo ${CYAN}~~~~~~~~~~~~~~~~~~~~~~${NC}
511+
476512
# delete lock file(s)
477513
rm -f ../out/lock.tmp
478514

@@ -529,6 +565,8 @@ else
529565
rm -f ../out/example_gfx_3_*.so
530566
rm -f ../out/example_gfx_4.so
531567
rm -f ../out/example_gfx_4_*.so
568+
rm -f ../out/example_gfx_5.so
569+
rm -f ../out/example_gfx_5_*.so
532570

533571

534572
fi
@@ -906,6 +944,40 @@ fi
906944
echo ${CYAN}Results: ${NC} ${PL_RESULT}
907945
echo ${CYAN}~~~~~~~~~~~~~~~~~~~~~~${NC}
908946

947+
#~~~~~~~~~~~~~~~~~~~~~~~~~~~ example_gfx_5 | release ~~~~~~~~~~~~~~~~~~~~~~~~~~~~
948+
949+
PL_RESULT=${BOLD}${GREEN}Successful.${NC}
950+
PL_DEFINES="-D_USE_MATH_DEFINES -DPL_PROFILING_ON -DPL_ALLOW_HOT_RELOAD -DPL_ENABLE_VALIDATION_LAYERS -DPL_CONFIG_DEBUG "
951+
PL_INCLUDE_DIRECTORIES="-I../examples -I../internal/sandbox -I../src -I../shaders -I../libs -I../extensions -I../out -I../internal/demo -I../thirdparty/stb -I../thirdparty/imgui "
952+
PL_LINK_DIRECTORIES="-L../out -Wl,-rpath,../out -L/usr/lib/x86_64-linux-gnu -Wl,-rpath,/usr/lib/x86_64-linux-gnu "
953+
PL_COMPILER_FLAGS="-std=gnu11 -fPIC "
954+
PL_LINKER_FLAGS="-ldl -lm "
955+
PL_STATIC_LINK_LIBRARIES=""
956+
PL_DYNAMIC_LINK_LIBRARIES="-lpl_unity_ext -lpl_platform_ext "
957+
PL_SOURCES="example_gfx_5.c "
958+
959+
# run compiler (and linker)
960+
echo
961+
echo ${YELLOW}Step: example_gfx_5${NC}
962+
echo ${YELLOW}~~~~~~~~~~~~~~~~~~~${NC}
963+
echo ${CYAN}Compiling and Linking...${NC}
964+
gcc -shared $PL_SOURCES $PL_INCLUDE_DIRECTORIES $PL_DEFINES $PL_COMPILER_FLAGS $PL_INCLUDE_DIRECTORIES $PL_LINK_DIRECTORIES $PL_STATIC_LINK_LIBRARIES $PL_DYNAMIC_LINK_LIBRARIES $PL_LINKER_FLAGS -o "./../out/libexample_gfx_5.so"
965+
966+
# check build status
967+
if [ $? -ne 0 ]
968+
then
969+
PL_RESULT=${BOLD}${RED}Failed.${NC}
970+
PL_BUILD_STATUS=1
971+
echo ${CYAN}Results: ${NC} ${PL_RESULT}
972+
echo ${CYAN}~~~~~~~~~~~~~~~~~~~~~~${NC}
973+
popd >/dev/null
974+
exit 1
975+
fi
976+
977+
# print results
978+
echo ${CYAN}Results: ${NC} ${PL_RESULT}
979+
echo ${CYAN}~~~~~~~~~~~~~~~~~~~~~~${NC}
980+
909981
# delete lock file(s)
910982
rm -f ../out/lock.tmp
911983

examples/build_macos.sh

Lines changed: 88 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -100,6 +100,8 @@ else
100100
rm -f ../out/example_gfx_3_*.dylib
101101
rm -f ../out/example_gfx_4.dylib
102102
rm -f ../out/example_gfx_4_*.dylib
103+
rm -f ../out/example_gfx_5.dylib
104+
rm -f ../out/example_gfx_5_*.dylib
103105

104106
fi
105107
#~~~~~~~~~~~~~~~~~~~~~~~~~~~ example_basic_0 | debug ~~~~~~~~~~~~~~~~~~~~~~~~~~~~
@@ -564,6 +566,48 @@ fi
564566
echo ${CYAN}Results: ${NC} ${PL_RESULT}
565567
echo ${CYAN}~~~~~~~~~~~~~~~~~~~~~~${NC}
566568

569+
#~~~~~~~~~~~~~~~~~~~~~~~~~~~~ example_gfx_5 | debug ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
570+
571+
PL_RESULT=${BOLD}${GREEN}Successful.${NC}
572+
PL_DEFINES="-D_USE_MATH_DEFINES -DPL_PROFILING_ON -DPL_ALLOW_HOT_RELOAD -DPL_ENABLE_VALIDATION_LAYERS -DPL_CONFIG_DEBUG "
573+
PL_INCLUDE_DIRECTORIES="-I../examples -I../internal/sandbox -I../src -I../shaders -I../libs -I../extensions -I../out -I../internal/demo -I../thirdparty/stb -I../thirdparty/imgui "
574+
PL_LINK_DIRECTORIES="-L../out -Wl,-rpath,../out -L/usr/local/lib -Wl,-rpath,/usr/local/lib "
575+
PL_COMPILER_FLAGS="-std=c99 --debug -g -fmodules -ObjC -fPIC "
576+
PL_LINKER_FLAGS=""
577+
PL_STATIC_LINK_LIBRARIES=""
578+
PL_DYNAMIC_LINK_LIBRARIES="-lpl_unity_ext -lpl_platform_ext "
579+
PL_SOURCES="example_gfx_5.c "
580+
PL_LINK_FRAMEWORKS="-framework Metal -framework MetalKit -framework Cocoa -framework IOKit -framework CoreVideo -framework QuartzCore "
581+
582+
# add flags for specific hardware
583+
if [[ "$ARCH" == "arm64" ]]; then
584+
PL_COMPILER_FLAGS+="-arch arm64 "
585+
else
586+
PL_COMPILER_FLAGS+="-arch x86_64 "
587+
fi
588+
589+
# run compiler (and linker)
590+
echo
591+
echo ${YELLOW}Step: example_gfx_5${NC}
592+
echo ${YELLOW}~~~~~~~~~~~~~~~~~~~${NC}
593+
echo ${CYAN}Compiling and Linking...${NC}
594+
clang -shared $PL_SOURCES $PL_INCLUDE_DIRECTORIES $PL_DEFINES $PL_COMPILER_FLAGS $PL_INCLUDE_DIRECTORIES $PL_LINK_DIRECTORIES $PL_STATIC_LINK_LIBRARIES $PL_DYNAMIC_LINK_LIBRARIES $PL_LINK_FRAMEWORKS $PL_LINKER_FLAGS -o "./../out/libexample_gfx_5.dylib"
595+
596+
# check build status
597+
if [ $? -ne 0 ]
598+
then
599+
PL_RESULT=${BOLD}${RED}Failed.${NC}
600+
PL_BUILD_STATUS=1
601+
echo ${CYAN}Results: ${NC} ${PL_RESULT}
602+
echo ${CYAN}~~~~~~~~~~~~~~~~~~~~~~${NC}
603+
popd >/dev/null
604+
exit 1
605+
fi
606+
607+
# print results
608+
echo ${CYAN}Results: ${NC} ${PL_RESULT}
609+
echo ${CYAN}~~~~~~~~~~~~~~~~~~~~~~${NC}
610+
567611
# delete lock file(s)
568612
rm -f ../out/lock.tmp
569613

@@ -622,6 +666,8 @@ else
622666
rm -f ../out/example_gfx_3_*.dylib
623667
rm -f ../out/example_gfx_4.dylib
624668
rm -f ../out/example_gfx_4_*.dylib
669+
rm -f ../out/example_gfx_5.dylib
670+
rm -f ../out/example_gfx_5_*.dylib
625671

626672
fi
627673
#~~~~~~~~~~~~~~~~~~~~~~~~~~ example_basic_0 | release ~~~~~~~~~~~~~~~~~~~~~~~~~~~
@@ -1086,6 +1132,48 @@ fi
10861132
echo ${CYAN}Results: ${NC} ${PL_RESULT}
10871133
echo ${CYAN}~~~~~~~~~~~~~~~~~~~~~~${NC}
10881134

1135+
#~~~~~~~~~~~~~~~~~~~~~~~~~~~ example_gfx_5 | release ~~~~~~~~~~~~~~~~~~~~~~~~~~~~
1136+
1137+
PL_RESULT=${BOLD}${GREEN}Successful.${NC}
1138+
PL_DEFINES="-D_USE_MATH_DEFINES -DPL_PROFILING_ON -DPL_ALLOW_HOT_RELOAD -DPL_ENABLE_VALIDATION_LAYERS -DPL_CONFIG_DEBUG "
1139+
PL_INCLUDE_DIRECTORIES="-I../examples -I../internal/sandbox -I../src -I../shaders -I../libs -I../extensions -I../out -I../internal/demo -I../thirdparty/stb -I../thirdparty/imgui "
1140+
PL_LINK_DIRECTORIES="-L../out -Wl,-rpath,../out -L/usr/local/lib -Wl,-rpath,/usr/local/lib "
1141+
PL_COMPILER_FLAGS="-std=c99 -fmodules -ObjC -fPIC "
1142+
PL_LINKER_FLAGS=""
1143+
PL_STATIC_LINK_LIBRARIES=""
1144+
PL_DYNAMIC_LINK_LIBRARIES="-lpl_unity_ext -lpl_platform_ext "
1145+
PL_SOURCES="example_gfx_5.c "
1146+
PL_LINK_FRAMEWORKS="-framework Metal -framework MetalKit -framework Cocoa -framework IOKit -framework CoreVideo -framework QuartzCore "
1147+
1148+
# add flags for specific hardware
1149+
if [[ "$ARCH" == "arm64" ]]; then
1150+
PL_COMPILER_FLAGS+="-arch arm64 "
1151+
else
1152+
PL_COMPILER_FLAGS+="-arch x86_64 "
1153+
fi
1154+
1155+
# run compiler (and linker)
1156+
echo
1157+
echo ${YELLOW}Step: example_gfx_5${NC}
1158+
echo ${YELLOW}~~~~~~~~~~~~~~~~~~~${NC}
1159+
echo ${CYAN}Compiling and Linking...${NC}
1160+
clang -shared $PL_SOURCES $PL_INCLUDE_DIRECTORIES $PL_DEFINES $PL_COMPILER_FLAGS $PL_INCLUDE_DIRECTORIES $PL_LINK_DIRECTORIES $PL_STATIC_LINK_LIBRARIES $PL_DYNAMIC_LINK_LIBRARIES $PL_LINK_FRAMEWORKS $PL_LINKER_FLAGS -o "./../out/libexample_gfx_5.dylib"
1161+
1162+
# check build status
1163+
if [ $? -ne 0 ]
1164+
then
1165+
PL_RESULT=${BOLD}${RED}Failed.${NC}
1166+
PL_BUILD_STATUS=1
1167+
echo ${CYAN}Results: ${NC} ${PL_RESULT}
1168+
echo ${CYAN}~~~~~~~~~~~~~~~~~~~~~~${NC}
1169+
popd >/dev/null
1170+
exit 1
1171+
fi
1172+
1173+
# print results
1174+
echo ${CYAN}Results: ${NC} ${PL_RESULT}
1175+
echo ${CYAN}~~~~~~~~~~~~~~~~~~~~~~${NC}
1176+
10891177
# delete lock file(s)
10901178
rm -f ../out/lock.tmp
10911179

examples/build_win32.bat

Lines changed: 70 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -97,6 +97,8 @@
9797
@if exist "../out/example_gfx_3_*.pdb" del "..\out\example_gfx_3_*.pdb"
9898
@if exist "../out/example_gfx_4.dll" del "..\out\example_gfx_4.dll"
9999
@if exist "../out/example_gfx_4_*.pdb" del "..\out\example_gfx_4_*.pdb"
100+
@if exist "../out/example_gfx_5.dll" del "..\out\example_gfx_5.dll"
101+
@if exist "../out/example_gfx_5_*.pdb" del "..\out\example_gfx_5_*.pdb"
100102

101103
)
102104

@@ -463,6 +465,39 @@ cl %PL_INCLUDE_DIRECTORIES% %PL_DEFINES% %PL_COMPILER_FLAGS% %PL_SOURCES% -Fe"..
463465

464466
@del "..\out\*.obj" > nul 2> nul
465467

468+
::~~~~~~~~~~~~~~~~~~~~~~~~~~~~ example_gfx_5 | debug ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
469+
470+
@set PL_DEFINES=-D_USE_MATH_DEFINES -DPL_PROFILING_ON -DPL_ALLOW_HOT_RELOAD -DPL_ENABLE_VALIDATION_LAYERS -DPL_CONFIG_DEBUG
471+
@set PL_INCLUDE_DIRECTORIES=-I"../examples" -I"../internal/sandbox" -I"../src" -I"../shaders" -I"../libs" -I"../extensions" -I"../out" -I"../internal/demo" -I"../thirdparty/stb" -I"../thirdparty/imgui"
472+
@set PL_LINK_DIRECTORIES=-LIBPATH:"../out"
473+
@set PL_COMPILER_FLAGS=-Zc:preprocessor -nologo -std:c11 -W4 -WX -wd4201 -wd4100 -wd4996 -wd4505 -wd4189 -wd5105 -wd4115 -permissive- -Od -MDd -Zi
474+
@set PL_LINKER_FLAGS=-noimplib -noexp -incremental:no
475+
@set PL_DYNAMIC_LINK_LIBRARIES=pl_unity_ext.lib pl_platform_ext.lib
476+
@set PL_SOURCES="example_gfx_5.c"
477+
478+
:: run compiler (and linker)
479+
@echo.
480+
@echo Step: example_gfx_5
481+
@echo ~~~~~~~~~~~~~~~~~~~~~~
482+
@echo Compiling and Linking...
483+
cl %PL_INCLUDE_DIRECTORIES% %PL_DEFINES% %PL_COMPILER_FLAGS% %PL_SOURCES% -Fe"../out/example_gfx_5.dll" -Fo"../out/" -LD -link %PL_LINKER_FLAGS% -PDB:"../out/example_gfx_5_%random%.pdb" %PL_LINK_DIRECTORIES% %PL_DYNAMIC_LINK_LIBRARIES%
484+
485+
:: check build status
486+
@set PL_BUILD_STATUS=%ERRORLEVEL%
487+
488+
:: failed
489+
@if %PL_BUILD_STATUS% NEQ 0 (
490+
@echo Compilation Failed with error code: %PL_BUILD_STATUS%
491+
@set PL_RESULT=Failed.
492+
goto Cleanupdebug
493+
)
494+
495+
:: print results
496+
@echo Result:  %PL_RESULT%
497+
@echo ~~~~~~~~~~~~~~~~~~~~~~
498+
499+
@del "..\out\*.obj" > nul 2> nul
500+
466501
:Cleanupdebug
467502

468503
@echo Cleaning...
@@ -527,6 +562,8 @@ goto ExitLabel
527562
@if exist "../out/example_gfx_3_*.pdb" del "..\out\example_gfx_3_*.pdb"
528563
@if exist "../out/example_gfx_4.dll" del "..\out\example_gfx_4.dll"
529564
@if exist "../out/example_gfx_4_*.pdb" del "..\out\example_gfx_4_*.pdb"
565+
@if exist "../out/example_gfx_5.dll" del "..\out\example_gfx_5.dll"
566+
@if exist "../out/example_gfx_5_*.pdb" del "..\out\example_gfx_5_*.pdb"
530567

531568
)
532569

@@ -893,6 +930,39 @@ cl %PL_INCLUDE_DIRECTORIES% %PL_DEFINES% %PL_COMPILER_FLAGS% %PL_SOURCES% -Fe"..
893930

894931
@del "..\out\*.obj" > nul 2> nul
895932

933+
::~~~~~~~~~~~~~~~~~~~~~~~~~~~ example_gfx_5 | release ~~~~~~~~~~~~~~~~~~~~~~~~~~~~
934+
935+
@set PL_DEFINES=-D_USE_MATH_DEFINES -DPL_PROFILING_ON -DPL_ALLOW_HOT_RELOAD -DPL_ENABLE_VALIDATION_LAYERS -DPL_CONFIG_DEBUG
936+
@set PL_INCLUDE_DIRECTORIES=-I"../examples" -I"../internal/sandbox" -I"../src" -I"../shaders" -I"../libs" -I"../extensions" -I"../out" -I"../internal/demo" -I"../thirdparty/stb" -I"../thirdparty/imgui"
937+
@set PL_LINK_DIRECTORIES=-LIBPATH:"../out"
938+
@set PL_COMPILER_FLAGS=-Zc:preprocessor -nologo -std:c11 -W4 -WX -wd4201 -wd4100 -wd4996 -wd4505 -wd4189 -wd5105 -wd4115 -permissive- -O2 -MD
939+
@set PL_LINKER_FLAGS=-noimplib -noexp -incremental:no
940+
@set PL_DYNAMIC_LINK_LIBRARIES=pl_unity_ext.lib pl_platform_ext.lib
941+
@set PL_SOURCES="example_gfx_5.c"
942+
943+
:: run compiler (and linker)
944+
@echo.
945+
@echo Step: example_gfx_5
946+
@echo ~~~~~~~~~~~~~~~~~~~~~~
947+
@echo Compiling and Linking...
948+
cl %PL_INCLUDE_DIRECTORIES% %PL_DEFINES% %PL_COMPILER_FLAGS% %PL_SOURCES% -Fe"../out/example_gfx_5.dll" -Fo"../out/" -LD -link %PL_LINKER_FLAGS% -PDB:"../out/example_gfx_5_%random%.pdb" %PL_LINK_DIRECTORIES% %PL_DYNAMIC_LINK_LIBRARIES%
949+
950+
:: check build status
951+
@set PL_BUILD_STATUS=%ERRORLEVEL%
952+
953+
:: failed
954+
@if %PL_BUILD_STATUS% NEQ 0 (
955+
@echo Compilation Failed with error code: %PL_BUILD_STATUS%
956+
@set PL_RESULT=Failed.
957+
goto Cleanuprelease
958+
)
959+
960+
:: print results
961+
@echo Result:  %PL_RESULT%
962+
@echo ~~~~~~~~~~~~~~~~~~~~~~
963+
964+
@del "..\out\*.obj" > nul 2> nul
965+
896966
:Cleanuprelease
897967

898968
@echo Cleaning...

0 commit comments

Comments
 (0)