本文整理汇总了C++中RenderPort类的典型用法代码示例。如果您正苦于以下问题:C++ RenderPort类的具体用法?C++ RenderPort怎么用?C++ RenderPort使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了RenderPort类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: renderLargeSmallSmall
void TripleView::renderLargeSmallSmall(RenderPort& large, RenderPort& small1, RenderPort& small2) {
MatStack.matrixMode(tgt::MatrixStack::MODELVIEW);
outport_.activateTarget();
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
if (large.isReady())
renderPortQuad(large, vec3(-0.333333f, 0.0f, 0.0f), vec3(0.666666, 1.0f, 1.0f));
if (small1.isReady())
renderPortQuad(small1, vec3(0.666666f, 0.5f, 0.0f), vec3(0.333333f, 0.5f, 1.0f));
if (small2.isReady())
renderPortQuad(small2, vec3(0.666666f, -0.5f, 0.0f), vec3(0.333333f, 0.5f, 1.0f));
glActiveTexture(GL_TEXTURE0);
if(showGrid_.get()) {
glDepthFunc(GL_ALWAYS);
glColor4f(gridColor_.get().r, gridColor_.get().g, gridColor_.get().b, gridColor_.get().a);
glBegin(GL_LINES);
glVertex2f(0.333333f, -1.0f);
glVertex2f(0.333333f, 1.0f);
glVertex2f(0.333333f, 0.0f);
glVertex2f(1.f, 0.0f);
glEnd();
glDepthFunc(GL_LESS);
}
outport_.deactivateTarget();
MatStack.matrixMode(tgt::MatrixStack::MODELVIEW);
MatStack.loadIdentity();
LGL_ERROR;
}
示例2: setGlobalShaderParameters
// Parameters currently set:
// - screenDim_
// - screenDimRCP_
// - cameraPosition_ (camera position in world coordinates)
void RenderProcessor::setGlobalShaderParameters(tgt::Shader* shader, const tgt::Camera* camera, tgt::ivec2 screenDim) {
shader->setIgnoreUniformLocationError(true);
if (screenDim == tgt::ivec2(-1)) {
RenderPort* rp = 0;
for (size_t i=0; i<getOutports().size(); ++i) {
rp = dynamic_cast<RenderPort*>(getOutports()[i]);
if (rp && rp->hasRenderTarget())
break;
}
if (rp) {
screenDim = rp->getSize();
}
}
shader->setUniform("screenDim_", tgt::vec2(screenDim));
shader->setUniform("screenDimRCP_", 1.f / tgt::vec2(screenDim));
// camera position in world coordinates, and corresponding transformation matrices
if (camera) {
shader->setUniform("cameraPosition_", camera->getPosition());
shader->setUniform("viewMatrix_", camera->getViewMatrix());
shader->setUniform("projectionMatrix_", camera->getProjectionMatrix());
tgt::mat4 viewInvert;
if(camera->getViewMatrix().invert(viewInvert))
shader->setUniform("viewMatrixInverse_", viewInvert);
tgt::mat4 projInvert;
if(camera->getProjectionMatrix().invert(projInvert))
shader->setUniform("projectionMatrixInverse_", projInvert);
}
shader->setIgnoreUniformLocationError(false);
LGL_ERROR;
}
示例3: disconnect
void RenderPort::disconnect(Port* other) {
Port::disconnect(other);
RenderPort* rp = static_cast<RenderPort*>(other);
if (isOutport()) {
if (getSizeOrigin() != rp->getSizeOrigin())
static_cast<RenderProcessor*>(getProcessor())->sizeOriginChanged(this);
other->invalidate();
}
}
示例4: dim
void RenderProcessor::adjustRenderOutportDimensions() {
// detect largest inport dimension
tgt::ivec2 dim(-1);
const std::vector<Port*> inports = getInports();
for (size_t i=0; i<inports.size(); ++i) {
RenderPort* rp = dynamic_cast<RenderPort*>(inports[i]);
if (rp && rp->hasRenderTarget() && (rp->getSize().x >= dim.x && rp->getSize().y >= dim.y))
dim = rp->getSize();
}
if (dim == tgt::ivec2(-1))
return;
// assign largest inport dimension to all render outports without size origin
bool assigned = false;
const std::vector<Port*> outports = getOutports();
for (size_t i=0; i<outports.size(); ++i) {
RenderPort* rp = dynamic_cast<RenderPort*>(outports[i]);
if (rp && rp->isConnected() && (rp->getSizeOrigin() == 0)) {
rp->resize(dim);
assigned = true;
}
}
// assign size to private ports
if (assigned) {
const std::vector<RenderPort*> privatePorts = getPrivateRenderPorts();
for (size_t i=0; i<privatePorts.size(); ++i) {
privatePorts[i]->resize(dim);
}
}
}
示例5: connect
bool RenderPort::connect(Port* inport) {
if (Port::connect(inport)) {
RenderPort* rp = static_cast<RenderPort*>(inport);
sizeOriginChanged(rp->getSizeOrigin());
if (rp->getSizeOrigin()) {
static_cast<RenderProcessor*>(getProcessor())->portResized(this, rp->size_);
}
return true;
}
return false;
}
示例6: renderPortQuad
void TripleView::renderPortQuad(RenderPort& rp, tgt::vec3 translate, tgt::vec3 scale) {
rp.bindColorTexture(GL_TEXTURE0);
rp.getColorTexture()->enable();
glTexEnvi(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_REPLACE);
MatStack.translate(translate.x, translate.y, translate.z);
MatStack.scale(scale.x, scale.y, scale.z);
glDepthFunc(GL_ALWAYS);
renderQuad();
glDepthFunc(GL_LESS);
MatStack.loadIdentity();
rp.getColorTexture()->disable();
}
示例7: sizeOriginChanged
void RenderPort::sizeOriginChanged(void* so) {
if (isOutport()) {
static_cast<RenderProcessor*>(getProcessor())->sizeOriginChanged(this);
validResult_ = false;
}
else {
if (sizeOrigin_ == so)
return;
sizeOrigin_ = so;
for (size_t i = 0; i < connectedPorts_.size(); ++i) {
RenderPort* rp = static_cast<RenderPort*>(connectedPorts_[i]);
rp->sizeOriginChanged(so);
if (so)
rp->resize(size_);
}
}
}
示例8: tgtAssert
bool RenderPort::doesSizeOriginConnectFailWithPort(Port* inport) const {
tgtAssert(inport, "passed null pointer");
RenderPort* rin = dynamic_cast<RenderPort*>(inport);
if (!rin)
return false;
bool unEqual = this != rin;
bool outIsOutport = isOutport();
bool inIsInport = rin->isInport();
bool processorUnEqual = getProcessor() != rin->getProcessor();
bool isNotConnected = !isConnectedTo(rin);
bool thisIsConnected = rin->isConnected();
bool thisAllowsMultiple = rin->allowMultipleConnections();
return rin && unEqual && outIsOutport && inIsInport && processorUnEqual && isNotConnected && (!thisIsConnected || thisAllowsMultiple);
}
示例9: invalidate
void RenderProcessor::invalidate(int inv) {
Processor::invalidate(inv);
if (inv == Processor::VALID)
return;
if (!isInitialized())
return;
// invalidate result of render ports
for (size_t i=0; i<getOutports().size(); ++i) {
RenderPort* renderPort = dynamic_cast<RenderPort*>(getOutports()[i]);
if (renderPort)
renderPort->invalidateResult();
}
}
示例10: getOutports
void RenderProcessor::sizeOriginChanged(RenderPort* p) {
if (!p->getSizeOrigin()) {
const std::vector<Port*> outports = getOutports();
for (size_t i=0; i<outports.size(); ++i) {
RenderPort* rp = dynamic_cast<RenderPort*>(outports[i]);
if (rp) {
if (rp->getSizeOrigin())
return;
}
}
}
const std::vector<Port*> inports = getInports();
for (size_t i=0; i<inports.size(); ++i) {
RenderPort* rp = dynamic_cast<RenderPort*>(inports[i]);
if (rp)
rp->sizeOriginChanged(p->getSizeOrigin());
}
}
示例11: getOutports
void RenderStore::sizeOriginChanged(RenderPort* p) {
if (!p->getSizeOrigin()) {
const std::vector<Port*> outports = getOutports();
for (size_t i=0; i<outports.size(); ++i) {
RenderPort* rp = dynamic_cast<RenderPort*>(outports[i]);
if (rp) {
if (rp->getSizeOrigin())
return;
}
}
}
// do not propagate to inport
/*const std::vector<Port*> inports = getInports();
for (size_t i=0; i<inports.size(); ++i) {
RenderPort* rp = dynamic_cast<RenderPort*>(inports[i]);
if (rp)
rp->sizeOriginChanged(p->getSizeOrigin());
} */
}
示例12: tgtAssert
bool RenderStore::testSizeOrigin(const RenderPort* p, void* so) const {
tgtAssert(p->isOutport(), "testSizeOrigin used with inport");
if (so) {
const std::vector<Port*> outports = getOutports();
for (size_t i=0; i<outports.size(); ++i) {
if(p == outports[i])
continue;
RenderPort* rp = dynamic_cast<RenderPort*>(outports[i]);
if (rp) {
if (rp->getSizeOrigin() && (rp->getSizeOrigin() != so)) {
return false;
}
}
}
}
// do not test inport
/*const std::vector<Port*> inports = getInports();
for (size_t i=0; i<inports.size(); ++i) {
RenderPort* rp = dynamic_cast<RenderPort*>(inports[i]);
if (rp) {
if (rp->getSizeOrigin() && (rp->getSizeOrigin() != so) ) {
testSizeOriginVisited_ = false;
return false;
}
const std::vector<Port*>& connectedOutports = inports[i]->getConnected();
for (size_t j=0; j<connectedOutports.size(); ++j) {
RenderPort* op = static_cast<RenderPort*>(connectedOutports[j]);
if (!static_cast<RenderProcessor*>(op->getProcessor())->testSizeOrigin(op, so)) {
testSizeOriginVisited_ = false;
return false;
}
}
}
} */
return true;
}
示例13: reattachTargets
void PortGroup::reattachTargets() {
if (!fbo_)
return;
fbo_->activate();
fbo_->detachAll();
if (ports_.empty())
return;
bool hasDepth_ = false;
for (size_t i=0; i<ports_.size(); ++i) {
RenderPort* p = ports_[i];
if (!ignoreConnectivity_ && !p->isConnected())
continue;
if (p->getColorTexture())
fbo_->attachTexture(p->getColorTexture(), GL_COLOR_ATTACHMENT0_EXT+i);
if (!hasDepth_ && p->getDepthTexture()) {
hasDepth_ = true;
fbo_->attachTexture(p->getDepthTexture(), GL_DEPTH_ATTACHMENT_EXT);
}
}
LGL_ERROR;
if (hasDepth_)
fbo_->isComplete();
}
示例14: rescaleRendering
void VolumeRaycaster::rescaleRendering(RenderPort& srcPort, RenderPort& destPort) {
// activate and clear output render target
destPort.activateTarget();
destPort.clearTarget();
// activate shader and set uniforms
tgtAssert(rescaleShader_, "bypass shader not loaded");
rescaleShader_->activate();
setGlobalShaderParameters(rescaleShader_, 0, destPort.getSize());
// bind input rendering to texture units
tgt::TextureUnit colorUnit, depthUnit;
srcPort.bindTextures(colorUnit.getEnum(), depthUnit.getEnum(), GL_LINEAR);
srcPort.setTextureParameters(rescaleShader_, "texParams_");
rescaleShader_->setUniform("colorTex_", colorUnit.getUnitNumber());
rescaleShader_->setUniform("depthTex_", depthUnit.getUnitNumber());
// render screen aligned quad
renderQuad();
// cleanup
rescaleShader_->deactivate();
destPort.deactivateTarget();
TextureUnit::setZeroUnit();
// check for OpenGL errors
LGL_ERROR;
}
示例15: distributeEventLargeSmallSmall
void TripleView::distributeEventLargeSmallSmall(RenderPort& large, RenderPort& small1, RenderPort& small2, tgt::MouseEvent* me) {
if (me->x() < (me->viewport().x * 0.666666f)) {
tgt::MouseEvent newme(me->x(), me->y(), me->action(), me->modifiers(), me->button(), ivec2(static_cast<int>(me->viewport().x * 0.666666f), me->viewport().y));
newme.ignore(); // accepted is set to true by default
large.distributeEvent(&newme);
if (newme.isAccepted())
me->accept();
}
else if (me->y() < (me->viewport().y * 0.5)) {
tgt::MouseEvent newme(me->x() - static_cast<int>(me->viewport().x * 0.666666f), me->y(), me->action(), me->modifiers(), me->button(), ivec2(me->viewport().x / 3, me->viewport().y / 2));
newme.ignore();
small1.distributeEvent(&newme);
if (newme.isAccepted())
me->accept();
}
else {
tgt::MouseEvent newme(me->x() - static_cast<int>(me->viewport().x * 0.666666f), me->y() - static_cast<int>(me->viewport().y * 0.5f), me->action(), me->modifiers(), me->button(), ivec2(me->viewport().x / 3, me->viewport().y / 2));
newme.ignore();
small2.distributeEvent(&newme);
if (newme.isAccepted())
me->accept();
}
}