PDA

View Full Version : GLSL Error: parser finding no code.



aviel
05-26-2011, 11:27 PM
So, I'm learning GLSL and have a fragment shader with the extreme simple following code:



varying float diffuse_value;

void main()
{
gl_FragColor = vec4(1.0, 0, 0, 1.0);
}


When I compile it, I get this error:



ERROR: 0:1: '/' : syntax error syntax error
ERROR: Parser found no code to compile in source strings.


I have no idea what to make of this. What does it mean? I know it's finding the files correctly. By the way, the code I have to load the shader is as follows:




this->vertexShaderID = glCreateShader(GL_VERTEX_SHADER);
this->fragmentShaderID = glCreateShader(GL_FRAGMENT_SHADER);

const char *vertexShaderPathChar = vertexShaderPath.c_str();
const char *fragmentShaderPathChar = fragmentShaderPath.c_str();

glShaderSource(this->vertexShaderID, 1, &vertexShaderPathChar, NULL);
glShaderSource(this->fragmentShaderID, 1, &fragmentShaderPathChar, NULL);

glCompileShader(this->vertexShaderID);
glCompileShader(this->fragmentShaderID);

this->programID = glCreateProgram();

glAttachShader(this->programID, this->vertexShaderID);
glAttachShader(this->programID, this->fragmentShaderID);

glLinkProgram(this->programID);

Alfonse Reinheart
05-26-2011, 11:47 PM
vertexShaderPath
fragmentShaderPath


These names look suspiciously like filenames ("Path"), not shaders. OpenGL does not read files; that's your job. You must give OpenGL what you load from that file.

aviel
05-27-2011, 09:39 AM
vertexShaderPath
fragmentShaderPath


These names look suspiciously like filenames ("Path"), not shaders. OpenGL does not read files; that's your job. You must give OpenGL what you load from that file.

Oh, i have to give them the text of the file? Well I'm an idiot. Okay, thanks.