aboutsummaryrefslogtreecommitdiff
path: root/dxwindow/include/dxwindow.h
blob: e8f551a834f06bb6c8dc2f06074e8e0c7bb82f08 (plain)
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
#pragma once

// Include Windows.h before GLFW to avoid macro redefinition warnings.
#define WIN32_LEAN_AND_MEAN
#include <Windows.h>

#define GLFW_INCLUDE_NONE  // Do not include OpenGL headers.
#include <GLFW/glfw3.h>

namespace dx
{

class Window
{
public:
    ~Window();

    /// Creates the window.
    bool Initialise(int width, int height, const char* title);

    /// Returns the native window handle.
    /// If the window has not been initialized, returns an invalid handle.
    HWND GetWindowHandle();

    /// Updates the window by polling for user input.
    void Update();

    /// Returns true if the user tried to close the window, false otherwise.
    bool ShouldClose() const;

private:
    GLFWwindow* m_window = nullptr;
};

/// Initialise the window subsystem.
///
/// This function must be called at the start of your application before any
/// Windows are created.
bool WindowInitialise();

/// Terminate the window subsystem.
///
/// This function should be called at the end of your application. Any existing
/// Windows are destroyed and are invalid beyond this call.
void WindowTerminate();

/// Returns the last Window error.
const char* GetWindowError();

}  // namespace dx