{
public:
LocalGLWidget
(QWidget * Parent
= NULL) :
{
setAutoFillBackground(false);
}
void initializeGL()
{
glViewport(0, 0, width(), height());
glClearColor(0.0f, 1.0f, 0.0f, 0.0f);
}
void paintGL()
{
glClear(GL_COLOR_BUFFER_BIT);
const int W = 512;
const int H = 256;
glBegin(GL_QUADS);
glColor3f(1.0f, 0.0f, 0.0f);glVertex2i(0, 0);
glColor3f(0.0f, 1.0f, 0.0f);glVertex2i(W, 0);
glColor3f(0.0f, 0.0f, 1.0f);glVertex2i(W, H);
glColor3f(1.0f, 1.0f, 1.0f);glVertex2i(0, H);
glEnd();
}
void resizeGL(int W, int H)
{
glViewport(0, 0, W, H);
glMatrixMode(GL_PROJECTION);
glLoadIdentity();
gluOrtho2D(0, W, 0, H);
glMatrixMode(GL_MODELVIEW);
glLoadIdentity();
}
};
class LocalGLSubWindow : public QMdiSubWindow
{
public:
LocalGLSubWindow
(QWidget * Parent
= NULL) :
QMdiSubWindow(Parent)
{
setAutoFillBackground(false);
mGL = new LocalGLWidget();
setWidget(mGL);
}
LocalGLWidget * mGL;
};
class LocalGLWidget : public QGLWidget
{
public:
LocalGLWidget(QWidget * Parent = NULL)
:
QGLWidget(QGLFormat(QGL::SampleBuffers | QGL::DirectRendering), Parent)
{
setAutoFillBackground(false);
}
void initializeGL()
{
glViewport(0, 0, width(), height());
glClearColor(0.0f, 1.0f, 0.0f, 0.0f);
}
void paintGL()
{
glClear(GL_COLOR_BUFFER_BIT);
const int W = 512;
const int H = 256;
glBegin(GL_QUADS);
glColor3f(1.0f, 0.0f, 0.0f);glVertex2i(0, 0);
glColor3f(0.0f, 1.0f, 0.0f);glVertex2i(W, 0);
glColor3f(0.0f, 0.0f, 1.0f);glVertex2i(W, H);
glColor3f(1.0f, 1.0f, 1.0f);glVertex2i(0, H);
glEnd();
}
void resizeGL(int W, int H)
{
glViewport(0, 0, W, H);
glMatrixMode(GL_PROJECTION);
glLoadIdentity();
gluOrtho2D(0, W, 0, H);
glMatrixMode(GL_MODELVIEW);
glLoadIdentity();
}
};
class LocalGLSubWindow : public QMdiSubWindow
{
public:
LocalGLSubWindow(QWidget * Parent = NULL)
:
QMdiSubWindow(Parent)
{
setAutoFillBackground(false);
mGL = new LocalGLWidget();
setWidget(mGL);
}
LocalGLWidget * mGL;
};
To copy to clipboard, switch view to plain text mode
Bookmarks