aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorladevieq <ladevie.quentin@gmail.com>2021-01-09 23:31:58 +0100
committerladevieq <ladevie.quentin@gmail.com>2021-01-09 23:31:58 +0100
commit78302e1982c1b7b727c95603611b19913f5c13d0 (patch)
tree0389c971c0941006a9544beb48dc72136662050b /src
parent2db0d27e7f1744443958717c19b732eed57455f2 (diff)
XCB window creation
Diffstat (limited to 'src')
-rw-r--r--src/CMakeLists.txt7
-rw-r--r--src/main.cpp35
-rw-r--r--src/window.cpp28
3 files changed, 53 insertions, 17 deletions
diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt
index 1fd25b7..43a9858 100644
--- a/src/CMakeLists.txt
+++ b/src/CMakeLists.txt
@@ -1,6 +1,10 @@
include_directories(${CMAKE_SOURCE_DIR}/include)
include_directories(${Vulkan_INCLUDE_DIRS})
+if(UNIX)
+ include_directories(${X11_xcb_INCLUDE_PATH})
+endif()
+
add_executable(
path-tracer
main.cpp
@@ -11,8 +15,9 @@ add_executable(
vulkan-loader.cpp
utils.cpp
vk-renderer.cpp
+ window.cpp
)
if(UNIX)
- target_link_libraries(path-tracer ${CMAKE_DL_LIBS})
+ target_link_libraries(path-tracer ${CMAKE_DL_LIBS} ${X11_xcb_LIB})
endif()
diff --git a/src/main.cpp b/src/main.cpp
index 03706b4..7a91c4e 100644
--- a/src/main.cpp
+++ b/src/main.cpp
@@ -4,11 +4,11 @@
#include <cstring>
#include <cstdio>
#include <cassert>
+#include <unistd.h>
#include <dlfcn.h>
-#include "vk-renderer.hpp"
-
#include "rt.hpp"
+#include "vk-renderer.hpp"
#include "thirdparty/renderdoc.h"
color ground_color { 1.0, 1.0, 1.0 };
@@ -79,6 +79,7 @@ int main() {
assert(ret == 1);
}
+ window wnd {};
vkrenderer renderer {};
// Image dimensions
@@ -132,28 +133,30 @@ int main() {
std::cerr << "Generating image" << std::endl;
+ pause();
+
// To start a frame capture, call StartFrameCapture.
// You can specify NULL, NULL for the device to capture on if you have only one device and
// either no windows at all or only one window, and it will capture from that device.
// See the documentation below for a longer explanation
- if(rdoc_api) rdoc_api->StartFrameCapture(NULL, NULL);
+ // if(rdoc_api) rdoc_api->StartFrameCapture(NULL, NULL);
- auto start = std::chrono::high_resolution_clock::now();
- renderer.compute(inputs, width, height);
- auto end = std::chrono::high_resolution_clock::now();
+ // auto start = std::chrono::high_resolution_clock::now();
+ // renderer.compute(inputs, width, height);
+ // auto end = std::chrono::high_resolution_clock::now();
- std::cerr << "Image generation took " << std::chrono::duration_cast<std::chrono::milliseconds>(end - start).count() << "ms" << std::endl;
+ // std::cerr << "Image generation took " << std::chrono::duration_cast<std::chrono::milliseconds>(end - start).count() << "ms" << std::endl;
- // stop the capture
- if(rdoc_api) rdoc_api->EndFrameCapture(NULL, NULL);
+ // // stop the capture
+ // if(rdoc_api) rdoc_api->EndFrameCapture(NULL, NULL);
- //-------------------------
- // GPU path tracer
- //-------------------------
- auto output_image = renderer.output_image();
- for (size_t index = 0; index < height * width; index++) {
- write_color(std::cout, output_image[index]);
- }
+ // //-------------------------
+ // // GPU path tracer
+ // //-------------------------
+ // auto output_image = renderer.output_image();
+ // for (size_t index = 0; index < height * width; index++) {
+ // write_color(std::cout, output_image[index]);
+ // }
std::cerr << "Done !" << std::endl;
diff --git a/src/window.cpp b/src/window.cpp
new file mode 100644
index 0000000..93c7517
--- /dev/null
+++ b/src/window.cpp
@@ -0,0 +1,28 @@
+#include "window.hpp"
+
+window::window() {
+ connection = xcb_connect(NULL, NULL);
+ win = xcb_generate_id(connection);
+
+ auto setup = xcb_get_setup (connection);
+ auto screen_info = xcb_setup_roots_iterator(setup).data;
+
+ xcb_create_window(
+ connection,
+ XCB_COPY_FROM_PARENT,
+ win,
+ screen_info->root,
+ 10,
+ 10,
+ 400,
+ 400,
+ 10,
+ XCB_WINDOW_CLASS_INPUT_OUTPUT,
+ screen_info->root_visual,
+ 0,
+ nullptr
+ );
+
+ xcb_map_window(connection, win);
+ xcb_flush(connection);
+}