cancel
Showing results for 
Search instead for 
Did you mean: 

Problem with SDK 1.32 for Native windows with openGL

Martti
Honored Guest
Hi,
I get OpenGL to work but I dont know how to get the Oculus SDK 1.32 to work with OpenGL
I get a problem with 

textureSwapChain = 0;
 swap_chain_desc = {};
 swap_chain_desc.Type = ovrTexture_2D;
 swap_chain_desc.ArraySize = 1;
 swap_chain_desc.Format = OVR_FORMAT_R8G8B8A8_UNORM_SRGB;
 swap_chain_desc.Width = renderTargetSize.w;
 swap_chain_desc.Height = renderTargetSize.h;
 swap_chain_desc.MipLevels = 1;
 swap_chain_desc.SampleCount = 1;
 swap_chain_desc.StaticImage = ovrFalse;

If(ovr_CreateTextureSwapChainGL(session,&swap_chain_desc,&textureSwapChain) == ovrSuccess)

Where textureSwapChain = 0 that means NULL.

I cant get anything from the function it doesnt even pass the if statement. What is wrong?

My code is the following:


int Hmd::init_framebuffers(){

// Framebuffers

 //-----------------------------------------------
 // In order to display, it has to be "complete" (at least 1 color/depth/stencil buffer attached, 1color attachement, same number of multisamples, attachement completes)
 frameBuffer = 0;
 glGenFramebuffers(1, &frameBuffer);
 glBindFramebuffer(GL_FRAMEBUFFER, frameBuffer);
 // ---- Texture "Color Buffer"


textureSwapChain = 0;
 swap_chain_desc = {};
 swap_chain_desc.Type = ovrTexture_2D;
 swap_chain_desc.ArraySize = 1;
 swap_chain_desc.Format = OVR_FORMAT_R8G8B8A8_UNORM_SRGB;
 swap_chain_desc.Width = renderTargetSize.w;
 swap_chain_desc.Height = renderTargetSize.h;
 swap_chain_desc.MipLevels = 1;
 swap_chain_desc.SampleCount = 1;
 swap_chain_desc.StaticImage = ovrFalse;
 ovr_CreateTextureSwapChainGL(session, &swap_chain_desc, &textureSwapChain);

  
 hmdDesc = ovr_GetHmdDesc(session);
 eyeRenderDesc[0] = ovr_GetRenderDesc(session, ovrEye_Left, hmdDesc.DefaultEyeFov[0]);
 //eyeRenderDesc[1] = ovr_GetRenderDesc(session, ovrEye_Right, hmdDesc.DefaultEyeFov[1]);
 hmdToEyeViewPose[0] = eyeRenderDesc[0].HmdToEyePose;
 hmdToEyeViewPose[1] = eyeRenderDesc[1].HmdToEyePose;
 // Initialize our single full screen Fov layer.
 layer.Header.Type = ovrLayerType_EyeFov;
 layer.Header.Flags = 0;
 layer.ColorTexture[0] = textureSwapChain;
 layer.ColorTexture[1] = textureSwapChain;
 layer.Fov[0] = eyeRenderDesc[0].Fov;
 layer.Fov[1] = eyeRenderDesc[1].Fov;
 layer.Viewport[0] = OVR::Recti(0, 0, renderTargetSize.w / 2, renderTargetSize.h);
 layer.Viewport[1] = OVR::Recti(renderTargetSize.w / 2, 0, renderTargetSize.w / 2, renderTargetSize.h);

  glGenTextures(1, &renderedTex);
  ovr_GetTextureSwapChainBufferGL(session, textureSwapChain, 0, &renderedTex);
  glBindTexture(GL_TEXTURE_2D, renderedTex);
  glTexImage2D(GL_TEXTURE_2D, 0, GL_RGB, renderTargetSize.w, renderTargetSize.h, 0, GL_RGB, GL_UNSIGNED_BYTE, 0);
  glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST);
  glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST);
  glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE);
  glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE);
  glBindTexture(GL_TEXTURE_2D, 0);
  glGenRenderbuffers(1, &renderBuffer);
  glBindRenderbuffer(GL_RENDERBUFFER, renderBuffer);
  glRenderbufferStorage(GL_RENDERBUFFER, GL_DEPTH24_STENCIL8, renderTargetSize.w, renderTargetSize.h);
  // Attaching the render buffer to the framebuffer
  glFramebufferRenderbuffer(GL_FRAMEBUFFER, GL_DEPTH_STENCIL_ATTACHMENT, GL_RENDERBUFFER, renderBuffer);

  // Attaching the color buffer to the frame Buffer
  //glFramebufferTexture2D(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, GL_TEXTURE_2D, renderedTex, 0);
  glFramebufferTexture(GL_FRAMEBUFFER, GL_COLOR_ATTACHMENT0, renderedTex, 0);
 //}

 // ---- RenderBuffer
 // Render Buffer (to be able to render Depth calculation)
 
 GLenum l_GLDrawBuffers[1] = { GL_COLOR_ATTACHMENT0 };
    glDrawBuffers(1, l_GLDrawBuffers); // "1" is the size of DrawBuffers
 
 GLenum l_Check = glCheckFramebufferStatus(GL_DRAW_FRAMEBUFFER);
       if (l_Check!=GL_FRAMEBUFFER_COMPLETE)
       {
          printf("There is a problem with the FBO.\n");
          exit(199);
       }
 return 0;
}
I dont know where to initiate the ovr_CreateTextureSwapChainGL? Is it with framebuffers? how do I connect SDL2 or OpenGL 3.2 with Oculus SDK 1.32 for Native Windows?

1 ACCEPTED SOLUTION

Accepted Solutions

volgaksoy
Expert Protege
In the Oculus PC SDK download, in the samples visual studio solution you can find the OculusRoomTiny_GL sample which demonstrates how you can use OpenGL with the SDK. It's a nice little compact app that should help get a better understanding of the case you're trying to handle. The guts of the SDK related calls will be in the main.cpp file for the sample.

View solution in original post

2 REPLIES 2

volgaksoy
Expert Protege
In the Oculus PC SDK download, in the samples visual studio solution you can find the OculusRoomTiny_GL sample which demonstrates how you can use OpenGL with the SDK. It's a nice little compact app that should help get a better understanding of the case you're trying to handle. The guts of the SDK related calls will be in the main.cpp file for the sample.

Martti
Honored Guest
Thanks for the idea. I think it helps