I saw this question and it really shedded some light. Despite this, I can't seem to figure out how I'm "improperly" loading my shader, because this has executed before without any recent changes to the shader loading code, so I assume these errors must be coming from my draw calls.
Despite this, I'll still post the shader files for the sake of brevity, the draw function used to draw the circle I'm trying to render, and the code which loads in the shader file as a string.
Basically what I need to know is why I'm getting these errors and what in the hell is wrong with them?
(From debug output)
ERROR {
OpenGL Says:
Vertex info
-----------
0(1) : error C0000: syntax error, unexpected $undefined at token "<undefined>"
Fragment info
-------------
0(1) : error C0000: syntax error, unexpected $undefined at token "<undefined>"
};
Draw Code
void Circle::draw( GLuint program )
{
const size_t centerMag = mCenter.length();
glUseProgram( program );
for( float t = 0; t < mCircumference; t += 0.1 )
{
float x = centerMag + glm::cos( 2 * M_PI * t );
float y = centerMag + glm::sin( 2 * M_PI * t );
mVertices->push_back( glm::vec4( x, y, 0, 1 ) );
}
QListIterator< glm::vec4 > iVertices( *mVertices );
const size_t size = mVertices->size();
float** verts = new float*[ size ];
size_t i = 0;
glEnableClientState( GL_VERTEX_ARRAY );
while( iVertices.hasNext() )
{
verts[ i ] = new float[ size ];
verts[ i ] = const_cast< float* >( glm::value_ptr( iVertices.next() ) );
glVertexPointer( 4, GL_FLOAT, 0, verts[ i ] );
glDrawArrays( GL_LINES, 0, 4 );
++i;
}
glDisableClientState( GL_VERTEX_ARRAY );
for( unsigned iMem = 0; iMem < size; ++iMem )
{
delete[] verts[ iMem ];
verts[ iMem ] = NULL;
}
delete[] verts;
verts = NULL;
}
FileUtility
QString FileUtility::readShader( QString filepath )
{
std::ifstream in( filepath.toStdString().c_str() );
std::stringstream shaderDat;
shaderDat << in.rdbuf();
QString shaderFile;
shaderFile += shaderDat.str().c_str();
in.close();
return shaderFile;
}
GenericColor.frag
#version 330
out vec4 outputColor;
void main()
{
outputColor = vec4(1.0f, 0, 0, 1.0f);
}
Position.vert
#version 330
layout(location = 0) in vec4 position;
void main()
{
gl_Position = position;
}
Update
Since my shader binding/compilation code was requested, I figured I may as well just post my entire shader handler, as well as the engine class.
Update
Here are the shader strings parsed (Info
is a debug output):
Info {
Shader Source #version 330
in uniform mvp;
layout(location = 0) in vec4 position;
void main()
{
gl_ModelViewProjectionMatrix = mvp;
gl_Position = position;
}
};
Info {
Shader Source #version 330
out vec4 outputColor;
void main()
{
outputColor = vec4(1.0f, 0, 0, 1.0f);
}
};