本文整理汇总了C++中GLShader::getUniformMatrix4x4方法的典型用法代码示例。如果您正苦于以下问题:C++ GLShader::getUniformMatrix4x4方法的具体用法?C++ GLShader::getUniformMatrix4x4怎么用?C++ GLShader::getUniformMatrix4x4使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类GLShader
的用法示例。
在下文中一共展示了GLShader::getUniformMatrix4x4方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: paintWindow
void ExplosionEffect::paintWindow(EffectWindow* w, int mask, QRegion region, WindowPaintData& data)
{
// Make sure we have OpenGL compositing and the window is vidible and not a
// special window
bool useshader = (mValid && mWindows.contains(w));
if (useshader) {
double maxscaleadd = 1.5f;
double scale = 1 + maxscaleadd * mWindows[w];
data.setXScale(scale);
data.setYScale(scale);
data.translate(int(w->width() / 2 * (1 - scale)), int(w->height() / 2 * (1 - scale)));
data.multiplyOpacity(0.99); // Force blending
ShaderManager *manager = ShaderManager::instance();
GLShader *shader = manager->pushShader(ShaderManager::GenericShader);
QMatrix4x4 screenTransformation = shader->getUniformMatrix4x4("screenTransformation");
manager->popShader();
ShaderManager::instance()->pushShader(mShader);
mShader->setUniform("screenTransformation", screenTransformation);
mShader->setUniform("factor", (float)mWindows[w]);
mShader->setUniform("scale", (float)scale);
mShader->setUniform("windowSize", QVector2D(w->width(), w->height()));
glActiveTexture(GL_TEXTURE4);
mStartOffsetTex->bind();
glActiveTexture(GL_TEXTURE5);
mEndOffsetTex->bind();
glActiveTexture(GL_TEXTURE0);
data.shader = mShader;
}
// Call the next effect.
effects->paintWindow(w, mask, region, data);
if (useshader) {
ShaderManager::instance()->popShader();
glActiveTexture(GL_TEXTURE4);
mStartOffsetTex->unbind();
glActiveTexture(GL_TEXTURE5);
mEndOffsetTex->unbind();
glActiveTexture(GL_TEXTURE0);
}
}
示例2: paintScreen
void CoverSwitchEffect::paintScreen(int mask, QRegion region, ScreenPaintData& data)
{
effects->paintScreen(mask, region, data);
if (mActivated || stop || stopRequested) {
QMatrix4x4 origProjection;
QMatrix4x4 origModelview;
ShaderManager *shaderManager = ShaderManager::instance();
if (effects->numScreens() > 1) {
// unfortunatelly we have to change the projection matrix in dual screen mode
QRect fullRect = effects->clientArea(FullArea, activeScreen, effects->currentDesktop());
float fovy = 60.0f;
float aspect = 1.0f;
float zNear = 0.1f;
float zFar = 100.0f;
float ymax = zNear * tan(fovy * M_PI / 360.0f);
float ymin = -ymax;
float xmin = ymin * aspect;
float xmax = ymax * aspect;
float xTranslate = 0.0;
float yTranslate = 0.0;
float xminFactor = 1.0;
float xmaxFactor = 1.0;
float yminFactor = 1.0;
float ymaxFactor = 1.0;
if (area.x() == 0 && area.width() != fullRect.width()) {
// horizontal layout: left screen
xminFactor = (float)area.width() / (float)fullRect.width();
xmaxFactor = ((float)fullRect.width() - (float)area.width() * 0.5f) / ((float)fullRect.width() * 0.5f);
xTranslate = (float)fullRect.width() * 0.5f - (float)area.width() * 0.5f;
}
if (area.x() != 0 && area.width() != fullRect.width()) {
// horizontal layout: right screen
xminFactor = ((float)fullRect.width() - (float)area.width() * 0.5f) / ((float)fullRect.width() * 0.5f);
xmaxFactor = (float)area.width() / (float)fullRect.width();
xTranslate = (float)fullRect.width() * 0.5f - (float)area.width() * 0.5f;
}
if (area.y() == 0 && area.height() != fullRect.height()) {
// vertical layout: top screen
yminFactor = ((float)fullRect.height() - (float)area.height() * 0.5f) / ((float)fullRect.height() * 0.5f);
ymaxFactor = (float)area.height() / (float)fullRect.height();
yTranslate = (float)fullRect.height() * 0.5f - (float)area.height() * 0.5f;
}
if (area.y() != 0 && area.height() != fullRect.height()) {
// vertical layout: bottom screen
yminFactor = (float)area.height() / (float)fullRect.height();
ymaxFactor = ((float)fullRect.height() - (float)area.height() * 0.5f) / ((float)fullRect.height() * 0.5f);
yTranslate = (float)fullRect.height() * 0.5f - (float)area.height() * 0.5f;
}
QMatrix4x4 projection;
projection.frustum(xmin * xminFactor, xmax * xmaxFactor, ymin * yminFactor, ymax * ymaxFactor, zNear, zFar);
QMatrix4x4 modelview;
modelview.translate(xTranslate, yTranslate, 0.0);
if (shaderManager->isShaderBound()) {
GLShader *shader = shaderManager->pushShader(ShaderManager::GenericShader);
origProjection = shader->getUniformMatrix4x4("projection");
origModelview = shader->getUniformMatrix4x4("modelview");
shader->setUniform("projection", projection);
shader->setUniform("modelview", origModelview * modelview);
shaderManager->popShader();
} else {
#ifndef KWIN_HAVE_OPENGLES
glMatrixMode(GL_PROJECTION);
pushMatrix();
loadMatrix(projection);
glMatrixMode(GL_MODELVIEW);
pushMatrix(modelview);
#endif
}
}
QList< EffectWindow* > tempList = currentWindowList;
int index = tempList.indexOf(selected_window);
if (animation || start || stop) {
if (!start && !stop) {
if (direction == Right)
index++;
else
index--;
if (index < 0)
index = tempList.count() + index;
if (index >= tempList.count())
index = index % tempList.count();
}
foreach (Direction direction, scheduled_directions) {
if (direction == Right)
index++;
else
index--;
if (index < 0)
index = tempList.count() + index;
if (index >= tempList.count())
index = index % tempList.count();
}
}
int leftIndex = index - 1;
if (leftIndex < 0)
leftIndex = tempList.count() - 1;
int rightIndex = index + 1;
if (rightIndex == tempList.count())
//.........这里部分代码省略.........