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: What's faster drawing line with GL_LINES or Texture?

  1. #1
    Newbie Newbie
    Join Date
    Aug 2012
    Posts
    2

    What's faster drawing line with GL_LINES or Texture?

    In my 2D app, I'm looking to draw irregular grid consisting of hundreds of short line segments, similar to how spider's web look like.

    I'm concerned about performance, therefore before embarking on implementation wanted to consult with professionals here, what technique would you guys use to draw something line that?

    Couple of points:
    - in my spider's web I want to be able to manipulate individual lines (change color for example)
    - the web drawing will not be static for example it can shrink or grow thus less or more lines will be drawn

    Appreciate any help.

  2. #2
    Super Moderator OpenGL Guru
    Join Date
    Feb 2000
    Location
    Montreal, Canada
    Posts
    4,421
    A 100 lines doesn't sound like much. I've seen games render objects in wireframe and any design program such as 3D Studio Max render complex objects in wireframe.
    ------------------------------
    Sig: http://glhlib.sourceforge.net
    an open source GLU replacement library. Much more modern than GLU.
    float matrix[16], inverse_matrix[16];
    glhLoadIdentityf2(matrix);
    glhTranslatef2(matrix, 0.0, 0.0, 5.0);
    glhRotateAboutXf2(matrix, angleInRadians);
    glhScalef2(matrix, 1.0, 1.0, -1.0);
    glhQuickInvertMatrixf2(matrix, inverse_matrix);
    glUniformMatrix4fv(uniformLocation1, 1, FALSE, matrix);
    glUniformMatrix4fv(uniformLocation2, 1, FALSE, inverse_matrix);

  3. #3
    Intern Contributor
    Join Date
    Apr 2012
    Posts
    98
    Quote Originally Posted by AlexeyZ View Post
    In my 2D app, I'm looking to draw irregular grid consisting of hundreds of short line segments, similar to how spider's web look like. I'm concerned about performance, ...
    You probably don't have to worry about performance until you get well over 100,000 line segments.

  4. #4
    Newbie Newbie
    Join Date
    Aug 2012
    Posts
    2
    Thanks guys! This is the reply I was hoping for

  5. #5
    Member Regular Contributor
    Join Date
    Dec 2007
    Posts
    250
    Quote Originally Posted by AlexeyZ View Post
    In my 2D app
    lol you probably won't have to worry about performance .. at all.

  6. #6
    Advanced Member Frequent Contributor
    Join Date
    Apr 2010
    Location
    Germany
    Posts
    943
    Quote Originally Posted by dukey
    lol you probably won't have to worry about performance .. at all.
    And you base that on the fact that the thread starter isn't planning to have everything happen in on z-plane? You can wreck any "2D" application just as good as you can "real 3D" applications.

    AlexeyZ: Not only do a few hundred line segments fail to make your GPU sweat, the constraints you put on your design already rule out using some static, probably alpha-tested texture for your purpose. The CPU overhead is what's more interesting here. Especially as your web grows.

Posting Permissions

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