UltraGrid
UltraGrid Low-Latency High-Resolution Transmission System
Loading...
Searching...
No Matches
PanoramaScene Struct Reference

#include <opengl_panorama.hpp>

Collaboration diagram for PanoramaScene:
Collaboration graph

Public Member Functions

 PanoramaScene ()
 
 PanoramaScene (GlProgram program, Model model)
 
std::vector< codec_t > get_codecs ()
 
void put_frame (video_frame *f, bool pbo_frame=false)
 
void render (int width, int height)
 
void render (int width, int height, const glm::mat4 &pvMat)
 
void rotate (float dx, float dy)
 

Public Attributes

float fov = 55
 
Model model
 
GlProgram program
 
float rot_x = 0
 
float rot_y = 0
 
TripleBufferTexture tex
 
std::mutex tex_mut
 
FrameUploader uploader
 

Detailed Description

Class representing the scene to render. Contains the model and texture to be rendered. Automatically performs pixel format coversions if needed. It is possible to call put_frame() from another thread, but limitations apply

Definition at line 48 of file opengl_panorama.hpp.

Constructor & Destructor Documentation

◆ PanoramaScene() [1/2]

PanoramaScene::PanoramaScene ( )

Definition at line 76 of file opengl_panorama.cpp.

static Model get_sphere()
static const char * persp_frag_src
static const char * persp_vert_src

◆ PanoramaScene() [2/2]

PanoramaScene::PanoramaScene ( GlProgram program,
Model model )

Definition at line 79 of file opengl_panorama.cpp.

79 : program(std::move(program)),
80 model(std::move(model))
81{
83}
TripleBufferTexture tex

References TripleBufferTexture::allocateTextures(), and tex.

Here is the call graph for this function:

Member Function Documentation

◆ get_codecs()

std::vector< codec_t > PanoramaScene::get_codecs ( )
inline

Definition at line 89 of file opengl_panorama.hpp.

std::vector< codec_t > get_supported_codecs()
FrameUploader uploader

References FrameUploader::get_supported_codecs(), and uploader.

Referenced by display_panogl_get_property().

Here is the call graph for this function:

◆ put_frame()

void PanoramaScene::put_frame ( video_frame * f,
bool pbo_frame = false )

Uploads a video frame to be rendered. Can be called from other thread, but must be always called from the thread that called it the first time.

Parameters
fvideo frame to upload
pbo_frametrue if video frame contains the image data in a PBO buffer

Definition at line 121 of file opengl_panorama.cpp.

121 {
123
124 Texture *back_texture;
125 {
126 std::lock_guard<std::mutex> lock(tex_mut);
127 back_texture = &tex.get_back();
128 }
129
130 uploader.attach_dst_texture(back_texture);
131 uploader.put_frame(f, pbo_frame);
132
133 glBindTexture(GL_TEXTURE_2D, back_texture->get());
134 glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_REPEAT);
135
136 glFinish();
137
138 {
139 std::lock_guard<std::mutex> lock(tex_mut);
140 tex.swap_back();
141 }
142}
void put_frame(video_frame *f, bool pbo_frame=false)
void attach_dst_texture(Texture *tex)
GLuint get() const
#define PROFILE_FUNC

References FrameUploader::attach_dst_texture(), Texture::get(), TripleBufferTexture::get_back(), PROFILE_FUNC, FrameUploader::put_frame(), TripleBufferTexture::swap_back(), tex, tex_mut, and uploader.

Referenced by handle_user_event(), and worker().

Here is the call graph for this function:

◆ render() [1/2]

void PanoramaScene::render ( int width,
int height )

Renders the scene.

Parameters
widthWidth of result used for aspect ration correction
heightHeight of result used for aspect ration correction

Definition at line 85 of file opengl_panorama.cpp.

85 {
86 float aspect_ratio = static_cast<float>(width) / height;
87 glm::mat4 projMat = glm::perspective(glm::radians(fov),
88 aspect_ratio,
89 0.1f,
90 300.0f);
91 glm::mat4 viewMat(1.f);
92 viewMat = glm::rotate(viewMat, glm::radians(rot_y), {1.f, 0, 0});
93 viewMat = glm::rotate(viewMat, glm::radians(rot_x), {0.f, 1, 0});
94 glm::mat4 pvMat = projMat * viewMat;
95
96 render(width, height, pvMat);
97}
void render(int width, int height)

References fov, render(), rot_x, and rot_y.

Referenced by display_xrgl_run(), draw(), and render().

Here is the call graph for this function:

◆ render() [2/2]

void PanoramaScene::render ( int width,
int height,
const glm::mat4 & pvMat )

Renders the scene.

Parameters
widthWidth of result used for aspect ration correction
heightHeight of result used for aspect ration correction
pvMatcustom perspective and view Matrix to be used

Definition at line 99 of file opengl_panorama.cpp.

99 {
101
102 glUseProgram(program.get());
103 glViewport(0, 0, width, height);
104 GLuint pvLoc;
105 pvLoc = glGetUniformLocation(program.get(), "pv_mat");
106 glUniformMatrix4fv(pvLoc, 1, GL_FALSE, glm::value_ptr(pvMat));
107
108 GLuint tex_id;
109 {//lock
110 std::lock_guard<std::mutex> lock(tex_mut);
112 tex.swap_front();
113 }
114 tex_id = tex.get_front().get();
115 }
116
117 glBindTexture(GL_TEXTURE_2D, tex_id);
118 model.render();
119}
GLuint get()
void render()
bool is_new_front_available() const

References GlProgram::get(), Texture::get(), TripleBufferTexture::get_front(), TripleBufferTexture::is_new_front_available(), model, PROFILE_FUNC, program, Model::render(), TripleBufferTexture::swap_front(), tex, and tex_mut.

Here is the call graph for this function:

◆ rotate()

void PanoramaScene::rotate ( float dx,
float dy )

Rotate the view. The vertical rotation is constrained to -90 to 90 degrees.

Parameters
dxhorizontal angle to rotate by
dyvertical angle to rotate by

Definition at line 144 of file opengl_panorama.cpp.

144 {
145 rot_x -= dx;
146 rot_y -= dy;
147
148 if(rot_y > 90) rot_y = 90;
149 if(rot_y < -90) rot_y = -90;
150}

References rot_x, and rot_y.

Referenced by display_panogl_run().

Member Data Documentation

◆ fov

float PanoramaScene::fov = 55

Definition at line 99 of file opengl_panorama.hpp.

Referenced by display_panogl_run(), and render().

◆ model

Model PanoramaScene::model

Definition at line 92 of file opengl_panorama.hpp.

Referenced by render().

◆ program

GlProgram PanoramaScene::program

Definition at line 91 of file opengl_panorama.hpp.

Referenced by render().

◆ rot_x

float PanoramaScene::rot_x = 0

Definition at line 97 of file opengl_panorama.hpp.

Referenced by render(), and rotate().

◆ rot_y

float PanoramaScene::rot_y = 0

Definition at line 98 of file opengl_panorama.hpp.

Referenced by render(), and rotate().

◆ tex

TripleBufferTexture PanoramaScene::tex

Definition at line 93 of file opengl_panorama.hpp.

Referenced by PanoramaScene(), put_frame(), and render().

◆ tex_mut

std::mutex PanoramaScene::tex_mut

Definition at line 94 of file opengl_panorama.hpp.

Referenced by put_frame(), and render().

◆ uploader

FrameUploader PanoramaScene::uploader

Definition at line 96 of file opengl_panorama.hpp.

Referenced by get_codecs(), and put_frame().


The documentation for this struct was generated from the following files: