Reviewed example with new maths
This commit is contained in:
parent
cbb134946c
commit
2fc7bc9504
@ -128,14 +128,15 @@ int main(void)
|
||||
// Draw
|
||||
//----------------------------------------------------------------------------------
|
||||
rlClearScreenBuffers(); // Clear current framebuffer
|
||||
|
||||
|
||||
// Draw '3D' elements in the scene
|
||||
//-----------------------------------------------
|
||||
// Calculate projection matrix (from perspective) and view matrix from camera look at
|
||||
Matrix matProj = MatrixPerspective(camera.fovy*DEG2RAD, (double)screenWidth/(double)screenHeight, 0.01, 1000.0);
|
||||
MatrixTranspose(&matProj);
|
||||
Matrix matView = MatrixLookAt(camera.position, camera.target, camera.up);
|
||||
|
||||
SetMatrixModelview(matView); // Replace internal modelview matrix by a custom one
|
||||
SetMatrixProjection(matProj); // Replace internal projection matrix by a custom one
|
||||
SetMatrixModelview(matView); // Set internal modelview matrix (default shader)
|
||||
SetMatrixProjection(matProj); // Set internal projection matrix (default shader)
|
||||
|
||||
DrawCube(cubePosition, 2.0f, 2.0f, 2.0f, RED);
|
||||
DrawCubeWires(cubePosition, 2.0f, 2.0f, 2.0f, RAYWHITE);
|
||||
@ -143,16 +144,17 @@ int main(void)
|
||||
|
||||
// NOTE: Internal buffers drawing (3D data)
|
||||
rlglDraw();
|
||||
//-----------------------------------------------
|
||||
|
||||
// Draw '2D' elements in the scene (GUI)
|
||||
//-----------------------------------------------
|
||||
#define RLGL_CREATE_MATRIX_MANUALLY
|
||||
#if defined(RLGL_CREATE_MATRIX_MANUALLY)
|
||||
matProj = MatrixOrtho(0.0, screenWidth, screenHeight, 0.0, 0.0, 1.0);
|
||||
MatrixTranspose(&matProj);
|
||||
matView = MatrixIdentity();
|
||||
|
||||
SetMatrixModelview(matView); // Replace internal modelview matrix by a custom one
|
||||
SetMatrixProjection(matProj); // Replace internal projection matrix by a custom one
|
||||
SetMatrixModelview(matView); // Set internal modelview matrix (default shader)
|
||||
SetMatrixProjection(matProj); // Set internal projection matrix (default shader)
|
||||
|
||||
#else // Let rlgl generate and multiply matrix internally
|
||||
|
||||
@ -166,6 +168,7 @@ int main(void)
|
||||
|
||||
// NOTE: Internal buffers drawing (2D data)
|
||||
rlglDraw();
|
||||
//-----------------------------------------------
|
||||
|
||||
glfwSwapBuffers(window);
|
||||
glfwPollEvents();
|
||||
|
Loading…
Reference in New Issue
Block a user