Original Post
OK well I am testing out my new class and I can't seem to get my test shaders to compile.
Errors:
Vertex Shader:
Fragment Shader:
Function that loads shaders:
Thanks ahead,
Brent
Errors:
ERROR: 0:1: error(#76) Syntax error unexpected tokens following #version
ERROR: 0:1: error(#106) Version number not supported by GL2
ERROR: 0:1: error(#76) Syntax error unexpected tokens following #version
ERROR: error(#273) 3 compilation errors. No code generated
Fragment shader failed to compile with the following errors:
ERROR: 0:1: error(#76) Syntax error unexpected tokens following #version
ERROR: 0:1: error(#106) Version number not supported by GL2
ERROR: 0:1: error(#76) Syntax error unexpected tokens following #version
ERROR: error(#273) 3 compilation errors. No code generated
Vertex Shader:
#version 330
layout(location=0) in vec4 in_Position;
layout(location=1) in vec4 in_Color;
out vec4 ex_Color;
void main(void)
{
gl_Position = in_Position;
ex_Color = in_Color;
}Fragment Shader:
#version 330
in vec4 ex_Color;
out vec4 out_Color;
void main(void)
{
out_Color = ex_Color;
}Function that loads shaders:
void ttt::Shader::LoadFromFile(string vshader, string fshader)
{
ifstream vFile;
ifstream fFile;
vFile.open(vshader.c_str());
if(!vFile)
{
cout << "Error loading file" << endl;
return;
}
string vSource,fSource;
string temp;
while(!vFile.eof())
{
temp = "";
vFile >> temp;
vSource += temp;
}
vFile.close();
fFile.open(fshader.c_str());
if(!fFile)
{
cout << "Error loading file" << endl;
return;
}
while(!fFile.eof())
{
temp = "";
fFile >> temp;
fSource += temp;
}
fFile.close();
const char * vText = vSource.c_str();
const char * fText = fSource.c_str();
m_vshader = glCreateShader(GL_VERTEX_SHADER);
m_fshader = glCreateShader(GL_FRAGMENT_SHADER);
GLint vlength = sizeof(vText);
GLint flength = sizeof(fText);
cout << vSource << fSource << endl;
if(vText == NULL || fText == NULL)
{
cout << "ERROR: One of the Shaders could not load!" << endl;
return;
}
glShaderSource(m_vshader, 1, &vText, &vlength);
glShaderSource(m_fshader, 1, &fText, &flength);
}Thanks ahead,
Brent