本文整理汇总了C++中QWindow::setFormat方法的典型用法代码示例。如果您正苦于以下问题:C++ QWindow::setFormat方法的具体用法?C++ QWindow::setFormat怎么用?C++ QWindow::setFormat使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类QWindow
的用法示例。
在下文中一共展示了QWindow::setFormat方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: 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);
//.........这里部分代码省略.........
示例2: create_sys
void QWidgetPrivate::create_sys(WId window, bool initializeWindow, bool destroyOldWindow)
{
Q_Q(QWidget);
Q_UNUSED(window);
Q_UNUSED(initializeWindow);
Q_UNUSED(destroyOldWindow);
Qt::WindowFlags flags = data.window_flags;
if (!q->testAttribute(Qt::WA_NativeWindow) && !q->isWindow())
return; // we only care about real toplevels
QWindow *win = topData()->window;
// topData() ensures the extra is created but does not ensure 'window' is non-null
// in case the extra was already valid.
if (!win) {
createTLSysExtra();
win = topData()->window;
}
win->setFlags(data.window_flags);
fixPosIncludesFrame();
if (q->testAttribute(Qt::WA_Moved))
win->setGeometry(q->geometry());
else
win->resize(q->size());
win->setScreen(QGuiApplication::screens().value(topData()->screenIndex, 0));
if (q->testAttribute(Qt::WA_TranslucentBackground)) {
QSurfaceFormat format;
format.setAlphaBufferSize(8);
win->setFormat(format);
}
if (QWidget *nativeParent = q->nativeParentWidget()) {
if (nativeParent->windowHandle()) {
if (flags & Qt::Window) {
win->setTransientParent(nativeParent->windowHandle());
win->setParent(0);
} else {
win->setTransientParent(0);
win->setParent(nativeParent->windowHandle());
}
}
}
qt_window_private(win)->positionPolicy = topData()->posIncludesFrame ?
QWindowPrivate::WindowFrameInclusive : QWindowPrivate::WindowFrameExclusive;
win->create();
// Enable nonclient-area events for QDockWidget and other NonClientArea-mouse event processing.
if ((flags & Qt::Desktop) == Qt::Window)
win->handle()->setFrameStrutEventsEnabled(true);
data.window_flags = win->flags();
QBackingStore *store = q->backingStore();
if (!store) {
if (win && q->windowType() != Qt::Desktop)
q->setBackingStore(new QBackingStore(win));
else
q->setAttribute(Qt::WA_PaintOnScreen, true);
}
setWindowModified_helper();
setWinId(win->winId());
// Check children and create windows for them if necessary
q_createNativeChildrenAndSetParent(q);
if (extra && !extra->mask.isEmpty())
setMask_sys(extra->mask);
// If widget is already shown, set window visible, too
if (q->isVisible())
win->setVisible(true);
}