Merge HIDPI_GL_CANVAS wrapper with OPENGL_GAL implementation.
This commit is contained in:
parent
909d95b5be
commit
19d7112fa2
|
@ -37,10 +37,7 @@ HIDPI_GL_CANVAS::HIDPI_GL_CANVAS( wxWindow *parent,
|
|||
const wxPalette& palette ) :
|
||||
wxGLCanvas( parent, dispAttrs, id, pos, size, style, name, palette )
|
||||
{
|
||||
#ifdef RETINA_OPENGL_PATCH
|
||||
SetViewWantsBestResolution( true );
|
||||
scaleFactor = GetBackingScaleFactor();
|
||||
#endif
|
||||
initialize();
|
||||
}
|
||||
|
||||
HIDPI_GL_CANVAS::HIDPI_GL_CANVAS( wxWindow *parent,
|
||||
|
@ -53,10 +50,7 @@ HIDPI_GL_CANVAS::HIDPI_GL_CANVAS( wxWindow *parent,
|
|||
const wxPalette& palette ) :
|
||||
wxGLCanvas( parent, id, attribList, pos, size, style, name, palette )
|
||||
{
|
||||
#ifdef RETINA_OPENGL_PATCH
|
||||
SetViewWantsBestResolution( true );
|
||||
scaleFactor = GetBackingScaleFactor();
|
||||
#endif
|
||||
initialize();
|
||||
}
|
||||
|
||||
|
||||
|
@ -65,9 +59,29 @@ wxSize HIDPI_GL_CANVAS::GetClientSize() const
|
|||
wxSize size = wxGLCanvas::GetClientSize();
|
||||
|
||||
#ifdef RETINA_OPENGL_PATCH
|
||||
const float scaleFactor = GetBackingScaleFactor();
|
||||
size.x *= scaleFactor;
|
||||
size.y *= scaleFactor;
|
||||
#endif
|
||||
|
||||
return size;
|
||||
}
|
||||
|
||||
float HIDPI_GL_CANVAS::GetBackingScaleFactor() const
|
||||
{
|
||||
#ifdef RETINA_OPENGL_PATCH
|
||||
// this is ugly, but original method isn't marked const although it doesn't modify anything
|
||||
// => clean up when it officially has arrived in wxWidgets
|
||||
return static_cast< wxGLCanvas* >( const_cast< HIDPI_GL_CANVAS* >( this ))->GetBackingScaleFactor();
|
||||
#else
|
||||
return 1.0f;
|
||||
#endif
|
||||
}
|
||||
|
||||
|
||||
void HIDPI_GL_CANVAS::initialize()
|
||||
{
|
||||
#ifdef RETINA_OPENGL_PATCH
|
||||
SetViewWantsBestResolution( true );
|
||||
#endif
|
||||
}
|
||||
|
|
|
@ -68,7 +68,7 @@ OPENGL_GAL::OPENGL_GAL( GAL_DISPLAY_OPTIONS& aDisplayOptions, wxWindow* aParent,
|
|||
wxEvtHandler* aMouseListener, wxEvtHandler* aPaintListener,
|
||||
const wxString& aName ) :
|
||||
GAL( aDisplayOptions ),
|
||||
wxGLCanvas( aParent, wxID_ANY, (int*) glAttributes, wxDefaultPosition, wxDefaultSize,
|
||||
HIDPI_GL_CANVAS( aParent, wxID_ANY, (int*) glAttributes, wxDefaultPosition, wxDefaultSize,
|
||||
wxEXPAND, aName ),
|
||||
mouseListener( aMouseListener ), paintListener( aPaintListener ), currentManager( nullptr ),
|
||||
cachedManager( nullptr ), nonCachedManager( nullptr ), overlayManager( nullptr )
|
||||
|
@ -96,10 +96,6 @@ OPENGL_GAL::OPENGL_GAL( GAL_DISPLAY_OPTIONS& aDisplayOptions, wxWindow* aParent,
|
|||
isGrouping = false;
|
||||
groupCounter = 0;
|
||||
|
||||
#ifdef RETINA_OPENGL_PATCH
|
||||
SetViewWantsBestResolution( true );
|
||||
#endif
|
||||
|
||||
// Connecting the event handlers
|
||||
Connect( wxEVT_PAINT, wxPaintEventHandler( OPENGL_GAL::onPaint ) );
|
||||
|
||||
|
@ -1155,13 +1151,8 @@ void OPENGL_GAL::ResizeScreen( int aWidth, int aHeight )
|
|||
{
|
||||
screenSize = VECTOR2I( aWidth, aHeight );
|
||||
|
||||
#ifdef RETINA_OPENGL_PATCH
|
||||
const float scaleFactor = GetBackingScaleFactor();
|
||||
#else
|
||||
const float scaleFactor = 1.0f;
|
||||
#endif
|
||||
|
||||
// Resize framebuffers
|
||||
const float scaleFactor = GetBackingScaleFactor();
|
||||
compositor->Resize( aWidth * scaleFactor, aHeight * scaleFactor );
|
||||
isFramebufferInitialized = false;
|
||||
|
||||
|
|
|
@ -40,6 +40,7 @@
|
|||
class HIDPI_GL_CANVAS : public wxGLCanvas
|
||||
{
|
||||
public:
|
||||
// wxGLCanvas constructor
|
||||
HIDPI_GL_CANVAS( wxWindow *parent,
|
||||
const wxGLAttributes& dispAttrs,
|
||||
wxWindowID id = wxID_ANY,
|
||||
|
@ -49,6 +50,7 @@ public:
|
|||
const wxString& name = wxGLCanvasName,
|
||||
const wxPalette& palette = wxNullPalette );
|
||||
|
||||
// wxGLCanvas constructor
|
||||
HIDPI_GL_CANVAS( wxWindow *parent,
|
||||
wxWindowID id = wxID_ANY,
|
||||
const int *attribList = NULL,
|
||||
|
@ -58,13 +60,19 @@ public:
|
|||
const wxString& name = wxGLCanvasName,
|
||||
const wxPalette& palette = wxNullPalette );
|
||||
|
||||
wxSize GetClientSize() const;
|
||||
|
||||
// wxGLCanvas override
|
||||
virtual wxSize GetClientSize() const;
|
||||
|
||||
// wxGLCanvas override (with patch applied) or default value of 1.0
|
||||
virtual float GetBackingScaleFactor() const;
|
||||
|
||||
|
||||
#ifdef RETINA_OPENGL_PATCH
|
||||
private:
|
||||
float scaleFactor;
|
||||
#endif
|
||||
/**
|
||||
* @brief Common initialization
|
||||
*/
|
||||
void initialize();
|
||||
};
|
||||
|
||||
#endif // HIDPI_GL_CANVAS_H
|
||||
|
|
|
@ -38,8 +38,7 @@
|
|||
#include <gal/opengl/cached_container.h>
|
||||
#include <gal/opengl/noncached_container.h>
|
||||
#include <gal/opengl/opengl_compositor.h>
|
||||
|
||||
#include <wx/glcanvas.h>
|
||||
#include <gal/hidpi_gl_canvas.h>
|
||||
|
||||
#include <unordered_map>
|
||||
#include <boost/smart_ptr/shared_array.hpp>
|
||||
|
@ -62,7 +61,7 @@ class SHADER;
|
|||
* and quads. The purpose is to provide a fast graphics interface, that takes advantage of modern
|
||||
* graphics card GPUs. All methods here benefit thus from the hardware acceleration.
|
||||
*/
|
||||
class OPENGL_GAL : public GAL, public wxGLCanvas
|
||||
class OPENGL_GAL : public GAL, public HIDPI_GL_CANVAS
|
||||
{
|
||||
public:
|
||||
/**
|
||||
|
|
Loading…
Reference in New Issue