#ifndef GLVIEWER_H
#define GLVIEWER_H
#include <QtOpenGL/qgl.h>
public:
~GLViewer();
protected:
int viewport[4];
void initializeGL();
void resizeGL (int width, int height);
void paintGL();
};
#endif // GLVIEWER_H
#ifndef GLVIEWER_H
#define GLVIEWER_H
#include <QtOpenGL/qgl.h>
class GLViewer : public QGLWidget {
public:
GLViewer(QWidget * parent = 0);
~GLViewer();
protected:
int viewport[4];
void initializeGL();
void resizeGL (int width, int height);
void paintGL();
};
#endif // GLVIEWER_H
To copy to clipboard, switch view to plain text mode
#include "GLViewer.h"
GLViewer
::GLViewer(QWidget * parent
){
}
GLViewer::~GLViewer() {
}
void GLViewer::initializeGL() {
}
void GLViewer::resizeGL(int width, int height) {
viewport[0] = 0;
viewport[1] = 0;
viewport[2] = width;
viewport[3] = height;
glViewport(0, 0, width, height);
}
void GLViewer::paintGL() {
glClearColor(1,1,1,1);
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
glMatrixMode(GL_PROJECTION);
glLoadIdentity();
glOrtho(-1.0, 1.0, -1.0, 1.0, 0, 1);
glMatrixMode(GL_MODELVIEW);
glLoadIdentity();
glColor3f(0.0f, 0.0f, 1.0f);
glBegin(GL_TRIANGLES);
glVertex3f(0,0,.5);
glVertex3f(0,1,.5);
glVertex3f(1,1,.5);
glEnd();
}
#include "GLViewer.h"
GLViewer::GLViewer(QWidget * parent)
: QGLWidget(parent)
{
}
GLViewer::~GLViewer() {
}
void GLViewer::initializeGL() {
}
void GLViewer::resizeGL(int width, int height) {
viewport[0] = 0;
viewport[1] = 0;
viewport[2] = width;
viewport[3] = height;
glViewport(0, 0, width, height);
}
void GLViewer::paintGL() {
glClearColor(1,1,1,1);
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
glMatrixMode(GL_PROJECTION);
glLoadIdentity();
glOrtho(-1.0, 1.0, -1.0, 1.0, 0, 1);
glMatrixMode(GL_MODELVIEW);
glLoadIdentity();
glColor3f(0.0f, 0.0f, 1.0f);
glBegin(GL_TRIANGLES);
glVertex3f(0,0,.5);
glVertex3f(0,1,.5);
glVertex3f(1,1,.5);
glEnd();
}
To copy to clipboard, switch view to plain text mode
Bookmarks