From 86f2d59536e17257bc85ad60c08ede18ab7d701c Mon Sep 17 00:00:00 2001 From: Carl Hetherington Date: Mon, 31 Dec 2018 20:19:33 +0000 Subject: Tweaks. --- hacks/gl.cc | 25 ++++++++++++++++--------- 1 file changed, 16 insertions(+), 9 deletions(-) diff --git a/hacks/gl.cc b/hacks/gl.cc index 5487d35bf..8c2029cd0 100644 --- a/hacks/gl.cc +++ b/hacks/gl.cc @@ -13,6 +13,7 @@ public: private: void paint (wxPaintEvent& event); + void sized (); wxGLContext* _context; }; @@ -22,6 +23,7 @@ GLView::GLView(wxFrame *parent) { _context = new wxGLContext (this); Bind (wxEVT_PAINT, boost::bind(&GLView::paint, this, _1)); + Bind (wxEVT_SIZE, boost::bind(&GLView::sized, this)); } GLView::~GLView () @@ -46,7 +48,20 @@ check_gl_error (char const * last) } } -void GLView::paint (wxPaintEvent &) +void +GLView::sized () +{ + glViewport (0, 0, GetSize().x, GetSize().y); + glMatrixMode(GL_PROJECTION); + glLoadIdentity(); + + glOrtho (0, GetSize().x, GetSize().y, 0, -1, 1); + glMatrixMode(GL_MODELVIEW); + glLoadIdentity(); +} + +void +GLView::paint (wxPaintEvent &) { SetCurrent (*_context); wxPaintDC (this); @@ -57,14 +72,6 @@ void GLView::paint (wxPaintEvent &) glDisable(GL_DEPTH_TEST); glBlendFunc (GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); - glViewport (0, 0, GetSize().x, GetSize().y); - glMatrixMode(GL_PROJECTION); - glLoadIdentity(); - - glOrtho (0, GetSize().x, GetSize().y, 0, -1, 1); - glMatrixMode(GL_MODELVIEW); - glLoadIdentity(); - int const width = 1998; int const height = 1080; unsigned char image[width * height * 3]; -- cgit v1.2.3