diff --git a/engine/gfx/vulkan/src/gfx_vulkan.cpp b/engine/gfx/vulkan/src/gfx_vulkan.cpp index 375d1ec..2b9db9f 100755 --- a/engine/gfx/vulkan/src/gfx_vulkan.cpp +++ b/engine/gfx/vulkan/src/gfx_vulkan.cpp @@ -284,8 +284,11 @@ GFXBuffer* GFXVulkan::create_buffer(void *data, const GFXSize size, const bool d void GFXVulkan::copy_buffer(GFXBuffer* buffer, void* data, GFXSize offset, GFXSize size) { GFXVulkanBuffer* vulkanBuffer = (GFXVulkanBuffer*)buffer; - void* mapped_data; + void* mapped_data = nullptr; vkMapMemory(device, vulkanBuffer->memory, offset, vulkanBuffer->size - offset, 0, &mapped_data); + if(mapped_data == nullptr) + return; + memcpy(mapped_data, data, size); VkMappedMemoryRange range = {}; diff --git a/platforms/linux/CMakeLists.txt b/platforms/linux/CMakeLists.txt index 70d72d6..1347b8a 100755 --- a/platforms/linux/CMakeLists.txt +++ b/platforms/linux/CMakeLists.txt @@ -7,6 +7,7 @@ add_platform( LINK_LIBRARIES X11 xcb + xcb-randr Core GFXVulkan COMPILE_OPTIONS diff --git a/platforms/linux/main.cpp.in b/platforms/linux/main.cpp.in index 9e0b809..8b1eee7 100755 --- a/platforms/linux/main.cpp.in +++ b/platforms/linux/main.cpp.in @@ -10,6 +10,7 @@ #include #include #include +#include #include @APP_CLASS@* app = nullptr; @@ -51,6 +52,9 @@ const char* platform::get_name() { } bool platform::supports_feature(const PlatformFeature feature) { + if(feature == PlatformFeature::Windowing) + return true; + return false; } @@ -129,9 +133,42 @@ float platform::get_monitor_dpi() { } prism::Rectangle platform::get_monitor_resolution() { + // based off of https://stackoverflow.com/a/27141466 + xcb_flush(connection); + + xcb_randr_get_screen_resources_cookie_t screenResCookie = {}; + screenResCookie = xcb_randr_get_screen_resources(connection, screen->root); + + xcb_randr_get_screen_resources_reply_t* screenResReply = {}; + screenResReply = xcb_randr_get_screen_resources_reply(connection, screenResCookie, 0); + + int crtcs_num = xcb_randr_get_screen_resources_crtcs_length(screenResReply); + xcb_randr_crtc_t* firstCRTC = xcb_randr_get_screen_resources_crtcs(screenResReply); + + xcb_randr_get_crtc_info_cookie_t* crtcResCookie = new xcb_randr_get_crtc_info_cookie_t[crtcs_num]; + for(int i = 0; i < crtcs_num; i++) + crtcResCookie[i] = xcb_randr_get_crtc_info(connection, *(firstCRTC+i), 0); + + xcb_randr_get_crtc_info_reply_t** crtcResReply = new xcb_randr_get_crtc_info_reply_t*[crtcs_num]; + for(int i = 0; i < crtcs_num; i++) + crtcResReply[i] = xcb_randr_get_crtc_info_reply(connection, crtcResCookie[i], 0); + + for(int i = 0; i < crtcs_num; i++) { + // just pick up the first monitor for now + if(crtcResReply[i]) { + prism::Rectangle rect; + rect.extent.width = crtcResReply[i]->width; + rect.extent.height = crtcResReply[i]->height; + + return rect; + } + } + + return {}; } prism::Rectangle platform::get_monitor_work_area() { + return platform::get_monitor_resolution(); } prism::Offset platform::get_window_position(const int index) { @@ -356,6 +393,8 @@ int main(int argc, char* argv[]) { engine->update(1.0 / 60.0); engine->begin_frame(1.0 / 60.0); engine->render(0); + + engine->end_frame(); } return 0;