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 11

Thread: Rendering simple shapes without passing vertices?

  1. #1
    Junior Member Newbie
    Join Date
    Apr 2012
    Posts
    3

    Rendering simple shapes without passing vertices?


    Hi.

    I would like to know if its possible to render a simple shape(such as a 2d square) via GLSL without passing a single vertice via the fixed pipeline , and if it is , where can i find a simple example ?

    Thanks.

  2. #2
    Intern Contributor
    Join Date
    Mar 2011
    Posts
    87

    Re: Rendering simple shapes without passing vertices?

    As far as i know ,it is impossible. Because GPU can not generate any new vertex without any input data. Only geometry shader can generate new vertex according to your input data.

  3. #3
    Member Regular Contributor
    Join Date
    Apr 2009
    Posts
    258

    Re: Rendering simple shapes without passing vertices?

    Depending on what you mean by 'witout passing single vertice via the fixed pipeline' it may be possible.

    You can issue a draw call without any attributes enabled (at least in core profile) and then hardcode positions of your quad in the shader using gl_VertexID to put each in aproperiate place. This translates to 'passing' 4 vertices in your case (but without any data).

    Some people here reported issues with this however (but this was some time ago, so the bugs may be already fixed in latest drivers).

  4. #4
    Junior Member Newbie
    Join Date
    Apr 2012
    Posts
    3

    Re: Rendering simple shapes without passing vertices?

    Quote Originally Posted by kyle_
    Depending on what you mean by 'witout passing single vertice via the fixed pipeline' it may be possible.

    You can issue a draw call without any attributes enabled (at least in core profile) and then hardcode positions of your quad in the shader using gl_VertexID to put each in aproperiate place. This translates to 'passing' 4 vertices in your case (but without any data).

    Some people here reported issues with this however (but this was some time ago, so the bugs may be already fixed in latest drivers).
    Yeah , that's what i meant.Are there any basic examples to get started ?

  5. #5
    Advanced Member Frequent Contributor
    Join Date
    Jan 2012
    Location
    Australia
    Posts
    782

    Re: Rendering simple shapes without passing vertices?

    I had varying success with zero length buffer. The most recent version of nVidia and ATI drives seem to require real vertices.

    This works for me

    create a vbo with 4, data is irrelevant and an index buffer with
    indices 0,1,2,0,2,3

    I use
    Code :
      glDrawElementsBaseVertex(GL_TRIANGLES,6,GL_UNSIGNED_INT,(void*)0,0);
    to draw 1 quad
    Code :
    glDrawElementsInstancedBaseVertex(GL_TRIANGLES,6,GL_UNSIGNED_INT,(void*)0,nbr_of_quads,0);
    to draw multiple quads.

    in the shader gl_InstanceID tells me which quad.

  6. #6
    Member Regular Contributor
    Join Date
    Jan 2012
    Location
    Germany
    Posts
    303

    Re: Rendering simple shapes without passing vertices?

    It's possible and sometimes referred to as 'Attribute-less rendering' (search this forum) or look at:

    Attribute-less rendering

    To see how to create objects from an 'empty' render call, or:

    Generating

    to see how to generate the geometry itself in the geometry shader (with an empty vertex shader and only one point with no attributes as the rendering call).

  7. #7
    Senior Member OpenGL Guru
    Join Date
    May 2009
    Posts
    4,789

    Re: Rendering simple shapes without passing vertices?

    The most recent version of nVidia and ATI drives seem to require real vertices.
    AMD's 12.1 drivers certainly don't, and neither do NVIDIA's drivers. My impostor tutorial has a section about doing this. It's about in the middle of that page.

  8. #8
    Advanced Member Frequent Contributor
    Join Date
    Jan 2012
    Location
    Australia
    Posts
    782

    Re: Rendering simple shapes without passing vertices?

    Thanks all for the extra info. I will revisit my code as we can use gpu generated vertices a lot

  9. #9
    Member Regular Contributor
    Join Date
    Jan 2012
    Location
    Germany
    Posts
    303

    Re: Rendering simple shapes without passing vertices?

    Alfonse is right, it should work on up-to-date ATI and NVidia drivers.
    But rendering like this is very uncommon, so you could run into problems with Intel, MacOS or Linux OpenSource drivers later on.
    Be carefull, test alot and document these tricks very well!

  10. #10
    Junior Member Newbie
    Join Date
    Apr 2012
    Posts
    3

    Re: Rendering simple shapes without passing vertices?

    Brilliant - Thank you all!

Posting Permissions

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