Solved

OpenGL Double Buffering

Posted on 2007-03-26
5
3,506 Views
Last Modified: 2013-12-21
Hi,

I'm having a problem with OpenGL double buffering. I'm using JOGL so I'm not sure if this is a general OpenGL question or a JOGL one!

I'm noticing that when I move objects around I can sometimes see the scan lines being rapidly drawn. There is no flickering as such, as i think i have double buffering on. I set double buffering in 2 places. Once in the capabilities (capabilities.setDoubleBuffered(true)), and once in the initialisation (glEnable(gl.GL_DOUBLEBUFFER)). Are these the only 2 things you need to set for double buffering? I've noticed some code using a swapbuffers function, is this something thats needed?

Any ideas why I'm sometimes seeing these scanlines being rapidly drawn?

Kind Regards,
Michael
0
Comment
Question by:Xavior2K3
  • 2
  • 2
5 Comments
 
LVL 35

Expert Comment

by:TimYates
ID: 18791703
Are you embedding JOGL into a Swing app using GLJPanel?  Or doing a standalone OpenGL app with no GUI elements?
0
 
LVL 1

Author Comment

by:Xavior2K3
ID: 18791719
Yes I'm using swing elements and I'm adding the GLCanvas it to a standard JPanel. Could a GLJPanel be the answer? I've never heard if it before! :)
0
 
LVL 35

Assisted Solution

by:TimYates
TimYates earned 100 total points
ID: 18791742
I think GLJPanel is better with Swing, as it follows swing's updating method...

An interesting post here:  http://weblogs.java.net/blog/campbell/archive/2006/10/easy_2d3d_mixin.html

"In theory, the performance of GLJPanel may be slightly worse than GLCanvas, because GLJPanel inherently works within the Swing doublebuffering system (which blits the Swing backbuffer to the screen), whereas GLCanvas can use page flipping (which has lower overhead and has the benefit of being synced with the vertical retrace). But in most applications, the time spent copying the backbuffer contents to the screen is a very small percentage of the total rendering time. So practically speaking, you're not likely to notice a difference between the two."

Which seems to suggest that with GLCanvas, you should be page flipping, not double buffering (I guess it's the same thing, but I *think* you have to tell the canvas to flip)  I haven't done JOGL for a while :-(  So I'm a bit rusty
0
 
LVL 17

Accepted Solution

by:
davebytes earned 150 total points
ID: 18872660
"But in most applications, the time spent copying the backbuffer contents to the screen is a very small percentage of the total rendering time. So practically speaking, you're not likely to notice a difference between the two."

Boy, that person doesn't know graphics well. ;)

Flipping is always faster, period.  If you have to blit graphics, that's going to be slow.  Especially if Swing isn't managing its data under the covers via hardware, and is doing a copy from system memory or something.  Any time there are copies back and forth, that will slow things down.

Double buffering is a scheme specifying that you're never rendering direct into the 'primary' buffer (which in windowed GL would be physically to the screen unless the GL itself is being 'managed' by the operating system -- which OSX does, and Vista may, and new Linux GL compiz/et al compositors do).  Double buffering can use page-flipping if you control the entire screen (it really is just a change of a register before the retrace begins again), or if there's a compositing window system (so you flip surfaces 'internal' to your app, can start rendering into the new backbuffer, while the OS pulls the new frontbuffer contents and gets them onto the screen for you).

The function in 'real GL' is SwapBuffers (can be wglSwapBuffers, or some other variant depending on who is managing GL).

I would think given the above description that you want to use GLCanvas if you want to NOT have Swing doing extra 'things' to your buffers, and have more control.

-d
0
 
LVL 1

Author Comment

by:Xavior2K3
ID: 19006888
Thanks for all of your input. I really think this is a JOGL issue. I'm not sticking with Java for too much longer so i hope i wont be plagued with this problem in the future!

Thanks again!
0

Featured Post

6 Surprising Benefits of Threat Intelligence

All sorts of threat intelligence is available on the web. Intelligence you can learn from, and use to anticipate and prepare for future attacks.

Join & Write a Comment

This was posted to the Netbeans forum a Feb, 2010 and I also sent it to Verisign. Who didn't help much in my struggles to get my application signed. ------------------------- Start The idea here is to target your cell phones with the correct…
Introduction This article is the last of three articles that explain why and how the Experts Exchange QA Team does test automation for our web site. This article covers our test design approach and then goes through a simple test case example, how …
Viewers learn about the “for” loop and how it works in Java. By comparing it to the while loop learned before, viewers can make the transition easily. You will learn about the formatting of the for loop as we write a program that prints even numbers…
Viewers will learn about arithmetic and Boolean expressions in Java and the logical operators used to create Boolean expressions. We will cover the symbols used for arithmetic expressions and define each logical operator and how to use them in Boole…

706 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

15 Experts available now in Live!

Get 1:1 Help Now