mirror of
https://github.com/gwm17/Specter.git
synced 2025-03-14 06:28:50 -04:00
56 lines
1.5 KiB
C++
56 lines
1.5 KiB
C++
/*
|
|
OpenGLWindow.h
|
|
Implementation of a window with OpenGL context. Not really OpenGL specific, other than in creation of GraphicsContext.
|
|
Bulk of creation can be used in any api/context (glfw compatible with Cocoa, X11, or Windows). Based entirely upon the
|
|
work of @TheCherno in his game engine series.
|
|
|
|
GWM -- Feb 2022
|
|
*/
|
|
#ifndef OPENGL_WINDOW_H
|
|
#define OPENGL_WINDOW_H
|
|
|
|
#include "Navigator/NavCore.h"
|
|
#include "Navigator/Window.h"
|
|
#include "Navigator/Renderer/GraphicsContext.h"
|
|
#include "GLFW/glfw3.h"
|
|
|
|
namespace Navigator {
|
|
|
|
class NAV_API OpenGLWindow : public Window
|
|
{
|
|
|
|
public:
|
|
OpenGLWindow(const WindowProperties& props);
|
|
virtual ~OpenGLWindow();
|
|
|
|
void OnUpdate() override;
|
|
|
|
inline void SetEventCallback(const EventCallbackFunc& function) override { m_data.event_callback_func = function; }
|
|
inline unsigned int GetWidth() const override { return m_data.width; }
|
|
inline unsigned int GetHeight() const override { return m_data.height; }
|
|
inline std::string GetName() const override { return m_data.name; }
|
|
void SetVSync(bool enabled) override;
|
|
bool IsVSync() const override;
|
|
|
|
inline virtual void* GetNativeWindow() const override { return m_window; }
|
|
private:
|
|
virtual void Init(const WindowProperties& props);
|
|
virtual void Shutdown();
|
|
|
|
GraphicsContext* m_context;
|
|
|
|
GLFWwindow* m_window;
|
|
|
|
struct Data
|
|
{
|
|
int height, width;
|
|
std::string name;
|
|
bool vsyncFlag;
|
|
EventCallbackFunc event_callback_func;
|
|
};
|
|
|
|
Data m_data;
|
|
};
|
|
}
|
|
|
|
#endif |