本文整理汇总了C++中GLTexture::setFilter方法的典型用法代码示例。如果您正苦于以下问题:C++ GLTexture::setFilter方法的具体用法?C++ GLTexture::setFilter怎么用?C++ GLTexture::setFilter使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类GLTexture
的用法示例。
在下文中一共展示了GLTexture::setFilter方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: performPaint
//.........这里部分代码省略.........
if (hardwareClipping) {
glDisable(GL_SCISSOR_TEST);
}
cachedTexture->unbind();
m_timer.start(5000, this);
return;
} else {
// offscreen texture not matching - delete
delete cachedTexture;
cachedTexture = 0;
w->setData(LanczosCacheRole, QVariant());
}
}
WindowPaintData thumbData = data;
thumbData.setXScale(1.0);
thumbData.setYScale(1.0);
thumbData.setXTranslation(-w->x() - left);
thumbData.setYTranslation(-w->y() - top);
thumbData.setBrightness(1.0);
thumbData.setOpacity(1.0);
thumbData.setSaturation(1.0);
// Bind the offscreen FBO and draw the window on it unscaled
updateOffscreenSurfaces();
GLRenderTarget::pushRenderTarget(m_offscreenTarget);
glClearColor(0.0, 0.0, 0.0, 0.0);
glClear(GL_COLOR_BUFFER_BIT);
w->sceneWindow()->performPaint(mask, infiniteRegion(), thumbData);
// Create a scratch texture and copy the rendered window into it
GLTexture tex(sw, sh);
tex.setFilter(GL_LINEAR);
tex.setWrapMode(GL_CLAMP_TO_EDGE);
tex.bind();
glCopyTexSubImage2D(GL_TEXTURE_2D, 0, 0, 0, 0, m_offscreenTex->height() - sh, sw, sh);
// Set up the shader for horizontal scaling
float dx = sw / float(tw);
int kernelSize;
m_shader->createKernel(dx, &kernelSize);
m_shader->createOffsets(kernelSize, sw, Qt::Horizontal);
m_shader->bind();
m_shader->setUniforms();
// Draw the window back into the FBO, this time scaled horizontally
glClear(GL_COLOR_BUFFER_BIT);
QVector<float> verts;
QVector<float> texCoords;
verts.reserve(12);
texCoords.reserve(12);
texCoords << 1.0 << 0.0; verts << tw << 0.0; // Top right
texCoords << 0.0 << 0.0; verts << 0.0 << 0.0; // Top left
texCoords << 0.0 << 1.0; verts << 0.0 << sh; // Bottom left
texCoords << 0.0 << 1.0; verts << 0.0 << sh; // Bottom left
texCoords << 1.0 << 1.0; verts << tw << sh; // Bottom right
texCoords << 1.0 << 0.0; verts << tw << 0.0; // Top right
GLVertexBuffer *vbo = GLVertexBuffer::streamingBuffer();
vbo->reset();
vbo->setData(6, 2, verts.constData(), texCoords.constData());
vbo->render(GL_TRIANGLES);
示例2: doCachedBlur
void BlurEffect::doCachedBlur(EffectWindow *w, const QRegion& region, const float opacity)
{
const QRect screen = effects->virtualScreenGeometry();
const QRegion blurredRegion = blurRegion(w).translated(w->pos()) & screen;
const QRegion expanded = expand(blurredRegion) & screen;
const QRect r = expanded.boundingRect();
// The background texture we get is only partially valid.
CacheEntry it = windows.find(w);
if (it == windows.end()) {
BlurWindowInfo bwi;
bwi.blurredBackground = GLTexture(r.width(),r.height());
bwi.damagedRegion = expanded;
bwi.dropCache = false;
bwi.windowPos = w->pos();
it = windows.insert(w, bwi);
} else if (it->blurredBackground.size() != r.size()) {
it->blurredBackground = GLTexture(r.width(),r.height());
it->dropCache = false;
it->windowPos = w->pos();
} else if (it->windowPos != w->pos()) {
it->dropCache = false;
it->windowPos = w->pos();
}
GLTexture targetTexture = it->blurredBackground;
targetTexture.setFilter(GL_LINEAR);
targetTexture.setWrapMode(GL_CLAMP_TO_EDGE);
shader->bind();
QMatrix4x4 textureMatrix;
QMatrix4x4 modelViewProjectionMatrix;
/**
* Which part of the background texture can be updated ?
*
* Well this is a rather difficult question. We kind of rely on the fact, that
* we need a bigger background region being painted before, more precisely if we want to
* blur region A we need the background region expand(A). This business logic is basically
* done in prePaintWindow:
* data.paint |= expand(damagedArea);
*
* Now "data.paint" gets clipped and becomes what we receive as the "region" variable
* in this function. In theory there is now only one function that does this clipping
* and this is paintSimpleScreen. The clipping has the effect that "damagedRegion"
* is no longer a subset of "region" and we cannot fully validate the cache within one
* rendering pass. If we would now update the "damageRegion & region" part of the cache
* we would wrongly update the part of the cache that is next to the "region" border and
* which lies within "damagedRegion", just because we cannot assume that the framebuffer
* outside of "region" is valid. Therefore the maximal damaged region of the cache that can
* be repainted is given by:
* validUpdate = damagedRegion - expand(damagedRegion - region);
*
* Now you may ask what is with the rest of "damagedRegion & region" that is not part
* of "validUpdate" but also might end up on the screen. Well under the assumption
* that only the occlusion culling can shrink "data.paint", we can control this by reducing
* the opaque area of every window by a margin of the blurring radius (c.f. prePaintWindow).
* This way we are sure that this area is overpainted by a higher opaque window.
*
* Apparently paintSimpleScreen is not the only function that can influence "region".
* In fact every effect's paintWindow that is called before Blur::paintWindow
* can do so (e.g. SlidingPopups). Hence we have to make the compromise that we update
* "damagedRegion & region" of the cache but only mark "validUpdate" as valid.
**/
const QRegion damagedRegion = it->damagedRegion;
const QRegion updateBackground = damagedRegion & region;
const QRegion validUpdate = damagedRegion - expand(damagedRegion - region);
const QRegion horizontal = validUpdate.isEmpty() ? QRegion() : (updateBackground & screen);
const QRegion vertical = blurredRegion & region;
const int horizontalOffset = 0;
const int horizontalCount = horizontal.rectCount() * 6;
const int verticalOffset = horizontalCount;
const int verticalCount = vertical.rectCount() * 6;
GLVertexBuffer *vbo = GLVertexBuffer::streamingBuffer();
uploadGeometry(vbo, horizontal, vertical);
vbo->bindArrays();
if (!validUpdate.isEmpty()) {
const QRect updateRect = (expand(updateBackground) & expanded).boundingRect();
// First we have to copy the background from the frontbuffer
// into a scratch texture (in this case "tex").
tex.bind();
glCopyTexSubImage2D(GL_TEXTURE_2D, 0, 0, 0, updateRect.x(), displayHeight() - updateRect.y() - updateRect.height(),
updateRect.width(), updateRect.height());
// Draw the texture on the offscreen framebuffer object, while blurring it horizontally
target->attachTexture(targetTexture);
GLRenderTarget::pushRenderTarget(target);
shader->setDirection(Qt::Horizontal);
shader->setPixelDistance(1.0 / tex.width());
modelViewProjectionMatrix.ortho(0, r.width(), r.height(), 0 , 0, 65535);
modelViewProjectionMatrix.translate(-r.x(), -r.y(), 0);
//.........这里部分代码省略.........