1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
|
#pragma once
#include "mat4.h"
#include "spatial3.h"
typedef struct Camera {
Spatial3 spatial;
mat4 projection;
} Camera;
/// Create an orthographic camera.
///
/// The camera is positioned at the origin with canonical right/up/forward
/// vectors.
///
/// \param left The coordinate for the left vertical clipping plane.
/// \param right The coordinate for the right vertical clipping plane.
/// \param bottom The coordinate for the bottom horizontal clipping plane.
/// \param top The coordinate for the top horizontal clipping plane.
/// \param near The distance to the near clipping plane.
/// \param far The distance to the far clipping plane.
static inline Camera camera_orthographic(
R left, R right, R bottom, R top, R near, R far) {
return (Camera){
.spatial = spatial3_make(),
.projection = mat4_ortho(left, right, bottom, top, near, far)};
}
/// Create a perspective camera.
///
/// The camera is positioned at the origin with canonical right/up/forward
/// vectors.
///
/// \param fovy The vertical field of view angle in degrees.
/// \param aspect The aspect ratio that determines the field of view in the
/// x-direction.
/// \param near Distance to the near clipping plane.
/// \param far Distance to the far clipping plane.
static inline Camera camera_perspective(R fovy, R aspect, R near, R far) {
return (Camera){
.spatial = spatial3_make(),
.projection = mat4_perspective(fovy, aspect, near, far)};
}
|