-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathglwidget.cpp
More file actions
40 lines (33 loc) · 900 Bytes
/
glwidget.cpp
File metadata and controls
40 lines (33 loc) · 900 Bytes
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
#include "glwidget.h"
#include <GLUT/glut.h>
#include <vector>
#include <iostream>
using namespace std;
GLWidget::GLWidget(QWidget *parent)
{
connect(&timer, SIGNAL(timeout()), this, SLOT(updateGL()));
timer.start(16);
}
void GLWidget::initializeGL() {
glClearColor(1, 0.2, 0.2, 1);
}
void GLWidget::paintGL() {
glClear(GL_COLOR_BUFFER_BIT);
// 4 bytes per pixel (RGBA), 1x1 bitmap
vector< unsigned char > pixels( 1 * 1 * 4 );
glReadPixels
(
10, glutGet( GLUT_WINDOW_HEIGHT ) - 10,
1, 1,
GL_RGBA, GL_UNSIGNED_BYTE, &pixels[0]
);
cout << "r: " << (int)pixels[0] << endl;
cout << "g: " << (int)pixels[1] << endl;
cout << "b: " << (int)pixels[2] << endl;
cout << "a: " << (int)pixels[3] << endl;
cout << endl;
glRotatef(0.5, 1, 1, 1);
glutWireTeapot(0.6);
}
void GLWidget::resizeGL(int w, int h) {
}