bjornblissing / osgoculusviewer

An OsgViewer with support for the Oculus Rift
Other
106 stars 67 forks source link

Fixed issue with rendering flickering on Linux #28

Closed seken closed 9 years ago

seken commented 9 years ago

On linux, with a Nvidia card, some wierd flickering occurs where ~1 in 30 frames are the first frame ever rendered, either a bug in osg or driver

bjornblissing commented 9 years ago

I have heard that other have had similar problems, even on windows. RenderToTexture cameras normally use GL_FRONT, so I really don't see why you are getting these flicker issues. I think it may be a driver related issue.

Would you mind changing your proposed code to the following code and see if that helps your situation:

GLenum buffer = gc->getTraits()->doubleBuffer ? GL_BACK : GL_FRONT;
camera->setDrawBuffer(buffer);
camera->setReadBuffer(buffer);

I would prefer to have a solution which is not platform dependent.

bjornblissing commented 9 years ago

Do you have the same problems with the osgdistortion example? Since it uses a similar camera setup, i.e. using GL_FRONT as both read and draw buffer.

perezsolerj commented 9 years ago

Hi everyone,

Same issue here on linux / nvidia, your code fixes the issue for me (both, platform dependant and not dependant). Although launching example with optirun (i'm using an nvidia optimus) also solved the issue.

bjornblissing commented 9 years ago

@perezsolerj Can you try running the osgdistortion example and see if the same error happens there?

perezsolerj commented 9 years ago

osgdistortion seems OK. no flickering.

bjornblissing commented 9 years ago

Ok, that is strange since the osgdistortion example uses that same setup for the cameras. May I ask what type of Nvidia cards it is? GeForce or Quadro?

seken commented 9 years ago

I've just run the osg distortion demo and do not have the same issue. I am using a GTX Titan Black, your code change also stops the flickering, but I cannot test on platforms other than Linux.

perezsolerj commented 9 years ago

Hi again,

using: GeForce GTX 660M

bjornblissing commented 9 years ago

Well, this seems to be a common problem on Linux and there do not seem to be any side effects of the proposed change so I will merge this latest change.