本文整理汇总了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);
}
示例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;
}
示例3:
ModulatedMagneticFieldGrid::ModulatedMagneticFieldGrid(ref_ptr<VectorGrid> grid,
ref_ptr<ScalarGrid> modGrid) {
grid->setReflective(false);
modGrid->setReflective(true);
setGrid(grid);
setModulationGrid(modGrid);
}
示例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);
}
示例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:
{
}
}
}
示例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());
}
示例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 );
}
示例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;
}
示例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;
}
示例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
}
示例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;
}
示例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;
}
示例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);
}
}
示例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);
}
示例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;
}