Part of the Khronos Group
OpenGL.org

The Industry's Foundation for High Performance Graphics

from games to virtual reality, mobile phones to supercomputers

Page 1 of 2 12 LastLast
Results 1 to 10 of 14

Thread: gl_PointCoord and OpenGL 3.1 / GLSL 1.4

  1. #1
    Junior Member Newbie
    Join Date
    Nov 2008
    Location
    Germany
    Posts
    16

    gl_PointCoord and OpenGL 3.1 / GLSL 1.4

    Hi all,

    I want to render points using a specific size with OpenGL 3.1 / GLSL 1.4. If I enable GL_POINT_SPRITE and using backward compatibility, gl_PointCoord gives me valid values. But, as enabling point sprites is deprecated, how do I get valid values in gl_PointCoord? Is there a bug in the driver (latest NVIDIA): The spec says "Point rasterization is always performed as though POINT_SPRITE were enabled.". But it doesn't seem so ...

    Any help?

    Regards Norbert

  2. #2
    Junior Member Regular Contributor
    Join Date
    Aug 2005
    Posts
    148

    Re: gl_PointCoord and OpenGL 3.1 / GLSL 1.4

    Try enabling GL_VERTEX_PROGRAM_POINT_SIZE, set gl_PointSize in your vertex shader, then specify your points normally. Works just dandy for me (Vista32/G80-190.38).

  3. #3
    Junior Member Newbie
    Join Date
    Nov 2008
    Location
    Germany
    Posts
    16

    Re: gl_PointCoord and OpenGL 3.1 / GLSL 1.4

    Thanks for your help.

    I already enabled GL_VERTEX_PROGRAM_POINT_SIZE and this is not the problem. The points do have the wanted size. The problem is, that gl_PointCoord is not correctly set, which I need e.g. for texture mapping.

    Any more help or any solutions?

  4. #4
    Advanced Member Frequent Contributor
    Join Date
    Apr 2003
    Posts
    652

    Re: gl_PointCoord and OpenGL 3.1 / GLSL 1.4

    Did you specify

    #version 140

    in your fragment shader?

  5. #5
    Junior Member Newbie
    Join Date
    Nov 2008
    Location
    Germany
    Posts
    16

    Re: gl_PointCoord and OpenGL 3.1 / GLSL 1.4

    Yes.

  6. #6
    Junior Member Regular Contributor
    Join Date
    Aug 2005
    Posts
    148

    Re: gl_PointCoord and OpenGL 3.1 / GLSL 1.4

    I can't seem to reproduce the problem you are having. You do realize that gl_PointCoord in strictly a FS input? I'm sure you do but it wasn't entirely clear from your first post.

    Just so we're on the same page, you enable both GL_POINT_SPRITE (for texture coordinate generation) and GL_VERTEX_PROGRAM_POINT_SIZE (so that gl_PointSize is respected). Otherwise I'm at something of a loss for recommendations. Could there be trouble with your textures?

    Incidentally, you can verify that your texture coordinates are being generated correctly by setting your output FragColor to vec4(gl_PointCoord.st, 0, 1); This should produce black in the top left corner and yellow in the bottom right (unless POINT_SPRITE_COORD_ORIGIN is set to LOWER_LEFT).

  7. #7
    Junior Member Newbie
    Join Date
    Nov 2008
    Location
    Germany
    Posts
    16

    Re: gl_PointCoord and OpenGL 3.1 / GLSL 1.4

    Well, everything is working fine (if I enable GL_POINT_SPRITE) with a backward(!) compatible context. Then gl_PointCoord delivers me correct values. But if I do have a forward(!) compatible context, then glEnable(GL_POINT_SPRITE) is deprecated:
    "Non-sprite points - Enable/Disable targets POINT SMOOTH
    and POINT SPRITE, and all associated state. Point rasterization is always
    performed as though POINT SPRITE were enabled."
    So in this case, I can not enable point sprites and I expect, that they are already enabled, right?
    Right now, I am pretty sure this is a bug in the driver.

  8. #8
    Junior Member Regular Contributor
    Join Date
    Aug 2005
    Posts
    148

    Re: gl_PointCoord and OpenGL 3.1 / GLSL 1.4

    That could very well be. I haven't done any testing with forward compatible contexts. Are you getting any errors?

  9. #9
    Junior Member Newbie
    Join Date
    Nov 2008
    Location
    Germany
    Posts
    16

    Re: gl_PointCoord and OpenGL 3.1 / GLSL 1.4

    Well, if I try to enable point sprites in the forward context, it does report an invalid enum (which is ok). I guess, what is missing, that when creating the forward compatible context, the point sprites are not "enabled" by default. I have posted this issue also on the NVIDIA developer site. Let's see what they respond ...

  10. #10
    Junior Member Regular Contributor
    Join Date
    Aug 2005
    Posts
    148

    Re: gl_PointCoord and OpenGL 3.1 / GLSL 1.4

    For what it's worth I can confirm what you're seeing in forward-compatible mode. (On a hunch that it's texture related I discovered that TexParameterf with TEXTURE_LOD_BIAS is generating an INVALID_ENUM, unrelated though that may be).

Posting Permissions

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