Archived
1
Fork 0

Begin work for multiviewport support on Linux

This commit is contained in:
redstrate 2021-02-17 09:15:35 -05:00
parent 1a324e61af
commit bf192cd23a
3 changed files with 44 additions and 1 deletions

View file

@ -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 = {};

View file

@ -7,6 +7,7 @@ add_platform(
LINK_LIBRARIES
X11
xcb
xcb-randr
Core
GFXVulkan
COMPILE_OPTIONS

View file

@ -10,6 +10,7 @@
#include <unistd.h>
#include <X11/Xlib.h>
#include <xcb/xcb.h>
#include <xcb/randr.h>
#include <X11/Xutil.h>
@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;