Occulus SDL how to create the dual screen

Hello dudes,

How do I create a split screen like the Occulus Requires? using SDL 1.2 or SDL 2.0

I’m still no sure, if the screens have to be identical, or one is just slightly offset.

I’m still no sure, if the screens have to be identical, or one is just
slightly offset.

You should absolutely not make them as separate screens.

Use SDL 2.0. The Oculus SDK will tell you the desktop coordinates of the
Rift’s display…iterate through SDL’s list of displays until you find
one at those coordinates, and then make an
SDL_WINDOW_FULLSCREEN_DESKTOP|SDL_WINDOW_OPENGL window on it. That’s as
much as you specifically need SDL for: one window that covers the entire
Rift display without changing the resolution.

At that point, you will render things twice, slightly offset, but this
is all done in OpenGL. The Oculus SDK documentation spells out the
details pretty well, but it’s something like:

  • call glViewport() to draw to one half of the window
  • Set up the weird projection matrix, and render for the left eye.
  • call glViewport() to draw to the other half of the window
  • Set up the weird projection matrix, and render for the right eye.
  • Postprocess with the barrel shader (but even before you add this,
    you’d be surprised how good it looks once you get both eyes correct).
  • SDL_GL_SwapBuffers() to get it on the Rift display.
  • Repeat.

The math involved is all detailed pretty well in the SDK documentation,
and there are code samples if (like me) you struggle with math that
isn’t expressed as C++ code.

–ryan.

Also, if you’re making a Steam game, Joe Ludwig is putting together an
example of an SDL game that does this for the Steamworks SDK.On Fri, Feb 7, 2014 at 9:49 PM, Ryan C. Gordon wrote:

I’m still no sure, if the screens have to be identical, or one is just

slightly offset.

You should absolutely not make them as separate screens.

Use SDL 2.0. The Oculus SDK will tell you the desktop coordinates of the
Rift’s display…iterate through SDL’s list of displays until you find one
at those coordinates, and then make an SDL_WINDOW_FULLSCREEN_DESKTOP|SDL_WINDOW_OPENGL
window on it. That’s as much as you specifically need SDL for: one window
that covers the entire Rift display without changing the resolution.

At that point, you will render things twice, slightly offset, but this
is all done in OpenGL. The Oculus SDK documentation spells out the details
pretty well, but it’s something like:

  • call glViewport() to draw to one half of the window
  • Set up the weird projection matrix, and render for the left eye.
  • call glViewport() to draw to the other half of the window
  • Set up the weird projection matrix, and render for the right eye.
  • Postprocess with the barrel shader (but even before you add this, you’d
    be surprised how good it looks once you get both eyes correct).
  • SDL_GL_SwapBuffers() to get it on the Rift display.
  • Repeat.

The math involved is all detailed pretty well in the SDK documentation,
and there are code samples if (like me) you struggle with math that isn’t
expressed as C++ code.

–ryan.


SDL mailing list
SDL at lists.libsdl.org
http://lists.libsdl.org/listinfo.cgi/sdl-libsdl.org

I got working, used very old SDL 1.2 code

//SETUP the projection for both screens

glMatrixMode(GL_PROJECTION); // Select The Projection Matrix
glLoadIdentity(); // Reset The Projection Matrix
gluPerspective(110,(GLfloat)640/(GLfloat)800,0.1f,20000);

in the Draw Code\

for (int i = 0; i < 2; i++)
{

	if ( i == 1) //Right Side
	          glViewport(640,0,640,800);						// Reset The Current Viewport
	else if ( i == 0) //Left Side
		glViewport(0,0,640,800);

          Draw Stuff//

}
SDL_GL_SwapBuffers();

Set computer to 1280x800

I guess that’s the simplest one can go.

I suspect the IPD is off, might need to tune it, well more research. But extremely happy as the device is running at 60hz in this very simple graphic’s engine.

The majority of the Occulus demo’s have a hard time maintaining 60hz.

Thanks Very Much!

I’m only using one Matrix (complicated stuff which I’m not very a good at)
I tried popping and pushing the matrix for the right side, to rotate it slightly to the right.
I’ll have a look at the SDK show how deal with the right side. It seems like right side rotated to the right.