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
3ef9d0a7
Commit
3ef9d0a7
authored
Mar 21, 2012
by
Ilkka Ollakka
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
opengl: use vertex/texture array instead of glBegin/glEnd
parent
ea068351
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
59 additions
and
47 deletions
+59
-47
modules/video_output/opengl.c
modules/video_output/opengl.c
+59
-47
No files found.
modules/video_output/opengl.c
View file @
3ef9d0a7
...
@@ -43,7 +43,7 @@
...
@@ -43,7 +43,7 @@
# define PFNGLDELETEPROGRAMSARBPROC typeof(glDeleteProgramsARB)*
# define PFNGLDELETEPROGRAMSARBPROC typeof(glDeleteProgramsARB)*
# define PFNGLPROGRAMLOCALPARAMETER4FVARBPROC typeof(glProgramLocalParameter4fvARB)*
# define PFNGLPROGRAMLOCALPARAMETER4FVARBPROC typeof(glProgramLocalParameter4fvARB)*
# define PFNGLACTIVETEXTUREARBPROC typeof(glActiveTextureARB)*
# define PFNGLACTIVETEXTUREARBPROC typeof(glActiveTextureARB)*
# define PFNGL
MULTITEXCOORD2FARBPROC typeof(glMultiTexCoord2f
ARB)*
# define PFNGL
CLIENTACTIVETEXTUREARBPROC typeof(glClientActiveTexture
ARB)*
#endif
#endif
/* RV16 */
/* RV16 */
...
@@ -118,7 +118,7 @@ struct vout_display_opengl_t {
...
@@ -118,7 +118,7 @@ struct vout_display_opengl_t {
/* multitexture */
/* multitexture */
bool
use_multitexture
;
bool
use_multitexture
;
PFNGLACTIVETEXTUREARBPROC
ActiveTextureARB
;
PFNGLACTIVETEXTUREARBPROC
ActiveTextureARB
;
PFNGL
MULTITEXCOORD2FARBPROC
MultiTexCoord2f
ARB
;
PFNGL
CLIENTACTIVETEXTUREARBPROC
ClientActiveTexture
ARB
;
};
};
static
inline
int
GetAlignedSize
(
unsigned
size
)
static
inline
int
GetAlignedSize
(
unsigned
size
)
...
@@ -188,13 +188,13 @@ vout_display_opengl_t *vout_display_opengl_New(video_format_t *fmt,
...
@@ -188,13 +188,13 @@ vout_display_opengl_t *vout_display_opengl_New(video_format_t *fmt,
if
(
HasExtension
(
extensions
,
"GL_ARB_multitexture"
))
{
if
(
HasExtension
(
extensions
,
"GL_ARB_multitexture"
))
{
#if !defined(MACOS_OPENGL)
#if !defined(MACOS_OPENGL)
vgl
->
ActiveTextureARB
=
(
PFNGLACTIVETEXTUREARBPROC
)
vlc_gl_GetProcAddress
(
vgl
->
gl
,
"glActiveTextureARB"
);
vgl
->
ActiveTextureARB
=
(
PFNGLACTIVETEXTUREARBPROC
)
vlc_gl_GetProcAddress
(
vgl
->
gl
,
"glActiveTextureARB"
);
vgl
->
MultiTexCoord2fARB
=
(
PFNGLMULTITEXCOORD2FARBPROC
)
vlc_gl_GetProcAddress
(
vgl
->
gl
,
"glMultiTexCoord2f
ARB"
);
vgl
->
ClientActiveTextureARB
=
(
PFNGLCLIENTACTIVETEXTUREARBPROC
)
vlc_gl_GetProcAddress
(
vgl
->
gl
,
"glClientActiveTexture
ARB"
);
#else
#else
vgl
->
ActiveTextureARB
=
glActiveTextureARB
;
vgl
->
ActiveTextureARB
=
glActiveTextureARB
;
vgl
->
MultiTexCoord2fARB
=
glMultiTexCoord2f
ARB
;
vgl
->
ClientActiveTextureARB
=
glClientActiveTexture
ARB
;
#endif
#endif
supports_multitexture
=
vgl
->
ActiveTextureARB
&&
supports_multitexture
=
vgl
->
ActiveTextureARB
&&
vgl
->
MultiTexCoord2f
ARB
;
vgl
->
ClientActiveTexture
ARB
;
if
(
supports_multitexture
)
if
(
supports_multitexture
)
glGetIntegerv
(
GL_MAX_TEXTURE_UNITS_ARB
,
&
max_texture_units
);
glGetIntegerv
(
GL_MAX_TEXTURE_UNITS_ARB
,
&
max_texture_units
);
}
}
...
@@ -669,35 +669,45 @@ int vout_display_opengl_Display(vout_display_opengl_t *vgl,
...
@@ -669,35 +669,45 @@ int vout_display_opengl_Display(vout_display_opengl_t *vgl,
glTexCoordPointer
(
2
,
GL_FLOAT
,
0
,
textureCoord
);
glTexCoordPointer
(
2
,
GL_FLOAT
,
0
,
textureCoord
);
glDrawArrays
(
GL_TRIANGLE_STRIP
,
0
,
4
);
glDrawArrays
(
GL_TRIANGLE_STRIP
,
0
,
4
);
#else
for
(
unsigned
j
=
0
;
j
<
vgl
->
chroma
->
plane_count
;
j
++
)
{
if
(
vgl
->
use_multitexture
)
vgl
->
ActiveTextureARB
(
GL_TEXTURE0_ARB
+
j
);
glBindTexture
(
vgl
->
tex_target
,
vgl
->
texture
[
0
][
j
]);
}
glBegin
(
GL_POLYGON
);
glTexCoord2f
(
left
[
0
],
top
[
0
]);
glDisableClientState
(
GL_TEXTURE_COORD_ARRAY
);
for
(
unsigned
j
=
1
;
j
<
vgl
->
chroma
->
plane_count
;
j
++
)
glDisableClientState
(
GL_VERTEX_ARRAY
);
vgl
->
MultiTexCoord2fARB
(
GL_TEXTURE0_ARB
+
j
,
left
[
j
],
top
[
j
]);
#else
glVertex2f
(
-
1
.
0
,
1
.
0
);
glTexCoord2f
(
right
[
0
],
top
[
0
]);
const
GLfloat
vertexCoord
[]
=
{
for
(
unsigned
j
=
1
;
j
<
vgl
->
chroma
->
plane_count
;
j
++
)
-
1
.
0
,
1
.
0
,
vgl
->
MultiTexCoord2fARB
(
GL_TEXTURE0_ARB
+
j
,
right
[
j
],
top
[
j
]);
-
1
.
0
,
-
1
.
0
,
glVertex2f
(
1
.
0
,
1
.
0
);
1
.
0
,
1
.
0
,
1
.
0
,
-
1
.
0
,
};
glTexCoord2f
(
right
[
0
],
bottom
[
0
]);
for
(
unsigned
j
=
0
;
j
<
vgl
->
chroma
->
plane_count
;
j
++
)
for
(
unsigned
j
=
1
;
j
<
vgl
->
chroma
->
plane_count
;
j
++
)
{
vgl
->
MultiTexCoord2fARB
(
GL_TEXTURE0_ARB
+
j
,
right
[
j
],
bottom
[
j
]);
const
GLfloat
texCoord
[]
=
{
glVertex2f
(
1
.
0
,
-
1
.
0
);
left
[
j
],
top
[
j
],
left
[
j
],
bottom
[
j
],
right
[
j
],
top
[
j
],
right
[
j
],
bottom
[
j
],
};
vgl
->
ActiveTextureARB
(
GL_TEXTURE0_ARB
+
j
);
vgl
->
ClientActiveTextureARB
(
GL_TEXTURE0_ARB
+
j
);
glEnableClientState
(
GL_TEXTURE_COORD_ARRAY
);
glBindTexture
(
vgl
->
tex_target
,
vgl
->
texture
[
0
][
j
]);
glTexCoordPointer
(
2
,
GL_FLOAT
,
0
,
texCoord
);
}
glEnableClientState
(
GL_VERTEX_ARRAY
);
glVertexPointer
(
2
,
GL_FLOAT
,
0
,
vertexCoord
);
glDrawArrays
(
GL_TRIANGLE_STRIP
,
0
,
4
);
glDisableClientState
(
GL_VERTEX_ARRAY
);
for
(
int
j
=
vgl
->
chroma
->
plane_count
;
j
>=
0
;
j
--
)
{
vgl
->
ActiveTextureARB
(
GL_TEXTURE0_ARB
+
j
);
vgl
->
ClientActiveTextureARB
(
GL_TEXTURE0_ARB
+
j
);
glDisableClientState
(
GL_TEXTURE_COORD_ARRAY
);
}
glTexCoord2f
(
left
[
0
],
bottom
[
0
]);
for
(
unsigned
j
=
1
;
j
<
vgl
->
chroma
->
plane_count
;
j
++
)
vgl
->
MultiTexCoord2fARB
(
GL_TEXTURE0_ARB
+
j
,
left
[
j
],
bottom
[
j
]);
glVertex2f
(
-
1
.
0
,
-
1
.
0
);
glEnd
();
#endif
#endif
if
(
vgl
->
program
)
if
(
vgl
->
program
)
...
@@ -711,29 +721,31 @@ int vout_display_opengl_Display(vout_display_opengl_t *vgl,
...
@@ -711,29 +721,31 @@ int vout_display_opengl_Display(vout_display_opengl_t *vgl,
glEnable
(
GL_TEXTURE_2D
);
glEnable
(
GL_TEXTURE_2D
);
glEnable
(
GL_BLEND
);
glEnable
(
GL_BLEND
);
glBlendFunc
(
GL_SRC_ALPHA
,
GL_ONE_MINUS_SRC_ALPHA
);
glBlendFunc
(
GL_SRC_ALPHA
,
GL_ONE_MINUS_SRC_ALPHA
);
glEnableClientState
(
GL_VERTEX_ARRAY
);
const
GLfloat
textureCoord
[]
=
{
0
.
0
,
0
.
0
,
0
.
0
,
1
.
0
,
1
.
0
,
0
.
0
,
1
.
0
,
1
.
0
,
};
for
(
int
i
=
0
;
i
<
vgl
->
region_count
;
i
++
)
{
for
(
int
i
=
0
;
i
<
vgl
->
region_count
;
i
++
)
{
gl_region_t
*
glr
=
&
vgl
->
region
[
i
];
gl_region_t
*
glr
=
&
vgl
->
region
[
i
];
const
GLfloat
vertexCoord
[]
=
{
glr
->
left
,
glr
->
top
,
glr
->
left
,
glr
->
bottom
,
glr
->
right
,
glr
->
top
,
glr
->
right
,
glr
->
bottom
,
};
glColor4f
(
1
.
0
f
,
1
.
0
f
,
1
.
0
f
,
glr
->
alpha
);
glEnableClientState
(
GL_TEXTURE_COORD_ARRAY
);
glBindTexture
(
GL_TEXTURE_2D
,
glr
->
texture
);
glBindTexture
(
GL_TEXTURE_2D
,
glr
->
texture
);
glVertexPointer
(
2
,
GL_FLOAT
,
0
,
vertexCoord
);
glBegin
(
GL_POLYGON
);
glTexCoordPointer
(
2
,
GL_FLOAT
,
0
,
textureCoord
);
glDrawArrays
(
GL_TRIANGLE_STRIP
,
0
,
4
);
glColor4f
(
1
.
0
,
1
.
0
,
1
.
0
,
glr
->
alpha
);
glDisableClientState
(
GL_TEXTURE_COORD_ARRAY
);
glTexCoord2f
(
0
.
0
,
0
.
0
);
glVertex2f
(
glr
->
left
,
glr
->
top
);
glTexCoord2f
(
1
.
0
,
0
.
0
);
glVertex2f
(
glr
->
right
,
glr
->
top
);
glTexCoord2f
(
1
.
0
,
1
.
0
);
glVertex2f
(
glr
->
right
,
glr
->
bottom
);
glTexCoord2f
(
0
.
0
,
1
.
0
);
glVertex2f
(
glr
->
left
,
glr
->
bottom
);
glEnd
();
}
}
glDisableClientState
(
GL_VERTEX_ARRAY
);
glDisable
(
GL_BLEND
);
glDisable
(
GL_BLEND
);
glDisable
(
GL_TEXTURE_2D
);
glDisable
(
GL_TEXTURE_2D
);
#endif
#endif
...
...
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