本文整理汇总了C++中QOpenGLFramebufferObjectFormat::setAttachment方法的典型用法代码示例。如果您正苦于以下问题:C++ QOpenGLFramebufferObjectFormat::setAttachment方法的具体用法?C++ QOpenGLFramebufferObjectFormat::setAttachment怎么用?C++ QOpenGLFramebufferObjectFormat::setAttachment使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类QOpenGLFramebufferObjectFormat
的用法示例。
在下文中一共展示了QOpenGLFramebufferObjectFormat::setAttachment方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: initializeGL
void TApplication::initializeGL() {
// Init shaders
if (!Shader.addShaderFromSourceFile(QGLShader::Vertex, "vert.glsl")) {
qFatal("failed to load shader vert.glsl");
}
if (!Shader.addShaderFromSourceFile(QGLShader::Fragment, "frag.glsl")) {
qFatal("failed to load shader frag.glsl");
}
if (!Shader.link()) {
qFatal("failed to link shader planet");
}
if (!Shader.bind()) {
qFatal("failed to bind shader");
}
// Init framebuffers
QOpenGLFramebufferObjectFormat format;
format.setAttachment(QOpenGLFramebufferObject::CombinedDepthStencil);
format.setSamples(8);
Fbo.reset(new QOpenGLFramebufferObject(WINDOW_WIDTH, WINDOW_HEIGHT, format));
QOpenGLFramebufferObjectFormat format1;
format.setAttachment(QOpenGLFramebufferObject::CombinedDepthStencil);
Fbo1.reset(new QOpenGLFramebufferObject(WINDOW_WIDTH, WINDOW_HEIGHT, format1));
// Load model and textures
Obj = LoadJsonModel("model.json");
ObjectSize = Obj.size();
VertexBuff.reset(new QOpenGLBuffer(QOpenGLBuffer::VertexBuffer));
VertexBuff->create();
VertexBuff->bind();
VertexBuff->setUsagePattern(QOpenGLBuffer::StaticDraw);
VertexBuff->allocate(Obj.data(), Obj.size() * sizeof(TVertex));
VertexBuff->release();
Texture.reset(new QOpenGLTexture(QImage("diffuse.jpg")));
Texture->bind();
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR_MIPMAP_LINEAR);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR_MIPMAP_LINEAR);
Texture->release();
NormalMap.reset(new QOpenGLTexture(QImage("normal.jpg")));
NormalMap->bind();
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR_MIPMAP_LINEAR);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR_MIPMAP_LINEAR);
NormalMap->release();
// Initial angles
AngleX = 0;
AngleY = 0;
AngleZ = 0;
Paused = false;
}
示例2: QOpenGLFramebufferObject
QOpenGLFramebufferObject *createFramebufferObject(const QSize &size)
{
QOpenGLFramebufferObjectFormat format;
format.setAttachment(QOpenGLFramebufferObject::CombinedDepthStencil);
format.setSamples(4);
return new QOpenGLFramebufferObject(size, format);
}
示例3: fboSimpleRendering
void tst_QOpenGL::fboSimpleRendering()
{
QFETCH(int, surfaceClass);
QScopedPointer<QSurface> surface(createSurface(surfaceClass));
QOpenGLContext ctx;
ctx.create();
ctx.makeCurrent(surface.data());
if (!QOpenGLFramebufferObject::hasOpenGLFramebufferObjects())
QSKIP("QOpenGLFramebufferObject not supported on this platform");
// No multisample with combined depth/stencil attachment:
QOpenGLFramebufferObjectFormat fboFormat;
fboFormat.setAttachment(QOpenGLFramebufferObject::NoAttachment);
QOpenGLFramebufferObject *fbo = new QOpenGLFramebufferObject(200, 100, fboFormat);
fbo->bind();
glClearColor(1.0, 0.0, 0.0, 1.0);
glClear(GL_COLOR_BUFFER_BIT);
glFinish();
QImage fb = fbo->toImage().convertToFormat(QImage::Format_RGB32);
QImage reference(fb.size(), QImage::Format_RGB32);
reference.fill(0xffff0000);
QFUZZY_COMPARE_IMAGES(fb, reference);
delete fbo;
}
示例4: render
void RenderSurface::render(QPainter *painter)
{
Q_UNUSED(painter);
QOpenGLFramebufferObjectFormat fboFormat;
fboFormat.setSamples(1);
fboFormat.setAttachment(QOpenGLFramebufferObject::CombinedDepthStencil);
const QRect drawRect(0, 0, m_outWidth, m_outHeight);
const QSize drawRectSize = drawRect.size();
QOpenGLFramebufferObject fbo(drawRectSize, fboFormat);
fbo.bind();
glViewport(0, 0, m_outWidth, m_outHeight);
glClear(GL_COLOR_BUFFER_BIT);
glClearColor(0.0f, 0.0f, 0.0f, 1.0f);
glEnable(GL_BLEND);
glBlendFuncSeparate(GL_ONE, GL_ZERO, GL_ZERO, GL_ONE);
m_program->bind();
int texCount = 0;
for (size_t i = 0; i < sp.size(); ++i) {
if (sp[i].bind == ShaderParameter::BindTextureSampler) {
textures[sp[i].name].obj->bind(texCount);
m_program->setUniformValue(sp[i].name.c_str(), texCount);
texCount++;
} else if (sp[i].bind == ShaderParameter::BindTextureResolution) {
const QImage& image = textures[sp[i].texture].image;
m_program->setUniformValue(sp[i].name.c_str(), QVector2D(image.width(),image.height()));
} else if (sp[i].bind == ShaderParameter::BindGlobalTime) {
m_program->setUniformValue(sp[i].name.c_str(), m_globalTime);
} else if (sp[i].bind == ShaderParameter::BindOutputResolution) {
m_program->setUniformValue(sp[i].name.c_str(), QVector2D(m_outWidth,m_outHeight));
}
}
GLfloat vertices[] = {
-1.0f, -1.0f, 0.0f,
1.0f, -1.0f, 0.0f,
-1.0f, 1.0f, 0.0f,
1.0f, 1.0f, 0.0f
};
glVertexAttribPointer(m_posAttr, 3, GL_FLOAT, GL_FALSE, 0, vertices);
glEnableVertexAttribArray(0);
glDrawArrays(GL_TRIANGLE_STRIP, 0, 4);
glDisableVertexAttribArray(0);
m_program->release();
imageFrame = fbo.toImage();
}
示例5: createFramebufferObject
QOpenGLFramebufferObject* QQuickMapboxGLRenderer::createFramebufferObject(const QSize &size)
{
m_map->resize(size);
QOpenGLFramebufferObjectFormat format;
format.setAttachment(QOpenGLFramebufferObject::CombinedDepthStencil);
return new QOpenGLFramebufferObject(size, format);
}
示例6: createFramebufferObject
QOpenGLFramebufferObject* COglRenderer::createFramebufferObject(const QSize &size)
{
// create opengl FBO
QOpenGLFramebufferObjectFormat format;
format.setAttachment(QOpenGLFramebufferObject::CombinedDepthStencil);
format.setSamples(4);
m_oglFBO = new QOpenGLFramebufferObject(size, format);
// return opengl FBO
return m_oglFBO;
}
示例7: makeCurrent
bool QGLPixelBuffer::makeCurrent()
{
Q_D(QGLPixelBuffer);
if (d->invalid)
return false;
d->qctx->makeCurrent();
if (!d->fbo) {
QOpenGLFramebufferObjectFormat format;
if (d->req_format.stencil())
format.setAttachment(QOpenGLFramebufferObject::CombinedDepthStencil);
else if (d->req_format.depth())
format.setAttachment(QOpenGLFramebufferObject::Depth);
if (d->req_format.sampleBuffers())
format.setSamples(d->req_format.samples());
d->fbo = new QOpenGLFramebufferObject(d->req_size, format);
d->fbo->bind();
d->glDevice.setFbo(d->fbo->handle());
QOpenGLContext::currentContext()->functions()->glViewport(0, 0, d->req_size.width(), d->req_size.height());
}
return true;
}
示例8:
std::unique_ptr<QOpenGLFramebufferObject>
_createMultisampledFBO( const QSize& size )
{
QOpenGLFramebufferObjectFormat format;
format.setAttachment( QOpenGLFramebufferObject::CombinedDepthStencil );
format.setSamples( MULTI_SAMPLE_ANTI_ALIASING_SAMPLES );
auto fbo = make_unique<QOpenGLFramebufferObject>( size, format );
fbo->bind();
auto gl = QOpenGLContext::currentContext()->functions();
gl->glClearColor( 0.0f, 0.0f, 0.0f, 0.0f );
gl->glClear( GL_COLOR_BUFFER_BIT );
fbo->release();
return fbo;
}
示例9: fboRendering
// NOTE: This tests that CombinedDepthStencil attachment works by assuming the
// GL2 engine is being used and is implemented the same way as it was when
// this autotest was written. If this is not the case, there may be some
// false-positives: I.e. The test passes when either the depth or stencil
// buffer is actually missing. But that's probably ok anyway.
void tst_QOpenGL::fboRendering()
{
#if defined(Q_OS_LINUX) && defined(Q_CC_GNU) && !defined(__x86_64__)
QSKIP("QTBUG-22617");
#endif
QFETCH(int, surfaceClass);
QScopedPointer<QSurface> surface(createSurface(surfaceClass));
QOpenGLContext ctx;
QVERIFY(ctx.create());
QVERIFY(ctx.makeCurrent(surface.data()));
if (!QOpenGLFramebufferObject::hasOpenGLFramebufferObjects())
QSKIP("QOpenGLFramebufferObject not supported on this platform");
// No multisample with combined depth/stencil attachment:
QOpenGLFramebufferObjectFormat fboFormat;
fboFormat.setAttachment(QOpenGLFramebufferObject::CombinedDepthStencil);
// Uncomplicate things by using NPOT:
const QSize size(256, 128);
QOpenGLFramebufferObject fbo(size, fboFormat);
if (fbo.attachment() != QOpenGLFramebufferObject::CombinedDepthStencil)
QSKIP("FBOs missing combined depth~stencil support");
QVERIFY(fbo.bind());
QPainter fboPainter;
QOpenGLPaintDevice device(fbo.width(), fbo.height());
bool painterBegun = fboPainter.begin(&device);
QVERIFY(painterBegun);
qt_opengl_draw_test_pattern(&fboPainter, fbo.width(), fbo.height());
fboPainter.end();
const QImage fb = fbo.toImage().convertToFormat(QImage::Format_RGB32);
QCOMPARE(fb.size(), size);
qt_opengl_check_test_pattern(fb);
}
示例10: QOpenGLFramebufferObject
void QQuickContext2DFBOTile::setRect(const QRect& r)
{
if (m_rect == r)
return;
m_rect = r;
m_dirty = true;
if (!m_fbo || m_fbo->size() != r.size()) {
QOpenGLFramebufferObjectFormat format;
format.setAttachment(QOpenGLFramebufferObject::CombinedDepthStencil);
format.setInternalTextureFormat(GL_RGBA);
format.setMipmap(false);
if (m_painter.isActive())
m_painter.end();
delete m_fbo;
m_fbo = new QOpenGLFramebufferObject(r.size(), format);
}
}
示例11: fboTextureOwnership
void tst_QOpenGL::fboTextureOwnership()
{
QFETCH(int, surfaceClass);
QScopedPointer<QSurface> surface(createSurface(surfaceClass));
QOpenGLContext ctx;
QVERIFY(ctx.create());
ctx.makeCurrent(surface.data());
if (!QOpenGLFramebufferObject::hasOpenGLFramebufferObjects())
QSKIP("QOpenGLFramebufferObject not supported on this platform");
QOpenGLFramebufferObjectFormat fboFormat;
fboFormat.setAttachment(QOpenGLFramebufferObject::NoAttachment);
QOpenGLFramebufferObject *fbo = new QOpenGLFramebufferObject(200, 100, fboFormat);
QVERIFY(fbo->texture() != 0);
fbo->bind();
// pull out the texture
GLuint texture = fbo->takeTexture();
QVERIFY(texture != 0);
QVERIFY(fbo->texture() == 0);
// verify that the next bind() creates a new texture
fbo->bind();
QVERIFY(fbo->texture() != 0 && fbo->texture() != texture);
glClearColor(1.0, 0.0, 0.0, 1.0);
glClear(GL_COLOR_BUFFER_BIT);
glFinish();
QImage fb = fbo->toImage().convertToFormat(QImage::Format_RGB32);
QImage reference(fb.size(), QImage::Format_RGB32);
reference.fill(0xffff0000);
QFUZZY_COMPARE_IMAGES(fb, reference);
glDeleteTextures(1, &texture);
delete fbo;
}
示例12: sipNoMethod
static PyObject *meth_QOpenGLFramebufferObjectFormat_setAttachment(PyObject *sipSelf, PyObject *sipArgs)
{
PyObject *sipParseErr = NULL;
{
QOpenGLFramebufferObject::Attachment a0;
QOpenGLFramebufferObjectFormat *sipCpp;
if (sipParseArgs(&sipParseErr, sipArgs, "BE", &sipSelf, sipType_QOpenGLFramebufferObjectFormat, &sipCpp, sipType_QOpenGLFramebufferObject_Attachment, &a0))
{
sipCpp->setAttachment(a0);
Py_INCREF(Py_None);
return Py_None;
}
}
/* Raise an exception if the arguments couldn't be parsed. */
sipNoMethod(sipParseErr, sipName_QOpenGLFramebufferObjectFormat, sipName_setAttachment, doc_QOpenGLFramebufferObjectFormat_setAttachment);
return NULL;
}
示例13: initialize
void GLImageProcessor::initialize()
{
initializeOpenGLFunctions();
texture.reset(new QOpenGLTexture(image.mirrored()));
texture->setWrapMode(QOpenGLTexture::WrapMode::ClampToEdge);
texture->setMinificationFilter(QOpenGLTexture::LinearMipMapLinear);
texture->setMagnificationFilter(QOpenGLTexture::Linear);
program.reset(buildProgram());
program->release();
plotProgram.reset(buildPassthorughProgram());
plotProgram->release();
vao.create();
vao.bind();
vbo.reset(buildQuadTextured());
vao.release();
QOpenGLFramebufferObjectFormat format;
format.setAttachment(QOpenGLFramebufferObject::CombinedDepthStencil);
renderFbo.reset(new QOpenGLFramebufferObject(image.size(), format));
}
示例14: indexAt
int indexAt( /*GLuint *buffer,*/ NifModel * model, Scene * scene, QList<DrawFunc> drawFunc, int cycle, const QPoint & pos, int & furn )
{
Q_UNUSED( model ); Q_UNUSED( cycle );
// Color Key O(1) selection
// Open GL 3.0 says glRenderMode is deprecated
// ATI OpenGL API implementation of GL_SELECT corrupts NifSkope memory
//
// Create FBO for sharp edges and no shading.
// Texturing, blending, dithering, lighting and smooth shading should be disabled.
// The FBO can be used for the drawing operations to keep the drawing operations invisible to the user.
GLint viewport[4];
glGetIntegerv( GL_VIEWPORT, viewport );
// Create new FBO with multisampling disabled
QOpenGLFramebufferObjectFormat fboFmt;
fboFmt.setTextureTarget( GL_TEXTURE_2D );
fboFmt.setInternalTextureFormat( GL_RGB32F_ARB );
fboFmt.setAttachment( QOpenGLFramebufferObject::Attachment::CombinedDepthStencil );
QOpenGLFramebufferObject fbo( viewport[2], viewport[3], fboFmt );
fbo.bind();
glEnable( GL_LIGHTING );
glDisable( GL_MULTISAMPLE );
glDisable( GL_MULTISAMPLE_ARB );
glDisable( GL_LINE_SMOOTH );
glDisable( GL_POINT_SMOOTH );
glDisable( GL_POLYGON_SMOOTH );
glDisable( GL_TEXTURE_1D );
glDisable( GL_TEXTURE_2D );
glDisable( GL_TEXTURE_3D );
glDisable( GL_BLEND );
glDisable( GL_DITHER );
glDisable( GL_FOG );
glDisable( GL_LIGHTING );
glShadeModel( GL_FLAT );
glEnable( GL_DEPTH_TEST );
glDepthFunc( GL_LEQUAL );
glClearColor( 0, 0, 0, 1 );
glClear( GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT );
// Rasterize the scene
Node::SELECTING = 1;
for ( DrawFunc df : drawFunc ) {
(scene->*df)();
}
Node::SELECTING = 0;
fbo.release();
QImage img( fbo.toImage() );
QColor pixel = img.pixel( pos );
#ifndef QT_NO_DEBUG
img.save( "fbo.png" );
#endif
// Encode RGB to Int
int a = 0;
a |= pixel.red() << 0;
a |= pixel.green() << 8;
a |= pixel.blue() << 16;
// Decode:
// R = (id & 0x000000FF) >> 0
// G = (id & 0x0000FF00) >> 8
// B = (id & 0x00FF0000) >> 16
int choose = COLORKEY2ID( a );
// Pick BSFurnitureMarker
if ( choose > 0 ) {
auto furnBlock = model->getBlock( model->index( 3, 0, model->getBlock( choose & 0x0ffff ) ), "BSFurnitureMarker" );
if ( furnBlock.isValid() ) {
furn = choose >> 16;
choose &= 0x0ffff;
}
示例15: QOpenGLFramebufferObject
QOpenGLFramebufferObject *createFramebufferObject(const QSize &size) override {
m_heightMapRenderer.setAspectRatio(size.width(), size.height());
QOpenGLFramebufferObjectFormat format;
format.setAttachment(QOpenGLFramebufferObject::Depth);
return new QOpenGLFramebufferObject(size, format);
}