Part of the Khronos Group
OpenGL.org

The Industry's Foundation for High Performance Graphics

from games to virtual reality, mobile phones to supercomputers

Page 1 of 2 12 LastLast
Results 1 to 10 of 15

Thread: Problem with #version

  1. #1
    Junior Member Newbie
    Join Date
    Oct 2009
    Posts
    5

    Problem with #version

    I am having some trouble with the
    Code :
    #version
    preprocessor statement. When I use
    Code :
    #version 130
    for example I get the following error:
    Code :
    Vertex shader failed to compile with the following errors:
    ERROR: 0:1: error(#76) Syntax error unexpected tokens following #version
    ERROR: error(#273) 1 compilation errors.  No code generated


    The reason why I want to change the version from 110 to 130: I wanted to do something like this
    Code :
    mat3 normalMatrix = transpose(inverse(mat3x3(modelViewMatrix)));
    However, the compiler says:
    Code :
    ERROR: 0:1: error(#202) No matching overloaded function found inverse
    ERROR: 0:1: error(#202) No matching overloaded function found transpose
    ERROR: 0:1: error(#160) Cannot convert from 'const float' to '3X3 matrix of float'
    so I thought maybe this can be fixed by increasing the version.

  2. #2
    Senior Member OpenGL Pro
    Join Date
    Sep 2004
    Location
    Prombaatu
    Posts
    1,386

    Re: Problem with #version

    Hadn't even noticed inverse had been added. Looks like it's a 140 thing.

  3. #3
    Senior Member OpenGL Guru Dark Photon's Avatar
    Join Date
    Oct 2004
    Location
    Druidia
    Posts
    3,209

    Re: Problem with #version

    Quote Originally Posted by Spooky_
    When I use
    Code :
    #version 130
    for example I get the following error:
    Code :
    Vertex shader failed to compile with the following errors:
    ERROR: 0:1: error(#76) Syntax error unexpected tokens following #version
    ERROR: error(#273) 1 compilation errors.  No code generated
    Weird. Works here on NVidia. What driver vendor/version are you using? And do you know for a fact that it supports GLSL 1.3? Perhaps it doesn't, and it's not very good at saying so.

    The reason why I want to change the version from 110 to 130: I wanted to do something like this
    Code :
    mat3 normalMatrix = transpose(inverse(mat3x3(modelViewMatrix)));
    However, the compiler says:
    Code :
    ERROR: 0:1: error(#202) No matching overloaded function found inverse
    Per the SIGGRAPH 2009 OpenGL BOF GLSL slides here, the built-in function inverse() was added in GLSL 1.4.

  4. #4
    Junior Member Regular Contributor pjcozzi's Avatar
    Join Date
    Jun 2004
    Location
    Philadelphia, PA
    Posts
    196

    Re: Problem with #version

    Quote Originally Posted by Spooky_
    Code :
    Vertex shader failed to compile with the following errors:
    ERROR: 0:1: error(#76) Syntax error unexpected tokens following #version
    ERROR: error(#273) 1 compilation errors.  No code generated
    Make sure you have a newline ("\n") at the end of the #version line.

    Patrick

  5. #5
    Junior Member Newbie
    Join Date
    Oct 2009
    Posts
    5

    Re: Problem with #version

    Quote Originally Posted by Dark Photon
    Per the SIGGRAPH 2009 OpenGL BOF GLSL slides here, the built-in function inverse() was added in GLSL 1.4.
    Oh ok, looks like I have to create an OpenGL 3 context, if I want to use inverse() in the shader.



    Quote Originally Posted by pjcozzi
    Make sure you have a newline ("\n") at the end of the #version line.

    Patrick
    Well, this is an excerpt of the beginning of the shader
    Code :
    #version 130
     
    in  vec4 a2v_position;
    in  vec3 a2v_normal;
    //...
    So there is definitely a \n . The weird thing is, if I write
    Code :
    #version 150
    I get the following error
    Code :
    Vertex shader failed to compile with the following errors:
    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) 2 compilation errors.  No code generated
    So the compiler is in fact able to recognize #version 150 but not anything after that.

  6. #6
    Junior Member Newbie
    Join Date
    Oct 2009
    Posts
    5

    Re: Problem with #version

    Btw. the 'syntax error' happens with any preprocessor statement. Even with just #line 1 for example.

  7. #7
    Member Regular Contributor DmitryM's Avatar
    Join Date
    Mar 2009
    Location
    Toronto
    Posts
    435

    Re: Problem with #version

    Code :
    Vertex shader failed to compile with the following errors:
    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) 2 compilation errors.  No code generated
    The same problem under 3.1 context. I guess you are on ATI, right?

  8. #8
    Junior Member Newbie
    Join Date
    Oct 2009
    Posts
    5

    Re: Problem with #version

    Quote Originally Posted by DmitryM
    Code :
    Vertex shader failed to compile with the following errors:
    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) 2 compilation errors.  No code generated
    The same problem under 3.1 context. I guess you are on ATI, right?
    Yes, but it doesn't work on NVidia either. The error gets even weirder there!

    Code :
    0(1) : error C0129: invalid char 'i' in integer constant suffix
    0(1) : error C0129: invalid char 'n' in integer constant suffix
    (0) : error C0000: syntax error, unexpected $end at token "<EOF>"
    (0) : error C0501: type name expected at token "<invalid atom -1>"

    Also keep in mind that this part is expected
    Code :
    ERROR: 0:1: error(#106) Version number not supported by GL2
    since I do not have a GL3 context in my app (yet).

  9. #9
    Senior Member OpenGL Guru
    Join Date
    May 2009
    Posts
    4,948

    Re: Problem with #version

    Btw. the 'syntax error' happens with any preprocessor statement. Even with just #line 1 for example.
    That sounds like you're passing your string in wrong. Are there any byte-order marks or anything? Is this a UTF-16 string or something?

  10. #10
    Senior Member OpenGL Guru Dark Photon's Avatar
    Join Date
    Oct 2004
    Location
    Druidia
    Posts
    3,209

    Re: Problem with #version

    Quote Originally Posted by Spooky_
    Yes, but it doesn't work on NVidia either. The error gets even weirder there!

    Code :
    0(1) : error C0129: invalid char 'i' in integer constant suffix
    0(1) : error C0129: invalid char 'n' in integer constant suffix
    (0) : error C0000: syntax error, unexpected $end at token "<EOF>"
    (0) : error C0501: type name expected at token "<invalid atom -1>"
    Ok, now this is just getting weird. Let's see your glShaderSource() invocation, with a single constant (hard-coded in the source code) string being fed as input. Post a little 10-line test program that demonstrates the problem so we can get our hands on it. I suspect you'll figure this out while you're cooking it.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •