Solved

OpenGL Double Buffering

Posted on 2007-03-26
5
3,513 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

Courses: Start Training Online With Pros, Today

Brush up on the basics or master the advanced techniques required to earn essential industry certifications, with Courses. Enroll in a course and start learning today. Training topics range from Android App Dev to the Xen Virtualization Platform.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
netstat -ano | find "8000" and taskkill /f /pid 2984 3 56
oracle 11g 23 74
login jsp example 24 46
login form jsp example 2 24
For beginner Java programmers or at least those new to the Eclipse IDE, the following tutorial will show some (four) ways in which you can import your Java projects to your Eclipse workbench. Introduction While learning Java can be done with…
By the end of 1980s, object oriented programming using languages like C++, Simula69 and ObjectPascal gained momentum. It looked like programmers finally found the perfect language. C++ successfully combined the object oriented principles of Simula w…
Video by: Michael
Viewers learn about how to reduce the potential repetitiveness of coding in main by developing methods to perform specific tasks for their program. Additionally, objects are introduced for the purpose of learning how to call methods in Java. Define …
This theoretical tutorial explains exceptions, reasons for exceptions, different categories of exception and exception hierarchy.

785 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