Skip to content

Commit

Permalink
Merge pull request #11982 from daschuer/EGL
Browse files Browse the repository at this point in the history
EGL
  • Loading branch information
Swiftb0y authored Sep 14, 2023
2 parents 2975ec5 + 19d2f34 commit 860ff09
Show file tree
Hide file tree
Showing 12 changed files with 51 additions and 41 deletions.
14 changes: 7 additions & 7 deletions src/shaders/endoftrackshader.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,9 @@ using namespace mixxx;

void EndOfTrackShader::init() {
QString vertexShaderCode = QStringLiteral(R"--(
attribute vec4 position;
attribute float gradient;
varying float vgradient;
attribute highp vec4 position;
attribute highp float gradient;
varying highp float vgradient;
void main()
{
vgradient = gradient;
Expand All @@ -15,12 +15,12 @@ void main()
)--");

QString fragmentShaderCode = QStringLiteral(R"--(
uniform vec4 color;
varying float vgradient;
uniform highp vec4 color;
varying highp float vgradient;
void main()
{
float minAlpha = 0.5 * color.w;
float maxAlpha = 0.83 * color.w;
float minAlpha = 0.5f * color.w;
float maxAlpha = 0.83f * color.w;
gl_FragColor = vec4(color.xyz, mix(minAlpha, maxAlpha, max(0.,vgradient)));
}
)--");
Expand Down
8 changes: 4 additions & 4 deletions src/shaders/rgbashader.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,9 @@ using namespace mixxx;
void RGBAShader::init() {
QString vertexShaderCode = QStringLiteral(R"--(
uniform mat4 matrix;
attribute vec4 position;
attribute vec4 color;
varying vec4 vcolor;
attribute highp vec4 position;
attribute highp vec4 color;
varying highp vec4 vcolor;
void main()
{
vcolor = color;
Expand All @@ -16,7 +16,7 @@ void main()
)--");

QString fragmentShaderCode = QStringLiteral(R"--(
varying vec4 vcolor;
varying highp vec4 vcolor;
void main()
{
gl_FragColor = vcolor;
Expand Down
8 changes: 4 additions & 4 deletions src/shaders/rgbshader.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,9 @@ using namespace mixxx;
void RGBShader::init() {
QString vertexShaderCode = QStringLiteral(R"--(
uniform mat4 matrix;
attribute vec4 position;
attribute vec3 color;
varying vec3 vcolor;
attribute highp vec4 position;
attribute highp vec3 color;
varying highp vec3 vcolor;
void main()
{
vcolor = color;
Expand All @@ -16,7 +16,7 @@ void main()
)--");

QString fragmentShaderCode = QStringLiteral(R"--(
varying vec3 vcolor;
varying highp vec3 vcolor;
void main()
{
gl_FragColor = vec4(vcolor,1.0);
Expand Down
8 changes: 4 additions & 4 deletions src/shaders/textureshader.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,9 @@ using namespace mixxx;
void TextureShader::init() {
QString vertexShaderCode = QStringLiteral(R"--(
uniform mat4 matrix;
attribute vec4 position;
attribute vec3 texcoor;
varying vec3 vTexcoor;
attribute highp vec4 position;
attribute highp vec3 texcoor;
varying highp vec3 vTexcoor;
void main()
{
vTexcoor = texcoor;
Expand All @@ -17,7 +17,7 @@ void main()

QString fragmentShaderCode = QStringLiteral(R"--(
uniform sampler2D sampler;
varying vec3 vTexcoor;
varying highp vec3 vTexcoor;
void main()
{
gl_FragColor = texture2D(sampler, vTexcoor.xy);
Expand Down
4 changes: 2 additions & 2 deletions src/shaders/unicolorshader.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -5,15 +5,15 @@ using namespace mixxx;
void UnicolorShader::init() {
QString vertexShaderCode = QStringLiteral(R"--(
uniform mat4 matrix;
attribute vec4 position;
attribute highp vec4 position;
void main()
{
gl_Position = matrix * position;
}
)--");

QString fragmentShaderCode = QStringLiteral(R"--(
uniform vec4 color;
uniform highp vec4 color;
void main()
{
gl_FragColor = color;
Expand Down
12 changes: 6 additions & 6 deletions src/shaders/vinylqualityshader.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,9 @@ using namespace mixxx;
void VinylQualityShader::init() {
QString vertexShaderCode = QStringLiteral(R"--(
uniform mat4 matrix;
attribute vec4 position;
attribute vec3 texcoor;
varying vec3 vTexcoor;
attribute highp vec4 position;
attribute highp vec3 texcoor;
varying highp vec3 vTexcoor;
void main()
{
vTexcoor = texcoor;
Expand All @@ -17,11 +17,11 @@ void main()

QString fragmentShaderCode = QStringLiteral(R"--(
uniform sampler2D sampler;
uniform vec4 color;
varying vec3 vTexcoor;
uniform highp vec4 color;
varying highp vec3 vTexcoor;
void main()
{
gl_FragColor = vec4(color.xyz, texture2D(sampler, vTexcoor.xy) * 0.75);
gl_FragColor = vec4(color.xyz, texture2D(sampler, vTexcoor.xy) * 0.75f);
}
)--");

Expand Down
28 changes: 19 additions & 9 deletions src/waveform/waveformwidgetfactory.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -173,10 +173,13 @@ WaveformWidgetFactory::WaveformWidgetFactory()
m_openGLVersion = pContext->isOpenGLES() ? "ES " : "";
m_openGLVersion += majorVersion == 0 ? QString("None") : versionString;

if (majorVersion * 100 + minorVersion >= 201) {
if (pContext->isOpenGLES()) {
// Qt5 requires at least OpenGL 2.1 or OpenGL ES 2.0
if (pContext->isOpenGLES()) {
if (majorVersion * 100 + minorVersion >= 200) {
m_openGlesAvailable = true;
} else {
}
} else {
if (majorVersion * 100 + minorVersion >= 201) {
m_openGlAvailable = true;
}
}
Expand Down Expand Up @@ -1167,15 +1170,18 @@ QString WaveformWidgetFactory::buildWidgetDisplayName() const {
if (isLegacy) {
extras.push_back(tr("legacy"));
}
if (isOpenGlAvailable() || isOpenGlesAvailable()) {
if (isOpenGlesAvailable()) {
if (WaveformT::useOpenGLShaders()) {
extras.push_back(QStringLiteral("GLSL ES"));
} else if (WaveformT::useOpenGles()) {
extras.push_back(QStringLiteral("GLES"));
}
} else if (isOpenGlAvailable()) {
if (WaveformT::useOpenGLShaders()) {
extras.push_back(QStringLiteral("GLSL"));
} else if (WaveformT::useOpenGl()) {
extras.push_back(QStringLiteral("GL"));
}
if (WaveformT::useOpenGles()) {
extras.push_back(QStringLiteral("ES"));
}
}
QString name = WaveformT::getWaveformWidgetName();
if (extras.isEmpty()) {
Expand All @@ -1187,8 +1193,12 @@ QString WaveformWidgetFactory::buildWidgetDisplayName() const {
// static
QSurfaceFormat WaveformWidgetFactory::getSurfaceFormat() {
QSurfaceFormat format;
format.setVersion(2, 1);
format.setProfile(QSurfaceFormat::CoreProfile);
// Qt5 requires at least OpenGL 2.1 or OpenGL ES 2.0, default is 2.0
// format.setVersion(2, 1);
// Core and Compatibility contexts have been introduced in openGL 3.2
// From 3.0 to 3.1 we have implicit the Core profile and Before 3.0 we have the
// Compatibility profile
// format.setProfile(QSurfaceFormat::CoreProfile);

// setSwapInterval sets the application preferred swap interval
// in minimum number of video frames that are displayed before a buffer swap occurs
Expand Down
2 changes: 1 addition & 1 deletion src/waveform/widgets/allshader/filteredwaveformwidget.h
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ class allshader::FilteredWaveformWidget final : public allshader::WaveformWidget
return true;
}
static constexpr bool useOpenGles() {
return false;
return true;
}
static constexpr bool useOpenGLShaders() {
return true;
Expand Down
2 changes: 1 addition & 1 deletion src/waveform/widgets/allshader/hsvwaveformwidget.h
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ class allshader::HSVWaveformWidget final : public allshader::WaveformWidget {
return true;
}
static constexpr bool useOpenGles() {
return false;
return true;
}
static constexpr bool useOpenGLShaders() {
return true;
Expand Down
2 changes: 1 addition & 1 deletion src/waveform/widgets/allshader/lrrgbwaveformwidget.h
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ class allshader::LRRGBWaveformWidget final : public allshader::WaveformWidget {
return true;
}
static constexpr bool useOpenGles() {
return false;
return true;
}
static constexpr bool useOpenGLShaders() {
return true;
Expand Down
2 changes: 1 addition & 1 deletion src/waveform/widgets/allshader/rgbwaveformwidget.h
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ class allshader::RGBWaveformWidget final : public allshader::WaveformWidget {
return true;
}
static constexpr bool useOpenGles() {
return false;
return true;
}
static constexpr bool useOpenGLShaders() {
return true;
Expand Down
2 changes: 1 addition & 1 deletion src/waveform/widgets/allshader/simplewaveformwidget.h
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ class allshader::SimpleWaveformWidget final : public allshader::WaveformWidget {
return true;
}
static constexpr bool useOpenGles() {
return false;
return true;
}
static constexpr bool useOpenGLShaders() {
return true;
Expand Down

0 comments on commit 860ff09

Please sign in to comment.