3
\$\begingroup\$

I have this reaallly strange issue that as soon as I render to an offscreen framebuffer I am no longer able to toggle VSync while my application is running. I am using OpenTK as the opengl wrapper, but I have a strong feeling it's not related at all to OpenTK.

The odd thing is I can still turn VSync on/off during startup of the application, but not anymore while the game is running. If I temporarily redirect rendering to the default framebuffer i can also again toggle Vsync.

I can use an ugly hack to just redirect rendering to the default framebuffer, a frame later set toggle vsync mode, then redirect rendering to the offscreen framebuffer again, however I would much prefer a proper fix.

Here's some pesudo code what my code does:

Initialize 2 Framebuffers. Bind first offscreen framebuffer.
while(!exit) {
    Render opaque stuff
    Switch to second framebuffer for transparent objects
    Render transparent stuff
    Switch to first buffer
    Render transparent texture to primary buffer
    Switch to default framebuffer (default FB in write mode, first FB in readmode)
    Blit from first to default framebuffer
    Bind first offscreen FB
}

I had to use offscreen frame buffers in order to re-use the depth buffer in the transparent render pass for implementing WOIT (Weighted Blended Order Independent Transparency)

\$\endgroup\$
  • \$\begingroup\$ Providing the actual code might be a better idea, as your pseudo code may be missing what is causing the problem. Try and make as small a sample as possible that reproduces the issue. \$\endgroup\$ – William Mariager Mar 31 '16 at 11:14
  • \$\begingroup\$ "no longer" / "not anymore while the game is running" - have you reverted to an earlier version of your code where it DID work? If not that, then it must be a local OS/driver level configuration issue, so trying it on a different system might help. Otherwise you are bashing your head against a brick wall when it's not even a problem with the code. \$\endgroup\$ – Engineer Apr 2 '16 at 11:40
  • \$\begingroup\$ There is no earlier version, as soon as i implemented offscreen buffering, the problem started to appear. I then added a switch to toggle between rendering to offscreen FB or to default FB while my application is running - that lets me again set Vsync when rendering to default FB (i can literally switch between them during rendering, then switch vsync on/off and the latter only works as long as i'm not rendering offscreen) \$\endgroup\$ – Tyron Apr 2 '16 at 11:55
0
\$\begingroup\$

Oddly enough, after switching to 64bit builds this problem disappeared.

\$\endgroup\$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.