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


C++ QOpenGLContext::screen方法代码示例

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


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

示例1: initialize

void OpenGLRenderPrivate::initialize()
{
	initializeOpenGLFunctions();
	glPixelStorei(GL_UNPACK_ALIGNMENT, 1);
	for (int i = 0; i < 5; ++i){
		const char *fShaderCode = nullptr;
		switch (i){
		case 0:
		case 1:
			fShaderCode = fShaderI420;
			break;
		case 2:
			fShaderCode = fShaderNV12;
			break;
		case 3:
			fShaderCode = fShaderNV21;
			break;
		case 4:
			fShaderCode = fShaderBGRP;
			break;
		}
		QOpenGLShaderProgram &p = program[i];
		p.addShaderFromSourceCode(QOpenGLShader::Vertex, vShaderCode);
		p.addShaderFromSourceCode(QOpenGLShader::Fragment, fShaderCode);
		p.bindAttributeLocation("VtxCoord", 0);
		p.bindAttributeLocation("TexCoord", 1);
		p.bind();
		switch (i){
		case 0:
			p.setUniformValue("SamplerY", 0);
			p.setUniformValue("SamplerU", 1);
			p.setUniformValue("SamplerV", 2);
			break;
		case 1:
			p.setUniformValue("SamplerY", 0);
			p.setUniformValue("SamplerV", 1);
			p.setUniformValue("SamplerU", 2);
			break;
		case 2:
		case 3:
			p.setUniformValue("SamplerY", 0);
			p.setUniformValue("SamplerA", 1);
			break;
		case 4:
			p.setUniformValue("SamplerP", 0);
			break;
		}
	}
	tex[0] = 0; tex[1] = 0;
	tex[2] = 1; tex[3] = 0;
	tex[4] = 0; tex[5] = 1;
	tex[6] = 1; tex[7] = 1;
	QOpenGLContext *c = QOpenGLContext::currentContext();
	timer.setInterval(c->format().swapInterval() / (double)c->screen()->refreshRate());
}
开发者ID:LethargicTamias,项目名称:BiliLocal,代码行数:55,代码来源:OpenGLRender.cpp

示例2: init

void QSGTextMaskMaterial::init(QFontEngine::GlyphFormat glyphFormat)
{
    Q_ASSERT(m_font.isValid());

    setFlag(Blending, true);

    QOpenGLContext *ctx = const_cast<QOpenGLContext *>(QOpenGLContext::currentContext());
    Q_ASSERT(ctx != 0);

    // The following piece of code will read/write to the font engine's caches,
    // potentially from different threads. However, this is safe because this
    // code is only called from QQuickItem::updatePaintNode() which is called
    // only when the GUI is blocked, and multiple threads will call it in
    // sequence. See also QSGRenderContext::invalidate

    QRawFontPrivate *fontD = QRawFontPrivate::get(m_font);
    if (QFontEngine *fontEngine = fontD->fontEngine) {
        if (glyphFormat == QFontEngine::Format_None) {
            glyphFormat = fontEngine->glyphFormat != QFontEngine::Format_None
                        ? fontEngine->glyphFormat
                        : QFontEngine::Format_A32;
        }

        qreal devicePixelRatio = ctx->surface()->surfaceClass() == QSurface::Window ?
            static_cast<QWindow *>(ctx->surface())->devicePixelRatio() : ctx->screen()->devicePixelRatio();

        QTransform glyphCacheTransform = QTransform::fromScale(devicePixelRatio, devicePixelRatio);
        if (!fontEngine->supportsTransformation(glyphCacheTransform))
            glyphCacheTransform = QTransform();

        m_glyphCache = fontEngine->glyphCache(ctx, glyphFormat, glyphCacheTransform);
        if (!m_glyphCache || int(m_glyphCache->glyphFormat()) != glyphFormat) {
            m_glyphCache = new QOpenGLTextureGlyphCache(glyphFormat, glyphCacheTransform);
            fontEngine->setGlyphCache(ctx, m_glyphCache.data());
            QSGRenderContext *sg = QSGRenderContext::from(ctx);
            Q_ASSERT(sg);
            sg->registerFontengineForCleanup(fontEngine);
        }
    }
}
开发者ID:SchleunigerAG,项目名称:WinEC7_Qt5.3.1_Fixes,代码行数:40,代码来源:qsgdefaultglyphnode_p.cpp


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