WVR_EXPORT void WVR_RenderMask(WVR_Eye eye, WVR_TextureTarget target = WVR_TextureTarget_2D)

Renders a mask to cover the pixels that will be hidden after distortion.

The mask will be drawn into the depth buffer setting near clipping distance in the z-direction. This will improve performance by letting the GPU early-reject pixels the user will never see. Called before rendering the scene texture of each eye.

API Level 1
  • eye: WVR_Eye, eye id to specify the side of scene.
  • target: WVR_TextureTarget, Specifies the target texture.

Struct and enumeration

enum WVR_Eye

The sides of target scene.

Specify the side of eye for target scene.


WVR_Eye_Left = 0

WVR_Eye_Left: Left eye id.

WVR_Eye_Right = 1

WVR_Eye_Right: Right eye id.

WVR_Eye_Both = 2

WVR_Eye_Both: Both Left and Right eye id.

How to use

Here is an example for the function:

#include <wvr/wvr_render.h>
#include <VertexArrayObject.h>
#include <Shader.h>
#include <Texture.h>
#include <GLES3/gl31.h>
#include <GLES2/gl2ext.h>

RenderTarget::RenderTarget() {

    loadShaderFromAsset("shader/vertex/vertex.glsl", "shader/fragment/fragment.glsl");

    mMatrixLocation = mShader->getUniformLocation("matrix");
    mNormalMatrixLocation = mShader->getUniformLocation("normal");
    mLightDirLocation = mShader->getUniformLocation("light_dir");

    mVAO = new VertexArrayObject(true, true);
    mTexture = Texture::loadTexture("textures/texture.jpg");


void RenderTarget::draw(const Matrix4& projection, const Matrix4& eye, const Matrix4& view, const Vector4& lightDir) {
    // Draw scene in single eye.

void RenderTarget::drawMultiView(const Matrix4 projection[2], const Matrix4 eye[2], const Matrix4& view, const Vector4& lightDir) {
    // Draw scene in multi-view mode.

bool MainApplication::initGL() {
    RenderTarget * mRenderTarget;

    mRenderTarget = new RenderTarget();

void MainApplication::renderScene(WVR_Eye nEye) {
    // Specify the RenderMask before drawing the render target via OpenGL.

    // Render target
    if (nEye == WVR_Eye_Left)
        mRenderTarget->draw(mProjectionLeft, mEyePosLeft, mHMDPose, mLightDir);
    else if (nEye == WVR_Eye_Right)
        mRenderTarget->draw(mProjectionRight, mEyePosRight, mHMDPose, mLightDir);


void MainApplication::renderSceneMultiView() {
    // Activate RenderMask in multi-view mode.
    WVR_RenderMask(WVR_Eye_Left, WVR_TextureTarget_2D_ARRAY);

    // Render target
    mRenderTarget->drawMultiView(mProjectionMultiView, mEyePosMultiView, mHMDPose, mLightDir);