diff options
Diffstat (limited to 'modules/window-vulkan/examples')
-rw-r--r-- | modules/window-vulkan/examples/SConscript | 35 | ||||
-rw-r--r-- | modules/window-vulkan/examples/window_create.cpp | 34 |
2 files changed, 69 insertions, 0 deletions
diff --git a/modules/window-vulkan/examples/SConscript b/modules/window-vulkan/examples/SConscript new file mode 100644 index 0000000..e64eb92 --- /dev/null +++ b/modules/window-vulkan/examples/SConscript @@ -0,0 +1,35 @@ +#!/bin/false + +import os +import os.path +import glob + + +Import('env') + +dir_path = Dir('.').abspath + +# Environment for base library +examples_env = env.Clone(); + + +examples_env.sources = sorted(glob.glob(dir_path + "/*.cpp")) +examples_env.headers = sorted(glob.glob(dir_path + "/*.hpp")) + +env.sources += examples_env.sources; +env.headers += examples_env.headers; + +ex_objects = []; +# examples_env.add_source_files(ex_objects, ['window_create_kernel.cpp'], shared=True); + +objects_static = [] +examples_env.window_create = examples_env.Program('#bin/window_create', ['window_create.cpp', env.library_static]); + +# Set Alias +env.examples = [examples_env.window_create]; +env.Alias('examples', env.examples); + +if env["build_examples"]: + env.targets += ['examples']; + env.Install('$prefix/bin/', env.examples); +#endif diff --git a/modules/window-vulkan/examples/window_create.cpp b/modules/window-vulkan/examples/window_create.cpp new file mode 100644 index 0000000..a5a2ae4 --- /dev/null +++ b/modules/window-vulkan/examples/window_create.cpp @@ -0,0 +1,34 @@ +#include <forstio/io/io.hpp> + +#include <iostream> + +int main(){ + auto eo_aio = saw::setup_async_io(); + if(eo_aio.is_error()){ + auto& err = eo_aio.get_error(); + std::cerr<<"Error: "<<err.get_category(); + + auto err_msg = err.get_message(); + if(err_msg.size() > 0u){ + std::cerr<<" - "<<err_msg; + } + + std::cerr<<std::endl; + return err.get_id(); + } + auto& aio = eo_aio.get_value(); + saw::wait_scope wait{aio.event_loop}; + + bool running = true; + + aio.event_port.on_signal(saw::Signal::Terminate).then([&running](){ + running = false; + }).detach(); + + while(running){ + device->flush(); + wait.wait(std::chrono::seconds{1u}); + } + + return 0; +} |