Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Q
qgroundcontrol
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Valentin Platzgummer
qgroundcontrol
Commits
8983c746
Commit
8983c746
authored
Oct 21, 2015
by
Gus Grubba
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Fixing OpenGL issues for Windows (Video Streaming)
parent
77be5c4b
Changes
3
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
135 additions
and
96 deletions
+135
-96
qtvideosinkdelegate.cpp
...treaming/gstqtvideosink/delegates/qtvideosinkdelegate.cpp
+10
-7
openglsurfacepainter.cpp
...treaming/gstqtvideosink/painters/openglsurfacepainter.cpp
+87
-68
videomaterial.cpp
src/VideoStreaming/gstqtvideosink/painters/videomaterial.cpp
+38
-21
No files found.
src/VideoStreaming/gstqtvideosink/delegates/qtvideosinkdelegate.cpp
View file @
8983c746
...
...
@@ -27,6 +27,7 @@
#include <QStack>
#include <QPainter>
#include <QOpenGLFunctions_2_0>
QtVideoSinkDelegate
::
QtVideoSinkDelegate
(
GstElement
*
sink
,
QObject
*
parent
)
:
BaseDelegate
(
sink
,
parent
)
...
...
@@ -137,20 +138,22 @@ void QtVideoSinkDelegate::setGLContext(QGLContext *context)
if
(
m_glContext
)
{
m_glContext
->
makeCurrent
();
const
QByteArray
extensions
(
reinterpret_cast
<
const
char
*>
(
glGetString
(
GL_EXTENSIONS
)));
GST_LOG_OBJECT
(
m_sink
,
"Available GL extensions: %s"
,
extensions
.
constData
());
QOpenGLFunctions_2_0
*
funcs
=
QOpenGLContext
::
currentContext
()
->
versionFunctions
<
QOpenGLFunctions_2_0
>
();
if
(
funcs
)
{
const
QByteArray
extensions
(
reinterpret_cast
<
const
char
*>
(
funcs
->
glGetString
(
GL_EXTENSIONS
)));
GST_LOG_OBJECT
(
m_sink
,
"Available GL extensions: %s"
,
extensions
.
constData
());
#ifndef QT_OPENGL_ES
if
(
extensions
.
contains
(
"ARB_fragment_program"
))
m_supportedPainters
|=
ArbFp
;
if
(
extensions
.
contains
(
"ARB_fragment_program"
))
m_supportedPainters
|=
ArbFp
;
#endif
#ifndef QT_OPENGL_ES_2
if
(
QGLShaderProgram
::
hasOpenGLShaderPrograms
(
m_glContext
)
if
(
QGLShaderProgram
::
hasOpenGLShaderPrograms
(
m_glContext
)
&&
extensions
.
contains
(
"ARB_shader_objects"
))
#endif
m_supportedPainters
|=
Glsl
;
m_supportedPainters
|=
Glsl
;
}
}
GST_LOG_OBJECT
(
m_sink
,
"Done setting GL context. m_supportedPainters=%x"
,
(
int
)
m_supportedPainters
);
...
...
src/VideoStreaming/gstqtvideosink/painters/openglsurfacepainter.cpp
View file @
8983c746
This diff is collapsed.
Click to expand it.
src/VideoStreaming/gstqtvideosink/painters/videomaterial.cpp
View file @
8983c746
...
...
@@ -26,7 +26,7 @@
#include <qmath.h>
#include <QOpenGLContext>
#include <QOpenGLFunctions>
#include <QOpenGLFunctions
_2_0
>
#include <QtQuick/QSGMaterialShader>
static
const
char
*
const
qtvideosink_glsl_vertexShader
=
...
...
@@ -256,7 +256,13 @@ VideoMaterial::VideoMaterial()
VideoMaterial
::~
VideoMaterial
()
{
if
(
!
m_textureSize
.
isEmpty
())
glDeleteTextures
(
m_textureCount
,
m_textureIds
);
{
QOpenGLFunctions_2_0
*
funcs
=
QOpenGLContext
::
currentContext
()
->
versionFunctions
<
QOpenGLFunctions_2_0
>
();
if
(
funcs
)
{
funcs
->
glDeleteTextures
(
m_textureCount
,
m_textureIds
);
}
}
gst_buffer_replace
(
&
m_frame
,
NULL
);
}
...
...
@@ -323,9 +329,13 @@ void VideoMaterial::initYuv420PTextureInfo(bool uvSwapped, const QSize &size)
void
VideoMaterial
::
init
(
GstVideoColorMatrix
colorMatrixType
)
{
glGenTextures
(
m_textureCount
,
m_textureIds
);
m_colorMatrixType
=
colorMatrixType
;
updateColors
(
0
,
0
,
0
,
0
);
QOpenGLFunctions_2_0
*
funcs
=
QOpenGLContext
::
currentContext
()
->
versionFunctions
<
QOpenGLFunctions_2_0
>
();
if
(
funcs
)
{
funcs
->
glGenTextures
(
m_textureCount
,
m_textureIds
);
m_colorMatrixType
=
colorMatrixType
;
updateColors
(
0
,
0
,
0
,
0
);
}
}
void
VideoMaterial
::
setCurrentFrame
(
GstBuffer
*
buffer
)
...
...
@@ -411,7 +421,10 @@ void VideoMaterial::updateColors(int brightness, int contrast, int hue, int satu
void
VideoMaterial
::
bind
()
{
QOpenGLFunctions
*
functions
=
QOpenGLContext
::
currentContext
()
->
functions
();
QOpenGLFunctions_2_0
*
funcs
=
QOpenGLContext
::
currentContext
()
->
versionFunctions
<
QOpenGLFunctions_2_0
>
();
if
(
!
funcs
)
return
;
GstBuffer
*
frame
=
NULL
;
m_frameMutex
.
lock
();
...
...
@@ -422,28 +435,32 @@ void VideoMaterial::bind()
if
(
frame
)
{
GstMapInfo
info
;
gst_buffer_map
(
frame
,
&
info
,
GST_MAP_READ
);
func
tion
s
->
glActiveTexture
(
GL_TEXTURE1
);
funcs
->
glActiveTexture
(
GL_TEXTURE1
);
bindTexture
(
1
,
info
.
data
);
func
tion
s
->
glActiveTexture
(
GL_TEXTURE2
);
funcs
->
glActiveTexture
(
GL_TEXTURE2
);
bindTexture
(
2
,
info
.
data
);
func
tion
s
->
glActiveTexture
(
GL_TEXTURE0
);
// Finish with 0 as default texture unit
funcs
->
glActiveTexture
(
GL_TEXTURE0
);
// Finish with 0 as default texture unit
bindTexture
(
0
,
info
.
data
);
gst_buffer_unmap
(
frame
,
&
info
);
gst_buffer_unref
(
frame
);
}
else
{
func
tion
s
->
glActiveTexture
(
GL_TEXTURE1
);
glBindTexture
(
GL_TEXTURE_2D
,
m_textureIds
[
1
]);
func
tion
s
->
glActiveTexture
(
GL_TEXTURE2
);
glBindTexture
(
GL_TEXTURE_2D
,
m_textureIds
[
2
]);
func
tion
s
->
glActiveTexture
(
GL_TEXTURE0
);
// Finish with 0 as default texture unit
glBindTexture
(
GL_TEXTURE_2D
,
m_textureIds
[
0
]);
funcs
->
glActiveTexture
(
GL_TEXTURE1
);
funcs
->
glBindTexture
(
GL_TEXTURE_2D
,
m_textureIds
[
1
]);
funcs
->
glActiveTexture
(
GL_TEXTURE2
);
funcs
->
glBindTexture
(
GL_TEXTURE_2D
,
m_textureIds
[
2
]);
funcs
->
glActiveTexture
(
GL_TEXTURE0
);
// Finish with 0 as default texture unit
funcs
->
glBindTexture
(
GL_TEXTURE_2D
,
m_textureIds
[
0
]);
}
}
void
VideoMaterial
::
bindTexture
(
int
i
,
const
quint8
*
data
)
{
glBindTexture
(
GL_TEXTURE_2D
,
m_textureIds
[
i
]);
glTexImage2D
(
QOpenGLFunctions_2_0
*
funcs
=
QOpenGLContext
::
currentContext
()
->
versionFunctions
<
QOpenGLFunctions_2_0
>
();
if
(
!
funcs
)
return
;
funcs
->
glBindTexture
(
GL_TEXTURE_2D
,
m_textureIds
[
i
]);
funcs
->
glTexImage2D
(
GL_TEXTURE_2D
,
0
,
m_textureInternalFormat
,
...
...
@@ -453,9 +470,9 @@ void VideoMaterial::bindTexture(int i, const quint8 *data)
m_textureFormat
,
m_textureType
,
data
+
m_textureOffsets
[
i
]);
glTexParameteri
(
GL_TEXTURE_2D
,
GL_TEXTURE_MAG_FILTER
,
GL_LINEAR
);
glTexParameteri
(
GL_TEXTURE_2D
,
GL_TEXTURE_MIN_FILTER
,
GL_LINEAR
);
glTexParameteri
(
GL_TEXTURE_2D
,
GL_TEXTURE_WRAP_S
,
GL_CLAMP_TO_EDGE
);
glTexParameteri
(
GL_TEXTURE_2D
,
GL_TEXTURE_WRAP_T
,
GL_CLAMP_TO_EDGE
);
funcs
->
glTexParameteri
(
GL_TEXTURE_2D
,
GL_TEXTURE_MAG_FILTER
,
GL_LINEAR
);
funcs
->
glTexParameteri
(
GL_TEXTURE_2D
,
GL_TEXTURE_MIN_FILTER
,
GL_LINEAR
);
funcs
->
glTexParameteri
(
GL_TEXTURE_2D
,
GL_TEXTURE_WRAP_S
,
GL_CLAMP_TO_EDGE
);
funcs
->
glTexParameteri
(
GL_TEXTURE_2D
,
GL_TEXTURE_WRAP_T
,
GL_CLAMP_TO_EDGE
);
}
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