Skip to main content
gamedev.net
🔒 Locked

GLSL Compilation error

Started by TTT_Dutch 5 replies 3.9k views
Original Post
TTT_Dutch
TTT_Dutch
OK well I am testing out my new class and I can't seem to get my test shaders to compile.


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
TTT_Dutch
TTT_Dutch

umm do you have OGL 3.3 support?


Yes I checked my graphics card and it supports OGL 3.3

[font="arial, verdana, tahoma, sans-serif"]

How do you create your OpenGL context? You have to specify the version when creating it.


[/font][font="arial, verdana, tahoma, sans-serif"]I do not specify the version or OpenGL context. I just init glew and make an sfml window.[/font]
TTT_Dutch
TTT_Dutch
Ok I tried switching to GLFW and I still get the same errors. So maybe sfml and GLFW both don't support gl 3.3? IDK. I need something that can get the job done.
TTT_Dutch
TTT_Dutch
Ok guys I fixed it. My problem was with loading the files.

Topic Locked

This topic has been locked by a moderator. New replies are not allowed.

Sign in to reply to this topic.