Thread overview
[Derelict-GL3] GLSL: Syntax error unexpected tokens following #version
Dec 04, 2016
Payotz
Dec 04, 2016
Mike Parker
Dec 04, 2016
Mike Parker
Dec 04, 2016
Payotz
December 04, 2016
So I've been trying to teach myself how to OpenGL, and there are errors whenever I try to compile my shaders.

Errors are : http://i.imgur.com/5hRaQL8.png

My shader code is as follows:
///
#version 130

attribute vec3 position;

void main()
{
    gl_Position = vec4(position,1.0);
}
///

My shader loader code is :

//
string loadShader(string fileName){
    File file = File(fileName,"r");
    string line;
    line = string.init;
    while(!file.eof()){
        line ~= file.readln();
    }
    writeln(line);
    return line;
}//

Through my constant "googling" on the internet, I've seen many countless answers to the loader code not appending '\n' to each newline when it reads the new code.
It was not the case: http://i.imgur.com/6mWSs4S.png ;

So with that, I don't have any leads. Any ideas?

My graphics card is an Intel HD 5000, and GPU is AMD Radeon HD 7670M which supports OpenGL 3.0.
December 04, 2016
On Sunday, 4 December 2016 at 06:41:07 UTC, Payotz wrote:
> So I've been trying to teach myself how to OpenGL, and there are errors whenever I try to compile my shaders.
>
> Errors are : http://i.imgur.com/5hRaQL8.png

Why the screenshot? Simpler to respond to copy/pasted text.

The second line is a pretty strong hint:

"Version number not supported by GL2"

It seems you haven't created a GL30 context. Before loading your shader, print out the result of glGetString(GL_VERSION) to verify. Then make sure you create a GL3 context with whichever API you are using.

>
> My shader code is as follows:
> ///
> #version 130
>
> attribute vec3 position;

`attribute` was deprecated in GLSL 1.3. Use `in` instead.


December 04, 2016
On Sunday, 4 December 2016 at 08:30:40 UTC, Mike Parker wrote:

> your shader, print out the result of glGetString(GL_VERSION) to

Alternatively, since you're using Derelict, you can check the return value of DerelictGL3.reload() or, any time after calling it, DerelictGL3.loadedVersion.
December 04, 2016
On Sunday, 4 December 2016 at 08:32:23 UTC, Mike Parker wrote:
> On Sunday, 4 December 2016 at 08:30:40 UTC, Mike Parker wrote:
>
>> your shader, print out the result of glGetString(GL_VERSION) to
>
> Alternatively, since you're using Derelict, you can check the return value of DerelictGL3.reload() or, any time after calling it, DerelictGL3.loadedVersion.

Actually, the fix was something anticlimactic. It had something to do with glShaderSource() and how I passed the arguments, it had nothing to do with the source code itself.
Thanks for the advice though. I'll be taking note of this.