Solved

OpenGL Double Buffering

Posted on 2007-03-26
5
3,524 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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

PeopleSoft Has Never Been Easier

PeopleSoft Adoption Made Smooth & Simple!

On-The-Job Training Is made Intuitive & Easy With WalkMe's On-Screen Guidance Tool.  Claim Your Free WalkMe Account Now

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Go is an acronym of golang, is a programming language developed Google in 2007. Go is a new language that is mostly in the C family, with significant input from Pascal/Modula/Oberon family. Hence Go arisen as low-level language with fast compilation…
Introduction This article is the first of three articles that explain why and how the Experts Exchange QA Team does test automation for our web site. This article explains our test automation goals. Then rationale is given for the tools we use to a…
Viewers will learn about basic arrays, how to declare them, and how to use them. Introduction and definition: Declare an array and cover the syntax of declaring them: Initialize every index in the created array: Example/Features of a basic arr…
The viewer will learn how to implement Singleton Design Pattern in Java.

697 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