本文整理汇总了C++中ref_ptr类的典型用法代码示例。如果您正苦于以下问题:C++ ref_ptr类的具体用法?C++ ref_ptr怎么用?C++ ref_ptr使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了ref_ptr类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C++代码示例。
示例1: Build
void Arrow3d::Render(ScreenBase const & screen, int zoomLevel, ref_ptr<dp::GpuProgramManager> mng)
{
// Unbind current VAO, because glVertexAttributePointer and glEnableVertexAttribute can affect it.
if (dp::GLExtensionsList::Instance().IsSupported(dp::GLExtensionsList::VertexArrayObject))
GLFunctions::glBindVertexArray(0);
if (!m_isInitialized)
{
Build();
m_isInitialized = true;
}
// Render shadow.
if (screen.isPerspective())
{
ref_ptr<dp::GpuProgram> shadowProgram = mng->GetProgram(gpu::ARROW_3D_SHADOW_PROGRAM);
RenderArrow(screen, shadowProgram, dp::Color(60, 60, 60, 60), 0.05f, false /* hasNormals */);
}
// Render arrow.
ref_ptr<dp::GpuProgram> arrowProgram = mng->GetProgram(gpu::ARROW_3D_PROGRAM);
dp::Color const color = df::GetColorConstant(GetStyleReader().GetCurrentStyle(),
m_obsoletePosition ? df::Arrow3DObsolete : df::Arrow3D);
RenderArrow(screen, arrowProgram, color, 0.0f, true /* hasNormals */);
arrowProgram->Unbind();
GLFunctions::glBindBuffer(0, gl_const::GLArrayBuffer);
}
开发者ID:trashkalmar,项目名称:omim,代码行数:28,代码来源:arrow3d.cpp
示例2: create
ref_ptr<ShaderInput> ShaderInput::copy(const ref_ptr<ShaderInput> &in, GLboolean copyData)
{
ref_ptr<ShaderInput> cp = create(in->name(), in->dataType(), in->valsPerElement());
cp->stride_ = in->stride_;
cp->offset_ = in->offset_;
cp->inputSize_ = in->inputSize_;
cp->elementSize_ = in->elementSize_;
cp->elementCount_ = in->elementCount_;
cp->numVertices_ = in->numVertices_;
cp->numInstances_ = in->numInstances_;
cp->divisor_ = in->divisor_;
cp->buffer_ = 0;
cp->bufferStamp_ = 0;
cp->normalize_ = in->normalize_;
cp->isVertexAttribute_ = in->isVertexAttribute_;
cp->isConstant_ = in->isConstant_;
cp->transpose_ = in->transpose_;
cp->stamp_ = in->stamp_;
cp->forceArray_ = in->forceArray_;
cp->data_ = new byte[cp->inputSize_];
if(copyData && in->data_!=NULL) {
std::memcpy(cp->data_, in->data_, cp->inputSize_);
}
// make data_ stack root
cp->dataStack_.push(cp->data_);
return cp;
}
开发者ID:daniel86,项目名称:regen,代码行数:29,代码来源:shader-input.cpp
示例3:
ModulatedMagneticFieldGrid::ModulatedMagneticFieldGrid(ref_ptr<VectorGrid> grid,
ref_ptr<ScalarGrid> modGrid) {
grid->setReflective(false);
modGrid->setReflective(true);
setGrid(grid);
setModulationGrid(modGrid);
}
开发者ID:CRPropa,项目名称:CRPropa3,代码行数:7,代码来源:MagneticFieldGrid.cpp
示例4: CalculateTransform
void Arrow3d::RenderArrow(ScreenBase const & screen, ref_ptr<dp::GpuProgram> program,
dp::Color const & color, float dz, bool hasNormals)
{
program->Bind();
GLFunctions::glBindBuffer(m_bufferId, gl_const::GLArrayBuffer);
uint32_t const attributePosition = program->GetAttributeLocation("a_pos");
ASSERT_NOT_EQUAL(attributePosition, -1, ());
GLFunctions::glEnableVertexAttribute(attributePosition);
GLFunctions::glVertexAttributePointer(attributePosition, kComponentsInVertex,
gl_const::GLFloatType, false, 0, 0);
if (hasNormals)
{
GLFunctions::glBindBuffer(m_bufferNormalsId, gl_const::GLArrayBuffer);
uint32_t const attributeNormal = program->GetAttributeLocation("a_normal");
ASSERT_NOT_EQUAL(attributeNormal, -1, ());
GLFunctions::glEnableVertexAttribute(attributeNormal);
GLFunctions::glVertexAttributePointer(attributeNormal, 3, gl_const::GLFloatType, false, 0, 0);
}
dp::UniformValuesStorage uniforms;
math::Matrix<float, 4, 4> const modelTransform = CalculateTransform(screen, dz);
uniforms.SetMatrix4x4Value("u_transform", modelTransform.m_data);
glsl::vec4 const c = glsl::ToVec4(color);
uniforms.SetFloatValue("u_color", c.r, c.g, c.b, c.a);
dp::ApplyState(m_state, program);
dp::ApplyUniforms(uniforms, program);
GLFunctions::glDrawArrays(gl_const::GLTriangles, 0, m_vertices.size() / kComponentsInVertex);
}
开发者ID:trashkalmar,项目名称:omim,代码行数:30,代码来源:arrow3d.cpp
示例5: drawCurve
void BezierCurveVisualizer::drawCurve(ref_ptr<MatrixTransform> master)
{
Vec4 colorRed = Vec4(1.0, 0.0, 0.0, 1.0);
double t;
switch (computation)
{
case APROXIMATION:
{
std::vector<Vec3> points = controlPoints;
Vec3 p1 = casteljauAproximation(controlPoints, 0.0);
Vec3 p2 = casteljauAproximation(controlPoints, 0.005);
drawLine(master, p1, p2, colorRed);
for (t = 0.01; t <= 1.0; t += 0.005)
{
p1 = p2;
p2 = casteljauAproximation(controlPoints, t);
drawLine(master.get(), p1, p2, colorRed);
}
break;
}
case EXACT_COMPUTATION:
{
Vec3 p1 = computePointOnCurve(controlPoints, 0.0);
Vec3 p2 = computePointOnCurve(controlPoints, 0.001);
drawLine(master, p1, p2, colorRed);
for (t = 0.002; t <= 1.0; t += 0.001)
{
p1 = p2;
p2 = computePointOnCurve(controlPoints, t);
drawLine(master.get(), p1, p2, colorRed);
}
break;
}
//takes just the first 4 points of controlPoints to compute the curve
case CUBIC_APROXIMATION:
{
if (controlPoints.size() < 4)
{
if (cover->debugLevel(3))
fprintf(stderr, "Nicht genügend Kontrollpunkte vorhanden, um eine kubische Bezierkurve zu erzeugen.\n");
}
else
{
Vec3 p1 = controlPoints[0];
Vec3 p2 = controlPoints[1];
Vec3 p3 = controlPoints[2];
Vec3 p4 = controlPoints[3];
cubicCasteljauAproximation(master, p1, p2, p3, p4, 4);
}
break;
}
default:
{
}
}
}
开发者ID:nixz,项目名称:covise,代码行数:59,代码来源:BezierCurveVisualizer.cpp
示例6: FinalizeBucket
void Batcher::ChangeBuffer(ref_ptr<CallbacksWrapper> wrapper)
{
GLState const & state = wrapper->GetState();
FinalizeBucket(state);
ref_ptr<RenderBucket> bucket = GetBucket(state);
wrapper->SetVAO(bucket->GetBuffer());
}
开发者ID:ipaddr,项目名称:omim,代码行数:8,代码来源:batcher.cpp
示例7: addFirstChild
void StateNode::addFirstChild(const ref_ptr<StateNode> &child)
{
if(child->parent_!=NULL) {
child->parent_->removeChild(child.get());
}
childs_.push_front(child);
child->set_parent( this );
}
开发者ID:thills167,项目名称:regen,代码行数:8,代码来源:state-node.cpp
示例8:
// associe un objet light a un objet lightsource
ref_ptr<LightSource> MyView::associeLightASource(ref_ptr<Light> light,ref_ptr<Camera> camera){
ref_ptr<LightSource> source = new LightSource;
source->setLight(light);
if(light->getLightNum() == 0){
source->setReferenceFrame(LightSource::ABSOLUTE_RF);
}
camera->addChild(source);
return source;
}
开发者ID:MaXllll,项目名称:Quoridor,代码行数:10,代码来源:MyView.cpp
示例9:
PhysicalProps::PhysicalProps(
const ref_ptr<btMotionState> &motionState,
const ref_ptr<btCollisionShape> &shape)
: constructInfo_(0,motionState.get(),shape.get()),
shape_(shape),
motionState_(motionState)
{
constructInfo_.m_restitution = 0;
constructInfo_.m_friction = 1.5;
}
开发者ID:thills167,项目名称:regen,代码行数:10,代码来源:physical-props.cpp
示例10: Render
void Render(float curTime)
{
// render
device->Clear(true, true);
static float lastTime = -2.0;
switch(fractalType)
{
case JULIA:
RenderJulia(animationTime += (curTime - lastTime) * animationSpeed * toggleAnimation);
break;
case TAILOR:
RenderTailor(animationTime += (curTime - lastTime) * animationSpeed * toggleAnimation);
break;
default:
assert(!"Fractal is not supported");
break;
}
RenderCommon(curTime);
lastTime = curTime;
// here we can take screenshot
if ( takeScreenShot )
{
if ( outputFile.empty() )
{
// get time
static int screenNum = 0;
ostringstream numSS;
numSS << screenNum++;
outputFile = string("screen_") + numSS.str()
#ifdef SIMPLE_GL_USE_SDL_IMAGE
+ ".bmp";
#else // SIMPLE_GL_USE_DEVIL
+ ".jpg";
#endif // SIMPLE_GL_USE_SDL_IMAGE
}
// screenshot
ref_ptr<Image> image( device->CreateImage() );
//device->TakeScreenshot( image.get() );
image->SaveToFile( outputFile.c_str() );
outputFile.clear();
takeScreenShot = false;
}
#ifndef __ANDROID__
device->SwapBuffers();
#endif
}
开发者ID:BackupTheBerlios,项目名称:sgl,代码行数:55,代码来源:main.cpp
示例11: meanFieldVector
Vector3f meanFieldVector(ref_ptr<VectorGrid> grid) {
size_t Nx = grid->getNx();
size_t Ny = grid->getNy();
size_t Nz = grid->getNz();
Vector3f mean(0.);
for (int ix = 0; ix < Nx; ix++)
for (int iy = 0; iy < Ny; iy++)
for (int iz = 0; iz < Nz; iz++)
mean += grid->get(ix, iy, iz);
return mean / Nx / Ny / Nz;
}
开发者ID:msettimo,项目名称:CRPropa3,代码行数:11,代码来源:GridTools.cpp
示例12: meanFieldStrength
double meanFieldStrength(ref_ptr<VectorGrid> grid) {
size_t Nx = grid->getNx();
size_t Ny = grid->getNy();
size_t Nz = grid->getNz();
double mean = 0;
for (int ix = 0; ix < Nx; ix++)
for (int iy = 0; iy < Ny; iy++)
for (int iz = 0; iz < Nz; iz++)
mean += grid->get(ix, iy, iz).getR();
return mean / Nx / Ny / Nz;
}
开发者ID:msettimo,项目名称:CRPropa3,代码行数:11,代码来源:GridTools.cpp
示例13: AnimationStarted
void MyPositionController::AnimationStarted(ref_ptr<Animation> anim)
{
if (m_isPendingAnimation && m_animCreator != nullptr && anim != nullptr &&
(anim->GetType() == Animation::MapFollow ||
anim->GetType() == Animation::MapLinear))
{
m_isPendingAnimation = false;
double const kDoNotChangeDuration = -1.0;
m_animCreator(anim->GetType() == Animation::MapFollow ? anim->GetDuration() : kDoNotChangeDuration);
}
}
开发者ID:,项目名称:,代码行数:11,代码来源:
示例14: rmsFieldStrength
double rmsFieldStrength(ref_ptr<VectorGrid> grid) {
size_t Nx = grid->getNx();
size_t Ny = grid->getNy();
size_t Nz = grid->getNz();
double sumB2 = 0;
for (int ix = 0; ix < Nx; ix++)
for (int iy = 0; iy < Ny; iy++)
for (int iz = 0; iz < Nz; iz++)
sumB2 += grid->get(ix, iy, iz).getR2();
return std::sqrt(sumB2 / Nx / Ny / Nz);
}
开发者ID:msettimo,项目名称:CRPropa3,代码行数:11,代码来源:GridTools.cpp
示例15: OmniDirectionalCamera
ParaboloidCamera::ParaboloidCamera(
const ref_ptr<Mesh> &mesh,
const ref_ptr<Camera> &userCamera,
GLboolean hasBackFace)
: OmniDirectionalCamera(hasBackFace,GL_FALSE),
userCamera_(userCamera)
{
GLuint numLayer = (hasBackFace ? 2 : 1);
shaderDefine("RENDER_TARGET", hasBackFace ? "DUAL_PARABOLOID" : "PARABOLOID");
shaderDefine("RENDER_LAYER", REGEN_STRING(numLayer));
shaderDefine("USE_PARABOLOID_PROJECTION", "TRUE");
updateFrustum(180.0f, 1.0f,
userCamera_->near()->getVertex(0),
userCamera_->far()->getVertex(0),
GL_FALSE);
// Set matrix array size
view_->set_elementCount(numLayer);
viewInv_->set_elementCount(numLayer);
viewproj_->set_elementCount(numLayer);
viewprojInv_->set_elementCount(numLayer);
// Allocate matrices
proj_->setUniformDataUntyped(NULL);
projInv_->setUniformDataUntyped(NULL);
view_->setUniformDataUntyped(NULL);
viewInv_->setUniformDataUntyped(NULL);
viewproj_->setUniformDataUntyped(NULL);
viewprojInv_->setUniformDataUntyped(NULL);
// Projection is calculated in shaders.
proj_->setVertex(0, Mat4f::identity());
projInv_->setVertex(0, Mat4f::identity());
// Initialize directions.
direction_->set_elementCount(numLayer);
direction_->setUniformDataUntyped(NULL);
direction_->setVertex(0, Vec3f(0.0,0.0, 1.0));
if(hasBackFace_)
direction_->setVertex(1, Vec3f(0.0,0.0,-1.0));
modelMatrix_ = ref_ptr<ShaderInputMat4>::dynamicCast(mesh->findShaderInput("modelMatrix"));
pos_ = ref_ptr<ShaderInput3f>::dynamicCast(mesh->positions());
nor_ = ref_ptr<ShaderInput3f>::dynamicCast(mesh->normals());
matrixStamp_ = 0;
positionStamp_ = 0;
normalStamp_ = 0;
// initially update shadow maps
update();
}
开发者ID:daniel86,项目名称:regen,代码行数:51,代码来源:paraboloid-camera.cpp
示例16: loadUnlightedGeostate
void FlightPathVisualizer::loadUnlightedGeostate(ref_ptr<StateSet> state)
{
ref_ptr<Material> mat = new Material;
mat->setColorMode(Material::AMBIENT_AND_DIFFUSE);
mat->setDiffuse(Material::FRONT_AND_BACK, Vec4(0.9f, 0.9f, 0.9f, 1.f));
mat->setSpecular(Material::FRONT_AND_BACK, Vec4(0.9f, 0.9f, 0.9f, 1.f));
mat->setAmbient(Material::FRONT_AND_BACK, Vec4(0.2f, 0.2f, 0.2f, 1.f));
mat->setEmission(Material::FRONT_AND_BACK, Vec4(0.0f, 0.0f, 0.0f, 1.f));
mat->setShininess(Material::FRONT_AND_BACK, 16.f);
mat->setTransparency(Material::FRONT_AND_BACK, 1.f); // Noch Wert anpassen für Transparency
state->setAttributeAndModes(mat, osg::StateAttribute::ON);
state->setMode(GL_BLEND, osg::StateAttribute::ON);
state->setRenderingHint(osg::StateSet::TRANSPARENT_BIN);
}
开发者ID:nixz,项目名称:covise,代码行数:15,代码来源:FlightPathVisualizer.cpp
示例17: handleChildren
void handleChildren(
SceneParser *parser,
SceneInputNode &input,
const ref_ptr<StateNode> &newNode)
{
// Process node children
const list< ref_ptr<SceneInputNode> > &childs = input.getChildren();
for(list< ref_ptr<SceneInputNode> >::const_iterator
it=childs.begin(); it!=childs.end(); ++it)
{
const ref_ptr<SceneInputNode> &x = *it;
// First try node processor
ref_ptr<NodeProcessor> nodeProcessor = parser->getNodeProcessor(x->getCategory());
if(nodeProcessor.get()!=NULL) {
nodeProcessor->processInput(parser, *x.get(), newNode);
continue;
}
// Second try state processor
ref_ptr<StateProcessor> stateProcessor = parser->getStateProcessor(x->getCategory());
if(stateProcessor.get()!=NULL) {
stateProcessor->processInput(parser, *x.get(), newNode->state());
continue;
}
REGEN_WARN("No processor registered for '" << x->getDescription() << "'.");
}
}
开发者ID:thills167,项目名称:regen,代码行数:26,代码来源:scene-display-widget.cpp
示例18: Vec3Array
void BezierCurveVisualizer::drawLine(ref_ptr<MatrixTransform> master, Vec3 point1, Vec3 point2, Vec4 color, float linewidth)
{
ref_ptr<Vec3Array> lineCoordList = new Vec3Array(2);
lineCoordList.get()->at(0) = point1;
lineCoordList.get()->at(1) = point2;
ref_ptr<Vec4Array> lineColorList = new Vec4Array;
lineColorList->push_back(color);
ref_ptr<Geometry> lineGeoset = new Geometry;
ref_ptr<StateSet> lineGeoset_state = lineGeoset->getOrCreateStateSet();
lineGeoset->setVertexArray(lineCoordList);
lineGeoset->setColorArray(lineColorList);
lineGeoset->setColorBinding(Geometry::BIND_OVERALL);
lineGeoset->addPrimitiveSet(new DrawArrays(PrimitiveSet::LINES, 0, 2));
ref_ptr<LineWidth> lw = new LineWidth(linewidth);
lineGeoset_state->setAttribute(lw);
ref_ptr<Material> mtl = new Material;
mtl->setColorMode(Material::AMBIENT_AND_DIFFUSE);
mtl->setAmbient(Material::FRONT_AND_BACK, Vec4(0.2f, 0.2f, 0.2f, 1.f));
mtl->setDiffuse(Material::FRONT_AND_BACK, Vec4(0.9f, 0.9f, 0.9f, 1.f));
mtl->setSpecular(Material::FRONT_AND_BACK, Vec4(0.9f, 0.9f, 0.9f, 1.f));
mtl->setEmission(Material::FRONT_AND_BACK, Vec4(0.0f, 0.0f, 0.0f, 1.f));
mtl->setShininess(Material::FRONT_AND_BACK, 16.f);
// lineGeoState->setAttributeAndModes(material, osg::StateAttribute::ON);
lineGeoset_state->setAttribute(mtl.get());
ref_ptr<Geode> lineGeode = new Geode;
lineGeode->addDrawable(lineGeoset);
master->addChild(lineGeode);
}
开发者ID:nixz,项目名称:covise,代码行数:34,代码来源:BezierCurveVisualizer.cpp
示例19: addPart
void Furniture::addPart(ref_ptr < AbstractObject > apAbstractObject) {
addChild(apAbstractObject);
string strCommand = apAbstractObject->getSQLCommand();
m_arrSQLCommandLines.push_back(strCommand);
}
开发者ID:octaviansoldea,项目名称:VRShop,代码行数:7,代码来源:VRFurniture.cpp
示例20: main_Model3D
void main_Model3D(ref_ptr<Group> pScene) {
ref_ptr<Model3D> pModel3D = new Model3D();
pModel3D->setColor(Vec4(0.0, 1.0, 0.0, 1.0));
pModel3D->setIsTargetPick(true);
pScene->addChild(pModel3D);
}
开发者ID:octaviansoldea,项目名称:VRShop,代码行数:7,代码来源:OSG_GUI.cpp
注:本文中的ref_ptr类示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论