本文整理汇总了C++中QSurfaceFormat::setDepthBufferSize方法的典型用法代码示例。如果您正苦于以下问题:C++ QSurfaceFormat::setDepthBufferSize方法的具体用法?C++ QSurfaceFormat::setDepthBufferSize怎么用?C++ QSurfaceFormat::setDepthBufferSize使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类QSurfaceFormat
的用法示例。
在下文中一共展示了QSurfaceFormat::setDepthBufferSize方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: createAndSetPlatformContext
void QMinimalEglScreen::createAndSetPlatformContext()
{
QSurfaceFormat platformFormat;
QByteArray depthString = qgetenv("QT_QPA_EGLFS_DEPTH");
if (depthString.toInt() == 16) {
platformFormat.setDepthBufferSize(16);
platformFormat.setRedBufferSize(5);
platformFormat.setGreenBufferSize(6);
platformFormat.setBlueBufferSize(5);
m_depth = 16;
m_format = QImage::Format_RGB16;
} else {
platformFormat.setDepthBufferSize(24);
platformFormat.setStencilBufferSize(8);
platformFormat.setRedBufferSize(8);
platformFormat.setGreenBufferSize(8);
platformFormat.setBlueBufferSize(8);
m_depth = 32;
m_format = QImage::Format_RGB32;
}
if (!qEnvironmentVariableIsEmpty("QT_QPA_EGLFS_MULTISAMPLE"))
platformFormat.setSamples(4);
EGLConfig config = q_configFromGLFormat(m_dpy, platformFormat);
EGLNativeWindowType eglWindow = 0;
#ifdef Q_OPENKODE
if (kdInitializeNV() == KD_ENOTINITIALIZED) {
qFatal("Did not manage to initialize openkode");
}
KDWindow *window = kdCreateWindow(m_dpy,config,0);
kdRealizeWindow(window,&eglWindow);
#endif
#ifdef QEGL_EXTRA_DEBUG
q_printEglConfig(m_dpy, config);
#endif
m_surface = eglCreateWindowSurface(m_dpy, config, eglWindow, NULL);
if (m_surface == EGL_NO_SURFACE) {
qWarning("Could not create the egl surface: error = 0x%x\n", eglGetError());
eglTerminate(m_dpy);
qFatal("EGL error");
}
// qWarning("Created surface %dx%d\n", w, h);
QEGLPlatformContext *platformContext = new QMinimalEglContext(platformFormat, 0, m_dpy);
m_platformContext = platformContext;
EGLint w,h; // screen size detection
eglQuerySurface(m_dpy, m_surface, EGL_WIDTH, &w);
eglQuerySurface(m_dpy, m_surface, EGL_HEIGHT, &h);
m_geometry = QRect(0,0,w,h);
}
示例2: main
int main(int argc, char *argv[])
{
QApplication app(argc, argv);
QApplication::setApplicationName("Editor");
QApplication::setApplicationVersion("1.0");
#if C3_OS == C3_OS_WINDOWS_NT
//Windows native theme looks so ugly
app.setStyle("fusion");
#endif
QCommandLineParser parser;
parser.setApplicationDescription("The Editor");
parser.addHelpOption();
parser.addVersionOption();
QCommandLineOption dataDirOption("root",
"Root directory location.\nThis will override ENGINE_ROOT.",
"path");
parser.addOption(dataDirOption);
parser.process(app);
QProcessEnvironment env = QProcessEnvironment::systemEnvironment();
QString absPath;
if(!parser.value(dataDirOption).isEmpty())
{
absPath = parser.value(dataDirOption);
}
else if(env.contains("ENGINE_ROOT"))
absPath = env.value("ENGINE_ROOT");
else
absPath = ".";
QFileInfo dirInfo(absPath);
if(!dirInfo.exists() || !dirInfo.isDir() || !QFileInfo::exists(absPath + "/Data"))
{
const char* msg = "Invalid root directory!";
QMessageBox::critical(nullptr, app.applicationName(), msg);
throw msg;
}
absPath = dirInfo.canonicalFilePath();
EngineLoader.SetRootDirectory(absPath.toUtf8().constData());
c3::RC.Loader = &EngineLoader;
c3::RC.Loader->InitEngine();
c3::FEditor EditorController;
c3::RC.Editor = &EditorController;
QSurfaceFormat format;
format.setVersion(4, 5);
format.setProfile(QSurfaceFormat::CoreProfile);
format.setDepthBufferSize(24);
format.setStencilBufferSize(8);
QSurfaceFormat::setDefaultFormat(format);
MainWindow mainWindow;
c3::FLogDisplay* LogDisplay = static_cast<c3::FLogDisplay*>(EditorController.GetLogDisplay());
QObject::connect(LogDisplay, &c3::FLogDisplay::LogRefreshed,
&mainWindow, &MainWindow::OnLogChanged);
mainWindow.showMaximized();
app.exec();
}
示例3: ScreenKeyboard
SsvepBciScreen::SsvepBciScreen(QSharedPointer<SsvepBci> pSsvepBci, QSharedPointer<SsvepBciSetupStimulusWidget> pSsvepBciSetupStimulusWidget, QOpenGLWidget *parent)
: m_pSsvepBci(pSsvepBci)
, m_pSsvepBciSetupStimulusWidget(pSsvepBciSetupStimulusWidget)
, m_pScreenKeyboard(QSharedPointer<ScreenKeyboard>(new ScreenKeyboard(m_pSsvepBci, m_pSsvepBciSetupStimulusWidget, QSharedPointer<SsvepBciScreen>(this))))
, m_dXPosCross(0.5)
, m_dYPosCross(0.5)
, m_dStep(0.01)
, m_bUseScreenKeyboard(false)
, m_qPainter(this)
, m_qCrossColor(Qt::red)
, m_bClearScreen(true)
{
Q_UNUSED(parent);
// register Meta Type
qRegisterMetaType<MyQList>("MyQList");
//set format of the QOpenGLWidget (enable vsync and setup buffers)
QSurfaceFormat format;
format.setDepthBufferSize(24);
format.setStencilBufferSize(8);
format.setSwapInterval(1);
setFormat(format);
// set update behaviour to preserved-swap-buffer
setUpdateBehavior(UpdateBehavior::PartialUpdate);
// connect classResult and frequency list signal of SsvepBci class to setClassResult slot
connect(m_pSsvepBci.data(), &SsvepBci::classificationResult, this, &SsvepBciScreen::setClassResults);
connect(m_pSsvepBci.data(), &SsvepBci::getFrequencyLabels, this, &SsvepBciScreen::updateFrequencyList);
// initialize freqList
m_lFreqList << 6.66 << 7.5 << 8.57 << 10 << 12;
}
示例4: QMenu
OpenGLWidget::OpenGLWidget(MainWindow* mainWindow)
: QOpenGLWidget{mainWindow}
, m_axisLegendScene{mainWindow->app()}
, m_width{0}
, m_height{0}
, m_currentLocation{}
, m_previousLocation{}
{
this->setFocusPolicy(Qt::StrongFocus);
m_contextMenu = new QMenu(this);
QMenu* createMenu = m_contextMenu->addMenu("Create");
createMenu->addAction(tr("Box"), this, SLOT(createBox()));
createMenu->addAction(tr("Cylinder"), this, SLOT(createCylinder()));
createMenu->addAction(tr("Cone"), this, SLOT(createCone()));
createMenu->addAction(tr("Sphere"), this, SLOT(createSphere()));
m_contextMenu->addAction(tr("Import Mesh"), this, SLOT(importMesh()));
QSurfaceFormat format = this->format();
format.setVersion(kOpenGLMajorVersion, kOpenGLMinorVersion);
format.setProfile(QSurfaceFormat::CoreProfile);
format.setDepthBufferSize(32);
format.setSwapBehavior(QSurfaceFormat::DoubleBuffer);
LOG(INFO) << fmt::format("Setting format with OpenGL version {}.{}", kOpenGLMajorVersion, kOpenGLMinorVersion);
this->setFormat(format);
}
示例5: main
int main(int argc, char **argv)
{
QGuiApplication app(argc, argv);
// create an OpenGL format specifier
QSurfaceFormat format;
// set the number of samples for multisampling
// will need to enable glEnable(GL_MULTISAMPLE); once we have a context
format.setSamples(4);
format.setMajorVersion(3);
format.setMinorVersion(2);
// now we are going to set to Compat Profile OpenGL so we can use and old Immediate mode GL
format.setProfile(QSurfaceFormat::CompatibilityProfile);
// now set the depth buffer to 24 bits
format.setDepthBufferSize(24);
QSurfaceFormat::setDefaultFormat(format);
// now we are going to create our scene window
OpenGLWindow window;
// we can now query the version to see if it worked
std::cout<<"Profile is "<<format.majorVersion()<<" "<<format.minorVersion()<<"\n";
// set the window size
window.resize(1024, 720);
// and finally show
window.show();
return app.exec();
}
示例6: QOpenGLWidget
GlWidget::GlWidget(QWidget *parent) : QOpenGLWidget(parent)
{
QSurfaceFormat format;
format.setDepthBufferSize(24);
format.setSamples(24);
setFormat(format);
this->setMouseTracking(true);
qApp->setOverrideCursor(Qt::BlankCursor);
soundPlayer = new soundObject();
soundPlayer->atAmbiend();
connect(&timer, SIGNAL(timeout()), this, SLOT(eventLoop()));
timer.setInterval(5);
timer.start();
currentTime.start();
canonFire = false;
horizontalAngle = 0.0f;
verticalAngle = 0.0f;
walkspeed = .05f;
canonElevation= 0;
canonTraverse = 180;
camera[0].setX(0);
camera[0].setY(0.75f);
camera[0].setZ(0);
camera[2].setX(0);
camera[2].setY(1);
camera[2].setZ(0);
}
示例7: main
int main(int argc, char** argv) try {
QApplication app(argc, argv);
app.setApplicationDisplayName("Interactive OpenBC sim. interface");
QSurfaceFormat fmt;
fmt.setDepthBufferSize(24);
//if (QCoreApplication::arguments().contains(QStringLiteral("--multisample"))) {
std::cout << "Using multisample" << std::endl;;
fmt.setSamples(4);
//}
// Hard-coded to use the core profile.
fmt.setVersion(3, 2);
fmt.setProfile(QSurfaceFormat::CoreProfile);
QSurfaceFormat::setDefaultFormat(fmt);
MainWindow mainWindow;
mainWindow.resize(mainWindow.sizeHint());
int desktopArea = QApplication::desktop()->width()*QApplication::desktop()->height();
int widgetArea = mainWindow.width()*mainWindow.height();
if (((float)widgetArea / (float)desktopArea) < 0.75f) {
mainWindow.show();
} else {
mainWindow.showMaximized();
}
return app.exec();
} catch (std::exception& e) {
std::cout << "Caught exception: " << e.what() << std::endl;
} catch (...) {
std::cout << "Caught unknown exception.\n";
}
示例8: main
int main(int argc, char *argv[])
{
qputenv("PATH", qgetenv("PATH") + ":/usr/local/bin:/usr/bin");
QApplication a(argc, argv);
QSplashScreen s(QPixmap(":/application/splash"), Qt::WindowStaysOnTopHint);
s.show();
QApplication::setOrganizationName("Regulomics");
QApplication::setApplicationName("QChromosome 4D Studio");
QApplication::setWindowIcon(QIcon(":/application/icon"));
QSurfaceFormat format;
format.setDepthBufferSize(24);
format.setVersion(4, 1);
format.setProfile(QSurfaceFormat::CoreProfile);
QSurfaceFormat::setDefaultFormat(format);
QFontDatabase::addApplicationFont(":/fonts/Roboto-Regular");
QFontDatabase::addApplicationFont(":/fonts/Roboto-Bold");
QFontDatabase::addApplicationFont(":/fonts/RobotoMono-Regular");
MainWindow w(a.arguments().mid(1));
a.installEventFilter(&w);
w.showMaximized();
s.finish(&w);
return a.exec();
}
示例9: QWindow
Window::Window(QScreen *screen) :
QWindow (screen),
scene_ (new BasicUsageScene)
{
setSurfaceType(OpenGLSurface);
QSurfaceFormat format;
format.setDepthBufferSize(24);
format.setMajorVersion(3);
format.setMinorVersion(3);
format.setSamples(4);
format.setProfile(QSurfaceFormat::CoreProfile);
resize(800, 600);
setFormat(format);
create();
context_ = new QOpenGLContext();
context_->setFormat(format);
context_->create();
scene_->setContext(context_);
initializeGl();
connect(this, SIGNAL(widthChanged(int)), this, SLOT(resizeGl()));
connect(this, SIGNAL(heightChanged(int)), this, SLOT(resizeGl()));
resizeGl();
QTimer* timer = new QTimer(this);
connect(timer, SIGNAL(timeout()), this, SLOT(updateScene()));
timer->start(16);
}
示例10: main
int main(int argc, char *argv[])
{
QApplication app(argc, argv);
QSurfaceFormat fmt;
fmt.setDepthBufferSize(24);
if (QCoreApplication::arguments().contains(QStringLiteral("--multisample")))
fmt.setSamples(4);
if (QCoreApplication::arguments().contains(QStringLiteral("--coreprofile"))) {
fmt.setVersion(3, 2);
fmt.setProfile(QSurfaceFormat::CoreProfile);
}
QSurfaceFormat::setDefaultFormat(fmt);
MainWindow mainWindow;
mainWindow.resize(mainWindow.sizeHint());
int desktopArea = QApplication::desktop()->width() *
QApplication::desktop()->height();
int widgetArea = mainWindow.width() * mainWindow.height();
if (((float)widgetArea / (float)desktopArea) < 0.75f)
mainWindow.show();
else
mainWindow.showMaximized();
return app.exec();
}
示例11: QOpenGLWidget
OGLViewer::OGLViewer(QWidget *parent)
: QOpenGLWidget(parent), mTimeCount(0), mFps(30)
, mSelectMode(OBJECT_SELECT)
, mViewCamera(new PerspectiveCamera(Point3f(10, 6, 11),
Point3f(0, 0, 0),
Vector3f(0, 1, 0),
width() / float(height())))
, box_mesh(new TriangleMesh("../../scene/obj/cube_large.obj"))
, model_mesh(new TriangleMesh("../../scene/obj/monkey.obj"))
{
// Set surface format for current widget
QSurfaceFormat format;
format.setDepthBufferSize(32);
format.setStencilBufferSize(8);
format.setSamples(4);
format.setVersion(4, 5);
format.setProfile(QSurfaceFormat::CoreProfile);
this->setFormat(format);
// Link timer trigger
/*process_time.start();
QTimer *timer = new QTimer(this);
//timer->setSingleShot(false);
connect(timer, SIGNAL(timeout()), this, SLOT(update()));
timer->start(0);*/
}
示例12: main
int main( int argc, char* argv[] )
{
QGuiApplication a( argc, argv );
QStringList args = a.arguments();
if ( args.size() != 2 )
{
qDebug() << "Please specify an obj file to load";
exit( 1 );
}
const QString fileName = args.last();
// Specify the format we wish to use
QSurfaceFormat format;
format.setMajorVersion( 3 );
#if !defined(Q_OS_MAC)
format.setMinorVersion( 3 );
#else
format.setMinorVersion( 2 );
#endif
format.setDepthBufferSize( 24 );
format.setSamples( 4 );
format.setProfile( QSurfaceFormat::CoreProfile );
OpenGLWindow w( format );
w.setScene( new MultipleLightsScene( fileName ) );
w.show();
return a.exec();
}
示例13: QOpenGLWidget
OGLViewer::OGLViewer(QWidget *parent)
: QOpenGLWidget(parent), tcount(0), fps(30)
, simp_lv(1)
, m_selectMode(OBJECT_SELECT)
{
// Set surface format for current widget
QSurfaceFormat format;
format.setDepthBufferSize(32);
format.setStencilBufferSize(8);
format.setVersion(4, 5);
format.setProfile(QSurfaceFormat::CoreProfile);
this->setFormat(format);
// Read obj file
//box_mesh = new Mesh("../../scene/obj/cube_large.obj");
//model_mesh = new Mesh("../../scene/obj/monkey.obj");
#ifdef _DEBUG
hds_box = new HDS_Mesh("../../scene/obj/frog.obj");
#else
hds_box = new HDS_Mesh("quad_cube.obj");
#endif
//hds_box->reIndexing();
//hds_box->validate();
simp_mesh = new Simplification(simp_lv, hds_box);
resetCamera();
}
示例14: QMainWindow
MainWindow::MainWindow
(
QWidget * parent
):
QMainWindow(parent),
m_ui(new Ui::MainWindow)
{
m_ui->setupUi(this);
// Setup OpenGL context format
QSurfaceFormat format;
#ifdef __APPLE__
// Get OpenGL 3.2/4.1 core context
format.setVersion(3, 2);
format.setProfile(QSurfaceFormat::CoreProfile);
#else
// Get newest available compatibility context
#endif
format.setDepthBufferSize(16);
// Create OpenGL context and window
m_canvas.reset(new gloperate_qt::QtOpenGLWindowBase(format));
// Create widget container
setCentralWidget(QWidget::createWindowContainer(m_canvas.get()));
centralWidget()->setFocusPolicy(Qt::StrongFocus);
}
示例15: main
int main(int argc, char *argv[])
{
// Enable the following to have touch events generated from mouse events.
// Very handy for testing touch event delivery without a real touch device.
// QGuiApplication::setAttribute(Qt::AA_SynthesizeTouchForUnhandledMouseEvents, true);
QGuiApplication app(argc, argv);
QScreen *screen = QGuiApplication::primaryScreen();
QRect screenGeometry = screen->availableGeometry();
QSurfaceFormat format;
format.setDepthBufferSize(16);
QRect geom = screenGeometry;
if (QCoreApplication::arguments().contains(QLatin1String("-nofullscreen")))
geom = QRect(screenGeometry.width() / 4, screenGeometry.height() / 4,
screenGeometry.width() / 2, screenGeometry.height() / 2);
QOpenGLWindow window(format, geom);
QWindowCompositor compositor(&window);
window.show();
return app.exec();
}