1
0
Fork 0

Spectre/Window/Window: refactor out GLContext specific code to its own class (GLWindow)

This commit is contained in:
Henrik Hautakoski 2023-08-23 19:28:24 +02:00
parent 2de3bd93f7
commit b1ccea1397
7 changed files with 120 additions and 55 deletions

View file

@ -0,0 +1,41 @@
#ifndef SPECTRE_WINDOW_GLWINDOW_H
#define SPECTRE_WINDOW_GLWINDOW_H
#include <Spectre/Window/Window.h>
#include <Spectre/Window/GLContext.h>
namespace sp {
class GLContext;
// GLWindow represents a window that has an OpenGL context attached to it.
class GLWindow : public Window
{
public:
GLWindow();
virtual ~GLWindow();
virtual bool create(WindowDescription decription);
virtual void destroy();
bool activate(bool value);
// Enable/Disable Vertical Sync.
bool enableVSync(bool value);
void swapBuffers();
protected:
virtual void onReshape(int width, int height);
private:
GLContext* m_context;
};
} // namepsace sp
#endif /* SPECTRE_WINDOW_GLWINDOW_H */

View file

@ -5,7 +5,6 @@
#include "DisplayMode.h"
#include "WindowDescription.h"
#include <Spectre/Math/Vector2.h>
#include <Spectre/Window/GLContext.h>
#include <cstdint>
#include <string>
@ -28,9 +27,9 @@ public :
Window();
virtual ~Window();
bool create(WindowDescription decription);
virtual bool create(WindowDescription decription);
void destroy();
virtual void destroy();
void setSize(unsigned int width, unsigned int height);
@ -58,18 +57,11 @@ public :
void grabCursor(bool value);
bool activate(bool value);
// Enable/Disable Vertical Sync.
bool enableVSync(bool value);
void swapBuffers();
protected :
void init();
void onReshape(int width, int height);
virtual void onReshape(int width, int height);
protected :
enum Mode m_fmode;
@ -84,8 +76,6 @@ protected :
std::string m_caption;
PlatformWindow* m_impl;
GLContext* m_context;
};
} // namepsace sp