charcoal/archive/Window.h
elipzer b494f68d0c A Working Triangle
Now using GLFW3 instead of the custom window class. This library
looks like it will make development much simpler and will make it
so that I am less worried about my windows code breaking. Currently
setup the http://antongerdelan.net/opengl/hellotriangle.html
tutorial in the MySimpleScene. Will probably create another scene
file to try to get the object oriented stuff working.
2018-09-05 16:26:50 -04:00

76 lines
1.6 KiB
C++

#pragma once
#include "stdafx.h"
#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();
// Swaps the window's buffers
void swap();
// Calls CloseWindow on the HWND
void close();
// Sets the OpenGL Rendering Context
void set_h_glrc(HGLRC h_glrc);
// Returns the HWND
HWND get_h_wnd();
// Returns the Device Context
HDC get_h_dc();
// Returns the OpenGL Rendering Context
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;
HDC m_h_dc = nullptr; // The Device Context
HGLRC m_h_glrc = nullptr; // The OpenGL Rendering Context (Extra variable used by application)
InputManager m_input_manager;
};