本文整理汇总了C++中shader::IProgramObject::SetUniformMatrix4fv方法的典型用法代码示例。如果您正苦于以下问题:C++ IProgramObject::SetUniformMatrix4fv方法的具体用法?C++ IProgramObject::SetUniformMatrix4fv怎么用?C++ IProgramObject::SetUniformMatrix4fv使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类shader::IProgramObject
的用法示例。
在下文中一共展示了IProgramObject::SetUniformMatrix4fv方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: SetupDefShadowUnitDrawState
// shadow-pass state management funcs
// FIXME: setup face culling for S3O?
static void SetupDefShadowUnitDrawState(unsigned int modelType, bool deferredPass) {
glDisable(GL_TEXTURE_2D);
glPolygonOffset(1.0f, 1.0f);
glEnable(GL_POLYGON_OFFSET_FILL);
Shader::IProgramObject* po = shadowHandler->GetShadowGenProg(CShadowHandler::SHADOWGEN_PROGRAM_MODEL);
po->Enable();
po->SetUniformMatrix4fv(1, false, shadowHandler->GetShadowViewMatrix());
po->SetUniformMatrix4fv(2, false, shadowHandler->GetShadowProjMatrix());
}
示例2: DrawShadowPass
void CSMFGroundDrawer::DrawShadowPass()
{
if (!globalRendering->drawGround)
return;
if (readMap->HasOnlyVoidWater())
return;
Shader::IProgramObject* po = shadowHandler->GetShadowGenProg(CShadowHandler::SHADOWGEN_PROGRAM_MAP);
glEnable(GL_POLYGON_OFFSET_FILL);
glPolygonOffset(spPolygonOffsetScale, spPolygonOffsetUnits); // dz*s + r*u
// also render the border geometry to prevent light-visible backfaces
po->Enable();
po->SetUniformMatrix4fv(1, false, shadowHandler->GetShadowViewMatrix());
po->SetUniformMatrix4fv(2, false, shadowHandler->GetShadowProjMatrix());
meshDrawer->DrawMesh(DrawPass::Shadow);
meshDrawer->DrawBorderMesh(DrawPass::Shadow);
po->Disable();
glDisable(GL_POLYGON_OFFSET_FILL);
}
示例3: Draw
void CAdvTreeDrawer::Draw(float treeDistance, bool drawReflection)
{
const int activeFarTex = (camera->forward.z < 0.0f)? treeGen->farTex[0]: treeGen->farTex[1];
const bool drawDetailed = ((treeDistance >= 4.0f) || drawReflection);
CBaseGroundDrawer* gd = readmap->GetGroundDrawer();
Shader::IProgramObject* treeShader = NULL;
#define L mapInfo->light
glEnable(GL_ALPHA_TEST);
glEnable(GL_TEXTURE_2D);
if (globalRendering->drawFog) {
glFogfv(GL_FOG_COLOR, mapInfo->atmosphere.fogColor);
glEnable(GL_FOG);
}
if (shadowHandler->shadowsLoaded && !gd->DrawExtraTex()) {
glActiveTexture(GL_TEXTURE1);
glBindTexture(GL_TEXTURE_2D, activeFarTex);
glActiveTexture(GL_TEXTURE0);
glBindTexture(GL_TEXTURE_2D, shadowHandler->shadowTexture);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_COMPARE_MODE_ARB, GL_COMPARE_R_TO_TEXTURE);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_COMPARE_FUNC_ARB, GL_LEQUAL);
glTexParameteri(GL_TEXTURE_2D, GL_DEPTH_TEXTURE_MODE_ARB, GL_ALPHA);
treeShader = treeShaders[TREE_PROGRAM_DIST_SHADOW];
treeShader->Enable();
if (globalRendering->haveGLSL) {
treeShader->SetUniformMatrix4fv(7, false, &shadowHandler->shadowMatrix.m[0]);
treeShader->SetUniform4fv(8, &(shadowHandler->GetShadowParams().x));
} else {
treeShader->SetUniformTarget(GL_FRAGMENT_PROGRAM_ARB);
treeShader->SetUniform4f(10, L.groundAmbientColor.x, L.groundAmbientColor.y, L.groundAmbientColor.z, 1.0f);
treeShader->SetUniform4f(11, 0.0f, 0.0f, 0.0f, 1.0f - (sky->GetLight()->GetGroundShadowDensity() * 0.5f));
treeShader->SetUniformTarget(GL_VERTEX_PROGRAM_ARB);
glMatrixMode(GL_MATRIX0_ARB);
glLoadMatrixf(shadowHandler->shadowMatrix.m);
glMatrixMode(GL_MODELVIEW);
}
} else {
glBindTexture(GL_TEXTURE_2D, activeFarTex);
}
const int cx = int(camera->pos.x / (SQUARE_SIZE * TREE_SQUARE_SIZE));
const int cy = int(camera->pos.z / (SQUARE_SIZE * TREE_SQUARE_SIZE));
CAdvTreeSquareDrawer drawer(this, cx, cy, treeDistance * SQUARE_SIZE * TREE_SQUARE_SIZE, drawDetailed);
GML_STDMUTEX_LOCK(tree); // Draw
oldTreeDistance = treeDistance;
// draw far-trees using map-dependent grid-visibility
readmap->GridVisibility(camera, TREE_SQUARE_SIZE, drawer.treeDistance * 2.0f, &drawer);
if (drawDetailed) {
// draw near-trees
const int xstart = std::max( 0, cx - 2);
const int xend = std::min(gs->mapx / TREE_SQUARE_SIZE - 1, cx + 2);
const int ystart = std::max( 0, cy - 2);
const int yend = std::min(gs->mapy / TREE_SQUARE_SIZE - 1, cy + 2);
if (shadowHandler->shadowsLoaded && !gd->DrawExtraTex()) {
treeShader->Disable();
treeShader = treeShaders[TREE_PROGRAM_NEAR_SHADOW];
treeShader->Enable();
if (globalRendering->haveGLSL) {
treeShader->SetUniformMatrix4fv(7, false, &shadowHandler->shadowMatrix.m[0]);
treeShader->SetUniform4fv(8, &(shadowHandler->GetShadowParams().x));
}
glActiveTexture(GL_TEXTURE1);
glEnable(GL_TEXTURE_2D);
glBindTexture(GL_TEXTURE_2D, treeGen->barkTex);
glActiveTexture(GL_TEXTURE0);
} else {
glBindTexture(GL_TEXTURE_2D, treeGen->barkTex);
treeShader = treeShaders[TREE_PROGRAM_NEAR_BASIC];
treeShader->Enable();
if (!globalRendering->haveGLSL) {
#define MX (gs->pwr2mapx * SQUARE_SIZE)
#define MY (gs->pwr2mapy * SQUARE_SIZE)
treeShader->SetUniformTarget(GL_VERTEX_PROGRAM_ARB);
treeShader->SetUniform4f(15, 1.0f / MX, 1.0f / MY, 1.0f / MX, 1.0f);
#undef MX
#undef MY
}
}
//.........这里部分代码省略.........