SDK 0.3.1 feedback (OpenGL)
I just wanted to give some feedback on Oculus SDK 0.3.1 in combination with OpenGL.
Despite a few problems (see below), I think the API is a step in the right direction since it's more straightforward and requires less code.
A few days ago, I started porting my codebase over from 0.2.5 to 0.3.1 and wrote down everything I noticed in the process – so forgive me if this post is a bit of a random collection of stuff.
Getting SDK rendering to work
So far, I havenot gotten SDK rendering to work. Opening the HMD and reading the sensor orientation works (with exceptions, see below). Configuring the SDK renderer doesn't return an error but calling ovrHmd_EndFrame() results in a black screen being rendered. This could very well be a problem on my side, but since there's no OpenGL sample code available, I can't really check.
Here's my setup:
1. Create a new OpenGL framebuffer object as my render target
2. Configure SDK rendering
In my rendering loop, I do the following:
3. Call ovrHmd_BeginFrame()
4. For each eye: Call ovrHmd_BeginEyeRender(), render my scene and call ovrHmd_EndEyeRender()
5. Bind FBO 0, so stuff gets drawn on the screen and not on the target FBO
6. Call ovrHmd_EndFrame()
The result is a black screen. I can see in geDebugger, that the GL calls are being sent and that the FBO's color buffer texture gets bound correctly (it contains two side-by-side views of the scene, as it should).
Did I miss something? Vertex order was the problem (see below) – thanks to jherico!
Miscellaneous Observations
Apart from the rendering problem, here are some of the things I noted:
Questions
Last but not least, some quick questions:
Despite a few problems (see below), I think the API is a step in the right direction since it's more straightforward and requires less code.
A few days ago, I started porting my codebase over from 0.2.5 to 0.3.1 and wrote down everything I noticed in the process – so forgive me if this post is a bit of a random collection of stuff.
Getting SDK rendering to work
So far, I have
Here's my setup:
1. Create a new OpenGL framebuffer object as my render target
- Color format: GL_RGB / GL_UNSIGNED_BYTE
- Depth format: GL_DEPTH24_STENCIL_8 / GL_UNSIGNED_INT
- Size is 1928x1432 for DK1 (calculation based on the SDK sample code)
2. Configure SDK rendering
- I'm setting the texture id for both eyes to the target FBO's color buffer texture id and set TextureSize and RenderViewport for each eye based on the SDK sample code
- I'm using wglGetCurrentContext() for the WglContext, wglGetCurrentDC() for the GdiDC and the HWND returned by SDL2 (info.win.window) for the Window parameter
In my rendering loop, I do the following:
3. Call ovrHmd_BeginFrame()
4. For each eye: Call ovrHmd_BeginEyeRender(), render my scene and call ovrHmd_EndEyeRender()
5. Bind FBO 0, so stuff gets drawn on the screen and not on the target FBO
6. Call ovrHmd_EndFrame()
The result is a black screen. I can see in geDebugger, that the GL calls are being sent and that the FBO's color buffer texture gets bound correctly (it contains two side-by-side views of the scene, as it should).
Miscellaneous Observations
Apart from the rendering problem, here are some of the things I noted:
- The documentation is still a bit rough (e.g. the members of Sizei and the parameters for ovrHmd_EndFrame() have changed compared to the docs). It usually helps to look at the OculusRoomTiny example next to the documentation.
- ovrHmd_EndFrame() sets glClearDepth to 0 without resetting it afterwards (hooray for geDebugger). I know saving and restoring OpenGL state can be problematic but the SDK rendering functions should at least reset any state it touches back to OpenGL defaults afterwards. Otherwise, things get unpredictable and very hard to debug.
-
So far, I haven't been able to get a usable projection matrix from ovrMatrix4f_Projection()
Fixed. Forgot to transpose the matrix.
Questions
Last but not least, some quick questions:
-
Does SDK rendering require a depth buffer to be present? Previously, I only had a depth buffer on my target FBO, but not the screen itself. I changed that now, while debugging the SDK rendering problem, but I wonder if it's needed.
Works without one, so let's restate the question: Should there be a depth buffer present (maybe for future use)? -
The new SDK docs do not mention latency tester support. Is that part not finished yet or is latency tester support automatically enabled via SDK rendering?
Latency tester automatically works when SDK rendering is enabled.
