From 50aae8763fbb64aeae0bb6f8499dc710508abb49 Mon Sep 17 00:00:00 2001 From: Ralph Sennhauser Date: Mon, 4 Nov 2024 18:36:28 +0100 Subject: [PATCH] Improve script generating glad headers The script assumes glad got cloned into glad subdirectory. This is the case if you follow the procedure outlined in the README, however if you are using system glad or or glad installed via pip this assumption doesn't hold. Therefore relax the requirement on where to get glad from. While at it add shell option errexit and make the script callable from repository root. Signed-off-by: Ralph Sennhauser --- source/third_party/glad/README.md | 4 ++++ source/third_party/glad/update-headers.sh | 25 +++++++++++++++-------- 2 files changed, 20 insertions(+), 9 deletions(-) diff --git a/source/third_party/glad/README.md b/source/third_party/glad/README.md index 60688fd604..db871358d0 100644 --- a/source/third_party/glad/README.md +++ b/source/third_party/glad/README.md @@ -4,6 +4,10 @@ This folder contains the files generated by the glad GL loader for the game. ## Instructions +Install glad via package manager or pip, for the latter create a venv if +necessary. Alternatively fetch the glad git repo as outlined below. On +Windows fetching the git repo is assumed. + Download glad v2: ```sh git clone https://github.com/Dav1dde/glad.git -b glad2 diff --git a/source/third_party/glad/update-headers.sh b/source/third_party/glad/update-headers.sh index e06c9d7d82..26e5ed96a6 100755 --- a/source/third_party/glad/update-headers.sh +++ b/source/third_party/glad/update-headers.sh @@ -1,14 +1,21 @@ #!/bin/sh -( - cd glad || exit - python -m glad --api="gl:core=2.1" --extensions="../extensions/gl.txt" --out-path="../" c - python -m glad --api="gles2=2.0" --extensions="../extensions/gles2.txt" --out-path="../" c - python -m glad --api="glx=1.4" --extensions="../extensions/glx.txt" --out-path="../" c - python -m glad --api="wgl=1.0" --extensions="../extensions/wgl.txt" --out-path="../" c - python -m glad --api="egl=1.5" --extensions="../extensions/egl.txt" --out-path="../" c - python -m glad --api="vulkan=1.1" --extensions="../extensions/vulkan.txt" --out-path="../" c -) +set -e + +cd "$(dirname "$0")" + +# In case glad is not installed system wide or not installed via pip assume glad +# repository was fetched into glad subdirectory. +export PYTHONPATH="glad" + +python -m glad --api="gl:core=2.1" --extensions="extensions/gl.txt" --out-path="." c +python -m glad --api="gles2=2.0" --extensions="extensions/gles2.txt" --out-path="." c +python -m glad --api="glx=1.4" --extensions="extensions/glx.txt" --out-path="." c +python -m glad --api="wgl=1.0" --extensions="extensions/wgl.txt" --out-path="." c +python -m glad --api="egl=1.5" --extensions="extensions/egl.txt" --out-path="." c +python -m glad --api="vulkan=1.1" --extensions="extensions/vulkan.txt" --out-path="." c + patch -p1 --ignore-whitespace --fuzz 1