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: Render to Framebuffer with OpenGL 3.1

  1. #1
    Intern Contributor
    Join Date
    Jun 2012
    Posts
    71

    Render to Framebuffer with OpenGL 3.1

    Hello,
    I've been following this tutorial to try to get a simple mirror working. Since that tutorial series uses OpenGL 3.3 and I only have support up to 3.1, I had to change a few things, but not much. However, there's a part where this line is added to the fragment shader:
    Code :
    layout(location = 0) out vec3 color;
    Since I only have GLSL 1.3, I can't use location=# syntax. In the past, for shader inputs I've just used glBindAttribLocation before linking the program, but that was only for the vertex shader, and for inputs, not outputs. How can I specify the location of a fragment shader output, with GLSL 1.3?

  2. #2
    Advanced Member Frequent Contributor
    Join Date
    Dec 2007
    Location
    Hungary
    Posts
    985
    For fragment shader outputs you have to use glBindFragDataLocation. It works exactly how glBindAttribLocation works for vertex attributes.
    Disclaimer: This is my personal profile. Whatever I write here is my personal opinion and none of my statements or speculations are anyhow related to my employer and as such should not be treated as accurate or valid and in no case should those be considered to represent the opinions of my employer.
    Technical Blog: http://www.rastergrid.com/blog/

  3. #3
    Advanced Member Frequent Contributor arekkusu's Avatar
    Join Date
    Nov 2003
    Posts
    783
    And since the location is zero, you can just delete the layout and do nothing. Locations default to zero.

  4. #4
    Intern Contributor
    Join Date
    Jun 2012
    Posts
    71
    Quote Originally Posted by aqnuep View Post
    For fragment shader outputs you have to use glBindFragDataLocation. It works exactly how glBindAttribLocation works for vertex attributes.
    Ah, thanks, that appears to be want I was missing.
    Quote Originally Posted by arekkusu View Post
    And since the location is zero, you can just delete the layout and do nothing. Locations default to zero.
    You mean delete the layout part in the shader? Or that I could omit that glBindFragDataLocation line entirely?

  5. #5
    Senior Member OpenGL Guru
    Join Date
    May 2009
    Posts
    4,948
    Locations default to zero.
    I would love to see some confirmation on this in the OpenGL specification. I used to think that this was true until I actually looked through the spec. And I have yet to find any evidence to support it.

Posting Permissions

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