本文整理汇总了C++中TextureUnit::getEnum方法的典型用法代码示例。如果您正苦于以下问题:C++ TextureUnit::getEnum方法的具体用法?C++ TextureUnit::getEnum怎么用?C++ TextureUnit::getEnum使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类TextureUnit
的用法示例。
在下文中一共展示了TextureUnit::getEnum方法的11个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: bindTexture
void bindTexture(const Volume& volume, const TextureUnit& texUnit) {
if (auto volumeGL = volume.getRepresentation<VolumeGL>()) {
volumeGL->bindTexture(texUnit.getEnum());
} else {
LogErrorCustom("TextureUtils", "Could not get a GL representation from volume");
}
}
示例2: preProcess
void ImageMapping::preProcess() {
TextureUnit transFuncUnit;
const Layer* tfLayer = transferFunction_.get().getData();
const LayerGL* transferFunctionGL = tfLayer->getRepresentation<LayerGL>();
transferFunctionGL->bindTexture(transFuncUnit.getEnum());
shader_.setUniform("transferFunc_", transFuncUnit.getUnitNumber());
}
示例3: process
void DepthPeelingProcessor::process() {
outport_.activateTarget();
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
// set modelview and projection matrices
glMatrixMode(GL_PROJECTION);
tgt::loadMatrix(camera_.get().getProjectionMatrix());
glMatrixMode(GL_MODELVIEW);
tgt::loadMatrix(camera_.get().getViewMatrix());
LGL_ERROR;
TextureUnit depthTexUnit;
inport_.bindDepthTexture(depthTexUnit.getEnum());
LGL_ERROR;
// initialize shader
shaderPrg_->activate();
// set common uniforms used by all shaders
tgt::Camera cam = camera_.get();
setGlobalShaderParameters(shaderPrg_, &cam);
// pass the remaining uniforms to the shader
shaderPrg_->setUniform("depthTex_", depthTexUnit.getUnitNumber());
inport_.setTextureParameters(shaderPrg_, "depthTexParameters_");
std::vector<GeometryRendererBase*> portData = cpPort_.getConnectedProcessors();
for (size_t i=0; i<portData.size(); i++) {
GeometryRendererBase* pdcp = portData.at(i);
if(pdcp->isReady()) {
pdcp->setCamera(camera_.get());
pdcp->setViewport(outport_.getSize());
pdcp->render();
LGL_ERROR;
}
}
shaderPrg_->deactivate();
outport_.deactivateTarget();
// restore matrices
glMatrixMode(GL_PROJECTION);
glLoadIdentity();
glMatrixMode(GL_MODELVIEW);
glLoadIdentity();
LGL_ERROR;
}
示例4: renderLayer
void CanvasGL::renderLayer(size_t idx) {
previousRenderedLayerIdx_ = idx;
if (imageGL_) {
const LayerGL* layerGL = imageGL_->getLayerGL(layerType_,idx);
if (layerGL) {
TextureUnit textureUnit;
layerGL->bindTexture(textureUnit.getEnum());
renderTexture(textureUnit.getUnitNumber());
layerGL->unbindTexture();
return;
} else {
renderNoise();
}
}
if (!image_) renderNoise();
}
示例5: bindTextures
void bindTextures(const ImageOutport& outport, const TextureUnit& colorTexUnit,
const TextureUnit& depthTexUnit, const TextureUnit& pickingTexUnit) {
bindTextures(*outport.getData(), true, true, true, colorTexUnit.getEnum(),
depthTexUnit.getEnum(), pickingTexUnit.getEnum());
}
示例6: process
void OcclusionSlicer::process() {
// compile program if needed
if (getInvalidationLevel() >= Processor::INVALID_PROGRAM)
compile();
LGL_ERROR;
occlusionbuffer0_.activateTarget();
glClearColor(1.0f, 1.0f, 1.0f, 1.0f);
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
occlusionbuffer1_.activateTarget();
glClearColor(1.0f, 1.0f, 1.0f, 1.0f);
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
outport_.activateTarget();
glClearColor(0.0f, 0.0f, 0.0f, 0.0f);
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
LGL_ERROR;
// bind transfer function
TextureUnit transferUnit;
transferUnit.activate();
if (transferFunc_.get())
transferFunc_.get()->bind();
transferFunc_.setVolumeHandle(volumeInport_.getData());
// vector containing the volumes to bind; is passed to bindVolumes()
std::vector<VolumeStruct> volumeTextures;
// add main volume
TextureUnit volUnit;
volumeTextures.push_back(VolumeStruct(
volumeInport_.getData(),
&volUnit,
"volume_","volumeStruct_")
);
// initialize slicing shader
tgt::Shader* slicingPrg = shaderProp_.getShader();
slicingPrg->activate();
// fragment shader uniforms
TextureUnit occlusionUnit;
transferFunc_.get()->setUniform(slicingPrg, "transferFunc_", "transferFuncTex_", transferUnit.getUnitNumber());
slicingPrg->setUniform("occlusion_", occlusionUnit.getUnitNumber());
occlusionbuffer1_.setTextureParameters(slicingPrg, "occlusionParams_");
//clipping uniforms
setupUniforms(slicingPrg);
// set common uniforms used by all shaders
tgt::Camera cam = camera_.get();
setGlobalShaderParameters(slicingPrg, &cam);
slicingPrg->setUniform("sigma_", sigma_.get());
slicingPrg->setUniform("radius_", radius_.get());
slicingPrg->setUniform("lightPos_", lightPosition_.get().xyz());
// bind the volumes and pass the necessary information to the shader
bindVolumes(slicingPrg, volumeTextures, &cam, lightPosition_.get());
glDisable(GL_DEPTH_TEST);
glMatrixMode(GL_PROJECTION);
glPushMatrix();
tgt::loadMatrix(camera_.get().getProjectionMatrix(outport_.getSize()));
glMatrixMode(GL_MODELVIEW);
glPushMatrix();
tgt::loadMatrix(camera_.get().getViewMatrix());
unsigned int numSlices = static_cast<unsigned int>(maxLength_ / sliceDistance_);
slicingPrg->activate();
for (unsigned int curSlice=0; curSlice<numSlices; curSlice++) {
// first pass
slicingPrg->setUniform("secondPass_", false);
outport_.activateTarget();
glEnable(GL_BLEND);
glBlendFunc(GL_ONE_MINUS_DST_ALPHA, GL_ONE);
occlusionbuffer0_.bindColorTexture(occlusionUnit.getEnum());
glBegin(GL_POLYGON);
for (unsigned int curPoint=0; curPoint<6; curPoint++)
glVertex2i(curPoint, curSlice);
glEnd();
glDisable(GL_BLEND);
outport_.deactivateTarget();
// second pass
slicingPrg->setUniform("secondPass_", true);
occlusionbuffer1_.activateTarget();
slicingPrg->setUniform("blurDirection_", tgt::vec2(1.f, 0.f));
glBegin(GL_POLYGON);
for (unsigned int curPoint=0; curPoint<6; curPoint++)
//.........这里部分代码省略.........
示例7: process
void LightVolumeGL::process() {
bool lightColorChanged = false;
if (lightSource_.isChanged()) {
lightColorChanged = lightSourceChanged();
}
bool reattach = false;
if (internalVolumesInvalid_ || lightColorChanged || inport_.isChanged()) {
reattach = volumeChanged(lightColorChanged);
}
VolumeGL* outVolumeGL = volume_->getEditableRepresentation<VolumeGL>();
TextureUnit volUnit;
const VolumeGL* inVolumeGL = inport_.getData()->getRepresentation<VolumeGL>();
inVolumeGL->bindTexture(volUnit.getEnum());
TextureUnit transFuncUnit;
const Layer* tfLayer = transferFunction_.get().getData();
const LayerGL* transferFunctionGL = tfLayer->getRepresentation<LayerGL>();
transferFunctionGL->bindTexture(transFuncUnit.getEnum());
TextureUnit lightVolUnit[2];
propParams_[0].vol->bindTexture(lightVolUnit[0].getEnum());
propParams_[1].vol->bindTexture(lightVolUnit[1].getEnum());
propagationShader_.activate();
propagationShader_.setUniform("volume_", volUnit.getUnitNumber());
utilgl::setShaderUniforms(propagationShader_, *inport_.getData(), "volumeParameters_");
propagationShader_.setUniform("transferFunc_", transFuncUnit.getUnitNumber());
propagationShader_.setUniform("lightVolumeParameters_.dimensions", volumeDimOutF_);
propagationShader_.setUniform("lightVolumeParameters_.reciprocalDimensions", volumeDimOutFRCP_);
BufferObjectArray* rectArray = utilgl::enableImagePlaneRect();
//Perform propagation passes
for (int i=0; i<2; ++i) {
propParams_[i].fbo->activate();
glViewport(0, 0, static_cast<GLsizei>(volumeDimOut_.x), static_cast<GLsizei>(volumeDimOut_.y));
if (reattach)
propParams_[i].fbo->attachColorTexture(propParams_[i].vol->getTexture().get(), 0);
propagationShader_.setUniform("lightVolume_", lightVolUnit[i].getUnitNumber());
propagationShader_.setUniform("permutationMatrix_", propParams_[i].axisPermutation);
if (lightSource_.getData()->getLightSourceType() == LightSourceType::LIGHT_POINT) {
propagationShader_.setUniform("lightPos_", lightPos_);
propagationShader_.setUniform("permutedLightMatrix_", propParams_[i].axisPermutationLight);
}
else {
propagationShader_.setUniform("permutedLightDirection_", propParams_[i].permutedLightDirection);
}
for (unsigned int z=0; z<volumeDimOut_.z; ++z) {
glFramebufferTexture3DEXT(GL_FRAMEBUFFER_EXT, GL_COLOR_ATTACHMENT0_EXT, GL_TEXTURE_3D, propParams_[i].vol->getTexture()->getID(), 0, z);
propagationShader_.setUniform("sliceNum_", static_cast<GLint>(z));
glDrawArrays(GL_TRIANGLE_STRIP, 0, 4);
glFlush();
}
propParams_[i].fbo->deactivate();
}
utilgl::disableImagePlaneRect(rectArray);
propagationShader_.deactivate();
mergeShader_.activate();
mergeShader_.setUniform("lightVolume_", lightVolUnit[0].getUnitNumber());
mergeShader_.setUniform("lightVolumeSec_", lightVolUnit[1].getUnitNumber());
mergeShader_.setUniform("lightVolumeParameters_.dimensions", volumeDimOutF_);
mergeShader_.setUniform("lightVolumeParameters_.reciprocalDimensions", volumeDimOutFRCP_);
mergeShader_.setUniform("permMatInv_", propParams_[0].axisPermutationINV);
mergeShader_.setUniform("permMatInvSec_", propParams_[1].axisPermutationINV);
mergeShader_.setUniform("blendingFactor_", blendingFactor_);
//Perform merge pass
mergeFBO_->activate();
glViewport(0, 0, static_cast<GLsizei>(volumeDimOut_.x), static_cast<GLsizei>(volumeDimOut_.y));
if (reattach)
mergeFBO_->attachColorTexture(outVolumeGL->getTexture().get(), 0);
utilgl::multiDrawImagePlaneRect(static_cast<int>(volumeDimOut_.z));
mergeShader_.deactivate();
mergeFBO_->deactivate();
}
示例8: copyRepresentationsTo
bool ImageGL::copyRepresentationsTo(ImageGL* target) const {
const ImageGL* source = this;
auto singleChannel = source->getColorLayerGL()->getDataFormat()->getComponents() == 1;
// Set shader to copy all color layers
if (!shader_.isReady() || singleChanelCopy_ != singleChannel ||
colorLayerCopyCount_ != colorLayersGL_.size()) {
std::stringstream ssUniform;
for (size_t i = 1; i < colorLayersGL_.size(); ++i) {
ssUniform << "layout(location = " << i + 1 << ") out vec4 FragData" << i << ";";
}
for (size_t i = 1; i < colorLayersGL_.size(); ++i) {
ssUniform << "uniform sampler2D color" << i << ";";
}
shader_.getFragmentShaderObject()->addShaderDefine("ADDITIONAL_COLOR_LAYER_OUT_UNIFORMS",
ssUniform.str());
std::stringstream ssWrite;
for (size_t i = 1; i < colorLayersGL_.size(); ++i) {
if (singleChannel) {
ssWrite << "FragData" << i << " = vec4(texture(color" << i << ", texCoord_.xy).r);";
} else {
ssWrite << "FragData" << i << " = texture(color" << i << ", texCoord_.xy);";
}
}
shader_.getFragmentShaderObject()->addShaderDefine("ADDITIONAL_COLOR_LAYER_WRITE",
ssWrite.str());
if (colorLayersGL_.size() > 1) {
shader_.getFragmentShaderObject()->addShaderDefine("ADDITIONAL_COLOR_LAYERS");
} else {
shader_.getFragmentShaderObject()->removeShaderDefine("ADDITIONAL_COLOR_LAYERS");
}
if (singleChannel) {
shader_.getFragmentShaderObject()->addShaderDefine("SINGLE_CHANNEL");
} else {
shader_.getFragmentShaderObject()->removeShaderDefine("SINGLE_CHANNEL");
}
colorLayerCopyCount_ = colorLayersGL_.size();
singleChanelCopy_ = singleChannel;
shader_.build();
}
TextureUnit colorUnit, depthUnit, pickingUnit;
source->getColorLayerGL()->bindTexture(colorUnit.getEnum());
if (source->getDepthLayerGL()) {
source->getDepthLayerGL()->bindTexture(depthUnit.getEnum());
}
if (source->getPickingLayerGL()) {
source->getPickingLayerGL()->bindTexture(pickingUnit.getEnum());
}
TextureUnitContainer additionalColorUnits;
for (size_t i = 0; i < colorLayersGL_.size(); ++i) {
TextureUnit unit;
source->getColorLayerGL(i)->bindTexture(unit.getEnum());
additionalColorUnits.push_back(std::move(unit));
}
// Render to FBO, with correct scaling
target->activateBuffer(ImageType::AllLayers);
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
float ratioSource = (float)source->getDimensions().x / (float)source->getDimensions().y;
float ratioTarget = (float)target->getDimensions().x / (float)target->getDimensions().y;
glm::mat4 scale;
if (ratioTarget < ratioSource)
scale = glm::scale(glm::vec3(1.0f, ratioTarget / ratioSource, 1.0f));
else
scale = glm::scale(glm::vec3(ratioSource / ratioTarget, 1.0f, 1.0f));
GLint prog;
glGetIntegerv(GL_CURRENT_PROGRAM, &prog);
shader_.activate();
shader_.setUniform("color_", colorUnit.getUnitNumber());
if (source->getDepthLayerGL()) {
shader_.setUniform("depth_", depthUnit.getUnitNumber());
}
if (source->getPickingLayerGL()) {
shader_.setUniform("picking_", pickingUnit.getUnitNumber());
}
for (size_t i = 0; i < additionalColorUnits.size(); ++i) {
shader_.setUniform("color" + toString<size_t>(i + 1),
additionalColorUnits[i].getUnitNumber());
}
shader_.setUniform("dataToClip", scale);
LGL_ERROR;
target->renderImagePlaneRect();
LGL_ERROR;
shader_.deactivate();
target->deactivateBuffer();
LGL_ERROR;
glUseProgram(prog);
//.........这里部分代码省略.........
示例9: bindDepthTexture
void bindDepthTexture(const Image& image, const TextureUnit& texUnit) {
bindTextures(image, false, true, false, 0, texUnit.getEnum(), 0);
}
示例10: bindColorTexture
void bindColorTexture(const ImageOutport& outport, const TextureUnit& texUnit) {
bindTextures(*outport.getData(), true, false, false, texUnit.getEnum(), 0, 0);
}
示例11: bindPickingTexture
void bindPickingTexture(const ImageOutport& outport, const TextureUnit& texUnit) {
bindTextures(*outport.getData(), false, false, true, 0, 0, texUnit.getEnum());
}