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


C++ ref_ptr类代码示例

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


在下文中一共展示了ref_ptr类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的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: startup

Group* startup()
{
	// we need the scene's state set to enable the light for the entire scene
	Group *scene = new Group();
	lightStateSet = scene->getOrCreateStateSet();
	lightStateSet->ref();
	
	// create VideoGeometry
	try {
		videoGeode = new VideoGeode();
		
		// stars / starfield
		Material *material = new Material();
		material->setEmission(Material::FRONT, Vec4(1.0f, 1.0f, 1.0f, 1.0f));
		material->setAmbient(Material::FRONT,  Vec4(1.0f, 1.0f, 1.0f, 1.0f));
		material->setShininess(Material::FRONT, 25.0f);
		// creating a video plane
		videoGeode->prepareMaterial(material);
      //videoPlane = videoGeode->createVideoPlane(1,1, true);
      videoPlane = videoGeode->createVideoPlane(2,2, true);
      videoPlane->setPosition(Vec3(0,0,0));
	} catch (char *e) {
		std::cerr << e;
	}
	
   scene->addChild(videoPlane);
	
	return scene;
}
开发者ID:SPhoenixx,项目名称:NAM,代码行数:29,代码来源:main-VideoGeometry.cpp


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