Dynamic GL: remove exporting symbols
Remove the opengl proxy for now. Later it will either be moved into a separate library or replaced by a QOpenGLFunctions-based approach. This means that the -opengl dynamic configuration is not usable for the time being. The rest of the enablers remain in place. The convenience function QOpenGLFunctions::isES() is now moved to QOpenGLContext and is changed to check the renderable type. This is extremely useful since besides supporting dynamic GL it solves also the problem of GL_ARB_ES2_compatibility (i.e. it triggers the real ES path when creating an ES-compatible context with a desktop OpenGL implementation). Task-number: QTBUG-36483 Task-number: QTBUG-37172 Change-Id: I045be3fc16e9043e1528cf48e6bf0903da4fa7ca Reviewed-by: Friedemann Kleint <Friedemann.Kleint@digia.com> Reviewed-by: Jørgen Lind <jorgen.lind@digia.com>
This commit is contained in:
parent
fe2ce05d23
commit
4b2f35d04c
@ -337,9 +337,9 @@ void Widget::renderWindowReady()
|
||||
|
||||
const char *gltype[] = { "Desktop", "GLES 2", "GLES 1" };
|
||||
m_output->append(tr("\nQt OpenGL configuration: %1")
|
||||
.arg(QString::fromLatin1(gltype[QOpenGLFunctions::platformGLType()])));
|
||||
.arg(QString::fromLatin1(gltype[QOpenGLContext::openGLModuleType()])));
|
||||
m_output->append(tr("Qt OpenGL library handle: %1")
|
||||
.arg(QString::number(qintptr(QOpenGLFunctions::platformGLHandle()), 16)));
|
||||
.arg(QString::number(qintptr(QOpenGLContext::openGLModuleHandle()), 16)));
|
||||
|
||||
QList<QByteArray> extensionList = context->extensions().toList();
|
||||
std::sort(extensionList.begin(), extensionList.end());
|
||||
|
@ -338,7 +338,8 @@ int QOpenGLContextPrivate::maxTextureSize()
|
||||
glGetIntegerv(GL_MAX_TEXTURE_SIZE, &max_texture_size);
|
||||
|
||||
#ifndef QT_OPENGL_ES
|
||||
if (!QOpenGLFunctions::isES()) {
|
||||
Q_Q(QOpenGLContext);
|
||||
if (!q->isES()) {
|
||||
GLenum proxy = GL_PROXY_TEXTURE_2D;
|
||||
|
||||
GLint size;
|
||||
@ -643,8 +644,8 @@ QOpenGLFunctions *QOpenGLContext::functions() const
|
||||
QAbstractOpenGLFunctions *QOpenGLContext::versionFunctions(const QOpenGLVersionProfile &versionProfile) const
|
||||
{
|
||||
#ifndef QT_OPENGL_ES_2
|
||||
if (QOpenGLFunctions::isES()) {
|
||||
qWarning("versionFunctions: Not supported on dynamic GL ES");
|
||||
if (isES()) {
|
||||
qWarning("versionFunctions: Not supported on OpenGL ES");
|
||||
return 0;
|
||||
}
|
||||
#endif // QT_OPENGL_ES_2
|
||||
@ -959,6 +960,75 @@ void QOpenGLContext::deleteQGLContext()
|
||||
}
|
||||
}
|
||||
|
||||
/*!
|
||||
Returns the platform-specific handle for the OpenGL implementation that
|
||||
is currently in use. (for example, a HMODULE on Windows)
|
||||
|
||||
On platforms that do not use dynamic GL switch the return value is null.
|
||||
|
||||
The library might be GL-only, meaning that windowing system interface
|
||||
functions (for example EGL) may live in another, separate library.
|
||||
|
||||
\sa openGLModuleType()
|
||||
|
||||
\since 5.3
|
||||
*/
|
||||
void *QOpenGLContext::openGLModuleHandle()
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
/*!
|
||||
\enum QOpenGLContext::OpenGLModuleType
|
||||
This enum defines the type of the underlying OpenGL implementation.
|
||||
|
||||
\value DesktopGL Desktop OpenGL
|
||||
\value GLES2 OpenGL ES 2.0 or higher
|
||||
\value GLES1 OpenGL ES 1.x
|
||||
|
||||
\since 5.3
|
||||
*/
|
||||
|
||||
/*!
|
||||
Returns the underlying OpenGL implementation type.
|
||||
|
||||
On platforms where the OpenGL implementation is not dynamically
|
||||
loaded, the return value is determined during compile time and never
|
||||
changes.
|
||||
|
||||
\note A desktop OpenGL implementation may be capable of creating
|
||||
ES-compatible contexts too. Therefore in most cases it is more
|
||||
appropriate to check QSurfaceFormat::renderableType() or using the
|
||||
the convenience function isES().
|
||||
|
||||
\since 5.3
|
||||
*/
|
||||
QOpenGLContext::OpenGLModuleType QOpenGLContext::openGLModuleType()
|
||||
{
|
||||
#if defined(QT_OPENGL_ES_2)
|
||||
return GLES2;
|
||||
#elif defined(QT_OPENGL_ES)
|
||||
return GLES1;
|
||||
#else
|
||||
return DesktopGL;
|
||||
#endif
|
||||
}
|
||||
|
||||
/*!
|
||||
Returns true if the context is an OpenGL ES context.
|
||||
|
||||
If the context has not yet been created, the result is based on the
|
||||
requested format set via setFormat().
|
||||
|
||||
\sa create(), format(), setFormat()
|
||||
|
||||
\since 5.3
|
||||
*/
|
||||
bool QOpenGLContext::isES() const
|
||||
{
|
||||
return format().renderableType() == QSurfaceFormat::OpenGLES;
|
||||
}
|
||||
|
||||
/*!
|
||||
\internal
|
||||
*/
|
||||
|
@ -192,6 +192,18 @@ public:
|
||||
QSet<QByteArray> extensions() const;
|
||||
bool hasExtension(const QByteArray &extension) const;
|
||||
|
||||
static void *openGLModuleHandle();
|
||||
|
||||
enum OpenGLModuleType {
|
||||
DesktopGL,
|
||||
GLES2,
|
||||
GLES1
|
||||
};
|
||||
|
||||
static OpenGLModuleType openGLModuleType();
|
||||
|
||||
bool isES() const;
|
||||
|
||||
Q_SIGNALS:
|
||||
void aboutToBeDestroyed();
|
||||
|
||||
|
@ -333,7 +333,7 @@ void QOpenGLBuffer::destroy()
|
||||
bool QOpenGLBuffer::read(int offset, void *data, int count)
|
||||
{
|
||||
#if !defined(QT_OPENGL_ES)
|
||||
if (QOpenGLFunctions::platformGLType() != QOpenGLFunctions::GLES1) {
|
||||
if (QOpenGLContext::openGLModuleType() != QOpenGLContext::GLES1) {
|
||||
Q_D(QOpenGLBuffer);
|
||||
if (!d->funcs->hasOpenGLFeature(QOpenGLFunctions::Buffers) || !d->guard->id())
|
||||
return false;
|
||||
|
@ -43,7 +43,6 @@
|
||||
#include <QtCore/qglobal.h>
|
||||
#include <QtCore/qvarlengtharray.h>
|
||||
#include <QtGui/qopengl.h>
|
||||
#include <QtGui/qopenglfunctions.h>
|
||||
|
||||
#include "qopengldebug.h"
|
||||
|
||||
@ -1370,7 +1369,7 @@ bool QOpenGLDebugLogger::initialize()
|
||||
// through wglGetProcAddress
|
||||
#if defined(Q_OS_WIN) && !defined(QT_OPENGL_ES_2)
|
||||
{
|
||||
HMODULE handle = static_cast<HMODULE>(QOpenGLFunctions::platformGLHandle());
|
||||
HMODULE handle = static_cast<HMODULE>(QOpenGLContext::openGLModuleHandle());
|
||||
if (!handle)
|
||||
handle = GetModuleHandleA("opengl32.dll");
|
||||
d->glGetPointerv = reinterpret_cast<qt_glGetPointerv_t>(GetProcAddress(handle, QByteArrayLiteral("glGetPointerv")));
|
||||
|
@ -164,7 +164,7 @@ QOpenGLEngineSharedShaders::QOpenGLEngineSharedShaders(QOpenGLContext* context)
|
||||
code[NonPremultipliedImageSrcFragmentShader] = qopenglslNonPremultipliedImageSrcFragmentShader;
|
||||
code[CustomImageSrcFragmentShader] = qopenglslCustomSrcFragmentShader; // Calls "customShader", which must be appended
|
||||
code[SolidBrushSrcFragmentShader] = qopenglslSolidBrushSrcFragmentShader;
|
||||
if (QOpenGLFunctions::isES())
|
||||
if (context->isES())
|
||||
code[TextureBrushSrcFragmentShader] = qopenglslTextureBrushSrcFragmentShader_ES;
|
||||
else
|
||||
code[TextureBrushSrcFragmentShader] = qopenglslTextureBrushSrcFragmentShader_desktop;
|
||||
|
@ -590,7 +590,7 @@ void QOpenGLFramebufferObjectPrivate::initAttachments(QOpenGLContext *ctx, QOpen
|
||||
funcs.glBindRenderbuffer(GL_RENDERBUFFER, depth_buffer);
|
||||
Q_ASSERT(funcs.glIsRenderbuffer(depth_buffer));
|
||||
if (samples != 0 && funcs.hasOpenGLExtension(QOpenGLExtensions::FramebufferMultisample)) {
|
||||
if (QOpenGLFunctions::isES()) {
|
||||
if (ctx->isES()) {
|
||||
if (funcs.hasOpenGLExtension(QOpenGLExtensions::Depth24))
|
||||
funcs.glRenderbufferStorageMultisample(GL_RENDERBUFFER, samples,
|
||||
GL_DEPTH_COMPONENT24, size.width(), size.height());
|
||||
@ -602,7 +602,7 @@ void QOpenGLFramebufferObjectPrivate::initAttachments(QOpenGLContext *ctx, QOpen
|
||||
GL_DEPTH_COMPONENT, size.width(), size.height());
|
||||
}
|
||||
} else {
|
||||
if (QOpenGLFunctions::isES()) {
|
||||
if (ctx->isES()) {
|
||||
if (funcs.hasOpenGLExtension(QOpenGLExtensions::Depth24)) {
|
||||
funcs.glRenderbufferStorage(GL_RENDERBUFFER, GL_DEPTH_COMPONENT24,
|
||||
size.width(), size.height());
|
||||
@ -631,7 +631,7 @@ void QOpenGLFramebufferObjectPrivate::initAttachments(QOpenGLContext *ctx, QOpen
|
||||
#ifdef QT_OPENGL_ES
|
||||
GLenum storage = GL_STENCIL_INDEX8;
|
||||
#else
|
||||
GLenum storage = QOpenGLFunctions::isES() ? GL_STENCIL_INDEX8 : GL_STENCIL_INDEX;
|
||||
GLenum storage = ctx->isES() ? GL_STENCIL_INDEX8 : GL_STENCIL_INDEX;
|
||||
#endif
|
||||
|
||||
if (samples != 0 && funcs.hasOpenGLExtension(QOpenGLExtensions::FramebufferMultisample))
|
||||
@ -773,7 +773,7 @@ QOpenGLFramebufferObject::QOpenGLFramebufferObject(const QSize &size, GLenum tar
|
||||
Q_D(QOpenGLFramebufferObject);
|
||||
d->init(this, size, NoAttachment, target,
|
||||
#ifndef QT_OPENGL_ES_2
|
||||
QOpenGLFunctions::isES() ? GL_RGBA : GL_RGBA8
|
||||
QOpenGLContext::currentContext()->isES() ? GL_RGBA : GL_RGBA8
|
||||
#else
|
||||
GL_RGBA
|
||||
#endif
|
||||
@ -793,7 +793,7 @@ QOpenGLFramebufferObject::QOpenGLFramebufferObject(int width, int height, GLenum
|
||||
Q_D(QOpenGLFramebufferObject);
|
||||
d->init(this, QSize(width, height), NoAttachment, target,
|
||||
#ifndef QT_OPENGL_ES_2
|
||||
QOpenGLFunctions::isES() ? GL_RGBA : GL_RGBA8
|
||||
QOpenGLContext::currentContext()->isES() ? GL_RGBA : GL_RGBA8
|
||||
#else
|
||||
GL_RGBA
|
||||
#endif
|
||||
@ -850,7 +850,7 @@ QOpenGLFramebufferObject::QOpenGLFramebufferObject(int width, int height, Attach
|
||||
#ifdef QT_OPENGL_ES_2
|
||||
internal_format = GL_RGBA;
|
||||
#else
|
||||
internal_format = QOpenGLFunctions::isES() ? GL_RGBA : GL_RGBA8;
|
||||
internal_format = QOpenGLContext::currentContext()->isES() ? GL_RGBA : GL_RGBA8;
|
||||
#endif
|
||||
d->init(this, QSize(width, height), attachment, target, internal_format);
|
||||
}
|
||||
@ -877,7 +877,7 @@ QOpenGLFramebufferObject::QOpenGLFramebufferObject(const QSize &size, Attachment
|
||||
#ifdef QT_OPENGL_ES_2
|
||||
internal_format = GL_RGBA;
|
||||
#else
|
||||
internal_format = QOpenGLFunctions::isES() ? GL_RGBA : GL_RGBA8;
|
||||
internal_format = QOpenGLContext::currentContext()->isES() ? GL_RGBA : GL_RGBA8;
|
||||
#endif
|
||||
d->init(this, size, attachment, target, internal_format);
|
||||
}
|
||||
|
@ -70,7 +70,12 @@ public:
|
||||
mipmap(false)
|
||||
{
|
||||
#ifndef QT_OPENGL_ES_2
|
||||
internal_format = QOpenGLFunctions::isES() ? GL_RGBA : GL_RGBA8;
|
||||
// There is nothing that says QOpenGLFramebufferObjectFormat needs a current
|
||||
// context, so we need a fallback just to be safe, even though in pratice there
|
||||
// will usually be a context current.
|
||||
QOpenGLContext *ctx = QOpenGLContext::currentContext();
|
||||
const bool isES = ctx ? ctx->isES() : QOpenGLContext::openGLModuleType() != QOpenGLContext::DesktopGL;
|
||||
internal_format = isES ? GL_RGBA : GL_RGBA8;
|
||||
#else
|
||||
internal_format = GL_RGBA;
|
||||
#endif
|
||||
|
@ -249,7 +249,9 @@ QOpenGLExtensions::QOpenGLExtensions(QOpenGLContext *context)
|
||||
|
||||
static int qt_gl_resolve_features()
|
||||
{
|
||||
if (QOpenGLFunctions::platformGLType() == QOpenGLFunctions::GLES2) {
|
||||
QOpenGLContext *ctx = QOpenGLContext::currentContext();
|
||||
if (ctx->isES() && QOpenGLContext::openGLModuleType() != QOpenGLContext::GLES1) {
|
||||
// OpenGL ES 2
|
||||
int features = QOpenGLFunctions::Multitexture |
|
||||
QOpenGLFunctions::Shaders |
|
||||
QOpenGLFunctions::Buffers |
|
||||
@ -269,7 +271,8 @@ static int qt_gl_resolve_features()
|
||||
features |= QOpenGLFunctions::NPOTTextures |
|
||||
QOpenGLFunctions::NPOTTextureRepeat;
|
||||
return features;
|
||||
} else if (QOpenGLFunctions::platformGLType() == QOpenGLFunctions::GLES1) {
|
||||
} else if (ctx->isES()) {
|
||||
// OpenGL ES 1
|
||||
int features = QOpenGLFunctions::Multitexture |
|
||||
QOpenGLFunctions::Buffers |
|
||||
QOpenGLFunctions::CompressedTextures |
|
||||
@ -289,6 +292,7 @@ static int qt_gl_resolve_features()
|
||||
features |= QOpenGLFunctions::NPOTTextures;
|
||||
return features;
|
||||
} else {
|
||||
// OpenGL
|
||||
int features = 0;
|
||||
QSurfaceFormat format = QOpenGLContext::currentContext()->format();
|
||||
QOpenGLExtensionMatcher extensions;
|
||||
@ -352,7 +356,7 @@ static int qt_gl_resolve_extensions()
|
||||
if (extensionMatcher.match("GL_EXT_bgra"))
|
||||
extensions |= QOpenGLExtensions::BGRATextureFormat;
|
||||
|
||||
if (QOpenGLFunctions::isES()) {
|
||||
if (QOpenGLContext::currentContext()->isES()) {
|
||||
if (extensionMatcher.match("GL_OES_mapbuffer"))
|
||||
extensions |= QOpenGLExtensions::MapBuffer;
|
||||
if (extensionMatcher.match("GL_OES_packed_depth_stencil"))
|
||||
@ -2511,88 +2515,4 @@ QOpenGLExtensionsPrivate::QOpenGLExtensionsPrivate(QOpenGLContext *ctx)
|
||||
GetBufferSubData = qopenglfResolveGetBufferSubData;
|
||||
}
|
||||
|
||||
#if defined(QT_OPENGL_DYNAMIC)
|
||||
extern int qgl_proxyLibraryType(void);
|
||||
extern HMODULE qgl_glHandle(void);
|
||||
#endif
|
||||
|
||||
/*!
|
||||
\enum QOpenGLFunctions::PlatformGLType
|
||||
This enum defines the type of the underlying GL implementation.
|
||||
|
||||
\value DesktopGL Desktop OpenGL
|
||||
\value GLES2 OpenGL ES 2.0 or higher
|
||||
\value GLES1 OpenGL ES 1.x
|
||||
|
||||
\since 5.3
|
||||
*/
|
||||
|
||||
/*!
|
||||
\fn QOpenGLFunctions::isES()
|
||||
|
||||
On platforms where the OpenGL implementation is dynamically loaded
|
||||
this function returns true if the underlying GL implementation is
|
||||
Open GL ES.
|
||||
|
||||
On platforms that do not use runtime loading of the GL the return
|
||||
value is based on Qt's compile-time configuration and will never
|
||||
change during runtime.
|
||||
|
||||
\sa platformGLType()
|
||||
|
||||
\since 5.3
|
||||
*/
|
||||
|
||||
/*!
|
||||
Returns the underlying GL implementation type.
|
||||
|
||||
On platforms where the OpenGL implementation is not dynamically
|
||||
loaded, the return value is determined during compile time and never
|
||||
changes.
|
||||
|
||||
Platforms that use dynamic GL loading (e.g. Windows) cannot rely on
|
||||
compile-time defines for differentiating between desktop and ES
|
||||
OpenGL code. Instead, they rely on this function to query, during
|
||||
runtime, the type of the loaded graphics library.
|
||||
|
||||
\since 5.3
|
||||
*/
|
||||
QOpenGLFunctions::PlatformGLType QOpenGLFunctions::platformGLType()
|
||||
{
|
||||
#if defined(QT_OPENGL_DYNAMIC)
|
||||
return PlatformGLType(qgl_proxyLibraryType());
|
||||
#elif defined(QT_OPENGL_ES_2)
|
||||
return GLES2;
|
||||
#elif defined(QT_OPENGL_ES)
|
||||
return GLES1;
|
||||
#else
|
||||
return DesktopGL;
|
||||
#endif
|
||||
}
|
||||
|
||||
/*!
|
||||
Returns the platform-specific handle for the OpenGL implementation that
|
||||
is currently in use. (for example, a HMODULE on Windows)
|
||||
|
||||
On platforms that do not use dynamic GL switch the return value is null.
|
||||
|
||||
The library might be GL-only, meaning that windowing system interface
|
||||
functions (for example EGL) may live in another, separate library.
|
||||
|
||||
Always use platformGLType() before resolving any functions to check if the
|
||||
library implements desktop OpenGL or OpenGL ES.
|
||||
|
||||
\sa platformGLType()
|
||||
|
||||
\since 5.3
|
||||
*/
|
||||
void *QOpenGLFunctions::platformGLHandle()
|
||||
{
|
||||
#if defined(QT_OPENGL_DYNAMIC)
|
||||
return qgl_glHandle();
|
||||
#else
|
||||
return 0;
|
||||
#endif
|
||||
}
|
||||
|
||||
QT_END_NAMESPACE
|
||||
|
@ -311,15 +311,6 @@ public:
|
||||
void glVertexAttrib4fv(GLuint indx, const GLfloat* values);
|
||||
void glVertexAttribPointer(GLuint indx, GLint size, GLenum type, GLboolean normalized, GLsizei stride, const void* ptr);
|
||||
|
||||
enum PlatformGLType {
|
||||
DesktopGL = 0,
|
||||
GLES2,
|
||||
GLES1
|
||||
};
|
||||
static PlatformGLType platformGLType();
|
||||
static void *platformGLHandle();
|
||||
static bool isES() { return platformGLType() != DesktopGL; }
|
||||
|
||||
protected:
|
||||
QOpenGLFunctionsPrivate *d_ptr;
|
||||
static bool isInitialized(const QOpenGLFunctionsPrivate *d) { return d != 0; }
|
||||
|
@ -221,7 +221,7 @@ void QOpenGL2PaintEngineExPrivate::updateBrushTexture()
|
||||
currentBrushPixmap = currentBrushPixmap.scaled(max_texture_size, max_texture_size, Qt::KeepAspectRatio);
|
||||
|
||||
GLuint wrapMode = GL_REPEAT;
|
||||
if (QOpenGLFunctions::isES()) {
|
||||
if (QOpenGLContext::currentContext()->isES()) {
|
||||
// OpenGL ES does not support GL_REPEAT wrap modes for NPOT textures. So instead,
|
||||
// we emulate GL_REPEAT by only taking the fractional part of the texture coords
|
||||
// in the qopenglslTextureBrushSrcFragmentShader program.
|
||||
@ -542,7 +542,7 @@ void QOpenGL2PaintEngineEx::beginNativePainting()
|
||||
d->funcs.glDisableVertexAttribArray(i);
|
||||
|
||||
#ifndef QT_OPENGL_ES_2
|
||||
if (!QOpenGLFunctions::isES()) {
|
||||
if (!QOpenGLContext::currentContext()->isES()) {
|
||||
Q_ASSERT(QOpenGLContext::currentContext());
|
||||
const QOpenGLContext *ctx = d->ctx;
|
||||
const QSurfaceFormat &fmt = d->device->context()->format();
|
||||
@ -600,7 +600,7 @@ void QOpenGL2PaintEngineExPrivate::resetGLState()
|
||||
setVertexAttribArrayEnabled(QT_TEXTURE_COORDS_ATTR, false);
|
||||
setVertexAttribArrayEnabled(QT_VERTEX_COORDS_ATTR, false);
|
||||
setVertexAttribArrayEnabled(QT_OPACITY_ATTR, false);
|
||||
if (!QOpenGLFunctions::isES()) {
|
||||
if (!QOpenGLContext::currentContext()->isES()) {
|
||||
// gl_Color, corresponding to vertex attribute 3, may have been changed
|
||||
float color[] = { 1.0f, 1.0f, 1.0f, 1.0f };
|
||||
funcs.glVertexAttrib4fv(3, color);
|
||||
@ -1335,7 +1335,7 @@ void QOpenGL2PaintEngineEx::renderHintsChanged()
|
||||
state()->renderHintsChanged = true;
|
||||
|
||||
#ifndef QT_OPENGL_ES_2
|
||||
if (!QOpenGLFunctions::isES()) {
|
||||
if (!QOpenGLContext::currentContext()->isES()) {
|
||||
if ((state()->renderHints & QPainter::Antialiasing)
|
||||
|| (state()->renderHints & QPainter::HighQualityAntialiasing))
|
||||
glEnable(GL_MULTISAMPLE);
|
||||
@ -2012,7 +2012,7 @@ bool QOpenGL2PaintEngineEx::begin(QPaintDevice *pdev)
|
||||
d->glyphCacheFormat = QFontEngine::Format_A8;
|
||||
|
||||
#ifndef QT_OPENGL_ES_2
|
||||
if (!QOpenGLFunctions::isES()) {
|
||||
if (!QOpenGLContext::currentContext()->isES()) {
|
||||
glDisable(GL_MULTISAMPLE);
|
||||
d->glyphCacheFormat = QFontEngine::Format_A32;
|
||||
d->multisamplingAlwaysEnabled = false;
|
||||
|
File diff suppressed because it is too large
Load Diff
@ -176,7 +176,7 @@ public:
|
||||
#endif
|
||||
{
|
||||
#ifndef QT_OPENGL_ES_2
|
||||
if (!QOpenGLFunctions::isES()) {
|
||||
if (!ctx->isES()) {
|
||||
QSurfaceFormat f = ctx->format();
|
||||
|
||||
// Geometry shaders require OpenGL >= 3.2
|
||||
@ -445,7 +445,7 @@ bool QOpenGLShader::compileSourceCode(const char *source)
|
||||
|
||||
#ifdef QOpenGL_REDEFINE_HIGHP
|
||||
if (d->shaderType == Fragment && !ctx_d->workaround_missingPrecisionQualifiers
|
||||
&& QOpenGLFunctions::isES()) {
|
||||
&& QOpenGLContext::currentContext()->isES()) {
|
||||
src.append(redefineHighp);
|
||||
srclen.append(GLint(sizeof(redefineHighp) - 1));
|
||||
}
|
||||
@ -674,7 +674,7 @@ bool QOpenGLShaderProgram::init()
|
||||
#ifndef QT_OPENGL_ES_2
|
||||
// Resolve OpenGL 4 functions for tessellation shader support
|
||||
QSurfaceFormat format = context->format();
|
||||
if (!QOpenGLFunctions::isES()
|
||||
if (!context->isES()
|
||||
&& format.version() >= qMakePair<int, int>(4, 0)) {
|
||||
d->tessellationFuncs = context->versionFunctions<QOpenGLFunctions_4_0_Core>();
|
||||
d->tessellationFuncs->initializeOpenGLFunctions();
|
||||
@ -3273,7 +3273,7 @@ bool QOpenGLShader::hasOpenGLShaders(ShaderType type, QOpenGLContext *context)
|
||||
#ifndef QT_OPENGL_ES_2
|
||||
// Geometry shaders require OpenGL 3.2 or newer
|
||||
QSurfaceFormat format = context->format();
|
||||
return (!QOpenGLFunctions::isES())
|
||||
return (!context->isES())
|
||||
&& (format.version() >= qMakePair<int, int>(3, 2));
|
||||
#else
|
||||
// No geometry shader support in OpenGL ES2
|
||||
@ -3281,7 +3281,7 @@ bool QOpenGLShader::hasOpenGLShaders(ShaderType type, QOpenGLContext *context)
|
||||
#endif
|
||||
} else if (type == TessellationControl || type == TessellationEvaluation) {
|
||||
#if !defined(QT_OPENGL_ES_2)
|
||||
return (!QOpenGLFunctions::isES())
|
||||
return (!context->isES())
|
||||
&& (format.version() >= qMakePair<int, int>(4, 0));
|
||||
#else
|
||||
// No tessellation shader support in OpenGL ES2
|
||||
|
@ -2430,7 +2430,7 @@ bool QOpenGLTexture::hasFeature(Feature feature)
|
||||
bool supported = false;
|
||||
|
||||
#if !defined(QT_OPENGL_ES_2)
|
||||
if (!QOpenGLFunctions::isES()) {
|
||||
if (!ctx->isES()) {
|
||||
switch (feature) {
|
||||
case ImmutableMultisampleStorage:
|
||||
case TextureBuffer:
|
||||
@ -2487,7 +2487,7 @@ bool QOpenGLTexture::hasFeature(Feature feature)
|
||||
}
|
||||
}
|
||||
|
||||
if (QOpenGLFunctions::isES())
|
||||
if (ctx->isES())
|
||||
#endif
|
||||
{
|
||||
switch (feature) {
|
||||
@ -2522,7 +2522,7 @@ bool QOpenGLTexture::hasFeature(Feature feature)
|
||||
void QOpenGLTexture::setMipBaseLevel(int baseLevel)
|
||||
{
|
||||
#if !defined(QT_OPENGL_ES_2)
|
||||
if (!QOpenGLFunctions::isES()) {
|
||||
if (!QOpenGLContext::currentContext()->isES()) {
|
||||
Q_D(QOpenGLTexture);
|
||||
d->create();
|
||||
Q_ASSERT(d->textureId);
|
||||
@ -2559,7 +2559,7 @@ int QOpenGLTexture::mipBaseLevel() const
|
||||
void QOpenGLTexture::setMipMaxLevel(int maxLevel)
|
||||
{
|
||||
#if !defined(QT_OPENGL_ES_2)
|
||||
if (!QOpenGLFunctions::isES()) {
|
||||
if (!QOpenGLContext::currentContext()->isES()) {
|
||||
Q_D(QOpenGLTexture);
|
||||
d->create();
|
||||
Q_ASSERT(d->textureId);
|
||||
@ -2596,7 +2596,7 @@ int QOpenGLTexture::mipMaxLevel() const
|
||||
void QOpenGLTexture::setMipLevelRange(int baseLevel, int maxLevel)
|
||||
{
|
||||
#if !defined(QT_OPENGL_ES_2)
|
||||
if (!QOpenGLFunctions::isES()) {
|
||||
if (!QOpenGLContext::currentContext()->isES()) {
|
||||
Q_D(QOpenGLTexture);
|
||||
d->create();
|
||||
Q_ASSERT(d->textureId);
|
||||
@ -2706,7 +2706,7 @@ void QOpenGLTexture::generateMipMaps(int baseLevel, bool resetBaseLevel)
|
||||
void QOpenGLTexture::setSwizzleMask(SwizzleComponent component, SwizzleValue value)
|
||||
{
|
||||
#if !defined(Q_OS_MAC) && !defined(QT_OPENGL_ES_2)
|
||||
if (!QOpenGLFunctions::isES()) {
|
||||
if (!QOpenGLContext::currentContext()->isES()) {
|
||||
Q_D(QOpenGLTexture);
|
||||
d->create();
|
||||
Q_ASSERT(d->texFuncs);
|
||||
@ -2733,7 +2733,7 @@ void QOpenGLTexture::setSwizzleMask(SwizzleValue r, SwizzleValue g,
|
||||
SwizzleValue b, SwizzleValue a)
|
||||
{
|
||||
#if !defined(Q_OS_MAC) && !defined(QT_OPENGL_ES_2)
|
||||
if (!QOpenGLFunctions::isES()) {
|
||||
if (!QOpenGLContext::currentContext()->isES()) {
|
||||
Q_D(QOpenGLTexture);
|
||||
d->create();
|
||||
Q_ASSERT(d->texFuncs);
|
||||
@ -2782,7 +2782,7 @@ QOpenGLTexture::SwizzleValue QOpenGLTexture::swizzleMask(SwizzleComponent compon
|
||||
void QOpenGLTexture::setDepthStencilMode(QOpenGLTexture::DepthStencilMode mode)
|
||||
{
|
||||
#if !defined(Q_OS_MAC) && !defined(QT_OPENGL_ES_2)
|
||||
if (!QOpenGLFunctions::isES()) {
|
||||
if (!QOpenGLContext::currentContext()->isES()) {
|
||||
Q_D(QOpenGLTexture);
|
||||
d->create();
|
||||
Q_ASSERT(d->texFuncs);
|
||||
@ -2972,7 +2972,7 @@ QOpenGLTexture::WrapMode QOpenGLTexture::wrapMode(QOpenGLTexture::CoordinateDire
|
||||
void QOpenGLTexture::setBorderColor(QColor color)
|
||||
{
|
||||
#if !defined(QT_OPENGL_ES_2)
|
||||
if (!QOpenGLFunctions::isES()) {
|
||||
if (!QOpenGLContext::currentContext()->isES()) {
|
||||
Q_D(QOpenGLTexture);
|
||||
d->create();
|
||||
Q_ASSERT(d->texFuncs);
|
||||
@ -3000,7 +3000,7 @@ void QOpenGLTexture::setBorderColor(QColor color)
|
||||
void QOpenGLTexture::setBorderColor(float r, float g, float b, float a)
|
||||
{
|
||||
#if !defined(QT_OPENGL_ES_2)
|
||||
if (!QOpenGLFunctions::isES()) {
|
||||
if (!QOpenGLContext::currentContext()->isES()) {
|
||||
Q_D(QOpenGLTexture);
|
||||
d->create();
|
||||
Q_ASSERT(d->texFuncs);
|
||||
@ -3031,7 +3031,7 @@ void QOpenGLTexture::setBorderColor(float r, float g, float b, float a)
|
||||
void QOpenGLTexture::setBorderColor(int r, int g, int b, int a)
|
||||
{
|
||||
#if !defined(QT_OPENGL_ES_2)
|
||||
if (!QOpenGLFunctions::isES()) {
|
||||
if (!QOpenGLContext::currentContext()->isES()) {
|
||||
Q_D(QOpenGLTexture);
|
||||
d->create();
|
||||
Q_ASSERT(d->texFuncs);
|
||||
@ -3064,7 +3064,7 @@ void QOpenGLTexture::setBorderColor(int r, int g, int b, int a)
|
||||
void QOpenGLTexture::setBorderColor(uint r, uint g, uint b, uint a)
|
||||
{
|
||||
#if !defined(QT_OPENGL_ES_2)
|
||||
if (!QOpenGLFunctions::isES()) {
|
||||
if (!QOpenGLContext::currentContext()->isES()) {
|
||||
Q_D(QOpenGLTexture);
|
||||
d->create();
|
||||
Q_ASSERT(d->texFuncs);
|
||||
@ -3170,7 +3170,7 @@ void QOpenGLTexture::borderColor(unsigned int *border) const
|
||||
void QOpenGLTexture::setMinimumLevelOfDetail(float value)
|
||||
{
|
||||
#if !defined(QT_OPENGL_ES_2)
|
||||
if (!QOpenGLFunctions::isES()) {
|
||||
if (!QOpenGLContext::currentContext()->isES()) {
|
||||
Q_D(QOpenGLTexture);
|
||||
d->create();
|
||||
Q_ASSERT(d->texFuncs);
|
||||
@ -3207,7 +3207,7 @@ float QOpenGLTexture::minimumLevelOfDetail() const
|
||||
void QOpenGLTexture::setMaximumLevelOfDetail(float value)
|
||||
{
|
||||
#if !defined(QT_OPENGL_ES_2)
|
||||
if (!QOpenGLFunctions::isES()) {
|
||||
if (!QOpenGLContext::currentContext()->isES()) {
|
||||
Q_D(QOpenGLTexture);
|
||||
d->create();
|
||||
Q_ASSERT(d->texFuncs);
|
||||
@ -3243,7 +3243,7 @@ float QOpenGLTexture::maximumLevelOfDetail() const
|
||||
void QOpenGLTexture::setLevelOfDetailRange(float min, float max)
|
||||
{
|
||||
#if !defined(QT_OPENGL_ES_2)
|
||||
if (!QOpenGLFunctions::isES()) {
|
||||
if (!QOpenGLContext::currentContext()->isES()) {
|
||||
Q_D(QOpenGLTexture);
|
||||
d->create();
|
||||
Q_ASSERT(d->texFuncs);
|
||||
@ -3282,7 +3282,7 @@ QPair<float, float> QOpenGLTexture::levelOfDetailRange() const
|
||||
void QOpenGLTexture::setLevelofDetailBias(float bias)
|
||||
{
|
||||
#if !defined(QT_OPENGL_ES_2)
|
||||
if (!QOpenGLFunctions::isES()) {
|
||||
if (!QOpenGLContext::currentContext()->isES()) {
|
||||
Q_D(QOpenGLTexture);
|
||||
d->create();
|
||||
Q_ASSERT(d->texFuncs);
|
||||
|
@ -378,7 +378,7 @@ void QOpenGLTextureGlyphCache::fillTexture(const Coord &c, glyph_t glyph, QFixed
|
||||
|| mask.format() == QImage::Format_ARGB32_Premultiplied
|
||||
#else
|
||||
|| (mask.format() == QImage::Format_ARGB32_Premultiplied
|
||||
&& QOpenGLFunctions::isES())
|
||||
&& ctx->isES())
|
||||
#endif
|
||||
) {
|
||||
for (int y = 0; y < maskHeight; ++y) {
|
||||
@ -396,7 +396,7 @@ void QOpenGLTextureGlyphCache::fillTexture(const Coord &c, glyph_t glyph, QFixed
|
||||
src[x] = qRgba(r, g, b, avg);
|
||||
// swizzle the bits to accommodate for the GL_RGBA upload.
|
||||
#if Q_BYTE_ORDER != Q_BIG_ENDIAN
|
||||
if (QOpenGLFunctions::isES())
|
||||
if (ctx->isES())
|
||||
#endif
|
||||
src[x] = ARGB2RGBA(src[x]);
|
||||
}
|
||||
@ -409,7 +409,7 @@ void QOpenGLTextureGlyphCache::fillTexture(const Coord &c, glyph_t glyph, QFixed
|
||||
#ifdef QT_OPENGL_ES_2
|
||||
GLenum fmt = GL_RGBA;
|
||||
#else
|
||||
GLenum fmt = QOpenGLFunctions::isES() ? GL_RGBA : GL_BGRA;
|
||||
GLenum fmt = ctx->isES() ? GL_RGBA : GL_BGRA;
|
||||
#endif // QT_OPENGL_ES_2
|
||||
|
||||
#if Q_BYTE_ORDER == Q_BIG_ENDIAN
|
||||
|
@ -42,14 +42,13 @@
|
||||
#include "qopengltexturehelper_p.h"
|
||||
|
||||
#include <QOpenGLContext>
|
||||
#include <QOpenGLFunctions>
|
||||
|
||||
QT_BEGIN_NAMESPACE
|
||||
|
||||
QOpenGLTextureHelper::QOpenGLTextureHelper(QOpenGLContext *context)
|
||||
{
|
||||
// Resolve EXT_direct_state_access entry points if present
|
||||
if (!QOpenGLFunctions::isES()
|
||||
if (!context->isES()
|
||||
&& context->hasExtension(QByteArrayLiteral("GL_EXT_direct_state_access"))) {
|
||||
TextureParameteriEXT = reinterpret_cast<void (QOPENGLF_APIENTRYP)(GLuint , GLenum , GLenum , GLint )>(context->getProcAddress(QByteArrayLiteral("glTextureParameteriEXT")));
|
||||
TextureParameterivEXT = reinterpret_cast<void (QOPENGLF_APIENTRYP)(GLuint , GLenum , GLenum , const GLint *)>(context->getProcAddress(QByteArrayLiteral("glTextureParameterivEXT")));
|
||||
@ -122,7 +121,7 @@ QOpenGLTextureHelper::QOpenGLTextureHelper(QOpenGLContext *context)
|
||||
}
|
||||
|
||||
// Some DSA functions are part of NV_texture_multisample instead
|
||||
if (!QOpenGLFunctions::isES()
|
||||
if (!context->isES()
|
||||
&& context->hasExtension(QByteArrayLiteral("GL_NV_texture_multisample"))) {
|
||||
TextureImage3DMultisampleNV = reinterpret_cast<void (QOPENGLF_APIENTRYP)(GLuint , GLenum , GLsizei , GLint , GLsizei , GLsizei , GLsizei , GLboolean )>(context->getProcAddress(QByteArrayLiteral("glTextureImage3DMultisampleNV")));
|
||||
TextureImage2DMultisampleNV = reinterpret_cast<void (QOPENGLF_APIENTRYP)(GLuint , GLenum , GLsizei , GLint , GLsizei , GLsizei , GLboolean )>(context->getProcAddress(QByteArrayLiteral("glTextureImage2DMultisampleNV")));
|
||||
@ -138,7 +137,7 @@ QOpenGLTextureHelper::QOpenGLTextureHelper(QOpenGLContext *context)
|
||||
// Hence, we resolve them "the hard way"
|
||||
|
||||
#if defined(Q_OS_WIN) && !defined(QT_OPENGL_ES_2)
|
||||
HMODULE handle = static_cast<HMODULE>(QOpenGLFunctions::platformGLHandle());
|
||||
HMODULE handle = static_cast<HMODULE>(QOpenGLContext::openGLModuleHandle());
|
||||
if (!handle)
|
||||
handle = GetModuleHandleA("opengl32.dll");
|
||||
|
||||
@ -191,7 +190,7 @@ QOpenGLTextureHelper::QOpenGLTextureHelper(QOpenGLContext *context)
|
||||
TexSubImage1D = reinterpret_cast<void (QOPENGLF_APIENTRYP)(GLenum , GLint , GLint , GLsizei , GLenum , GLenum , const GLvoid *)>(context->getProcAddress(QByteArrayLiteral("glTexSubImage1D")));
|
||||
#endif
|
||||
|
||||
if (QOpenGLFunctions::isES() && context->hasExtension(QByteArrayLiteral("GL_OES_texture_3D"))) {
|
||||
if (context->isES() && context->hasExtension(QByteArrayLiteral("GL_OES_texture_3D"))) {
|
||||
TexImage3D = reinterpret_cast<void (QOPENGLF_APIENTRYP)(GLenum, GLint, GLint, GLsizei, GLsizei, GLsizei, GLint, GLenum, GLenum, const GLvoid*)>(context->getProcAddress(QByteArrayLiteral("glTexImage3DOES")));
|
||||
TexSubImage3D = reinterpret_cast<void (QOPENGLF_APIENTRYP)(GLenum, GLint, GLint, GLint, GLint, GLsizei, GLsizei, GLsizei, GLenum, GLenum, const GLvoid*)>(context->getProcAddress(QByteArrayLiteral("glTexSubImage3DOES")));
|
||||
CompressedTexImage3D = reinterpret_cast<void (QOPENGLF_APIENTRYP)(GLenum, GLint, GLenum, GLsizei, GLsizei, GLsizei, GLint, GLsizei, const GLvoid*)>(context->getProcAddress(QByteArrayLiteral("glCompressedTexImage3DOES")));
|
||||
|
@ -124,11 +124,6 @@ public:
|
||||
|
||||
bool QOpenGLTimerQueryPrivate::create()
|
||||
{
|
||||
if (QOpenGLFunctions::isES()) {
|
||||
qWarning("QOpenGLTimerQuery: Not supported on dynamic GL ES");
|
||||
return false;
|
||||
}
|
||||
|
||||
QOpenGLContext *ctx = QOpenGLContext::currentContext();
|
||||
|
||||
if (timer && context == ctx)
|
||||
@ -140,6 +135,11 @@ bool QOpenGLTimerQueryPrivate::create()
|
||||
return false;
|
||||
}
|
||||
|
||||
if (context->isES()) {
|
||||
qWarning("QOpenGLTimerQuery: Not supported on OpenGL ES");
|
||||
return false;
|
||||
}
|
||||
|
||||
// Resolve the functions provided by OpenGL 1.5 and OpenGL 3.3 or ARB_timer_query
|
||||
core = new QOpenGLQueryHelper(context);
|
||||
|
||||
|
@ -59,7 +59,7 @@ public:
|
||||
QVertexArrayObjectHelper(QOpenGLContext *context)
|
||||
{
|
||||
Q_ASSERT(context);
|
||||
if (QOpenGLFunctions::isES()) {
|
||||
if (context->isES()) {
|
||||
GenVertexArrays = reinterpret_cast<void (QOPENGLF_APIENTRYP)(GLsizei , GLuint *)>(context->getProcAddress(QByteArrayLiteral("glGenVertexArraysOES")));
|
||||
DeleteVertexArrays = reinterpret_cast<void (QOPENGLF_APIENTRYP)(GLsizei , const GLuint *)>(context->getProcAddress(QByteArrayLiteral("glDeleteVertexArraysOES")));
|
||||
BindVertexArray = reinterpret_cast<void (QOPENGLF_APIENTRYP)(GLuint )>(context->getProcAddress(QByteArrayLiteral("glBindVertexArrayOES")));
|
||||
@ -160,7 +160,7 @@ bool QOpenGLVertexArrayObjectPrivate::create()
|
||||
context = ctx;
|
||||
QObject::connect(context, SIGNAL(aboutToBeDestroyed()), q, SLOT(_q_contextAboutToBeDestroyed()));
|
||||
|
||||
if (QOpenGLFunctions::isES()) {
|
||||
if (ctx->isES()) {
|
||||
if (ctx->hasExtension(QByteArrayLiteral("GL_OES_vertex_array_object"))) {
|
||||
vaoFuncs.helper = new QVertexArrayObjectHelper(ctx);
|
||||
vaoFuncsType = OES;
|
||||
|
@ -286,7 +286,7 @@ GLuint QPlatformBackingStore::toTexture(const QRegion &dirtyRegion) const
|
||||
glGenTextures(1, &d_ptr->textureId);
|
||||
glBindTexture(GL_TEXTURE_2D, d_ptr->textureId);
|
||||
#ifndef QT_OPENGL_ES_2
|
||||
if (!QOpenGLFunctions::isES()) {
|
||||
if (!QOpenGLContext::currentContext()->isES()) {
|
||||
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_BASE_LEVEL, 0);
|
||||
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAX_LEVEL, 0);
|
||||
}
|
||||
|
@ -163,7 +163,7 @@ QGLEngineSharedShaders::QGLEngineSharedShaders(const QGLContext* context)
|
||||
code[NonPremultipliedImageSrcFragmentShader] = qglslNonPremultipliedImageSrcFragmentShader;
|
||||
code[CustomImageSrcFragmentShader] = qglslCustomSrcFragmentShader; // Calls "customShader", which must be appended
|
||||
code[SolidBrushSrcFragmentShader] = qglslSolidBrushSrcFragmentShader;
|
||||
if (!QOpenGLFunctions::isES())
|
||||
if (!context->contextHandle()->isES())
|
||||
code[TextureBrushSrcFragmentShader] = qglslTextureBrushSrcFragmentShader_desktop;
|
||||
else
|
||||
code[TextureBrushSrcFragmentShader] = qglslTextureBrushSrcFragmentShader_ES;
|
||||
|
@ -539,7 +539,7 @@ void QGL2PaintEngineEx::beginNativePainting()
|
||||
d->funcs.glDisableVertexAttribArray(i);
|
||||
|
||||
#ifndef QT_OPENGL_ES_2
|
||||
if (!QOpenGLFunctions::isES()) {
|
||||
if (!d->ctx->contextHandle()->isES()) {
|
||||
const QGLContext *ctx = d->ctx;
|
||||
const QGLFormat &fmt = d->device->format();
|
||||
if (fmt.majorVersion() < 3 || (fmt.majorVersion() == 3 && fmt.minorVersion() < 1)
|
||||
@ -597,7 +597,7 @@ void QGL2PaintEngineExPrivate::resetGLState()
|
||||
ctx->d_func()->setVertexAttribArrayEnabled(QT_VERTEX_COORDS_ATTR, false);
|
||||
ctx->d_func()->setVertexAttribArrayEnabled(QT_OPACITY_ATTR, false);
|
||||
#ifndef QT_OPENGL_ES_2
|
||||
if (!QOpenGLFunctions::isES()) {
|
||||
if (!ctx->contextHandle()->isES()) {
|
||||
// gl_Color, corresponding to vertex attribute 3, may have been changed
|
||||
float color[] = { 1.0f, 1.0f, 1.0f, 1.0f };
|
||||
funcs.glVertexAttrib4fv(3, color);
|
||||
@ -1353,10 +1353,11 @@ void QGL2PaintEngineEx::compositionModeChanged()
|
||||
|
||||
void QGL2PaintEngineEx::renderHintsChanged()
|
||||
{
|
||||
Q_D(QGL2PaintEngineEx);
|
||||
state()->renderHintsChanged = true;
|
||||
|
||||
#if !defined(QT_OPENGL_ES_2)
|
||||
if (!QOpenGLFunctions::isES()) {
|
||||
if (!d->ctx->contextHandle()->isES()) {
|
||||
if ((state()->renderHints & QPainter::Antialiasing)
|
||||
|| (state()->renderHints & QPainter::HighQualityAntialiasing))
|
||||
glEnable(GL_MULTISAMPLE);
|
||||
@ -1365,7 +1366,6 @@ void QGL2PaintEngineEx::renderHintsChanged()
|
||||
}
|
||||
#endif
|
||||
|
||||
Q_D(QGL2PaintEngineEx);
|
||||
d->lastTextureUsed = GLuint(-1);
|
||||
d->brushTextureDirty = true;
|
||||
// qDebug("QGL2PaintEngineEx::renderHintsChanged() not implemented!");
|
||||
@ -2032,14 +2032,14 @@ bool QGL2PaintEngineEx::begin(QPaintDevice *pdev)
|
||||
glDisable(GL_SCISSOR_TEST);
|
||||
|
||||
#if !defined(QT_OPENGL_ES_2)
|
||||
if (!QOpenGLFunctions::isES())
|
||||
if (!d->ctx->contextHandle()->isES())
|
||||
glDisable(GL_MULTISAMPLE);
|
||||
#endif
|
||||
|
||||
d->glyphCacheFormat = QFontEngine::Format_A8;
|
||||
|
||||
#if !defined(QT_OPENGL_ES_2)
|
||||
if (!QOpenGLFunctions::isES()) {
|
||||
if (!d->ctx->contextHandle()->isES()) {
|
||||
d->glyphCacheFormat = QFontEngine::Format_A32;
|
||||
d->multisamplingAlwaysEnabled = false;
|
||||
} else {
|
||||
|
@ -319,7 +319,7 @@ void QGLTextureGlyphCache::fillTexture(const Coord &c, glyph_t glyph, QFixed sub
|
||||
uchar g = src[x] >> 8;
|
||||
uchar b = src[x];
|
||||
quint32 avg = (quint32(r) + quint32(g) + quint32(b) + 1) / 3; // "+1" for rounding.
|
||||
if (QOpenGLFunctions::isES()) {
|
||||
if (ctx->contextHandle()->isES()) {
|
||||
// swizzle the bits to accommodate for the GL_RGBA upload.
|
||||
src[x] = (avg << 24) | (quint32(r) << 0) | (quint32(g) << 8) | (quint32(b) << 16);
|
||||
} else {
|
||||
@ -333,7 +333,7 @@ void QGLTextureGlyphCache::fillTexture(const Coord &c, glyph_t glyph, QFixed sub
|
||||
if (mask.format() == QImage::Format_RGB32) {
|
||||
GLenum format = GL_RGBA;
|
||||
#if !defined(QT_OPENGL_ES_2)
|
||||
if (!QOpenGLFunctions::isES())
|
||||
if (!ctx->contextHandle()->isES())
|
||||
format = GL_BGRA;
|
||||
#endif
|
||||
glTexSubImage2D(GL_TEXTURE_2D, 0, c.x, c.y, maskWidth, maskHeight, format, GL_UNSIGNED_BYTE, mask.bits());
|
||||
|
@ -1700,7 +1700,7 @@ QImage qt_gl_read_texture(const QSize &size, bool alpha_format, bool include_alp
|
||||
int w = size.width();
|
||||
int h = size.height();
|
||||
#ifndef QT_OPENGL_ES
|
||||
if (!QOpenGLFunctions::isES()) {
|
||||
if (!QOpenGLContext::currentContext()->isES()) {
|
||||
//### glGetTexImage not in GL ES 2.0, need to do something else here!
|
||||
glGetTexImage(GL_TEXTURE_2D, 0, GL_RGBA, GL_UNSIGNED_BYTE, img.bits());
|
||||
}
|
||||
@ -2284,7 +2284,8 @@ QGLTexture* QGLContextPrivate::bindTexture(const QImage &image, GLenum target, G
|
||||
glBindTexture(target, tx_id);
|
||||
glTexParameteri(target, GL_TEXTURE_MAG_FILTER, filtering);
|
||||
|
||||
bool genMipmap = !QOpenGLFunctions::isES();
|
||||
QOpenGLContext *ctx = QOpenGLContext::currentContext();
|
||||
bool genMipmap = !ctx->isES();
|
||||
if (glFormat.directRendering()
|
||||
&& (qgl_extensions()->hasOpenGLExtension(QOpenGLExtensions::GenerateMipmap))
|
||||
&& target == GL_TEXTURE_2D
|
||||
@ -2426,7 +2427,7 @@ QGLTexture* QGLContextPrivate::bindTexture(const QImage &image, GLenum target, G
|
||||
printf(" - did byte swapping (%d ms)\n", time.elapsed());
|
||||
#endif
|
||||
}
|
||||
if (QOpenGLFunctions::isES()) {
|
||||
if (ctx->isES()) {
|
||||
// OpenGL/ES requires that the internal and external formats be
|
||||
// identical.
|
||||
internalFormat = externalFormat;
|
||||
@ -2439,7 +2440,7 @@ QGLTexture* QGLContextPrivate::bindTexture(const QImage &image, GLenum target, G
|
||||
const QImage &constRef = img; // to avoid detach in bits()...
|
||||
glTexImage2D(target, 0, internalFormat, img.width(), img.height(), 0, externalFormat,
|
||||
pixel_type, constRef.bits());
|
||||
if (genMipmap && QOpenGLFunctions::isES())
|
||||
if (genMipmap && ctx->isES())
|
||||
functions->glGenerateMipmap(target);
|
||||
#ifndef QT_NO_DEBUG
|
||||
GLenum error = glGetError();
|
||||
@ -2516,13 +2517,15 @@ QGLTexture *QGLContextPrivate::bindTexture(const QPixmap &pixmap, GLenum target,
|
||||
/*! \internal */
|
||||
int QGLContextPrivate::maxTextureSize()
|
||||
{
|
||||
Q_Q(QGLContext);
|
||||
|
||||
if (max_texture_size != -1)
|
||||
return max_texture_size;
|
||||
|
||||
glGetIntegerv(GL_MAX_TEXTURE_SIZE, &max_texture_size);
|
||||
|
||||
#ifndef QT_OPENGL_ES
|
||||
if (!QOpenGLFunctions::isES()) {
|
||||
if (!q->contextHandle()->isES()) {
|
||||
GLenum proxy = GL_PROXY_TEXTURE_2D;
|
||||
|
||||
GLint size;
|
||||
@ -2700,7 +2703,7 @@ static void qDrawTextureRect(const QRectF &target, GLint textureWidth, GLint tex
|
||||
Q_UNUSED(textureHeight);
|
||||
Q_UNUSED(textureTarget);
|
||||
#else
|
||||
if (textureTarget != GL_TEXTURE_2D && !QOpenGLFunctions::isES()) {
|
||||
if (textureTarget != GL_TEXTURE_2D && !QOpenGLContext::currentContext()->isES()) {
|
||||
if (textureWidth == -1 || textureHeight == -1) {
|
||||
glGetTexLevelParameteriv(textureTarget, 0, GL_TEXTURE_WIDTH, &textureWidth);
|
||||
glGetTexLevelParameteriv(textureTarget, 0, GL_TEXTURE_HEIGHT, &textureHeight);
|
||||
@ -2767,7 +2770,7 @@ void QGLContext::drawTexture(const QRectF &target, GLuint textureId, GLenum text
|
||||
#endif
|
||||
|
||||
#ifndef QT_OPENGL_ES_2
|
||||
if (!QOpenGLFunctions::isES()) {
|
||||
if (!contextHandle()->isES()) {
|
||||
#ifdef QT_OPENGL_ES
|
||||
if (textureTarget != GL_TEXTURE_2D) {
|
||||
qWarning("QGLContext::drawTexture(): texture target must be GL_TEXTURE_2D on OpenGL ES");
|
||||
@ -2829,7 +2832,7 @@ void QGLContext::drawTexture(const QPointF &point, GLuint textureId, GLenum text
|
||||
Q_UNUSED(textureId);
|
||||
Q_UNUSED(textureTarget);
|
||||
#else
|
||||
if (!QOpenGLFunctions::isES()) {
|
||||
if (!contextHandle()->isES()) {
|
||||
const bool wasEnabled = glIsEnabled(GL_TEXTURE_2D);
|
||||
GLint oldTexture;
|
||||
glGetIntegerv(GL_TEXTURE_BINDING_2D, &oldTexture);
|
||||
@ -4172,7 +4175,7 @@ void QGLWidget::glDraw()
|
||||
return;
|
||||
makeCurrent();
|
||||
#ifndef QT_OPENGL_ES
|
||||
if (d->glcx->deviceIsPixmap() && !QOpenGLFunctions::isES())
|
||||
if (d->glcx->deviceIsPixmap() && !d->glcx->contextHandle()->isES())
|
||||
glDrawBuffer(GL_FRONT);
|
||||
#endif
|
||||
QSize readback_target_size = d->glcx->d_ptr->readback_target_size;
|
||||
@ -4215,20 +4218,18 @@ void QGLWidget::qglColor(const QColor& c) const
|
||||
#ifdef QT_OPENGL_ES
|
||||
glColor4f(c.redF(), c.greenF(), c.blueF(), c.alphaF());
|
||||
#else
|
||||
if (!QOpenGLFunctions::isES()) {
|
||||
Q_D(const QGLWidget);
|
||||
const QGLContext *ctx = QGLContext::currentContext();
|
||||
if (ctx) {
|
||||
if (ctx->format().rgba())
|
||||
glColor4f(c.redF(), c.greenF(), c.blueF(), c.alphaF());
|
||||
else if (!d->cmap.isEmpty()) { // QGLColormap in use?
|
||||
int i = d->cmap.find(c.rgb());
|
||||
if (i < 0)
|
||||
i = d->cmap.findNearest(c.rgb());
|
||||
glIndexi(i);
|
||||
} else
|
||||
glIndexi(ctx->colorIndex(c));
|
||||
}
|
||||
Q_D(const QGLWidget);
|
||||
const QGLContext *ctx = QGLContext::currentContext();
|
||||
if (ctx && !ctx->contextHandle()->isES()) {
|
||||
if (ctx->format().rgba())
|
||||
glColor4f(c.redF(), c.greenF(), c.blueF(), c.alphaF());
|
||||
else if (!d->cmap.isEmpty()) { // QGLColormap in use?
|
||||
int i = d->cmap.find(c.rgb());
|
||||
if (i < 0)
|
||||
i = d->cmap.findNearest(c.rgb());
|
||||
glIndexi(i);
|
||||
} else
|
||||
glIndexi(ctx->colorIndex(c));
|
||||
}
|
||||
#endif //QT_OPENGL_ES
|
||||
#else
|
||||
@ -4249,20 +4250,18 @@ void QGLWidget::qglClearColor(const QColor& c) const
|
||||
#ifdef QT_OPENGL_ES
|
||||
glClearColor(c.redF(), c.greenF(), c.blueF(), c.alphaF());
|
||||
#else
|
||||
if (!QOpenGLFunctions::isES()) {
|
||||
Q_D(const QGLWidget);
|
||||
const QGLContext *ctx = QGLContext::currentContext();
|
||||
if (ctx) {
|
||||
if (ctx->format().rgba())
|
||||
glClearColor(c.redF(), c.greenF(), c.blueF(), c.alphaF());
|
||||
else if (!d->cmap.isEmpty()) { // QGLColormap in use?
|
||||
int i = d->cmap.find(c.rgb());
|
||||
if (i < 0)
|
||||
i = d->cmap.findNearest(c.rgb());
|
||||
glClearIndex(i);
|
||||
} else {
|
||||
glClearIndex(ctx->colorIndex(c));
|
||||
}
|
||||
Q_D(const QGLWidget);
|
||||
const QGLContext *ctx = QGLContext::currentContext();
|
||||
if (ctx && !ctx->contextHandle()->isES()) {
|
||||
if (ctx->format().rgba())
|
||||
glClearColor(c.redF(), c.greenF(), c.blueF(), c.alphaF());
|
||||
else if (!d->cmap.isEmpty()) { // QGLColormap in use?
|
||||
int i = d->cmap.find(c.rgb());
|
||||
if (i < 0)
|
||||
i = d->cmap.findNearest(c.rgb());
|
||||
glClearIndex(i);
|
||||
} else {
|
||||
glClearIndex(ctx->colorIndex(c));
|
||||
}
|
||||
} else {
|
||||
glClearColor(c.redF(), c.greenF(), c.blueF(), c.alphaF());
|
||||
@ -4427,7 +4426,8 @@ static void qt_gl_draw_text(QPainter *p, int x, int y, const QString &str,
|
||||
void QGLWidget::renderText(int x, int y, const QString &str, const QFont &font)
|
||||
{
|
||||
#ifndef QT_OPENGL_ES
|
||||
if (!QOpenGLFunctions::isES()) {
|
||||
Q_D(QGLWidget);
|
||||
if (!d->glcx->contextHandle()->isES()) {
|
||||
Q_D(QGLWidget);
|
||||
if (str.isEmpty() || !isValid())
|
||||
return;
|
||||
@ -4522,7 +4522,8 @@ void QGLWidget::renderText(int x, int y, const QString &str, const QFont &font)
|
||||
void QGLWidget::renderText(double x, double y, double z, const QString &str, const QFont &font)
|
||||
{
|
||||
#ifndef QT_OPENGL_ES
|
||||
if (!QOpenGLFunctions::isES()) {
|
||||
Q_D(QGLWidget);
|
||||
if (!d->glcx->contextHandle()->isES()) {
|
||||
Q_D(QGLWidget);
|
||||
if (str.isEmpty() || !isValid())
|
||||
return;
|
||||
|
@ -321,7 +321,7 @@ QGLTemporaryContext::QGLTemporaryContext(bool, QWidget *)
|
||||
|
||||
d->context = new QOpenGLContext;
|
||||
#if !defined(QT_OPENGL_ES)
|
||||
if (!QOpenGLFunctions::isES()) {
|
||||
if (QOpenGLContext::openGLModuleType() == QOpenGLContext::DesktopGL) {
|
||||
// On desktop, request latest released version
|
||||
QSurfaceFormat format;
|
||||
#if defined(Q_OS_MAC)
|
||||
|
@ -344,7 +344,7 @@ void QGLBuffer::destroy()
|
||||
bool QGLBuffer::read(int offset, void *data, int count)
|
||||
{
|
||||
#if !defined(QT_OPENGL_ES)
|
||||
if (QOpenGLFunctions::platformGLType() != QOpenGLFunctions::GLES1) {
|
||||
if (QOpenGLContext::openGLModuleType() != QOpenGLContext::GLES1) {
|
||||
Q_D(QGLBuffer);
|
||||
if (!d->funcs->hasOpenGLFeature(QOpenGLFunctions::Buffers) || !d->guard->id())
|
||||
return false;
|
||||
|
@ -595,7 +595,7 @@ void QGLFramebufferObjectPrivate::init(QGLFramebufferObject *q, const QSize &sz,
|
||||
GL_DEPTH_COMPONENT16, size.width(), size.height());
|
||||
}
|
||||
#else
|
||||
if (QOpenGLFunctions::isES()) {
|
||||
if (ctx->contextHandle()->isES()) {
|
||||
if (funcs.hasOpenGLExtension(QOpenGLExtensions::Depth24))
|
||||
funcs.glRenderbufferStorageMultisample(GL_RENDERBUFFER, samples,
|
||||
GL_DEPTH_COMPONENT24, size.width(), size.height());
|
||||
@ -617,7 +617,7 @@ void QGLFramebufferObjectPrivate::init(QGLFramebufferObject *q, const QSize &sz,
|
||||
size.width(), size.height());
|
||||
}
|
||||
#else
|
||||
if (QOpenGLFunctions::isES()) {
|
||||
if (ctx->contextHandle()->isES()) {
|
||||
if (funcs.hasOpenGLExtension(QOpenGLExtensions::Depth24)) {
|
||||
funcs.glRenderbufferStorage(GL_RENDERBUFFER, GL_DEPTH_COMPONENT24,
|
||||
size.width(), size.height());
|
||||
@ -647,7 +647,7 @@ void QGLFramebufferObjectPrivate::init(QGLFramebufferObject *q, const QSize &sz,
|
||||
#ifdef QT_OPENGL_ES
|
||||
GLenum storage = GL_STENCIL_INDEX8;
|
||||
#else
|
||||
GLenum storage = QOpenGLFunctions::isES() ? GL_STENCIL_INDEX8 : GL_STENCIL_INDEX;
|
||||
GLenum storage = ctx->contextHandle()->isES() ? GL_STENCIL_INDEX8 : GL_STENCIL_INDEX;
|
||||
#endif
|
||||
|
||||
if (samples != 0 && funcs.hasOpenGLExtension(QOpenGLExtensions::FramebufferMultisample))
|
||||
@ -849,7 +849,7 @@ QGLFramebufferObject::QGLFramebufferObject(const QSize &size, GLenum target)
|
||||
Q_D(QGLFramebufferObject);
|
||||
d->init(this, size, NoAttachment, target,
|
||||
#ifndef QT_OPENGL_ES_2
|
||||
QOpenGLFunctions::isES() ? GL_RGBA : GL_RGBA8
|
||||
QOpenGLContext::currentContext()->isES() ? GL_RGBA : GL_RGBA8
|
||||
#else
|
||||
GL_RGBA
|
||||
#endif
|
||||
@ -869,7 +869,7 @@ QGLFramebufferObject::QGLFramebufferObject(int width, int height, GLenum target)
|
||||
Q_D(QGLFramebufferObject);
|
||||
d->init(this, QSize(width, height), NoAttachment, target,
|
||||
#ifndef QT_OPENGL_ES_2
|
||||
QOpenGLFunctions::isES() ? GL_RGBA : GL_RGBA8
|
||||
QOpenGLContext::currentContext()->isES() ? GL_RGBA : GL_RGBA8
|
||||
#else
|
||||
GL_RGBA
|
||||
#endif
|
||||
@ -926,7 +926,7 @@ QGLFramebufferObject::QGLFramebufferObject(int width, int height, Attachment att
|
||||
#ifdef QT_OPENGL_ES_2
|
||||
internal_format = GL_RGBA;
|
||||
#else
|
||||
internal_format = QOpenGLFunctions::isES() ? GL_RGBA : GL_RGBA8;
|
||||
internal_format = QOpenGLContext::currentContext()->isES() ? GL_RGBA : GL_RGBA8;
|
||||
#endif
|
||||
d->init(this, QSize(width, height), attachment, target, internal_format);
|
||||
}
|
||||
@ -953,7 +953,7 @@ QGLFramebufferObject::QGLFramebufferObject(const QSize &size, Attachment attachm
|
||||
#ifdef QT_OPENGL_ES_2
|
||||
internal_format = GL_RGBA;
|
||||
#else
|
||||
internal_format = QOpenGLFunctions::isES() ? GL_RGBA : GL_RGBA8;
|
||||
internal_format = QOpenGLContext::currentContext()->isES() ? GL_RGBA : GL_RGBA8;
|
||||
#endif
|
||||
d->init(this, size, attachment, target, internal_format);
|
||||
}
|
||||
|
@ -71,7 +71,9 @@ public:
|
||||
mipmap(false)
|
||||
{
|
||||
#ifndef QT_OPENGL_ES_2
|
||||
internal_format = QOpenGLFunctions::isES() ? GL_RGBA : GL_RGBA8;
|
||||
QOpenGLContext *ctx = QOpenGLContext::currentContext();
|
||||
const bool isES = ctx ? ctx->isES() : QOpenGLContext::openGLModuleType() != QOpenGLContext::DesktopGL;
|
||||
internal_format = isES ? GL_RGBA : GL_RGBA8;
|
||||
#else
|
||||
internal_format = GL_RGBA;
|
||||
#endif
|
||||
|
@ -213,7 +213,9 @@ QGLFunctions::QGLFunctions(const QGLContext *context)
|
||||
|
||||
static int qt_gl_resolve_features()
|
||||
{
|
||||
if (QOpenGLFunctions::platformGLType() == QOpenGLFunctions::GLES2) {
|
||||
QOpenGLContext *ctx = QOpenGLContext::currentContext();
|
||||
if (ctx->isES() && QOpenGLContext::openGLModuleType() != QOpenGLContext::GLES1) {
|
||||
// OpenGL ES 2
|
||||
int features = QGLFunctions::Multitexture |
|
||||
QGLFunctions::Shaders |
|
||||
QGLFunctions::Buffers |
|
||||
@ -232,7 +234,8 @@ static int qt_gl_resolve_features()
|
||||
if (extensions.match("GL_IMG_texture_npot"))
|
||||
features |= QGLFunctions::NPOTTextures;
|
||||
return features;
|
||||
} if (QOpenGLFunctions::platformGLType() == QOpenGLFunctions::GLES1) {
|
||||
} else if (ctx->isES()) {
|
||||
// OpenGL ES 1
|
||||
int features = QGLFunctions::Multitexture |
|
||||
QGLFunctions::Buffers |
|
||||
QGLFunctions::CompressedTextures |
|
||||
@ -252,6 +255,7 @@ static int qt_gl_resolve_features()
|
||||
features |= QGLFunctions::NPOTTextures;
|
||||
return features;
|
||||
} else {
|
||||
// OpenGL
|
||||
int features = 0;
|
||||
QGLFormat::OpenGLVersionFlags versions = QGLFormat::openGLVersionFlags();
|
||||
QOpenGLExtensionMatcher extensions;
|
||||
|
@ -361,7 +361,7 @@ void QGLPixelBuffer::updateDynamicTexture(GLuint texture_id) const
|
||||
|
||||
glBindTexture(GL_TEXTURE_2D, texture_id);
|
||||
#ifndef QT_OPENGL_ES
|
||||
GLenum format = QOpenGLFunctions::isES() ? GL_RGBA : GL_RGBA8;
|
||||
GLenum format = ctx->isES() ? GL_RGBA : GL_RGBA8;
|
||||
glCopyTexImage2D(GL_TEXTURE_2D, 0, format, 0, 0, d->req_size.width(), d->req_size.height(), 0);
|
||||
#else
|
||||
glCopyTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, 0, 0, d->req_size.width(), d->req_size.height(), 0);
|
||||
@ -488,7 +488,7 @@ GLuint QGLPixelBuffer::bindTexture(const QImage &image, GLenum target)
|
||||
{
|
||||
Q_D(QGLPixelBuffer);
|
||||
#ifndef QT_OPENGL_ES
|
||||
GLenum format = QOpenGLFunctions::isES() ? GL_RGBA : GL_RGBA8;
|
||||
GLenum format = QOpenGLContext::currentContext()->isES() ? GL_RGBA : GL_RGBA8;
|
||||
return d->qctx->bindTexture(image, target, GLint(format));
|
||||
#else
|
||||
return d->qctx->bindTexture(image, target, GL_RGBA);
|
||||
@ -507,7 +507,7 @@ GLuint QGLPixelBuffer::bindTexture(const QPixmap &pixmap, GLenum target)
|
||||
{
|
||||
Q_D(QGLPixelBuffer);
|
||||
#ifndef QT_OPENGL_ES
|
||||
GLenum format = QOpenGLFunctions::isES() ? GL_RGBA : GL_RGBA8;
|
||||
GLenum format = QOpenGLContext::currentContext()->isES() ? GL_RGBA : GL_RGBA8;
|
||||
return d->qctx->bindTexture(pixmap, target, GLint(format));
|
||||
#else
|
||||
return d->qctx->bindTexture(pixmap, target, GL_RGBA);
|
||||
|
@ -248,7 +248,7 @@ bool QGLShaderPrivate::create()
|
||||
shader = glfuncs->glCreateShader(GL_VERTEX_SHADER);
|
||||
#if !defined(QT_OPENGL_ES_2)
|
||||
else if (shaderType == QGLShader::Geometry
|
||||
&& !QOpenGLFunctions::isES())
|
||||
&& !context->contextHandle()->isES())
|
||||
shader = glfuncs->glCreateShader(GL_GEOMETRY_SHADER_EXT);
|
||||
#endif
|
||||
else
|
||||
@ -430,14 +430,14 @@ bool QGLShader::compileSourceCode(const char *source)
|
||||
srclen.append(GLint(headerLen));
|
||||
}
|
||||
#ifdef QGL_DEFINE_QUALIFIERS
|
||||
if (!QOpenGLFunctions::isES()) {
|
||||
if (!QOpenGLContext::currentContext()->isES()) {
|
||||
src.append(qualifierDefines);
|
||||
srclen.append(GLint(sizeof(qualifierDefines) - 1));
|
||||
}
|
||||
#endif
|
||||
#ifdef QGL_REDEFINE_HIGHP
|
||||
if (d->shaderType == Fragment
|
||||
&& QOpenGLFunctions::isES()) {
|
||||
&& QOpenGLContext::currentContext()->isES()) {
|
||||
src.append(redefineHighp);
|
||||
srclen.append(GLint(sizeof(redefineHighp) - 1));
|
||||
}
|
||||
@ -567,8 +567,8 @@ public:
|
||||
|
||||
void initializeGeometryShaderFunctions()
|
||||
{
|
||||
if (!QOpenGLFunctions::isES()) {
|
||||
QOpenGLContext *context = QOpenGLContext::currentContext();
|
||||
QOpenGLContext *context = QOpenGLContext::currentContext();
|
||||
if (!context->isES()) {
|
||||
glProgramParameteri = (type_glProgramParameteri)
|
||||
context->getProcAddress("glProgramParameteri");
|
||||
|
||||
@ -936,7 +936,7 @@ bool QGLShaderProgram::link()
|
||||
|
||||
#if !defined(QT_OPENGL_ES_2)
|
||||
// Set up the geometry shader parameters
|
||||
if (!QOpenGLFunctions::isES()
|
||||
if (!QOpenGLContext::currentContext()->isES()
|
||||
&& d->glfuncs->glProgramParameteri) {
|
||||
foreach (QGLShader *shader, d->shaders) {
|
||||
if (shader->shaderType() & QGLShader::Geometry) {
|
||||
@ -3068,7 +3068,7 @@ int QGLShaderProgram::maxGeometryOutputVertices() const
|
||||
{
|
||||
GLint n = 0;
|
||||
#if !defined(QT_OPENGL_ES_2)
|
||||
if (!QOpenGLFunctions::isES())
|
||||
if (!QOpenGLContext::currentContext()->isES())
|
||||
glGetIntegerv(GL_MAX_GEOMETRY_OUTPUT_VERTICES_EXT, &n);
|
||||
#endif
|
||||
return n;
|
||||
|
@ -40,7 +40,7 @@
|
||||
****************************************************************************/
|
||||
|
||||
#include <QByteArray>
|
||||
#include <QOpenGLFunctions>
|
||||
#include <QOpenGLContext>
|
||||
|
||||
#ifdef Q_OS_LINUX
|
||||
#include <sys/ioctl.h>
|
||||
@ -245,9 +245,11 @@ EGLConfig QEglConfigChooser::chooseConfig()
|
||||
break;
|
||||
#ifdef EGL_VERSION_1_4
|
||||
case QSurfaceFormat::DefaultRenderableType:
|
||||
if (!QOpenGLFunctions::isES())
|
||||
#ifndef QT_NO_OPENGL
|
||||
if (QOpenGLContext::openGLModuleType() == QOpenGLContext::DesktopGL)
|
||||
configureAttributes.append(EGL_OPENGL_BIT);
|
||||
else
|
||||
#endif // QT_NO_OPENGL
|
||||
configureAttributes.append(EGL_OPENGL_ES2_BIT);
|
||||
break;
|
||||
case QSurfaceFormat::OpenGL:
|
||||
@ -361,7 +363,9 @@ QSurfaceFormat q_glFormatFromConfig(EGLDisplay display, const EGLConfig config,
|
||||
&& (renderableType & EGL_OPENGL_BIT))
|
||||
format.setRenderableType(QSurfaceFormat::OpenGL);
|
||||
else if (referenceFormat.renderableType() == QSurfaceFormat::DefaultRenderableType
|
||||
&& !QOpenGLFunctions::isES()
|
||||
#ifndef QT_NO_OPENGL
|
||||
&& QOpenGLContext::openGLModuleType() == QOpenGLContext::DesktopGL
|
||||
#endif
|
||||
&& (renderableType & EGL_OPENGL_BIT))
|
||||
format.setRenderableType(QSurfaceFormat::OpenGL);
|
||||
#endif
|
||||
|
@ -42,7 +42,7 @@
|
||||
#include "qeglplatformcontext_p.h"
|
||||
#include "qeglconvenience_p.h"
|
||||
#include <qpa/qplatformwindow.h>
|
||||
#include <QtGui/QOpenGLFunctions>
|
||||
#include <QOpenGLContext>
|
||||
|
||||
QT_BEGIN_NAMESPACE
|
||||
|
||||
@ -71,9 +71,11 @@ static inline void bindApi(const QSurfaceFormat &format)
|
||||
break;
|
||||
#ifdef EGL_VERSION_1_4
|
||||
case QSurfaceFormat::DefaultRenderableType:
|
||||
if (!QOpenGLFunctions::isES())
|
||||
#ifndef QT_NO_OPENGL
|
||||
if (QOpenGLContext::openGLModuleType() == QOpenGLContext::DesktopGL)
|
||||
eglBindAPI(EGL_OPENGL_API);
|
||||
else
|
||||
#endif // QT_NO_OPENGL
|
||||
eglBindAPI(EGL_OPENGL_ES_API);
|
||||
break;
|
||||
case QSurfaceFormat::OpenGL:
|
||||
|
@ -234,7 +234,8 @@ bool QWindowsIntegration::hasCapability(QPlatformIntegration::Capability cap) co
|
||||
return true;
|
||||
case ThreadedOpenGL:
|
||||
#if defined(QT_OPENGL_ES_2) || defined(QT_OPENGL_DYNAMIC)
|
||||
return QOpenGLFunctions::isES() ? QWindowsEGLContext::hasThreadedOpenGLCapability() : true;
|
||||
return QOpenGLContext::openGLModuleType() != QOpenGLContext::DesktopGL
|
||||
? QWindowsEGLContext::hasThreadedOpenGLCapability() : true;
|
||||
# else
|
||||
return true;
|
||||
# endif // QT_OPENGL_ES_2
|
||||
@ -298,7 +299,7 @@ QPlatformOpenGLContext
|
||||
{
|
||||
qCDebug(lcQpaGl) << __FUNCTION__ << context->format();
|
||||
#if defined(QT_OPENGL_ES_2) || defined(QT_OPENGL_DYNAMIC)
|
||||
if (QOpenGLFunctions::isES()){
|
||||
if (QOpenGLContext::openGLModuleType() != QOpenGLContext::DesktopGL) {
|
||||
if (d->m_staticEGLContext.isNull()) {
|
||||
QWindowsEGLStaticContext *staticContext = QWindowsEGLStaticContext::create();
|
||||
if (!staticContext)
|
||||
@ -309,7 +310,7 @@ QPlatformOpenGLContext
|
||||
}
|
||||
#endif
|
||||
#if !defined(QT_OPENGL_ES_2)
|
||||
if (!QOpenGLFunctions::isES()) {
|
||||
if (QOpenGLContext::openGLModuleType() == QOpenGLContext::DesktopGL) {
|
||||
if (d->m_staticOpenGLContext.isNull())
|
||||
d->m_staticOpenGLContext =
|
||||
QSharedPointer<QOpenGLStaticContext>(QOpenGLStaticContext::create());
|
||||
|
@ -125,7 +125,7 @@ void *QWindowsNativeInterface::nativeResourceForContext(const QByteArray &resour
|
||||
return 0;
|
||||
}
|
||||
#if defined(QT_OPENGL_ES_2) || defined(QT_OPENGL_DYNAMIC)
|
||||
if (QOpenGLFunctions::isES()) {
|
||||
if (QOpenGLContext::openGLModuleType() != QOpenGLContext::DesktopGL) {
|
||||
QWindowsEGLContext *windowsEglContext = static_cast<QWindowsEGLContext *>(context->handle());
|
||||
if (resource == QByteArrayLiteral("eglDisplay"))
|
||||
return windowsEglContext->eglDisplay();
|
||||
@ -136,7 +136,7 @@ void *QWindowsNativeInterface::nativeResourceForContext(const QByteArray &resour
|
||||
}
|
||||
#endif // QT_OPENGL_ES_2 || QT_OPENGL_DYNAMIC
|
||||
#if !defined(QT_OPENGL_ES_2)
|
||||
if (!QOpenGLFunctions::isES()) {
|
||||
if (QOpenGLContext::openGLModuleType() == QOpenGLContext::DesktopGL) {
|
||||
QWindowsGLContext *windowsContext = static_cast<QWindowsGLContext *>(context->handle());
|
||||
if (resource == QByteArrayLiteral("renderingContext"))
|
||||
return windowsContext->renderingContext();
|
||||
|
@ -880,7 +880,7 @@ QWindowsWindow::QWindowsWindow(QWindow *aWindow, const QWindowsWindowData &data)
|
||||
if (aWindow->surfaceType() == QWindow::OpenGLSurface) {
|
||||
setFlag(OpenGLSurface);
|
||||
#if defined(QT_OPENGL_ES_2) || defined(QT_OPENGL_DYNAMIC)
|
||||
if (QOpenGLFunctions::isES())
|
||||
if (QOpenGLContext::openGLModuleType() != QOpenGLContext::DesktopGL)
|
||||
setFlag(OpenGL_ES2);
|
||||
#endif
|
||||
}
|
||||
|
@ -752,7 +752,7 @@ void tst_QGL::openGLVersionCheck()
|
||||
#elif defined(QT_OPENGL_ES_2)
|
||||
QVERIFY(QGLFormat::openGLVersionFlags() & QGLFormat::OpenGL_ES_Version_2_0);
|
||||
#else
|
||||
if (QOpenGLFunctions::isES())
|
||||
if (QOpenGLContext::currentContext()->isES())
|
||||
QVERIFY(QGLFormat::openGLVersionFlags() & QGLFormat::OpenGL_ES_Version_2_0);
|
||||
else
|
||||
QVERIFY(QGLFormat::openGLVersionFlags() & QGLFormat::OpenGL_Version_1_1);
|
||||
@ -1534,7 +1534,7 @@ void tst_QGL::fboFormat()
|
||||
#ifdef QT_OPENGL_ES_2
|
||||
GL_RGBA;
|
||||
#else
|
||||
QOpenGLFunctions::isES() ? GL_RGBA : GL_RGBA8;
|
||||
QOpenGLContext::openGLModuleType() != QOpenGLContext::DesktopGL ? GL_RGBA : GL_RGBA8;
|
||||
#endif
|
||||
QCOMPARE(int(format1.internalTextureFormat()), expectedFormat);
|
||||
|
||||
@ -1611,7 +1611,7 @@ void tst_QGL::fboFormat()
|
||||
#ifdef QT_OPENGL_ES_2
|
||||
GL_RGBA
|
||||
#else
|
||||
QOpenGLFunctions::isES() ? GL_RGBA : GL_RGBA8
|
||||
QOpenGLContext::openGLModuleType() != QOpenGLContext::DesktopGL ? GL_RGBA : GL_RGBA8
|
||||
#endif
|
||||
);
|
||||
QVERIFY(!(format1c == format3c));
|
||||
@ -1624,7 +1624,7 @@ void tst_QGL::fboFormat()
|
||||
#ifdef QT_OPENGL_ES_2
|
||||
GL_RGBA
|
||||
#else
|
||||
QOpenGLFunctions::isES() ? GL_RGBA : GL_RGBA8
|
||||
QOpenGLContext::openGLModuleType() != QOpenGLContext::DesktopGL ? GL_RGBA : GL_RGBA8
|
||||
#endif
|
||||
);
|
||||
QVERIFY(!(format1c == format4c));
|
||||
|
@ -96,7 +96,7 @@ void tst_QGLFunctions::features()
|
||||
funcs.initializeGLFunctions();
|
||||
|
||||
// Validate the features against what we expect for this platform.
|
||||
if (QOpenGLFunctions::isES()) {
|
||||
if (QOpenGLContext::currentContext()->isES()) {
|
||||
#if !defined(QT_OPENGL_ES) || defined(QT_OPENGL_ES_2)
|
||||
QGLFunctions::OpenGLFeatures allFeatures =
|
||||
(QGLFunctions::Multitexture |
|
||||
|
@ -333,7 +333,7 @@ static inline float qrandom() { return (rand() % 100) / 100.f; }
|
||||
|
||||
void renderAScene(int w, int h)
|
||||
{
|
||||
if (QOpenGLFunctions::isES()) {
|
||||
if (QOpenGLContext::currentContext()->isES()) {
|
||||
QGLFunctions funcs(QGLContext::currentContext());
|
||||
Q_UNUSED(w);
|
||||
Q_UNUSED(h);
|
||||
|
@ -59,6 +59,7 @@
|
||||
#include <QTextEdit>
|
||||
#ifndef QT_NO_OPENGL
|
||||
#include <QtOpenGL>
|
||||
#include <QOpenGLContext>
|
||||
#endif
|
||||
#include <QStyleHints>
|
||||
|
||||
@ -2596,8 +2597,8 @@ void tst_QMdiArea::nativeSubWindows()
|
||||
const QString platformName = QGuiApplication::platformName();
|
||||
if (platformName != QLatin1String("xcb") && platformName != QLatin1String("windows"))
|
||||
QSKIP(qPrintable(QString::fromLatin1("nativeSubWindows() does not work on this platform (%1).").arg(platformName)));
|
||||
#ifdef Q_OS_WIN
|
||||
if (QOpenGLFunctions::isES())
|
||||
#if defined(Q_OS_WIN) && !defined(QT_NO_OPENGL)
|
||||
if (QOpenGLContext::openGLModuleType() != QOpenGLContext::DesktopGL)
|
||||
QSKIP("nativeSubWindows() does not work with ANGLE on Windows, QTBUG-28545.");
|
||||
#endif
|
||||
{ // Add native widgets after show.
|
||||
|
Loading…
Reference in New Issue
Block a user