Commit 4d8c77f5 authored by Patrik Huber's avatar Patrik Huber

Fixed compile errors

- Moved divide_by_w to render_detail
- Include utils.hpp for clip_to_screen_space()
parent c7d0d5fa
...@@ -25,6 +25,7 @@ ...@@ -25,6 +25,7 @@
#include "eos/core/Mesh.hpp" #include "eos/core/Mesh.hpp"
#include "eos/render/Rasterizer.hpp" #include "eos/render/Rasterizer.hpp"
#include "eos/render/detail/Vertex.hpp" #include "eos/render/detail/Vertex.hpp"
#include "eos/render/detail/render_detail.hpp"
#include "eos/render/utils.hpp" // for Texture, potentially others #include "eos/render/utils.hpp" // for Texture, potentially others
#include "glm/mat4x4.hpp" #include "glm/mat4x4.hpp"
...@@ -52,9 +53,6 @@ namespace eos { ...@@ -52,9 +53,6 @@ namespace eos {
namespace render { namespace render {
// Forward declarations (these functions should probably be moved into detail/): // Forward declarations (these functions should probably be moved into detail/):
template <typename T, glm::precision P = glm::defaultp>
glm::tvec4<T, P> divide_by_w(const glm::tvec4<T, P>& vertex);
template <typename T, glm::precision P = glm::defaultp> template <typename T, glm::precision P = glm::defaultp>
std::vector<detail::v2::Vertex<T, P>> std::vector<detail::v2::Vertex<T, P>>
clip_polygon_to_plane_in_4d(const std::vector<detail::v2::Vertex<T, P>>& vertices, clip_polygon_to_plane_in_4d(const std::vector<detail::v2::Vertex<T, P>>& vertices,
...@@ -115,6 +113,7 @@ public: ...@@ -115,6 +113,7 @@ public:
mesh.texcoords.empty()); // same for the texcoords mesh.texcoords.empty()); // same for the texcoords
// Add another assert: If cv::Mat texture != empty (and/or texturing=true?), then we need texcoords? // Add another assert: If cv::Mat texture != empty (and/or texturing=true?), then we need texcoords?
using detail::divide_by_w;
using cv::Mat; using cv::Mat;
using std::vector; using std::vector;
...@@ -342,27 +341,6 @@ private: ...@@ -342,27 +341,6 @@ private:
VertexShaderType vertex_shader; VertexShaderType vertex_shader;
}; };
/**
* @brief Todo.
*
* Takes in clip coords? and outputs NDC.
* divides by w and outputs [x_ndc, y_ndc, z_ndc, 1/w_clip].
* The w-component is set to 1/w_clip (which is what OpenGL passes to the FragmentShader).
*
* @param[in] vertex X.
* @ return X.
*/
template <typename T, glm::precision P = glm::defaultp>
glm::tvec4<T, P> divide_by_w(const glm::tvec4<T, P>& vertex)
{
auto one_over_w = 1.0 / vertex.w;
// divide by w: (if ortho, w will just be 1)
glm::tvec4<T, P> v_ndc(vertex / vertex.w);
// Set the w coord to 1/w (i.e. 1/w_clip). This is what OpenGL passes to the FragmentShader.
v_ndc.w = one_over_w;
return v_ndc;
};
/** /**
* @brief Todo. * @brief Todo.
* *
......
...@@ -3,7 +3,7 @@ ...@@ -3,7 +3,7 @@
* *
* File: include/eos/render/detail/render_detail.hpp * File: include/eos/render/detail/render_detail.hpp
* *
* Copyright 2014, 2015 Patrik Huber * Copyright 2014-2017 Patrik Huber
* *
* Licensed under the Apache License, Version 2.0 (the "License"); * Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License. * you may not use this file except in compliance with the License.
...@@ -24,7 +24,7 @@ ...@@ -24,7 +24,7 @@
#include "eos/render/utils.hpp" #include "eos/render/utils.hpp"
#include "glm/glm.hpp" // tvec2, glm::precision, tvec3, normalize, dot, cross #include "glm/glm.hpp" // tvec2, glm::precision, tvec3, tvec4, normalize, dot, cross
#include "opencv2/core/core.hpp" #include "opencv2/core/core.hpp"
...@@ -279,6 +279,27 @@ inline std::vector<Vertex> clip_polygon_to_plane_in_4d(const std::vector<Vertex> ...@@ -279,6 +279,27 @@ inline std::vector<Vertex> clip_polygon_to_plane_in_4d(const std::vector<Vertex>
return clippedVertices; return clippedVertices;
}; };
/**
* @brief Todo.
*
* Takes in clip coords? and outputs NDC.
* divides by w and outputs [x_ndc, y_ndc, z_ndc, 1/w_clip].
* The w-component is set to 1/w_clip (which is what OpenGL passes to the FragmentShader).
*
* @param[in] vertex X.
* @ return X.
*/
template <typename T, glm::precision P = glm::defaultp>
glm::tvec4<T, P> divide_by_w(const glm::tvec4<T, P>& vertex)
{
auto one_over_w = 1.0 / vertex.w;
// divide by w: (if ortho, w will just be 1)
glm::tvec4<T, P> v_ndc(vertex / vertex.w);
// Set the w coord to 1/w (i.e. 1/w_clip). This is what OpenGL passes to the FragmentShader.
v_ndc.w = one_over_w;
return v_ndc;
};
// used only in tex2D_linear_mipmap_linear // used only in tex2D_linear_mipmap_linear
// template? // template?
inline float clamp(float x, float a, float b) inline float clamp(float x, float a, float b)
......
...@@ -26,6 +26,7 @@ ...@@ -26,6 +26,7 @@
#include "eos/render/detail/texture_extraction_detail.hpp" #include "eos/render/detail/texture_extraction_detail.hpp"
#include "eos/render/render_affine.hpp" #include "eos/render/render_affine.hpp"
#include "eos/render/detail/render_detail.hpp" #include "eos/render/detail/render_detail.hpp"
#include "eos/render/utils.hpp" // for clip_to_screen_space()
#include "eos/render/Rasterizer.hpp" #include "eos/render/Rasterizer.hpp"
#include "eos/render/FragmentShader.hpp" #include "eos/render/FragmentShader.hpp"
#include "eos/fitting/closest_edge_fitting.hpp" // for ray_triangle_intersect() #include "eos/fitting/closest_edge_fitting.hpp" // for ray_triangle_intersect()
...@@ -376,6 +377,7 @@ cv::Mat extract_texture(core::Mesh mesh, glm::mat4x4 view_model_matrix, glm::mat ...@@ -376,6 +377,7 @@ cv::Mat extract_texture(core::Mesh mesh, glm::mat4x4 view_model_matrix, glm::mat
glm::vec4 /*viewport, not needed at the moment */, cv::Mat image, glm::vec4 /*viewport, not needed at the moment */, cv::Mat image,
bool /* compute_view_angle, unused atm */, int isomap_resolution = 512) bool /* compute_view_angle, unused atm */, int isomap_resolution = 512)
{ {
using detail::divide_by_w;
using glm::vec2; using glm::vec2;
using glm::vec3; using glm::vec3;
using glm::vec4; using glm::vec4;
......
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