sculpto
Main Page
Namespaces
Classes
Files
File List
File Members
core
gui
windows
viewport_window.cpp
Go to the documentation of this file.
1
/*!****************************************************************/
/*!*
2
* \file editor_viewport_window.h
3
* \brief Sculpto editor viewport window class implementation module.
4
*
5
* \author Sabitov Kirill
6
* \date 09 July 2022
7
*********************************************************************/
8
9
#include "
sclpch.h
"
10
11
#include <imgui.h>
12
#include <entt.hpp>
13
14
#include "
viewport_window.h
"
15
#include "
core/scene/scene.h
"
16
#include "
core/events/events.h
"
17
#include "
core/render/primitives/frame_buffer.h
"
18
#include "
core/render/primitives/texture.h
"
19
20
scl::viewport_window::viewport_window
(
const
shared<frame_buffer>
&ViewportBuffer,
int
ViewportId) :
21
ViewportBuffer(ViewportBuffer) {
SetViewportId
(ViewportId); }
22
23
void
scl::viewport_window::Draw
()
24
{
25
ImGui::Begin(
"Viewport"
);
26
{
27
const
ImVec2 window_size = ImGui::GetContentRegionAvail();
28
if
((window_size.x != ViewportWidth || window_size.y != ViewportHeight) &&
29
window_size.x > 0 && window_size.y > 0)
30
{
31
ViewportWidth = window_size.x, ViewportHeight = window_size.y;
32
viewport_resize_event
e { ViewportWidth, ViewportHeight, ViewportId };
33
event_dispatcher::Invoke
(e);
34
}
35
36
if
(
auto
viewport_buffer = ViewportBuffer.lock())
37
ImGui::Image((ImTextureID)viewport_buffer->GetColorAttachment()->GetHandle(), window_size, {0, 1}, {1, 0});
38
39
if
(ImGui::IsItemHovered()) ImGui::SetNextFrameWantCaptureMouse(
false
);
40
if
(ImGui::IsItemActive()) ImGui::SetNextFrameWantCaptureKeyboard(
false
);
41
}
42
ImGui::End();
43
}
scl::event_dispatcher::Invoke
static void Invoke(Tevent &Event)
Definition:
event_dispatcher.h:72
scl::viewport_resize_event
Definition:
vieport_resize_event.h:17
scl::viewport_window::viewport_window
viewport_window(const shared< frame_buffer > &ViewportBuffer, int ViewportId=30)
Definition:
viewport_window.cpp:20
scl::viewport_window::Draw
void Draw()
Definition:
viewport_window.cpp:23
scl::viewport_window::SetViewportId
void SetViewportId(int ViewportId)
Definition:
viewport_window.h:37
events.h
Events include module.
frame_buffer.h
Frame buffer interface implementation module.
scl::shared
std::shared_ptr< T > shared
Definition:
smart_ptr.h:15
scene.h
Scene class defintion module.
sclpch.h
Sculpto library prehompiled header. Defines common definitions, includes commonly used modules.
texture.h
Texture interface definition module.
viewport_window.h
Generated by
1.9.4