11#define GL_MULTISAMPLE 0x809D
14QHyodaGL::QHyodaGL(QWidget *parent):QOpenGLWidget(parent){
15 qDebug()<<
"\33[31m[QHyodaGL::QHyodaGL] NEW\33[m";
22void QHyodaGL::initializeGL(
void){
23 qDebug()<<
"\33[31m[QHyodaGL::initializeGL]\33[m";
26 glShadeModel(GL_SMOOTH);
27 glEnable(GL_MULTISAMPLE);
28 glEnable(GL_POINT_SMOOTH);
30 glEnable(GL_DEPTH_TEST);
31 glDepthFunc(GL_LEQUAL);
33 glLineStipple(1, 0x0101);
34 glEnable(GL_LINE_STIPPLE);
37void QHyodaGL::paintGL(){
39 glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
42 glTranslatef(0.0f, 0.0f, -16.0f);
43 glRotatef(pov.x(), 1.0f, 0.0f, 0.0f);
44 glRotatef(pov.y(), 0.0f, 1.0f, 0.0f);
45 glRotatef(pov.z(), 0.0f, 0.0f, 1.0f);
46 glScalef(pov.w(), pov.w(), pov.w());
51void QHyodaGL::resizeGL(
int w,
int h){
53 const int side = qMin(w, h);
54 glViewport((w-side)/2,(h-side)/2,side,side);
55 glMatrixMode(GL_PROJECTION);
57 glOrtho(-2.0f,+2.0f,-2.0f,+2.0f,1.0f,32.0f);
58 glMatrixMode(GL_MODELVIEW);
61void QHyodaGL::mousePressEvent(QMouseEvent *event){
63 mouse = QVector2D(event->localPos());
66void QHyodaGL::mouseMoveEvent(QMouseEvent *event){
68 QVector2D diff = QVector2D(event->localPos())-mouse;
69 if (event->buttons() & Qt::LeftButton) {
70 pov.setX(pov.x()+diff.y()/4.0f);
71 pov.setY(pov.y()+diff.x()/4.0f);
72 }
else if (event->buttons() & Qt::RightButton) {
73 pov.setX(pov.x()+diff.y()/4.0f);
74 pov.setZ(pov.z()+diff.x()/4.0f);
76 mouse = QVector2D(event->localPos());
79void QHyodaGL::wheelEvent(QWheelEvent *e){
82 pov.setW(pov.w()+pov.w()*0.1f):
83 pov.setW(pov.w()-pov.w()*0.1f);