Commit 9ebe49cc authored by Patrik Huber's avatar Patrik Huber

Added clip_to_screen_space() to utils.hpp

Forgot to add in earlier commit - this should fix compile error.
Also added cv:: in Rasterizer to fix second compile error
parent 4d8c77f5
......@@ -45,7 +45,7 @@ public:
{
colorbuffer = cv::Mat(viewport_height, viewport_width, CV_8UC4, cv::Scalar::all(255));
depthbuffer =
std::numeric_limits<double>::max() * Mat::ones(viewport_height, viewport_width, CV_64FC1);
std::numeric_limits<double>::max() * cv::Mat::ones(viewport_height, viewport_width, CV_64FC1);
};
/**
......
......@@ -84,6 +84,14 @@ inline cv::Vec2f screen_to_clip_space(const cv::Vec2f& screen_coordinates, int s
return cv::Vec2f(x_cs, y_cs);
};
template<typename T, glm::precision P = glm::defaultp>
glm::tvec2<T, P> clip_to_screen_space(const T clip_coord_x, const T clip_coord_y, int screen_width, int screen_height) {
// Todo: See/copy notes from utils.hpp/clip_to_screen_space.
const T x_ss = (clip_coord_x + T(1)) * (screen_width / 2.0);
const T y_ss = screen_height - (clip_coord_y + T(1)) * (screen_height / 2.0); // also flip y; Qt: Origin top-left. OpenGL: bottom-left.
return glm::tvec2<T, P>(x_ss, y_ss);
};
/**
* Calculates the normal of a face (or triangle), i.e. the
* per-face normal. Return normal will be normalised.
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment