Welcome, Guest. Please login or register. Did you miss your activation email?

Author Topic: Quad Buffering  (Read 1637 times)

0 Members and 1 Guest are viewing this topic.

fallout

  • Newbie
  • *
  • Posts: 15
    • View Profile
Quad Buffering
« on: December 09, 2012, 05:02:24 am »
I'm new to stereoscopy so I hope I make some sense.

I want to implement side-by-side stereoscopy for a project. All I know so far is that I need to create an asymmetric frustum, something like this:



It seems like sf::View should be capable of doing this, but I'm not sure how. I think I should have 2 views that sample from one window?  One is a reference view (just integer coordinates) which points at the center of the window, and a left-eye and right-eye view that is offset in their respective directions from the center view. The problem with that is that it seems a window can only set one other view with setView(...). Or can it do more?

I've been told that for this to work, the api/framework/library that I'll be using - in this case, SFML - needs to support quad buffering (as well as the video card). That would be 2 buffers, front and back, for the left and right views. However, it seems that if I'm just taking samples from one renderwindow, I'll just have to make my draw calls and then display, which is basically quad buffering, is it not? If a window can't set two views at once, then how do you ensure that the left and right buffers for both sides swap at the same time?

edit: I just tested some code and a window cannot set more than one view. So, does SFML support quad buffering or do I have to use OpenGL?
« Last Edit: December 09, 2012, 06:14:40 am by fallout »

Laurent

  • Administrator
  • Hero Member
  • *****
  • Posts: 32498
    • View Profile
    • SFML's website
    • Email
Re: Quad Buffering
« Reply #1 on: December 09, 2012, 08:56:59 am »
SFML supports none of what you describe. The first thing being perspective projections: sfml-graphics (and sf::View) are purely 2D, and what you want to do requires 3D/perspective -- look at your picture, it's not the kind of perspective that sf::View provides.
Laurent Gomila - SFML developer

Mario

  • SFML Team
  • Hero Member
  • *****
  • Posts: 879
    • View Profile
Re: Quad Buffering
« Reply #2 on: December 12, 2012, 09:26:43 pm »
You can fake the effect. I've done it in the past and it works rather well. Also you won't have to use any additional buffers or render textures (not the perfect solution, for better colors use a render texture):

  • Use "glColorMask();" to disable blue and green color channels.
  • Render your scene offsetting everything to the left or right by a few pixels based on the distance to the screen.
  • Disable the red channel and enable red and green.
  • Render the scene again, inverting the previous offsets.
  • You're done.
For simple 2D games like platformers, this won't need perspective projection, however it might look odd if you try to move things back/forth without properly adjusting their scale.