Want to protect your cyber security and still get fast solutions? Ask a secure question today.Go Premium

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 3569
  • Last Modified:

OpenGL Double Buffering

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
Xavior2K3
Asked:
Xavior2K3
  • 2
  • 2
2 Solutions
 
TimYatesCommented:
Are you embedding JOGL into a Swing app using GLJPanel?  Or doing a standalone OpenGL app with no GUI elements?
0
 
Xavior2K3Author Commented:
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
 
TimYatesCommented:
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
 
davebytesCommented:
"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
 
Xavior2K3Author Commented:
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

[Webinar On Demand] Database Backup and Recovery

Does your company store data on premises, off site, in the cloud, or a combination of these? If you answered “yes”, you need a data backup recovery plan that fits each and every platform. Watch now as as Percona teaches us how to build agile data backup recovery plan.

  • 2
  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now