11 #include <QOpenGLFunctions> 23 QOpenGLFunctions* pFunc =
24 QOpenGLContext::currentContext()->functions();
25 pFunc->glClearColor(1.0f, 1.0f, 1.0f, 1.0f);
31 glMatrixMode(GL_PROJECTION);
33 glViewport(0, 0, (GLint)nWidth, (GLint)nHeight);
34 glOrtho(0, 400, 200, 0, -1, 1);
40 glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
42 draw(0, 0, GL_POINTS);
43 draw(100, 0, GL_LINES);
44 draw(200, 0, GL_LINE_STRIP);
45 draw(300, 0, GL_LINE_LOOP);
47 draw(0, 100, GL_TRIANGLE_STRIP);
48 draw(100, 100, GL_POLYGON);
49 draw(200, 100, GL_QUADS);
50 draw(300, 100, GL_TRIANGLES);
61 for (
int i = 0; i < n; ++i) {
62 float fAngle = 2 * 3.14 * i / n;
63 int x = (int)(50 + cos(fAngle) * 40 + xOffset);
64 int y = (int)(50 + sin(fAngle) * 40 + yOffset);
void draw(int xOffset, int yOffset, GLenum type)
virtual void initializeGL()
virtual void resizeGL(int nWidth, int nHeight)