Unravel Engine C++ Reference
Loading...
Searching...
No Matches
render_window.cpp
Go to the documentation of this file.
1#include "render_window.h"
2#include <graphics/graphics.h>
3
4namespace unravel
5{
6render_window::render_window(os::window&& win) : window_(std::move(win))
7{
9}
10
15
17{
18 // force internal handle destruction
19 if(surface_)
20 {
21 surface_.reset();
22
23 gfx::flush();
24 }
25}
26
27void render_window::resize(uint32_t w, uint32_t h)
28{
29 window_.set_size(w, h);
31}
32
34{
35 auto size = window_.get_size();
36
37 bool needs_recreate = true;
38 if(surface_)
39 {
40 auto surf_size = surface_->get_size();
41 needs_recreate = surf_size.width != size.w || surf_size.height != size.h;
42 }
43
44 if(needs_recreate)
45 {
46 surface_ = std::make_shared<gfx::frame_buffer>(window_.get_native_handle(),
47 static_cast<std::uint16_t>(size.w),
48 static_cast<std::uint16_t>(size.h));
49 }
50}
51
52auto render_window::get_window() -> os::window&
53{
54 return window_;
55}
57{
58 return surface_;
59}
60
62{
63 pass_.reset();
64 pass_ = std::make_unique<gfx::render_pass>("present_to_window_pass");
65 pass_->bind(surface_.get());
66
67 return *pass_;
68}
69
71{
72 return *pass_;
73}
74} // namespace unravel
void flush()
T height
Definition basetypes.hpp:56
~render_window()
Destructor for the render window.
std::shared_ptr< gfx::frame_buffer > graphics_surface_t
auto get_surface() -> graphics_surface_t &
Gets the rendering surface.
void prepare_surface()
Prepares the rendering surface.
void destroy_surface()
Destroys the rendering surface.
auto begin_present_pass() -> gfx::render_pass &
Begins the present render pass.
void resize(uint32_t w, uint32_t h)
Resizes the render window to the specified width and height.
auto get_window() -> os::window &
Gets the associated OS window.
render_window(os::window &&win)
Constructs a render window with the specified OS window.
auto get_present_pass() -> gfx::render_pass &
Gets the present render pass.