本文整理汇总了C++中ProgramObject::deactivate方法的典型用法代码示例。如果您正苦于以下问题:C++ ProgramObject::deactivate方法的具体用法?C++ ProgramObject::deactivate怎么用?C++ ProgramObject::deactivate使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类ProgramObject
的用法示例。
在下文中一共展示了ProgramObject::deactivate方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: renderChunkLocally
void ChunkRenderer::renderChunkLocally(const Chunk& chunk, const RenderData& data) {
ProgramObject* programObject = getActivatedProgramWithTileData(
_localRenderingShaderProvider.get(),
_localProgramUniformHandler,
chunk);
if (programObject == nullptr) {
return;
}
using namespace glm;
const Ellipsoid& ellipsoid = chunk.owner()->ellipsoid();
bool performAnyBlending = false;
for (int i = 0; i < LayeredTextures::NUM_TEXTURE_CATEGORIES; ++i) {
LayeredTextures::TextureCategory category = (LayeredTextures::TextureCategory)i;
if (_tileProviderManager->getTileProviderGroup(i).levelBlendingEnabled && _tileProviderManager->getTileProviderGroup(category).getActiveTileProviders().size() > 0) {
performAnyBlending = true;
break;
}
}
if (performAnyBlending) {
float distanceScaleFactor = chunk.owner()->lodScaleFactor * chunk.owner()->ellipsoid().minimumRadius();
programObject->setUniform("distanceScaleFactor", distanceScaleFactor);
programObject->setUniform("chunkLevel", chunk.index().level);
}
// Calculate other uniform variables needed for rendering
dmat4 modelTransform = chunk.owner()->modelTransform();
dmat4 viewTransform = data.camera.combinedViewMatrix();
dmat4 modelViewTransform = viewTransform * modelTransform;
std::vector<std::string> cornerNames = { "p01", "p11", "p00", "p10" };
std::vector<Vec3> cornersCameraSpace(4);
for (int i = 0; i < 4; ++i) {
Quad q = (Quad)i;
Geodetic2 corner = chunk.surfacePatch().getCorner(q);
Vec3 cornerModelSpace = ellipsoid.cartesianSurfacePosition(corner);
Vec3 cornerCameraSpace = Vec3(dmat4(modelViewTransform) * glm::dvec4(cornerModelSpace, 1));
cornersCameraSpace[i] = cornerCameraSpace;
programObject->setUniform(cornerNames[i], vec3(cornerCameraSpace));
}
vec3 patchNormalCameraSpace = normalize(
cross(cornersCameraSpace[Quad::SOUTH_EAST] - cornersCameraSpace[Quad::SOUTH_WEST],
cornersCameraSpace[Quad::NORTH_EAST] - cornersCameraSpace[Quad::SOUTH_WEST]));
programObject->setUniform("patchNormalCameraSpace", patchNormalCameraSpace);
programObject->setUniform("projectionTransform", data.camera.projectionMatrix());
if (_tileProviderManager->getTileProviderGroup(
LayeredTextures::NightTextures).getActiveTileProviders().size() > 0 ||
_tileProviderManager->getTileProviderGroup(
LayeredTextures::WaterMasks).getActiveTileProviders().size() > 0) {
glm::vec3 directionToSunWorldSpace =
glm::normalize(-data.modelTransform.translation);
glm::vec3 directionToSunCameraSpace =
(viewTransform * glm::dvec4(directionToSunWorldSpace, 0));
data.modelTransform.translation;
programObject->setUniform("lightDirectionCameraSpace", -directionToSunCameraSpace);
}
// OpenGL rendering settings
glEnable(GL_DEPTH_TEST);
glEnable(GL_CULL_FACE);
glCullFace(GL_BACK);
// render
_grid->geometry().drawUsingActiveProgram();
// disable shader
programObject->deactivate();
}
示例2: renderChunkGlobally
void ChunkRenderer::renderChunkGlobally(const Chunk& chunk, const RenderData& data){
ProgramObject* programObject = getActivatedProgramWithTileData(
_globalRenderingShaderProvider.get(),
_globalProgramUniformHandler,
chunk);
if (programObject == nullptr) {
return;
}
const Ellipsoid& ellipsoid = chunk.owner()->ellipsoid();
bool performAnyBlending = false;
for (int i = 0; i < LayeredTextures::NUM_TEXTURE_CATEGORIES; ++i) {
LayeredTextures::TextureCategory category = (LayeredTextures::TextureCategory)i;
if(_tileProviderManager->getTileProviderGroup(i).levelBlendingEnabled && _tileProviderManager->getTileProviderGroup(category).getActiveTileProviders().size() > 0){
performAnyBlending = true;
break;
}
}
if (performAnyBlending) {
// Calculations are done in the reference frame of the globe. Hence, the camera
// position needs to be transformed with the inverse model matrix
glm::dmat4 inverseModelTransform = chunk.owner()->inverseModelTransform();
glm::dvec3 cameraPosition =
glm::dvec3(inverseModelTransform * glm::dvec4(data.camera.positionVec3(), 1));
float distanceScaleFactor = chunk.owner()->lodScaleFactor * ellipsoid.minimumRadius();
programObject->setUniform("cameraPosition", vec3(cameraPosition));
programObject->setUniform("distanceScaleFactor", distanceScaleFactor);
programObject->setUniform("chunkLevel", chunk.index().level);
}
// Calculate other uniform variables needed for rendering
Geodetic2 swCorner = chunk.surfacePatch().getCorner(Quad::SOUTH_WEST);
auto patchSize = chunk.surfacePatch().size();
dmat4 modelTransform = chunk.owner()->modelTransform();
dmat4 viewTransform = data.camera.combinedViewMatrix();
mat4 modelViewTransform = mat4(viewTransform * modelTransform);
mat4 modelViewProjectionTransform = data.camera.projectionMatrix() * modelViewTransform;
// Upload the uniform variables
programObject->setUniform("modelViewProjectionTransform", modelViewProjectionTransform);
programObject->setUniform("minLatLon", vec2(swCorner.toLonLatVec2()));
programObject->setUniform("lonLatScalingFactor", vec2(patchSize.toLonLatVec2()));
programObject->setUniform("radiiSquared", vec3(ellipsoid.radiiSquared()));
if (_tileProviderManager->getTileProviderGroup(
LayeredTextures::NightTextures).getActiveTileProviders().size() > 0 ||
_tileProviderManager->getTileProviderGroup(
LayeredTextures::WaterMasks).getActiveTileProviders().size() > 0) {
glm::vec3 directionToSunWorldSpace =
glm::normalize(-data.modelTransform.translation);
glm::vec3 directionToSunCameraSpace =
(viewTransform * glm::dvec4(directionToSunWorldSpace, 0));
data.modelTransform.translation;
programObject->setUniform("modelViewTransform", modelViewTransform);
programObject->setUniform("lightDirectionCameraSpace", -directionToSunCameraSpace);
}
// OpenGL rendering settings
glEnable(GL_DEPTH_TEST);
glEnable(GL_CULL_FACE);
glCullFace(GL_BACK);
// render
_grid->geometry().drawUsingActiveProgram();
// disable shader
programObject->deactivate();
}