Forum Discussion
vlitomsk
11 years agoHonored Guest
LibOVR+OpenGL strange behaviour
Hello.
I'm exploring LibOVR API. I wrote app which creates grey texture and submits it to the Oculus drawing API.
But there's one strange thing: It doesn't work without creating a framebuffer object (I get black screen). Only calls to gl*Framebuffer* are THAT piece of code and cleanup code. All the references to created FBO are THAT piece of code and cleanup code.
Does anybody know, where is the trouble? What is the origin of this behaviour? (http://pastebin.com/kigH7eef)
I'm exploring LibOVR API. I wrote app which creates grey texture and submits it to the Oculus drawing API.
But there's one strange thing: It doesn't work without creating a framebuffer object (I get black screen). Only calls to gl*Framebuffer* are THAT piece of code and cleanup code. All the references to created FBO are THAT piece of code and cleanup code.
Does anybody know, where is the trouble? What is the origin of this behaviour? (http://pastebin.com/kigH7eef)
// ...
BYTE *pixels;
void initGL(void) {
/* init GLFW, GLEW...*/
glEnable(GL_TEXTURE_2D);
glGenTextures(1, &gltexture);
glBindTexture(GL_TEXTURE_2D, gltexture);
pixels = new BYTE[texW * texH * 3];
memset(pixels, 0x90, texW * texH * 3);
glTexImage2D(GL_TEXTURE_2D, 0, GL_RGB, texW, texH, 0, GL_RGB, GL_UNSIGNED_BYTE, pixels);
glBindTexture(GL_TEXTURE_2D, 0);
/* generate framebuffer */
/* THIS piece of code */
/* vvvvvvvvvvvvvvvvvv */
glGenFramebuffers(1, &fbo);
glBindFramebuffer(GL_FRAMEBUFFER, fbo);
glFramebufferTexture2D(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, GL_TEXTURE_2D, gltexture, 0);
glBindFramebuffer(GL_FRAMEBUFFER, 0);
/* ^^^^^^^^^^^^^^^^^^ */
}
/* It's standard usage */
void draw(void) {
ovrFrameTiming hmdFrameTiming = ovrHmd_BeginFrame(hmd, 0);
for (int i = 0; i < 2; ++i) {
ovrEyeType eye = hmdDesc.EyeRenderOrder[i];
ovrPosef eyePose = ovrHmd_BeginEyeRender(hmd, eye);
ovrHmd_EndEyeRender(hmd, eye, eyePose, &eyeTexture[i].Texture);
}
ovrHmd_EndFrame(hmd);
}
void initOR(void) {
// creating ovrHmd, ... ovrHmdDesc
ovrGLConfig cfg;
memset(&cfg, 0, sizeof(cfg));
memset(eyes, 0, sizeof(eyes));
cfg.OGL.Header.API = ovrRenderAPI_OpenGL;
cfg.OGL.Header.RTSize = { screenW, screenH };
cfg.OGL.Header.Multisample = 1;
cfg.OGL.Window = 0;
ovrFovPort fov[2];
// setting fov...
if (!ovrHmd_ConfigureRendering(hmd, &cfg.Config, ovrDistortionCap_TimeWarp | ovrDistortionCap_Chromatic | ovrDistortionCap_Vignette, fov, eyes)) {
MSG("Can't configure OculusRift rendering!");
exit(EXIT_FAILURE);
}
for (int i = 0; i < 2; ++i) {
eyeTexture[i].OGL.Header.API = ovrRenderAPI_OpenGL;
eyeTexture[i].OGL.Header.TextureSize = { texW, texH };
eyeTexture[i].OGL.Header.RenderViewport.Pos = { i*(screenW >> 1), 0 };
eyeTexture[i].OGL.Header.RenderViewport.Size = { screenW >> 1, screenH };
eyeTexture[i].OGL.TexId = gltexture;
}
}
// ....
1 Reply
- jhericoAdventurerYou don't show where you're activating the framebuffer or actually rendering anything, even as an ellipsis. You're also not checking to see that the framebuffer is complete (http://www.opengl.org/wiki/GLAPI/glCheckFramebufferStatus).
Quick Links
- Horizon Developer Support
- Quest User Forums
- Troubleshooting Forum for problems with a game or app
- Quest Support for problems with your device
Other Meta Support
Related Content
- 4 months ago