diff options
| author | Ray <[email protected]> | 2021-03-23 11:51:09 +0100 |
|---|---|---|
| committer | Ray <[email protected]> | 2021-03-23 11:51:09 +0100 |
| commit | 6f5a4a935196993720e0fc5bb82098a9ad3e5c96 (patch) | |
| tree | fe32351daaf8cd3db4fa0387587482e40301c3a7 /examples/others | |
| parent | 5325d8d2bab019dece92115939932ce4440cdf19 (diff) | |
| download | raylib-6f5a4a935196993720e0fc5bb82098a9ad3e5c96.tar.gz raylib-6f5a4a935196993720e0fc5bb82098a9ad3e5c96.zip | |
REVIEWED: rlgl_standalone usage
Diffstat (limited to 'examples/others')
| -rw-r--r-- | examples/others/rlgl_standalone.c | 25 |
1 files changed, 17 insertions, 8 deletions
diff --git a/examples/others/rlgl_standalone.c b/examples/others/rlgl_standalone.c index b1e2e735..5282aaa8 100644 --- a/examples/others/rlgl_standalone.c +++ b/examples/others/rlgl_standalone.c @@ -65,6 +65,15 @@ #define RAYWHITE (Color){ 245, 245, 245, 255 } // My own White (raylib logo) #define DARKGRAY (Color){ 80, 80, 80, 255 } // Dark Gray +// Camera type, defines a camera position/orientation in 3d space +typedef struct Camera { + Vector3 position; // Camera position + Vector3 target; // Camera target it looks-at + Vector3 up; // Camera up vector (rotation over its axis) + float fovy; // Camera field-of-view apperture in Y (degrees) in perspective, used as near plane width in orthographic + int projection; // Camera projection: CAMERA_PERSPECTIVE or CAMERA_ORTHOGRAPHIC +} Camera; + //---------------------------------------------------------------------------------- // Module specific Functions Declaration //---------------------------------------------------------------------------------- @@ -170,15 +179,15 @@ int main(void) Matrix matProj = MatrixPerspective(camera.fovy*DEG2RAD, (double)screenWidth/(double)screenHeight, 0.01, 1000.0); Matrix matView = MatrixLookAt(camera.position, camera.target, camera.up); - SetMatrixModelview(matView); // Set internal modelview matrix (default shader) - SetMatrixProjection(matProj); // Set internal projection matrix (default shader) + rlSetMatrixModelview(matView); // Set internal modelview matrix (default shader) + rlSetMatrixProjection(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); DrawGrid(10, 1.0f); - // NOTE: Internal buffers drawing (3D data) - rlglDraw(); + // Draw internal render batch buffers (3D data) + rlDrawRenderBatchActive(); //----------------------------------------------- // Draw '2D' elements in the scene (GUI) @@ -188,8 +197,8 @@ int main(void) matProj = MatrixOrtho(0.0, screenWidth, screenHeight, 0.0, 0.0, 1.0); matView = MatrixIdentity(); - SetMatrixModelview(matView); // Set internal modelview matrix (default shader) - SetMatrixProjection(matProj); // Set internal projection matrix (default shader) + rlSetMatrixModelview(matView); // Set internal modelview matrix (default shader) + rlSetMatrixProjection(matProj); // Set internal projection matrix (default shader) #else // Let rlgl generate and multiply matrix internally @@ -201,8 +210,8 @@ int main(void) #endif DrawRectangleV((Vector2){ 10.0f, 10.0f }, (Vector2){ 780.0f, 20.0f }, DARKGRAY); - // NOTE: Internal buffers drawing (2D data) - rlglDraw(); + // Draw internal render batch buffers (3D data) + rlDrawRenderBatchActive(); //----------------------------------------------- glfwSwapBuffers(window); |
