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

Thread: Rolling back GLSL 3.30 shaders to 1.50

  1. #1
    Junior Member Regular Contributor
    Join Date
    Mar 2009
    Location
    California
    Posts
    145

    Rolling back GLSL 3.30 shaders to 1.50

    I'm testing my 3.3 renderer with OpenGL 3.2 and GLSL 1.50, for better compatibility. Here's part of a fragment shader I use:
    layout(location = 0) out vec4 out_diffuse;
    layout(location = 1) out vec4 out_normal;
    layout(location = 2) out vec4 out_properties;
    layout(location = 3) out vec4 out_emission;

    Now in GLSL, the layout stuff isn't supported, right? What do I use to define these values from my main program for GLSL 1.50?

  2. #2
    Senior Member OpenGL Pro Ilian Dinev's Avatar
    Join Date
    Jan 2008
    Location
    Watford, UK
    Posts
    1,261

    Re: Rolling back GLSL 3.30 shaders to 1.50

    for vertex attribs: glBindAttribLocation
    for frag outputs: glBindFragDataLocation

  3. #3
    Junior Member Regular Contributor
    Join Date
    Mar 2009
    Location
    California
    Posts
    145

    Re: Rolling back GLSL 3.30 shaders to 1.50

    Whew, that is way easier than using GetAttributeLocation, or whatever it's called. The problem with letting OpenGL automatically assign the attribute locations like uniforms is that your vertex buffer class becomes dependent on feedback from your shader class, and it gets messy.

  4. #4
    Junior Member Regular Contributor
    Join Date
    Mar 2009
    Location
    California
    Posts
    145

    Re: Rolling back GLSL 3.30 shaders to 1.50

    I actually like using glBindAttribLocation better than specifying the layout in the shader, because you only have to store the attribute definitions in one place in your program.

  5. #5
    Intern Contributor
    Join Date
    Jun 2008
    Posts
    65

    Re: Rolling back GLSL 3.30 shaders to 1.50

    Quote Originally Posted by JoshKlint
    Whew, that is way easier than using GetAttributeLocation, or whatever it's called. The problem with letting OpenGL automatically assign the attribute locations like uniforms is that your vertex buffer class becomes dependent on feedback from your shader class, and it gets messy.
    I hear you, but then drawing the same VAO with multiple shaders gets messy.

    - Chris

  6. #6
    Junior Member Regular Contributor malexander's Avatar
    Join Date
    Aug 2009
    Location
    Ontario
    Posts
    247

    Re: Rolling back GLSL 3.30 shaders to 1.50

    One of the issues I found with 1.50 is that it's not possible to query what the fragment shader outputs are, unlike input attributes (which are queried with glGetProgram(GL_ACTIVE_ATTRIBUTES)/glGetActiveAttrib). You just have to know what outputs the shader has, though admittedly in most cases this isn't an issue. Explicit Attribute Location comes in handy in the other cases, but it still doesn't seem possible to query the number of fragment shader outputs.

    Edit: I should point out that I worked around the issue by doing a glGetFragDataLocation() for all output names that were supported in a given context and checking it against -1.

Posting Permissions

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