本文整理汇总了C++中QSurfaceFormat类的典型用法代码示例。如果您正苦于以下问题:C++ QSurfaceFormat类的具体用法?C++ QSurfaceFormat怎么用?C++ QSurfaceFormat使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了QSurfaceFormat类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: main
int main(int argc, char *argv[])
{
QApplication app(argc, argv);
app.setAttribute(Qt::AA_DontCreateNativeWidgetSiblings);
QSurfaceFormat fmt;
fmt.setSamples(4);
QSurfaceFormat::setDefaultFormat(fmt);
Window window;
window.show();
return app.exec();
}
示例2: surfaceFormatFor
QSurfaceFormat EGLDeviceIntegration::surfaceFormatFor(const QSurfaceFormat &inputFormat) const
{
QSurfaceFormat format = inputFormat;
static const bool force888 = qEnvironmentVariableIntValue("GREENISLAND_QPA_FORCE888");
if (force888) {
format.setRedBufferSize(8);
format.setGreenBufferSize(8);
format.setBlueBufferSize(8);
}
return format;
}
示例3: main
int main(int argc, char *argv[])
{
QApplication a(argc, argv);
QSurfaceFormat format;
format.setDepthBufferSize( 4 );
format.setSamples(24);
format.setRenderableType(QSurfaceFormat::OpenGL);
a.setStyle(QStyleFactory::create("Android"));
MainWindow w;
w.showMaximized();
return a.exec();
}
示例4: main
int main(int argc, char *argv[])
{
QGuiApplication a(argc,argv);
Window w;
QSurfaceFormat f = w.requestedFormat();
f.setMajorVersion(3);
f.setMinorVersion(3);
w.setFormat(f);
w.setWidth(640);
w.setHeight(480);
w.show();
return a.exec();
}
示例5: main
int main(int argc, char* argv[])
{
QSurfaceFormat format;
format.setRenderableType(QSurfaceFormat::OpenGL);
format.setProfile(QSurfaceFormat::CoreProfile);
format.setVersion(3,3);
Magick::InitializeMagick(*argv);
QApplication a(argc, argv);
MainWindow w;
w.show();
return a.exec();
}
示例6: Q_ASSERT
bool QOpenGLFunctions_3_2_Compatibility::isContextCompatible(QOpenGLContext *context)
{
Q_ASSERT(context);
QSurfaceFormat f = context->format();
const QPair<int, int> v = qMakePair(f.majorVersion(), f.minorVersion());
if (v < qMakePair(3, 2))
return false;
if (f.profile() == QSurfaceFormat::CoreProfile)
return false;
return true;
}
示例7: surfaceFormatFor
QSurfaceFormat QEglFSHooks::surfaceFormatFor(const QSurfaceFormat &inputFormat) const
{
QSurfaceFormat format = inputFormat;
static const bool force888 = qgetenv("QT_QPA_EGLFS_FORCE888").toInt();
if (force888) {
format.setRedBufferSize(8);
format.setGreenBufferSize(8);
format.setBlueBufferSize(8);
}
return format;
}
示例8: QOpenGLWidget
GLView::GLView(int textureWidth, int textureHeight, std::function<void(GLView *)> initCallback) : QOpenGLWidget(), _textureWidth(textureWidth), _textureHeight(textureHeight)
{
#if __APPLE__
QSurfaceFormat glFormat;
glFormat.setVersion( 3, 3 );
glFormat.setProfile(QSurfaceFormat::OpenGLContextProfile::CompatibilityProfile);
glFormat.setSwapBehavior(QSurfaceFormat::SwapBehavior::SingleBuffer);
glFormat.setSwapInterval(0);
setFormat(glFormat);
#endif
_initCallback = initCallback;
}
示例9: app_init_open_gl
static void app_init_open_gl()
{
if(app_open_gl_initialized == 0)
{
QSurfaceFormat format;
format.setDepthBufferSize(24);
format.setStencilBufferSize(8);
format.setVersion(3, 2);
format.setProfile(QSurfaceFormat::CoreProfile);
QSurfaceFormat::setDefaultFormat(format);
app_open_gl_initialized = 1;
}
}
示例10: main
int main( int argc, char ** argv )
{
QApplication a( argc, argv );
QSurfaceFormat format;
format.setDepthBufferSize(16);
QSurfaceFormat::setDefaultFormat(format);
// Two top-level windows with two QOpenGLWidget children in each.
// The rendering for the four QOpenGLWidgets happens on four separate threads.
GLWidget topLevelGlWidget;
QPoint pos = QApplication::desktop()->availableGeometry(&topLevelGlWidget).topLeft() + QPoint(200, 200);
topLevelGlWidget.setWindowTitle(QStringLiteral("Threaded QOpenGLWidget example top level"));
topLevelGlWidget.resize(200, 200);
topLevelGlWidget.move(pos);
topLevelGlWidget.show();
const QString glInfo = getGlString(topLevelGlWidget.context()->functions(), GL_VENDOR)
+ QLatin1Char('/') + getGlString(topLevelGlWidget.context()->functions(), GL_RENDERER);
const bool supportsThreading = !glInfo.contains(QLatin1String("nouveau"), Qt::CaseInsensitive)
&& !glInfo.contains(QLatin1String("ANGLE"), Qt::CaseInsensitive)
&& !glInfo.contains(QLatin1String("llvmpipe"), Qt::CaseInsensitive);
const QString toolTip = supportsThreading ? glInfo : glInfo + QStringLiteral("\ndoes not support threaded OpenGL.");
topLevelGlWidget.setToolTip(toolTip);
QScopedPointer<MainWindow> mw1;
QScopedPointer<MainWindow> mw2;
if (!QApplication::arguments().contains(QStringLiteral("--single"))) {
if (supportsThreading) {
pos += QPoint(100, 100);
mw1.reset(new MainWindow);
mw1->setToolTip(toolTip);
mw1->move(pos);
mw1->setWindowTitle(QStringLiteral("Threaded QOpenGLWidget example #1"));
mw1->show();
pos += QPoint(100, 100);
mw2.reset(new MainWindow);
mw2->setToolTip(toolTip);
mw2->move(pos);
mw2->setWindowTitle(QStringLiteral("Threaded QOpenGLWidget example #2"));
mw2->show();
} else {
qWarning() << toolTip;
}
}
return a.exec();
}
示例11: QObject
ListControll::ListControll(QObject *parent) : QObject(parent), QQuickImageProvider(QQuickImageProvider::Image)
{
resetProjectToDefault();
/* QList <QString> temp;
temp.append("1");
temp.append("2");
temp.append("3");
temp.append("4");
temp.append("5");
temp.append("6");
test.append(temp);
QList <int> temp_int;
temp_int.append(200);
temp_int.append(200);
temp_int.append(200);
temp_int.append(200);
temp_int.append(200);
temp_int.append(200);
testWidth.append(temp_int);
*/
if (qgetenv("QT_QUICK_CORE_PROFILE").toInt()) {\
QSurfaceFormat f = view.format();\
f.setProfile(QSurfaceFormat::CoreProfile);\
f.setVersion(4, 4);\
view.setFormat(f);\
}\
// view.connect(view.engine(), SIGNAL(quit()), &app, SLOT(quit()));
new QQmlFileSelector(view.engine(), &view);\
view.engine()->rootContext()->setContextProperty("timeControll", this);
view.engine()->rootContext()->setContextProperty("viewerWidget", &view);
cloneImg = new ImageClone(this);
view.engine()->addImageProvider("imageProvider", cloneImg);//&image_provider);
view.setSource(QUrl("qrc:/main.qml")); \
view.setResizeMode(QQuickView::SizeRootObjectToView);
view.setPersistentOpenGLContext(true);
view.setColor("transparent");
view.setMinimumHeight(205);
view.setMinimumWidth(500);
view.setHeight(view.minimumHeight());
view.setWidth(800);
view.setFlags(Qt::CustomizeWindowHint | Qt::FramelessWindowHint | Qt::WindowTitleHint);
//view.setMaximumHeight(215);
//loadCurrentTextInTheFirstBlockWhenInit();
}
示例12: initializeContext
int KisOpenGL::initializeContext(QOpenGLContext* s) {
#ifdef HAVE_OPENGL
KisConfig cfg;
dbgUI << "OpenGL: Opening new context";
// Double check we were given the version we requested
QSurfaceFormat format = s->format();
glVersion = 100 * format.majorVersion() + format.minorVersion();
if (!SharedSurface) {
SharedSurface = new QOffscreenSurface();
SharedSurface->setFormat(format);
SharedSurface->create();
}
if (!SharedContext) {
SharedContext = new QOpenGLContext;
SharedContext->setFormat(format);
SharedContext->setShareContext(s);
SharedContext->create();
SharedContext->makeCurrent(SharedSurface);
}
QOpenGLFunctions *f = QOpenGLContext::currentContext()->functions();
QFile log(QDesktopServices::storageLocation(QDesktopServices::TempLocation) + "/krita-opengl.txt");
log.open(QFile::WriteOnly);
QString vendor((const char*)f->glGetString(GL_VENDOR));
log.write(vendor.toLatin1());
log.write(", ");
QString renderer((const char*)f->glGetString(GL_RENDERER));
log.write(renderer.toLatin1());
log.write(", ");
QString version((const char*)f->glGetString(GL_VERSION));
log.write(version.toLatin1());
// Check if we have a bugged driver that needs fence workaround
bool isOnX11 = false;
#ifdef HAVE_X11
isOnX11 = true;
#endif
if ((isOnX11 && renderer.startsWith("AMD")) || cfg.forceOpenGLFenceWorkaround()) {
NeedsFenceWorkaround = true;
}
#else
Q_UNUSED(s);
NeedsFenceWorkaround = false;
#endif
return glVersion;
}
示例13: debugFormatVersion
void debugFormatVersion()
{
QSurfaceFormat form = QSurfaceFormat::defaultFormat();
QSurfaceFormat::OpenGLContextProfile prof = form.profile();
const char *profile =
prof == QSurfaceFormat::CoreProfile ? "Core" :
prof == QSurfaceFormat::CompatibilityProfile ? "Compatibility" :
"None";
printf("Requested format:\n");
printf(" Version: %d.%d\n", form.majorVersion(), form.minorVersion());
printf(" Profile: %s\n", profile);
}
示例14: 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);
#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(1);
#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);
QSurfaceFormat::setDefaultFormat(format);
// now we are going to create our scene window
OpenGLWindow window;
// set the window size
window.resize(1024, 720);
// and finally show
window.show();
return app.exec();
}
示例15: 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();
}