0

I want to animate my GL_LINE_STRIP vertex by vertex. Here is how I do it now (inefficiently):

void renderFunc()
{
 glDrawElements(GL_LINE_STRIP, testCount, GL_UNSIGNED_INT, (GLvoid*)0);

if ( testCount < verts.size() )
    testCount++;
}

However, it must completely redraw vertices, because it draws from the beginning as opposed to from where it left off, which takes extra time. I'd like to try and draw one vertex at a time to speed things up, unless there are other ideas.

genpfault
  • 51,148
  • 11
  • 85
  • 139
TheBlindSpring
  • 631
  • 5
  • 22
  • And how many vertices are you rendering this way? A modern GPU should allow you to draw at least 500 million of them. – Bartek Banachewicz Mar 20 '14 at 21:24
  • my program reads in vertices so I have a varying number of vertices, but I have had programs with almost 2 million. I just don't want to draw them all at once, I want to draw a new vertex every frame. – TheBlindSpring Mar 20 '14 at 21:32
  • 2 million should render effortlessly in realtime. What are your frame times right now? – Bartek Banachewicz Mar 20 '14 at 21:33
  • My frame rate depends on on how many vertices have been drawn. When I initially start drawing, I get about 1,500 FPS, when the drawing is finished it runs about 1,000 FPS. – TheBlindSpring Mar 20 '14 at 23:48

1 Answers1

0

Just don't clear your render target. In case, where you are drawing to back buffer, remove those functions:

glClearColor(...);
glClear(GL_COLOR_BUFFER_BIT);

(if you rendering to any other target, you already know how to do it ;) )

Consider also leaving depth /stencil buffers uncleared:

`GL_DEPTH_BUFFER_BIT | GL_STENCIL_BUFFER_BIT`


But wait, is performance really so bad, that you gonna let a hairy mess been drawn up?

Ivan Aksamentov - Drop
  • 12,860
  • 3
  • 34
  • 61
  • Okay, I kind of figured out what you mean. The problem is, it only draws every other vertex, and it flickers (It is fast though). Any idea what I am doing wrong? – TheBlindSpring Mar 20 '14 at 21:50
  • Probably you are using double buffering so you draw into the back buffer and then it swaps the buffers every frame so in the odd frames you are drawing into one buffer and the even frames you are drawing into the other buffer. – user3256930 Mar 20 '14 at 22:12
  • Okay, is there anyway to fix this? – TheBlindSpring Mar 20 '14 at 23:52
  • @TheBlindSpring Yes. Disable double buffering. I can't say how to do it exactly, because it's platform specific. Indicate your platform (how do you create window and context) or wrapper library. – Ivan Aksamentov - Drop Mar 21 '14 at 07:09
  • I am using just OpenGL C++ and I am writing for windows. I changed it from GLUT_DOUBLE to GLUT_SINGLE, but then nothing draws. If you don't mind me asking, (if done correctly of course) why will this improve my performance? And by how much? – TheBlindSpring Mar 21 '14 at 13:13
  • @TheBlindSpring, so you using GLUT, to create window (it's a cross-platform helper library). After removing `GLUT_DOUBLE` you have only one back buffer, so no swapping needed. This could remove flickering as *user3256930* explained. Although sometimes it can cause some other rendering issues. I'm not aware on how it can affect performance. Generally, you must always profile your application, and not by measuring FPS or frame time, but with CPU and GPU profilers. – Ivan Aksamentov - Drop Mar 21 '14 at 16:11