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 4 of 4

Thread: Problem of varying and in

  1. #1
    Intern Contributor
    Join Date
    Mar 2011
    Posts
    86

    Problem of varying and in

    it works well like that:
    in the vertex shader
    varying float v;
    void main()
    {
    ...
    v=10;
    ...
    }

    in the Fragment shader
    varying float v;
    main()
    {
    gl_FragColor = gl_Color*v;
    }

    however ,if i change it like that,it won't work,why????????
    in the vertex shader:
    out float v;
    void main()
    {
    ...
    v=10;
    ...
    }

    in the Fragment shader
    in float v;
    main()
    {
    gl_FragColor = gl_Color*v;
    }

  2. #2
    Senior Member OpenGL Lord
    Join Date
    May 2009
    Posts
    6,015

    Re: Problem of varying and in

    however ,if i change it like that,it won't work,why????????
    I don't know; do you think this question really needs eight question marks?



    In any case, you didn't say what about this doesn't work. Is it a compiler error? A linker error?

    Your shader examples do not seem to have a #version definition, which means that it will be compiled against GLSL version 1.10. And back then, they didn't have "in" and "out"; only "varying". If you want to use more up-to-date GLSL syntax, you need to have a #version definition for GLSL 1.30 or greater.

  3. #3
    Intern Contributor
    Join Date
    Mar 2011
    Posts
    86

    Re: Problem of varying and in

    it does not work mean that in the Fragment shader
    in float v;
    main()
    {
    gl_FragColor = gl_Color*v;
    }

    in float v should affect gl_FragColor,but the result teapot is just white , so i think v does not receive any value from vertex shader,i use #version 140 ,but it does not work either.

  4. #4
    Junior Member Regular Contributor
    Join Date
    Nov 2010
    Location
    Brazil, Rio de Janeiro
    Posts
    147

    Re: Problem of varying and in

    Isn't gl_FragColor deprecated since GLSL > 1.2 ?

Posting Permissions

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