#include <QtGui> #include <QtOpenGL> #include <math.h> #include "glwidget.h" void GLWidget::paintGL() { glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); glLoadIdentity(); glTranslated(0.0, 0.0, -10.0); glBegin(GL_POLYGON); glColor3d(100,0,0); glVertex2d(1,1); glVertex2d(1,-1); glVertex2d(-1,-1); glVertex2d(-1,1); glEnd(); glFlush(); } void GLWidget::resizeGL(int width, int height) { int side = qMin(width, height); glViewport((width - side) , (height - side), side, side); glClearColor(0,234,0,255); glMatrixMode(GL_PROJECTION); glLoadIdentity(); glOrtho(-3.0, +3.0, +3.0, -3.0, 0.0, 30.0); glMatrixMode(GL_MODELVIEW); }
|