I am working on a project that uploads some rendering to a native plugin that I wrote for Unity, in order to use instances and other advanced graphical functions. I am developing it for cross-platform release, but I work with Mac, so testing is done primarily with OpenGL. At the moment, the plugin displays only a square in the center of the screen, colored with hexadecimal values. The plugin works as expected in an empty Unity project, but as soon as I include it in my Oculus project, it starts to behave erratically.
In a rift, the geometry of the plug-in draws twice, stretches once to both eyes and another time pattern only within the right eye. Also, any primitive colors that I apply to geometry are lost, and the geometry seems to capture the surrounding colors; on a black screen with red text, the geometry will be mostly black with red blood flow in line. As soon as my green area loads, the geometry drawn by the plugin will turn green.
Below is a screenshot of the geometry created in an empty Unity project where there is nothing:

And here is a screenshot of the same geometry as at the top of my Oculus Rift application:

Here the vertices that I execute are created (three coordinates and color):
Vertex verts[4] = { { -0.5f, 0.5f, 0, 0xFF0000ff }, { 0.5f, 0.5f, 0, 0xFFff0000 }, { 0.5f, -0.5f, 0, 0xFF00ff00 }, { -0.5f, -0.5f, 0, 0xFFff0000 }, };
Here's the draw function, called each frame inside the plugin:
// OpenGL case if (g_DeviceType == kGfxRendererOpenGL) { //initialize model view matrices glMatrixMode (GL_MODELVIEW); float modelMatrix[16] = { 1,0,0,0, 0,1,0,0, 0,0,1,0, 0,0,0,1, }; glLoadMatrixf (modelMatrix); //assign our matrix to the current MatrixMode //initialize projection matrix glMatrixMode (GL_PROJECTION); projectionMatrix[10] = 2.0f; //tweak projection matrix to match D3D projectionMatrix[14] = -1.0f; glLoadMatrixf (projectionMatrix); // Vertex layout glVertexPointer (3, GL_FLOAT, sizeof(verts[0]), &verts[0].x); glEnableClientState (GL_VERTEX_ARRAY); glColorPointer (4, GL_UNSIGNED_BYTE, sizeof(verts[0]), &verts[0].color); glEnableClientState (GL_COLOR_ARRAY); glDrawArrays(GL_LINE_LOOP, 0, 4); }
Any insight from experienced plugin / rift graphic encoders will be appreciated!