Use Qt's resource system to store the shader source

The shader source is included inside each comipled binary file. The
OpenGL example also provides its own shader files which overrides
the default. Common shader code is in the 'common' directory and
each example's custom shader is alongside the example's C++ code.
This commit is contained in:
Matt Williams
2014-05-28 10:29:05 +01:00
parent 35049b7a53
commit c26686476d
10 changed files with 104 additions and 87 deletions

View File

@ -92,7 +92,7 @@ void OpenGLWidget::initializeGL()
// This is basically a simple fallback vertex shader which does the most basic rendering possible.
// PolyVox examples are able to provide their own shaders to demonstrate certain effects if desired.
if (!mShader->addShaderFromSourceFile(QGLShader::Vertex, QCoreApplication::applicationDirPath()+"/"+"example.vert"))
if (!mShader->addShaderFromSourceFile(QGLShader::Vertex, ":/example.vert"))
{
std::cerr << mShader->log().toStdString() << std::endl;
exit(EXIT_FAILURE);
@ -100,7 +100,7 @@ void OpenGLWidget::initializeGL()
// This is basically a simple fallback fragment shader which does the most basic rendering possible.
// PolyVox examples are able to provide their own shaders to demonstrate certain effects if desired.
if (!mShader->addShaderFromSourceFile(QGLShader::Fragment, QCoreApplication::applicationDirPath()+"/"+"example.frag"))
if (!mShader->addShaderFromSourceFile(QGLShader::Fragment, ":/example.frag"))
{
std::cerr << mShader->log().toStdString() << std::endl;
exit(EXIT_FAILURE);