-
Notifications
You must be signed in to change notification settings - Fork 1
/
glwindow.cpp
69 lines (54 loc) · 1.32 KB
/
glwindow.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
57
58
59
60
61
62
63
64
65
66
67
68
69
#include "glwindow.h"
#include <QDebug>
#include <QString>
GLWindow::GLWindow()
{
}
GLWindow::~GLWindow()
{
makeCurrent();
cleanupGL();
}
void GLWindow::initializeGL()
{
initializeOpenGLFunctions();
printContext();
glClearColor(0.0f,0.9f,1.0f,10.f);
shader.compile("../Renderer/shader.vert","../Renderer/shader.frag");
connect(this,SIGNAL(frameSwapped()),this,SLOT(update()));
}
void GLWindow::resizeGL(int width, int height)
{
glViewport( 0, 0, width, height );
float aspect = (float)width/(float)height;
scene.camera.setAspect(aspect);
}
void GLWindow::paintGL()
{
glClear(GL_COLOR_BUFFER_BIT);
scene.render(shader);
}
void GLWindow::cleanupGL()
{
}
// Private
void GLWindow::printContext()
{
QString glType;
QString glVersion;
QString glProfile;
// Get Version Information
glType = (context()->isOpenGLES()) ? "OpenGL ES" : "OpenGL";
glVersion = reinterpret_cast<const char*>(glGetString(GL_VERSION));
// Get Profile Information
#define CASE(c) case QSurfaceFormat::c: glProfile = #c; break
switch (format().profile())
{
CASE(NoProfile);
CASE(CoreProfile);
CASE(CompatibilityProfile);
}
#undef CASE
// qPrintable() will print our QString w/o quotes around it.
qDebug() << glType +" "+ glVersion + "(" + glProfile + ")";
}