opengl: do not pass the picture_t to the renderer
[vlc.git] / modules / video_output / opengl / renderer.h
blob6e3f34b9de33703cc55eef86722c445e40335e2d
1 /*****************************************************************************
2 * renderer.h: OpenGL internal header
3 *****************************************************************************
4 * Copyright (C) 2016 VLC authors and VideoLAN
6 * This program is free software; you can redistribute it and/or modify it
7 * under the terms of the GNU Lesser General Public License as published by
8 * the Free Software Foundation; either version 2.1 of the License, or
9 * (at your option) any later version.
11 * This program is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 * GNU Lesser General Public License for more details.
16 * You should have received a copy of the GNU Lesser General Public License
17 * along with this program; if not, write to the Free Software Foundation,
18 * Inc., 51 Franklin Street, Fifth Floor, Boston MA 02110-1301, USA.
19 *****************************************************************************/
21 #ifndef VLC_GL_RENDERER_H
22 #define VLC_GL_RENDERER_H
24 #include <vlc_common.h>
25 #include <vlc_codec.h>
26 #include <vlc_opengl.h>
27 #include <vlc_plugin.h>
29 #include "gl_api.h"
30 #include "gl_common.h"
31 #include "interop.h"
32 #include "sampler.h"
34 struct pl_context;
35 struct pl_shader;
36 struct pl_shader_res;
38 /**
39 * OpenGL picture renderer
41 struct vlc_gl_renderer
43 /* Pointer to object gl, set by the caller */
44 vlc_gl_t *gl;
46 /* Set by the caller */
47 const struct vlc_gl_api *api;
48 const opengl_vtable_t *vt; /* for convenience, same as &api->vt */
50 /* True to dump shaders, set by the caller */
51 bool b_dump_shaders;
53 /* GLSL version, set by the caller. 100 for GLSL ES, 120 for desktop GLSL */
54 unsigned glsl_version;
55 /* Precision header, set by the caller. In OpenGLES, the fragment language
56 * has no default precision qualifier for floating point types. */
57 const char *glsl_precision_header;
59 GLuint program_id;
61 struct {
62 GLfloat ProjectionMatrix[16];
63 GLfloat StereoMatrix[3*3];
64 GLfloat ZoomMatrix[16];
65 GLfloat ViewMatrix[16];
66 } var;
68 struct {
69 GLint StereoMatrix;
70 GLint ProjectionMatrix;
71 GLint ViewMatrix;
72 GLint ZoomMatrix;
73 } uloc;
75 struct {
76 GLint PicCoordsIn;
77 GLint VertexPosition;
78 } aloc;
80 struct vlc_gl_sampler *sampler;
82 video_format_t fmt;
84 unsigned nb_indices;
85 GLuint vertex_buffer_object;
86 GLuint index_buffer_object;
87 GLuint texture_buffer_object;
89 /* View point */
90 vlc_viewpoint_t vp;
91 float f_teta;
92 float f_phi;
93 float f_roll;
94 float f_fovx; /* f_fovx and f_fovy are linked but we keep both */
95 float f_fovy; /* to avoid recalculating them when needed. */
96 float f_z; /* Position of the camera on the shpere radius vector */
97 float f_sar;
101 * Create a new renderer
103 * \param gl the GL context
104 * \param api the OpenGL API
105 * \param sampler the OpenGL sampler
106 * \param dump_shaders indicate if the shaders must be dumped in logs
108 struct vlc_gl_renderer *
109 vlc_gl_renderer_New(vlc_gl_t *gl, const struct vlc_gl_api *api,
110 struct vlc_gl_sampler *sampler, bool dump_shaders);
113 * Delete a renderer
115 * \param renderer the renderer
117 void
118 vlc_gl_renderer_Delete(struct vlc_gl_renderer *renderer);
121 * Draw the prepared picture
123 * \param sr the renderer
126 vlc_gl_renderer_Draw(struct vlc_gl_renderer *renderer);
129 vlc_gl_renderer_SetViewpoint(struct vlc_gl_renderer *renderer,
130 const vlc_viewpoint_t *p_vp);
132 void
133 vlc_gl_renderer_SetWindowAspectRatio(struct vlc_gl_renderer *renderer,
134 float f_sar);
136 #endif /* include-guard */