Skip to content

Instantly share code, notes, and snippets.

@ara4n
Created December 17, 2014 19:47
Show Gist options
  • Save ara4n/875b5e8b66be3617efb7 to your computer and use it in GitHub Desktop.
Save ara4n/875b5e8b66be3617efb7 to your computer and use it in GitHub Desktop.
OSX snippet for using GL to transfer full-frame video (without head-tracking) to Oculus Rift via libovr
uint8_t* EyeBuffer[2]; // raw per-eye data;
void onIdle() {
HmdFrameTiming = ovrHmd_BeginFrame(Hmd, 0);
// ...normal frame management from OculusWorldDemoApp::OnIdle goes here..
// ...and then immediately before you EndFrame:
// just transfer directly onto the eye textures
// The texture we're going to render to.
GLuint texId;
for (int i = 0; i < 2; i++) {
texId = ((ovrGLTextureData&)(EyeTexture[i])).TexId;
glBindTexture(GL_TEXTURE_2D, texId);
// Upload the current texture from EyeBuffer
glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA,
EyeTexture[i].Header.TextureSize.w,
EyeTexture[i].Header.TextureSize.h,
0, GL_RGBA, GL_UNSIGNED_BYTE, EyeBuffer[i]);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
}
ovrHmd_EndFrame(Hmd, EyeRenderPose, EyeTexture);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment