1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39
|
#include <QtGui/QApplication>
#include <QtOpenGL/QGLWidget>
class OpenGL: public QGLWidget{
protected:
void initializeGL(){
glClearColor(0,1,1,0);
}
void resizeGL(int w, int h){
glViewport(0, 0, w, h);
glMatrixMode(GL_PROJECTION);
glLoadIdentity();
glOrtho(0,w,0,h,-1,1);
glMatrixMode(GL_MODELVIEW);
glLoadIdentity();
}
void paintGL(){
glClear(GL_COLOR_BUFFER_BIT);
glColor3f(1,0,0);
glBegin(GL_POLYGON);{
glVertex2f(0,0);
glVertex2f(100,500);
glVertex2f(500,100);
}glEnd();
}
};
int main(int argc, char **argv){
QApplication app(argc, argv);
OpenGL window;
//window.resize(800,600); //tilling windows manager
window.show();
return app.exec();
}
|