当前位置: 首页>>代码示例>>C++>>正文


C++ QSurfaceFormat::setRenderableType方法代码示例

本文整理汇总了C++中QSurfaceFormat::setRenderableType方法的典型用法代码示例。如果您正苦于以下问题:C++ QSurfaceFormat::setRenderableType方法的具体用法?C++ QSurfaceFormat::setRenderableType怎么用?C++ QSurfaceFormat::setRenderableType使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在QSurfaceFormat的用法示例。


在下文中一共展示了QSurfaceFormat::setRenderableType方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: q_glFormatFromConfig

QSurfaceFormat q_glFormatFromConfig(EGLDisplay display, const EGLConfig config, const QSurfaceFormat &referenceFormat)
{
    QSurfaceFormat format;
    EGLint redSize     = 0;
    EGLint greenSize   = 0;
    EGLint blueSize    = 0;
    EGLint alphaSize   = 0;
    EGLint depthSize   = 0;
    EGLint stencilSize = 0;
    EGLint sampleCount = 0;
    EGLint renderableType = 0;

    eglGetConfigAttrib(display, config, EGL_RED_SIZE,     &redSize);
    eglGetConfigAttrib(display, config, EGL_GREEN_SIZE,   &greenSize);
    eglGetConfigAttrib(display, config, EGL_BLUE_SIZE,    &blueSize);
    eglGetConfigAttrib(display, config, EGL_ALPHA_SIZE,   &alphaSize);
    eglGetConfigAttrib(display, config, EGL_DEPTH_SIZE,   &depthSize);
    eglGetConfigAttrib(display, config, EGL_STENCIL_SIZE, &stencilSize);
    eglGetConfigAttrib(display, config, EGL_SAMPLES,      &sampleCount);
    eglGetConfigAttrib(display, config, EGL_RENDERABLE_TYPE, &renderableType);

    if (referenceFormat.renderableType() == QSurfaceFormat::OpenVG && (renderableType & EGL_OPENVG_BIT))
        format.setRenderableType(QSurfaceFormat::OpenVG);
#ifdef EGL_VERSION_1_4
    else if (referenceFormat.renderableType() == QSurfaceFormat::OpenGL
             && (renderableType & EGL_OPENGL_BIT))
        format.setRenderableType(QSurfaceFormat::OpenGL);
    else if (referenceFormat.renderableType() == QSurfaceFormat::DefaultRenderableType
#ifndef QT_NO_OPENGL
             && QOpenGLContext::openGLModuleType() == QOpenGLContext::LibGL
#endif
             && (renderableType & EGL_OPENGL_BIT))
        format.setRenderableType(QSurfaceFormat::OpenGL);
#endif
    else
        format.setRenderableType(QSurfaceFormat::OpenGLES);

    format.setRedBufferSize(redSize);
    format.setGreenBufferSize(greenSize);
    format.setBlueBufferSize(blueSize);
    format.setAlphaBufferSize(alphaSize);
    format.setDepthBufferSize(depthSize);
    format.setStencilBufferSize(stencilSize);
    format.setSamples(sampleCount);
    format.setStereo(false);         // EGL doesn't support stereo buffers
    format.setSwapInterval(referenceFormat.swapInterval());

    // Clear the EGL error state because some of the above may
    // have errored out because the attribute is not applicable
    // to the surface type.  Such errors don't matter.
    eglGetError();

    return format;
}
开发者ID:James-intern,项目名称:Qt,代码行数:54,代码来源:qeglconvenience.cpp

示例2: main

int main(int argc, char *argv[])
{
  qInstallMessageHandler(&handleMessageOutput);
  QApplication app(argc, argv);
  std::vector<QSurfaceFormat> formats;

#if !defined(QT_OPENGL_ES)
  {
    QSurfaceFormat glFormat;
    glFormat.setRenderableType(QSurfaceFormat::OpenGL);
    glFormat.setProfile(QSurfaceFormat::CoreProfile);
    glFormat.setVersion(4,3);
    formats.push_back(glFormat);
  }
#endif

#if defined(QT_OPENGL_ES)
  {
    QSurfaceFormat glesFormat;
    glesFormat.setRenderableType(QSurfaceFormat::OpenGLES);
    glesFormat.setProfile(QSurfaceFormat::CoreProfile);
    glesFormat.setVersion(3,0);
    formats.push_back(glesFormat);
  }
#endif

  // Find out which version we support
  QSurfaceFormat *format = getFirstSupported(formats);
  if (format == NULL)
  {
    QMessageBox::critical(0, "Critical Error", "No valid supported version of OpenGL found on device!");
    exit(-1);
  }

#ifdef    GL_DEBUG
  format->setOption(QSurfaceFormat::DebugContext);
#endif // GL_DEBUG
  format->setDepthBufferSize(0);

  // Set the widget up
  MainWidget *widget = new MainWidget;
  widget->setFormat(*format);

  // Set the window up
  MainWindow *window = new MainWindow;
  window->show();

  return app.exec();
}
开发者ID:kyunghoWon,项目名称:QtOpenGL,代码行数:49,代码来源:main.cpp

示例3: qSurfaceFormatFromPixelFormat

static QSurfaceFormat
    qSurfaceFormatFromPixelFormat(const PIXELFORMATDESCRIPTOR &pfd,
                                         QWindowsOpenGLAdditionalFormat *additionalIn = 0)
{
    QSurfaceFormat format;
    format.setRenderableType(QSurfaceFormat::OpenGL);
    if (pfd.dwFlags & PFD_DOUBLEBUFFER)
        format.setSwapBehavior(QSurfaceFormat::DoubleBuffer);
    format.setDepthBufferSize(pfd.cDepthBits);

    if (pfd.iPixelType == PFD_TYPE_RGBA)
        format.setAlphaBufferSize(pfd.cAlphaBits);
    format.setRedBufferSize(pfd.cRedBits);
    format.setGreenBufferSize(pfd.cGreenBits);
    format.setBlueBufferSize(pfd.cBlueBits);
    format.setStencilBufferSize(pfd.cStencilBits);
    format.setStereo(pfd.dwFlags & PFD_STEREO);
    if (additionalIn) {
        QWindowsOpenGLAdditionalFormat additional;
        if (isDirectRendering(pfd))
            additional.formatFlags |= QWindowsGLDirectRendering;
        if (hasGLOverlay(pfd))
            additional.formatFlags |= QWindowsGLOverlay;
        if (pfd.cAccumRedBits)
            additional.formatFlags |= QWindowsGLAccumBuffer;
        if (testFlag(pfd.dwFlags, PFD_DRAW_TO_BITMAP)) {
            additional.formatFlags |= QWindowsGLRenderToPixmap;
            additional.pixmapDepth = pfd.cColorBits;
        }
        *additionalIn = additional;
    }
    return format;
}
开发者ID:CodeDJ,项目名称:qt5-hidpi,代码行数:33,代码来源:qwindowsglcontext.cpp

示例4: QOpenGLWidget

RenderWidget::RenderWidget(QWidget *parent) :
  QOpenGLWidget(parent),
  renderFunctions(nullptr),
  render(nullptr),
  quad(nullptr),
  quadShader(nullptr),
  openglDebugLogger(nullptr),
  captureMouse(false),
  onlyShowTexture(false),
  textureDisplayed(color)
{
  // Widget config
  setUpdateBehavior(QOpenGLWidget::NoPartialUpdate);
  setFocusPolicy(Qt::ClickFocus);

  // Update Timer config
  connect(&updateTimer, SIGNAL(timeout()), this, SLOT(update()));
  startUpdateLoop();

  // Open GL Context config
  QSurfaceFormat f;
  f.setRenderableType(QSurfaceFormat::OpenGL);
  f.setMajorVersion(4);
  f.setMinorVersion(5);
  f.setProfile(QSurfaceFormat::CoreProfile);
  f.setOptions(QSurfaceFormat::DebugContext | f.options());
  setFormat(f);
}
开发者ID:lamogui,项目名称:rmeditor,代码行数:28,代码来源:renderwidget.cpp

示例5: formatFromConfig

static QSurfaceFormat formatFromConfig(EGLDisplay dpy, EGLConfig config)
{
    QSurfaceFormat format;
    EGLint value = 0;
#define HELPER(__egl__, __qt__) \
    eglGetConfigAttrib(dpy, config, EGL_##__egl__, &value); \
    format.set##__qt__(value); \
    value = 0;

#define BUFFER_HELPER(__eglColor__, __color__) \
    HELPER(__eglColor__##_SIZE, __color__##BufferSize)

    BUFFER_HELPER(RED, Red)
    BUFFER_HELPER(GREEN, Green)
    BUFFER_HELPER(BLUE, Blue)
    BUFFER_HELPER(ALPHA, Alpha)
    BUFFER_HELPER(STENCIL, Stencil)
    BUFFER_HELPER(DEPTH, Depth)
#undef BUFFER_HELPER
    HELPER(SAMPLES, Samples)
#undef HELPER
    format.setRenderableType(isOpenGLES() ? QSurfaceFormat::OpenGLES : QSurfaceFormat::OpenGL);
    format.setStereo(false);

    return format;
}
开发者ID:CyberShadow,项目名称:kwin,代码行数:26,代码来源:abstractplatformcontext.cpp

示例6: 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());
}
开发者ID:JJ,项目名称:ARehab,代码行数:27,代码来源:main.cpp

示例7: getDefaultOpenGLSurfaceFormat

const QSurfaceFormat& getDefaultOpenGLSurfaceFormat() {
    static QSurfaceFormat format;
    static std::once_flag once;
    std::call_once(once, [] {
#if defined(USE_GLES)
        format.setRenderableType(QSurfaceFormat::OpenGLES);
        format.setRedBufferSize(8);
        format.setGreenBufferSize(8);
        format.setBlueBufferSize(8);
        format.setAlphaBufferSize(8);
#else
        format.setProfile(QSurfaceFormat::OpenGLContextProfile::CoreProfile);
#endif
        if (gl::Context::enableDebugLogger()) {
            format.setOption(QSurfaceFormat::DebugContext);
        }
        // Qt Quick may need a depth and stencil buffer. Always make sure these are available.
        format.setDepthBufferSize(DEFAULT_GL_DEPTH_BUFFER_BITS);
        format.setStencilBufferSize(DEFAULT_GL_STENCIL_BUFFER_BITS);
        int major, minor;
        ::gl::getTargetVersion(major, minor);
        format.setMajorVersion(major);
        format.setMinorVersion(minor);
    });
    return format;
}
开发者ID:Menithal,项目名称:hifi,代码行数:26,代码来源:GLHelpers.cpp

示例8: reserved

ContextPoolContext::ContextPoolContext(QOpenGLContext* share_context, bool reserved)
    : reserved(reserved), count(0), surface(NULL), context(NULL)
{
    QSurfaceFormat format;
    format.setMajorVersion(3);
    format.setMinorVersion(2);
    format.setSwapInterval(0);
    format.setSwapBehavior(QSurfaceFormat::SingleBuffer);
    format.setRenderableType(QSurfaceFormat::OpenGL);
    format.setProfile(QSurfaceFormat::CoreProfile);
    format.setOption(QSurfaceFormat::DebugContext);
    surface = new QOffscreenSurface();
    surface->setFormat(format);
    surface->create();
    if (!surface->isValid()) {
        throw;
    }

    context = new QOpenGLContext();
    context->setShareContext(share_context);
    context->setFormat(surface->requestedFormat());

    if (!context->create()) {
        throw;
    }

    context->makeCurrent(surface);
    gl = context->versionFunctions<QOpenGLFunctions_3_2_Core>();
    if (gl == nullptr || !gl->initializeOpenGLFunctions()) {
        throw;
    }
    indirect = new QOpenGLExtension_ARB_multi_draw_indirect();
    if (!indirect->initializeOpenGLFunctions()) {
        throw;
    }
    vab = new QOpenGLExtension_ARB_vertex_attrib_binding();
    if (!vab->initializeOpenGLFunctions()) {
        throw;
    }
    sso = new QOpenGLExtension_ARB_separate_shader_objects();
    if (!sso->initializeOpenGLFunctions()) {
        throw;
    }
    tex = new QOpenGLExtension_ARB_texture_buffer_object();
    if (!tex->initializeOpenGLFunctions()) {
        throw;
    }
    buffer = (QOpenGLExtension_ARB_buffer_storage)context->getProcAddress("glBufferStorage");
    debug = new QOpenGLExtension_ARB_debug_output();
    if (!debug->initializeOpenGLFunctions()) {
        throw;
    }
    debug->glDebugMessageCallbackARB(debug_callback, nullptr);
    debug->glDebugMessageControlARB(GL_DONT_CARE, GL_DONT_CARE, GL_DONT_CARE, 0, 0, GL_FALSE);
    debug->glDebugMessageControlARB(GL_DONT_CARE, GL_DONT_CARE, GL_DEBUG_SEVERITY_MEDIUM, 0, 0, GL_TRUE);
    context->doneCurrent();
    context->moveToThread(nullptr);
}
开发者ID:x414e54,项目名称:x3d-compositor,代码行数:58,代码来源:openglhelper.cpp

示例9: main

int main(int argc, char ** argv)
{
	ShowWindow(GetConsoleWindow(), SW_HIDE);

	QApplication app(argc, argv);

	QSurfaceFormat format;
	format.setDepthBufferSize(4);
	format.setSamples(24);
	format.setVersion(4, 4);
	format.setRenderableType(QSurfaceFormat::OpenGL);

	OpenGLWidget window;
	window.setFormat(format);
	window.resize(WINDOW_WIDTH, WINDOW_HEIGHT);

	selector = new ShaderFinder();

	pane = new CollapsiblePanelWidget(&window);
	pane->setStyleSheet("background-color:white");
	pane->setWidgetResizable(true);
	pane->setGeometry(0, 0, WINDOW_WIDTH / 5, WINDOW_HEIGHT);
	pane->duration = 500;
	pane->config(QRect(0, 0, WINDOW_WIDTH / 5, WINDOW_HEIGHT), QRect(-WINDOW_WIDTH / 5, 0, WINDOW_WIDTH / 5, WINDOW_HEIGHT));

	paneBox = new QGroupBox();
	pane->setWidget(paneBox);

	paneLayout = new QVBoxLayout();
	paneLayout->setSpacing(10);
	paneLayout->setAlignment(Qt::AlignTop);
	paneLayout->addWidget(selector);

	pane->widget()->setLayout(paneLayout);
	pane->show();

	anim = new CollapsiblePanelWidget(&window);
	anim->setStyleSheet("background-color:white");
	anim->setWidgetResizable(true);
	anim->setGeometry(WINDOW_WIDTH * 0.8, 0, WINDOW_WIDTH / 5, WINDOW_HEIGHT);
	anim->duration = 500;
	anim->config(QRect(WINDOW_WIDTH * 0.8, 0, WINDOW_WIDTH / 5, WINDOW_HEIGHT), QRect(WINDOW_WIDTH, 0, WINDOW_WIDTH / 5, WINDOW_HEIGHT));

	animBox = new QGroupBox();
	anim->setWidget(animBox);

	animLayout = new QVBoxLayout();
	animLayout->setSpacing(10);
	animLayout->setAlignment(Qt::AlignTop);

	anim->widget()->setLayout(animLayout);
	anim->show();

	window.show();

	return app.exec();
}
开发者ID:otah007,项目名称:fractal-z,代码行数:57,代码来源:main.cpp

示例10: start

void Widget::start()
{
    QSurfaceFormat fmt;

    int idx = m_version->currentIndex();
    if (idx < 0)
        return;
    fmt.setVersion(versions[idx].major, versions[idx].minor);

    for (size_t i = 0; i < sizeof(profiles) / sizeof(Profile); ++i)
        if (static_cast<QRadioButton *>(m_profiles->itemAt(int(i))->widget())->isChecked()) {
            fmt.setProfile(profiles[i].profile);
            break;
        }

    bool forceGLSL110 = false;
    for (size_t i = 0; i < sizeof(options) / sizeof(Option); ++i)
        if (static_cast<QCheckBox *>(m_options->itemAt(int(i))->widget())->isChecked()) {
            if (options[i].option)
                fmt.setOption(options[i].option);
            else if (i == 3)
                forceGLSL110 = true;
        }

    for (size_t i = 0; i < sizeof(renderables) / sizeof(Renderable); ++i)
        if (static_cast<QRadioButton *>(m_renderables->itemAt(int(i))->widget())->isChecked()) {
            fmt.setRenderableType(renderables[i].renderable);
            break;
        }

    // The example rendering will need a depth buffer.
    fmt.setDepthBufferSize(16);

    m_output->clear();
    m_extensions->clear();
    qDebug() << "Requesting surface format" << fmt;

    m_renderWindowLayout->removeWidget(m_renderWindowContainer);
    delete m_renderWindowContainer;

    RenderWindow *renderWindow = new RenderWindow(fmt);
    if (!renderWindow->context()) {
        m_output->append(tr("Failed to create context"));
        delete renderWindow;
        m_renderWindowContainer = new QWidget;
        addRenderWindow();
        return;
    }
    m_surface = renderWindow;

    renderWindow->setForceGLSL110(forceGLSL110);
    connect(renderWindow, &RenderWindow::ready, this, &Widget::renderWindowReady);
    connect(renderWindow, &RenderWindow::error, this, &Widget::renderWindowError);

    m_renderWindowContainer = QWidget::createWindowContainer(renderWindow);
    addRenderWindow();
}
开发者ID:RSATom,项目名称:Qt,代码行数:57,代码来源:widget.cpp

示例11: controlContext

void HsQMLContextControl::controlContext()
{
    // Do nothing if no window
    if (!mWindow) {
        return;
    }

    // Do nothing if changes are being deferred
    if (mDefer || !mWhen) {
        mPending = true;
        return;
    }
    mPending = false;

    QSurfaceFormat fmt = mOriginal;
    if (mMajorVersion >= 0) {
        fmt.setMajorVersion(mMajorVersion);
    }
    if (mMinorVersion >= 0) {
        fmt.setMinorVersion(mMinorVersion);
    }
    if (mContextType >= 0) {
        fmt.setRenderableType(static_cast<QSurfaceFormat::RenderableType>(
            mContextType));
    }
    if (mContextProfile >= 0) {
        fmt.setProfile(static_cast<QSurfaceFormat::OpenGLContextProfile>(
            mContextProfile));
    }
    if (mDeprecatedFunctionsSet) {
#if QT_VERSION >= 0x050300
        fmt.setOption(QSurfaceFormat::DeprecatedFunctions,
            mDeprecatedFunctions);
#else
        if (mDeprecatedFunctions) {
            fmt.setOption(QSurfaceFormat::DeprecatedFunctions);
        }
#endif
    }
    fmt.setDepthBufferSize(qMax(fmt.depthBufferSize(), mDepthBufferSize));
    fmt.setStencilBufferSize(qMax(fmt.stencilBufferSize(), mStencilBufferSize));
    if (fmt == mWindow->requestedFormat()) {
        return;
    }
    mWindow->setFormat(fmt);

    // Recreate OpenGL context
    mWindow->setPersistentOpenGLContext(false);
    mWindow->setPersistentSceneGraph(false);
    bool visible = mWindow->isVisible();
    mWindow->destroy();
    mWindow->releaseResources();
    mWindow->setVisible(visible);
    mWindow->setPersistentOpenGLContext(true);
    mWindow->setPersistentSceneGraph(true);
}
开发者ID:johntyree,项目名称:HsQML,代码行数:56,代码来源:Canvas.cpp

示例12: main

int main(int argc, char** argv) {
    QSurfaceFormat format;
#if defined(Q_OS_IOS) || defined(Q_OS_ANDROID)
    format.setRenderableType(QSurfaceFormat::OpenGLES);
    format.setVersion(3, 0);
#else
    format.setRenderableType(QSurfaceFormat::OpenGL);
    format.setProfile(QSurfaceFormat::CoreProfile);
    format.setVersion(3, 3);
#endif
    format.setDepthBufferSize(16);
    format.setStencilBufferSize(8);
    QSurfaceFormat::setDefaultFormat(format);

    QApplication a(argc, argv);

    ncMainWindow w;
    w.show();

    return a.exec();
}
开发者ID:funcman,项目名称:NailClipper,代码行数:21,代码来源:main.cpp

示例13: 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();
}
开发者ID:Zakhrov,项目名称:WebPhonon-Android-Audio-Edition,代码行数:13,代码来源:main.cpp

示例14: 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();
}
开发者ID:djkah11,项目名称:cg_cursach,代码行数:13,代码来源:main.cpp

示例15: main

int main(int argc, char *argv[])
{
    QApplication a(argc, argv);

    QSurfaceFormat format;
    format.setRenderableType(QSurfaceFormat::OpenGL);
    format.setProfile(QSurfaceFormat::CoreProfile);
    format.setOption(QSurfaceFormat::DebugContext);
    format.setVersion(4,1);
    QSurfaceFormat::setDefaultFormat(format);

    MGLWidgetUniformBlock widget(NULL,"UniformBlock",false);
    widget.show();
    
    return a.exec();
}
开发者ID:wolfand11,项目名称:StudyProjects,代码行数:16,代码来源:main.cpp


注:本文中的QSurfaceFormat::setRenderableType方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。