Would you upload your shader programs in a different way. Add vertext.sh and fragment.sh to your src. Then try linking them this way as below:
//#version 130
precision mediump float;
uniform mat4 mvpMatrix;
attribute vec4 vertex;
attribute float color;
varying float varyingColor;
void main(void)
{
varyingColor = color;
gl_Position = mvpMatrix * vertex;
}
//#version 130
precision mediump float;
uniform mat4 mvpMatrix;
attribute vec4 vertex;
attribute float color;
varying float varyingColor;
void main(void)
{
varyingColor = color;
gl_Position = mvpMatrix * vertex;
}
To copy to clipboard, switch view to plain text mode
fragment shader has the same format, you know it. Then do this in the code:
initCommon();
shaderProgram.addShaderFromSourceFile(QGLShader::Vertex, ":/vertexShader.vsh");
shaderProgram.addShaderFromSourceFile(QGLShader::Fragment, ":/fragmentShader.fsh");
if(!shaderProgram.link())
{
exit(1);
}
initCommon();
shaderProgram.addShaderFromSourceFile(QGLShader::Vertex, ":/vertexShader.vsh");
shaderProgram.addShaderFromSourceFile(QGLShader::Fragment, ":/fragmentShader.fsh");
if(!shaderProgram.link())
{
exit(1);
}
To copy to clipboard, switch view to plain text mode
initCommon() is:
void GlWidget::initCommon()
{
//qglClearColor(QColor(Qt::black));
glEnable(GL_DEPTH_TEST);
glEnable(GL_CULL_FACE);
glEnable(GL_BLEND);
glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
}
void GlWidget::initCommon()
{
//qglClearColor(QColor(Qt::black));
glEnable(GL_DEPTH_TEST);
glEnable(GL_CULL_FACE);
glEnable(GL_BLEND);
glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
}
To copy to clipboard, switch view to plain text mode
check this method and let us know about the result.
PS: don't forget to upload your shaders to your resources.
Bookmarks