Reputation: 44
I'm creating a game in (modern) opengl, c++, glm, glfw and openvr.h and currently learning from provided example source code (hellovr_opengl_main.cpp). There are apis found in openvr to provide both the view and projection matrices and used in combination would replicate what your eyes would see in real life through virtual reality goggles.
So I implemented framebuffers into my opengl application and everything worked perfectly so all ok there then followed the examples and tried to access the apis from openvr.h myself, and after that failed i downright copied and pasted from their example code the entire hierarchy of everything that was relevant to this problem and called everything in the same order as they appeared from the example and that didnt work either so ive tried everything i can think of and i cant figure it out
Also i use there matrix definitions as they are until it reaches my code where i convert it to glm::mat4, but i did get the viewmatrix working w/o any modification (like column major)
glm::mat4 CMainApplication::GetCurrentViewProjectionMatrix(vr::Hmd_Eye nEye)
{
Matrix4 i;
if (nEye == vr::Eye_Left)
{
i = m_mat4ProjectionLeft * m_mat4eyePosLeft * m_mat4HMDPose;
}
else if (nEye == vr::Eye_Right)
{
i = m_mat4ProjectionRight * m_mat4eyePosRight * m_mat4HMDPose;
}
Matrix4 i2 = m_mat4eyePosRight * m_mat4HMDPose;//works!
view = glm::mat4(i2[0], i2[1], i2[2], i2[3], i2[4], i2[5], i2[6], i2[7], i2[8], i2[9],
i2[10], i2[11], i2[12], i2[13], i2[14], i2[15]);
Matrix4 i3 = m_mat4ProjectionRight;
project = glm::mat4(i3[0], i3[1], i3[2], i3[3], i3[4], i3[5], i3[6], i3[7], i3[8], i3[9],
i3[10], i3[11], i3[12], i3[13], i3[14], i3[15]);//doesnt work
project = glm::mat4(i3[0], i3[4], i3[8], i3[12], i3[1], i3[5], i3[9], i3[13], i3[2], i3[6],
i3[10], i3[14], i3[3], i3[7], i3[11], i3[15]);//row>>column //doesnt work
return glm::mat4(i[0], i[4], i[8], i[12], i[1], i[5], i[9], i[13], i[2], i[6],
i[10], i[14], i[3], i[7], i[11], i[15]);//doesnt work
return glm::mat4(i[0], i[4], i[8], i[12], i[1], i[5], i[9], i[13], i[2], i[6],
i[10], i[14], i[3], i[7], i[11], i[15]);//row>>column //doesnt work
return glm::mat4(i[12], i[13], i[14], i[15], i[4], i[5], i[6], i[7], i[8], i[9],
i[10], i[11], i[0], i[1], i[2], i[3]);//replace top w/ bottom //doesnt work
}
Upvotes: 0
Views: 543