2018-09-04 19:25:54 +00:00
|
|
|
#pragma once
|
|
|
|
|
2018-09-05 15:47:09 +00:00
|
|
|
#include "stdafx.h"
|
2018-09-04 19:25:54 +00:00
|
|
|
|
|
|
|
#include "InputManager.h"
|
|
|
|
|
|
|
|
enum MessageResponse {
|
|
|
|
UNSET,
|
|
|
|
NO_MESSAGE,
|
|
|
|
HANDLED_MESSAGE,
|
|
|
|
QUIT_MESSAGE
|
|
|
|
};
|
|
|
|
|
|
|
|
// A class to create a window in windows.
|
|
|
|
class Window
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
Window(const char* class_name, HINSTANCE h_instance);
|
|
|
|
~Window();
|
|
|
|
|
|
|
|
LRESULT CALLBACK wnd_proc(HWND h_wnd, UINT msg, WPARAM w_param, LPARAM l_param);
|
|
|
|
|
|
|
|
// Registers m_wc with windows.
|
|
|
|
bool register_class();
|
|
|
|
|
|
|
|
// Creates the window
|
|
|
|
// Use -1 for x and/or y to specify centered relative to the screen.
|
|
|
|
bool create_window(const char* title, int x, int y, int w, int h);
|
|
|
|
|
|
|
|
// Peeks the next message for the window, translates it, and then
|
|
|
|
// dispatches it.
|
|
|
|
// Returns true for a regular message. False for an exit message.
|
|
|
|
// When the message is an exit message, the message will not be translated
|
|
|
|
// or dispatched.
|
|
|
|
MessageResponse handle_message();
|
|
|
|
|
|
|
|
// Calls ShowWindow on the HWND
|
|
|
|
void show(int cmd_show);
|
|
|
|
|
|
|
|
// Calls UpdateWindow on the HWND
|
|
|
|
void update();
|
|
|
|
|
2018-09-05 06:49:02 +00:00
|
|
|
// Swaps the window's buffers
|
|
|
|
void swap();
|
|
|
|
|
2018-09-04 19:25:54 +00:00
|
|
|
// Calls CloseWindow on the HWND
|
|
|
|
void close();
|
|
|
|
|
2018-09-05 06:49:02 +00:00
|
|
|
// Sets the OpenGL Rendering Context
|
2018-09-04 19:25:54 +00:00
|
|
|
void set_h_glrc(HGLRC h_glrc);
|
|
|
|
|
|
|
|
// Returns the HWND
|
|
|
|
HWND get_h_wnd();
|
|
|
|
|
2018-09-05 06:49:02 +00:00
|
|
|
// Returns the Device Context
|
|
|
|
HDC get_h_dc();
|
|
|
|
|
|
|
|
// Returns the OpenGL Rendering Context
|
2018-09-04 19:25:54 +00:00
|
|
|
HGLRC get_h_glrc();
|
|
|
|
|
|
|
|
// Returns the InputManager
|
|
|
|
const InputManager& get_input_manager();
|
|
|
|
|
|
|
|
private:
|
|
|
|
const char* m_class_name;
|
|
|
|
|
|
|
|
HINSTANCE m_h_instance = nullptr;
|
|
|
|
WNDCLASSEX m_wc;
|
|
|
|
HWND m_h_wnd = nullptr;
|
2018-09-05 06:49:02 +00:00
|
|
|
HDC m_h_dc = nullptr; // The Device Context
|
2018-09-04 19:25:54 +00:00
|
|
|
HGLRC m_h_glrc = nullptr; // The OpenGL Rendering Context (Extra variable used by application)
|
|
|
|
|
|
|
|
InputManager m_input_manager;
|
|
|
|
};
|
|
|
|
|