1
0
Fork 0

GLContext: remove setSize() and set glViewport() in Display::onReshape()

This commit is contained in:
Henrik Hautakoski 2023-08-02 22:30:45 +02:00
parent 60333f6d02
commit c1f1dd75bd
6 changed files with 8 additions and 33 deletions

View file

@ -38,9 +38,6 @@ public :
// This is usually refered to as enabling/disabling vertical synchronization. // This is usually refered to as enabling/disabling vertical synchronization.
virtual bool setSwapInterval(int interval) = 0; virtual bool setSwapInterval(int interval) = 0;
// Set the size of the pixel buffer.
virtual void setSize(unsigned int width, unsigned int height) = 0;
// Swap front with back buffer and vice versa. // Swap front with back buffer and vice versa.
virtual void swapBuffers() = 0; virtual void swapBuffers() = 0;
}; };

View file

@ -5,6 +5,8 @@
#include <Spectre/Graphics/Image.h> #include <Spectre/Graphics/Image.h>
#include <Platform/PlatformDisplay.h> #include <Platform/PlatformDisplay.h>
#include <Graphics/GL/gl.h>
namespace sp { namespace sp {
#define CAPTION_DEFAULT "Spectre" #define CAPTION_DEFAULT "Spectre"
@ -182,8 +184,12 @@ void Display::swapBuffers()
void Display::onReshape(int width, int height) void Display::onReshape(int width, int height)
{ {
// Resize context if the windows resizes. // TODO: This should even not be here.
m_context->setSize(width, height); // Generic Display should not have any GL calls.
// But it's better to have it here then in the platform specific GLContext
if (activate(true)) {
glViewport(0, 0, width, height);
}
} }
} // namespace sp } // namespace sp

View file

@ -189,19 +189,6 @@ bool GLXContext::setSwapInterval(int interval)
return false; return false;
} }
void GLXContext::setSize(unsigned int width, unsigned int height)
{
// TODO: Not GLX specific! move to generic GLContext class.
if (activate()) {
glViewport(0, 0, width, height);
}
}
void GLXContext::setSize(const Vector2u size)
{
setSize(size.x, size.y);
}
void GLXContext::swapBuffers() void GLXContext::swapBuffers()
{ {
glXSwapBuffers(Xlib::getDisplay(), m_win); glXSwapBuffers(Xlib::getDisplay(), m_win);

View file

@ -28,10 +28,6 @@ public :
bool setSwapInterval(int interval); bool setSwapInterval(int interval);
void setSize(unsigned int width, unsigned int height);
void setSize(const Vector2u size);
void swapBuffers(); void swapBuffers();
private : private :

View file

@ -149,13 +149,6 @@ bool Win32GLContext::setSwapInterval(int interval)
return wglSwapIntervalEXT(interval); return wglSwapIntervalEXT(interval);
} }
void Win32GLContext::setSize(unsigned int width, unsigned int height)
{
if (activate()) {
glViewport(0, 0, width, height);
}
}
void Win32GLContext::swapBuffers() void Win32GLContext::swapBuffers()
{ {
if (m_deviceContext) { if (m_deviceContext) {

View file

@ -28,10 +28,6 @@ public :
bool setSwapInterval(int interval); bool setSwapInterval(int interval);
void setSize(unsigned int width, unsigned int height);
void setSize(const Vector2u size);
void swapBuffers(); void swapBuffers();
private : private :