MGL(Win32)
読み取り中…
検索中…
一致する文字列を見つけられません
mgl_win32_window.h
[詳解]
1// SPDX-License-Identifier: Zlib
2/* ------------------------------------------------------------------------- */
9/* ------------------------------------------------------------------------- */
10
11#ifndef INCGUARD_MGL_WIN32_WINDOW_H_1614567872
12#define INCGUARD_MGL_WIN32_WINDOW_H_1614567872
13
14#include <mgl/mgl_environment.h>
15#if defined(MGL_TARGET_WIN32)
16
17#include <Windows.h>
21
22namespace MGL::Win32
23{
25class Window final : public MGL::SharedSingleton<Window>
26{
27public:
28
31 {
32 int width{1280};
33 int height{720};
34 LPCWSTR windowTitle{L"MGL-App"};
35 LPCWSTR className{nullptr};
36 HICON icon{nullptr};
37 HICON smallIcon{nullptr};
38 };
39
40 static STL::unique_ptr<Window> &GetInstanceRef() noexcept;
41
42 bool Initialize(HINSTANCE hInstance, int nCmdShow, WNDPROC windowProc, const Descriptor &descriptor) noexcept;
43
44 /* ------------------------------------------------------------------------- */
48 /* ------------------------------------------------------------------------- */
49 constexpr HWND GetWindowHandler() noexcept
50 {
51 return _hWnd;
52 }
53
54 /* ------------------------------------------------------------------------- */
59 /* ------------------------------------------------------------------------- */
60 [[nodiscard]] constexpr int GetWidth() const noexcept
61 {
62 return _width;
63 }
64
65 /* ------------------------------------------------------------------------- */
70 /* ------------------------------------------------------------------------- */
71 [[nodiscard]] constexpr int GetHeight() const noexcept
72 {
73 return _height;
74 }
75
76
77 /* ------------------------------------------------------------------------- */
81 /* ------------------------------------------------------------------------- */
82 [[nodiscard]] constexpr HINSTANCE GetAppInstanceHandle() const noexcept
83 {
84 return _hInstance;
85 }
86
87 void SetWindowTitle(const char *title) noexcept;
88 bool Resize(int width, int height) noexcept;
89 [[nodiscard]] float GetLogicalScaleFactor() const noexcept;
90
91 void Update() noexcept;
92
93private:
94 HINSTANCE _hInstance{nullptr};
95 HWND _hWnd{nullptr};
96 int _width{0};
97 int _height{0};
98 float _scaleFactor{1.0f};
99};
100} // namespace MGL::Win32
101
102#endif // MGL_TARGET_WIN32
103#endif // INCGUARD_MGL_WIN32_WINDOW_H_1614567872
104
105// vim: et ts=4 sw=4 sts=4
シングルトンテンプレート(共有ライブラリ用)
Definition mgl_singleton.h:44
Win32用ウィンドウクラス
Definition mgl_win32_window.h:26
constexpr HINSTANCE GetAppInstanceHandle() const noexcept
アプリケーションインスタンスのハンドルを取得
Definition mgl_win32_window.h:82
bool Resize(int width, int height) noexcept
ウィンドウのリサイズ
Definition mgl_win32_window.cc:126
constexpr int GetWidth() const noexcept
ウィンドウの幅を取得
Definition mgl_win32_window.h:60
constexpr int GetHeight() const noexcept
ウィンドウの高さを取得
Definition mgl_win32_window.h:71
void SetWindowTitle(const char *title) noexcept
ウィンドウタイトルの設定
Definition mgl_win32_window.cc:108
float GetLogicalScaleFactor() const noexcept
ウィンドウの論理サイズの倍率を取得
Definition mgl_win32_window.cc:149
void Update() noexcept
ウィンドウの更新処理
Definition mgl_win32_window.cc:160
bool Initialize(HINSTANCE hInstance, int nCmdShow, WNDPROC windowProc, const Descriptor &descriptor) noexcept
初期化処理
Definition mgl_win32_window.cc:40
constexpr HWND GetWindowHandler() noexcept
ウィンドウハンドラの取得
Definition mgl_win32_window.h:49
static STL::unique_ptr< Window > & GetInstanceRef() noexcept
インスタンスの取得
Definition mgl_win32_window.cc:22
MGL 環境定義
MGL イベントハンドル
MGL シングルトンクラス
MGL STLのメモリ関連の代替
std::unique_ptr< T, Deleter > unique_ptr
MGLのアロケータを利用するユニークポインタ
Definition mgl_stl_memory.h:248
ウィンドウ初期化用記述子
Definition mgl_win32_window.h:31
int height
ウィンドウの高さ
Definition mgl_win32_window.h:33
HICON icon
ウィンドウアイコン
Definition mgl_win32_window.h:36
int width
ウィンドウの幅
Definition mgl_win32_window.h:32
LPCWSTR className
クラス名(nullptr指定でウィンドウタイトルを使用)
Definition mgl_win32_window.h:35
HICON smallIcon
ウィンドウの小アイコン
Definition mgl_win32_window.h:37
LPCWSTR windowTitle
ウィンドウタイトル
Definition mgl_win32_window.h:34