#ifndef MYQGLWIDGET_H
#define MYQGLWIDGET_H
#include <QGLWidget>
#include <QMouseEvent>
#include <QDebug>
#include <QPaintEvent>
#include <QSize>
{
Q_OBJECT
public:
explicit MyQGLWidget
(QWidget *parent
= NULL);
}
QSize minimumSizeHint
() { }
return QSize(999999,
999999);
}
int minimumWidth() {
return 800;
}
int minimumHeight() {
return 600;
}
int maximumWidth() {
return 999999;
}
int maximumHeight() {
return 999999;
}
protected:
int count;
void initializeGL() {
glClearColor(0, 1, 0, 1);
glPushMatrix();
glOrtho(0, size().width(), size().height(), 0, -1, 1);
glViewport(0, 0, (GLint)size().width(), (GLint)size().height());
glDisable(GL_DEPTH_TEST);
glShadeModel(GL_FLAT);
}
void resizeGL(int w, int h)
{
glPopMatrix();
glPushMatrix();
glOrtho(0, w, h, 0, -1, 1);
glViewport(0, 0, w, h);
}
void paintGL() {
qDebug() << "paintGL() " << count;
count++;
// Draw some squares
int r = ((int) (rand())) % 255;
for (int i = 0; i < 10; i++) {
for (int j = 0; j < 10; j++) {
glColor3f((((i * 51 + 3 + r) * (j * 127 + 17 + r)) % 173) / 173.0f,
(((i * 73 + 19 + r) * (j * 1337 + 5 + r)) % 143) / 143.0f,
(((i * 97 + 13 + r) * (j * 27 + 77 + r)) % 931) / 931.0f);
glBegin(GL_QUADS);
glVertex2i(10 + (20 * i), 10 + (20 * j));
glVertex2i(20 + (20 * i), 10 + (20 * j));
glVertex2i(20 + (20 * i), 20 + (20 * j));
glVertex2i(10 + (20 * i), 20 + (20 * j));
glEnd();
}
}
}
signals:
public slots:
};
#endif // MYQGLWIDGET_H
#ifndef MYQGLWIDGET_H
#define MYQGLWIDGET_H
#include <QGLWidget>
#include <QMouseEvent>
#include <QDebug>
#include <QPaintEvent>
#include <QSize>
class MyQGLWidget : public QGLWidget
{
Q_OBJECT
public:
explicit MyQGLWidget(QWidget *parent = NULL);
QSizePolicy sizeHint() {
return QSizePolicy(QSizePolicy::Ignored, QSizePolicy::Ignored);
}
QSize minimumSizeHint() {
return QSize(800, 600);
}
QSize maximumSize() {
return QSize(999999, 999999);
}
int minimumWidth() {
return 800;
}
int minimumHeight() {
return 600;
}
int maximumWidth() {
return 999999;
}
int maximumHeight() {
return 999999;
}
protected:
int count;
void initializeGL() {
glClearColor(0, 1, 0, 1);
glPushMatrix();
glOrtho(0, size().width(), size().height(), 0, -1, 1);
glViewport(0, 0, (GLint)size().width(), (GLint)size().height());
glDisable(GL_DEPTH_TEST);
glShadeModel(GL_FLAT);
}
void resizeGL(int w, int h)
{
glPopMatrix();
glPushMatrix();
glOrtho(0, w, h, 0, -1, 1);
glViewport(0, 0, w, h);
}
void paintGL() {
qDebug() << "paintGL() " << count;
count++;
// Draw some squares
int r = ((int) (rand())) % 255;
for (int i = 0; i < 10; i++) {
for (int j = 0; j < 10; j++) {
glColor3f((((i * 51 + 3 + r) * (j * 127 + 17 + r)) % 173) / 173.0f,
(((i * 73 + 19 + r) * (j * 1337 + 5 + r)) % 143) / 143.0f,
(((i * 97 + 13 + r) * (j * 27 + 77 + r)) % 931) / 931.0f);
glBegin(GL_QUADS);
glVertex2i(10 + (20 * i), 10 + (20 * j));
glVertex2i(20 + (20 * i), 10 + (20 * j));
glVertex2i(20 + (20 * i), 20 + (20 * j));
glVertex2i(10 + (20 * i), 20 + (20 * j));
glEnd();
}
}
}
signals:
public slots:
};
#endif // MYQGLWIDGET_H
To copy to clipboard, switch view to plain text mode
Bookmarks