void XCompositeGLXClientBufferIntegration::initializeHardware(QtWayland::Display *) { qDebug() << "Initializing GLX integration"; QPlatformNativeInterface *nativeInterface = QGuiApplicationPrivate::platformIntegration()->nativeInterface(); if (nativeInterface) { mDisplay = static_cast<Display *>(nativeInterface->nativeResourceForWindow("Display",m_compositor->window())); if (!mDisplay) qFatal("could not retireve Display from platform integration"); } else { qFatal("Platform integration doesn't have native interface"); } mScreen = XDefaultScreen(mDisplay); mHandler = new XCompositeHandler(m_compositor->handle(), mDisplay); QOpenGLContext *glContext = new QOpenGLContext(); glContext->create(); m_glxBindTexImageEXT = reinterpret_cast<PFNGLXBINDTEXIMAGEEXTPROC>(glContext->getProcAddress("glXBindTexImageEXT")); if (!m_glxBindTexImageEXT) { qDebug() << "Did not find glxBindTexImageExt, everything will FAIL!"; } m_glxReleaseTexImageEXT = reinterpret_cast<PFNGLXRELEASETEXIMAGEEXTPROC>(glContext->getProcAddress("glXReleaseTexImageEXT")); if (!m_glxReleaseTexImageEXT) { qDebug() << "Did not find glxReleaseTexImageExt"; } delete glContext; }
gl::glProc HeadlessBackend::initializeExtension(const char* name) { #if QT_VERSION >= 0x050000 QOpenGLContext* thisContext = QOpenGLContext::currentContext(); return thisContext->getProcAddress(name); #else const QGLContext* thisContext = QGLContext::currentContext(); return reinterpret_cast<mbgl::gl::glProc>(thisContext->getProcAddress(name)); #endif }
static void *get_proc_address(void *ctx, const char *name) { Q_UNUSED(ctx); QOpenGLContext *glctx = QOpenGLContext::currentContext(); if(!glctx) return nullptr; return (void *)glctx->getProcAddress(QByteArray(name)); }
void GLWidget::initializeGL() { QPalette palette; #ifndef Q_OS_WIN // getProcAddress is not working for me on Windows. if (Settings.playerGPU()) { QOpenGLContext* cx = context()->contextHandle(); if (m_glslManager && cx->hasExtension("GL_ARB_sync")) { ClientWaitSync = (ClientWaitSync_fp) cx->getProcAddress("glClientWaitSync"); } if (!ClientWaitSync) { emit gpuNotSupported(); delete m_glslManager; m_glslManager = 0; } } #endif initializeOpenGLFunctions(); qglClearColor(palette.color(QPalette::Window)); glShadeModel(GL_FLAT); glEnable(GL_TEXTURE_2D); glDisable(GL_DEPTH_TEST); glDisable(GL_CULL_FACE); glDisable(GL_LIGHTING); glDisable(GL_DITHER); glDisable(GL_BLEND); glPixelStorei(GL_UNPACK_ALIGNMENT, 1); m_condition.wakeAll(); m_isInitialized = true; }
static bool resolveGLMethods(GraphicsSurfacePrivate* p) { static bool resolved = false; if (resolved) return true; QOpenGLContext* glContext = p->glContext(); pGlXBindTexImageEXT = reinterpret_cast<PFNGLXBINDTEXIMAGEEXTPROC>(glContext->getProcAddress("glXBindTexImageEXT")); pGlXReleaseTexImageEXT = reinterpret_cast<PFNGLXRELEASETEXIMAGEEXTPROC>(glContext->getProcAddress("glXReleaseTexImageEXT")); pGlBindFramebuffer = reinterpret_cast<PFNGLBINDFRAMEBUFFERPROC>(glContext->getProcAddress("glBindFramebuffer")); pGlBlitFramebuffer = reinterpret_cast<PFNGLBLITFRAMEBUFFERPROC>(glContext->getProcAddress("glBlitFramebuffer")); resolved = pGlBlitFramebuffer && pGlBindFramebuffer && pGlXBindTexImageEXT && pGlXReleaseTexImageEXT; return resolved; }
static void* get_proc_address(void* ctx, const char* name) { Q_UNUSED(ctx); QOpenGLContext* glctx = QOpenGLContext::currentContext(); if (!glctx) return NULL; void *res = (void *)glctx->getProcAddress(QByteArray(name)); if (strcmp(name, "glMPGetNativeDisplay") == 0) { return (void *)&MPGetNativeDisplay; } #ifdef Q_OS_WIN32 // wglGetProcAddress(), which is used by Qt, does not always resolve all // builtin functions with all drivers (only extensions). Qt compensates this // for a degree, but does this only for functions Qt happens to need. So // we need our own falback as well. if (!res) { HMODULE handle = (HMODULE)QOpenGLContext::openGLModuleHandle(); if (handle) res = (void *)GetProcAddress(handle, name); } #endif return res; }
QOpenGLExtensionMatcher::QOpenGLExtensionMatcher() { QOpenGLContext *ctx = QOpenGLContext::currentContext(); QOpenGLFunctions *funcs = ctx->functions(); const char *extensionStr = 0; if (ctx->isOpenGLES() || ctx->format().majorVersion() < 3) extensionStr = reinterpret_cast<const char *>(funcs->glGetString(GL_EXTENSIONS)); if (extensionStr) { QByteArray ba(extensionStr); QList<QByteArray> extensions = ba.split(' '); m_extensions = extensions.toSet(); } else { #ifdef QT_OPENGL_3 // clear error state while (funcs->glGetError()) {} if (ctx) { qt_glGetStringi glGetStringi = (qt_glGetStringi)ctx->getProcAddress("glGetStringi"); if (!glGetStringi) return; GLint numExtensions; funcs->glGetIntegerv(GL_NUM_EXTENSIONS, &numExtensions); for (int i = 0; i < numExtensions; ++i) { const char *str = reinterpret_cast<const char *>(glGetStringi(GL_EXTENSIONS, i)); m_extensions.insert(str); } } #endif // QT_OPENGL_3 } }
static QGLMultiTextureExtensions *resolveMultiTextureExtensions (const QOpenGLContext *ctx) { Q_ASSERT(ctx); if (!qt_multitexture_funcs) qt_multitexture_funcs = new QGLMultiTextureExtensions(); if (!(qt_multitexture_funcs->multiTextureResolved)) { qt_multitexture_funcs->multiTextureResolved = true; if (!qt_multitexture_funcs->clientActiveTexture) { QOpenGLContext *vctx = const_cast<QOpenGLContext*>(ctx); qt_multitexture_funcs->clientActiveTexture = (q_PFNGLCLIENTACTIVETEXTUREPROC) vctx->getProcAddress("glClientActiveTexture"); } if (!qt_multitexture_funcs->clientActiveTexture) { QOpenGLContext *vctx = const_cast<QOpenGLContext*>(ctx); qt_multitexture_funcs->clientActiveTexture = (q_PFNGLCLIENTACTIVETEXTUREPROC) vctx->getProcAddress("glClientActiveTextureARB"); } } return qt_multitexture_funcs; }
void QMapboxGLPrivate::invalidate() { // Map thread if (!q_ptr->isExposed()) { return; } if (!context) { context.reset(new QOpenGLContext()); context->setFormat(q_ptr->requestedFormat()); context->create(); context->makeCurrent(q_ptr); mbgl::gl::InitializeExtensions([](const char *name) { QOpenGLContext *thisContext = QOpenGLContext::currentContext(); return thisContext->getProcAddress(name); }); } emit viewInvalidated(); }
// This callback is called by VLC to get OpenGL functions. static void* get_proc_address(void* data, const char* current) { VLCVideo* that = static_cast<VLCVideo*>(data); QOpenGLContext *ctx = that->mWidget->context(); return reinterpret_cast<void*>(ctx->getProcAddress(current)); }
// Debug info about OpenGL capabilities. void StelMainView::dumpOpenGLdiagnostics() const { QOpenGLContext *context = QOpenGLContext::currentContext(); if (context) { context->functions()->initializeOpenGLFunctions(); qDebug() << "initializeOpenGLFunctions()..."; QOpenGLFunctions::OpenGLFeatures oglFeatures=context->functions()->openGLFeatures(); qDebug() << "OpenGL Features:"; qDebug() << " - glActiveTexture() function" << (oglFeatures&QOpenGLFunctions::Multitexture ? "is" : "is NOT") << "available."; qDebug() << " - Shader functions" << (oglFeatures&QOpenGLFunctions::Shaders ? "are" : "are NOT ") << "available."; qDebug() << " - Vertex and index buffer functions" << (oglFeatures&QOpenGLFunctions::Buffers ? "are" : "are NOT") << "available."; qDebug() << " - Framebuffer object functions" << (oglFeatures&QOpenGLFunctions::Framebuffers ? "are" : "are NOT") << "available."; qDebug() << " - glBlendColor()" << (oglFeatures&QOpenGLFunctions::BlendColor ? "is" : "is NOT") << "available."; qDebug() << " - glBlendEquation()" << (oglFeatures&QOpenGLFunctions::BlendEquation ? "is" : "is NOT") << "available."; qDebug() << " - glBlendEquationSeparate()" << (oglFeatures&QOpenGLFunctions::BlendEquationSeparate ? "is" : "is NOT") << "available."; qDebug() << " - glBlendFuncSeparate()" << (oglFeatures&QOpenGLFunctions::BlendFuncSeparate ? "is" : "is NOT") << "available."; qDebug() << " - Blend subtract mode" << (oglFeatures&QOpenGLFunctions::BlendSubtract ? "is" : "is NOT") << "available."; qDebug() << " - Compressed texture functions" << (oglFeatures&QOpenGLFunctions::CompressedTextures ? "are" : "are NOT") << "available."; qDebug() << " - glSampleCoverage() function" << (oglFeatures&QOpenGLFunctions::Multisample ? "is" : "is NOT") << "available."; qDebug() << " - Separate stencil functions" << (oglFeatures&QOpenGLFunctions::StencilSeparate ? "are" : "are NOT") << "available."; qDebug() << " - Non power of two textures" << (oglFeatures&QOpenGLFunctions::NPOTTextures ? "are" : "are NOT") << "available."; qDebug() << " - Non power of two textures" << (oglFeatures&QOpenGLFunctions::NPOTTextureRepeat ? "can" : "CANNOT") << "use GL_REPEAT as wrap parameter."; qDebug() << " - The fixed function pipeline" << (oglFeatures&QOpenGLFunctions::FixedFunctionPipeline ? "is" : "is NOT") << "available."; qDebug() << "OpenGL shader capabilities and details:"; qDebug() << " - Vertex Shader:" << (QOpenGLShader::hasOpenGLShaders(QOpenGLShader::Vertex, context) ? "YES" : "NO"); qDebug() << " - Fragment Shader:" << (QOpenGLShader::hasOpenGLShaders(QOpenGLShader::Fragment, context) ? "YES" : "NO"); qDebug() << " - Geometry Shader:" << (QOpenGLShader::hasOpenGLShaders(QOpenGLShader::Geometry, context) ? "YES" : "NO"); qDebug() << " - TessellationControl Shader:" << (QOpenGLShader::hasOpenGLShaders(QOpenGLShader::TessellationControl, context) ? "YES" : "NO"); qDebug() << " - TessellationEvaluation Shader:" << (QOpenGLShader::hasOpenGLShaders(QOpenGLShader::TessellationEvaluation, context) ? "YES" : "NO"); qDebug() << " - Compute Shader:" << (QOpenGLShader::hasOpenGLShaders(QOpenGLShader::Compute, context) ? "YES" : "NO"); // GZ: List available extensions. Not sure if this is in any way useful? QSet<QByteArray> extensionSet=context->extensions(); qDebug() << "We have" << extensionSet.count() << "OpenGL extensions:"; QMap<QString, QString> extensionMap; QSetIterator<QByteArray> iter(extensionSet); while (iter.hasNext()) { if (!iter.peekNext().isEmpty()) {// Don't insert empty lines extensionMap.insert(QString(iter.peekNext()), QString(iter.peekNext())); } iter.next(); } QMapIterator<QString, QString> iter2(extensionMap); while (iter2.hasNext()) { qDebug() << " -" << iter2.next().key(); } // Apparently EXT_gpu_shader4 is required for GLSL1.3. (http://en.wikipedia.org/wiki/OpenGL#OpenGL_3.0). qDebug() << "EXT_gpu_shader4" << (extensionSet.contains(("EXT_gpu_shader4")) ? "present, OK." : "MISSING!"); QFunctionPointer programParameterPtr =context->getProcAddress("glProgramParameteri"); if (programParameterPtr == 0) { qDebug() << "glProgramParameteri cannot be resolved here. BAD!"; } programParameterPtr =context->getProcAddress("glProgramParameteriEXT"); if (programParameterPtr == 0) { qDebug() << "glProgramParameteriEXT cannot be resolved here. BAD!"; } } else { qDebug() << "dumpOpenGLdiagnostics(): No OpenGL context"; } }