Commit 656aab6e by Kai Westerkamp

GLSL Version 2.1

parent 227f8ace
...@@ -2,7 +2,12 @@ ...@@ -2,7 +2,12 @@
MainWidget::MainWidget() MainWidget::MainWidget()
{ {
QSurfaceFormat format;
format.setDepthBufferSize(24);
format.setStencilBufferSize(8);
format.setVersion(2, 1);
format.setProfile(QSurfaceFormat::CoreProfile);
setFormat(format);
} }
QSize MainWidget::minimumSizeHint() const QSize MainWidget::minimumSizeHint() const
...@@ -34,43 +39,43 @@ void MainWidget::initializeGL(){ ...@@ -34,43 +39,43 @@ void MainWidget::initializeGL(){
//temp //temp
static const GLfloat g_vertex_buffer_data[] = { 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 ...@@ -90,7 +95,7 @@ QOpenGLShaderProgram* MainWidget::initShader(QString fragSource, QString vertSou
QOpenGLShader *frag = new QOpenGLShader(QOpenGLShader::Fragment); QOpenGLShader *frag = new QOpenGLShader(QOpenGLShader::Fragment);
if(!frag->compileSourceFile(fragSource)){ if(!frag->compileSourceFile(fragSource)){
qCritical()<< "Fragment Shader"<<fragSource<<"failed"<< frag->log(); qCritical()<< "Fragment Shader"<<fragSource<<"failed"<< frag->log();
exit(5); exit(5);
} }
QOpenGLShaderProgram* shader = new QOpenGLShaderProgram(); QOpenGLShaderProgram* shader = new QOpenGLShaderProgram();
...@@ -98,7 +103,7 @@ QOpenGLShaderProgram* MainWidget::initShader(QString fragSource, QString vertSou ...@@ -98,7 +103,7 @@ QOpenGLShaderProgram* MainWidget::initShader(QString fragSource, QString vertSou
shader->addShader(frag); shader->addShader(frag);
if(!shader->link()){ if(!shader->link()){
qCritical()<< "Linking shader failed:"<<shader->log(); qCritical()<< "Linking shader failed:"<<shader->log();
exit(5); exit(5);
} }
return shader; return shader;
...@@ -107,6 +112,7 @@ QOpenGLShaderProgram* MainWidget::initShader(QString fragSource, QString vertSou ...@@ -107,6 +112,7 @@ QOpenGLShaderProgram* MainWidget::initShader(QString fragSource, QString vertSou
void MainWidget::paintGL(){ void MainWidget::paintGL(){
glViewport(0,0,width(),height()); glViewport(0,0,width(),height());
qDebug()<<"Format"<<this->format().version();
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT ); glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT );
......
...@@ -4,10 +4,10 @@ ...@@ -4,10 +4,10 @@
#include <QObject> #include <QObject>
#include <QtOpenGL> #include <QtOpenGL>
#include <QOpenGLWidget> #include <QOpenGLWidget>
#include <QOpenGLFunctions_3_3_Core> #include <QOpenGLFunctions_2_1>
#include <QOpenGLShaderProgram> #include <QOpenGLShaderProgram>
class MainWidget : public QOpenGLWidget, public QOpenGLFunctions_3_3_Core class MainWidget : public QOpenGLWidget, public QOpenGLFunctions_2_1
{ {
Q_OBJECT Q_OBJECT
public: 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