qt5base-lts/tests/manual/rhi/stereo/main.cpp
Kristoffer Skau c9ad5ad3b7 Add support for stereoscopic content in QRhi::OpenGLES2
Setting the flag QSurfaceFormat::StereoBuffers does not actually do
anything, because we do not utilize the extra buffers provided. We need
to expose setting the correct buffers using glDrawBuffers between draw
calls.

Change-Id: I6a5110405e621030ac3a2886fa83df0cfe928723
Reviewed-by: Laszlo Agocs <laszlo.agocs@qt.io>
2022-11-07 09:08:44 +01:00

37 lines
843 B
C++

// Copyright (C) 2022 The Qt Company Ltd.
// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR BSD-3-Clause
// This is a demo showing stereoscopic rendering.
// For now, the backend is hardcoded to be OpenGL, because that's the only
// supported backend.
#include <QGuiApplication>
#include <QCommandLineParser>
#include "window.h"
int main(int argc, char **argv)
{
QGuiApplication app(argc, argv);
QSurfaceFormat fmt;
fmt.setDepthBufferSize(24);
fmt.setStencilBufferSize(8);
// Request stereoscopic rendering support with left/right buffers
fmt.setStereo(true);
QSurfaceFormat::setDefaultFormat(fmt);
Window w;
w.resize(1280, 720);
w.setTitle(QCoreApplication::applicationName());
w.show();
int ret = app.exec();
if (w.handle())
w.releaseSwapChain();
return ret;
}