SGCT master (487fac4)
Simple Graphics Cluster Toolkit
Loading...
Searching...
No Matches
cubemap.h
Go to the documentation of this file.
1/*****************************************************************************************
2 * SGCT *
3 * Simple Graphics Cluster Toolkit *
4 * *
5 * Copyright (c) 2012-2026 *
6 * For conditions of distribution and use, see copyright notice in LICENSE.md *
7 ****************************************************************************************/
8
9#ifndef __SGCT__CUBEMAP__H__
10#define __SGCT__CUBEMAP__H__
11
12#include <sgct/sgctexports.h>
14
15#include <sgct/math.h>
16#include <sgct/shaderprogram.h>
17#include <array>
18#include <string>
19#include <vector>
20
21#ifdef SGCT_HAS_NDI
22#include <Processing.NDI.Lib.h>
23#endif // SGCT_HAS_NDI
24
25#ifdef SGCT_HAS_SPOUT
26struct SPOUTLIBRARY;
27using SPOUTHANDLE = SPOUTLIBRARY*;
28#endif // SGCT_HAS_SPOUT
29
30namespace sgct {
31
32namespace config { struct CubemapProjection; }
33class BaseViewport;
34class OffScreenBuffer;
35class User;
36class Window;
37
41class SGCT_EXPORT CubemapProjection final : public NonLinearProjection {
42public:
44 const Window& parent, User& user);
46
50 void update(const vec2& size) const override;
51
55 void render(const BaseViewport& viewport, FrustumMode frustumMode) const override;
56
60
61 void setSpoutRigOrientation(vec3 orientation);
62
63private:
64 void initTextures(unsigned int internalFormat) override;
65 void initVBO() override;
66 void initViewports() override;
67 void initShaders() override;
68 void initFBO(unsigned int internalFormat, int nSamples) override;
69
70 void renderCubemap(FrustumMode frustumMode) const override;
71
72 std::unique_ptr<OffScreenBuffer> _spoutFBO;
73
74 struct Cubeface {
75 bool enabled = true;
76 unsigned int texture = 0;
77
78#ifdef SGCT_HAS_SPOUT
79 struct {
80 SPOUTHANDLE handle = nullptr;
81 } spout;
82#endif // SGCT_HAS_SPOUT
83
84#ifdef SGCT_HAS_NDI
85 mutable struct {
86 NDIlib_send_instance_t handle = nullptr;
87 NDIlib_video_frame_v2_t videoFrame;
88 std::string name;
89 std::vector<std::byte> videoBufferPing;
90 std::vector<std::byte> videoBufferPong;
91 std::vector<std::byte>* currentVideoBuffer = nullptr;
92 } ndi;
93#endif // SGCT_HAS_NDI
94 };
95 std::array<Cubeface, 6> _cubeFaces;
96
97#ifdef SGCT_HAS_SPOUT
98 const bool _spoutEnabled;
99 const std::string _spoutName;
100#endif // SGCT_HAS_SPOUT
101
102#ifdef SGCT_HAS_NDI
103 const bool _ndiEnabled;
104 const std::string _ndiName;
105 const std::string _ndiGroups;
106#endif // SGCT_HAS_NDI
107
108 vec3 _rigOrientation = vec3{ 0.f, 0.f, 0.f };
109
110 unsigned int _vao = 0;
111 unsigned int _vbo = 0;
112 ShaderProgram _shader;
113 unsigned int _blitFbo = 0;
114};
115
116} // namespace sgct
117
118#endif // __SGCT__CUBEMAP__H__
This class holds and manages viewportdata and calculates frustums.
Definition baseviewport.h:27
void render(const BaseViewport &viewport, FrustumMode frustumMode) const override
Render the non linear projection to currently bounded FBO.
~CubemapProjection() override
void setSpoutRigOrientation(vec3 orientation)
Render the enabled faces of the cubemap.
void update(const vec2 &size) const override
Update projection when aspect ratio changes for the viewport.
CubemapProjection(const config::CubemapProjection &config, const Window &parent, User &user)
NonLinearProjection(const Window &parent)
Class for handling compiling, linking and using shader programs.
Definition shaderprogram.h:24
Helper class for setting user variables.
Definition user.h:24
Definition window.h:46
SPOUTLIBRARY * SPOUTHANDLE
Definition cubemap.h:27
Definition clustermanager.h:22
Definition actions.h:16
FrustumMode
Definition definitions.h:23
std::vector< std::byte > * currentVideoBuffer
Definition config.h:144
Definition math.h:47
Definition math.h:56