cancel
Showing results for 
Search instead for 
Did you mean: 

Why does the VrCubeWorld_SurfaceView setup two projection matrices, but only use one?

griffin1977
Level 3
I am building a GearVR app based on the VrCubeWorld_SurfaceView example in the OVR Mobile SDK.

I noticed something weird about the app that I don't understand. In the C code the application sends two view and two projection matrices for the two eyes:

// Setup the scene matrices.
GL( glGenBuffers( 1, &scene->SceneMatrices ) );
GL( glBindBuffer( GL_UNIFORM_BUFFER, scene->SceneMatrices ) );
GL( glBufferData( GL_UNIFORM_BUFFER, 2 * sizeof( ovrMatrix4f ) /* 2 view matrices */ + 2 * sizeof( ovrMatrix4f ) /* 2 projection matrices */,
NULL, GL_STATIC_DRAW ) );
GL( glBindBuffer( GL_UNIFORM_BUFFER, 0 ) );
But the shader code only has a matrix for one projection matrix:
"uniform SceneMatrices\n"
"{\n"
" uniform mat4 ViewMatrix[NUM_VIEWS];\n"
" uniform mat4 ProjectionMatrix;\n"
"} sm;\n"
Why is this? Should I follow this model in my app? Will it effect the rendering?
1 REPLY 1

griffin1977
Level 3
That makes sense. Thanks for the clarification.