Use GL_BGRA_EXT format with ANGLE.
This commit is contained in:
parent
9c552215ab
commit
ed6c2cb541
4 changed files with 15 additions and 5 deletions
|
|
@ -91,11 +91,11 @@ void Image::bind(QOpenGLFunctions &f) {
|
||||||
f.glTexImage2D(
|
f.glTexImage2D(
|
||||||
GL_TEXTURE_2D,
|
GL_TEXTURE_2D,
|
||||||
0,
|
0,
|
||||||
GL_RGBA,
|
kFormatRGBA,
|
||||||
_subimage.width(),
|
_subimage.width(),
|
||||||
_subimage.height(),
|
_subimage.height(),
|
||||||
0,
|
0,
|
||||||
GL_RGBA,
|
kFormatRGBA,
|
||||||
GL_UNSIGNED_BYTE,
|
GL_UNSIGNED_BYTE,
|
||||||
_image.constBits());
|
_image.constBits());
|
||||||
} else {
|
} else {
|
||||||
|
|
@ -106,7 +106,7 @@ void Image::bind(QOpenGLFunctions &f) {
|
||||||
0,
|
0,
|
||||||
_subimage.width(),
|
_subimage.width(),
|
||||||
_subimage.height(),
|
_subimage.height(),
|
||||||
GL_RGBA,
|
kFormatRGBA,
|
||||||
GL_UNSIGNED_BYTE,
|
GL_UNSIGNED_BYTE,
|
||||||
_image.constBits());
|
_image.constBits());
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -136,4 +136,12 @@ private:
|
||||||
|
|
||||||
[[nodiscard]] GLint CurrentSingleComponentFormat();
|
[[nodiscard]] GLint CurrentSingleComponentFormat();
|
||||||
|
|
||||||
|
#ifdef Q_OS_WIN
|
||||||
|
inline constexpr auto kFormatRGBA = GL_BGRA_EXT;
|
||||||
|
inline constexpr auto kSwizzleRedBlue = false;
|
||||||
|
#else // Q_OS_WIN
|
||||||
|
inline constexpr auto kFormatRGBA = GL_RGBA;
|
||||||
|
inline constexpr auto kSwizzleRedBlue = true;
|
||||||
|
#endif // Q_OS_WIN
|
||||||
|
|
||||||
} // namespace Ui::GL
|
} // namespace Ui::GL
|
||||||
|
|
|
||||||
|
|
@ -25,7 +25,6 @@ void FillTriangles(
|
||||||
const QColor &color,
|
const QColor &color,
|
||||||
Fn<void()> additional = nullptr);
|
Fn<void()> additional = nullptr);
|
||||||
|
|
||||||
|
|
||||||
void FillRectangle(
|
void FillRectangle(
|
||||||
QOpenGLFunctions &f,
|
QOpenGLFunctions &f,
|
||||||
not_null<QOpenGLShaderProgram*> program,
|
not_null<QOpenGLShaderProgram*> program,
|
||||||
|
|
|
||||||
|
|
@ -6,6 +6,7 @@
|
||||||
//
|
//
|
||||||
#include "ui/gl/gl_shader.h"
|
#include "ui/gl/gl_shader.h"
|
||||||
|
|
||||||
|
#include "ui/gl/gl_image.h"
|
||||||
#include "base/debug_log.h"
|
#include "base/debug_log.h"
|
||||||
|
|
||||||
#include <QtGui/QOpenGLContext>
|
#include <QtGui/QOpenGLContext>
|
||||||
|
|
@ -72,8 +73,10 @@ uniform sampler2D s_texture;
|
||||||
)",
|
)",
|
||||||
.body = R"(
|
.body = R"(
|
||||||
result = texture2D(s_texture, v_texcoord);
|
result = texture2D(s_texture, v_texcoord);
|
||||||
|
)" + (kSwizzleRedBlue
|
||||||
|
? R"(
|
||||||
result = vec4(result.b, result.g, result.r, result.a);
|
result = vec4(result.b, result.g, result.r, result.a);
|
||||||
)",
|
)" : QString()),
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue