Results 1 to 2 of 2

Thread: local variables in glsl shader

  1. #1
    Member Contributor
    Join Date
    Jul 2018
    Posts
    63

    local variables in glsl shader

    Hi

    I am trying to use some local variables in the glsl shade. However, everytime I simply declare or declare and assign the variable to an initial value , it seems my shader stops working properly. Before doing this , I used to get a pretty picture on my screen, now I get a blank white screen.


    Code :
    static const char render_fs[] =
            "#version 430 core\n"
            "\n"
            "layout (location = 0) out vec4 color;\n"
            "\n"
            "uniform sampler2D output_image;\n"
            "\n"
            "void main(void)\n"
            "{\n"
    	"vec4 sample=vec4(1.0,1.0,1.0,1.0};\n"
    	"\n"
            "    color = texture(output_image, vec2(gl_FragCoord.xy) / vec2(textureSize(output_image, 0)));\n"
            "}\n";

    See the sample variable. Just adding this whites out what i see on the screen.

  2. #2
    Senior Member OpenGL Guru
    Join Date
    Oct 2004
    Posts
    4,660
    Quote Originally Posted by driver View Post
    Code glsl:
      ...
      vec4 sample=vec4(1.0,1.0,1.0,1.0};
      ...

    See the sample variable. Just adding this whites out what i see on the screen.
    You need to check the compilation log, print it out to the screen, and fatal on a compile error. The compiler is no doubt trying to tell you that there is a syntax error here. That last brace above should be a parenthesis.

Similar Threads

  1. [GLSL 130] Sharing variables between several fragments.
    By laurent7601 in forum OpenGL: GLSL
    Replies: 1
    Last Post: 10-21-2015, 07:01 AM
  2. Replies: 5
    Last Post: 06-23-2013, 01:13 AM
  3. GLSL variables (novice)
    By candela in forum OpenGL: GLSL
    Replies: 5
    Last Post: 05-30-2011, 02:35 PM
  4. using Variables to index arrays in GLSL on an ATI
    By burito in forum OpenGL: Basic Coding
    Replies: 0
    Last Post: 02-13-2011, 10:17 PM
  5. different local variables share memory?
    By oakus in forum OpenCL
    Replies: 2
    Last Post: 12-17-2010, 02:15 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Proudly hosted by Digital Ocean