aboutsummaryrefslogtreecommitdiffstats
path: root/yage/core/window.h
blob: 6087fc8da6bf2edaa2c08acbc9cd3e74ab015384 (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
51
52
53
54
55
56
57
58
59
60
61
/** ---------------------------------------------------------------------------
 * @file: window.h
 *
 * Copyright (c) 2017 Yann Herklotz Grave <ymherklotz@gmail.com>
 * MIT License, see LICENSE file for more details.
 * ----------------------------------------------------------------------------
 */

#pragma once

#include <string>

class GLFWwindow;

namespace yage
{

enum class key;

// window flags that can change it's appearance
enum WindowFlags : unsigned {
    SHOWN      = 0x1,
    HIDDEN     = 0x2,
    FULLSCREEN = 0x4,
    BORDERLESS = 0x8,
};

// window wrapper around GLFWwindow pointer
class Window
{
private:
    /// window handle
    GLFWwindow *window_ = nullptr;

public:
    Window() = default;
    Window(const Window &) = delete;
    Window(Window &&)      = delete;
    /// destroys the window handle
    ~Window();

    Window &operator=(const Window &) = delete;
    Window &operator=(Window &&) = delete;

    /// create the window, initialize the handle and update the width and height
    void create(std::string window_name, int width, int height);
    /// swap the buffer
    void swapBuffer();
    /// clear buffer
    void clearBuffer();
    /// hide windowProc
    void hide();
    /// show window
    void show();
    bool shouldClose();
    void pollEvents() const;

    bool keyPressed(key k);
};

} // namespace yage