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

Thread: gl_PointSize problem

  1. #1
    Junior Member
    Join Date
    Nov 2009
    Posts
    4

    gl_PointSize problem

    I have been trying to write some code to draw lines and points with different sizes.

    I have tried this in the vertex shader:
    //Vertex shader
    void main()
    {
    gl_Position = ...;
    gl_PointSize = 3.0;
    }

    if I modify the value of gl_PointSize anything happens (between 1 and 63), the points are always drawn in the same way. What am I doing wrong?

  2. #2
    Member
    Join Date
    Oct 2009
    Location
    London, UK
    Posts
    90

    Re: gl_PointSize problem

    I see the same thing.

    A bit of Googling suggests that there are known problems with ATI 2400/2600 series cards (http://www.mailinglistarchive.com/ma.../msg03188.html), and I have an ATI 2400 on this machine -- so if you have a similar card, that might be your problem.

    If you have a different card, it might be worth checking that you've enabled point sizes:

    Code :
        gl.enable(gl.POINT_SPRITE);
        gl.enable(gl.VERTEX_PROGRAM_POINT_SIZE);
        gl.drawArrays(gl.POINTS, 0, 3);

  3. #3
    Junior Member
    Join Date
    Nov 2009
    Posts
    4

    Re: gl_PointSize problem

    Thank you for your response, you have given me really helpful advice.
    My card is NVidia Geforce 9400. I have tried your solution:
    gl.enable(gl.POINT_SPRITE);
    gl.enable(gl.VERTEX_PROGRAM_POINT_SIZE);
    but It still does not work.

    So I have made a little research and have found that:
    gl.VERTEX_PROGRAM_POINT_SIZE (WebGL version) --> GL_VERTEX_PROGRAM_POINT_SIZE (OpenGL SE 2.0 specification)
    is not yet implemented in WebToolKit, almost in the version I downloaded last week. It doesn't mean you can not enable this feature, it only means that a handler has not yet been written.

    The solution, until the code is updated, is easy, change:
    gl.enable(gl.VERTEX_PROGRAM_POINT_SIZE); (will work in upgraded WebGL version, future)
    to
    gl.enable(0x8642); (my WebToolKit version)

    This magic number can be found in the GL.h file of the sourcecode of OpenGL ES 2.0 which is the core behind WebGL. You can find similar numbers for gl.BLEND, etc, that are actually implemented.

    About POINT_SPRITE feature I think (not completely sure) this only works for OpenGL, not for OpenGL ES. I have search the magic number for this number, in the same file, and I haven't found anything.

    I hope anybody could find this helpful until someone fix the issue.
    Giles, thank you for pointing me to the right direction.

    (Maybe at this time the WebToolKit has been already updated so this instructions are not really useful ... :X)

  4. #4
    Member Coolcat's Avatar
    Join Date
    Oct 2009
    Location
    NRW, Germany
    Posts
    75

    Re: gl_PointSize problem

    Neither VERTEX_PROGRAM_POINT_SIZE nor POINT_SPRITE are defined in gl.h for OpenGL ES 2.0. Maybe ES 2.0 does not support them?

    However, there is an extension GL_OES_point_sprite, which defines point sprites above ES 1.0.

  5. #5
    Junior Member
    Join Date
    Nov 2009
    Posts
    4

    Re: gl_PointSize problem

    Hi Coolcat,

    You are completely right. I have check http://www.khronos.org/registry/gles/api/2.0/gl2.h and there is no reference to GL_VERTEX_PROGRAM_POINT_SIZE or GL_POINT_SPRITE.

    The one I use was http://www.khronos.org/opengles/headers/2_0/GL.h, and in this file you can find:
    Code :
    /* Shaders */
    #define GL_VERTEX_PROGRAM_POINT_SIZE      0x8642
    #define GL_VERTEX_ATTRIB_ARRAY_NORMALIZED 0x886A
    which is the 'magic number' I used to get gl_PointSize working.

    The first file seems to be newer but If I do not enable GL_VERTEX_PROGRAM_POINT_SIZE with this code:
    Code :
    gl.enable(0x8642);
    the size of the pixel are always 1 pixel (always refering to WebToolKit implementation of WebGL).

    Maybe someone from Khronos group could give us more advice.

  6. #6
    Junior Member
    Join Date
    Jun 2004
    Posts
    2

    Re: gl_PointSize problem

    Hi,
    I don't know too much about how WebGL is layering on GL or GLES, but I can tell you that in GLES2.0 the *only* way to specify a point's size is through the gl_PointSize variable in the GLSL ES. This differs from desktop GL, which has a piece of API state controlled through glPointSize, and an enable GL_VERTEX_PROGRAM_POINT_SIZE which determines whether the API state or the shader state is used. I suspect your problem relates to the mapping between the GLES and the GL ways of specifying the sizes of points.

    Doubt this will help solve your problem, but a bit of information is never a bad thing..
    Thanks
    Ben

  7. #7
    Member
    Join Date
    Oct 2009
    Location
    London, UK
    Posts
    90

    Re: gl_PointSize problem

    Interesting, it's quite true that GL_POINT_SPRITE and GL_VERTEX_PROGRAM_POINT_SIZE aren't part of the OpenGL ES 2.0 spec, I wonder why they're included as constants in the WebGL context? Perhaps it was a case of copy/paste from somewhere.

    I've checked my OpenGL ES book, which agrees entirely with what MrB says -- that all you need to do to set the point size is set the gl_PointSize variable in the vertex shader, which is of course what you were originally doing!

  8. #8
    Junior Member
    Join Date
    Sep 2009
    Location
    Mozilla
    Posts
    4

    Re: gl_PointSize problem

    gl_PointSize is always enabled/available on ES 2.0; implementations mapping WebGL to desktop GL should be unconditionally enabling GL_VERTEX_PROGRAM_POINT_SIZE. We do this in Firefox currently, though I admit I've never tested gl_PointSize -- I'd be interested to hear if things are working as intended.

  9. #9
    Member
    Join Date
    Oct 2009
    Location
    London, UK
    Posts
    90

    Re: gl_PointSize problem

    When I tried setting gl_PointSize on Firefox, the points still came out as 1px in size.

    If I understand jgrarod correctly, he was getting the same effect in WebKit but was able to work around it by calling

    Code :
    gl.enable(0x8642);

  10. #10
    Junior Member
    Join Date
    Feb 2010
    Posts
    2

    Re: gl_PointSize problem

    Has anybody tried drawing point sprites recently? I'm using Minefield with "gl.enable(0x8642)" and it works fine - but it's not defined anywhere in the current draft spec. After reading through this thread and looking through the specs for myself, I agree that we shouldn't need to enable anything to be able to render point sprites, but when I comment out the "gl.enable(0x8642)", my points disappear. Is anybody successfully rendering point sprites with code that conforms to the draft spec?

Page 1 of 2 12 LastLast

Posting Permissions

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