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


C++ Color4f类代码示例

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


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

示例1: defined

void CPUSkinningAlgorithm::drawPrimitives(
    SkinnedGeometry *skinGeo, CPUSkinningDataAttachment* data, DrawEnv *pEnv)
{
    // store glColor.
    Color4f color;

#if !defined(OSG_OGL_COREONLY) || defined(OSG_CHECK_COREONLY)
    if(skinGeo->getColors() != NULL)
        glGetFloatv(GL_CURRENT_COLOR, color.getValuesRGBA());
#endif

    GeoPumpGroup::PropertyCharacteristics prop =
        GeoPumpGroup::characterizeGeometry(skinGeo);

    GeoPumpGroup::GeoPump pump = GeoPumpGroup::findGeoPump(pEnv, prop);

    if(pump != NULL)
    {
        pump(pEnv,
             skinGeo->getLengths(),      skinGeo->getTypes(),
             data   ->getMFProperties(), skinGeo->getMFPropIndices());
    }
    else
    {
        SWARNING << "CPUSkinningAlgorithm::drawPrimitives: no GeoPump found "
                 << "for SkinnedGeometry " << skinGeo
                 << std::endl;
    }

#if !defined(OSG_OGL_COREONLY) || defined(OSG_CHECK_COREONLY)
    // restore glColor.
    if(skinGeo->getColors() != NULL)
        glColor4fv(color.getValuesRGBA());
#endif
}
开发者ID:Himbeertoni,项目名称:OpenSGDevMaster,代码行数:35,代码来源:OSGCPUSkinningAlgorithm.cpp

示例2: Alpha

void Graphics3DExtrude::drawText(const Pnt2f& Position, const std::string& Text, const UIFontUnrecPtr TheFont, const Color4f& Color, const Real32& Opacity) const
{
   TextLayoutParam layoutParam;
   layoutParam.spacing = 1.1;
   layoutParam.majorAlignment = TextLayoutParam::ALIGN_BEGIN;
   layoutParam.minorAlignment = TextLayoutParam::ALIGN_BEGIN;
 
   TextLayoutResult layoutResult;
   TheFont->layout(Text, layoutParam, layoutResult);

   TheFont->getTexture()->activate(getDrawEnv());

   Real32 Alpha(Color.alpha() * Opacity * getOpacity());
	
   //Setup the blending equations properly
   glPushAttrib(GL_COLOR_BUFFER_BIT);
	glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
	glEnable(GL_BLEND);

   glColor4f(Color.red(), Color.green(), Color.blue(), Alpha );
   glPushMatrix();
   glTranslatef(Position.x(), Position.y(), 0.0);
   glScalef(TheFont->getSize(), TheFont->getSize(), 1);
   drawCharacters(layoutResult, TheFont);
   glPopMatrix();

   TheFont->getTexture()->deactivate(getDrawEnv());

	glDisable(GL_BLEND);
   glPopAttrib();
}
开发者ID:msteners,项目名称:OpenSGToolbox,代码行数:31,代码来源:OSGGraphics3DExtrude.cpp

示例3: glGetFloatv

void Graphics3DExtrude::drawArc(const Pnt2f& Center, const Real32& Width, const Real32& Height, const Real32& StartAngleRad, const Real32& EndAngleRad, const Real32& LineWidth, const UInt16& SubDivisions, const Color4f& Color, const Real32& Opacity) const
{
	GLfloat previousLineWidth;
	glGetFloatv(GL_LINE_WIDTH, &previousLineWidth);
	Real32 angleNow = StartAngleRad;
	Real32 angleDiff = (EndAngleRad-StartAngleRad)/(static_cast<Real32>(SubDivisions));
	//If andle difference is bigger to a circle, set it to equal to a circle
	if(EndAngleRad-StartAngleRad > 2*3.1415926535)
		angleDiff = 2*3.1415926535/static_cast<Real32>(SubDivisions);
   Real32 Alpha(Color.alpha() * Opacity * getOpacity());
	if(Alpha < 1.0)
	{
		//Setup the blending equations properly
		glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
		glEnable(GL_BLEND);
	}
	glLineWidth(LineWidth);
	glBegin(GL_LINE_STRIP);
      glColor4f(Color.red(), Color.green(), Color.blue(), Alpha );
		//draw vertex lines
      for(UInt16 i = 0 ; i<SubDivisions+1 ; ++i)
      {
			glVertex2f( static_cast<Real32>(Center.x()) + static_cast<Real32>(Width)*osgCos(angleNow ),static_cast<Real32>(Center.y()) +static_cast<Real32>(Height)*osgSin(angleNow));
			//glVertex2f(Center.x() + Width*osgCos(angleNow + angleDiff), Center.y() + Height*osgSin(angleNow+angleDiff));
			angleNow += angleDiff;
		}
	glEnd();

	
	if(Alpha < 1.0)
	{
		glDisable(GL_BLEND);
	}
   glLineWidth(previousLineWidth);
}
开发者ID:msteners,项目名称:OpenSGToolbox,代码行数:35,代码来源:OSGGraphics3DExtrude.cpp

示例4: SAFE_DELETE

bool ImageDiffer::Diff(const Image& ref, const Image& target) {
    SAFE_DELETE(m_diffData);
    SAFE_DELETE(m_displayData);

    if (ref.GetWidth() != target.GetWidth() ||
        ref.GetHeight() != target.GetHeight()) {
        ApolloException::NotYetImplemented();
    }

    m_ref = &ref;
    m_target = &target;
    m_diffData = new Image(ref.GetWidth(), ref.GetHeight());
    m_displayData = new Image(ref.GetWidth(), ref.GetHeight());

    bool identical = true;

    for (UINT32 row = 0; row < ref.GetHeight(); row++) {
        for (UINT32 col = 0; col < ref.GetWidth(); col++) {
            Color4f diff = ref.GetPixel(row, col) - target.GetPixel(row, col);
            diff.Abs();
            m_diffData->SetPixel(diff, row, col);

            diff *= m_magnify;
            if (diff.MaxChannel() > m_threshold) {
                Color4f c1 = ref.GetPixel(row, col);
                Color4f c2 = target.GetPixel(row, col);
                identical = false;
            }
        }
    }

    m_displayDirty = true;

    return identical;
}
开发者ID:nongli,项目名称:Apollo,代码行数:35,代码来源:ImageDiffer.cpp

示例5:

Color4b::Color4b    (const Color4f& rhs)
{
    r = rhs.r_as_byte();
    g = rhs.g_as_byte();
    b = rhs.b_as_byte();
    a = rhs.a_as_byte();
}
开发者ID:9heart,项目名称:DT3,代码行数:7,代码来源:Color4b.cpp

示例6: develop_to_tile

void GlobalAccumulationFramebuffer::develop_to_tile(
    Tile&           tile,
    const size_t    origin_x,
    const size_t    origin_y,
    const size_t    tile_x,
    const size_t    tile_y,
    const float     scale) const
{
    const size_t tile_width = tile.get_width();
    const size_t tile_height = tile.get_height();

    for (size_t y = 0; y < tile_height; ++y)
    {
        for (size_t x = 0; x < tile_width; ++x)
        {
            Color4f color;
            
            color.rgb() =
                get_pixel(
                    origin_x + x,
                    origin_y + y);

            color.rgb() *= scale;

            color.a = 1.0f;

            tile.set_pixel(x, y, color);
        }
    }
}
开发者ID:EgoIncarnate,项目名称:appleseed,代码行数:30,代码来源:globalaccumulationframebuffer.cpp

示例7: gluNewQuadric

void VanDerWaalsGLRenderer::drawAtoms( const BioStruct3DColorScheme* colorScheme )
{
    static float tolerance = 0.45f;
    int numSlices = 10 * settings->detailLevel;
    GLUquadricObj *pObj = gluNewQuadric();
    gluQuadricNormals(pObj, GLU_SMOOTH);


    // Draw atoms as spheres

    foreach (const SharedMolecule mol, bioStruct.moleculeMap) {
        foreach (int index, shownModels) {
            const Molecule3DModel& model = mol->models.value(index);
            foreach(const SharedAtom atom, model.atoms) {
                float radius = AtomConstants::getAtomCovalentRadius(atom->atomicNumber);
                Vector3D pos = atom->coord3d;
                Color4f atomColor = colorScheme->getAtomColor(atom);
                glMaterialfv(GL_FRONT, GL_AMBIENT_AND_DIFFUSE, atomColor.getConstData());
                glPushMatrix();
                glTranslatef(pos.x, pos.y, pos.z);
                gluSphere(pObj, radius + tolerance, numSlices, numSlices);
                glPopMatrix();
            }
        }
    }
    gluDeleteQuadric(pObj);

}
开发者ID:ggrekhov,项目名称:ugene,代码行数:28,代码来源:VanDerWaalsGLRenderer.cpp

示例8: compare

    auto_ptr<Image> compare(const Image& lhs, const Image& rhs, const IPixelOp& op)
    {
        const CanvasProperties& lhs_props = lhs.properties();
        const CanvasProperties& rhs_props = rhs.properties();

        if (lhs_props.m_canvas_width != rhs_props.m_canvas_width ||
            lhs_props.m_canvas_height != rhs_props.m_canvas_height ||
            lhs_props.m_channel_count != rhs_props.m_channel_count)
            throw ExceptionNonMatchingImageCharacteristics();

        if (lhs_props.m_channel_count != 4)
            throw ExceptionUnsupportedChannelCount();

        auto_ptr<Image> output(new Image(lhs));

        for (size_t y = 0; y < lhs_props.m_canvas_height; ++y)
        {
            for (size_t x = 0; x < lhs_props.m_canvas_width; ++x)
            {
                Color4f lhs_color;
                lhs.get_pixel(x, y, lhs_color);
                
                Color4f rhs_color;
                rhs.get_pixel(x, y, rhs_color);

                Color4f result;
                result.rgb() = op(lhs_color.rgb(), rhs_color.rgb());
                result.a = 1.0f;

                output->set_pixel(x, y, saturate(result));
            }
        }

        return output;
    }
开发者ID:EgoIncarnate,项目名称:appleseed,代码行数:35,代码来源:test_imagetools.cpp

示例9:

//--------------------------------------------------------------------------------------------------
/// 
//--------------------------------------------------------------------------------------------------
Color4ub::Color4ub(const Color4f& other)
{
    m_rgba[0] = static_cast<ubyte>(other.r()*255.0f);
    m_rgba[1] = static_cast<ubyte>(other.g()*255.0f);
    m_rgba[2] = static_cast<ubyte>(other.b()*255.0f);
    m_rgba[3] = static_cast<ubyte>(other.a()*255.0f);
}
开发者ID:akva2,项目名称:ResInsight,代码行数:10,代码来源:cvfColor4.cpp

示例10: fabs

void ImageDiffer::ComputePercentDiff() {
    for (UINT32 row = 0; row < m_diffData->GetHeight(); row++) {
        for (UINT32 col = 0; col < m_diffData->GetWidth(); col++) {
            Color4f color = m_diffData->GetPixel(row, col);
            color.r = fabs(color.r);
            color.g = fabs(color.g);
            color.b = fabs(color.b);
            color.a = fabs(color.a);

            FLOAT diffLuminance = color.ToLuminance();
            FLOAT refLuminance = MAX(
                                    m_ref->GetPixel(row, col).ToLuminance(),
                                    m_target->GetPixel(row, col).ToLuminance());

            Color4f displayColor;       
            FLOAT diff = 0;
            if (diffLuminance > EPSILON) {
                diff = diffLuminance / refLuminance;
                diff *= m_magnify;
                if (diff <= m_threshold) diff = 0;
            }

            displayColor = UIHelper::GetColorIntensity(diff);
            m_displayData->SetPixel(displayColor, row, col);
        }
    }
}
开发者ID:nongli,项目名称:Apollo,代码行数:27,代码来源:ImageDiffer.cpp

示例11: depth

//--------------------------------------------------------------------------------------------------
/// Draw a background rectangle using OGL 1.1 compatibility
//--------------------------------------------------------------------------------------------------
void InternalLegendRenderTools::renderBackgroundImmediateMode(OpenGLContext* oglContext,
                                                      const Vec2f& size,
                                                      const Color4f& backgroundColor,
                                                      const Color4f& backgroundFrameColor)
{
    RenderStateDepth depth(false);
    depth.applyOpenGL(oglContext);

    RenderStateLighting_FF lighting(false);
    lighting.applyOpenGL(oglContext);

    RenderStateBlending blend;
    blend.configureTransparencyBlending();
    blend.applyOpenGL(oglContext);

    // Frame vertices

    std::array<Vec3f, 4> vertexArray = {
        Vec3f(1       ,        1, 0.0f),
        Vec3f(size.x(),        1, 0.0f),
        Vec3f(size.x(), size.y(), 0.0f),
        Vec3f(1       , size.y(), 0.0f),
    };


    glColor4fv(backgroundColor.ptr());
    glBegin(GL_TRIANGLE_FAN);
    glVertex3fv(vertexArray[0].ptr());
    glVertex3fv(vertexArray[1].ptr());
    glVertex3fv(vertexArray[2].ptr());
    glVertex3fv(vertexArray[3].ptr());
    glEnd();

    // Render Line around

    {
        glColor4fv(backgroundFrameColor.ptr());
        glBegin(GL_LINES);
        glVertex3fv(vertexArray[0].ptr());
        glVertex3fv(vertexArray[1].ptr());
        glVertex3fv(vertexArray[1].ptr());
        glVertex3fv(vertexArray[2].ptr());
        glVertex3fv(vertexArray[2].ptr());
        glVertex3fv(vertexArray[3].ptr());
        glVertex3fv(vertexArray[3].ptr());
        glVertex3fv(vertexArray[0].ptr());
        glEnd();
    }

    // Reset render states

    RenderStateLighting_FF resetLighting;
    resetLighting.applyOpenGL(oglContext);
    RenderStateDepth resetDepth;
    resetDepth.applyOpenGL(oglContext);
    RenderStateBlending resetblend;
    resetblend.applyOpenGL(oglContext);
    CVF_CHECK_OGL(oglContext);
}
开发者ID:OPM,项目名称:ResInsight,代码行数:62,代码来源:cafInternalLegendRenderTools.cpp

示例12: set

//--------------------------------------------------------------------------------------------------
/// 
//--------------------------------------------------------------------------------------------------
void UniformFloat::set(const Color4f& value)
{
    m_type = FLOAT_VEC4;
    m_data.resize(4);
    m_data[0] = value.r();
    m_data[1] = value.g();
    m_data[2] = value.b();
    m_data[3] = value.a();
}
开发者ID:akva2,项目名称:ResInsight,代码行数:12,代码来源:cvfUniform.cpp

示例13: glColor4f

 void Triangle::draw(const Color4f& _color) const
 {
   glColor4f(_color.r(),_color.g(),_color.b(),_color.a());
   glBegin(GL_TRIANGLES);
     glNormal3f(COORDS(n_));
     glVertex3f(COORDS(v0()));
     glVertex3f(COORDS(v1()));
     glVertex3f(COORDS(v2()));
   glEnd();
 }
开发者ID:WilstonOreo,项目名称:cg2,代码行数:10,代码来源:Triangle.cpp

示例14: setRandomColors

void VRGeometry::setRandomColors() {
    GeoPnt3fPropertyRecPtr pos = dynamic_cast<GeoPnt3fProperty*>(mesh->getPositions());
	int N = pos->size();

	GeoVec4fPropertyRecPtr cols = GeoVec4fProperty::create();
	for (int i=0; i<N; i++) {
        Color4f c; c.setRandom();
        cols->addValue( c );
	}
    setColors(cols);
}
开发者ID:AntonChalakov,项目名称:polyvr,代码行数:11,代码来源:VRGeometry.cpp

示例15: blockSignals

void EdLevelPropertyColorField::doReadParams(void)
{
    blockSignals(true);

    keyButton()->disconnect();

    // Has Key
    if (_data->plug()) {
        keyButton()->setIcon(QIcon(":/images/key.png"));
                
        connect(    keyButton(),        SIGNAL(pressed()),
                    this,       SLOT(doKeyframePressed())    );
                    
    } else {
        keyButton()->setIcon(QIcon(":/images/blank.png"));
    }

    // Has Input
    if (_data->plug() && _data->plug()->has_incoming_connection()) {
        hasInputButton()->setIcon(QIcon(":/images/has_input.png"));
    } else {
        hasInputButton()->setIcon(QIcon(":/images/blank.png"));
    }

    // Has Output
    if (_data->plug() && _data->plug()->has_outgoing_connection()) {
        hasOutputButton()->setIcon(QIcon(":/images/has_output.png"));
    } else {
        hasOutputButton()->setIcon(QIcon(":/images/blank.png"));
    }

	TextBufferStream stream;
	_data->value(stream);
    
    Color4f val;
    stream >> val;
    
    Color4b val_b(val);
    
    _r->setValue(val_b.r_as_byte());
    _g->setValue(val_b.g_as_byte());
    _b->setValue(val_b.b_as_byte());
    _a->setValue(val_b.a_as_byte());
    
    _r2->setText( MoreStrings::cast_to_string(val.r_as_float()).c_str() );
    _g2->setText( MoreStrings::cast_to_string(val.g_as_float()).c_str() );
    _b2->setText( MoreStrings::cast_to_string(val.b_as_float()).c_str() );
    _a2->setText( MoreStrings::cast_to_string(val.a_as_float()).c_str() );

    doColorChange(0);
    blockSignals(false);
}
开发者ID:9heart,项目名称:DT3,代码行数:52,代码来源:EdLevelPropertyColorField.cpp


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