Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
V
vlc-2-2
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Redmine
Redmine
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Operations
Operations
Metrics
Environments
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
videolan
vlc-2-2
Commits
54560cc8
Commit
54560cc8
authored
Mar 18, 2014
by
Matthias Keiser
Committed by
Felix Abecassis
Mar 24, 2014
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Make opengl.c handle movie rotations.
Signed-off-by:
Felix Abecassis
<
felix.abecassis@gmail.com
>
parent
4af61938
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
97 additions
and
5 deletions
+97
-5
modules/video_output/opengl.c
modules/video_output/opengl.c
+97
-5
No files found.
modules/video_output/opengl.c
View file @
54560cc8
...
@@ -49,6 +49,7 @@
...
@@ -49,6 +49,7 @@
# define PFNGLGETATTRIBLOCATIONPROC typeof(glGetAttribLocation)*
# define PFNGLGETATTRIBLOCATIONPROC typeof(glGetAttribLocation)*
# define PFNGLVERTEXATTRIBPOINTERPROC typeof(glVertexAttribPointer)*
# define PFNGLVERTEXATTRIBPOINTERPROC typeof(glVertexAttribPointer)*
# define PFNGLENABLEVERTEXATTRIBARRAYPROC typeof(glEnableVertexAttribArray)*
# define PFNGLENABLEVERTEXATTRIBARRAYPROC typeof(glEnableVertexAttribArray)*
# define PFNGLUNIFORMMATRIX4FVPROC typeof(glUniformMatrix4fv)*
# define PFNGLUNIFORM4FVPROC typeof(glUniform4fv)*
# define PFNGLUNIFORM4FVPROC typeof(glUniform4fv)*
# define PFNGLUNIFORM4FPROC typeof(glUniform4f)*
# define PFNGLUNIFORM4FPROC typeof(glUniform4f)*
# define PFNGLUNIFORM1IPROC typeof(glUniform1i)*
# define PFNGLUNIFORM1IPROC typeof(glUniform1i)*
...
@@ -146,9 +147,10 @@ struct vout_display_opengl_t {
...
@@ -146,9 +147,10 @@ struct vout_display_opengl_t {
PFNGLVERTEXATTRIBPOINTERPROC
VertexAttribPointer
;
PFNGLVERTEXATTRIBPOINTERPROC
VertexAttribPointer
;
PFNGLENABLEVERTEXATTRIBARRAYPROC
EnableVertexAttribArray
;
PFNGLENABLEVERTEXATTRIBARRAYPROC
EnableVertexAttribArray
;
PFNGLUNIFORM4FVPROC
Uniform4fv
;
PFNGLUNIFORMMATRIX4FVPROC
UniformMatrix4fv
;
PFNGLUNIFORM4FPROC
Uniform4f
;
PFNGLUNIFORM4FVPROC
Uniform4fv
;
PFNGLUNIFORM1IPROC
Uniform1i
;
PFNGLUNIFORM4FPROC
Uniform4f
;
PFNGLUNIFORM1IPROC
Uniform1i
;
/* Shader command */
/* Shader command */
PFNGLCREATESHADERPROC
CreateShader
;
PFNGLCREATESHADERPROC
CreateShader
;
...
@@ -221,12 +223,13 @@ static void BuildVertexShader(vout_display_opengl_t *vgl,
...
@@ -221,12 +223,13 @@ static void BuildVertexShader(vout_display_opengl_t *vgl,
PRECISION
PRECISION
"varying vec4 TexCoord0,TexCoord1, TexCoord2;"
"varying vec4 TexCoord0,TexCoord1, TexCoord2;"
"attribute vec4 MultiTexCoord0,MultiTexCoord1,MultiTexCoord2;"
"attribute vec4 MultiTexCoord0,MultiTexCoord1,MultiTexCoord2;"
"attribute vec4 VertexPosition;"
"attribute vec2 VertexPosition;"
"uniform mat4 RotationMatrix;"
"void main() {"
"void main() {"
" TexCoord0 = MultiTexCoord0;"
" TexCoord0 = MultiTexCoord0;"
" TexCoord1 = MultiTexCoord1;"
" TexCoord1 = MultiTexCoord1;"
" TexCoord2 = MultiTexCoord2;"
" TexCoord2 = MultiTexCoord2;"
" gl_Position =
VertexPosition
;"
" gl_Position =
RotationMatrix * vec4(VertexPosition, 0.0, 1.0)
;"
"}"
;
"}"
;
*
shader
=
vgl
->
CreateShader
(
GL_VERTEX_SHADER
);
*
shader
=
vgl
->
CreateShader
(
GL_VERTEX_SHADER
);
...
@@ -432,6 +435,7 @@ vout_display_opengl_t *vout_display_opengl_New(video_format_t *fmt,
...
@@ -432,6 +435,7 @@ vout_display_opengl_t *vout_display_opengl_New(video_format_t *fmt,
vgl
->
GetAttribLocation
=
glGetAttribLocation
;
vgl
->
GetAttribLocation
=
glGetAttribLocation
;
vgl
->
VertexAttribPointer
=
glVertexAttribPointer
;
vgl
->
VertexAttribPointer
=
glVertexAttribPointer
;
vgl
->
EnableVertexAttribArray
=
glEnableVertexAttribArray
;
vgl
->
EnableVertexAttribArray
=
glEnableVertexAttribArray
;
vgl
->
UniformMatrix4fv
=
glUniformMatrix4fv
;
vgl
->
Uniform4fv
=
glUniform4fv
;
vgl
->
Uniform4fv
=
glUniform4fv
;
vgl
->
Uniform4f
=
glUniform4f
;
vgl
->
Uniform4f
=
glUniform4f
;
vgl
->
Uniform1i
=
glUniform1i
;
vgl
->
Uniform1i
=
glUniform1i
;
...
@@ -458,6 +462,7 @@ vout_display_opengl_t *vout_display_opengl_New(video_format_t *fmt,
...
@@ -458,6 +462,7 @@ vout_display_opengl_t *vout_display_opengl_New(video_format_t *fmt,
vgl
->
GetAttribLocation
=
(
PFNGLGETATTRIBLOCATIONPROC
)
vlc_gl_GetProcAddress
(
vgl
->
gl
,
"glGetAttribLocation"
);
vgl
->
GetAttribLocation
=
(
PFNGLGETATTRIBLOCATIONPROC
)
vlc_gl_GetProcAddress
(
vgl
->
gl
,
"glGetAttribLocation"
);
vgl
->
VertexAttribPointer
=
(
PFNGLVERTEXATTRIBPOINTERPROC
)
vlc_gl_GetProcAddress
(
vgl
->
gl
,
"glVertexAttribPointer"
);
vgl
->
VertexAttribPointer
=
(
PFNGLVERTEXATTRIBPOINTERPROC
)
vlc_gl_GetProcAddress
(
vgl
->
gl
,
"glVertexAttribPointer"
);
vgl
->
EnableVertexAttribArray
=
(
PFNGLENABLEVERTEXATTRIBARRAYPROC
)
vlc_gl_GetProcAddress
(
vgl
->
gl
,
"glEnableVertexAttribArray"
);
vgl
->
EnableVertexAttribArray
=
(
PFNGLENABLEVERTEXATTRIBARRAYPROC
)
vlc_gl_GetProcAddress
(
vgl
->
gl
,
"glEnableVertexAttribArray"
);
vgl
->
UniformMatrix4fv
=
(
PFNGLUNIFORMMATRIX4FVPROC
)
vlc_gl_GetProcAddress
(
vgl
->
gl
,
"glUniformMatrix4fv"
);
vgl
->
Uniform4fv
=
(
PFNGLUNIFORM4FVPROC
)
vlc_gl_GetProcAddress
(
vgl
->
gl
,
"glUniform4fv"
);
vgl
->
Uniform4fv
=
(
PFNGLUNIFORM4FVPROC
)
vlc_gl_GetProcAddress
(
vgl
->
gl
,
"glUniform4fv"
);
vgl
->
Uniform4f
=
(
PFNGLUNIFORM4FPROC
)
vlc_gl_GetProcAddress
(
vgl
->
gl
,
"glUniform4f"
);
vgl
->
Uniform4f
=
(
PFNGLUNIFORM4FPROC
)
vlc_gl_GetProcAddress
(
vgl
->
gl
,
"glUniform4f"
);
vgl
->
Uniform1i
=
(
PFNGLUNIFORM1IPROC
)
vlc_gl_GetProcAddress
(
vgl
->
gl
,
"glUniform1i"
);
vgl
->
Uniform1i
=
(
PFNGLUNIFORM1IPROC
)
vlc_gl_GetProcAddress
(
vgl
->
gl
,
"glUniform1i"
);
...
@@ -947,6 +952,76 @@ int vout_display_opengl_Prepare(vout_display_opengl_t *vgl,
...
@@ -947,6 +952,76 @@ int vout_display_opengl_Prepare(vout_display_opengl_t *vgl,
return
VLC_SUCCESS
;
return
VLC_SUCCESS
;
}
}
static
const
GLfloat
identity
[]
=
{
1
.
0
f
,
0
.
0
f
,
0
.
0
f
,
0
.
0
f
,
0
.
0
f
,
1
.
0
f
,
0
.
0
f
,
0
.
0
f
,
0
.
0
f
,
0
.
0
f
,
1
.
0
f
,
0
.
0
f
,
0
.
0
f
,
0
.
0
f
,
0
.
0
f
,
1
.
0
f
};
static
void
orientationTransformMatrix
(
GLfloat
matrix
[
static
16
],
video_orientation_t
orientation
)
{
memcpy
(
matrix
,
identity
,
sizeof
(
identity
));
const
int
k_cos_pi
=
-
1
;
const
int
k_cos_pi_2
=
0
;
const
int
k_cos_n_pi_2
=
0
;
const
int
k_sin_pi
=
0
;
const
int
k_sin_pi_2
=
1
;
const
int
k_sin_n_pi_2
=
-
1
;
bool
rotate
=
false
;
int
cos
=
0
,
sin
=
0
;
switch
(
orientation
)
{
case
ORIENT_ROTATED_90
:
cos
=
k_cos_pi_2
;
sin
=
k_sin_pi_2
;
rotate
=
true
;
break
;
case
ORIENT_ROTATED_180
:
cos
=
k_cos_pi
;
sin
=
k_sin_pi
;
rotate
=
true
;
break
;
case
ORIENT_ROTATED_270
:
cos
=
k_cos_n_pi_2
;
sin
=
k_sin_n_pi_2
;
rotate
=
true
;
break
;
case
ORIENT_HFLIPPED
:
matrix
[
0
*
4
+
0
]
=
-
1
;
break
;
case
ORIENT_VFLIPPED
:
matrix
[
1
*
4
+
1
]
=
-
1
;
break
;
case
ORIENT_TRANSPOSED
:
matrix
[
0
*
4
+
0
]
=
0
;
matrix
[
0
*
4
+
1
]
=
-
1
;
matrix
[
1
*
4
+
0
]
=
-
1
;
matrix
[
1
*
4
+
1
]
=
0
;
break
;
case
ORIENT_ANTI_TRANSPOSED
:
matrix
[
0
*
4
+
0
]
=
0
;
matrix
[
0
*
4
+
1
]
=
1
;
matrix
[
1
*
4
+
0
]
=
1
;
matrix
[
1
*
4
+
1
]
=
0
;
break
;
default:
break
;
}
if
(
rotate
)
{
matrix
[
0
*
4
+
0
]
=
cos
;
matrix
[
0
*
4
+
1
]
=
-
sin
;
matrix
[
1
*
4
+
0
]
=
sin
;
matrix
[
1
*
4
+
1
]
=
cos
;
}
}
#ifdef SUPPORTS_FIXED_PIPELINE
#ifdef SUPPORTS_FIXED_PIPELINE
static
void
DrawWithoutShaders
(
vout_display_opengl_t
*
vgl
,
static
void
DrawWithoutShaders
(
vout_display_opengl_t
*
vgl
,
float
*
left
,
float
*
top
,
float
*
right
,
float
*
bottom
)
float
*
left
,
float
*
top
,
float
*
right
,
float
*
bottom
)
...
@@ -965,6 +1040,13 @@ static void DrawWithoutShaders(vout_display_opengl_t *vgl,
...
@@ -965,6 +1040,13 @@ static void DrawWithoutShaders(vout_display_opengl_t *vgl,
right
[
0
],
top
[
0
]
right
[
0
],
top
[
0
]
};
};
GLfloat
transformMatrix
[
16
];
orientationTransformMatrix
(
transformMatrix
,
vgl
->
fmt
.
orientation
);
glPushMatrix
();
glMatrixMode
(
GL_MODELVIEW
);
glLoadMatrixf
(
transformMatrix
);
glColor4f
(
1
.
0
f
,
1
.
0
f
,
1
.
0
f
,
1
.
0
f
);
glColor4f
(
1
.
0
f
,
1
.
0
f
,
1
.
0
f
,
1
.
0
f
);
glEnable
(
vgl
->
tex_target
);
glEnable
(
vgl
->
tex_target
);
glActiveTexture
(
GL_TEXTURE0
+
0
);
glActiveTexture
(
GL_TEXTURE0
+
0
);
...
@@ -983,6 +1065,9 @@ static void DrawWithoutShaders(vout_display_opengl_t *vgl,
...
@@ -983,6 +1065,9 @@ static void DrawWithoutShaders(vout_display_opengl_t *vgl,
glDisableClientState
(
GL_TEXTURE_COORD_ARRAY
);
glDisableClientState
(
GL_TEXTURE_COORD_ARRAY
);
glDisableClientState
(
GL_VERTEX_ARRAY
);
glDisableClientState
(
GL_VERTEX_ARRAY
);
glDisable
(
vgl
->
tex_target
);
glDisable
(
vgl
->
tex_target
);
glPopMatrix
();
}
}
#endif
#endif
...
@@ -1014,6 +1099,9 @@ static void DrawWithShaders(vout_display_opengl_t *vgl,
...
@@ -1014,6 +1099,9 @@ static void DrawWithShaders(vout_display_opengl_t *vgl,
1
.
0
,
-
1
.
0
,
1
.
0
,
-
1
.
0
,
};
};
GLfloat
transformMatrix
[
16
];
orientationTransformMatrix
(
transformMatrix
,
vgl
->
fmt
.
orientation
);
for
(
unsigned
j
=
0
;
j
<
vgl
->
chroma
->
plane_count
;
j
++
)
{
for
(
unsigned
j
=
0
;
j
<
vgl
->
chroma
->
plane_count
;
j
++
)
{
const
GLfloat
textureCoord
[]
=
{
const
GLfloat
textureCoord
[]
=
{
left
[
j
],
top
[
j
],
left
[
j
],
top
[
j
],
...
@@ -1035,6 +1123,8 @@ static void DrawWithShaders(vout_display_opengl_t *vgl,
...
@@ -1035,6 +1123,8 @@ static void DrawWithShaders(vout_display_opengl_t *vgl,
vgl
->
EnableVertexAttribArray
(
vgl
->
GetAttribLocation
(
vgl
->
program
[
program
],
"VertexPosition"
));
vgl
->
EnableVertexAttribArray
(
vgl
->
GetAttribLocation
(
vgl
->
program
[
program
],
"VertexPosition"
));
vgl
->
VertexAttribPointer
(
vgl
->
GetAttribLocation
(
vgl
->
program
[
program
],
"VertexPosition"
),
2
,
GL_FLOAT
,
0
,
0
,
vertexCoord
);
vgl
->
VertexAttribPointer
(
vgl
->
GetAttribLocation
(
vgl
->
program
[
program
],
"VertexPosition"
),
2
,
GL_FLOAT
,
0
,
0
,
vertexCoord
);
vgl
->
UniformMatrix4fv
(
vgl
->
GetUniformLocation
(
vgl
->
program
[
program
],
"RotationMatrix"
),
1
,
GL_FALSE
,
transformMatrix
);
glDrawArrays
(
GL_TRIANGLE_STRIP
,
0
,
4
);
glDrawArrays
(
GL_TRIANGLE_STRIP
,
0
,
4
);
}
}
#endif
#endif
...
@@ -1138,6 +1228,8 @@ int vout_display_opengl_Display(vout_display_opengl_t *vgl,
...
@@ -1138,6 +1228,8 @@ int vout_display_opengl_Display(vout_display_opengl_t *vgl,
vgl
->
VertexAttribPointer
(
vgl
->
GetAttribLocation
(
vgl
->
program
[
1
],
"MultiTexCoord0"
),
2
,
GL_FLOAT
,
0
,
0
,
textureCoord
);
vgl
->
VertexAttribPointer
(
vgl
->
GetAttribLocation
(
vgl
->
program
[
1
],
"MultiTexCoord0"
),
2
,
GL_FLOAT
,
0
,
0
,
textureCoord
);
vgl
->
EnableVertexAttribArray
(
vgl
->
GetAttribLocation
(
vgl
->
program
[
1
],
"VertexPosition"
));
vgl
->
EnableVertexAttribArray
(
vgl
->
GetAttribLocation
(
vgl
->
program
[
1
],
"VertexPosition"
));
vgl
->
VertexAttribPointer
(
vgl
->
GetAttribLocation
(
vgl
->
program
[
1
],
"VertexPosition"
),
2
,
GL_FLOAT
,
0
,
0
,
vertexCoord
);
vgl
->
VertexAttribPointer
(
vgl
->
GetAttribLocation
(
vgl
->
program
[
1
],
"VertexPosition"
),
2
,
GL_FLOAT
,
0
,
0
,
vertexCoord
);
// Subpictures have the correct orientation:
vgl
->
UniformMatrix4fv
(
vgl
->
GetUniformLocation
(
vgl
->
program
[
1
],
"RotationMatrix"
),
1
,
GL_FALSE
,
identity
);
#endif
#endif
}
else
{
}
else
{
#ifdef SUPPORTS_FIXED_PIPELINE
#ifdef SUPPORTS_FIXED_PIPELINE
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment