49 lines
1.5 KiB
C++
49 lines
1.5 KiB
C++
// Copyright (C) 2022 RozK
|
|
//
|
|
// This program is free software: you can redistribute it and/or modify
|
|
// it under the terms of the GNU Affero General Public License as published by
|
|
// the Free Software Foundation, either version 3 of the License, or
|
|
// (at your option) any later version.
|
|
//
|
|
// This program is distributed in the hope that it will be useful,
|
|
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
// GNU Affero General Public License for more details.
|
|
//
|
|
// You should have received a copy of the GNU Affero General Public License
|
|
// along with this program. If not, see <http://www.gnu.org/licenses/>.
|
|
|
|
#include "render.hpp"
|
|
|
|
rk_vec3 rk_view_origin;
|
|
rk_vec3 rk_view_lookat;
|
|
rk_mat4 rk_view;
|
|
rk_mat4 rk_view_km;
|
|
|
|
float rk_projection_hfov;
|
|
float rk_projection_ratio;
|
|
float rk_projection_near;
|
|
float rk_projection_far;
|
|
rk_mat4 rk_projection;
|
|
|
|
void rk_set_projection(
|
|
float hfov,
|
|
float ratio,
|
|
float near,
|
|
float far) {
|
|
rk_projection_hfov = hfov;
|
|
rk_projection_ratio = ratio;
|
|
rk_projection_near = near;
|
|
rk_projection_far = far;
|
|
rk_projection = glm::perspectiveRH(hfov, ratio, near, far);
|
|
}
|
|
|
|
extern void rk_set_view(
|
|
rk_vec3 const & position,
|
|
rk_vec3 const & lookat) {
|
|
rk_view_origin = position;
|
|
rk_view_lookat = lookat;
|
|
rk_view = glm::lookAtRH(position, lookat, glm::vec3(0.0f, 0.0f, 1.0f));
|
|
rk_view_km = glm::lookAtRH(position * 0.001f, lookat * 0.001f, glm::vec3(0.0f, 0.0f, 1.0f));
|
|
}
|