|
|
@ -395,7 +395,7 @@ void rlLoadIdentity(void) { glLoadIdentity(); } |
|
|
|
void rlTranslatef(float x, float y, float z) { glTranslatef(x, y, z); } |
|
|
|
void rlRotatef(float angleDeg, float x, float y, float z) { glRotatef(angleDeg, x, y, z); } |
|
|
|
void rlScalef(float x, float y, float z) { glScalef(x, y, z); } |
|
|
|
void rlMultMatrixf(float *mat) { glMultMatrixf(mat); } |
|
|
|
void rlMultMatrixf(float *matf) { glMultMatrixf(matf); } |
|
|
|
|
|
|
|
#elif defined(GRAPHICS_API_OPENGL_33) || defined(GRAPHICS_API_OPENGL_ES2) |
|
|
|
|
|
|
@ -445,7 +445,6 @@ void rlLoadIdentity(void) |
|
|
|
void rlTranslatef(float x, float y, float z) |
|
|
|
{ |
|
|
|
Matrix matTranslation = MatrixTranslate(x, y, z); |
|
|
|
MatrixTranspose(&matTranslation); |
|
|
|
|
|
|
|
*currentMatrix = MatrixMultiply(*currentMatrix, matTranslation); |
|
|
|
} |
|
|
@ -458,7 +457,6 @@ void rlRotatef(float angleDeg, float x, float y, float z) |
|
|
|
Vector3 axis = (Vector3){ x, y, z }; |
|
|
|
VectorNormalize(&axis); |
|
|
|
matRotation = MatrixRotate(axis, angleDeg*DEG2RAD); |
|
|
|
MatrixTranspose(&matRotation); |
|
|
|
|
|
|
|
*currentMatrix = MatrixMultiply(*currentMatrix, matRotation); |
|
|
|
} |
|
|
@ -467,28 +465,26 @@ void rlRotatef(float angleDeg, float x, float y, float z) |
|
|
|
void rlScalef(float x, float y, float z) |
|
|
|
{ |
|
|
|
Matrix matScale = MatrixScale(x, y, z); |
|
|
|
MatrixTranspose(&matScale); |
|
|
|
|
|
|
|
*currentMatrix = MatrixMultiply(*currentMatrix, matScale); |
|
|
|
} |
|
|
|
|
|
|
|
// Multiply the current matrix by another matrix |
|
|
|
void rlMultMatrixf(float *mat) |
|
|
|
void rlMultMatrixf(float *matf) |
|
|
|
{ |
|
|
|
// Matrix creation from array |
|
|
|
Matrix mat2 = { m[0], m[1], m[2], m[3], |
|
|
|
m[4], m[5], m[6], m[7], |
|
|
|
m[8], m[9], m[10], m[11], |
|
|
|
m[12], m[13], m[14], m[15] }; |
|
|
|
Matrix mat = { matf[0], matf[4], matf[8], matf[12], |
|
|
|
matf[1], matf[5], matf[9], matf[13], |
|
|
|
matf[2], matf[6], matf[10], matf[14], |
|
|
|
matf[3], matf[7], matf[11], matf[15] }; |
|
|
|
|
|
|
|
*currentMatrix = MatrixMultiply(*currentMatrix, mat2); |
|
|
|
*currentMatrix = MatrixMultiply(*currentMatrix, mat); |
|
|
|
} |
|
|
|
|
|
|
|
// Multiply the current matrix by a perspective matrix generated by parameters |
|
|
|
void rlFrustum(double left, double right, double bottom, double top, double near, double far) |
|
|
|
{ |
|
|
|
Matrix matPerps = MatrixFrustum(left, right, bottom, top, near, far); |
|
|
|
MatrixTranspose(&matPerps); |
|
|
|
|
|
|
|
*currentMatrix = MatrixMultiply(*currentMatrix, matPerps); |
|
|
|
} |
|
|
@ -497,7 +493,6 @@ void rlFrustum(double left, double right, double bottom, double top, double near |
|
|
|
void rlOrtho(double left, double right, double bottom, double top, double near, double far) |
|
|
|
{ |
|
|
|
Matrix matOrtho = MatrixOrtho(left, right, bottom, top, near, far); |
|
|
|
MatrixTranspose(&matOrtho); |
|
|
|
|
|
|
|
*currentMatrix = MatrixMultiply(*currentMatrix, matOrtho); |
|
|
|
} |
|
|
@ -2545,7 +2540,7 @@ Texture2D GenTextureCubemap(Shader shader, Texture2D skyHDR, int size) |
|
|
|
|
|
|
|
// Create projection (transposed) and different views for each face |
|
|
|
Matrix fboProjection = MatrixPerspective(90.0*DEG2RAD, 1.0, 0.01, 1000.0); |
|
|
|
MatrixTranspose(&fboProjection); |
|
|
|
o">//MatrixTranspose(&fboProjection); |
|
|
|
Matrix fboViews[6] = { |
|
|
|
MatrixLookAt((Vector3){ 0.0f, 0.0f, 0.0f }, (Vector3){ 1.0f, 0.0f, 0.0f }, (Vector3){ 0.0f, -1.0f, 0.0f }), |
|
|
|
MatrixLookAt((Vector3){ 0.0f, 0.0f, 0.0f }, (Vector3){ -1.0f, 0.0f, 0.0f }, (Vector3){ 0.0f, -1.0f, 0.0f }), |
|
|
@ -2617,7 +2612,7 @@ Texture2D GenTextureIrradiance(Shader shader, Texture2D cubemap, int size) |
|
|
|
|
|
|
|
// Create projection (transposed) and different views for each face |
|
|
|
Matrix fboProjection = MatrixPerspective(90.0*DEG2RAD, 1.0, 0.01, 1000.0); |
|
|
|
MatrixTranspose(&fboProjection); |
|
|
|
o">//MatrixTranspose(&fboProjection); |
|
|
|
Matrix fboViews[6] = { |
|
|
|
MatrixLookAt((Vector3){ 0.0f, 0.0f, 0.0f }, (Vector3){ 1.0f, 0.0f, 0.0f }, (Vector3){ 0.0f, -1.0f, 0.0f }), |
|
|
|
MatrixLookAt((Vector3){ 0.0f, 0.0f, 0.0f }, (Vector3){ -1.0f, 0.0f, 0.0f }, (Vector3){ 0.0f, -1.0f, 0.0f }), |
|
|
@ -2693,7 +2688,7 @@ Texture2D GenTexturePrefilter(Shader shader, Texture2D cubemap, int size) |
|
|
|
|
|
|
|
// Create projection (transposed) and different views for each face |
|
|
|
Matrix fboProjection = MatrixPerspective(90.0*DEG2RAD, 1.0, 0.01, 1000.0); |
|
|
|
MatrixTranspose(&fboProjection); |
|
|
|
o">//MatrixTranspose(&fboProjection); |
|
|
|
Matrix fboViews[6] = { |
|
|
|
MatrixLookAt((Vector3){ 0.0f, 0.0f, 0.0f }, (Vector3){ 1.0f, 0.0f, 0.0f }, (Vector3){ 0.0f, -1.0f, 0.0f }), |
|
|
|
MatrixLookAt((Vector3){ 0.0f, 0.0f, 0.0f }, (Vector3){ -1.0f, 0.0f, 0.0f }, (Vector3){ 0.0f, -1.0f, 0.0f }), |
|
|
@ -2931,7 +2926,6 @@ void ToggleVrMode(void) |
|
|
|
// Reset viewport and default projection-modelview matrices |
|
|
|
rlViewport(0, 0, screenWidth, screenHeight); |
|
|
|
projection = MatrixOrtho(0, screenWidth, screenHeight, 0, 0.0f, 1.0f); |
|
|
|
MatrixTranspose(&projection); |
|
|
|
modelview = MatrixIdentity(); |
|
|
|
} |
|
|
|
else vrStereoRender = true; |
|
|
@ -3034,7 +3028,6 @@ void EndVrDrawing(void) |
|
|
|
// Reset viewport and default projection-modelview matrices |
|
|
|
rlViewport(0, 0, screenWidth, screenHeight); |
|
|
|
projection = MatrixOrtho(0, screenWidth, screenHeight, 0, 0.0f, 1.0f); |
|
|
|
MatrixTranspose(&projection); |
|
|
|
modelview = MatrixIdentity(); |
|
|
|
|
|
|
|
rlDisableDepthTest(); |
|
|
@ -3977,18 +3970,14 @@ static void SetStereoConfig(VrDeviceInfo hmd) |
|
|
|
// Fovy is normally computed with: 2*atan2(hmd.vScreenSize, 2*hmd.eyeToScreenDistance)*RAD2DEG |
|
|
|
// ...but with lens distortion it is increased (see Oculus SDK Documentation) |
|
|
|
//float fovy = 2.0f*atan2(hmd.vScreenSize*0.5f*distortionScale, hmd.eyeToScreenDistance)*RAD2DEG; // Really need distortionScale? |
|
|
|
float fovy = 2.0f*(float)atan2(hmd.vScreenSize*0.5f, hmd.eyeToScreenDistance)o">*RAD2DEG; |
|
|
|
float fovy = 2.0f*(float)atan2(hmd.vScreenSize*0.5f, hmd.eyeToScreenDistance); |
|
|
|
|
|
|
|
// Compute camera projection matrices |
|
|
|
float projOffset = 4.0f*lensShift; // Scaled to projection space coordinates [-1..1] |
|
|
|
Matrix proj = MatrixPerspective(fovyo">*DEG2RAD, aspect, 0.01, 1000.0); |
|
|
|
Matrix proj = MatrixPerspective(fovy, aspect, 0.01, 1000.0); |
|
|
|
vrConfig.eyesProjection[0] = MatrixMultiply(proj, MatrixTranslate(projOffset, 0.0f, 0.0f)); |
|
|
|
vrConfig.eyesProjection[1] = MatrixMultiply(proj, MatrixTranslate(-projOffset, 0.0f, 0.0f)); |
|
|
|
|
|
|
|
// NOTE: Projection matrices must be transposed due to raymath convention |
|
|
|
MatrixTranspose(&vrConfig.eyesProjection[0]); |
|
|
|
MatrixTranspose(&vrConfig.eyesProjection[1]); |
|
|
|
|
|
|
|
// Compute camera transformation matrices |
|
|
|
// NOTE: Camera movement might seem more natural if we model the head. |
|
|
|
// Our axis of rotation is the base of our head, so we might want to add |
|
|
|