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


C++ TextureUnit::getUnitNumber方法代码示例

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


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

示例1: bindAndSetUniforms

void bindAndSetUniforms(Shader& shader, TextureUnitContainer& cont,
    const TransferFunctionProperty& tf) {
    TextureUnit unit;
    bindTexture(tf, unit);
    shader.setUniform(tf.getIdentifier(), unit.getUnitNumber());
    cont.push_back(std::move(unit));
}
开发者ID:sarbi127,项目名称:inviwo,代码行数:7,代码来源:textureutils.cpp

示例2: process

void SimpleRaycaster::process() {
    // activate and clear output render target
    outport_.activateTarget();
    outport_.clearTarget();

    // retrieve shader from shader property
    tgt::Shader* shader = shader_.getShader();
    if (!shader || !shader->isLinked()) {
        outport_.deactivateTarget();
        return;
    }

    // activate shader and set common uniforms
    shader->activate();
    tgt::Camera cam = camera_.get();
    setGlobalShaderParameters(shader, &cam);

    // bind entry and exit params and pass texture units to the shader
    TextureUnit entryUnit, entryDepthUnit, exitUnit, exitDepthUnit;
    entryPort_.bindTextures(entryUnit, entryDepthUnit);
    shader->setUniform("entryPoints_", entryUnit.getUnitNumber());
    shader->setUniform("entryPointsDepth_", entryDepthUnit.getUnitNumber());
    entryPort_.setTextureParameters(shader, "entryParameters_");

    exitPort_.bindTextures(exitUnit, exitDepthUnit);
    shader->setUniform("exitPoints_", exitUnit.getUnitNumber());
    shader->setUniform("exitPointsDepth_", exitDepthUnit.getUnitNumber());
    exitPort_.setTextureParameters(shader, "exitParameters_");

    // bind volume texture and pass it to the shader
    std::vector<VolumeStruct> volumeTextures;
    TextureUnit volUnit;
     volumeTextures.push_back(VolumeStruct(
        volumePort_.getData(),
        &volUnit,
        "volume_",
        "volumeStruct_",
        volumePort_.getTextureClampModeProperty().getValue(),
        tgt::vec4(volumePort_.getTextureBorderIntensityProperty().get()),
        volumePort_.getTextureFilterModeProperty().getValue())
    );
    bindVolumes(shader, volumeTextures, &cam, lightPosition_.get());

    // bind transfer function and pass it to the shader
    TextureUnit transferUnit;
    if (transferFunc_.get()) {
        transferUnit.activate();
        transferFunc_.get()->bind();
        transferFunc_.get()->setUniform(shader, "transferFunc_", "transferFuncTex_", transferUnit.getUnitNumber());
    }

    // render screen aligned quad
    renderQuad();

    // clean up
    shader->deactivate();
    outport_.deactivateTarget();
    TextureUnit::setZeroUnit();
    LGL_ERROR;
}
开发者ID:molsimmsu,项目名称:3mview,代码行数:60,代码来源:simpleraycaster.cpp

示例3: bindAndSetUniforms

void bindAndSetUniforms(Shader& shader, TextureUnitContainer& cont, VolumeInport& volumePort) {
    TextureUnit unit;
    utilgl::bindTexture(volumePort, unit);
    shader.setUniform(volumePort.getIdentifier(), unit.getUnitNumber());
    utilgl::setShaderUniforms(shader, volumePort, volumePort.getIdentifier() + "Parameters");
    cont.push_back(std::move(unit));
}
开发者ID:sunwj,项目名称:inviwo,代码行数:7,代码来源:volumeutils.cpp

示例4: process

void ImageGLProcessor::process() {
    if (internalInvalid_) {
        internalInvalid_ = false;
        const DataFormatBase* format = inport_.getData()->getDataFormat();
        size2_t dimensions;
        if (outport_.isHandlingResizeEvents() || !inport_.isOutportDeterminingSize())
            dimensions  = outport_.getData()->getDimensions();
        else
            dimensions = inport_.getData()->getDimensions();
        if (!outport_.hasData() || format != outport_.getData()->getDataFormat()
            || dimensions != outport_.getData()->getDimensions()){
            Image *img = new Image(dimensions, format);
            img->copyMetaDataFrom(*inport_.getData());
            outport_.setData(img);
        }
    }

    TextureUnit imgUnit;    
    utilgl::bindColorTexture(inport_, imgUnit);

    utilgl::activateTargetAndCopySource(outport_, inport_, ImageType::ColorOnly);
    shader_.activate();

    utilgl::setShaderUniforms(shader_, outport_, "outportParameters_");
    shader_.setUniform("inport_", imgUnit.getUnitNumber());

    preProcess();

    utilgl::singleDrawImagePlaneRect();
    shader_.deactivate();
    utilgl::deactivateCurrentTarget();

    postProcess();
}
开发者ID:sunwj,项目名称:inviwo,代码行数:34,代码来源:imageglprocessor.cpp

示例5: 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());
}
开发者ID:Ojaswi,项目名称:inviwo,代码行数:8,代码来源:imagemapping.cpp

示例6: renderParallelCoordinates

void PCPUploadRenderer::renderParallelCoordinates() {
    std::shared_ptr<const ParallelCoordinatesPlotRawData> data = _inport.getData();
    int nDimensions = data->minMax.size();
    int nValues = data->data.size();

    utilgl::GlBoolState depthTest(GL_DEPTH_TEST, !_depthTesting);
    utilgl::BlendModeEquationState blendEquation(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA, GL_FUNC_ADD);

    utilgl::GlBoolState lineSmooth(GL_LINE_SMOOTH, _lineSmoothing);
    if (_lineSmoothing)
        glHint(GL_LINE_SMOOTH_HINT, GL_NICEST);

    _shader.activate();

    _shader.setUniform("_nDimensions", nDimensions);
    _shader.setUniform("_nData", nValues / nDimensions);
    _shader.setUniform("_horizontalBorder", _horizontalBorder);
    _shader.setUniform("_verticalBorder", _verticalBorder);
    _shader.setUniform("_depthTesting", !_depthTesting);
    _shader.setUniform("_alphaFactor", _alphaFactor);

    TextureUnit tfUnit;
    utilgl::bindTexture(_transFunc, tfUnit);
    _shader.setUniform("_transFunc", tfUnit.getUnitNumber());

    glBindVertexArray(_vao);

    bool hasColoringData = _coloringData.hasData() && _coloringData.getData()->hasData;
    _shader.setUniform("_hasColoringData", hasColoringData);
    if (hasColoringData) {
        glBindBufferBase(GL_SHADER_STORAGE_BUFFER, 2, _coloringData.getData()->ssboColor);
    }

    //glBindBufferBase(GL_SHADER_STORAGE_BUFFER, 0, data->ssboData);
    glBindBufferBase(GL_SHADER_STORAGE_BUFFER, 3, _dimensionOrderingBuffer);

    //for (int i = 0; i < nValues / nDimensions; ++i) {
    //    glDrawElements(GL_LINE_STRIP, nDimensions, )
    //}

    glEnable(GL_PRIMITIVE_RESTART);
    glPrimitiveRestartIndex(PRIM_RESTART);

    glDrawElements(GL_LINE_STRIP, nValues / nDimensions, GL_UNSIGNED_INT, _drawElements);


    glDisable(GL_PRIMITIVE_RESTART);
    //glDrawArrays(GL_LINE_STRIP, 0, nValues);

    //glMultiDrawArrays(GL_LINE_STRIP, _multiDrawIndices, _multiDrawCount, nValues / nDimensions);

    //glDrawArraysInstanced(GL_LINE_STRIP, 0, data->nDimensions, data->nValues / data->nDimensions);

    glBindVertexArray(0);

    _shader.deactivate();
}
开发者ID:alexanderbock,项目名称:Inviwo-ParallelCoordinatesClustering,代码行数:57,代码来源:pcpuploadrenderer.cpp

示例7: process

void SimpleRaycaster::process() {
    // activate and clear output render target
    outport_.activateTarget();
    outport_.clearTarget();

    // activate shader and set common uniforms
    raycastPrg_->activate();
    tgt::Camera cam = camera_.get();
    setGlobalShaderParameters(raycastPrg_, &cam);

    // bind entry and exit params and pass texture units to the shader
    TextureUnit entryUnit, entryDepthUnit, exitUnit, exitDepthUnit;
    entryPort_.bindTextures(entryUnit, entryDepthUnit);
    raycastPrg_->setUniform("entryPoints_", entryUnit.getUnitNumber());
    raycastPrg_->setUniform("entryPointsDepth_", entryDepthUnit.getUnitNumber());
    entryPort_.setTextureParameters(raycastPrg_, "entryParameters_");

    exitPort_.bindTextures(exitUnit, exitDepthUnit);
    raycastPrg_->setUniform("exitPoints_", exitUnit.getUnitNumber());
    raycastPrg_->setUniform("exitPointsDepth_", exitDepthUnit.getUnitNumber());
    exitPort_.setTextureParameters(raycastPrg_, "exitParameters_");

    // bind volume texture and pass it to the shader
    std::vector<VolumeStruct> volumeTextures;
    TextureUnit volUnit;
     volumeTextures.push_back(VolumeStruct(
        volumePort_.getData()->getVolumeGL(),
        &volUnit,
        "volume_",
        "volumeParameters_",
        true)
    );
    bindVolumes(raycastPrg_, volumeTextures, &cam, lightPosition_.get());

    // bind transfer function and pass it to the shader
    TextureUnit transferUnit;
    if (transferFunc_.get()) {
        transferUnit.activate();
        transferFunc_.get()->bind();
        raycastPrg_->setUniform("transferFunc_", transferUnit.getUnitNumber());
    }

    // render screen aligned quad
    renderQuad();

    // clean up
    raycastPrg_->deactivate();
    outport_.deactivateTarget();
    TextureUnit::setZeroUnit();
    LGL_ERROR;
}
开发者ID:alvatar,项目名称:smartmatter,代码行数:51,代码来源:simpleraycaster.cpp

示例8: jitterEntryPoints

void EntryExitPoints::jitterEntryPoints() {
    // if canvas resolution has changed, regenerate jitter texture
    if (!jitterTexture_ ||
        (jitterTexture_->getDimensions().x != entryPort_.getSize().x) ||
        (jitterTexture_->getDimensions().y != entryPort_.getSize().y))
    {
        generateJitterTexture();
    }

    shaderProgramJitter_->activate();
    tgt::Camera cam = camera_.get();
    setGlobalShaderParameters(shaderProgramJitter_, &cam);

    // bind jitter texture
    TextureUnit jitterUnit;
    jitterUnit.activate();
    jitterTexture_->bind();
    jitterTexture_->uploadTexture();
    shaderProgramJitter_->setUniform("jitterTexture_", jitterUnit.getUnitNumber());
    shaderProgramJitter_->setIgnoreUniformLocationError(true);
    shaderProgramJitter_->setUniform("jitterParameters_.dimensions_",
                                     tgt::vec2(jitterTexture_->getDimensions().xy()));
    shaderProgramJitter_->setUniform("jitterParameters_.dimensionsRCP_",
                                     tgt::vec2(1.0f) / tgt::vec2(jitterTexture_->getDimensions().xy()));
    shaderProgramJitter_->setUniform("jitterParameters_.matrix_", tgt::mat4::identity);
    shaderProgramJitter_->setIgnoreUniformLocationError(false);

    // bind entry points texture and depth texture (have been rendered to temporary port)
    TextureUnit entryParams, exitParams, entryParamsDepth;
    tmpPort_.bindColorTexture(entryParams.getEnum());
    shaderProgramJitter_->setUniform("entryPoints_", entryParams.getUnitNumber());

    tmpPort_.bindDepthTexture(entryParamsDepth.getEnum());
    shaderProgramJitter_->setUniform("entryPointsDepth_", entryParamsDepth.getUnitNumber());
    tmpPort_.setTextureParameters(shaderProgramJitter_, "entryParameters_");

    // bind exit points texture
    exitPort_.bindColorTexture(exitParams.getEnum());
    shaderProgramJitter_->setUniform("exitPoints_", exitParams.getUnitNumber());
    exitPort_.setTextureParameters(shaderProgramJitter_, "exitParameters_");

    shaderProgramJitter_->setUniform("stepLength_", jitterStepLength_.get());

    entryPort_.activateTarget("jitteredEntryParams");
    glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);

    // render screen aligned quad
    renderQuad();

    shaderProgramJitter_->deactivate();
}
开发者ID:alvatar,项目名称:smartmatter,代码行数:51,代码来源:entryexitpoints.cpp

示例9: 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;
}
开发者ID:alvatar,项目名称:smartmatter,代码行数:48,代码来源:depthpeelingprocessor.cpp

示例10: 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();
}
开发者ID:sarbi127,项目名称:inviwo,代码行数:16,代码来源:canvasgl.cpp

示例11: process

void ColorDepth::process() {
    if (!enableSwitch_.get()) {
        bypass(&inport_, &outport_);
        return;
    }

    if (!chromaDepthTex_) {
        LERROR("No chroma depth texture");
        return;
    }

    //compute Depth Range
    tgt::vec2 depthRange = computeDepthRange(&inport_);

    outport_.activateTarget();
    glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);

    TextureUnit colorUnit, depthUnit;
    inport_.bindTextures(colorUnit.getEnum(), depthUnit.getEnum());

    // bind chroma depth texture
    TextureUnit chromaDepthUnit;
    chromaDepthUnit.activate();
    //chromaDepthTex_ is 0 here
    chromaDepthTex_->bind();
    LGL_ERROR;

    // initialize shader
    program_->activate();
    setGlobalShaderParameters(program_);
    program_->setUniform("colorTex_", colorUnit.getUnitNumber());
    program_->setUniform("depthTex_", depthUnit.getUnitNumber());
    inport_.setTextureParameters(program_, "texParams_");
    program_->setUniform("chromadepthTex_", chromaDepthUnit.getUnitNumber());
    program_->setUniform("minDepth_", depthRange.x);
    program_->setUniform("maxDepth_", depthRange.y);
    program_->setUniform("colorMode_", colorMode_.getValue());
    program_->setUniform("colorDepthFactor_", factor_.get());

    renderQuad();

    program_->deactivate();
    TextureUnit::setZeroUnit();
    outport_.deactivateTarget();
    LGL_ERROR;
}
开发者ID:emmaai,项目名称:fractalM,代码行数:46,代码来源:colordepth.cpp

示例12: renderParallelCoordinates

void PCPRenderer::renderParallelCoordinates() {
    std::shared_ptr<const ParallelCoordinatesPlotData> data = _inport.getData();
    utilgl::GlBoolState depthTest(GL_DEPTH_TEST, !_depthTesting);

    //utilgl::GlBoolState alpha(GL_ALPHA, _alphaFactor != 1.f);
    utilgl::BlendModeEquationState blendEquation(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA, GL_FUNC_ADD);

    utilgl::GlBoolState lineSmooth(GL_LINE_SMOOTH, _lineSmoothing);
    if (_lineSmoothing)
        glHint(GL_LINE_SMOOTH_HINT, GL_NICEST);

    _shader.activate();

    _shader.setUniform("_nDimensions", data->nDimensions);
    _shader.setUniform("_nData", data->nValues / data->nDimensions);
    _shader.setUniform("_horizontalBorder", _horizontalBorder);
    _shader.setUniform("_verticalBorder", _verticalBorder);
    _shader.setUniform("_depthTesting", _depthTesting);
    _shader.setUniform("_alphaFactor", _alphaFactor);

    TextureUnit tfUnit;
    utilgl::bindTexture(_transFunc, tfUnit);
    _shader.setUniform("_transFunc", tfUnit.getUnitNumber());

    glBindVertexArray(_vao);

    bool hasColoringData = _coloringData.hasData() && _coloringData.getData()->hasData;
    _shader.setUniform("_hasColoringData", hasColoringData);
    if (hasColoringData) {
        glBindBufferBase(GL_SHADER_STORAGE_BUFFER, 1, _coloringData.getData()->ssboColor);
    }

    glBindBufferBase(GL_SHADER_STORAGE_BUFFER, 0, data->ssboData);
    glBindBufferBase(GL_SHADER_STORAGE_BUFFER, 2, _dimensionOrderingBuffer);

    glDrawArraysInstanced(GL_LINE_STRIP, 0, data->nDimensions, data->nValues / data->nDimensions);

    glBindVertexArray(0);

    _shader.deactivate();
}
开发者ID:alexanderbock,项目名称:Inviwo-ParallelCoordinatesClustering,代码行数:41,代码来源:pcprenderer.cpp

示例13: process

void RGBRaycaster::process() {

    if (!volumePort_.isReady())
        return;

    if (!outport_.isReady())
        return;

    outport_.activateTarget();

    glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);

    // compile program
    if (getInvalidationLevel() >= Processor::INVALID_PROGRAM)
        compile();
    LGL_ERROR;

    TextureUnit entryUnit, entryDepthUnit, exitUnit, exitDepthUnit;
    // bind entry params
    entryPort_.bindTextures(entryUnit.getEnum(), entryDepthUnit.getEnum());

    // bind exit params
    exitPort_.bindTextures(exitUnit.getEnum(), exitDepthUnit.getEnum());

    // vector containing the volumes to bind; is passed to bindVolumes()
    std::vector<VolumeStruct> volumeTextures;

    // add main volume
    TextureUnit volUnit;
    volumeTextures.push_back(VolumeStruct(
        volumePort_.getData(),
        &volUnit,
        "volumeStruct_")
    );

    // bind transfer function
    TextureUnit transferUnit;
    transferUnit.activate();
    if (transferFunc_.get())
        transferFunc_.get()->bind();

    // initialize shader
    raycastPrg_->activate();

    // set common uniforms used by all shaders
    tgt::Camera cam = camera_.get();
    setGlobalShaderParameters(raycastPrg_, &cam);
    // bind the volumes and pass the necessary information to the shader
    bindVolumes(raycastPrg_, volumeTextures, &cam, lightPosition_.get());

    // pass the remaining uniforms to the shader
    raycastPrg_->setUniform("entryPoints_", entryUnit.getUnitNumber());
    raycastPrg_->setUniform("entryPointsDepth_", entryDepthUnit.getUnitNumber());
    entryPort_.setTextureParameters(raycastPrg_, "entryParameters_");
    raycastPrg_->setUniform("exitPoints_", exitUnit.getUnitNumber());
    raycastPrg_->setUniform("exitPointsDepth_", exitDepthUnit.getUnitNumber());
    exitPort_.setTextureParameters(raycastPrg_, "exitParameters_");
    transferFunc_.get()->setUniform(raycastPrg_, "transferFunc_", transferUnit.getUnitNumber());
    raycastPrg_->setUniform("applyColorModulation_", applyColorModulation_.get());

    renderQuad();

    raycastPrg_->deactivate();
    TextureUnit::setZeroUnit();

    outport_.deactivateTarget();
    LGL_ERROR;
}
开发者ID:bsmr-opengl,项目名称:voreen,代码行数:68,代码来源:rgbraycaster.cpp

示例14: process

void HalfAngleSlicer::process() {

    // compile program if needed
    if (getInvalidationLevel() >= Processor::INVALID_PROGRAM)
        compile();
    LGL_ERROR;

    lightport_.activateTarget();
    glClearColor(1.0, 1.0, 1.0, 1.0);
    glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
    lightport_.deactivateTarget();
    outport_.activateTarget();
    glClearColor(0.0, 0.0, 0.0, 0.0);
    glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
    outport_.deactivateTarget();

    // 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
    transferFunc_.get()->setUniform(slicingPrg, "transferFunc_", "transferFuncTex_", transferUnit.getUnitNumber());

    // set common uniforms used by all shaders
    tgt::Camera cam = eyeCamera_.get();
    // bind the volumes and pass the necessary information to the shader
    bindVolumes(slicingPrg, volumeTextures, &cam, lightPosition_.get());

    setupUniforms(slicingPrg);

    // correct slice distance for this technique
    sliceDistance_ *= 0.5f*std::sqrt(1.f + dot(eyeCamera_.get().getLook(), lightCamera_.getLook()));
    slicingPrg->setUniform("dPlaneIncr_", sliceDistance_);

    glDisable(GL_DEPTH_TEST);

    glMatrixMode(GL_PROJECTION);
    glPushMatrix();
    tgt::loadMatrix(eyeCamera_.get().getProjectionMatrix(outport_.getSize()));

    glMatrixMode(GL_MODELVIEW);
    glPushMatrix();
    tgt::loadMatrix(eyeCamera_.get().getViewMatrix());

    slicingPrg->activate();
    glEnable(GL_BLEND);

    unsigned int numSlices = static_cast<unsigned int>(maxLength_ / sliceDistance_);

    TextureUnit lightBufferUnit;

    slicingPrg->setUniform("lightBuf_", lightBufferUnit.getUnitNumber());
    slicingPrg->setUniform("lightMat_", lightCamera_.getViewMatrix());
    lightport_.setTextureParameters(slicingPrg, "lightBufParameters_");

    for (unsigned int curSlice = 0; curSlice < numSlices; curSlice++) {
        outport_.activateTarget();

        // FIRST PASS
        if(invert_)
            glBlendFunc(GL_ONE, GL_ONE_MINUS_SRC_ALPHA);
        else
            glBlendFunc(GL_ONE_MINUS_DST_ALPHA, GL_ONE);

        lightBufferUnit.activate();
        glEnable(GL_TEXTURE_2D);
        lightport_.bindColorTexture();

        tgt::Camera cam = eyeCamera_.get();
        setGlobalShaderParameters(slicingPrg, &cam);
        slicingPrg->setUniform("secondPass_", false);

        glBegin(GL_POLYGON);
            for (unsigned int curPoint=0; curPoint<6; curPoint++)
                glVertex2i(curPoint, curSlice);
        glEnd();

        outport_.deactivateTarget();

        // SECOND PASS
        lightport_.activateTarget();
//.........这里部分代码省略.........
开发者ID:molsimmsu,项目名称:3mview,代码行数:101,代码来源:halfangleslicer.cpp

示例15: process

void CurvatureRaycaster::process() {
    // compile program if needed
    if (getInvalidationLevel() >= Processor::INVALID_PROGRAM)
        compile();
    LGL_ERROR;

    // bind transfer function
    TextureUnit transferUnit;
    transferUnit.activate();
    if (transferFunc_.get())
        transferFunc_.get()->bind();

    portGroup_.activateTargets();
    glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
    LGL_ERROR;

    transferFunc_.setVolumeHandle(volumeInport_.getData());

    TextureUnit entryUnit, entryDepthUnit, exitUnit, exitDepthUnit;
    // bind entry params
    entryPort_.bindTextures(entryUnit.getEnum(), entryDepthUnit.getEnum());
    LGL_ERROR;

    // bind exit params
    exitPort_.bindTextures(exitUnit.getEnum(), exitDepthUnit.getEnum());
    LGL_ERROR;

    // vector containing the volumes to bind; is passed to bindVolumes()
    std::vector<VolumeStruct> volumeTextures;

    // add main volume
    TextureUnit volUnit, volUnit2;
    volumeTextures.push_back(VolumeStruct(
        volumeInport_.getData(),
        &volUnit,
        "volumeStruct_")
        );
    volumeTextures.push_back(VolumeStruct(
        gradientInport_.getData(),
        &volUnit2,
        "gradientVolumeParameters_")
        );

    // segmentation volume
    //VolumeHandle* volumeSeg = volumeInport_.getData()->getRelatedVolumeHandle(Modality::MODALITY_SEGMENTATION);
    VolumeHandle* volumeSeg = 0;

    bool usingSegmentation = (maskingMode_.get() == "Segmentation") && volumeSeg;
    TextureUnit segUnit;
    if (usingSegmentation) {
        // Important to set the correct texture unit before getRepresentation<VolumeGL>() is called or
        // glTexParameter() might influence the wrong texture.
        segUnit.activate();

        volumeTextures.push_back(VolumeStruct(volumeSeg,
                                              &segUnit,
                                              "segmentationParameters_"));

        // set texture filtering for this texture unit
        glTexParameteri(GL_TEXTURE_3D, GL_TEXTURE_MAG_FILTER, GL_NEAREST);
        glTexParameteri(GL_TEXTURE_3D, GL_TEXTURE_MIN_FILTER, GL_NEAREST);
    }

    // initialize shader
    raycastPrg_->activate();

    // set common uniforms used by all shaders
    tgt::Camera cam = camera_.get();
    setGlobalShaderParameters(raycastPrg_, &cam);
    // bind the volumes and pass the necessary information to the shader
    bindVolumes(raycastPrg_, volumeTextures, &cam, lightPosition_.get());

    // pass the remaining uniforms to the shader
    raycastPrg_->setUniform("entryPoints_", entryUnit.getUnitNumber());
    raycastPrg_->setUniform("entryPointsDepth_", entryDepthUnit.getUnitNumber());
    entryPort_.setTextureParameters(raycastPrg_, "entryParameters_");
    raycastPrg_->setUniform("exitPoints_", exitUnit.getUnitNumber());
    raycastPrg_->setUniform("exitPointsDepth_", exitDepthUnit.getUnitNumber());
    exitPort_.setTextureParameters(raycastPrg_, "exitParameters_");

    if (compositingMode_.get() ==  "iso" ||
        compositingMode1_.get() == "iso" ||
        compositingMode2_.get() == "iso")
        raycastPrg_->setUniform("isoValue_", isoValue_.get());

    if (classificationMode_.get() == "transfer-function")
        transferFunc_.get()->setUniform(raycastPrg_, "transferFunc_", transferUnit.getUnitNumber());

    // curvature uniforms
    GLint curvatureType = -1;
    if (curvatureType_.get() == "first") curvatureType = 0;
    else if (curvatureType_.get() == "second") curvatureType = 1;
    else if (curvatureType_.get() == "mean") curvatureType = 2;
    else if (curvatureType_.get() == "gauss") curvatureType = 3;
    raycastPrg_->setUniform("curvatureType_", curvatureType);
    raycastPrg_->setUniform("curvatureFactor_", curvatureFactor_.get());
    raycastPrg_->setUniform("silhouetteWidth_", silhouetteWidth_.get());
    raycastPrg_->setUniform("minGradientLength_", minGradientLength_.get());

    LGL_ERROR;
//.........这里部分代码省略.........
开发者ID:bsmr-opengl,项目名称:voreen,代码行数:101,代码来源:curvatureraycaster.cpp


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