Commit 656aab6e by Kai Westerkamp

GLSL Version 2.1

parent 227f8ace
......@@ -2,7 +2,12 @@
MainWidget::MainWidget()
{
QSurfaceFormat format;
format.setDepthBufferSize(24);
format.setStencilBufferSize(8);
format.setVersion(2, 1);
format.setProfile(QSurfaceFormat::CoreProfile);
setFormat(format);
}
QSize MainWidget::minimumSizeHint() const
......@@ -34,43 +39,43 @@ void MainWidget::initializeGL(){
//temp
static const GLfloat g_vertex_buffer_data[] = {
-1.0f,-1.0f,-1.0f,
-1.0f,-1.0f, 1.0f,
-1.0f, 1.0f, 1.0f,
1.0f, 1.0f,-1.0f,
-1.0f,-1.0f,-1.0f,
-1.0f, 1.0f,-1.0f,
1.0f,-1.0f, 1.0f,
-1.0f,-1.0f,-1.0f,
1.0f,-1.0f,-1.0f,
1.0f, 1.0f,-1.0f,
1.0f,-1.0f,-1.0f,
-1.0f,-1.0f,-1.0f,
-1.0f,-1.0f,-1.0f,
-1.0f, 1.0f, 1.0f,
-1.0f, 1.0f,-1.0f,
1.0f,-1.0f, 1.0f,
-1.0f,-1.0f, 1.0f,
-1.0f,-1.0f,-1.0f,
-1.0f, 1.0f, 1.0f,
-1.0f,-1.0f, 1.0f,
1.0f,-1.0f, 1.0f,
1.0f, 1.0f, 1.0f,
1.0f,-1.0f,-1.0f,
1.0f, 1.0f,-1.0f,
1.0f,-1.0f,-1.0f,
1.0f, 1.0f, 1.0f,
1.0f,-1.0f, 1.0f,
1.0f, 1.0f, 1.0f,
1.0f, 1.0f,-1.0f,
-1.0f, 1.0f,-1.0f,
1.0f, 1.0f, 1.0f,
-1.0f, 1.0f,-1.0f,
-1.0f, 1.0f, 1.0f,
1.0f, 1.0f, 1.0f,
-1.0f, 1.0f, 1.0f,
1.0f,-1.0f, 1.0f
};
-1.0f,-1.0f,-1.0f,
-1.0f,-1.0f, 1.0f,
-1.0f, 1.0f, 1.0f,
1.0f, 1.0f,-1.0f,
-1.0f,-1.0f,-1.0f,
-1.0f, 1.0f,-1.0f,
1.0f,-1.0f, 1.0f,
-1.0f,-1.0f,-1.0f,
1.0f,-1.0f,-1.0f,
1.0f, 1.0f,-1.0f,
1.0f,-1.0f,-1.0f,
-1.0f,-1.0f,-1.0f,
-1.0f,-1.0f,-1.0f,
-1.0f, 1.0f, 1.0f,
-1.0f, 1.0f,-1.0f,
1.0f,-1.0f, 1.0f,
-1.0f,-1.0f, 1.0f,
-1.0f,-1.0f,-1.0f,
-1.0f, 1.0f, 1.0f,
-1.0f,-1.0f, 1.0f,
1.0f,-1.0f, 1.0f,
1.0f, 1.0f, 1.0f,
1.0f,-1.0f,-1.0f,
1.0f, 1.0f,-1.0f,
1.0f,-1.0f,-1.0f,
1.0f, 1.0f, 1.0f,
1.0f,-1.0f, 1.0f,
1.0f, 1.0f, 1.0f,
1.0f, 1.0f,-1.0f,
-1.0f, 1.0f,-1.0f,
1.0f, 1.0f, 1.0f,
-1.0f, 1.0f,-1.0f,
-1.0f, 1.0f, 1.0f,
1.0f, 1.0f, 1.0f,
-1.0f, 1.0f, 1.0f,
1.0f,-1.0f, 1.0f
};
......@@ -90,7 +95,7 @@ QOpenGLShaderProgram* MainWidget::initShader(QString fragSource, QString vertSou
QOpenGLShader *frag = new QOpenGLShader(QOpenGLShader::Fragment);
if(!frag->compileSourceFile(fragSource)){
qCritical()<< "Fragment Shader"<<fragSource<<"failed"<< frag->log();
exit(5);
exit(5);
}
QOpenGLShaderProgram* shader = new QOpenGLShaderProgram();
......@@ -98,7 +103,7 @@ QOpenGLShaderProgram* MainWidget::initShader(QString fragSource, QString vertSou
shader->addShader(frag);
if(!shader->link()){
qCritical()<< "Linking shader failed:"<<shader->log();
exit(5);
exit(5);
}
return shader;
......@@ -107,6 +112,7 @@ QOpenGLShaderProgram* MainWidget::initShader(QString fragSource, QString vertSou
void MainWidget::paintGL(){
glViewport(0,0,width(),height());
qDebug()<<"Format"<<this->format().version();
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT );
......
......@@ -4,10 +4,10 @@
#include <QObject>
#include <QtOpenGL>
#include <QOpenGLWidget>
#include <QOpenGLFunctions_3_3_Core>
#include <QOpenGLFunctions_2_1>
#include <QOpenGLShaderProgram>
class MainWidget : public QOpenGLWidget, public QOpenGLFunctions_3_3_Core
class MainWidget : public QOpenGLWidget, public QOpenGLFunctions_2_1
{
Q_OBJECT
public:
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment