本文整理汇总了C++中QSurfaceFormat::setSamples方法的典型用法代码示例。如果您正苦于以下问题:C++ QSurfaceFormat::setSamples方法的具体用法?C++ QSurfaceFormat::setSamples怎么用?C++ QSurfaceFormat::setSamples使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类QSurfaceFormat
的用法示例。
在下文中一共展示了QSurfaceFormat::setSamples方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: main
int main(int argc, char *argv[])
{
QApplication a(argc, argv);
// Set OpenGL 3.2 and, optionally, 4-sample multisampling
QSurfaceFormat format;
format.setVersion(3, 2);
format.setOption(QSurfaceFormat::DeprecatedFunctions, false);
format.setProfile(QSurfaceFormat::CoreProfile);
format.setSamples(4); // Uncomment for nice antialiasing. Not always supported.
/*** AUTOMATIC TESTING: DO NOT MODIFY ***/
/*** Check whether automatic testing is enabled */
/***/if (qgetenv("CIS277_AUTOTESTING") != nullptr) {
format.setSamples(0);
}
QSurfaceFormat::setDefaultFormat(format);
debugFormatVersion();
MainWindow w;
w.show();
return a.exec();
}
示例2: 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();
}
示例3: 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);
}
示例4: 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);*/
}
示例5: 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);
}
示例6: 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";
}
示例7: initialize
bool VideoWindow::initialize(Settings* settings)
{
qDebug("Initializing video window");
setSurfaceType(QWindow::OpenGLSurface);
setIcon(QIcon(":/icons/misc/icons/orientview.ico"));
setTitle("OrientView - Video");
resize(settings->window.width, settings->window.height);
setGeometry(QStyle::alignedRect(Qt::LeftToRight, Qt::AlignCenter, size(), QApplication::desktop()->availableGeometry()));
setWindowState(settings->window.fullscreen ? Qt::WindowFullScreen : Qt::WindowNoState);
setCursor(settings->window.hideCursor ? Qt::BlankCursor : Qt::ArrowCursor);
QSurfaceFormat surfaceFormat;
surfaceFormat.setSamples(settings->window.multisamples);
this->setFormat(surfaceFormat);
context = new QOpenGLContext();
context->setFormat(surfaceFormat);
if (!context->create())
{
qWarning("Could not create OpenGL context");
return false;
}
if (!context->makeCurrent(this))
{
qWarning("Could not make context current");
return false;
}
isInitialized = true;
return true;
}
示例8: main
int main(int argc, char **argv)
{
srand(time(NULL));
QGuiApplication app(argc, argv);
QSurfaceFormat format;
format.setSamples(16);
//1FPS
/*GameWindow window1(60);
window1.setFormat(format);
window1.resize(960, 720);
window1.setPosition(0,0);
window1.show();
window1.setAnimating(true);*/
//30FPS
GameWindow window30(60);
window30.setFormat(format);
window30.resize(960, 720);
window30.setPosition(380,0);
window30.show();
window30.setAnimating(true);
/*
//60FPS
GameWindow window60(60);
window60.setFormat(format);
window60.resize(320, 240);
window60.setPosition(0,290);
window60.show();
window60.setAnimating(true);
//120FPS
GameWindow window120(120);
window120.setFormat(format);
window120.resize(340, 240);
window120.setPosition(380,290);
window120.show();
window120.setAnimating(true);
*/
Camera *c = new Camera();
Camera *c1 = new Camera();
c->setEtat(6);
//window1.setCam(c1);
window30.setCam(c);
//window60.setCam(c);
// window120.setCam(c);
return app.exec();
}
示例9: setUseOpenGL
void MapView::setUseOpenGL(bool useOpenGL)
{
#ifndef QT_NO_OPENGL
if (useOpenGL) {
if (!qobject_cast<QOpenGLWidget*>(viewport())) {
QSurfaceFormat format = QSurfaceFormat::defaultFormat();
format.setDepthBufferSize(0); // No need for a depth buffer
format.setSamples(4); // Enable anti-aliasing
QOpenGLWidget *openGLWidget = new QOpenGLWidget(this);
openGLWidget->setFormat(format);
setViewport(openGLWidget);
}
} else {
if (qobject_cast<QOpenGLWidget*>(viewport()))
setViewport(nullptr);
}
QWidget *v = viewport();
if (mMode == StaticContents)
v->setAttribute(Qt::WA_StaticContents);
v->setMouseTracking(true);
#else
Q_UNUSED(useOpenGL)
#endif
}
示例10: qglx_reduceSurfaceFormat
QSurfaceFormat qglx_reduceSurfaceFormat(const QSurfaceFormat &format, bool *reduced)
{
QSurfaceFormat retFormat = format;
*reduced = true;
if (retFormat.redBufferSize() > 1) {
retFormat.setRedBufferSize(1);
} else if (retFormat.greenBufferSize() > 1) {
retFormat.setGreenBufferSize(1);
} else if (retFormat.blueBufferSize() > 1) {
retFormat.setBlueBufferSize(1);
} else if (retFormat.samples() > 1) {
retFormat.setSamples(qMin(retFormat.samples() / 2, 16));
} else if (retFormat.stereo()) {
retFormat.setStereo(false);
}else if (retFormat.stencilBufferSize() > 0) {
retFormat.setStencilBufferSize(0);
}else if (retFormat.hasAlpha()) {
retFormat.setAlphaBufferSize(0);
}else if (retFormat.depthBufferSize() > 0) {
retFormat.setDepthBufferSize(0);
}else if (retFormat.swapBehavior() != QSurfaceFormat::SingleBuffer) {
retFormat.setSwapBehavior(QSurfaceFormat::SingleBuffer);
}else{
*reduced = false;
}
return retFormat;
}
示例11: QWidget
PrimaryFlightDisplayQML::PrimaryFlightDisplayQML(QWidget *parent) :
QWidget(parent),
m_declarativeView(NULL),
m_uasInterface(NULL)
{
QUrl url = QUrl::fromLocalFile(QGC::shareDirectory() + "/qml/PrimaryFlightDisplayQML.qml");
QLOG_DEBUG() << url;
if (!QFile::exists(QGC::shareDirectory() + "/qml/PrimaryFlightDisplayQML.qml"))
{
QMessageBox::information(0,"Error", "" + QGC::shareDirectory() + "/qml/PrimaryFlightDisplayQML.qml" + " not found. Please reinstall the application and try again");
exit(-1);
}
m_declarativeView = new QQuickView();
m_declarativeView->engine()->addImportPath("qml/"); //For local or win32 builds
m_declarativeView->engine()->addImportPath(QGC::shareDirectory() +"/qml"); //For installed linux builds
m_declarativeView->setSource(url);
QSurfaceFormat format = m_declarativeView->format();
format.setSamples(16);
m_declarativeView->setFormat(format);
QLOG_DEBUG() << "QML Status:" << m_declarativeView->status();
m_declarativeView->setResizeMode(QQuickView::SizeRootObjectToView);
QVBoxLayout* layout = new QVBoxLayout();
QWidget *viewcontainer = QWidget::createWindowContainer(m_declarativeView);
layout->addWidget(viewcontainer);
setLayout(layout);
setContentsMargins(0,0,0,0);
show();
// Connect with UAS
connect(UASManager::instance(), SIGNAL(activeUASSet(UASInterface*)), this,
SLOT(setActiveUAS(UASInterface*)), Qt::UniqueConnection);
setActiveUAS(UASManager::instance()->getActiveUAS());
}
示例12: main
int main(int argc, char *argv[])
{
QApplication application(argc, argv);
application.setApplicationName("repliqode");
application.setOrganizationDomain("nous.ai");
// Invert the palette, for reasons
QPalette palette = QApplication::palette();
for (int group = 0; group < QPalette::NColorGroups; group++) {
QPalette::ColorGroup colorGroup = QPalette::ColorGroup(group);
for (int role = 0; role < QPalette::NColorRoles; role++) {
QPalette::ColorRole colorRole = QPalette::ColorRole(role);
QColor color = palette.color(colorGroup, colorRole);
QColor inverted(255 - color.red(), 255 - color.green(), 255 - color.blue(), color.alpha());
palette.setColor(colorGroup, colorRole, inverted);
}
}
QApplication::setPalette(palette);
// Fix antialiasing quality of hive plot
QSurfaceFormat fmt;
fmt.setSamples(32);
QSurfaceFormat::setDefaultFormat(fmt);
Window window;
window.showFullScreen();
return application.exec();
}
示例13: main
int main(int argc, char **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);
#if defined( DARWIN)
// at present mac osx Mountain Lion only supports GL3.2
// the new mavericks will have GL 4.x so can change
format.setMajorVersion(4);
format.setMinorVersion(2);
#else
// with luck we have the latest GL version so set to this
format.setMajorVersion(4);
format.setMinorVersion(3);
#endif
// now we are going to set to CoreProfile OpenGL so we can't use and old Immediate mode GL
format.setProfile(QSurfaceFormat::CoreProfile);
// now set the depth buffer to 24 bits
format.setDepthBufferSize(24);
// this will set the format for all widgets
QSurfaceFormat::setDefaultFormat(format);
// make an instance of the QApplication
CebApplication a(argc, argv);
// Create a new MainWindow
MainWindow w;
// show main window
w.show();
// show start dialog
w.showStartDialog();
// hand control over to Qt framework
return a.exec();
}
示例14: main
int main(int argc, char *argv[])
{
QApplication app(argc, argv);
Q_INIT_RESOURCE(ARehab_vTerapeuta);
QSurfaceFormat format;
format.setVersion(4, 3);
format.setProfile(QSurfaceFormat::CoreProfile);
format.setOption(QSurfaceFormat::DebugContext);
format.setRenderableType(QSurfaceFormat::OpenGL);
format.setDepthBufferSize(24);
format.setStencilBufferSize(8);
format.setSamples(4);
format.setSwapInterval(0); //Disable VSync
QSurfaceFormat::setDefaultFormat(format);
ARehabGUIDesigner::ARehabMainWindow w;
QFile styleFile(":/styles/main.qss");
styleFile.open(QFile::ReadOnly);
app.setStyleSheet(QLatin1String(styleFile.readAll()));
styleFile.close();
w.show();
return (app.exec());
}
示例15: 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();
}