Commit 955695d0 authored by wiebel's avatar wiebel
Browse files

extended functionality of gl widget and painter.

resizing of the window is now correctly reflected in the graphicsDisplay
parent 501639f6
......@@ -4,11 +4,12 @@
//
//---------------------------------------------------------------------------
#include "BGLScenePainter.h"
#include <cassert>
#include <GL/gl.h>
#include <GL/glu.h>
#include "BGLScenePainter.h"
BGLScenePainter::BGLScenePainter()
{
// TODO(wiebel): Auto-generated constructor stub
......@@ -21,6 +22,11 @@ BGLScenePainter::~BGLScenePainter()
void BGLScenePainter::initGL()
{
GLenum error = glGetError();
assert( error == GL_NO_ERROR );
// Set clear color
glClearColor( 0, 0, 0, 0 );
}
void BGLScenePainter::paintGL()
......@@ -44,6 +50,7 @@ void BGLScenePainter::paintGL()
glEnd();
}
void BGLScenePainter::resizeGL( int w, int h )
void BGLScenePainter::resizeGL( int width, int height )
{
glViewport( 0, 0, width, height );
}
......@@ -31,7 +31,7 @@ class BGLScenePainter
* Called, when the window is resized and re-initialization of the
* window parameters and matrices may need to be done.
*/
virtual void resizeGL( int w, int h );
virtual void resizeGL( int width, int height );
};
......
......@@ -41,3 +41,12 @@ QSize BQtGLWidget::sizeHint() const
return m_recommendedSize;
}
void BQtGLWidget::resizeGL( int width, int height )
{
m_scenePainter->resizeGL( width, height );
}
void BQtGLWidget:: initializeGL()
{
m_scenePainter->initGL();
}
......@@ -28,6 +28,21 @@ class BQtGLWidget: public QGLWidget
* parent widgets to give it a proper initial layout
*/
QSize sizeHint() const;
/**
* This virtual function is called whenever the widget has been
* resized. The new size is passed in width and height.
*/
void resizeGL( int width, int height );
protected:
/**
* This function is called once before the first
* call to paintGL() or resizeGL(), and then once whenever
* the widget has been assigned a new QGLContext.
*/
void initializeGL();
private:
/**
* This function is called whenever the widget needs to be painted.
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment