PDA

View Full Version : Performance issues



junlinxu
10-24-2000, 04:56 AM
I am writing an opengl application for Windows. Every time the program needs to add one line to a big drawing (say 10,000 lines), I have to refresh the whole drawing again. Is there a way in opengl to refresh only one line and leave the 10,000 lines as-is. Thanks.

mcraighead
10-24-2000, 05:27 AM
Yes, you can render to the front buffer directly. So if you have the 10000 lines already displayed and you just want to add one more:

glDrawBuffer(GL_FRONT);
glBegin(GL_LINES);
glVertex2f(...);
glVertex2f(...);
glEnd();
glFlush(); // required to ensure that the line will actually show up on the screen
glDrawBuffer(GL_BACK);

(or something along those lines)

Note that a lot of buggy apps fail to call glFlush() after front-buffered rendering. Don't fall into this trap. When you render to the front buffer, if you don't call glFlush(), everything you've done so far may just be buffered up still.

- Matt

junlinxu
10-24-2000, 11:25 AM
Thank you very much, Matt. That really helps.