本文整理汇总了C++中QPlatformWindowFormat类的典型用法代码示例。如果您正苦于以下问题:C++ QPlatformWindowFormat类的具体用法?C++ QPlatformWindowFormat怎么用?C++ QPlatformWindowFormat使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了QPlatformWindowFormat类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: Q_D
bool QGLContext::chooseContext(const QGLContext* shareContext)
{
Q_D(QGLContext);
if(!d->paintDevice || d->paintDevice->devType() != QInternal::Widget) {
d->valid = false;
}else {
QWidget *widget = static_cast<QWidget *>(d->paintDevice);
if (!widget->platformWindow()){
QGLFormat glformat = format();
QPlatformWindowFormat winFormat = QGLFormat::toPlatformWindowFormat(glformat);
if (shareContext) {
winFormat.setSharedContext(shareContext->d_func()->platformContext);
}
if (widget->testAttribute(Qt::WA_TranslucentBackground))
winFormat.setAlpha(true);
winFormat.setWindowApi(QPlatformWindowFormat::OpenGL);
winFormat.setWindowSurface(false);
widget->setPlatformWindowFormat(winFormat);
widget->winId();//make window
}
d->platformContext = widget->platformWindow()->glContext();
Q_ASSERT(d->platformContext);
d->glFormat = QGLFormat::fromPlatformWindowFormat(d->platformContext->platformWindowFormat());
d->valid =(bool) d->platformContext;
if (d->valid) {
d->platformContext->setQGLContextHandle(this,qDeleteQGLContext);
}
d->setupSharing();
}
return d->valid;
}
示例2: qglx_findConfig
GLXFBConfig qglx_findConfig(Display *display, int screen , const QPlatformWindowFormat &format, int drawableBit)
{
bool reduced = true;
GLXFBConfig chosenConfig = 0;
QPlatformWindowFormat reducedFormat = format;
while (!chosenConfig && reduced) {
QVector<int> spec = qglx_buildSpec(reducedFormat, drawableBit);
int confcount = 0;
GLXFBConfig *configs;
configs = glXChooseFBConfig(display, screen,spec.constData(),&confcount);
if (confcount)
{
for (int i = 0; i < confcount; i++) {
chosenConfig = configs[i];
// Make sure we try to get an ARGB visual if the format asked for an alpha:
if (reducedFormat.alpha()) {
int alphaSize;
glXGetFBConfigAttrib(display,configs[i],GLX_ALPHA_SIZE,&alphaSize);
if (alphaSize > 0)
break;
} else {
break; // Just choose the first in the list if there's no alpha requested
}
}
XFree(configs);
}
reducedFormat = qglx_reducePlatformWindowFormat(reducedFormat,&reduced);
}
if (!chosenConfig)
qWarning("Warning: no suitable glx confiuration found");
return chosenConfig;
}
示例3: QGLXContext
QPlatformGLContext *QXlibWindow::glContext() const
{
if (!QApplicationPrivate::platformIntegration()->hasCapability(QPlatformIntegration::OpenGL))
return 0;
if (!mGLContext) {
QXlibWindow *that = const_cast<QXlibWindow *>(this);
#if !defined(QT_NO_OPENGL)
#if !defined(QT_OPENGL_ES_2)
that->mGLContext = new QGLXContext(x_window, mScreen,widget()->platformWindowFormat());
#else
EGLDisplay display = mScreen->eglDisplay();
QPlatformWindowFormat windowFormat = correctColorBuffers(widget()->platformWindowFormat());
EGLConfig config = q_configFromQPlatformWindowFormat(display,windowFormat);
QVector<EGLint> eglContextAttrs;
eglContextAttrs.append(EGL_CONTEXT_CLIENT_VERSION);
eglContextAttrs.append(2);
eglContextAttrs.append(EGL_NONE);
EGLSurface eglSurface = eglCreateWindowSurface(display,config,(EGLNativeWindowType)x_window,0);
that->mGLContext = new QEGLPlatformContext(display, config, eglContextAttrs.data(), eglSurface, EGL_OPENGL_ES_API, static_cast<QEGLPlatformContext *>(windowFormat.sharedGLContext()));
#endif
#endif
}
return mGLContext;
}
示例4: d
QGLTemporaryContext::QGLTemporaryContext(bool, QWidget *)
: d(new QGLTemporaryContextPrivate)
{
d->context = const_cast<QPlatformGLContext *>(QPlatformGLContext::currentContext());
if (d->context)
d->context->doneCurrent();
d->widget = new QWidget;
d->widget->setGeometry(0,0,3,3);
QPlatformWindowFormat format = d->widget->platformWindowFormat();
format.setWindowApi(QPlatformWindowFormat::OpenGL);
format.setWindowSurface(false);
d->widget->setPlatformWindowFormat(format);
d->widget->winId();
d->widget->platformWindow()->glContext()->makeCurrent();
}
示例5: correctColorBuffers
QPlatformWindowFormat QXlibWindow::correctColorBuffers(const QPlatformWindowFormat &platformWindowFormat) const
{
// I have only tested this setup on a dodgy intel setup, where I didn't use standard libs,
// so this might be not what we want to do :)
if ( !(platformWindowFormat.redBufferSize() == -1 &&
platformWindowFormat.greenBufferSize() == -1 &&
platformWindowFormat.blueBufferSize() == -1))
return platformWindowFormat;
QPlatformWindowFormat windowFormat = platformWindowFormat;
if (mScreen->depth() == 16) {
windowFormat.setRedBufferSize(5);
windowFormat.setGreenBufferSize(6);
windowFormat.setBlueBufferSize(5);
} else {
windowFormat.setRedBufferSize(8);
windowFormat.setGreenBufferSize(8);
windowFormat.setBlueBufferSize(8);
}
return windowFormat;
}
示例6: QPlatformGLContext
QGLXContext::QGLXContext(Window window, QXcbScreen *screen, const QPlatformWindowFormat &format)
: QPlatformGLContext()
, m_screen(screen)
, m_drawable((Drawable)window)
, m_context(0)
{
Q_XCB_NOOP(m_screen->connection());
const QPlatformGLContext *sharePlatformContext;
sharePlatformContext = format.sharedGLContext();
GLXContext shareGlxContext = 0;
if (sharePlatformContext)
shareGlxContext = static_cast<const QGLXContext*>(sharePlatformContext)->glxContext();
GLXFBConfig config = qglx_findConfig(DISPLAY_FROM_XCB(screen),screen->screenNumber(),format);
m_context = glXCreateNewContext(DISPLAY_FROM_XCB(screen), config, GLX_RGBA_TYPE, shareGlxContext, TRUE);
m_windowFormat = qglx_platformWindowFromGLXFBConfig(DISPLAY_FROM_XCB(screen), config, m_context);
Q_XCB_NOOP(m_screen->connection());
}
示例7: QPlatformGLContext
QWaylandGLContext::QWaylandGLContext(EGLDisplay eglDisplay, const QPlatformWindowFormat &format)
: QPlatformGLContext()
, mEglDisplay(eglDisplay)
, mSurface(EGL_NO_SURFACE)
, mConfig(q_configFromQPlatformWindowFormat(mEglDisplay,format,true))
, mFormat(qt_qPlatformWindowFormatFromConfig(mEglDisplay,mConfig))
{
QPlatformGLContext *sharePlatformContext = 0;
sharePlatformContext = format.sharedGLContext();
mFormat.setSharedContext(sharePlatformContext);
EGLContext shareEGLContext = EGL_NO_CONTEXT;
if (sharePlatformContext)
shareEGLContext = static_cast<const QWaylandGLContext*>(sharePlatformContext)->mContext;
eglBindAPI(EGL_OPENGL_ES_API);
QVector<EGLint> eglContextAttrs;
eglContextAttrs.append(EGL_CONTEXT_CLIENT_VERSION);
eglContextAttrs.append(2);
eglContextAttrs.append(EGL_NONE);
mContext = eglCreateContext(mEglDisplay, mConfig,
shareEGLContext, eglContextAttrs.constData());
}
示例8: qglx_reducePlatformWindowFormat
QPlatformWindowFormat qglx_reducePlatformWindowFormat(const QPlatformWindowFormat &format, bool *reduced)
{
QPlatformWindowFormat retFormat = format;
*reduced = true;
if (retFormat.sampleBuffers()) {
retFormat.setSampleBuffers(false);
} else if (retFormat.stereo()) {
retFormat.setStereo(false);
} else if (retFormat.accum()) {
retFormat.setAccum(false);
}else if (retFormat.stencil()) {
retFormat.setStencil(false);
}else if (retFormat.alpha()) {
retFormat.setAlpha(false);
}else if (retFormat.depth()) {
retFormat.setDepth(false);
}else if (retFormat.doubleBuffer()) {
retFormat.setDoubleBuffer(false);
}else{
*reduced = false;
}
return retFormat;
}
示例9: qglx_platformWindowFromGLXFBConfig
QPlatformWindowFormat qglx_platformWindowFromGLXFBConfig(Display *display, GLXFBConfig config, GLXContext ctx)
{
QPlatformWindowFormat format;
int redSize = 0;
int greenSize = 0;
int blueSize = 0;
int alphaSize = 0;
int depthSize = 0;
int stencilSize = 0;
int sampleBuffers = 0;
int sampleCount = 0;
int level = 0;
int rgba = 0;
int stereo = 0;
int accumSizeA = 0;
int accumSizeR = 0;
int accumSizeG = 0;
int accumSizeB = 0;
XVisualInfo *vi = glXGetVisualFromFBConfig(display,config);
glXGetConfig(display,vi,GLX_RGBA,&rgba);
XFree(vi);
glXGetFBConfigAttrib(display, config, GLX_RED_SIZE, &redSize);
glXGetFBConfigAttrib(display, config, GLX_GREEN_SIZE, &greenSize);
glXGetFBConfigAttrib(display, config, GLX_BLUE_SIZE, &blueSize);
glXGetFBConfigAttrib(display, config, GLX_ALPHA_SIZE, &alphaSize);
glXGetFBConfigAttrib(display, config, GLX_DEPTH_SIZE, &depthSize);
glXGetFBConfigAttrib(display, config, GLX_STENCIL_SIZE, &stencilSize);
glXGetFBConfigAttrib(display, config, GLX_SAMPLES, &sampleBuffers);
glXGetFBConfigAttrib(display, config, GLX_LEVEL, &level);
glXGetFBConfigAttrib(display, config, GLX_STEREO, &stereo);
glXGetFBConfigAttrib(display, config, GLX_ACCUM_ALPHA_SIZE, &accumSizeA);
glXGetFBConfigAttrib(display, config, GLX_ACCUM_RED_SIZE, &accumSizeR);
glXGetFBConfigAttrib(display, config, GLX_ACCUM_GREEN_SIZE, &accumSizeG);
glXGetFBConfigAttrib(display, config, GLX_ACCUM_BLUE_SIZE, &accumSizeB);
format.setRedBufferSize(redSize);
format.setGreenBufferSize(greenSize);
format.setBlueBufferSize(blueSize);
format.setAlphaBufferSize(alphaSize);
format.setDepthBufferSize(depthSize);
format.setStencilBufferSize(stencilSize);
format.setSampleBuffers(sampleBuffers);
if (format.sampleBuffers()) {
glXGetFBConfigAttrib(display, config, GLX_SAMPLES_ARB, &sampleCount);
format.setSamples(sampleCount);
}
format.setDirectRendering(glXIsDirect(display, ctx));
format.setRgba(rgba);
format.setStereo(stereo);
format.setAccumBufferSize(accumSizeB);
return format;
}
示例10: QPlatformWindow
QOpenKODEWindow::QOpenKODEWindow(QWidget *tlw)
: QPlatformWindow(tlw), isFullScreen(false)
{
if (tlw->platformWindowFormat().windowApi() == QPlatformWindowFormat::OpenVG) {
m_eglApi = EGL_OPENVG_API;
} else {
m_eglContextAttrs.append(EGL_CONTEXT_CLIENT_VERSION);
m_eglContextAttrs.append(2);
m_eglApi = EGL_OPENGL_ES_API;
}
eglBindAPI(m_eglApi);
m_eglContextAttrs.append(EGL_NONE);
m_eglWindowAttrs.append(EGL_NONE);
QList<QPlatformScreen *> screens = QApplicationPrivate::platformIntegration()->screens();
//XXXX: jl figure out how to pick the correct screen.
// Q_ASSERT(screens.size() > tlw->d_func()->screenNumber);
// QOpenKODEScreen *screen = qobject_cast<QOpenKODEScreen *>(screens.at(tlw->d_func()->screenNumber));
QOpenKODEScreen *screen = qobject_cast<QOpenKODEScreen *>(screens.at(0));
if (!screen) {
qErrnoWarning("Could not make QOpenKODEWindow without a screen");
}
QPlatformWindowFormat format = tlw->platformWindowFormat();
format.setRedBufferSize(5);
format.setGreenBufferSize(6);
format.setBlueBufferSize(5);
m_eglConfig = q_configFromQPlatformWindowFormat(screen->eglDisplay(),format);
m_kdWindow = kdCreateWindow(screen->eglDisplay(),
m_eglConfig,
this);
kdInstallCallback(kdProcessMouseEvents,KD_EVENT_INPUT_POINTER,this);
#ifdef KD_ATX_keyboard
kdInstallCallback(kdProcessKeyEvents, KD_EVENT_INPUT_KEY_ATX,this);
#endif //KD_ATX_keyboard
if (!m_kdWindow) {
qErrnoWarning(kdGetError(), "Error creating native window");
return;
}
KDboolean exclusive(false);
if (kdSetWindowPropertybv(m_kdWindow,KD_WINDOWPROPERTY_DESKTOP_EXCLUSIVE_NV, &exclusive)) {
isFullScreen = true;
}
if (isFullScreen) {
tlw->setGeometry(screen->geometry());
screen->setFullScreen(isFullScreen);
}else {
const KDint windowSize[2] = { tlw->width(), tlw->height() };
if (kdSetWindowPropertyiv(m_kdWindow, KD_WINDOWPROPERTY_SIZE, windowSize)) {
qErrnoWarning(kdGetError(), "Could not set native window size");
}
KDboolean visibillity(false);
if (kdSetWindowPropertybv(m_kdWindow, KD_WINDOWPROPERTY_VISIBILITY, &visibillity)) {
qErrnoWarning(kdGetError(), "Could not set visibillity to false");
}
const KDint windowPos[2] = { tlw->x(), tlw->y() };
if (kdSetWindowPropertyiv(m_kdWindow, KD_WINDOWPROPERTY_DESKTOP_OFFSET_NV, windowPos)) {
qErrnoWarning(kdGetError(), "Could not set native window position");
return;
}
}
QOpenKODEIntegration *integration = static_cast<QOpenKODEIntegration *>(QApplicationPrivate::platformIntegration());
if (!isFullScreen || (isFullScreen && !integration->mainGLContext())) {
if (kdRealizeWindow(m_kdWindow, &m_eglWindow)) {
qErrnoWarning(kdGetError(), "Could not realize native window");
return;
}
EGLSurface surface = eglCreateWindowSurface(screen->eglDisplay(),m_eglConfig,m_eglWindow,m_eglWindowAttrs.constData());
m_platformGlContext = new QEGLPlatformContext(screen->eglDisplay(), m_eglConfig,
m_eglContextAttrs.data(), surface, m_eglApi);
integration->setMainGLContext(m_platformGLContext);
} else {
m_platformGlContext = integration->mainGLContext();
kdDestroyWindow(m_kdWindow);
m_kdWindow = 0;
}
}
示例11: qgetenv
void QEglFSScreen::createAndSetPlatformContext()
{
QPlatformWindowFormat platformFormat = QPlatformWindowFormat::defaultFormat();
platformFormat.setWindowApi(QPlatformWindowFormat::OpenGL);
QByteArray depthString = qgetenv("QT_QPA_EGLFS_DEPTH");
if (depthString.toInt() == 16) {
platformFormat.setDepth(16);
platformFormat.setRedBufferSize(5);
platformFormat.setGreenBufferSize(6);
platformFormat.setBlueBufferSize(5);
m_depth = 16;
m_format = QImage::Format_RGB16;
} else {
platformFormat.setDepth(32);
platformFormat.setRedBufferSize(8);
platformFormat.setGreenBufferSize(8);
platformFormat.setBlueBufferSize(8);
m_depth = 32;
m_format = QImage::Format_RGB32;
}
if (!qgetenv("QT_QPA_EGLFS_MULTISAMPLE").isEmpty()) {
platformFormat.setSampleBuffers(true);
}
EGLConfig config = q_configFromQPlatformWindowFormat(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
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);
#ifdef QEGL_EXTRA_DEBUG
qWarning("Configuration %d matches requirements\n", (int)config);
for (index = 0; attrs[index].attr != -1; ++index) {
EGLint value;
if (eglGetConfigAttrib(m_dpy, config, attrs[index].attr, &value)) {
qWarning("\t%s: %d\n", attrs[index].name, (int)value);
}
}
qWarning("\n");
#endif
EGLint temp;
EGLint attribList[32];
temp = 0;
attribList[temp++] = EGL_CONTEXT_CLIENT_VERSION;
attribList[temp++] = 2; // GLES version 2
attribList[temp++] = EGL_NONE;
QEGLPlatformContext *platformContext = new QEGLPlatformContext(m_dpy,config,attribList,m_surface,EGL_OPENGL_ES_API);
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);
}
示例12: q_createConfigAttributesFromFormat
QT_BEGIN_NAMESPACE
QVector<EGLint> q_createConfigAttributesFromFormat(const QPlatformWindowFormat &format)
{
int redSize = format.redBufferSize();
int greenSize = format.greenBufferSize();
int blueSize = format.blueBufferSize();
int alphaSize = format.alphaBufferSize();
int depthSize = format.depthBufferSize();
int stencilSize = format.stencilBufferSize();
int sampleCount = format.samples();
// QPlatformWindowFormat uses a magic value of -1 to indicate "don't care", even when a buffer of that
// type has been requested. So we must check QPlatformWindowFormat's booleans too if size is -1:
if (format.alpha() && alphaSize <= 0)
alphaSize = 1;
if (format.depth() && depthSize <= 0)
depthSize = 1;
if (format.stencil() && stencilSize <= 0)
stencilSize = 1;
if (format.sampleBuffers() && sampleCount <= 0)
sampleCount = 1;
// We want to make sure 16-bit configs are chosen over 32-bit configs as they will provide
// the best performance. The EGL config selection algorithm is a bit stange in this regard:
// The selection criteria for EGL_BUFFER_SIZE is "AtLeast", so we can't use it to discard
// 32-bit configs completely from the selection. So it then comes to the sorting algorithm.
// The red/green/blue sizes have a sort priority of 3, so they are sorted by first. The sort
// order is special and described as "by larger _total_ number of color bits.". So EGL will
// put 32-bit configs in the list before the 16-bit configs. However, the spec also goes on
// to say "If the requested number of bits in attrib_list for a particular component is 0,
// then the number of bits for that component is not considered". This part of the spec also
// seems to imply that setting the red/green/blue bits to zero means none of the components
// are considered and EGL disregards the entire sorting rule. It then looks to the next
// highest priority rule, which is EGL_BUFFER_SIZE. Despite the selection criteria being
// "AtLeast" for EGL_BUFFER_SIZE, it's sort order is "smaller" meaning 16-bit configs are
// put in the list before 32-bit configs. So, to make sure 16-bit is preffered over 32-bit,
// we must set the red/green/blue sizes to zero. This has an unfortunate consequence that
// if the application sets the red/green/blue size to 5/6/5 on the QPlatformWindowFormat,
// they will probably get a 32-bit config, even when there's an RGB565 config available.
// Now normalize the values so -1 becomes 0
redSize = redSize > 0 ? redSize : 0;
greenSize = greenSize > 0 ? greenSize : 0;
blueSize = blueSize > 0 ? blueSize : 0;
alphaSize = alphaSize > 0 ? alphaSize : 0;
depthSize = depthSize > 0 ? depthSize : 0;
stencilSize = stencilSize > 0 ? stencilSize : 0;
sampleCount = sampleCount > 0 ? sampleCount : 0;
QVector<EGLint> configAttributes;
configAttributes.append(EGL_RED_SIZE);
configAttributes.append(redSize);
configAttributes.append(EGL_GREEN_SIZE);
configAttributes.append(greenSize);
configAttributes.append(EGL_BLUE_SIZE);
configAttributes.append(blueSize);
configAttributes.append(EGL_ALPHA_SIZE);
configAttributes.append(alphaSize);
configAttributes.append(EGL_DEPTH_SIZE);
configAttributes.append(depthSize);
configAttributes.append(EGL_STENCIL_SIZE);
configAttributes.append(stencilSize);
configAttributes.append(EGL_SAMPLES);
configAttributes.append(sampleCount);
configAttributes.append(EGL_SAMPLE_BUFFERS);
configAttributes.append(sampleCount? 1:0);
return configAttributes;
}
示例13: q_configFromQPlatformWindowFormat
EGLConfig q_configFromQPlatformWindowFormat(EGLDisplay display, const QPlatformWindowFormat &format, bool highestPixelFormat, int surfaceType)
{
EGLConfig cfg = 0;
QVector<EGLint> configureAttributes = q_createConfigAttributesFromFormat(format);
configureAttributes.append(EGL_SURFACE_TYPE); //we only support eglconfigs for windows for now
configureAttributes.append(surfaceType);
configureAttributes.append(EGL_RENDERABLE_TYPE);
if (format.windowApi() == QPlatformWindowFormat::OpenVG) {
configureAttributes.append(EGL_OPENVG_BIT);
} else {
configureAttributes.append(EGL_OPENGL_ES2_BIT);
}
configureAttributes.append(EGL_NONE);
do {
// Get the number of matching configurations for this set of properties.
EGLint matching = 0;
if (!eglChooseConfig(display, configureAttributes.constData(), 0, 0, &matching) || !matching)
continue;
// If we want the best pixel format, then return the first
// matching configuration.
if (highestPixelFormat) {
eglChooseConfig(display, configureAttributes.constData(), &cfg, 1, &matching);
if (matching < 1)
continue;
return cfg;
}
// Fetch all of the matching configurations and find the
// first that matches the pixel format we wanted.
int i = configureAttributes.indexOf(EGL_RED_SIZE);
int confAttrRed = configureAttributes.at(i+1);
i = configureAttributes.indexOf(EGL_GREEN_SIZE);
int confAttrGreen = configureAttributes.at(i+1);
i = configureAttributes.indexOf(EGL_BLUE_SIZE);
int confAttrBlue = configureAttributes.at(i+1);
i = configureAttributes.indexOf(EGL_ALPHA_SIZE);
int confAttrAlpha = configureAttributes.at(i+1);
EGLint size = matching;
EGLConfig *configs = new EGLConfig [size];
eglChooseConfig(display, configureAttributes.constData(), configs, size, &matching);
for (EGLint index = 0; index < size; ++index) {
EGLint red, green, blue, alpha;
eglGetConfigAttrib(display, configs[index], EGL_RED_SIZE, &red);
eglGetConfigAttrib(display, configs[index], EGL_GREEN_SIZE, &green);
eglGetConfigAttrib(display, configs[index], EGL_BLUE_SIZE, &blue);
eglGetConfigAttrib(display, configs[index], EGL_ALPHA_SIZE, &alpha);
if (red == confAttrRed &&
green == confAttrGreen &&
blue == confAttrBlue &&
(confAttrAlpha == 0 ||
alpha == confAttrAlpha)) {
cfg = configs[index];
delete [] configs;
return cfg;
}
}
delete [] configs;
} while (q_reduceConfigAttributes(&configureAttributes));
qWarning("Cant find EGLConfig, returning null config");
return 0;
}
示例14: toPlatformWindowFormat
/*!
\since 4.8
Returns a platform window format for the OpenGL format specified by \a format.
*/
QPlatformWindowFormat QGLFormat::toPlatformWindowFormat(const QGLFormat &format)
{
QPlatformWindowFormat retFormat;
retFormat.setAccum(format.accum());
if (format.accumBufferSize() >= 0)
retFormat.setAccumBufferSize(format.accumBufferSize());
retFormat.setAlpha(format.alpha());
if (format.alphaBufferSize() >= 0)
retFormat.setAlphaBufferSize(format.alphaBufferSize());
if (format.blueBufferSize() >= 0)
retFormat.setBlueBufferSize(format.blueBufferSize());
retFormat.setDepth(format.depth());
if (format.depthBufferSize() >= 0)
retFormat.setDepthBufferSize(format.depthBufferSize());
retFormat.setDirectRendering(format.directRendering());
retFormat.setDoubleBuffer(format.doubleBuffer());
if (format.greenBufferSize() >= 0)
retFormat.setGreenBufferSize(format.greenBufferSize());
if (format.redBufferSize() >= 0)
retFormat.setRedBufferSize(format.redBufferSize());
retFormat.setRgba(format.rgba());
retFormat.setSampleBuffers(format.sampleBuffers());
if (format.samples() >= 0)
retFormat.setSamples(format.samples());
retFormat.setStencil(format.stencil());
if (format.stencilBufferSize() >= 0)
retFormat.setStencilBufferSize(format.stencilBufferSize());
retFormat.setStereo(format.stereo());
retFormat.setSwapInterval(format.swapInterval());
return retFormat;
}
示例15: qglx_buildSpec
QVector<int> qglx_buildSpec(const QPlatformWindowFormat &format, int drawableBit)
{
QVector<int> spec(48);
int i = 0;
spec[i++] = GLX_LEVEL;
spec[i++] = 0;
spec[i++] = GLX_DRAWABLE_TYPE; spec[i++] = drawableBit;
if (format.rgba()) {
spec[i++] = GLX_RENDER_TYPE; spec[i++] = GLX_RGBA_BIT;
spec[i++] = GLX_RED_SIZE; spec[i++] = (format.redBufferSize() == -1) ? 1 : format.redBufferSize();
spec[i++] = GLX_GREEN_SIZE; spec[i++] = (format.greenBufferSize() == -1) ? 1 : format.greenBufferSize();
spec[i++] = GLX_BLUE_SIZE; spec[i++] = (format.blueBufferSize() == -1) ? 1 : format.blueBufferSize();
if (format.alpha()) {
spec[i++] = GLX_ALPHA_SIZE; spec[i++] = (format.alphaBufferSize() == -1) ? 1 : format.alphaBufferSize();
}
spec[i++] = GLX_ACCUM_RED_SIZE; spec[i++] = (format.accumBufferSize() == -1) ? 1 : format.accumBufferSize();
spec[i++] = GLX_ACCUM_GREEN_SIZE; spec[i++] = (format.accumBufferSize() == -1) ? 1 : format.accumBufferSize();
spec[i++] = GLX_ACCUM_BLUE_SIZE; spec[i++] = (format.accumBufferSize() == -1) ? 1 : format.accumBufferSize();
if (format.alpha()) {
spec[i++] = GLX_ACCUM_ALPHA_SIZE; spec[i++] = (format.accumBufferSize() == -1) ? 1 : format.accumBufferSize();
}
} else {
spec[i++] = GLX_RENDER_TYPE; spec[i++] = GLX_COLOR_INDEX_BIT; //I'm really not sure if this works....
spec[i++] = GLX_BUFFER_SIZE; spec[i++] = 8;
}
spec[i++] = GLX_DOUBLEBUFFER; spec[i++] = format.doubleBuffer() ? True : False;
spec[i++] = GLX_STEREO; spec[i++] = format.stereo() ? True : False;
if (format.depth()) {
spec[i++] = GLX_DEPTH_SIZE; spec[i++] = (format.depthBufferSize() == -1) ? 1 : format.depthBufferSize();
}
if (format.stencil()) {
spec[i++] = GLX_STENCIL_SIZE; spec[i++] = (format.stencilBufferSize() == -1) ? 1 : format.stencilBufferSize();
}
if (format.sampleBuffers()) {
spec[i++] = GLX_SAMPLE_BUFFERS_ARB;
spec[i++] = 1;
spec[i++] = GLX_SAMPLES_ARB;
spec[i++] = format.samples() == -1 ? 4 : format.samples();
}
spec[i++] = XNone;
return spec;
}