Covellite++  Version: 2.3.3 Revision: 2585 Platform: x64 Build: 21:20 20.09.2026
Кроссплатформенный фреймворк для разработки приложений на С++
Загрузка...
Поиск...
Не найдено
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
84size_t Window::GetDrawCallCount(void) const /*final*/
85{
86 return m_pImpl->GetDrawCallCount();
87}
88
89/*static*/ auto Window::MakeImpl(const WindowOs_t & _Window) -> IGraphicApiPtr_t
90{
91 renderer::SettingsData oSettingsData;
92 oSettingsData.Handle = _Window.GetHandle();
93 oSettingsData.ClientRect = _Window.GetClientRect();
94
95 using String_t = ::alicorn::extension::std::String;
96
97 const auto MainSection = ::covellite::app::Settings_t::GetInstance();
98 const auto WindowSection = MainSection[uT("Window")];
99
100# if BOOST_OS_WINDOWS
101 oSettingsData.IsFullScreen = WindowSection.Get<bool>(uT("IsFullScreen"));
102# endif
103
104 const auto NameOfApiClass = WindowSection.Get<String_t>(uT("GraphicsApi"));
105
106 return MakeImpl(NameOfApiClass, oSettingsData);
107}
108
109} // namespace api
110
111} // namespace covellite
Класс для передачи значений настроек программы реализации рендера.
Определения IGraphicApi.hpp:63
bool IsFullScreen
Признак работы программы в полноэкранном режиме.
Определения IGraphicApi.hpp:67
Rect ClientRect
Фактические размеры клиентской области окна.
Определения IGraphicApi.hpp:66
Any_t Handle
Хэнд окна операционной системы.
Определения IGraphicApi.hpp:65
size_t GetDrawCallCount(void) const final
Количество drawcall'ов в последнем кадре.
Определения Window.cpp:84
RendersPtr_t GetRenders(void) const override
Функция получения объекта для созданий рендеров компонентов объектов 3D сцены.
Определения Window.cpp:78
Rect GetClientRect(void) const override
Функция получения размеров клиентской области окна.
Определения Window.cpp:61