• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

C++ TextureUnit类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

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



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

示例1: bindAndSetUniforms

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


示例2: 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


示例3: translate

	//------------------------------------------------------------------------------//
	void TextureUnitTranslator::translate(ScriptNodePtr& pScriptNode, const String& group)
	{
		Pass* pass = any_cast<Pass*>(pScriptNode->parent->createObj);
		TextureUnit* tu = pass->createTextureUnit();
		pScriptNode->createObj = tu;

		//set TextureUnit setting
		StringKeyValueMap::iterator it = pScriptNode->keyValueMap.find("texture"), itend = pScriptNode->keyValueMap.end();
		if(it != itend)
		{
			tu->setTexture(it->second);
			pScriptNode->keyValueMap.erase(it);
		}
		else
		{
			it = pScriptNode->keyValueMap.find("cube_texture");
			if(it != itend)
			{
				tu->setTexture(it->second, TT_CUBEMAP);
				pScriptNode->keyValueMap.erase(it);
			}
		}
		
		tu->setParams(pScriptNode->keyValueMap);
	}
开发者ID:cty41,项目名称:Titan,代码行数:26,代码来源:TiScriptTranslator.cpp


示例4: setGlobalShaderParameters

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


示例5: Image

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


示例6: 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


示例7: depthTest

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


示例8: setGlobalShaderParameters

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


示例9: generateJitterTexture

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


示例10: glClear

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


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


示例12: 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


示例13: bypass

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


示例14: getTextureUnit

namespace RenderState {

    Blending blending;
    DepthTest depthTest;
    StencilTest stencilTest;
    Culling culling;
    DepthWrite depthWrite;
    BlendingFunc blendingFunc;
    StencilWrite stencilWrite;
    StencilFunc stencilFunc;
    StencilOp stencilOp;
    ColorWrite colorWrite;
    FrontFace frontFace;
    CullFace cullFace;

    VertexBuffer vertexBuffer;
    IndexBuffer indexBuffer;

    TextureUnit textureUnit;
    Texture texture;

    GLuint getTextureUnit(GLuint _unit) {
        if (_unit >= TANGRAM_MAX_TEXTURE_UNIT) {
            logMsg("Warning: trying to access unavailable texture unit");
        }

        return GL_TEXTURE0 + _unit;
    }

    void bindVertexBuffer(GLuint _id) { glBindBuffer(GL_ARRAY_BUFFER, _id); }
    void bindIndexBuffer(GLuint _id) { glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, _id); }
    void activeTextureUnit(GLuint _unit) { glActiveTexture(getTextureUnit(_unit)); }
    void bindTexture(GLenum _target, GLuint _textureId) { glBindTexture(_target, _textureId); }

    void configure() {
        blending.init(GL_FALSE);
        blendingFunc.init(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
        culling.init(GL_TRUE);
        cullFace.init(GL_BACK);
        frontFace.init(GL_CCW);
        depthTest.init(GL_TRUE);
        depthWrite.init(GL_TRUE);

        glDisable(GL_STENCIL_TEST);
        glDepthFunc(GL_LEQUAL);
        glClearDepthf(1.0);
        glDepthRangef(0.0, 1.0);
        glClearColor(0.3, 0.3, 0.3, 1.0);

        vertexBuffer.init(std::numeric_limits<unsigned int>::max(), false);
        indexBuffer.init(std::numeric_limits<unsigned int>::max(), false);
        texture.init(GL_TEXTURE_2D, std::numeric_limits<unsigned int>::max(), false);
        texture.init(GL_TEXTURE_CUBE_MAP, std::numeric_limits<unsigned int>::max(), false);
        textureUnit.init(std::numeric_limits<unsigned int>::max(), false);
    }

}
开发者ID:potatolicious,项目名称:tangram-es,代码行数:57,代码来源:renderState.cpp


示例15: glEnable

void Renderer::drawParticles() {
    // We want to be able to set the point size from the shader
    // and let OpenGL generate texture coordinates for each point
    glEnable(GL_PROGRAM_POINT_SIZE);
    glEnable(GL_POINT_SPRITE); // Deprecated in OpenGL 3.2, but necessary

    // Activate the ProgramObject
    _particleProgram->activate();

    // Bind the only one texture that is used as the color and normal texture
    TextureUnit textureUnit;
    textureUnit.activate();
    _particleTexture->enable();
    _particleTexture->bind();

    // We are using 'fragColor' as the output variable from the FragmentShader
    _particleProgram->bindFragDataLocation("fragColor", 0);

    // Enable and bind the VBO holding the vertices for the ground and assign them a location
    glEnableVertexAttribArray(0);
    glBindBuffer(GL_ARRAY_BUFFER, _particleVBO);
    glVertexAttribPointer(0, 3, GL_FLOAT, GL_TRUE, 0, 0);
    _particleProgram->bindAttributeLocation("in_position", _particleVBO);

    // Set the rest of the uniforms
    // It would be faster to cache the uniform location and reuse that, but this is more readable
    _particleProgram->setUniform("_viewProjectionMatrix", _viewProjectionMatrix);
    _particleProgram->setUniform("_cameraPosition", _position);
    _particleProgram->setUniform("_lightPosition", _lightPosition);
    _particleProgram->setUniform("_texture", textureUnit.unitNumber());

    // _particleData holds the xyz coordinates, so it has thrice the amount of data
    // than it has points. And since we test for the correct amount of data elsewhere,
    // it is safe to assume that everything is fine
    glDrawArrays(GL_POINTS, 0, _numberOfParticles);

    // Be a good citizen and disable everything again
    glBindBuffer(GL_ARRAY_BUFFER, 0);
    _particleTexture->disable();
    _particleProgram->deactivate();
    glDisable(GL_POINT_SPRITE);
    glDisable(GL_PROGRAM_POINT_SIZE);
}
开发者ID:belindabernfort,项目名称:PUMlab3,代码行数:43,代码来源:renderer.cpp


示例16: init

TextureUnit TextureUnitManager::requestTextureUnit()
{
   if(!TextureUnitManager::initted)
   {
      init();
   }
   if(!unitQueue.empty())
   {
      TextureUnit ret = unitQueue.top();
      unitQueue.pop();
      ret.active = true;
      LOG(INFO) << "Leasing unit " + std::to_string(ret.getTexUnit());
      return ret;
   }
   else
   {
      LOG(ERROR) << "Out of texture untis!";
      exit(-1);
   }
}
开发者ID:kyle-piddington,项目名称:GLFWEngine,代码行数:20,代码来源:TextureUnitManager.cpp


示例17: depthTest

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


示例18: glEnableVertexAttribArray

void Renderer::drawGround() {
    // Active the ProgramObject
    _groundProgram->activate();

    // Bind the ground texture in the first available texture unit
    TextureUnit groundTextureUnit;
    groundTextureUnit.activate();
    _groundTexture->enable();
    _groundTexture->bind();

    // Bind the normal texture in the next free texture unit
    TextureUnit groundTextureNormalUnit;
    groundTextureNormalUnit.activate();
    _groundTextureNormal->enable();
    _groundTextureNormal->bind();

    // We are using 'fragColor' as the output variable from the FragmentShader
    _groundProgram->bindFragDataLocation("fragColor", 0);

    // Enable and bind the VBO holding the vertices for the ground and assign them a location
    glEnableVertexAttribArray(0);
    glBindBuffer(GL_ARRAY_BUFFER, _groundVBO);
    glVertexAttribPointer(0, 3, GL_FLOAT, GL_FALSE, 0, 0);
    _groundProgram->bindAttributeLocation("in_position", _groundVBO);
    
    // Set the rest of the uniforms
    // It would be faster to cache the uniform location and reuse that, but this is more readable
    _groundProgram->setUniform("_viewProjectionMatrix", _viewProjectionMatrix);
    _groundProgram->setUniform("_cameraPosition", _position);
    _groundProgram->setUniform("_lightPosition", _lightPosition);
    _groundProgram->setUniform("_texture", groundTextureUnit.unitNumber());
    _groundProgram->setUniform("_textureNormal", groundTextureNormalUnit.unitNumber());

    // Draw one quad 
    glDrawArrays(GL_QUADS, 0, 4);

    // And disable everything again to be a good citizen
    glBindBuffer(GL_ARRAY_BUFFER, 0);
    _groundTexture->disable();
    _groundTextureNormal->disable();
    _groundProgram->deactivate();
}
开发者ID:belindabernfort,项目名称:PUMlab3,代码行数:42,代码来源:renderer.cpp


示例19: compile

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++)
//.........这里部分代码省略.........
开发者ID:molsimmsu,项目名称:3mview,代码行数:101,代码来源:occlusionslicer.cpp


示例20: vec4

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);
//.........这里部分代码省略.........
开发者ID:ResearchDaniel,项目名称:inviwo,代码行数:101,代码来源:imagegl.cpp



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
C++ TextureUnitState类代码示例发布时间:2022-05-31
下一篇:
C++ TexturePtr类代码示例发布时间:2022-05-31
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap