当前位置: 首页>>代码示例>>C++>>正文


C++ IProgramObject::SetFlag方法代码示例

本文整理汇总了C++中shader::IProgramObject::SetFlag方法的典型用法代码示例。如果您正苦于以下问题:C++ IProgramObject::SetFlag方法的具体用法?C++ IProgramObject::SetFlag怎么用?C++ IProgramObject::SetFlag使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在shader::IProgramObject的用法示例。


在下文中一共展示了IProgramObject::SetFlag方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: Enable

void SMFRenderStateGLSL::Enable(const CSMFGroundDrawer* smfGroundDrawer, const DrawPass::e& drawPass) {
	if (useLuaShaders) {
		// use raw, GLSLProgramObject::Enable also calls RecompileIfNeeded
		glUseProgram(glslShaders[GLSL_SHADER_CURRENT]->GetObjID());
		// diffuse textures are always bound (SMFGroundDrawer::SetupBigSquare)
		glActiveTexture(GL_TEXTURE0);
		return;
	}

	Shader::IProgramObject* shader = glslShaders[GLSL_SHADER_CURRENT];

	const CSMFReadMap* smfMap = smfGroundDrawer->GetReadMap();

	const GL::LightHandler* cLightHandler = smfGroundDrawer->GetLightHandler();
	      GL::LightHandler* mLightHandler = const_cast<GL::LightHandler*>(cLightHandler); // XXX

	const float3 cameraPos = camera->GetPos();
	const float3 fogParams = {sky->fogStart, sky->fogEnd, globalRendering->viewRange};
	const float2 mapParams = {readMap->GetCurrMinHeight(), readMap->GetCurrMaxHeight()};

	shader->SetFlag("HAVE_SHADOWS", shadowHandler->ShadowsLoaded());
	shader->SetFlag("HAVE_INFOTEX", infoTextureHandler->IsEnabled());

	shader->Enable();
	shader->SetUniform2v<const char*, float>("mapHeights", &mapParams.x);
	shader->SetUniform3v<const char*, float>("cameraPos", &cameraPos.x);
	shader->SetUniformMatrix4x4<const char*, float>("viewMat", false, camera->GetViewMatrix());
	shader->SetUniformMatrix4x4<const char*, float>("viewMatInv", false, camera->GetViewMatrixInverse());
	shader->SetUniformMatrix4x4<const char*, float>("viewProjMat", false, camera->GetViewProjectionMatrix());
	shader->SetUniformMatrix4x4<const char*, float>("shadowMat", false, shadowHandler->GetShadowViewMatrix());
	shader->SetUniform4v<const char*, float>("shadowParams", shadowHandler->GetShadowParams());
	shader->SetUniform3v<const char*, float>("fogParams", &fogParams.x);
	shader->SetUniform<const char*, float>("infoTexIntensityMul", float(infoTextureHandler->InMetalMode()) + 1.0f);

	if (cLightHandler->NumConfigLights() > 0) {
		mLightHandler->Update();
		shader->SetUniform4v<const char*, float>("fwdDynLights", cLightHandler->NumUniformVecs(), cLightHandler->GetRawLightDataPtr());
	}

	switch (drawPass) {
		case DrawPass::WaterReflection: { shader->SetUniform4v<const char*, float>("clipPlane", IWater::MapReflClipPlane()); } break;
		case DrawPass::WaterRefraction: { shader->SetUniform4v<const char*, float>("clipPlane", IWater::MapRefrClipPlane()); } break;
		default: {} break;
	}

	if (shadowHandler->ShadowsLoaded())
		shadowHandler->SetupShadowTexSampler(GL_TEXTURE4);

	glActiveTexture(GL_TEXTURE2); glBindTexture(GL_TEXTURE_2D, smfMap->GetDetailTexture());
	glActiveTexture(GL_TEXTURE5); glBindTexture(GL_TEXTURE_2D, smfMap->GetNormalsTexture());
	glActiveTexture(GL_TEXTURE6); glBindTexture(GL_TEXTURE_2D, smfMap->GetSpecularTexture());
	glActiveTexture(GL_TEXTURE7); glBindTexture(GL_TEXTURE_2D, smfMap->GetSplatDetailTexture());
	glActiveTexture(GL_TEXTURE8); glBindTexture(GL_TEXTURE_2D, smfMap->GetSplatDistrTexture());
	glActiveTexture(GL_TEXTURE9); glBindTexture(GL_TEXTURE_CUBE_MAP, cubeMapHandler->GetSkyReflectionTextureID());
	glActiveTexture(GL_TEXTURE10); glBindTexture(GL_TEXTURE_2D, smfMap->GetSkyReflectModTexture());
	glActiveTexture(GL_TEXTURE11); glBindTexture(GL_TEXTURE_2D, smfMap->GetBlendNormalsTexture());
	glActiveTexture(GL_TEXTURE12); glBindTexture(GL_TEXTURE_2D, smfMap->GetLightEmissionTexture());
	glActiveTexture(GL_TEXTURE13); glBindTexture(GL_TEXTURE_2D, smfMap->GetParallaxHeightTexture());
	glActiveTexture(GL_TEXTURE14); glBindTexture(GL_TEXTURE_2D, infoTextureHandler->GetCurrentInfoTexture());

	for (int i = 0; i < CSMFReadMap::NUM_SPLAT_DETAIL_NORMALS; i++) {
		if (smfMap->GetSplatNormalTexture(i) != 0) {
			glActiveTexture(GL_TEXTURE15 + i); glBindTexture(GL_TEXTURE_2D, smfMap->GetSplatNormalTexture(i));
		}
	}

	glActiveTexture(GL_TEXTURE0);
}
开发者ID:sprunk,项目名称:spring,代码行数:68,代码来源:SMFRenderState.cpp


注:本文中的shader::IProgramObject::SetFlag方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。