~vladh/peony

peony/src/cameras.hpp -rw-r--r-- 1.2 KiB
7fc9922bVlad-Stefan Harbuz changes shaders namespace into class a month ago
                                                                                
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
44
45
46
47
48
49
50
51
52
53
54
/*
  Peony Game Engine
  Copyright (C) 2020 Vlad-Stefan Harbuz <vlad@vladh.net>
  All rights reserved.
*/

#pragma once

#include "types.hpp"

namespace cameras {
  enum class CameraType {perspective, ortho};

  struct Camera {
    m4 view;
    v3 position;
    real64 pitch;
    m4 projection;
    m4 ui_projection;
    real32 exposure;
    real32 horizontal_fov;
    real32 vertical_fov;
    real32 near_clip_dist;
    real32 far_clip_dist;
    CameraType type;
    real64 yaw;
    v3 front;
    v3 up;
    real32 speed;
  };

  struct CamerasState {
    Camera camera_main;
    Camera *camera_active;
  };

  void update_matrices(
    Camera *camera, uint32 window_width, uint32 window_height
  );
  void update_ui_matrices(
    Camera *camera, uint32 window_width, uint32 window_height
  );
  void move_front_back(Camera *camera, real32 sign, real64 dt);
  void move_left_right(Camera *camera, real32 sign, real64 dt);
  void move_up_down(Camera *camera, real32 sign, real64 dt);
  void update_mouse(Camera *camera, v2 mouse_offset);
  void init(
    CamerasState *cameras_state,
    uint32 window_width,
    uint32 window_height
  );
}

using cameras::CameraType, cameras::Camera, cameras::CamerasState;