Part of the Khronos Group
OpenGL.org

The Industry's Foundation for High Performance Graphics

from games to virtual reality, mobile phones to supercomputers

Results 1 to 5 of 5

Thread: glShaderSource() doesn't copy the code correctly

Threaded View

Previous Post Previous Post   Next Post Next Post
  1. #1
    Junior Member Newbie Apoptose's Avatar
    Join Date
    Jun 2012
    Location
    Germany
    Posts
    6

    glShaderSource() doesn't copy the code correctly

    Hi,

    my Problem is, that glShaderSource() cuts the Vertex Shader code, so glCompileShader() will fail and report the following error:

    Code :
    0(11) : error C0000: syntax error, unexpected $undefined, expecting "::" at token "<undefined>"

    the Vertex Shader code is:
    Code :
    #version 400
     
    layout (location = 0) in vec3 VertexPosition;
    layout (location = 1) in vec3 VertexTexCoord;
     
    out vec3 TexCoord;
     
    void main()
    { 
        TexCoord = VertexTexCoord; 
        gl_Position = vec4(VertexPosition, 1.0);
    }

    glGetShaderSource() returns:
    Code :
    #version 400
     
    layout (location = 0) in vec3 VertexPosition;
    layout (location = 1) in vec3 VertexTexCoord;
     
    out vec3 TexCoord;
     
    void main()
    { 
        TexCoord = VertexTexCoord; 
        gl_Position = vec4(VertexPosit�

    so glShaderSource() seems to screw up with copying the String. I use the following function to load the shader:
    Code :
     const char* loadShaderAsString(const char* file){
        std::ifstream shader_file(file, std::ifstream::in);
        std::string str((std::istreambuf_iterator<char>(shader_file)), std::istreambuf_iterator<char>());
     
        return str.c_str();
    }

    printf() prints the String correctly.

    I've tested this with an NVIDIA GTS 450. Operating system is Ubuntu 12.04.

    I attached the Eclipse(Indigo) CDT Project.

    Hopefully this is the correct forum since this *might* be a bug.

    Thanks for any help,
    Apoptose
    Attached Files Attached Files
    Last edited by Apoptose; 06-14-2012 at 10:33 AM.

Tags for this Thread

Posting Permissions

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