WVR_PreRenderEye

WVR_EXPORT void WVR_PreRenderEye(WVR_Eye eye, const WVR_TextureParams_t * textureParam, const WVR_RenderFoveationParams_t * foveatedParam = NULL)

Runtime do extra working on texture.

Need to be called before developer rendering any objects of scene onto texture. Failing to call this API will caused some functions are not working.

Version
API Level 3
Parameters
  • eye: WVR_Eye, eye id to specify the side of scene.
  • textureParam: pointer to struct WVR_TextureParams_t, to aggregate the name of scene texture.
  • foveatParam: pointer to struct WVR_RenderFoveationParams_t, to aggregate custom informations of foveated rendering. (optional)

How to use

Here is an example for the function:

// Must initialize render runtime once before calling all rendering-related API.
WVR_RenderInitParams_t param = {WVR_GraphicsApiType_OpenGL, WVR_RenderConfig_Default};
WVR_RenderError pError = WVR_RenderInit(&param);
if (pError != WVR_RenderError_None) {
    LOGE("Render init failed - Error[%d]", pError);
}

std::vector<FrameBufferObject*> LeftEyeFBO;
std::vector<FrameBufferObject*> RightEyeFBO;
FrameBufferObject* fbo;
uint32_t RenderWidth = 0, RenderHeight = 0;

WVR_GetRenderTargetSize(&RenderWidth, &RenderHeight);
void* mLeftEyeQ = WVR_ObtainTextureQueue(WVR_TextureTarget_2D, WVR_TextureFormat_RGBA, WVR_TextureType_UnsignedByte, RenderWidth, RenderHeight, 0);
void* mRightEyeQ = WVR_ObtainTextureQueue(WVR_TextureTarget_2D, WVR_TextureFormat_RGBA, WVR_TextureType_UnsignedByte, RenderWidth, RenderHeight, 0);

for (int i = 0; i < WVR_GetTextureQueueLength(mLeftEyeQ); i++) {
    fbo = new FrameBufferObject((int)WVR_GetTexture(mLeftEyeQ, i).id, RenderWidth, RenderHeight);
    LeftEyeFBO.push_back(fbo);
}
for (int j = 0; j < WVR_GetTextureQueueLength(mRightEyeQ); j++) {
    fbo = new FrameBufferObject((int)WVR_GetTexture(mRightEyeQ, j).id, RenderWidth, RenderHeight);
    RightEyeFBO.push_back(fbo);
}

Call WVR_PreRenderEye before rendering scene, and runtime will do some setup on texture.

// Left eye
int32_t index = WVR_GetAvailableTextureIndex(LeftEyeFBO);
WVR_TextureParams_t eyeTexture = WVR_GetTexture(LeftEyeFBO, index);
WVR_PreRenderEye(WVR_Eye_Left, &eyeTexture);

// Right eye
int32_t index =  = WVR_GetAvailableTextureIndex(RightEyeFBO);
eyeTexture = WVR_GetTexture(RightEyeFBO, index);
WVR_PreRenderEye(WVR_Eye_Right, &eyeTexture);

// Render Scene for both eyes

If need to pass different foveation parameter for frames. Create sturct WVR_RenderFoveationParams_t and put on third parameter,refer WVR_RenderFoveation