Can I just blit a texture into the Oculus backbuffer?
I'm integrating Oculus into my own OpenGL engine, and trying to figure out if this technique will work. Essentially, I'm rendering the left eye and right eye views into my own backbuffer, and then directly blitting the whole thing into the Oculus backbuffer like this (where "backbuffer" is my input texture):
// Get the render target for this frame
int currentIndex = 0;
ovr_GetTextureSwapChainCurrentIndex(mOVRSession, mOVRTextureSwapChain, ¤tIndex);
GLuint currentRenderTargetTextureId;
ovr_GetTextureSwapChainBufferGL(mOVRSession, mOVRTextureSwapChain, currentIndex, ¤tRenderTargetTextureId);
// Attach current texture to framebuffer
glBindFramebuffer(GL_DRAW_FRAMEBUFFER, mFramebufferId);
glFramebufferTexture2D(GL_DRAW_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, GL_TEXTURE_2D, currentRenderTargetTextureId, 0);
// Clear target
glClearColor(0.5f, 0.0f, 0.0f, 1.0f);
glClear(GL_COLOR_BUFFER_BIT);
// Copy input texture to framebuffer
GLuint inputFramebufferId = backbuffer->GetFrameBufferHandle();
glBindFramebuffer(GL_READ_FRAMEBUFFER, inputFramebufferId);
glBlitFramebuffer(
0, 0, mBackbufferSize.w, mBackbufferSize.h,
0, 0, mBackbufferSize.w, mBackbufferSize.h,
GL_COLOR_BUFFER_BIT, GL_NEAREST);
// Submit texture to HMD
ovr_CommitTextureSwapChain(mOVRSession, mOVRTextureSwapChain);
ovrLayerHeader* layers = &mMainLayer.Header;
ovr_SubmitFrame(mOVRSession, mCurrentFrameIndex, nullptr, &layers, 1);
When I look in the HMD, I'm finding that half of my backbuffer is present as a screen floating in space ninety degrees to the left in a black void. Which is kind of weird! So, two questions:
1. Is this possible to do at all, or is my only option getting the backbuffer from OVR and rendering my scene directly into it?
2. If this is possible, what could lead to this situation? Layer setup, perhaps? My layers are an exact copy of the eyeFov example from the SDK docs.
1. Is this possible to do at all, or is my only option getting the backbuffer from OVR and rendering my scene directly into it?
2. If this is possible, what could lead to this situation? Layer setup, perhaps? My layers are an exact copy of the eyeFov example from the SDK docs.
