本文整理汇总了C++中QOpenGLContext::doneCurrent方法的典型用法代码示例。如果您正苦于以下问题:C++ QOpenGLContext::doneCurrent方法的具体用法?C++ QOpenGLContext::doneCurrent怎么用?C++ QOpenGLContext::doneCurrent使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类QOpenGLContext
的用法示例。
在下文中一共展示了QOpenGLContext::doneCurrent方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1:
void OculusWin32DisplayPlugin::stop() {
_context->makeCurrent(_window);
if (_sceneSwapFbo) {
delete _sceneSwapFbo;
_sceneSwapFbo = nullptr;
}
if (_mirrorFbo) {
delete _mirrorFbo;
_mirrorFbo = nullptr;
}
_context->doneCurrent();
_timer.stop();
_window->deleteLater();
_window = nullptr;
_context->deleteLater();
_context = nullptr;
if (_hmd) {
ovr_Destroy(_hmd);
_hmd = nullptr;
}
ovr_Shutdown();
}
示例2: endRender
/******************************************************************************
* Is called after rendering has finished.
******************************************************************************/
void StandardSceneRenderer::endRender()
{
QOpenGLFramebufferObject::bindDefault();
QOpenGLContext* ctxt = QOpenGLContext::currentContext();
if(ctxt) ctxt->doneCurrent();
_framebufferObject.reset();
_offscreenContext.reset();
_offscreenSurface.reset();
ViewportSceneRenderer::endRender();
}
示例3: openGlContext
QString openGlContext()
{
QString result;
QTextStream str(&result);
QOpenGLContext context;
if (context.create()) {
# ifdef QT_OPENGL_DYNAMIC
str << "Dynamic GL ";
# endif
switch (context.openGLModuleType()) {
case QOpenGLContext::LibGL:
str << "LibGL";
break;
case QOpenGLContext::LibGLES:
str << "LibGLES";
break;
}
QWindow window;
if (QGuiApplication::platformName() == QLatin1String("greenisland"))
window.setFlags(Qt::Desktop);
window.setSurfaceType(QSurface::OpenGLSurface);
//window.setScreen(QGuiApplication::primaryScreen());
window.create();
if (context.makeCurrent(&window)) {
QOpenGLFunctions functions(&context);
str << " Vendor: " << reinterpret_cast<const char *>(functions.glGetString(GL_VENDOR))
<< "\nRenderer: " << reinterpret_cast<const char *>(functions.glGetString(GL_RENDERER))
<< "\nVersion: " << reinterpret_cast<const char *>(functions.glGetString(GL_VERSION))
<< "\nGLSL version: " << reinterpret_cast<const char *>(functions.glGetString(GL_SHADING_LANGUAGE_VERSION))
<< "\nFormat: " << context.format();
QList<QByteArray> extensionList = context.extensions().toList();
std::sort(extensionList.begin(), extensionList.end());
QByteArray extensions = extensionList.join(' ');
str << " \nFound " << extensionList.size() << " extensions:\n";
str << wordWrap(extensions, 78);
context.doneCurrent();
}
window.destroy();
} else {
str << "Unable to create an Open GL context.\n";
}
return result;
}
示例4: qCritical
OpenGLInfo::OpenGLInfo()
{
QOpenGLContext context;
QOffscreenSurface surface;
surface.create();
if (!context.create()) {
qCritical() << "Could not create QOpenGLContext";
return;
}
if (context.makeCurrent(&surface)) {
KWin::GLPlatform *platform = KWin::GLPlatform::instance();
if (context.isOpenGLES() || !QX11Info::isPlatformX11()) {
platform->detect(KWin::EglPlatformInterface);
} else {
platform->detect(KWin::GlxPlatformInterface);
}
if (platform->glRendererString().isEmpty()) {
qCritical() << "Neither GLX or EGL detection worked!";
}
openGLRenderer = QString::fromUtf8(platform->glRendererString());
openGLVersion = QString::fromUtf8(platform->glVersionString());
mesaVersion = KWin::GLPlatform::versionToString(platform->mesaVersion());
if (platform->driver() == KWin::Driver::Driver_Unknown) {
kwinDriver = platform->glVendorString();
} else {
kwinDriver = KWin::GLPlatform::driverToString(platform->driver());
}
displayServerVersion = KWin::GLPlatform::versionToString(platform->serverVersion());
}
else {
qCritical() <<"Error: makeCurrent() failed\n";
}
context.doneCurrent();
}
示例5: startResults
void ResultRecorder::startResults(const QString &id)
{
// sub process will get all this.
// safer that way, as then we keep OpenGL (and QGuiApplication) out of the host
if (!Options::instance.isSubProcess)
return;
m_results["id"] = id;
QString prettyProductName =
#if QT_VERSION >= 0x050400
QSysInfo::prettyProductName();
#else
# if defined(Q_OS_IOS)
QStringLiteral("iOS");
# elif defined(Q_OS_OSX)
QString::fromLatin1("OSX %d").arg(QSysInfo::macVersion());
# elif defined(Q_OS_WIN)
QString::fromLatin1("Windows %d").arg(QSysInfo::windowsVersion());
# elif defined(Q_OS_LINUX)
QStringLiteral("Linux");
# elif defined(Q_OS_ANDROID)
QStringLiteral("Android");
# else
QStringLiteral("unknown");
# endif
#endif
QVariantMap osMap;
osMap["prettyProductName"] = prettyProductName;
osMap["platformPlugin"] = QGuiApplication::platformName();
m_results["os"] = osMap;
m_results["qt"] = QT_VERSION_STR;
m_results["command-line"] = qApp->arguments().join(' ');
// The following code makes the assumption that an OpenGL context the GUI
// thread will get the same capabilities as the render thread's OpenGL
// context. Not 100% accurate, but it works...
QOpenGLContext context;
context.create();
QOffscreenSurface surface;
// In very odd cases, we can get incompatible configs here unless we pass the
// GL context's format on to the offscreen format.
surface.setFormat(context.format());
surface.create();
if (!context.makeCurrent(&surface)) {
qWarning() << "failed to acquire GL context to get version info.";
return;
}
QOpenGLFunctions *func = context.functions();
#if QT_VERSION >= 0x050300
const char *vendor = (const char *) func->glGetString(GL_VENDOR);
const char *renderer = (const char *) func->glGetString(GL_RENDERER);
const char *version = (const char *) func->glGetString(GL_VERSION);
#else
Q_UNUSED(func);
const char *vendor = (const char *) glGetString(GL_VENDOR);
const char *renderer = (const char *) glGetString(GL_RENDERER);
const char *version = (const char *) glGetString(GL_VERSION);
#endif
if (!Options::instance.printJsonToStdout) {
std::cout << "ID: " << id.toStdString() << std::endl;
std::cout << "OS: " << prettyProductName.toStdString() << std::endl;
std::cout << "QPA: " << QGuiApplication::platformName().toStdString() << std::endl;
std::cout << "GL_VENDOR: " << vendor << std::endl;
std::cout << "GL_RENDERER: " << renderer << std::endl;
std::cout << "GL_VERSION: " << version << std::endl;
}
QVariantMap glInfo;
glInfo["vendor"] = vendor;
glInfo["renderer"] = renderer;
glInfo["version"] = version;
m_results["opengl"] = glInfo;
context.doneCurrent();
}
示例6: memset
bool OculusWin32DisplayPlugin::start() {
{
ovrInitParams initParams; memset(&initParams, 0, sizeof(initParams));
#ifdef DEBUG
initParams.Flags |= ovrInit_Debug;
#endif
ovrResult result = ovr_Initialize(&initParams);
Q_ASSERT(OVR_SUCCESS(result));
result = ovr_Create(&_hmd, &_luid);
_hmdDesc = ovr_GetHmdDesc(_hmd);
for_each_eye([&](ovrEyeType eye) {
_eyeFovs[eye] = _hmdDesc.DefaultEyeFov[eye];
_eyeProjections[eye] = toGlm(ovrMatrix4f_Projection(_eyeFovs[eye],
0.01f, 100.0f, ovrProjection_RightHanded));
ovrEyeRenderDesc erd = ovr_GetRenderDesc(_hmd, eye, _eyeFovs[eye]);
_eyeOffsets[eye] = erd.HmdToEyeViewOffset;
});
_eyeTextureSize = ovr_GetFovTextureSize(_hmd, ovrEye_Left, _eyeFovs[ovrEye_Left], 1.0f);
_renderTargetSize = { _eyeTextureSize.w * 2, _eyeTextureSize.h };
ovr_ConfigureTracking(_hmd,
ovrTrackingCap_Orientation | ovrTrackingCap_Position | ovrTrackingCap_MagYawCorrection,
ovrTrackingCap_Orientation);
}
Q_ASSERT(!_window);
Q_ASSERT(_shareContext);
_window = new QWindow;
_window->setSurfaceType(QSurface::OpenGLSurface);
_window->setFormat(getDesiredSurfaceFormat());
_context = new QOpenGLContext;
_context->setFormat(getDesiredSurfaceFormat());
_context->setShareContext(_shareContext);
_context->create();
_window->show();
_window->setGeometry(QRect(100, -800, 1280, 720));
bool result = _context->makeCurrent(_window);
#if defined(Q_OS_WIN)
if (wglewGetExtension("WGL_EXT_swap_control")) {
wglSwapIntervalEXT(0);
int swapInterval = wglGetSwapIntervalEXT();
qDebug("V-Sync is %s\n", (swapInterval > 0 ? "ON" : "OFF"));
}
#elif defined(Q_OS_LINUX)
#else
qCDebug(interfaceapp, "V-Sync is FORCED ON on this system\n");
#endif
Q_ASSERT(result);
{
// The geometry and shader for rendering the 2D UI surface when needed
_program = oria::loadProgram(
Resource::SHADERS_TEXTURED_VS,
Resource::SHADERS_TEXTURED_FS);
_quad = oria::loadPlane(_program, 1.0f);
glClearColor(0, 1, 1, 1);
glDisable(GL_DEPTH_TEST);
glEnable(GL_BLEND);
glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
_mirrorFbo = new MirrorFramebufferWrapper(_hmd);
_sceneSwapFbo = new SwapFramebufferWrapper(_hmd);
_sceneSwapFbo->Init(toGlm(_renderTargetSize));
_uiSwapFbo = new SwapFramebufferWrapper(_hmd);
_uiSwapFbo->Init(_uiSize);
_mirrorFbo->Init(uvec2(100, 100));
_context->doneCurrent();
}
_sceneLayer.ColorTexture[0] = _sceneSwapFbo->color;
_sceneLayer.ColorTexture[1] = nullptr;
_sceneLayer.Viewport[0].Pos = { 0, 0 };
_sceneLayer.Viewport[0].Size = _eyeTextureSize;
_sceneLayer.Viewport[1].Pos = { _eyeTextureSize.w, 0 };
_sceneLayer.Viewport[1].Size = _eyeTextureSize;
_sceneLayer.Header.Type = ovrLayerType_EyeFov;
_sceneLayer.Header.Flags = ovrLayerFlag_TextureOriginAtBottomLeft;
for_each_eye([&](ovrEyeType eye) {
_eyeViewports[eye] = _sceneLayer.Viewport[eye];
_sceneLayer.Fov[eye] = _eyeFovs[eye];
});
_uiLayer.ColorTexture = _uiSwapFbo->color;
_uiLayer.Header.Type = ovrLayerType_QuadInWorld;
_uiLayer.Header.Flags = ovrLayerFlag_TextureOriginAtBottomLeft;
_uiLayer.QuadPoseCenter.Orientation = { 0, 0, 0, 1 };
_uiLayer.QuadPoseCenter.Position = { 0, 0, -1 };
_uiLayer.QuadSize = { aspect(_uiSize), 1.0f };
_uiLayer.Viewport = { { 0, 0 }, { (int)_uiSize.x, (int)_uiSize.y } };
_timer.start(0);
//.........这里部分代码省略.........