Covellite++  Version: 2.3.0 Revision: ??? Platform: x64 Build: 23:13 04.01.2025
Кроссплатформенный фреймворк для разработки приложений на С++
Загрузка...
Поиск...
Не найдено
Window.cpp
1
2#include "stdafx.h"
3#include <Covellite/Api/Window.hpp>
4#include <alicorn/std/string.hpp>
5#include <Covellite/Events.hpp>
6#include <Covellite/App/Events.hpp>
7#include <Covellite/App/Settings.hpp>
8#include <Covellite/Os/IWindow.hpp>
9#include <Covellite/Os/Events.hpp>
10#include <Covellite/Api/Events.hpp>
11#include "Renderer/IGraphicApi.hpp"
12
13#ifndef __USING_GTEST
14
15# if BOOST_OS_WINDOWS
16
17#include "Renderer/OpenGL.hpp"
18#include "Renderer/DirectX10.hpp"
19#include "Renderer/DirectX11.hpp"
20
21# elif BOOST_PLAT_ANDROID
22
23#include "Renderer/OpenGLES3.hpp"
24
25# endif // BOOST_OS_...
26
27#endif // __USING_GTEST
28
29namespace covellite
30{
31
32namespace api
33{
34
35Window::Window(const WindowOs_t & _Window) :
36 m_WindowOs(_Window),
37 m_Events(_Window),
38 m_pImpl(MakeImpl(_Window))
39{
40 LOGGER(Info) << uT("Using graphics API: ") << m_pImpl->GetUsingApi();
41
42 m_Events[events::Application.Update].Connect([this](void)
43 {
44 m_Events[events::Drawing.Do]();
45 m_pImpl->PresentFrame();
46 });
47
48 m_Events[events::Window.Resize].Connect([this](void)
49 {
50 m_pImpl->ResizeWindow(GetClientRect());
51 });
52}
53
54Window::~Window(void) = default;
55
56Window::operator Window::Events_t(void) const /*override*/
57{
58 return m_Events;
59}
60
61Rect Window::GetClientRect(void) const /*override*/
62{
63 return m_WindowOs.GetClientRect();
64}
65
78auto Window::GetRenders(void) const /*override*/ -> RendersPtr_t
79{
80 return ::std::make_shared<Component::Renders>(m_pImpl->GetCreators());
81}
82
83/*static*/ auto Window::MakeImpl(const WindowOs_t & _Window) -> IGraphicApiPtr_t
84{
85 renderer::SettingsData oSettingsData;
86 oSettingsData.Handle = _Window.GetHandle();
87 oSettingsData.ClientRect = _Window.GetClientRect();
88
89 using String_t = ::alicorn::extension::std::String;
90
91 const auto MainSection = ::covellite::app::Settings_t::GetInstance();
92 const auto WindowSection = MainSection[uT("Window")];
93
94# if BOOST_OS_WINDOWS
95 oSettingsData.IsFullScreen = WindowSection.Get<bool>(uT("IsFullScreen"));
96# endif
97
98 const auto NameOfApiClass = WindowSection.Get<String_t>(uT("GraphicsApi"));
99
100 return MakeImpl(NameOfApiClass, oSettingsData);
101}
102
103} // namespace api
104
105} // namespace covellite
Класс для передачи значений настроек программы реализации рендера.
Definition IGraphicApi.hpp:62
bool IsFullScreen
Признак работы программы в полноэкранном режиме.
Definition IGraphicApi.hpp:66
Rect ClientRect
Фактические размеры клиентской области окна.
Definition IGraphicApi.hpp:65
Any_t Handle
Хэнд окна операционной системы.
Definition IGraphicApi.hpp:64