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 2 of 2 FirstFirst 12
Results 11 to 13 of 13

Thread: Shader Compile Error: ERROR: 0:1: '' : syntax error #version

  1. #11
    Junior Member Newbie
    Join Date
    Sep 2011
    Posts
    26
    I've checked to see if my C string is my file... and it is. What I mean as Objective-C being my language is that I've been programming with Objective-C for years, while I've only been using C++ recently. I'm using iostream to read the file because Objective-C doesn't play nice with glfw (my window management system.) I'm not currently concerned with performance, so I've left the leak alone for now.

    Passing in the size doesn't seem to fix the problem. I did this to get the size of the C String for the final parameter:

    GLint sizeOfContents = sizeof(contentsConst);

    I passed this in as a pointer for the final parameter. (&sizeOfContents)

    So I'm still not sure why this doesn't work. What's odd to me is that sometimes the shaders will compile and other times the shaders won't compile.

    I'll try GCements method of loading the shaders and see if that makes a difference.

    Thanks!

  2. #12
    Member Regular Contributor
    Join Date
    Jun 2013
    Posts
    495
    Quote Originally Posted by Blakeasd View Post
    Passing in the size doesn't seem to fix the problem. I did this to get the size of the C String for the final parameter:

    GLint sizeOfContents = sizeof(contentsConst);
    That's wrong. sizeof(contentsConst) will be the size of a pointer (typically 4 or 8), not the size of the array which it points to. The size of the string can be obtained from the variable "size" which you used to allocate the array.

    Alternatively, you could null-terminate the string by allocating size+1 bytes and setting contents[size]='\0'.

    If you do neither, glShaderSource() won't know where the string ends, and it will try to parse whatever follows it in memory.

  3. #13
    Junior Member Newbie
    Join Date
    Sep 2011
    Posts
    26
    It worked! Thanks so much for the help GClements and Alfonse! I obtained the length of the C string (not the pointer this time) like this:
    GLint arraySize = (GLint)size;

    and passed it in as a reference like so: &arraySize

    Thanks Again!

Posting Permissions

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