Q_OBJECT
public:
protected:
void initializeGL ();
void resizeGL (int, int);
void paintGL ();
};
f.setDoubleBuffer (true);
setFormat (f);
}
void GLTest :: initializeGL () {
glClearColor (0.0, 0.0, 0.0, 0.0);
}
void GLTest :: resizeGL (int w, int h) {
glViewport (0, 0, (GLint)w, (GLint)h);
}
void GLTest :: paintGL () {
glClear (GL_COLOR_BUFFER_BIT);
glColor3f (1,0,0);
glBegin (GL_QUADS);
glVertex2f (0, 0);
glVertex2f (150, 0);
glVertex2f (150, 50);
glVertex2f (0, 50);
glEnd ();
swapBuffers ();
};
class GLTest : public QGLWidget {
Q_OBJECT
public:
GLTest (QWidget * = NULL);
protected:
void initializeGL ();
void resizeGL (int, int);
void paintGL ();
};
GLTest :: GLTest (QWidget * parent) : QGLWidget (parent) {
QGLFormat f = format();
f.setDoubleBuffer (true);
setFormat (f);
}
void GLTest :: initializeGL () {
glClearColor (0.0, 0.0, 0.0, 0.0);
}
void GLTest :: resizeGL (int w, int h) {
glViewport (0, 0, (GLint)w, (GLint)h);
}
void GLTest :: paintGL () {
glClear (GL_COLOR_BUFFER_BIT);
glColor3f (1,0,0);
glBegin (GL_QUADS);
glVertex2f (0, 0);
glVertex2f (150, 0);
glVertex2f (150, 50);
glVertex2f (0, 50);
glEnd ();
swapBuffers ();
};
To copy to clipboard, switch view to plain text mode
Bookmarks