mirror of
https://bitbucket.org/mfeemster/fractorium.git
synced 2025-01-21 21:20:07 -05:00
--Code changes
-Attempt to get GLSL working on Linux. Does not work.
This commit is contained in:
parent
ae7b1f3ba8
commit
d6131b67e5
@ -70,7 +70,8 @@
|
||||
#include <QMimeData>
|
||||
#include <QModelIndex>
|
||||
#include <QMouseEvent>
|
||||
#include <QOpenGLFunctions_3_2_Core.h>
|
||||
//#include <qopenglfunctions_4_5_core.h>
|
||||
#include <qopenglfunctions_3_3_core.h>
|
||||
//#include <qopenglfunctions_2_0.h>
|
||||
#include <QOpenGLWidget>
|
||||
#include <QPainter>
|
||||
|
@ -4,32 +4,38 @@
|
||||
|
||||
#ifdef USE_GLSL
|
||||
static const char* vertexShaderSource =
|
||||
"attribute vec4 posattr;\n"
|
||||
"#version 130\n"
|
||||
"in vec4 posattr;\n"
|
||||
"uniform mat4 matrix;\n"
|
||||
"void main() {\n"
|
||||
" gl_Position = matrix * posattr;\n"
|
||||
"}\n";
|
||||
|
||||
static const char* fragmentShaderSource =
|
||||
"#version 130\n"
|
||||
"uniform vec4 mycolor;\n"
|
||||
"out vec4 fragout;"
|
||||
"void main() {\n"
|
||||
" gl_FragColor = mycolor;\n"
|
||||
" fragout = mycolor;\n"
|
||||
"}\n";
|
||||
|
||||
static const char* quadVertexShaderSource =
|
||||
"attribute vec4 posattr;\n"
|
||||
"#version 130\n"
|
||||
"in vec4 posattr;\n"
|
||||
"uniform mat4 matrix;\n"
|
||||
"varying vec4 texcoord;\n"
|
||||
"out vec4 texcoord;\n"
|
||||
"void main() {\n"
|
||||
" gl_Position = matrix * posattr;\n"
|
||||
" texcoord = posattr;\n"
|
||||
"}\n";
|
||||
|
||||
static const char* quadFragmentShaderSource =
|
||||
"#version 130\n"
|
||||
"uniform sampler2D quadtex;\n"
|
||||
"varying vec4 texcoord;\n"
|
||||
"in vec4 texcoord;\n"
|
||||
"out vec4 fragout;"
|
||||
"void main() {\n"
|
||||
" gl_FragColor = texture2D(quadtex, texcoord.st);\n"
|
||||
" fragout = texture(quadtex, texcoord.st);\n"
|
||||
"}\n";
|
||||
#endif
|
||||
|
||||
@ -41,13 +47,28 @@
|
||||
GLWidget::GLWidget(QWidget* p)
|
||||
: QOpenGLWidget(p)
|
||||
{
|
||||
#ifndef USE_GLSL
|
||||
QSurfaceFormat qsf;
|
||||
qsf.setSwapInterval(1);//Vsync.
|
||||
qsf.setSwapBehavior(QSurfaceFormat::DoubleBuffer);
|
||||
qsf.setVersion(2, 0);
|
||||
setFormat(qsf);
|
||||
#endif
|
||||
/*
|
||||
auto qsf = this->format();
|
||||
qDebug() << "Version: " << qsf.majorVersion() << ',' << qsf.minorVersion();
|
||||
qDebug() << "Profile: " << qsf.profile();
|
||||
qDebug() << "Depth buffer size: " << qsf.depthBufferSize();
|
||||
qDebug() << "Swap behavior: " << qsf.swapBehavior();
|
||||
qDebug() << "Swap interval: " << qsf.swapInterval();
|
||||
//QSurfaceFormat qsf;
|
||||
//QSurfaceFormat::FormatOptions fo;
|
||||
//fo.
|
||||
//qsf.setDepthBufferSize(24);
|
||||
//qsf.setSwapInterval(1);//Vsync.
|
||||
//qsf.setSwapBehavior(QSurfaceFormat::DoubleBuffer);
|
||||
#ifndef USE_GLSL
|
||||
qsf.setVersion(2, 0);
|
||||
qsf.setProfile(QSurfaceFormat::CompatibilityProfile);
|
||||
#else
|
||||
qsf.setVersion(3, 3);
|
||||
//qsf.setProfile(QSurfaceFormat::CoreProfile);
|
||||
#endif
|
||||
setFormat(qsf);
|
||||
*/
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@ -281,7 +302,7 @@ void GLWidget::initializeGL()
|
||||
|
||||
if (!m_Init && m_Fractorium)
|
||||
{
|
||||
initializeOpenGLFunctions();
|
||||
this->initializeOpenGLFunctions();
|
||||
|
||||
if (!m_Program)
|
||||
{
|
||||
@ -289,19 +310,19 @@ void GLWidget::initializeGL()
|
||||
|
||||
if (!m_Program->addShaderFromSourceCode(QOpenGLShader::Vertex, vertexShaderSource))
|
||||
{
|
||||
QMessageBox::critical(m_Fractorium, "Shader Error", "Error compiling affine vertex source.");
|
||||
QMessageBox::critical(m_Fractorium, "Shader Error", "Error compiling affine vertex source: " + m_Program->log());
|
||||
QApplication::exit(1);
|
||||
}
|
||||
|
||||
if (!m_Program->addShaderFromSourceCode(QOpenGLShader::Fragment, fragmentShaderSource))
|
||||
{
|
||||
QMessageBox::critical(m_Fractorium, "Shader Error", "Error compiling affine fragment source.");
|
||||
QMessageBox::critical(m_Fractorium, "Shader Error", "Error compiling affine fragment source: " + m_Program->log());
|
||||
QApplication::exit(1);
|
||||
}
|
||||
|
||||
if (!m_Program->link())
|
||||
{
|
||||
QMessageBox::critical(m_Fractorium, "Shader Error", "Error linking affine source.");
|
||||
QMessageBox::critical(m_Fractorium, "Shader Error", "Error linking affine source: " + m_Program->log());
|
||||
QApplication::exit(1);
|
||||
}
|
||||
|
||||
@ -316,19 +337,19 @@ void GLWidget::initializeGL()
|
||||
|
||||
if (!m_QuadProgram->addShaderFromSourceCode(QOpenGLShader::Vertex, quadVertexShaderSource))
|
||||
{
|
||||
QMessageBox::critical(m_Fractorium, "Shader Error", "Error compiling image texture vertex source.");
|
||||
QMessageBox::critical(m_Fractorium, "Shader Error", "Error compiling image texture vertex source: " + m_QuadProgram->log());
|
||||
QApplication::exit(1);
|
||||
}
|
||||
|
||||
if (!m_QuadProgram->addShaderFromSourceCode(QOpenGLShader::Fragment, quadFragmentShaderSource))
|
||||
{
|
||||
QMessageBox::critical(m_Fractorium, "Shader Error", "Error compiling image texture fragment source.");
|
||||
QMessageBox::critical(m_Fractorium, "Shader Error", "Error compiling image texture fragment source: " + m_QuadProgram->log());
|
||||
QApplication::exit(1);
|
||||
}
|
||||
|
||||
if (!m_QuadProgram->link())
|
||||
{
|
||||
QMessageBox::critical(m_Fractorium, "Shader Error", "Error linking image texture source.");
|
||||
QMessageBox::critical(m_Fractorium, "Shader Error", "Error linking image texture source: " + m_QuadProgram->log());
|
||||
QApplication::exit(1);
|
||||
}
|
||||
|
||||
|
@ -28,7 +28,8 @@ template<typename T> class FractoriumEmberController;
|
||||
/// </summary>
|
||||
class GLWidget : public QOpenGLWidget, protected
|
||||
#ifdef USE_GLSL
|
||||
QOpenGLFunctions_3_2_Core
|
||||
//QOpenGLFunctions_4_5_Core
|
||||
QOpenGLFunctions_3_3_Core
|
||||
#else
|
||||
QOpenGLFunctions_2_0
|
||||
#endif
|
||||
@ -99,7 +100,7 @@ private:
|
||||
QMatrix4x4 m_ModelViewProjectionMatrix;
|
||||
QMatrix4x4 m_TextureProjMatrix;
|
||||
vector<float> m_Verts;
|
||||
std::array<GLfloat, 10> m_TexVerts =
|
||||
std::array<GLfloat, 10> m_TexVerts = std::array<GLfloat, 10>
|
||||
{
|
||||
0, 0,
|
||||
0, 1,
|
||||
|
@ -41,6 +41,24 @@ int main(int argc, char* argv[])
|
||||
#else
|
||||
putenv(const_cast<char*>("GPU_MAX_ALLOC_PERCENT=100"));
|
||||
#endif
|
||||
//auto qsf = QSurfaceFormat::defaultFormat();
|
||||
//qDebug() << "Version: " << qsf.majorVersion() << ',' << qsf.minorVersion();
|
||||
//qDebug() << "Profile: " << qsf.profile();
|
||||
//qDebug() << "Depth buffer size: " << qsf.depthBufferSize();
|
||||
//qDebug() << "Swap behavior: " << qsf.swapBehavior();
|
||||
//qDebug() << "Swap interval: " << qsf.swapInterval();
|
||||
//qsf.setDepthBufferSize(24);
|
||||
//qsf.setSwapInterval(1);//Vsync.
|
||||
//qsf.setSwapBehavior(QSurfaceFormat::DoubleBuffer);
|
||||
#ifndef USE_GLSL
|
||||
qsf.setVersion(2, 0);
|
||||
qsf.setProfile(QSurfaceFormat::CompatibilityProfile);
|
||||
#else
|
||||
//qsf.setVersion(4, 5);
|
||||
//qsf.setRenderableType(QSurfaceFormat::OpenGL);
|
||||
//qsf.setProfile(QSurfaceFormat::CoreProfile);
|
||||
#endif
|
||||
//QSurfaceFormat::setDefaultFormat(qsf);
|
||||
Fractorium w;
|
||||
w.show();
|
||||
a.installEventFilter(&w);
|
||||
|
Loading…
Reference in New Issue
Block a user