def configureEyeTextureInfo(self): """ This function creates the necessary Oculus Rift texture information structure for each eye to Allow Oculus Rift SDK to render properly """ # Create the left eye texture information structure leftEyeTexture=oculusvr.texture() leftEyeTexture.API=oculusvr.ovrRenderAPI_OpenGL leftEyeTexture.TextureSize=self.FullTextureSize leftEyeTexture.RenderViewport.Size=oculusvr.sizei(self.FullTextureSize.w/2,self.FullTextureSize.h) leftEyeTexture.RenderViewport.Pos.x=0 leftEyeTexture.RenderViewport.Pos.y=0 leftEyeTexture.TexId=self.cTextureID # Create the right eye texture information structure rightEyeTexture=oculusvr.texture() rightEyeTexture.API=oculusvr.ovrRenderAPI_OpenGL rightEyeTexture.TextureSize=self.FullTextureSize rightEyeTexture.RenderViewport.Size=oculusvr.sizei(self.FullTextureSize.w/2,self.FullTextureSize.h) rightEyeTexture.RenderViewport.Pos.x=(self.FullTextureSize.w+1)/2 rightEyeTexture.RenderViewport.Pos.y=0 rightEyeTexture.TexId=self.cTextureID # Combine left eye and right eye in a single list self.EyeTextures=[leftEyeTexture,rightEyeTexture]
def computeTextureSize(self): """ This function computes the desired texture size for the rendering texture of the Oculus Rift. We render both eyes into the same texture """ # Get the texture size for the left eye leftEyeTextureSize = oculusvr.ovrHmd_GetFovTextureSize(self.HMD, oculusvr.ovrEye_Left, self.HMDDesc.DefaultEyeFov[0], 1.0) # Get the texture size for the right eye rightEyeTextureSize = oculusvr.ovrHmd_GetFovTextureSize(self.HMD, oculusvr.ovrEye_Right, self.HMDDesc.DefaultEyeFov[1], 1.0) # Calculate the texture size for the final texture which is used for both eyes self.FullTextureSize=oculusvr.sizei() self.FullTextureSize.w=leftEyeTextureSize.w+rightEyeTextureSize.w self.FullTextureSize.h=max(leftEyeTextureSize.h,rightEyeTextureSize.h)