Add basic surface handling to RenderDriver and WindowDriver

This will likely require significant rework but it will do for now. A
considerations worth thinking about:

- What happends when the WindowDriver destroys a window, what happens to
  the corresponding surface?
This commit is contained in:
2025-04-10 16:59:59 +10:00
parent 536a1e8773
commit 6e1393ce64
6 changed files with 95 additions and 23 deletions

View File

@@ -13,6 +13,9 @@
namespace Nova {
using WindowID = uptr;
using SurfaceID = uptr;
class RenderDriver;
class NOVA_API WindowDriver {
public:
@@ -22,15 +25,15 @@ namespace Nova {
virtual void poll_events() = 0;
virtual void beep() = 0;
virtual WindowID create_window(std::string_view title, u32 width, u32 height) = 0;
[[nodiscard]] virtual u32 get_window_count() const = 0;
[[nodiscard]] virtual WindowID create_window(std::string_view title, u32 width, u32 height) = 0;
virtual void destroy_window(WindowID window) = 0;
virtual void set_window_title(WindowID window, std::string_view title) = 0;
virtual void set_window_size(WindowID window, u32 width, u32 height) = 0;
virtual void set_window_position(WindowID window, i32 x, i32 y) = 0;
[[nodiscard]] virtual u32 get_window_count() const = 0;
[[nodiscard]] virtual const char* get_surface_extension() const = 0;
[[nodiscard]] virtual SurfaceID create_surface(WindowID window, RenderDriver* render_driver) = 0;
};
} // namespace Nova

View File

@@ -7,7 +7,6 @@
#pragma once
#include <nova/api.h>
#include <nova/platform/window_driver.h>
#include <nova/render/render_api.h>
#include <nova/render/render_device.h>
#include <nova/types.h>
@@ -15,6 +14,11 @@
#include <string>
namespace Nova {
using WindowID = uptr;
using SurfaceID = uptr;
class WindowDriver;
class NOVA_API RenderDriver {
public:
static RenderDriver* create(RenderAPI api, WindowDriver* window_driver = nullptr);
@@ -28,5 +32,14 @@ namespace Nova {
[[nodiscard]] virtual u32 get_device_count() const = 0;
[[nodiscard]] virtual const RenderDevice& get_device(u32 index) const = 0;
virtual void select_device(u32 index) = 0;
[[nodiscard]] virtual SurfaceID create_surface(WindowID window) = 0;
virtual void destroy_surface(SurfaceID surface) = 0;
// TODO: get_surface_size
// TODO: get_surface_mode
// TODO: get_surface_state
// TODO: set_surface_size
// TODO: set_surface_mode
// TODO: set_surface_state
};
} // namespace Nova