|
|
NVIDIA DeepStream SDK API Reference
|
9.2 Release
|
Go to the documentation of this file.
18 #ifndef DS3D_GLPROCESS_GL_RENDER_BASE_PRIV_H
19 #define DS3D_GLPROCESS_GL_RENDER_BASE_PRIV_H
21 #include "ds3d/common/common.h"
22 #include "ds3d/common/hpp/datamap.hpp"
23 #include "ds3d/common/helper/cuda_utils.h"
24 #include "ds3d/glprocess/gl_program.h"
25 #include "ds3d/glprocess/gl_buf.h"
26 #include "ds3d/glprocess/gl_render_ctx.h"
27 #include "ds3d/glprocess/gl_cuda_utils.h"
29 namespace ds3d {
namespace gl {
143 uint32_t winW = 0, winH = 0;
154 uint32_t winW = 0, winH = 0;
172 YAML::Node node = YAML::Load(yamlStr);
173 auto yLayout = node[
"layout"];
174 auto ycolorClear = node[
"color_clear"];
176 auto yViewPos = node[
"view_position"];
177 auto yViewTarget = node[
"view_target"];
178 auto yViewUp = node[
"view_up"];
179 auto yNear = node[
"perspective_near"];
180 auto yFar = node[
"perspective_far"];
181 auto yFov = node[
"perspective_fov"];
182 auto yRatio = node[
"perspective_ratio"];
183 auto yModelMat = node[
"model_mat"];
186 auto vec = yLayout.as<std::vector<int32_t>>();
188 vec.size() == 4,
ErrCode::kConfig,
"layout must be list of [x0, y0, x1, y1]");
200 auto pos = yViewPos.as<std::vector<float>>();
207 auto target = yViewTarget.as<std::vector<float>>();
210 config.
lookat.
target = {{target[0], target[1], target[2]}};
214 auto up = yViewUp.as<std::vector<float>>();
216 config.
lookat.
up = {{up[0], up[1], up[2]}};
247 auto m4x4 = yModelMat.as<std::vector<float>>();
250 "model_mat must be a list of 16(4x4) float values");
252 for (
int r = 0; r < 4; ++r) {
254 {m4x4[r * 4], m4x4[r * 4 + 1], m4x4[r * 4 + 2], m4x4[r * 4 + 3]}};
265 glm::mat4 mat = glm::lookAt(
271 glm::mat4 mat = glm::perspective(
280 const ViewLayout& layout, uint32_t winW, uint32_t winH,
292 uint32_t&
width, uint32_t& height)
299 w = std::max<int32_t>(0, w);
300 h = std::max<int32_t>(0, h);
302 height = (uint32_t)h;
309 #endif // DS3D_GLPROCESS_GL_RENDER_BASE_PRIV_H
JDIMENSION JDIMENSION * width
ErrCode syncData() override
std::vector< vec4f > mat4f
virtual ErrCode getWindowSize(uint32_t &width, uint32_t &height)=0
vec2f xy0
lower left in viewpoint coordinates
static VertexArray * create()
ErrCode storeViewPort(const ViewLayout &layout)
static void normalizeViewPort(const ViewLayout &layout, uint32_t winW, uint32_t winH, NormalViewPort &normalizedView)
Normalized view port positon in the window in range [0, 1].
#define DS3D_FAILED_RETURN(condition, ret, fmt,...)
GuardGlWindow getWindow() override
ErrCode initBase(const BaseRenderConfig &conf)
vec2f xy1
upper right in viewpoint coordinates
static void getMVPFrom(mat4f &m, mat4f &v, mat4f &p, const BaseRenderConfig &config)
base config for all renders layout: [0, 0, 1280, 720] color_clear: True
glm::vec3 vec3ToGlm(const vec3f &m)
Ptr< VertexArray > & vao()
constexpr absl::OTABSL_OPTION_NAMESPACE_NAME::remove_reference_t< T > && move(T &&t) noexcept
bool isNear(float a, float b)
virtual ~BaseRenderPriv()=default
void initMvpFromConfig(const BaseRenderConfig &conf)
static ErrCode parseConfig(const std::string &yamlStr, BaseRenderConfig &config)
static functions for backward compatibility
ErrCode calculateViewPort(int32_t &x, int32_t &y, uint32_t &width, uint32_t &height)
Ptr< CudaStream > _cudaStream
Program * BuildProgramFromSource(const std::vector< std::string > &sources, const std::vector< GLenum > &types)
PerspectiveParam perspective
#define DS3D_ERROR_RETURN(code, fmt,...)
NormalViewPort _normalizedView
normalized viewport posion in the window
mat4f glmMat4ToDS(const glm::mat4 &m)
static void calculateViewPort(const NormalViewPort &normalizedView, uint32_t winW, uint32_t winH, int32_t &x, int32_t &y, uint32_t &width, uint32_t &height)
ErrCode buildShader(const std::vector< std::string > &scripts, const std::vector< GLenum > &types)
vec2< int32_t > xy1
buttom right in window coordinates
Ptr< Program > & shader()
layout position in window coordinates
NormalViewPort & normalizedView()
vec2< int32_t > xy0
top left in window coordinates
virtual ErrCode getFrameBufferSize(uint32_t &width, uint32_t &height)=0