Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
V
vlc
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
Commits
f7a324a5
Commit
f7a324a5
authored
Oct 31, 2010
by
Romain Goyet
Committed by
Pierre d'Herbemont
Oct 31, 2010
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
opengl: Supports OpenGL ES.
Signed-off-by:
Pierre d'Herbemont
<
pdherbemont@free.fr
>
parent
dc3c1978
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
102 additions
and
33 deletions
+102
-33
modules/video_output/opengl.h
modules/video_output/opengl.h
+102
-33
No files found.
modules/video_output/opengl.h
View file @
f7a324a5
...
@@ -30,7 +30,16 @@
...
@@ -30,7 +30,16 @@
#include <vlc_picture_pool.h>
#include <vlc_picture_pool.h>
#include <vlc_vout_opengl.h>
#include <vlc_vout_opengl.h>
#ifdef __APPLE__
// Define USE_OPENGL_ES to the GL ES Version you want to select
#if USE_OPENGL_ES == 1
# include <OpenGLES/ES1/gl.h>
# include <OpenGLES/ES1/glext.h>
#elif USE_OPENGL_ES == 2
# include <OpenGLES/ES2/gl.h>
# include <OpenGLES/ES2/glext.h>
#elif defindef(__APPLE__)
# define MACOS_OPENGL
# include <OpenGL/gl.h>
# include <OpenGL/gl.h>
# include <OpenGL/glext.h>
# include <OpenGL/glext.h>
#else
#else
...
@@ -51,7 +60,21 @@
...
@@ -51,7 +60,21 @@
# define GL_CLAMP_TO_EDGE 0x812F
# define GL_CLAMP_TO_EDGE 0x812F
#endif
#endif
#ifdef __APPLE__
#if USE_OPENGL_ES
# define VLCGL_TARGET GL_TEXTURE_2D
# define VLCGL_RGB_FORMAT GL_RGB
# define VLCGL_RGB_TYPE GL_UNSIGNED_SHORT_5_6_5
// Use RGB with OpenGLES
# define VLCGL_FORMAT VLCGL_RGB_FORMAT
# define VLCGL_TYPE VLCGL_RGB_TYPE
# define VLCGL_TEXTURE_COUNT (1)
#elif defined(MACOS_OPENGL)
/* On OS X, use GL_TEXTURE_RECTANGLE_EXT instead of GL_TEXTURE_2D.
/* On OS X, use GL_TEXTURE_RECTANGLE_EXT instead of GL_TEXTURE_2D.
This allows sizes which are not powers of 2 */
This allows sizes which are not powers of 2 */
# define VLCGL_TARGET GL_TEXTURE_RECTANGLE_EXT
# define VLCGL_TARGET GL_TEXTURE_RECTANGLE_EXT
...
@@ -91,7 +114,7 @@ static inline int GetAlignedSize(int i_size)
...
@@ -91,7 +114,7 @@ static inline int GetAlignedSize(int i_size)
}
}
typedef
struct
{
typedef
struct
{
vout_opengl_t
*
gl
;
vout_opengl_t
*
gl
;
video_format_t
fmt
;
video_format_t
fmt
;
...
@@ -109,7 +132,7 @@ static int vout_display_opengl_Init(vout_display_opengl_t *vgl,
...
@@ -109,7 +132,7 @@ static int vout_display_opengl_Init(vout_display_opengl_t *vgl,
video_format_t
*
fmt
,
video_format_t
*
fmt
,
vout_opengl_t
*
gl
)
vout_opengl_t
*
gl
)
{
{
vgl
->
gl
=
gl
;
vgl
->
gl
=
gl
;
/* Find the chroma we will use and update fmt */
/* Find the chroma we will use and update fmt */
/* TODO: We use YCbCr on Mac which is Y422, but on OSX it seems to == YUY2. Verify */
/* TODO: We use YCbCr on Mac which is Y422, but on OSX it seems to == YUY2. Verify */
...
@@ -161,23 +184,44 @@ static int vout_display_opengl_Init(vout_display_opengl_t *vgl,
...
@@ -161,23 +184,44 @@ static int vout_display_opengl_Init(vout_display_opengl_t *vgl,
vgl
->
fmt
=
*
fmt
;
vgl
->
fmt
=
*
fmt
;
/* Texture size */
#ifdef __APPLE__
vgl
->
tex_width
=
fmt
->
i_width
;
vgl
->
tex_height
=
fmt
->
i_height
;
#else
/* A texture must have a size aligned on a power of 2 */
vgl
->
tex_width
=
GetAlignedSize
(
fmt
->
i_width
);
vgl
->
tex_height
=
GetAlignedSize
(
fmt
->
i_height
);
#endif
/* */
/* */
for
(
int
i
=
0
;
i
<
VLCGL_TEXTURE_COUNT
;
i
++
)
{
for
(
int
i
=
0
;
i
<
VLCGL_TEXTURE_COUNT
;
i
++
)
{
vgl
->
texture
[
i
]
=
0
;
vgl
->
texture
[
i
]
=
0
;
vgl
->
buffer
[
i
]
=
NULL
;
vgl
->
buffer
[
i
]
=
NULL
;
}
}
vgl
->
pool
=
NULL
;
vgl
->
pool
=
NULL
;
bool
supports_npot
=
false
;
#if USE_OPENGL_ES == 2
supports_npot
=
true
;
#elif defined(MACOS_OPENGL)
supports_npot
=
true
;
#endif
#if defined(__APPLE__) && USE_OPENGL_ES == 1
if
(
!
vout_opengl_Lock
(
vgl
->
gl
))
{
const
char
*
extensions
=
(
char
*
)
glGetString
(
GL_EXTENSIONS
);
if
(
extensions
)
{
bool
npot
=
strstr
(
extensions
,
"GL_APPLE_texture_2D_limited_npot"
)
!=
0
;
if
(
npot
)
supports_npot
=
true
;
}
vout_opengl_Unlock
(
vgl
->
gl
);
}
#endif
/* Texture size */
if
(
supports_npot
)
{
vgl
->
tex_width
=
fmt
->
i_width
;
vgl
->
tex_height
=
fmt
->
i_height
;
}
else
{
/* A texture must have a size aligned on a power of 2 */
vgl
->
tex_width
=
GetAlignedSize
(
fmt
->
i_width
);
vgl
->
tex_height
=
GetAlignedSize
(
fmt
->
i_height
);
}
/* */
/* */
if
(
!
vout_opengl_Lock
(
vgl
->
gl
))
{
if
(
!
vout_opengl_Lock
(
vgl
->
gl
))
{
...
@@ -190,8 +234,9 @@ static int vout_display_opengl_Init(vout_display_opengl_t *vgl,
...
@@ -190,8 +234,9 @@ static int vout_display_opengl_Init(vout_display_opengl_t *vgl,
vout_opengl_Unlock
(
vgl
->
gl
);
vout_opengl_Unlock
(
vgl
->
gl
);
}
}
return
VLC_SUCCESS
;
return
VLC_SUCCESS
;
}
}
static
void
vout_display_opengl_Clean
(
vout_display_opengl_t
*
vgl
)
static
void
vout_display_opengl_Clean
(
vout_display_opengl_t
*
vgl
)
{
{
/* */
/* */
...
@@ -221,18 +266,18 @@ static int vout_display_opengl_ResetTextures(vout_display_opengl_t *vgl)
...
@@ -221,18 +266,18 @@ static int vout_display_opengl_ResetTextures(vout_display_opengl_t *vgl)
for
(
int
i
=
0
;
i
<
VLCGL_TEXTURE_COUNT
;
i
++
)
{
for
(
int
i
=
0
;
i
<
VLCGL_TEXTURE_COUNT
;
i
++
)
{
glBindTexture
(
VLCGL_TARGET
,
vgl
->
texture
[
i
]);
glBindTexture
(
VLCGL_TARGET
,
vgl
->
texture
[
i
]);
#if !USE_OPENGL_ES
/* Set the texture parameters */
/* Set the texture parameters */
glTexParameterf
(
VLCGL_TARGET
,
GL_TEXTURE_PRIORITY
,
1
.
0
);
glTexParameterf
(
VLCGL_TARGET
,
GL_TEXTURE_PRIORITY
,
1
.
0
);
glTexEnvf
(
GL_TEXTURE_ENV
,
GL_TEXTURE_ENV_MODE
,
GL_MODULATE
);
glTexParameteri
(
VLCGL_TARGET
,
GL_TEXTURE_WRAP_S
,
GL_CLAMP_TO_EDGE
);
#endif
glTexParameteri
(
VLCGL_TARGET
,
GL_TEXTURE_WRAP_T
,
GL_CLAMP_TO_EDGE
);
glTexParameteri
(
VLCGL_TARGET
,
GL_TEXTURE_MAG_FILTER
,
GL_LINEAR
);
glTexParameteri
(
VLCGL_TARGET
,
GL_TEXTURE_MAG_FILTER
,
GL_LINEAR
);
glTexParameteri
(
VLCGL_TARGET
,
GL_TEXTURE_MIN_FILTER
,
GL_LINEAR
);
glTexParameteri
(
VLCGL_TARGET
,
GL_TEXTURE_MIN_FILTER
,
GL_LINEAR
);
glTexParameteri
(
VLCGL_TARGET
,
GL_TEXTURE_WRAP_S
,
GL_CLAMP_TO_EDGE
);
glTexParameteri
(
VLCGL_TARGET
,
GL_TEXTURE_WRAP_T
,
GL_CLAMP_TO_EDGE
);
glTexEnvf
(
GL_TEXTURE_ENV
,
GL_TEXTURE_ENV_MODE
,
GL_MODULATE
);
#ifdef MACOS_OPENGL
#ifdef __APPLE__
/* Tell the driver not to make a copy of the texture but to use
/* Tell the driver not to make a copy of the texture but to use
our buffer */
our buffer */
glEnable
(
GL_UNPACK_CLIENT_STORAGE_APPLE
);
glEnable
(
GL_UNPACK_CLIENT_STORAGE_APPLE
);
...
@@ -250,16 +295,18 @@ static int vout_display_opengl_ResetTextures(vout_display_opengl_t *vgl)
...
@@ -250,16 +295,18 @@ static int vout_display_opengl_ResetTextures(vout_display_opengl_t *vgl)
#endif
#endif
/* Call glTexImage2D only once, and use glTexSubImage2D later */
/* Call glTexImage2D only once, and use glTexSubImage2D later */
if
(
vgl
->
buffer
[
i
])
if
(
vgl
->
buffer
[
i
])
{
glTexImage2D
(
VLCGL_TARGET
,
0
,
3
,
vgl
->
tex_width
,
vgl
->
tex_height
,
glTexImage2D
(
VLCGL_TARGET
,
0
,
VLCGL_FORMAT
,
vgl
->
tex_width
,
0
,
VLCGL_FORMAT
,
VLCGL_TYPE
,
vgl
->
buffer
[
i
]);
vgl
->
tex_height
,
0
,
VLCGL_FORMAT
,
VLCGL_TYPE
,
vgl
->
buffer
[
i
]);
}
}
}
vout_opengl_Unlock
(
vgl
->
gl
);
vout_opengl_Unlock
(
vgl
->
gl
);
return
VLC_SUCCESS
;
return
VLC_SUCCESS
;
}
}
#ifdef
__APPLE__
#ifdef
MACOS_OPENGL
/* XXX See comment vout_display_opengl_Prepare */
/* XXX See comment vout_display_opengl_Prepare */
struct
picture_sys_t
{
struct
picture_sys_t
{
vout_display_opengl_t
*
vgl
;
vout_display_opengl_t
*
vgl
;
...
@@ -279,7 +326,6 @@ static int PictureLock(picture_t *picture)
...
@@ -279,7 +326,6 @@ static int PictureLock(picture_t *picture)
vout_display_opengl_t
*
vgl
=
picture
->
p_sys
->
vgl
;
vout_display_opengl_t
*
vgl
=
picture
->
p_sys
->
vgl
;
if
(
!
vout_opengl_Lock
(
vgl
->
gl
))
{
if
(
!
vout_opengl_Lock
(
vgl
->
gl
))
{
glBindTexture
(
VLCGL_TARGET
,
get_texture
(
picture
));
glBindTexture
(
VLCGL_TARGET
,
get_texture
(
picture
));
glTexSubImage2D
(
VLCGL_TARGET
,
0
,
0
,
0
,
glTexSubImage2D
(
VLCGL_TARGET
,
0
,
0
,
0
,
vgl
->
fmt
.
i_width
,
vgl
->
fmt
.
i_height
,
vgl
->
fmt
.
i_width
,
vgl
->
fmt
.
i_height
,
...
@@ -309,7 +355,7 @@ static picture_pool_t *vout_display_opengl_GetPool(vout_display_opengl_t *vgl)
...
@@ -309,7 +355,7 @@ static picture_pool_t *vout_display_opengl_GetPool(vout_display_opengl_t *vgl)
picture_resource_t
rsc
;
picture_resource_t
rsc
;
memset
(
&
rsc
,
0
,
sizeof
(
rsc
));
memset
(
&
rsc
,
0
,
sizeof
(
rsc
));
#ifdef
__APPLE__
#ifdef
MACOS_OPENGL
rsc
.
p_sys
=
malloc
(
sizeof
(
*
rsc
.
p_sys
));
rsc
.
p_sys
=
malloc
(
sizeof
(
*
rsc
.
p_sys
));
if
(
rsc
.
p_sys
)
if
(
rsc
.
p_sys
)
{
{
...
@@ -336,7 +382,7 @@ static picture_pool_t *vout_display_opengl_GetPool(vout_display_opengl_t *vgl)
...
@@ -336,7 +382,7 @@ static picture_pool_t *vout_display_opengl_GetPool(vout_display_opengl_t *vgl)
memset
(
&
cfg
,
0
,
sizeof
(
cfg
));
memset
(
&
cfg
,
0
,
sizeof
(
cfg
));
cfg
.
picture_count
=
i
;
cfg
.
picture_count
=
i
;
cfg
.
picture
=
picture
;
cfg
.
picture
=
picture
;
#ifdef
__APPLE__
#ifdef
MACOS_OPENGL
cfg
.
lock
=
PictureLock
;
cfg
.
lock
=
PictureLock
;
cfg
.
unlock
=
PictureUnlock
;
cfg
.
unlock
=
PictureUnlock
;
#endif
#endif
...
@@ -378,7 +424,7 @@ static int vout_display_opengl_Prepare(vout_display_opengl_t *vgl,
...
@@ -378,7 +424,7 @@ static int vout_display_opengl_Prepare(vout_display_opengl_t *vgl,
if
(
vout_opengl_Lock
(
vgl
->
gl
))
if
(
vout_opengl_Lock
(
vgl
->
gl
))
return
VLC_EGENERIC
;
return
VLC_EGENERIC
;
#ifdef
__APPLE__
#ifdef
MACOS_OPENGL
/* Bind to the texture for drawing */
/* Bind to the texture for drawing */
glBindTexture
(
VLCGL_TARGET
,
get_texture
(
picture
));
glBindTexture
(
VLCGL_TARGET
,
get_texture
(
picture
));
#else
#else
...
@@ -422,12 +468,35 @@ static int vout_display_opengl_Display(vout_display_opengl_t *vgl,
...
@@ -422,12 +468,35 @@ static int vout_display_opengl_Display(vout_display_opengl_t *vgl,
glEnable
(
VLCGL_TARGET
);
glEnable
(
VLCGL_TARGET
);
#if USE_OPENGL_ES
static
const
GLfloat
vertexCoord
[]
=
{
-
1
.
0
f
,
-
1
.
0
f
,
1
.
0
f
,
-
1
.
0
f
,
-
1
.
0
f
,
1
.
0
f
,
1
.
0
f
,
1
.
0
f
,
};
const
GLfloat
textureCoord
[
8
]
=
{
f_x
,
f_height
,
f_width
,
f_height
,
f_x
,
f_y
,
f_width
,
f_y
};
glEnableClientState
(
GL_VERTEX_ARRAY
);
glEnableClientState
(
GL_TEXTURE_COORD_ARRAY
);
glVertexPointer
(
2
,
GL_FLOAT
,
0
,
vertexCoord
);
glTexCoordPointer
(
2
,
GL_FLOAT
,
0
,
textureCoord
);
glDrawArrays
(
GL_TRIANGLE_STRIP
,
0
,
4
);
#else
glBegin
(
GL_POLYGON
);
glBegin
(
GL_POLYGON
);
glTexCoord2f
(
f_x
,
f_y
);
glVertex2f
(
-
1
.
0
,
1
.
0
);
glTexCoord2f
(
f_x
,
f_y
);
glVertex2f
(
-
1
.
0
,
1
.
0
);
glTexCoord2f
(
f_width
,
f_y
);
glVertex2f
(
1
.
0
,
1
.
0
);
glTexCoord2f
(
f_width
,
f_y
);
glVertex2f
(
1
.
0
,
1
.
0
);
glTexCoord2f
(
f_width
,
f_height
);
glVertex2f
(
1
.
0
,
-
1
.
0
);
glTexCoord2f
(
f_width
,
f_height
);
glVertex2f
(
1
.
0
,
-
1
.
0
);
glTexCoord2f
(
f_x
,
f_height
);
glVertex2f
(
-
1
.
0
,
-
1
.
0
);
glTexCoord2f
(
f_x
,
f_height
);
glVertex2f
(
-
1
.
0
,
-
1
.
0
);
glEnd
();
glEnd
();
#endif
glDisable
(
VLCGL_TARGET
);
glDisable
(
VLCGL_TARGET
);
...
...
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