本文整理汇总了C++中shader::IProgramObject类的典型用法代码示例。如果您正苦于以下问题:C++ IProgramObject类的具体用法?C++ IProgramObject怎么用?C++ IProgramObject使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了IProgramObject类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1:
void CSM3GroundDrawer::DrawShadowPass()
{
if (!shadowrc)
return;
shadowCam.fov = camera->GetHalfFov()*2.0f; // Why *2?
shadowCam.front = camera->forward;
shadowCam.right = camera->right;
shadowCam.up = camera->up;
shadowCam.pos = camera->GetPos();
shadowCam.aspect = 1.0f;
Shader::IProgramObject* po =
shadowHandler->GetShadowGenProg(CShadowHandler::SHADOWGEN_PROGRAM_MAP);
glPolygonOffset(1, 1);
glEnable(GL_POLYGON_OFFSET_FILL);
glEnable(GL_CULL_FACE);
glCullFace(GL_FRONT);
po->Enable();
tr->SetActiveContext(shadowrc);
tr->DrawSimple();
tr->SetActiveContext(rc);
po->Disable();
glCullFace(GL_BACK);
glDisable(GL_CULL_FACE);
glDisable(GL_POLYGON_OFFSET_FILL);
}
示例2: CreateProgramObject
Shader::IProgramObject* CShaderHandler::CreateProgramObject(
const std::string& poClass,
const std::string& poName,
const std::string& vsStr,
const std::string& vsDefs,
const std::string& fsStr,
const std::string& fsDefs,
bool arbProgram
) {
Shader::IProgramObject* po = CreateProgramObject(poClass, poName, arbProgram);
if (po->IsValid()) {
return po;
}
Shader::IShaderObject* vso = CreateShaderObject(vsStr, vsDefs, (arbProgram? GL_VERTEX_PROGRAM_ARB: GL_VERTEX_SHADER));
Shader::IShaderObject* fso = CreateShaderObject(fsStr, fsDefs, (arbProgram? GL_FRAGMENT_PROGRAM_ARB: GL_FRAGMENT_SHADER));
po->AttachShaderObject(vso);
po->AttachShaderObject(fso);
po->Link();
if (!po->IsValid()) {
logOutput.Print("[CShaderHandler::CreateProgramObject]\n");
logOutput.Print("\tprogram-object name: %s, link-log:\n%s\n", poName.c_str(), po->GetLog().c_str());
}
return po;
}
示例3: HasValidShader
bool SMFRenderStateGLSL::HasValidShader(const DrawPass::e& drawPass) const {
Shader::IProgramObject* shader = nullptr;
switch (drawPass) {
case DrawPass::TerrainDeferred: { shader = glslShaders[GLSL_SHADER_DEFERRED]; } break;
default: { shader = glslShaders[GLSL_SHADER_CURRENT ]; } break;
}
return (shader != nullptr && shader->IsValid());
}
示例4: 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());
}
示例5: DrawBorder
void CSMFGroundDrawer::DrawBorder(const DrawPass::e drawPass)
{
ISMFRenderState* prvState = smfRenderStates[RENDER_STATE_SEL];
Shader::IProgramObject* shaderProg = &borderShader;
// no need to enable, does nothing
smfRenderStates[RENDER_STATE_SEL] = smfRenderStates[RENDER_STATE_NOP];
glEnable(GL_CULL_FACE);
glCullFace(GL_BACK);
glActiveTexture(GL_TEXTURE2);
glEnable(GL_TEXTURE_2D);
glBindTexture(GL_TEXTURE_2D, smfMap->GetDetailTexture());
glActiveTexture(GL_TEXTURE0);
glEnable(GL_TEXTURE_2D);
glEnable(GL_BLEND);
glPolygonMode(GL_FRONT_AND_BACK, GL_LINE * wireframe + GL_FILL * (1 - wireframe));
#if 0
if (mapRendering->voidWater && (drawPass != DrawPass::WaterReflection)) {
glEnable(GL_ALPHA_TEST);
glAlphaFunc(GL_GREATER, 0.9f);
}
#endif
shaderProg->Enable();
shaderProg->SetUniformMatrix4x4<const char*, float>("u_movi_mat", false, camera->GetViewMatrix());
shaderProg->SetUniformMatrix4x4<const char*, float>("u_proj_mat", false, camera->GetProjectionMatrix());
meshDrawer->DrawBorderMesh(drawPass); // calls back into ::SetupBigSquare
shaderProg->Disable();
#if 0
if (mapRendering->voidWater && (drawPass != DrawPass::WaterReflection))
glDisable(GL_ALPHA_TEST);
#endif
glPolygonMode(GL_FRONT_AND_BACK, GL_FILL);
glDisable(GL_BLEND);
glActiveTexture(GL_TEXTURE2);
glDisable(GL_TEXTURE_2D);
glActiveTexture(GL_TEXTURE0);
glDisable(GL_TEXTURE_2D);
glDisable(GL_CULL_FACE);
smfRenderStates[RENDER_STATE_SEL] = prvState;
}
示例6: ReleaseProgramObjectsMap
void CShaderHandler::ReleaseProgramObjectsMap(ProgramObjMap& poMap) {
for (auto it = poMap.cbegin(); it != poMap.cend(); ++it) {
Shader::IProgramObject* po = it->second;
// free the program object and its attachments
if (po != Shader::nullProgramObject) {
po->Release(); delete po;
}
}
poMap.clear();
}
示例7: HasValidShader
bool SMFRenderStateARB::HasValidShader(const DrawPass::e& drawPass) const {
Shader::IProgramObject* shader = nullptr;
switch (drawPass) {
case DrawPass::Normal: { shader = arbShaders[ARB_SHADER_CURRENT]; } break;
case DrawPass::WaterReflection: { shader = arbShaders[ARB_SHADER_REFLECT]; } break;
case DrawPass::WaterRefraction: { shader = arbShaders[ARB_SHADER_REFRACT]; } break;
default: {} break;
}
return (shader != nullptr && shader->IsValid());
}
示例8: LoadShadowGenShaderProgs
void CShadowHandler::LoadShadowGenShaderProgs()
{
shadowGenProgs.resize(SHADOWGEN_PROGRAM_LAST);
static const std::string shadowGenProgNames[SHADOWGEN_PROGRAM_LAST] = {
"ARB/unit_genshadow.vp",
"ARB/groundshadow.vp",
"ARB/treeShadow.vp",
"ARB/treeFarShadow.vp",
"ARB/projectileshadow.vp",
};
static const std::string shadowGenProgHandles[SHADOWGEN_PROGRAM_LAST] = {
"ShadowGenShaderProgModel",
"ShadowGenshaderProgMap",
"ShadowGenshaderProgTreeNear",
"ShadowGenshaderProgTreeDist",
"ShadowGenshaderProgProjectile",
};
static const std::string shadowGenProgDefines[SHADOWGEN_PROGRAM_LAST] = {
"#define SHADOWGEN_PROGRAM_MODEL\n",
"#define SHADOWGEN_PROGRAM_MAP\n",
"#define SHADOWGEN_PROGRAM_TREE_NEAR\n",
"#define SHADOWGEN_PROGRAM_TREE_DIST\n",
"#define SHADOWGEN_PROGRAM_PROJECTILE\n",
};
CShaderHandler* sh = shaderHandler;
if (globalRendering->haveGLSL) {
for (int i = 0; i < SHADOWGEN_PROGRAM_LAST; i++) {
Shader::IProgramObject* po = sh->CreateProgramObject("[ShadowHandler]", shadowGenProgHandles[i] + "GLSL", false);
Shader::IShaderObject* so = sh->CreateShaderObject("GLSL/ShadowGenVertProg.glsl", shadowGenProgDefines[i], GL_VERTEX_SHADER);
po->AttachShaderObject(so);
po->Link();
po->SetUniformLocation("shadowParams");
po->SetUniformLocation("cameraDirX"); // used by SHADOWGEN_PROGRAM_TREE_NEAR
po->SetUniformLocation("cameraDirY"); // used by SHADOWGEN_PROGRAM_TREE_NEAR
po->SetUniformLocation("treeOffset"); // used by SHADOWGEN_PROGRAM_TREE_NEAR
shadowGenProgs[i] = po;
}
} else {
for (int i = 0; i < SHADOWGEN_PROGRAM_LAST; i++) {
Shader::IProgramObject* po = sh->CreateProgramObject("[ShadowHandler]", shadowGenProgHandles[i] + "ARB", true);
Shader::IShaderObject* so = sh->CreateShaderObject(shadowGenProgNames[i], "", GL_VERTEX_PROGRAM_ARB);
po->AttachShaderObject(so);
po->Link();
shadowGenProgs[i] = po;
}
}
drawShadows = true;
}
示例9: DrawShadowPass
void CFeatureDrawer::DrawShadowPass()
{
glPolygonOffset(1.0f, 1.0f);
glEnable(GL_POLYGON_OFFSET_FILL);
Shader::IProgramObject* po =
shadowHandler->GetShadowGenProg(CShadowHandler::SHADOWGEN_PROGRAM_MODEL);
po->Enable();
{
GML_RECMUTEX_LOCK(feat); // DrawShadowPass
// note: for the shadow-pass, we want to make sure
// out-of-view features casting frustum-intersecting
// shadows are still rendered, but this is expensive
// and does not make much difference
//
// GetVisibleFeatures(1, false);
// need the alpha-mask for transparent features
glEnable(GL_TEXTURE_2D);
glPushAttrib(GL_COLOR_BUFFER_BIT);
glEnable(GL_ALPHA_TEST);
glAlphaFunc(GL_GREATER, 0.5f);
// needed for 3do models (else they will use any currently bound texture)
// note: texture0 is by default a 1x1 texture with rgba(0,0,0,255)
// (we are just interested in the 255 alpha here)
glBindTexture(GL_TEXTURE_2D, 0);
// 3DO's have clockwise-wound faces and
// (usually) holes, so disable backface
// culling for them
glDisable(GL_CULL_FACE);
DrawOpaqueFeatures(MODELTYPE_3DO);
glEnable(GL_CULL_FACE);
for (int modelType = MODELTYPE_S3O; modelType < MODELTYPE_OTHER; modelType++) {
DrawOpaqueFeatures(modelType);
}
glPopAttrib();
glDisable(GL_TEXTURE_2D);
}
po->Disable();
glDisable(GL_POLYGON_OFFSET_FILL);
}
示例10: DrawWaterPlane
void CSMFGroundDrawer::DrawWaterPlane(bool drawWaterReflection) {
if (drawWaterReflection)
return;
GL::RenderDataBuffer& buffer = waterPlaneBuffers[1 - (camera->GetPos().IsInBounds() && !mapRendering->voidWater)];
Shader::IProgramObject* shader = &buffer.GetShader();
shader->Enable();
shader->SetUniformMatrix4x4<const char*, float>("u_movi_mat", false, camera->GetViewMatrix());
shader->SetUniformMatrix4x4<const char*, float>("u_proj_mat", false, camera->GetProjectionMatrix());
shader->SetUniform("planeOffset", std::min(-200.0f, smfMap->GetCurrMinHeight() - 400.0f));
buffer.Submit(GL_TRIANGLE_STRIP, 0, buffer.GetNumElems<VA_TYPE_C>());
shader->Disable();
}
示例11: DrawShadowPass
void CSMFGroundDrawer::DrawShadowPass(void)
{
if (mapInfo->map.voidWater && readmap->currMaxHeight < 0.0f) {
return;
}
Shader::IProgramObject* po = shadowHandler->GetShadowGenProg(CShadowHandler::SHADOWGEN_PROGRAM_MAP);
glEnable(GL_POLYGON_OFFSET_FILL);
glPolygonOffset(-1.f, -1.f);
po->Enable();
meshDrawer->DrawMesh(DrawPass::Shadow);
po->Disable();
glDisable(GL_POLYGON_OFFSET_FILL);
}
示例12: CreateProgramObject
Shader::IProgramObject* CShaderHandler::CreateProgramObject(
const std::string& poClass,
const std::string& poName,
const std::string& vsStr,
const std::string& vsDefs,
const std::string& fsStr,
const std::string& fsDefs,
bool arbProgram
) {
Shader::IProgramObject* po = CreateProgramObject(poClass, poName, arbProgram);
if (po->IsValid()) {
return po;
}
Shader::IShaderObject* vso = CreateShaderObject(vsStr, vsDefs, (arbProgram? GL_VERTEX_PROGRAM_ARB: GL_VERTEX_SHADER));
Shader::IShaderObject* fso = CreateShaderObject(fsStr, fsDefs, (arbProgram? GL_FRAGMENT_PROGRAM_ARB: GL_FRAGMENT_SHADER));
po->AttachShaderObject(vso);
po->AttachShaderObject(fso);
po->Link();
po->Validate();
if (!po->IsValid()) {
const char* fmt = "[%s]\n\tprogram-object name: %s, link-log:\n%s";
const char* log = po->GetLog().c_str();
LOG_L(L_WARNING, fmt, __FUNCTION__, poName.c_str(), log);
}
return po;
}
示例13: 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);
}
示例14: DrawShadowPass
void CProjectileDrawer::DrawShadowPass()
{
Shader::IProgramObject* po =
shadowHandler->GetShadowGenProg(CShadowHandler::SHADOWGEN_PROGRAM_PROJECTILE);
glDisable(GL_TEXTURE_2D);
po->Enable();
CProjectile::inArray = false;
CProjectile::va = GetVertexArray();
CProjectile::va->Initialize();
{
GML_RECMUTEX_LOCK(proj); // DrawShadowPass
for (int modelType = MODELTYPE_3DO; modelType < MODELTYPE_OTHER; modelType++) {
DrawProjectilesShadow(modelType);
}
// draw the model-less projectiles
DrawProjectilesSetShadow(renderProjectiles);
}
if (CProjectile::inArray) {
glEnable(GL_TEXTURE_2D);
textureAtlas->BindTexture();
glColor4f(1.0f, 1.0f, 1.0f, 1.0f);
glAlphaFunc(GL_GREATER,0.3f);
glEnable(GL_ALPHA_TEST);
glShadeModel(GL_SMOOTH);
ph->currentParticles += CProjectile::DrawArray();
}
po->Disable();
glShadeModel(GL_FLAT);
glDisable(GL_ALPHA_TEST);
glDisable(GL_TEXTURE_2D);
}
示例15: CreateBorderShader
void CSMFGroundDrawer::CreateBorderShader() {
std::string vsCode = std::move(Shader::GetShaderSource("GLSL/SMFBorderVertProg4.glsl"));
std::string fsCode = std::move(Shader::GetShaderSource("GLSL/SMFBorderFragProg4.glsl"));
Shader::GLSLShaderObject shaderObjs[2] = {{GL_VERTEX_SHADER, vsCode.c_str(), ""}, {GL_FRAGMENT_SHADER, fsCode.c_str(), ""}};
Shader::IProgramObject* shaderProg = &borderShader;
borderShader.AttachShaderObject(&shaderObjs[0]);
borderShader.AttachShaderObject(&shaderObjs[1]);
borderShader.ReloadShaderObjects();
borderShader.CreateAndLink();
borderShader.RecalculateShaderHash();
borderShader.ClearAttachedShaderObjects();
borderShader.Validate();
shaderProg->Enable();
shaderProg->SetUniformMatrix4x4<const char*, float>("u_movi_mat", false, CMatrix44f::Identity());
shaderProg->SetUniformMatrix4x4<const char*, float>("u_proj_mat", false, CMatrix44f::Identity());
shaderProg->SetUniform("u_diffuse_tex_sqr", -1, -1);
shaderProg->SetUniform("u_diffuse_tex", 0);
shaderProg->SetUniform("u_detail_tex", 2);
shaderProg->Disable();
}