|
VLC 4.0.0-dev
|
This file defines the public OpenGL picture interface. More...
Go to the source code of this file.
Data Structures | |
| struct | vlc_gl_picture |
| An OpenGL picture state, with textures and a coordinate transformation matrix. More... | |
Macros | |
| #define | MTX(ROW, COL) |
Functions | |
| static void | vlc_gl_picture_ToTexCoords (const struct vlc_gl_picture *pic, unsigned coords_count, const float *pic_coords, float *tex_coords_out) |
| Convert from picture coordinates to texture coordinates, which can be used to sample at the correct location. | |
| static void | vlc_gl_picture_ComputeDirectionMatrix (const struct vlc_gl_picture *pic, float direction[static 2 *2]) |
| Return a matrix to orient texture coordinates. | |
This file defines the public OpenGL picture interface.
A vlc_gl_picture stores the OpenGL textures and transformation matrix associated with a VLC picture, as provided by the interop/importer.
| #define MTX | ( | ROW, | |
| COL ) |
Referenced by vlc_gl_picture_ToTexCoords().
|
inlinestatic |
Return a matrix to orient texture coordinates.
This matrix is 2x2 and is stored in column-major order.
While pic_to_tex_matrix transforms any picture coordinates into texture coordinates, it may be useful for example for vertex or fragment shaders to sample one pixel to the left of the current one, or two pixels to the top. Since the input texture may be rotated or flipped, the shaders need to know in which direction is the top and in which direction is the right of the picture.
This 2x2 matrix allows to transform a 2D vector expressed in picture coordinates into a 2D vector expressed in texture coordinates.
Concretely, it contains the coordinates (U, V) of the transformed unit vectors u = / 1 \ and v = / 0 \: \ 0 / \ 1 /
/ Ux Vx \ \ Uy Vy /
It is guaranteed that:
/ 0 \ or / 0 \ or / 1 \ or / -1 \ \ -1 / \ 1 / \ 0 / \ 0 /
Therefore, there are 8 possible matrices (4 possible rotations, flipped or not).
It may theoretically change on every picture (the transform matrix provided by Android may change). If it has changed since the last picture, then pic->mtx_has_changed is true.
The direction matrix is extracted from pic->mtx:
mtx = / a b c \ \ d e f /
The last column (the offset part of the affine transformation) is discarded, and the 2 remaining column vectors are normalized to remove any scaling:
direction = / a/unorm b/vnorm \ \ d/unorm e/vnorm /
where unorm = norm( / a \ ) and vnorm = norm( / b \ ). \ d / \ e /
References vlc_gl_picture::mtx.
|
inlinestatic |
Convert from picture coordinates to texture coordinates, which can be used to sample at the correct location.
This is a equivalent to retrieve the matrix and multiply manually.
The picture and texture coords may point to the same memory, in that case the transformation is applied in place (overwriting the picture coordinates by the texture coordinates).
| picture | the OpenGL picture |
| coords_count | the number of coordinates (x,y) coordinates to convert |
| pic_coords | picture coordinates as an array of 2*coords_count floats |
| tex_coords_out | texture coordinates as an array of 2*coords_count floats |
References MTX, and vlc_gl_picture::mtx.