…aaand add PREFIX to the freebsd makefile too
[voxelands-alt.git] / src / graphics / camera.c
blob85ef38f1b06f2e560a71b79aa1a9c44ce785f719
1 /************************************************************************
2 * camera.c
3 * voxelands - 3d voxel world sandbox game
4 * Copyright (C) Lisa 'darkrose' Milne 2016 <lisa@ltmnet.com>
6 * This program is free software: you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License as published by
8 * the Free Software Foundation, either version 3 of the License, or
9 * (at your option) any later version.
11 * This program is distributed in the hope that it will be useful, but
12 * WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
14 * See the GNU General Public License for more details.
16 * You should have received a copy of the GNU General Public License
17 * along with this program. If not, see <http://www.gnu.org/licenses/>
18 ************************************************************************/
20 #include "common.h"
21 #define _WM_EXPOSE_ALL
22 #include "wm.h"
24 static camera_t camera = {
25 0.0,
26 0.0,
27 0.0,
28 0.0,
29 0.0
32 /* move to the camera position */
33 void camera_view_matrix(matrix_t *mat)
35 matrix_init(mat);
36 matrix_rotate_deg_x(mat,camera.pitch);
37 matrix_rotate_deg_y(mat,-camera.yaw);
38 matrix_translate(mat,-camera.x, -camera.y, -camera.z);
41 /* get the camera data */
42 camera_t *camera_get()
44 return &camera;
47 /* set the position of the camera */
48 void camera_set_pos(v3_t *p)
50 camera.x = p->x;
51 camera.y = p->y;
52 camera.z = p->z;
55 /* set the yaw - y rotation - of the camera */
56 void camera_set_yaw(GLfloat yaw)
58 camera.yaw = yaw;
61 /* set the pitch - x rotation - of the camera */
62 void camera_set_pitch(GLfloat pitch)
64 camera.pitch = pitch;