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


C++ setActive函数代码示例

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


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

示例1: err

void RenderTarget::draw(const Vertex* vertices, std::size_t vertexCount,
                        PrimitiveType type, const RenderStates& states)
{
    // Nothing to draw?
    if (!vertices || (vertexCount == 0))
        return;

    // GL_QUADS is unavailable on OpenGL ES
    #ifdef SFML_OPENGL_ES
        if (type == Quads)
        {
            err() << "sf::Quads primitive type is not supported on OpenGL ES platforms, drawing skipped" << std::endl;
            return;
        }
        #define GL_QUADS 0
    #endif

    if (setActive(true))
    {
        // First set the persistent OpenGL states if it's the very first call
        if (!m_cache.glStatesSet)
            resetGLStates();

        // Check if the vertex count is low enough so that we can pre-transform them
        bool useVertexCache = (vertexCount <= StatesCache::VertexCacheSize);
        if (useVertexCache)
        {
            // Pre-transform the vertices and store them into the vertex cache
            for (std::size_t i = 0; i < vertexCount; ++i)
            {
                Vertex& vertex = m_cache.vertexCache[i];
                vertex.position = states.transform * vertices[i].position;
                vertex.color = vertices[i].color;
                vertex.texCoords = vertices[i].texCoords;
            }

            // Since vertices are transformed, we must use an identity transform to render them
            if (!m_cache.useVertexCache)
                applyTransform(Transform::Identity);
        }
        else
        {
            applyTransform(states.transform);
        }

        // Apply the view
        if (m_cache.viewChanged)
            applyCurrentView();

        // Apply the blend mode
        if (states.blendMode != m_cache.lastBlendMode)
            applyBlendMode(states.blendMode);

        // Apply the texture
        Uint64 textureId = states.texture ? states.texture->m_cacheId : 0;
        if (textureId != m_cache.lastTextureId)
            applyTexture(states.texture);

        // Apply the shader
        if (states.shader)
            applyShader(states.shader);

        // If we pre-transform the vertices, we must use our internal vertex cache
        if (useVertexCache)
        {
            // ... and if we already used it previously, we don't need to set the pointers again
            if (!m_cache.useVertexCache)
                vertices = m_cache.vertexCache;
            else
                vertices = NULL;
        }

        // Check if texture coordinates array is needed, and update client state accordingly
        bool enableTexCoordsArray = (states.texture || states.shader);
        if (enableTexCoordsArray != m_cache.texCoordsArrayEnabled)
        {
            if (enableTexCoordsArray)
                glCheck(glEnableClientState(GL_TEXTURE_COORD_ARRAY));
            else
                glCheck(glDisableClientState(GL_TEXTURE_COORD_ARRAY));
            m_cache.texCoordsArrayEnabled = enableTexCoordsArray;
        }

        // Setup the pointers to the vertices' components
        if (vertices)
        {
            const char* data = reinterpret_cast<const char*>(vertices);
            glCheck(glVertexPointer(2, GL_FLOAT, sizeof(Vertex), data + 0));
            glCheck(glColorPointer(4, GL_UNSIGNED_BYTE, sizeof(Vertex), data + 8));
            if (enableTexCoordsArray)
                glCheck(glTexCoordPointer(2, GL_FLOAT, sizeof(Vertex), data + 12));
        }

        // Find the OpenGL primitive type
        static const GLenum modes[] = {GL_POINTS, GL_LINES, GL_LINE_STRIP, GL_TRIANGLES,
                                       GL_TRIANGLE_STRIP, GL_TRIANGLE_FAN, GL_QUADS};
        GLenum mode = modes[type];

        // Draw the primitives
        glCheck(glDrawArrays(mode, 0, vertexCount));
//.........这里部分代码省略.........
开发者ID:Chaosus,项目名称:SFML,代码行数:101,代码来源:RenderTarget.cpp

示例2: setActive

GlContext::~GlContext()
{
    // Deactivate the context before killing it, unless we're inside Cleanup()
    if (sharedContext)
        setActive(false);
}
开发者ID:SuitEmUp,项目名称:SuitEmUp,代码行数:6,代码来源:GlContext.cpp

示例3: pts_rel

int H264::handlePacket(AVPacket* packet)
{
	int gotFrame;
	int bytes;
	H264Context* h = (H264Context*)stream()->codec->priv_data;
	
	// Transform timestamps to relative timestamps
	packet->dts = pts_rel(packet->dts);
	packet->pts = pts_rel(packet->pts);
	
	if(m_decoding && !m_syncing)
		parseNAL(packet->data, packet->size);
	
	if(!m_decoding)
	{
		if(m_nc && m_nc->time - packet->pts < m_startDecodeOffset)
		{
			log_debug("Switching decoder on at PTS %'10lld (m_nc: %'10lld)",
				packet->pts, m_nc->time);
			m_decoding = true;
			
			avcodec_flush_buffers(stream()->codec);
		}
	}
	
	if(m_decoding)
	{
		if(avcodec_decode_video2(stream()->codec, &m_frame, &gotFrame, packet) < 0)
			return error("Could not decode packet");
	}
	
	if(!m_encoding && m_nc)
	{
		if(m_nc->direction == CutPoint::OUT && m_nc->time < packet->dts)
		{
			m_decoding = false;
			m_isCutout = true;
			
			int64_t current_time = m_nc->time;
			m_nc = cutList().nextCutPoint(packet->dts);
			
			if(m_nc)
				setTotalCutout(m_nc->time - (current_time - totalCutout()));
			else
				setActive(false); // last cutpoint reached
		}
		else if(m_nc->direction == CutPoint::IN && m_nc->time <= packet->dts)
		{
			m_encoding = true;
			m_encFrameCount = 0;
			
			log_debug("Opening encoder for frame with PTS %'10lld", packet->dts);

			AVDictionary* opts = 0;
			av_dict_set(&opts, "profile", "main", 0);
			av_dict_set(&opts, "preset", "ultrafast", 0);
			
			if(avcodec_open2(outputStream()->codec, m_codec, &opts) != 0)
				return error("Could not open encoder");
		}
	}
	
	if(m_encoding && m_encFrameCount > 20 && packet->flags & AV_PKT_FLAG_KEY && h->s.current_picture_ptr)
	{
		m_syncing = true;
		m_syncPoint = packet->pts;
		
		log_debug("SYNC: start with keyframe packet PTS %'10lld", m_syncPoint);
// 		log_debug("SYNC: frame_num of first original frame is %d",
// 				h->s.current_picture_ptr->frame_num
// 		);
	}

	if(m_syncing)
	{
		log_debug("decode=%d, gotFrame=%d, keyframe=%d, t=%d", m_decoding, gotFrame, m_frame.key_frame, m_frame.pict_type);
	}
	
	if(m_syncing && gotFrame && m_frame.pict_type == 1)
	{
		// Flush out encoder
		while(1)
		{
			log_debug("SYNC: Flushing out encoder");
			bytes = avcodec_encode_video(
				outputStream()->codec,
				m_encodeBuffer, ENCODE_BUFSIZE,
				NULL
			);
			outputStream()->codec->has_b_frames = 6;
			
			if(!bytes)
				break;
			
			int64_t pts = av_rescale_q(outputStream()->codec->coded_frame->pts,
					outputStream()->codec->time_base, outputStream()->time_base
				);
			
			if(pts + totalCutout() >= m_syncPoint)
			{
//.........这里部分代码省略.........
开发者ID:kostyll,项目名称:justcutit,代码行数:101,代码来源:h264.cpp

示例4: setActive

void IrcChannelPrivate::disconnected()
{
    setActive(false);
}
开发者ID:Mudlet,项目名称:Mudlet,代码行数:4,代码来源:ircchannel.cpp

示例5: AMenu

MainMenu::MainMenu(AWidget *parent) :
  AMenu(parent)
{
  _start = new Button(this);
  _pvp = new Button(this);
  _pve = new Button(this);
  _5breakable = new Button(this);
  _doubleThree = new Button(this);

  _start->setSize(sf::Vector2f(200, 50));
  _start->setPosition(sf::Vector2f(150, 225));
  _start->setBackgroundTexture("../Assets/button_unselect.png");
  _start->setFont("../Assets/fontBambo.ttf");
  _start->setFontSize(30);
  _start->setText("START");
  _start->setAction([this] {
	  Arbitre::updateRules(_doubleThree->isActive(), _5breakable->isActive());
	  if (_pvp->isActive())
		  getGameInstance()->reset<Human>();
	  else
		  getGameInstance()->reset<AxelAI>();
	  setActive(false);
  });
  _pvp->setSize(sf::Vector2f(200, 50));
  _pvp->setPosition(sf::Vector2f(25, 25));
  _pvp->setBackgroundTexture("../Assets/button_select.png");
  _pvp->setFont("../Assets/fontBambo.ttf");
  _pvp->setFontSize(30);
  _pvp->setText("PVP");
  _pvp->setActive(true);
  _pvp->setAction([this] {
	  _pvp->setBackgroundTexture("../Assets/button_select.png");
	  _pvp->setActive(true);
	  _pve->setBackgroundTexture("../Assets/button_unselect.png");
	  _pve->setActive(false);
  });
  _pve->setSize(sf::Vector2f(200, 50));
  _pve->setPosition(sf::Vector2f(275, 25));
  _pve->setBackgroundTexture("../Assets/button_unselect.png");
  _pve->setFont("../Assets/fontBambo.ttf");
  _pve->setFontSize(30);
  _pve->setText("PVE");
  _pve->setActive(false);
  _pve->setAction([this] {
	  _pvp->setBackgroundTexture("../Assets/button_unselect.png");
	  _pvp->setActive(false);
	  _pve->setBackgroundTexture("../Assets/button_select.png");
	  _pve->setActive(true);
  });
  _5breakable->setSize(sf::Vector2f(200, 50));
  _5breakable->setPosition(sf::Vector2f(25, 125));
  _5breakable->setBackgroundTexture("../Assets/button_unselect.png");
  _5breakable->setFont("../Assets/fontBambo.ttf");
  _5breakable->setFontSize(30);
  _5breakable->setText("5 Cassables");
  _5breakable->setActive(false);
  _5breakable->setAction([this] {
	  _5breakable->setBackgroundTexture((_5breakable->isActive() ? "../Assets/button_unselect.png" : "../Assets/button_select.png" ));
	  _5breakable->setActive(!_5breakable->isActive());
  });
  _doubleThree->setSize(sf::Vector2f(200, 50));
  _doubleThree->setPosition(sf::Vector2f(275, 125));
  _doubleThree->setBackgroundTexture("../Assets/button_unselect.png");
  _doubleThree->setFont("../Assets/fontBambo.ttf");
  _doubleThree->setFontSize(30);
  _doubleThree->setText("Double Trois");
  _doubleThree->setActive(false);
  _doubleThree->setAction([this] {
	  _doubleThree->setBackgroundTexture((_doubleThree->isActive() ? "../Assets/button_unselect.png" : "../Assets/button_select.png" ));
	  _doubleThree->setActive(!_doubleThree->isActive());
  });

  setPosition(sf::Vector2f(149, 249));
  setSize(sf::Vector2f(500, 300));
  setBackgroundColor(sf::Color(0, 0, 0, 127));
}
开发者ID:Mulverick,项目名称:Gomoku,代码行数:76,代码来源:MainMenu.cpp

示例6: setActive

bool QwtNullPaintDevice::PaintEngine::begin( QPaintDevice * )
{
    setActive( true );
    return true;
}
开发者ID:CaptainFalco,项目名称:OpenPilot,代码行数:5,代码来源:qwt_null_paintdevice.cpp

示例7: newDef

void QgsDataDefinedButton::updateGui()
{
  QString oldDef = mCurrentDefinition;
  QString newDef( "" );
  bool hasExp = !getExpression().isEmpty();
  bool hasField = !getField().isEmpty();

  if ( useExpression() && !hasExp )
  {
    setActive( false );
    setUseExpression( false );
  }
  else if ( !useExpression() && !hasField )
  {
    setActive( false );
  }

  QIcon icon = mIconDataDefine;
  QString deftip = tr( "undefined" );
  if ( useExpression() && hasExp )
  {
    icon = isActive() ? mIconDataDefineExpressionOn : mIconDataDefineExpression;
    newDef = deftip = getExpression();

    QgsExpression exp( getExpression() );
    if ( exp.hasParserError() )
    {
      setActive( false );
      icon = mIconDataDefineExpressionError;
      deftip = tr( "Parse error: %1" ).arg( exp.parserErrorString() );
      newDef = "";
    }
  }
  else if ( !useExpression() && hasField )
  {
    icon = isActive() ? mIconDataDefineOn : mIconDataDefine;
    newDef = deftip = getField();

    if ( !mFieldNameList.contains( getField() ) )
    {
      setActive( false );
      icon = mIconDataDefineError;
      deftip = tr( "'%1' field missing" ).arg( getField() );
      newDef = "";
    }
  }

  setIcon( icon );

  // update and emit current definition
  if ( newDef != oldDef )
  {
    mCurrentDefinition = newDef;
    emit dataDefinedChanged( mCurrentDefinition );
  }

  // build full description for tool tip and popup dialog
  mFullDescription = tr( "<b><u>Data defined override</u></b><br>" );

  mFullDescription += tr( "<b>Active: </b>%1&nbsp;&nbsp;&nbsp;<i>(ctrl|right-click toggles)</i><br>" ).arg( isActive() ? tr( "yes" ) : tr( "no" ) );

  if ( !mUsageInfo.isEmpty() )
  {
    mFullDescription += tr( "<b>Usage:</b><br>%1<br>" ).arg( mUsageInfo );
  }

  if ( !mInputDescription.isEmpty() )
  {
    mFullDescription += tr( "<b>Expected input:</b><br>%1<br>" ).arg( mInputDescription );
  }

  if ( !mDataTypesString.isEmpty() )
  {
    mFullDescription += tr( "<b>Valid input types:</b><br>%1<br>" ).arg( mDataTypesString );
  }

  QString deftype( "" );
  if ( deftip != tr( "undefined" ) )
  {
    deftype = QString( " (%1)" ).arg( useExpression() ? tr( "expression" ) : tr( "field" ) );
  }

  // truncate long expressions, or tool tip may be too wide for screen
  if ( deftip.length() > 75 )
  {
    deftip.truncate( 75 );
    deftip.append( "..." );
  }

  mFullDescription += tr( "<b>Current definition %1:</b><br>%2" ).arg( deftype ).arg( deftip );

  setToolTip( mFullDescription );

}
开发者ID:Aladar64,项目名称:QGIS,代码行数:94,代码来源:qgsdatadefinedbutton.cpp

示例8: setActive

void QgsDataDefinedButton::menuActionTriggered( QAction* action )
{
  if ( action == mActionActive )
  {
    setActive( mActionActive->data().toBool() );
    updateGui();
  }
  else if ( action == mActionDescription )
  {
    showDescriptionDialog();
  }
  else if ( action == mActionExpDialog )
  {
    showExpressionDialog();
  }
  else if ( action == mActionExpression )
  {
    setUseExpression( true );
    setActive( true );
    updateGui();
  }
  else if ( action == mActionCopyExpr )
  {
    QApplication::clipboard()->setText( getExpression() );
  }
  else if ( action == mActionPasteExpr )
  {
    QString exprString = QApplication::clipboard()->text();
    if ( !exprString.isEmpty() )
    {
      setExpression( exprString );
      setUseExpression( true );
      setActive( true );
      updateGui();
    }
  }
  else if ( action == mActionClearExpr )
  {
    // only deactivate if defined expression is being used
    if ( isActive() && useExpression() )
    {
      setUseExpression( false );
      setActive( false );
    }
    setExpression( QString( "" ) );
    updateGui();
  }
  else if ( mFieldsMenu->actions().contains( action ) )  // a field name clicked
  {
    if ( action->isEnabled() )
    {
      if ( getField() != action->text() )
      {
        setField( action->data().toString() );
      }
      setUseExpression( false );
      setActive( true );
      updateGui();
    }
  }
}
开发者ID:Aladar64,项目名称:QGIS,代码行数:61,代码来源:qgsdatadefinedbutton.cpp

示例9: setVerticalSyncEnabled

void Window::setVerticalSyncEnabled(bool enabled)
{
    if (setActive())
        m_context->setVerticalSyncEnabled(enabled);
}
开发者ID:GrimshawA,项目名称:Nephilim,代码行数:5,代码来源:SFMLWindow.cpp

示例10: setActive

/*
 * Adds new command to queue of commands.
 * when the chainQueues are all empty,
 * a command is popped, locked, and chopped.
 * CAUTION: Will DELETE the enqueued command,
 * so do not resend commands. One use per command.
 * Only one BodyJointCommand can be enqueued at
 * a time, even if they deal with different joints or chains.
 */
void ScriptedProvider::setCommand(const BodyJointCommand::ptr command) {
    bodyCommandQueue.push(command);
    setActive();
}
开发者ID:CheddarB,项目名称:nbites,代码行数:13,代码来源:ScriptedProvider.cpp

示例11: showVideoTutorial

void Tutorial::showVideoTutorial()
{
    if (_video)
    {
        auto delay0 = DelayTime::create(2.f);
        
        auto idleRightCallback = CallFunc::create([this]()
        {
            Utility::fadeInNodeWithTime(_video, tutorialDefs::FADE_TIME);
            auto idleAnimation = _video->getAnimationWithName("idle");
            if (idleAnimation)
            {
                idleAnimation->setActive(true);
                _video->setScaleX(1);
                idleAnimation->restart();
            }
        });
        
        auto delay1 = DelayTime::create(2.f);
        
        auto playRightCallback = CallFunc::create([this]()
        {
            auto playAnimation = _video->getAnimationWithName("play");
            if (playAnimation)
            {
                playAnimation->setActive(true);
                playAnimation->restart();
            }
        });
        
        auto delay2 = DelayTime::create(7.f);
        
        auto fadeOutCallback = CallFunc::create([this]()
        {
            Utility::fadeOutNodeWithTime(_video, 2.f);
        });
        
        auto delay3 = DelayTime::create(2.f);
        
        auto idleLeftCallback = CallFunc::create([this]()
        {
            Utility::fadeInNodeWithTime(_video, tutorialDefs::FADE_TIME);
            auto idleAnimation = _video->getAnimationWithName("idle");
            if (idleAnimation)
            {
                idleAnimation->setActive(true);
                _video->setScaleX(-1);
                idleAnimation->restart();
            }
        });
        
        auto delay4 = DelayTime::create(1.f);
        
        auto playLeftCallback = CallFunc::create([this]()
        {
            auto playAnimation = _video->getAnimationWithName("play");
            if (playAnimation)
            {
                playAnimation->setActive(true);
                playAnimation->restart();
            }
        });
        
        auto sequence = Sequence::create(delay0, idleRightCallback, delay1, playRightCallback, delay2, fadeOutCallback, delay3, idleLeftCallback, delay4, playLeftCallback, delay2, fadeOutCallback, NULL);
        
        auto action = RepeatForever::create(sequence);
        action->setTag(tutorialDefs::VIDEO_ANIMATION_TAG);
        
        _video->runAction(action);
    }
}
开发者ID:iacopocheccacci,项目名称:cocos2dx-helloWorld-tvOS,代码行数:71,代码来源:Tutorial.cpp

示例12: setActive

GradientLineQmlAdaptor::GradientLineQmlAdaptor(QWidget *parent) :
    QmlEditorWidgets::GradientLine(parent)
{
    setActive(false);
    connect(this, SIGNAL(gradientChanged()), this, SLOT(writeGradient()));
}
开发者ID:KDE,项目名称:android-qt-creator,代码行数:6,代码来源:gradientlineqmladaptor.cpp

示例13: setActive

void QPalette::setNormal( const QColorGroup &g )
{
    setActive( g );
}
开发者ID:opieproject,项目名称:qte-opie,代码行数:4,代码来源:qpalette.cpp

示例14: setActive

void SoundManager2::activate( void ){
    setActive(true);
}
开发者ID:shadowcat-productions,项目名称:battleshape,代码行数:3,代码来源:SoundManager2.cpp

示例15: getViewport

void PlaneMoveManipulator::mouseButtonPress(const UInt16 button,
                                   const Int16  x,
                                   const Int16  y     )
{
    Transform *t = dynamic_cast<Transform *>(getTarget()->getCore());
    
    if (t == NULL)
    {
        SWARNING << "PlaneMoveManipulator::mouseButtonPress() target is not a Transform!" << endLog;
        return;
    }

    SLOG << "PlaneMoveManipulator::mouseButtonPress() button=" << button << " x=" << x << " y=" << y  << std::endl << endLog;

    OSG::Line viewray;
    getViewport()->getCamera()->calcViewRay(viewray, x, y, *getViewport());

    OSG::Node *scene = getTarget();
    while (scene->getParent() != 0)
    {
        scene = scene->getParent();
    }

    OSG::IntersectActionRefPtr act = OSG::IntersectAction::create();
    act->setLine( viewray );
    act->apply( scene );

    SLOG << "PlaneMoveManipulator::mouseButtonPress() viewray=" << viewray << " scene=" << scene << endLog;
 
    if ( act->didHit() )
    {
        SLOG << "PlaneMoveManipulator::mouseButtonPress() hit! at " << act->getHitPoint() << endLog;

        // Get manipulator plane into world space
        OSG::Matrix m = getTarget()->getToWorld();

        Vec3f      translation;       // for matrix decomposition
        Quaternion rotation;
        Vec3f      scaleFactor;
        Quaternion scaleOrientation;

        t->getMatrix().getTransform(translation, rotation, scaleFactor,
                                    scaleOrientation);

        Vec3f rot_axis;
        rotation.multVec(Vec3f(0,1,0), rot_axis);

        Plane pl(rot_axis, act->getHitPoint());

        SLOG << "PlaneMoveManipulator::mouseButtonPress() world plane: " << pl << endLog;
 
        setClickPoint(act->getHitPoint());

        setBaseTranslation(translation);
        setBaseRotation(rotation);
        
        setActive(true);
    }

    act = NULL;
}
开发者ID:Himbeertoni,项目名称:OpenSGDevMaster,代码行数:61,代码来源:OSGPlaneMoveManipulator.cpp


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