aboutsummaryrefslogtreecommitdiffstats
path: root/examples
diff options
context:
space:
mode:
Diffstat (limited to 'examples')
-rw-r--r--examples/meson.build131
-rw-r--r--examples/pugl_cairo_demo.app/MacOS/meson.build7
-rw-r--r--examples/pugl_cairo_demo.app/meson.build8
-rw-r--r--examples/pugl_cpp_demo.app/MacOS/meson.build7
-rw-r--r--examples/pugl_cpp_demo.app/meson.build8
-rw-r--r--examples/pugl_cursor_demo.app/MacOS/meson.build7
-rw-r--r--examples/pugl_cursor_demo.app/meson.build8
-rw-r--r--examples/pugl_embed_demo.app/MacOS/meson.build7
-rw-r--r--examples/pugl_embed_demo.app/meson.build8
-rw-r--r--examples/pugl_shader_demo.app/MacOS/meson.build11
-rw-r--r--examples/pugl_shader_demo.app/Resources/meson.build12
-rw-r--r--examples/pugl_shader_demo.app/meson.build21
-rw-r--r--examples/pugl_shader_demo.c15
-rw-r--r--examples/pugl_vulkan_cpp_demo.app/MacOS/meson.build10
-rw-r--r--examples/pugl_vulkan_cpp_demo.app/meson.build27
-rw-r--r--examples/pugl_vulkan_cpp_demo.cpp12
-rw-r--r--examples/pugl_vulkan_demo.app/MacOS/meson.build9
-rw-r--r--examples/pugl_vulkan_demo.app/meson.build8
-rw-r--r--examples/pugl_window_demo.app/MacOS/meson.build7
-rw-r--r--examples/pugl_window_demo.app/meson.build8
-rw-r--r--examples/shaders/meson.build42
21 files changed, 299 insertions, 74 deletions
diff --git a/examples/meson.build b/examples/meson.build
index d57fea4..a4bf84c 100644
--- a/examples/meson.build
+++ b/examples/meson.build
@@ -74,58 +74,85 @@ endif
subdir('shaders')
-# Build GL examples
-if opengl_dep.found()
- foreach example : gl_examples
- source = [example]
- target = example.split('.')[0]
- dependencies = [gl_backend_dep]
- defines = []
-
- if target == 'pugl_shader_demo'
- source += ['file_utils.c', 'glad/glad.c']
- dependencies += [dl_dep]
- defines += ['-D_POSIX_C_SOURCE=200809L']
- elif target == 'pugl_print_events'
- dependencies += [stub_backend_dep]
- endif
-
- executable(target, source,
- include_directories: includes,
- c_args: example_defines + example_c_args + defines,
- cpp_args: example_defines + example_cpp_args + defines,
- dependencies: dependencies)
- endforeach
-endif
+if host_machine.system() == 'darwin'
+ # On Darwin, build examples as application bundles (required to work properly)
-# Build Cairo examples
-if cairo_dep.found()
- foreach example : cairo_examples
- target = example.split('.')[0]
- executable(target, example,
- include_directories: includes,
- c_args: example_defines + example_c_args,
- dependencies: [pugl_dep, cairo_backend_dep])
- endforeach
-endif
+ subdir('pugl_cursor_demo.app')
+
+ if cairo_dep.found()
+ subdir('pugl_cairo_demo.app')
+ endif
-# Build Vulkan examples
-if vulkan_dep.found()
- foreach example : vulkan_examples
- source = [example]
- target = example.split('.')[0]
- dependencies = [dl_dep, vulkan_backend_dep]
- defines = []
-
- if target == 'pugl_vulkan_cpp_demo'
- source += ['file_utils.c']
- defines += ['-D_POSIX_C_SOURCE=200809L']
- endif
-
- executable(target, source,
- include_directories: includes,
- c_args: example_defines + example_c_args + defines,
- cpp_args: example_defines + example_cpp_args + defines,
- dependencies: dependencies)
- endforeach
+ if opengl_dep.found()
+ subdir('pugl_cpp_demo.app')
+ subdir('pugl_embed_demo.app')
+ subdir('pugl_shader_demo.app')
+ subdir('pugl_window_demo.app')
+ endif
+
+ if vulkan_dep.found()
+ subdir('pugl_vulkan_cpp_demo.app')
+ subdir('pugl_vulkan_demo.app')
+ endif
+
+else
+ # On all other platforms, build examples as simple programs
+
+ # Build GL examples
+ if opengl_dep.found()
+ foreach example : gl_examples
+ source = [example]
+ target = example.split('.')[0]
+ dependencies = [gl_backend_dep]
+ defines = []
+
+ if target == 'pugl_shader_demo'
+ source += ['file_utils.c', 'glad/glad.c']
+ dependencies += [dl_dep]
+ defines += ['-D_POSIX_C_SOURCE=200809L']
+ elif target == 'pugl_print_events'
+ dependencies += [stub_backend_dep]
+ elif target == 'pugl_cpp_demo'
+ dependencies += [puglpp_dep]
+ endif
+
+ executable(target, source,
+ include_directories: includes,
+ c_args: example_defines + example_c_args + defines,
+ cpp_args: example_defines + example_cpp_args + defines,
+ dependencies: dependencies)
+ endforeach
+ endif
+
+ # Build Cairo examples
+ if cairo_dep.found()
+ foreach example : cairo_examples
+ target = example.split('.')[0]
+ executable(target, example,
+ include_directories: includes,
+ c_args: example_defines + example_c_args,
+ dependencies: [pugl_dep, cairo_backend_dep])
+ endforeach
+ endif
+
+ # Build Vulkan examples
+ if vulkan_dep.found()
+ foreach example : vulkan_examples
+ source = [example]
+ target = example.split('.')[0]
+ dependencies = [dl_dep, vulkan_backend_dep]
+ defines = []
+
+ if target == 'pugl_vulkan_cpp_demo'
+ source += ['file_utils.c']
+ defines += ['-D_POSIX_C_SOURCE=200809L']
+ endif
+
+ executable(target, source,
+ include_directories: includes,
+ c_args: example_defines + example_c_args + defines,
+ cpp_args: example_defines + example_cpp_args + defines,
+ dependencies: dependencies)
+ endforeach
+ endif
endif
diff --git a/examples/pugl_cairo_demo.app/MacOS/meson.build b/examples/pugl_cairo_demo.app/MacOS/meson.build
new file mode 100644
index 0000000..d50da8a
--- /dev/null
+++ b/examples/pugl_cairo_demo.app/MacOS/meson.build
@@ -0,0 +1,7 @@
+executable(
+ 'pugl_cairo_demo',
+ ['../../pugl_cairo_demo.c'],
+ include_directories: include_directories('../../../../include', '../../..'),
+ c_args: example_defines + example_c_args,
+ cpp_args: example_defines + example_cpp_args,
+ dependencies: [pugl_dep, cairo_backend_dep])
diff --git a/examples/pugl_cairo_demo.app/meson.build b/examples/pugl_cairo_demo.app/meson.build
new file mode 100644
index 0000000..59793e1
--- /dev/null
+++ b/examples/pugl_cairo_demo.app/meson.build
@@ -0,0 +1,8 @@
+config = configuration_data()
+config.set('NAME', 'pugl_cairo_demo')
+
+info_plist = configure_file(configuration: config,
+ input: files('../../resources/Info.plist.in'),
+ output: 'Info.plist')
+
+subdir('MacOS')
diff --git a/examples/pugl_cpp_demo.app/MacOS/meson.build b/examples/pugl_cpp_demo.app/MacOS/meson.build
new file mode 100644
index 0000000..5317789
--- /dev/null
+++ b/examples/pugl_cpp_demo.app/MacOS/meson.build
@@ -0,0 +1,7 @@
+executable(
+ 'pugl_cpp_demo',
+ '../../pugl_cpp_demo.cpp',
+ include_directories: include_directories('../../../../include', '../../..'),
+ c_args: example_defines + example_c_args,
+ cpp_args: example_defines + example_cpp_args,
+ dependencies: [puglpp_dep, gl_backend_dep])
diff --git a/examples/pugl_cpp_demo.app/meson.build b/examples/pugl_cpp_demo.app/meson.build
new file mode 100644
index 0000000..d9d47ba
--- /dev/null
+++ b/examples/pugl_cpp_demo.app/meson.build
@@ -0,0 +1,8 @@
+config = configuration_data()
+config.set('NAME', 'pugl_cpp_demo')
+
+info_plist = configure_file(configuration: config,
+ input: files('../../resources/Info.plist.in'),
+ output: 'Info.plist')
+
+subdir('MacOS')
diff --git a/examples/pugl_cursor_demo.app/MacOS/meson.build b/examples/pugl_cursor_demo.app/MacOS/meson.build
new file mode 100644
index 0000000..d702c49
--- /dev/null
+++ b/examples/pugl_cursor_demo.app/MacOS/meson.build
@@ -0,0 +1,7 @@
+executable(
+ 'pugl_cursor_demo',
+ '../../pugl_cursor_demo.c',
+ include_directories: include_directories('../../../../include', '../../..'),
+ c_args: example_defines + example_c_args,
+ cpp_args: example_defines + example_cpp_args,
+ dependencies: [pugl_dep, gl_backend_dep])
diff --git a/examples/pugl_cursor_demo.app/meson.build b/examples/pugl_cursor_demo.app/meson.build
new file mode 100644
index 0000000..dfbb30c
--- /dev/null
+++ b/examples/pugl_cursor_demo.app/meson.build
@@ -0,0 +1,8 @@
+config = configuration_data()
+config.set('NAME', 'pugl_cursor_demo')
+
+info_plist = configure_file(configuration: config,
+ input: files('../../resources/Info.plist.in'),
+ output: 'Info.plist')
+
+subdir('MacOS')
diff --git a/examples/pugl_embed_demo.app/MacOS/meson.build b/examples/pugl_embed_demo.app/MacOS/meson.build
new file mode 100644
index 0000000..4ad3781
--- /dev/null
+++ b/examples/pugl_embed_demo.app/MacOS/meson.build
@@ -0,0 +1,7 @@
+executable(
+ 'pugl_embed_demo',
+ '../../pugl_embed_demo.c',
+ include_directories: include_directories('../../../../include', '../../..'),
+ c_args: example_defines + example_c_args,
+ cpp_args: example_defines + example_cpp_args,
+ dependencies: [pugl_dep, gl_backend_dep])
diff --git a/examples/pugl_embed_demo.app/meson.build b/examples/pugl_embed_demo.app/meson.build
new file mode 100644
index 0000000..3913bad
--- /dev/null
+++ b/examples/pugl_embed_demo.app/meson.build
@@ -0,0 +1,8 @@
+config = configuration_data()
+config.set('NAME', 'pugl_embed_demo')
+
+info_plist = configure_file(configuration: config,
+ input: files('../../resources/Info.plist.in'),
+ output: 'Info.plist')
+
+subdir('MacOS')
diff --git a/examples/pugl_shader_demo.app/MacOS/meson.build b/examples/pugl_shader_demo.app/MacOS/meson.build
new file mode 100644
index 0000000..3eb9ae1
--- /dev/null
+++ b/examples/pugl_shader_demo.app/MacOS/meson.build
@@ -0,0 +1,11 @@
+executable(
+ 'pugl_shader_demo',
+ [
+ '../../file_utils.c',
+ '../../glad/glad.c',
+ '../../pugl_shader_demo.c',
+ ],
+ include_directories: include_directories('../../../../include', '../../..'),
+ c_args: example_defines + example_c_args,
+ cpp_args: example_defines + example_cpp_args,
+ dependencies: [pugl_dep, gl_backend_dep, dl_dep])
diff --git a/examples/pugl_shader_demo.app/Resources/meson.build b/examples/pugl_shader_demo.app/Resources/meson.build
new file mode 100644
index 0000000..87e3a71
--- /dev/null
+++ b/examples/pugl_shader_demo.app/Resources/meson.build
@@ -0,0 +1,12 @@
+shaders = [
+ 'header_330.glsl',
+ 'header_420.glsl',
+ 'rect.vert',
+ 'rect.frag',
+]
+
+foreach shader : shaders
+ configure_file(input: files('..' / '..' / 'shaders' / shader),
+ output: shader,
+ copy: true)
+endforeach
diff --git a/examples/pugl_shader_demo.app/meson.build b/examples/pugl_shader_demo.app/meson.build
new file mode 100644
index 0000000..82b4a34
--- /dev/null
+++ b/examples/pugl_shader_demo.app/meson.build
@@ -0,0 +1,21 @@
+config = configuration_data()
+config.set('NAME', 'pugl_shader_demo')
+
+info_plist = configure_file(configuration: config,
+ input: files('../../resources/Info.plist.in'),
+ output: 'Info.plist')
+
+shaders = [
+ 'header_330.glsl',
+ 'header_420.glsl',
+ 'rect.vert',
+ 'rect.frag',
+]
+
+foreach shader : shaders
+ configure_file(input: files('..' / 'shaders' / shader),
+ output: shader,
+ copy: true)
+endforeach
+
+subdir('MacOS')
diff --git a/examples/pugl_shader_demo.c b/examples/pugl_shader_demo.c
index f4679e2..a2f3589 100644
--- a/examples/pugl_shader_demo.c
+++ b/examples/pugl_shader_demo.c
@@ -39,6 +39,12 @@
#include <stdlib.h>
#include <string.h>
+#ifdef __APPLE__
+# define SHADER_DIR "../"
+#else
+# define SHADER_DIR "shaders/"
+#endif
+
static const int defaultWidth = 512;
static const int defaultHeight = 512;
static const uintptr_t resizeTimerId = 1u;
@@ -284,16 +290,17 @@ setupGl(PuglTestApp* app)
}
const char* const headerFile =
- (app->glMajorVersion == 3 ? "shaders/header_330.glsl"
- : "shaders/header_420.glsl");
+ (app->glMajorVersion == 3 ? SHADER_DIR "header_330.glsl"
+ : SHADER_DIR "header_420.glsl");
// Load shader sources
char* const headerSource = loadShader(app->programPath, headerFile);
- char* const vertexSource = loadShader(app->programPath, "shaders/rect.vert");
+ char* const vertexSource =
+ loadShader(app->programPath, SHADER_DIR "rect.vert");
char* const fragmentSource =
- loadShader(app->programPath, "shaders/rect.frag");
+ loadShader(app->programPath, SHADER_DIR "rect.frag");
if (!vertexSource || !fragmentSource) {
logError("Failed to load shader sources\n");
diff --git a/examples/pugl_vulkan_cpp_demo.app/MacOS/meson.build b/examples/pugl_vulkan_cpp_demo.app/MacOS/meson.build
new file mode 100644
index 0000000..2ff4e87
--- /dev/null
+++ b/examples/pugl_vulkan_cpp_demo.app/MacOS/meson.build
@@ -0,0 +1,10 @@
+executable(
+ 'pugl_vulkan_cpp_demo',
+ [
+ '../../pugl_vulkan_cpp_demo.cpp',
+ '../../file_utils.c',
+ ],
+ include_directories: include_directories('../../../../include', '../../..'),
+ c_args: example_defines + example_c_args,
+ cpp_args: example_defines + example_cpp_args,
+ dependencies: [puglpp_dep, vulkan_backend_dep])
diff --git a/examples/pugl_vulkan_cpp_demo.app/meson.build b/examples/pugl_vulkan_cpp_demo.app/meson.build
new file mode 100644
index 0000000..90b2329
--- /dev/null
+++ b/examples/pugl_vulkan_cpp_demo.app/meson.build
@@ -0,0 +1,27 @@
+config = configuration_data()
+config.set('NAME', 'pugl_vulkan_cpp_demo')
+
+info_plist = configure_file(configuration: config,
+ input: files('../../resources/Info.plist.in'),
+ output: 'Info.plist')
+
+shaders = [
+ 'rect.frag.spv',
+ 'rect.vert.spv',
+]
+
+cp = find_program('../../scripts/cp.py')
+
+custom_target('rect.vert.spv',
+ input: rect_vert_spv,
+ output: 'rect.vert.spv',
+ command: [cp, '@INPUT@', '@OUTPUT@'],
+ build_by_default: true)
+
+custom_target('rect.frag.spv',
+ input: rect_frag_spv,
+ output: 'rect.frag.spv',
+ command: [cp, '@INPUT@', '@OUTPUT@'],
+ build_by_default: true)
+
+subdir('MacOS')
diff --git a/examples/pugl_vulkan_cpp_demo.cpp b/examples/pugl_vulkan_cpp_demo.cpp
index 0b34c81..6ed3885 100644
--- a/examples/pugl_vulkan_cpp_demo.cpp
+++ b/examples/pugl_vulkan_cpp_demo.cpp
@@ -42,6 +42,12 @@
#include <string>
#include <vector>
+#ifdef __APPLE__
+# define SHADER_DIR "../"
+#else
+# define SHADER_DIR "shaders/"
+#endif
+
namespace {
constexpr uintptr_t resizeTimerId = 1u;
@@ -712,9 +718,11 @@ RectShaders::init(const sk::VulkanApi& vk,
const GraphicsDevice& gpu,
const std::string& programPath)
{
- auto vertShaderCode = readFile(programPath.c_str(), "shaders/rect.vert.spv");
+ auto vertShaderCode =
+ readFile(programPath.c_str(), SHADER_DIR "rect.vert.spv");
- auto fragShaderCode = readFile(programPath.c_str(), "shaders/rect.frag.spv");
+ auto fragShaderCode =
+ readFile(programPath.c_str(), SHADER_DIR "rect.frag.spv");
if (vertShaderCode.empty() || fragShaderCode.empty()) {
return VK_ERROR_INITIALIZATION_FAILED;
diff --git a/examples/pugl_vulkan_demo.app/MacOS/meson.build b/examples/pugl_vulkan_demo.app/MacOS/meson.build
new file mode 100644
index 0000000..d2863b3
--- /dev/null
+++ b/examples/pugl_vulkan_demo.app/MacOS/meson.build
@@ -0,0 +1,9 @@
+executable(
+ 'pugl_vulkan_demo',
+ [
+ '../../pugl_vulkan_demo.c',
+ '../../file_utils.c',
+ ],
+ include_directories: include_directories('../../../../include', '../../..'),
+ c_args: example_defines + example_c_args,
+ dependencies: [pugl_dep, vulkan_backend_dep])
diff --git a/examples/pugl_vulkan_demo.app/meson.build b/examples/pugl_vulkan_demo.app/meson.build
new file mode 100644
index 0000000..240c129
--- /dev/null
+++ b/examples/pugl_vulkan_demo.app/meson.build
@@ -0,0 +1,8 @@
+config = configuration_data()
+config.set('NAME', 'pugl_vulkan_demo')
+
+info_plist = configure_file(configuration: config,
+ input: files('../../resources/Info.plist.in'),
+ output: 'Info.plist')
+
+subdir('MacOS')
diff --git a/examples/pugl_window_demo.app/MacOS/meson.build b/examples/pugl_window_demo.app/MacOS/meson.build
new file mode 100644
index 0000000..84b4c59
--- /dev/null
+++ b/examples/pugl_window_demo.app/MacOS/meson.build
@@ -0,0 +1,7 @@
+executable(
+ 'pugl_window_demo',
+ '../../pugl_window_demo.c',
+ include_directories: include_directories('../../../../include', '../../..'),
+ c_args: example_defines + example_c_args,
+ cpp_args: example_defines + example_cpp_args,
+ dependencies: [pugl_dep, gl_backend_dep])
diff --git a/examples/pugl_window_demo.app/meson.build b/examples/pugl_window_demo.app/meson.build
new file mode 100644
index 0000000..2d1cd9a
--- /dev/null
+++ b/examples/pugl_window_demo.app/meson.build
@@ -0,0 +1,8 @@
+config = configuration_data()
+config.set('NAME', 'pugl_window_demo')
+
+info_plist = configure_file(configuration: config,
+ input: files('../../resources/Info.plist.in'),
+ output: 'Info.plist')
+
+subdir('MacOS')
diff --git a/examples/shaders/meson.build b/examples/shaders/meson.build
index 83859b3..2fdd946 100644
--- a/examples/shaders/meson.build
+++ b/examples/shaders/meson.build
@@ -18,21 +18,31 @@ if vulkan_dep.found()
cat = find_program('../../scripts/cat.py')
glslang = find_program('glslangValidator')
- shaders = ['rect.vert', 'rect.frag']
- foreach shader : shaders
- source = shader.split('.')[0] + '.vulkan.' + shader.split('.')[1]
- shader_input = custom_target(source,
- output: source,
- input: ['header_420.glsl', shader],
- command: [cat, '@INPUT@'],
- build_by_default: true,
- capture: true)
+ rect_vulkan_vert = custom_target('rect.vulkan.vert',
+ output: 'rect.vulkan.vert',
+ input: ['header_420.glsl', 'rect.vert'],
+ command: [cat, '@INPUT@'],
+ build_by_default: true,
+ capture: true)
- mytarget = custom_target(shader,
- output: shader + '.spv',
- input: shader_input,
- command: [glslang, '-V', '-o', '@OUTPUT@', '@INPUT@'],
- build_by_default: true,
- install: false)
- endforeach
+ rect_vulkan_frag = custom_target('rect.vulkan.frag',
+ output: 'rect.vulkan.frag',
+ input: ['header_420.glsl', 'rect.frag'],
+ command: [cat, '@INPUT@'],
+ build_by_default: true,
+ capture: true)
+
+ rect_vert_spv = custom_target('rect.vert.spv',
+ output: 'rect.vert.spv',
+ input: rect_vulkan_vert,
+ command: [glslang, '-V', '-o', '@OUTPUT@', '@INPUT@'],
+ build_by_default: true,
+ install: false)
+
+ rect_frag_spv = custom_target('rect.frag.spv',
+ output: 'rect.frag.spv',
+ input: rect_vulkan_frag,
+ command: [glslang, '-V', '-o', '@OUTPUT@', '@INPUT@'],
+ build_by_default: true,
+ install: false)
endif