-
Notifications
You must be signed in to change notification settings - Fork 4
/
Copy pathBearUIViewport.cpp
77 lines (64 loc) · 1.47 KB
/
BearUIViewport.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
#include "BearUI.hpp"
BearUIViewport::BearUIViewport(bsize width, bsize height, bool fullscreen, BearFlags<int32> flags):BearWindow(width,height,fullscreen,flags)
{
}
BearUIViewport::~BearUIViewport()
{
}
void BearUIViewport::BeginFrame()
{
BearWindow::BeginFrame();
}
void BearUIViewport::EndFrame()
{
BearWindow::EndFrame();
Frame();
}
void BearUIViewport::Load()
{
BearViewportDescription Description;
Description.Clear = true;
m_Viewport = BearRenderInterface::CreateViewport(GetWindowHandle(), GetSize().x, GetSize().y, IsFullScreen(), Description);
BearUIViewportBase::Load(m_Viewport->GetFormat());
}
void BearUIViewport::Unload()
{
m_Viewport.clear();
}
void BearUIViewport::Render()
{
if (m_Context.empty())return;
m_Context->Reset();
m_Context->Lock(m_Viewport);
m_Context->SetViewportAsFrameBuffer(m_Viewport);
BearUIViewportBase::Render();
m_Context->Unlock(m_Viewport);
m_Context->Flush(m_Viewport, true);
}
void BearUIViewport::SetMousePosition(const BearFVector2& position)
{
BearWindow::SetMousePosition(position);
}
BearFVector2 BearUIViewport::GetMousePosition() const
{
return BearWindow::GetMousePosition();
}
BearFVector2 BearUIViewport::GetSizeViewport() const
{
return GetSizeFloat();
}
void BearUIViewport::OnEvent(BearEventWindows& e)
{
switch (e.Type)
{
case BearWindowEventType::KeyDown:
OnKeyDown(e.Key);
break;
case BearWindowEventType::KeyUp:
OnKeyUp(e.Key);
break;
case BearWindowEventType::Char:
OnChar(e.Char);
break;
}
}