-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathglwidget.cpp
57 lines (50 loc) · 1.29 KB
/
glwidget.cpp
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
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
#include "glwidget.h"
#include <GL/glut.h>
#include <GL/glu.h>
GLWidget::GLWidget(QWidget *parent) :
QGLWidget(parent)
{
connect(&timer, SIGNAL(timeout()),this, SLOT(updateGL()));
timer.start(25);
}
void GLWidget::initializeGL()
{
glClearColor(.2,.2,.2, 1);
glEnable(GL_DEPTH_TEST);
glEnable(GL_LIGHT0);
glEnable(GL_LIGHTING);
glEnable(GL_COLOR_MATERIAL);
}
void GLWidget::paintGL()
{
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
// glBegin(GL_TRIANGLES);
// glColor3f(.5,.5,.5);
// glVertex3f(-0.5, -0.5, 0);
// glVertex3f( 0.5, -0.5, 0);
// glVertex3f( 0 , 0.5, 0);
// glEnd();
// glBegin(GL_QUADS);
// glColor3f(1,0,0);
// glVertex3f(-0.5, -0.5, 0);
// glColor3f(0,1,0);
// glVertex3f( 0.5, -0.5, 0);
// glColor3f(0,0,1);
// glVertex3f( 0.5 , 0.5, .1);
// glColor3f(1,1,0);
// glVertex3f( -0.5 , 0.5, .1);
// glEnd();
glRotatef(.5,.25, .125, 1);
glColor3f(0.5,0.0,0.5);
// glutSolidTeapot(.6);
}
void GLWidget::resizeGL(int w, int h)
{
glViewport(0,0,w,h);
glMatrixMode(GL_PROJECTION);
glLoadIdentity();
gluPerspective(45, (float)w/h, 0.01,100.0);
glMatrixMode(GL_MODELVIEW);
glLoadIdentity();
gluLookAt(0,0,5, 0,0,0, 0,1,0);
}