]> git.sesse.net Git - nageru/blob - timecode_renderer.h
Fix an issue where the mixer lagging too much behind CEF would cause us to display...
[nageru] / timecode_renderer.h
1 #ifndef _TIMECODE_RENDERER_H
2 #define _TIMECODE_RENDERER_H 1
3
4 #include <memory>
5 #include <string>
6
7 #include <epoxy/gl.h>
8
9 // A class to render a simple text string onto the picture using Qt and OpenGL.
10
11 namespace movit {
12
13 class ResourcePool;
14
15 }  // namespace movit
16
17 class QImage;
18
19 class TimecodeRenderer {
20 public:
21         TimecodeRenderer(movit::ResourcePool *resource_pool, unsigned display_width, unsigned display_height);
22         ~TimecodeRenderer();
23
24         // Return a string with the current wall clock time and the
25         // logical stream time.
26         static std::string get_timecode_text(double pts, unsigned frame_num);
27
28         // The FBO is assumed to contain three outputs (Y', Cb/Cr and RGBA).
29         void render_timecode(GLuint fbo, const std::string &text);
30
31 private:
32         void render_string_to_buffer(const std::string &text);
33         void render_buffer_to_fbo(GLuint fbo);
34
35         movit::ResourcePool *resource_pool;
36         unsigned display_width, display_height, height;
37
38         GLuint vbo;  // Holds position and texcoord data.
39         GLuint tex;
40         //std::unique_ptr<unsigned char[]> pixel_buffer;
41         std::unique_ptr<QImage> image;
42
43         GLuint program_num;  // Owned by <resource_pool>.
44         GLuint texture_sampler_uniform;
45         GLuint position_attribute_index, texcoord_attribute_index;
46 };
47
48 #endif