Solved

OpenGL Double Buffering

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

Free Tool: Subnet Calculator

The subnet calculator helps you design networks by taking an IP address and network mask and returning information such as network, broadcast address, and host range.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
diffSum example 4 50
even odd program using while loop 3 60
Java syntax, or is it Selenium 6 30
hashmap order 17 36
Artificial Intelligence comes in many forms, and for game developers, Path-Finding is an important ability for making an NPC (Non-Playable Character) maneuver through terrain.  A* is a particularly easy way to approach it.  I’ll start with the algor…
Recently, in one of the tech-blogs I usually read, I saw a post about the best-selling video games through history. The first place in the list is for the classic, extremely addictive Tetris. Well, a long time ago, in a galaxy far far away, I was…
Viewers will learn about the different types of variables in Java and how to declare them. Decide the type of variable desired: Put the keyword corresponding to the type of variable in front of the variable name: Use the equal sign to assign a v…
This tutorial covers a practical example of lazy loading technique and early loading technique in a Singleton Design Pattern.

790 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