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


C++ std::map类代码示例

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


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

示例1: scanInstruction

void AArch64A57FPLoadBalancing::
scanInstruction(MachineInstr *MI, unsigned Idx, 
                std::map<unsigned, Chain*> &ActiveChains,
                std::set<std::unique_ptr<Chain>> &AllChains) {
  // Inspect "MI", updating ActiveChains and AllChains.

  if (isMul(MI)) {

    for (auto &I : MI->uses())
      maybeKillChain(I, Idx, ActiveChains);
    for (auto &I : MI->defs())
      maybeKillChain(I, Idx, ActiveChains);

    // Create a new chain. Multiplies don't require forwarding so can go on any
    // unit.
    unsigned DestReg = MI->getOperand(0).getReg();

    DEBUG(dbgs() << "New chain started for register "
          << TRI->getName(DestReg) << " at " << *MI);

    auto G = llvm::make_unique<Chain>(MI, Idx, getColor(DestReg));
    ActiveChains[DestReg] = G.get();
    AllChains.insert(std::move(G));

  } else if (isMla(MI)) {

    // It is beneficial to keep MLAs on the same functional unit as their
    // accumulator operand.
    unsigned DestReg  = MI->getOperand(0).getReg();
    unsigned AccumReg = MI->getOperand(3).getReg();

    maybeKillChain(MI->getOperand(1), Idx, ActiveChains);
    maybeKillChain(MI->getOperand(2), Idx, ActiveChains);
    if (DestReg != AccumReg)
      maybeKillChain(MI->getOperand(0), Idx, ActiveChains);

    if (ActiveChains.find(AccumReg) != ActiveChains.end()) {
      DEBUG(dbgs() << "Chain found for accumulator register "
            << TRI->getName(AccumReg) << " in MI " << *MI);

      // For simplicity we only chain together sequences of MULs/MLAs where the
      // accumulator register is killed on each instruction. This means we don't
      // need to track other uses of the registers we want to rewrite.
      //
      // FIXME: We could extend to handle the non-kill cases for more coverage.
      if (MI->getOperand(3).isKill()) {
        // Add to chain.
        DEBUG(dbgs() << "Instruction was successfully added to chain.\n");
        ActiveChains[AccumReg]->add(MI, Idx, getColor(DestReg));
        // Handle cases where the destination is not the same as the accumulator.
        if (DestReg != AccumReg) {
          ActiveChains[DestReg] = ActiveChains[AccumReg];
          ActiveChains.erase(AccumReg);
        }
        return;
      }

      DEBUG(dbgs() << "Cannot add to chain because accumulator operand wasn't "
            << "marked <kill>!\n");
      maybeKillChain(MI->getOperand(3), Idx, ActiveChains);
    }

    DEBUG(dbgs() << "Creating new chain for dest register "
          << TRI->getName(DestReg) << "\n");
    auto G = llvm::make_unique<Chain>(MI, Idx, getColor(DestReg));
    ActiveChains[DestReg] = G.get();
    AllChains.insert(std::move(G));

  } else {

    // Non-MUL or MLA instruction. Invalidate any chain in the uses or defs
    // lists.
    for (auto &I : MI->uses())
      maybeKillChain(I, Idx, ActiveChains);
    for (auto &I : MI->defs())
      maybeKillChain(I, Idx, ActiveChains);

  }
}
开发者ID:A2-Collaboration,项目名称:root,代码行数:79,代码来源:AArch64A57FPLoadBalancing.cpp

示例2: load_from_xml

/// Implements Base::load_from_xml()
void Joint::load_from_xml(XMLTreeConstPtr node, std::map<std::string, BasePtr>& id_map)
{
  std::map<std::string, BasePtr>::const_iterator id_iter;

  // ***********************************************************************
  // don't verify that the node is correct, b/c Joint will 
  // be subclassed
  // ***********************************************************************
  
  // load the parent data
  Visualizable::load_from_xml(node, id_map);

  // read the lower limits, if given
  const XMLAttrib* lolimit_attr = node->get_attrib("lower-limits");
  if (lolimit_attr)
    lolimit_attr->get_vector_value(lolimit);

  // read the upper limits, if given
  const XMLAttrib* hilimit_attr = node->get_attrib("upper-limits");
  if (hilimit_attr)
    hilimit_attr->get_vector_value(hilimit);

  // read the maximum actuator force, if given
  const XMLAttrib* maxforce_attr = node->get_attrib("max-forces");
  if (maxforce_attr)
    maxforce_attr->get_vector_value(maxforce);

  // read the joint positions, if given
  const XMLAttrib* q_attr = node->get_attrib("q");
  if (q_attr)
    q_attr->get_vector_value(q);
  else
    q.set_zero(num_dof());

  // read the joint velocities, if given
  const XMLAttrib* qd_attr = node->get_attrib("qd");
  if (qd_attr)
    qd_attr->get_vector_value(qd);

  // read the joint positions, if given
  const XMLAttrib* q_init_attr = node->get_attrib("q-tare");
  if (q_init_attr)
  {
    _determine_q_tare = false;
    q_init_attr->get_vector_value(_q_tare);
  }
  else
    _determine_q_tare = true;

  // read the Coulomb friction coefficient, if given
  const XMLAttrib* fc_attr = node->get_attrib("coulomb-friction-coeff");
  if (fc_attr)
    mu_fc = fc_attr->get_real_value();

  // read the viscous friction coefficient, if given
  const XMLAttrib* fv_attr = node->get_attrib("viscous-friction-coeff");
  if (fv_attr)
    mu_fv = fv_attr->get_real_value();

  // read the restitution coefficient, if given
  const XMLAttrib* resti_attr = node->get_attrib("restitution-coeff");
  if (resti_attr)
    limit_restitution = resti_attr->get_real_value();

  // read the articulated body, if given
  const XMLAttrib* ab_attr = node->get_attrib("articulated-body-id");
  if (ab_attr)
  {
    // get the ID
    const std::string& ID = ab_attr->get_string_value();

    // look for the ID -- only warn if it is not found
    if ((id_iter = id_map.find(ID)) == id_map.end())
    {
      #ifdef _DEBUG_XML_
      std::cout << "Joint::load_from_xml() warning - ";
      std::cout << "articulated body" << std::endl << "  '" << ID << "' not ";
      std::cout << "found" << std::endl << "  ** This warning could result ";
      std::cout << "from joints being constructed before articulated bodies ";
      std::cout << std::endl << "    and may not be serious..." << std::endl; 
      std::cout << "  offending node: " << std::endl << *node;
      #endif
    }
    else
      set_articulated_body(boost::dynamic_pointer_cast<RCArticulatedBody>(id_iter->second));
  }

  // read the inboard link id, if given
  const XMLAttrib* inboard_attr = node->get_attrib("inboard-link-id");
  if (inboard_attr)
  {
    // get the ID of the inboard link
    const std::string& id = inboard_attr->get_string_value();

    // complain if the link not found but don't treat it as an error-- there 
    // are circular dependencies
    if ((id_iter = id_map.find(id)) == id_map.end())
    {
      #ifdef _DEBUG_XML_
//.........这里部分代码省略.........
开发者ID:hsu,项目名称:Moby,代码行数:101,代码来源:Joint.cpp

示例3: Stream_id


//.........这里部分代码省略.........
        }
        printf("\n");
    }
    /// returns the data in the stream
    /** The returned data is located in a static buffer shared by all streams
     *  the data is valid until the next call to get_buffer()
     */
    unsigned char *get_buffer()
    {
        int p=0;
        for (std::list<Data_segment>::iterator it = m_segments.begin();
                it != m_segments.end(); it ++)
        {
            for (unsigned int i=0; i< it->m_datasize; i++)
            {
                m_buffer[p++]=it->m_data[i];
                if (p>=0xffff)
                    return m_buffer;
            }
        }
        return m_buffer;
    }
private:
    unsigned int                m_seq;
    int                     m_ser;
    bool                    m_content;
    bool                    m_nseq;
    std::list<Data_segment> m_segments;

    static unsigned char          m_buffer[0x10000];
};
unsigned char Stream::m_buffer[0x10000];

std::map<Stream_id,Stream> g_tcp_streams;



/// assemble_tcp builds datastreams out of tcp packets
/** TCP packets are inserted into streams. When the streams are closed
 *  the contained data is returned as a pointer the data
 *  it is up to the caller to free() the memory returned.
 */
unsigned char *
assemble_tcp (
    Payload &payload,
    in6addr_t *src_ip,
    in6addr_t *dst_ip,
    unsigned short src_port,
    unsigned short dst_port,
    unsigned int *rest,
    unsigned int seq,
    unsigned char *data,
    int len,
    char syn,
    char fin,
    char rst,
    char ack)
{
    Stream_id id ( *src_ip, *dst_ip, src_port, dst_port );
    Stream   &str = g_tcp_streams[id];
    bool data_avail = false;

    if (!str.has_content())
    {
        Data_segment seg( data, len);
        str.add( syn,seq, seg);
开发者ID:pawal,项目名称:PacketQ,代码行数:67,代码来源:tcp.cpp

示例4: uthread_terminate

int uthread_terminate(int tid)
{
	blockTimer();
	if(tid == 0)//if true: exits program
	{
//		terminate all threads:
		std::map<int, Thread*>::iterator threadIt;
		for (threadIt = gThreads.begin(); threadIt != gThreads.end(); ++threadIt)
		{
			Thread* tmp;
			switch(threadIt->second->getState() )
			{
			case(READY) :
					gReady.remove(threadIt->second->getID() );
					tmp = gThreads[threadIt->second->getID() ];
					gThreads.erase(threadIt);
					delete tmp;
					break;
			case(RUNNING) :
					gThreads.erase(threadIt);
//					gRunning = NULL;
					break;
			case(BLOCKED) :
					gBlocked.erase(threadIt->second->getID() );
					tmp = gThreads[threadIt->second->getID() ];
					gThreads.erase(threadIt);
					delete tmp;
					break;
			default :
				break;
			}

		}
		delete gRunning;
		gRunning = NULL;
		resumeTimer();
		exit(0);
	}
	if(gThreads.count(tid) == 0) //if true: thread doesn't exist
	{
		std::cerr<< TERMINATE_ERR << std::endl;
		resumeTimer();
		return FAILURE;
	}
	if(gThreads[tid]->getState() == RUNNING)//if true: deletes thread +  jumps to next thread
	{
		switchThreads(TERMINATED);
	}
//	if in ready or blocked: remove from lists (gReady/gBlocked + gThreads), and delete thread
	Thread* tmp = gThreads[tid];
	if (tmp->getState() == READY )
	{
		gReady.remove(tid);
	}
	if (tmp->getState() == BLOCKED)
	{
		gBlocked.erase(tid);
	}
	gThreads.erase(tid);
	gAvailableID.push(tid);
	delete tmp;
	resumeTimer();
	return SUCCESS;
}
开发者ID:OsoFlaco,项目名称:OS,代码行数:64,代码来源:uthreads.cpp

示例5: main

int main()
{
    {
        typedef std::pair<const int, double> V;
        V ar[] =
        {
            V(1, 1.5),
            V(2, 2.5),
            V(3, 3.5),
            V(4, 4.5),
            V(5, 5.5),
            V(7, 7.5),
            V(8, 8.5),
        };
        std::map<int, double> m(ar, ar+sizeof(ar)/sizeof(ar[0]));
        assert(m.size() == 7);
        assert(m.at(1) == 1.5);
        m.at(1) = -1.5;
        assert(m.at(1) == -1.5);
        assert(m.at(2) == 2.5);
        assert(m.at(3) == 3.5);
        assert(m.at(4) == 4.5);
        assert(m.at(5) == 5.5);
        try
        {
            m.at(6);
            assert(false);
        }
        catch (std::out_of_range&)
        {
        }
        assert(m.at(7) == 7.5);
        assert(m.at(8) == 8.5);
        assert(m.size() == 7);
    }
    {
        typedef std::pair<const int, double> V;
        V ar[] =
        {
            V(1, 1.5),
            V(2, 2.5),
            V(3, 3.5),
            V(4, 4.5),
            V(5, 5.5),
            V(7, 7.5),
            V(8, 8.5),
        };
        const std::map<int, double> m(ar, ar+sizeof(ar)/sizeof(ar[0]));
        assert(m.size() == 7);
        assert(m.at(1) == 1.5);
        assert(m.at(2) == 2.5);
        assert(m.at(3) == 3.5);
        assert(m.at(4) == 4.5);
        assert(m.at(5) == 5.5);
        try
        {
            m.at(6);
            assert(false);
        }
        catch (std::out_of_range&)
        {
        }
        assert(m.at(7) == 7.5);
        assert(m.at(8) == 8.5);
        assert(m.size() == 7);
    }
}
开发者ID:32bitmicro,项目名称:libcxx,代码行数:67,代码来源:at.pass.cpp

示例6: while

//--------------------------------------------------------------------------------------------------
/// 
//--------------------------------------------------------------------------------------------------
void RigWellLogExtractor::populateReturnArrays(std::map<RigMDCellIdxEnterLeaveKey, HexIntersectionInfo > &uniqueIntersections)
{
    // For same MD and same cell, remove enter/leave pairs, as they only touches the wellpath, and should not contribute.
    {
        std::map<RigMDCellIdxEnterLeaveKey, HexIntersectionInfo >::iterator it1 = uniqueIntersections.begin();
        std::map<RigMDCellIdxEnterLeaveKey, HexIntersectionInfo >::iterator it2 = uniqueIntersections.begin();

        std::vector<std::map<RigMDCellIdxEnterLeaveKey, HexIntersectionInfo >::iterator> iteratorsToIntersectonsToErase;

        while (it2 != uniqueIntersections.end())
        {
            ++it2;
            if (it2 != uniqueIntersections.end())
            {
                if (RigWellLogExtractionTools::isEqualDepth(it1->first.measuredDepth, it2->first.measuredDepth))
                {
                    if (it1->first.hexIndex == it2->first.hexIndex)
                    {
                        // Remove the two from the map, as they just are a touch of the cell surface
                        CVF_TIGHT_ASSERT(!it1->first.isEnteringCell && it2->first.isEnteringCell);

                        iteratorsToIntersectonsToErase.push_back(it1);
                        iteratorsToIntersectonsToErase.push_back(it2);
                    }
                }
            }
            ++it1;
        }

        // Erase all the intersections that is not needed
        for (size_t erItIdx = 0; erItIdx < iteratorsToIntersectonsToErase.size(); ++erItIdx)
        {
            uniqueIntersections.erase(iteratorsToIntersectonsToErase[erItIdx]);
        }
    }

    // Copy the map into a different sorting regime, with enter leave more significant than cell index

    std::map<RigMDEnterLeaveCellIdxKey, HexIntersectionInfo > sortedUniqueIntersections;
    {
        std::map<RigMDCellIdxEnterLeaveKey, HexIntersectionInfo >::iterator it = uniqueIntersections.begin();
        while (it != uniqueIntersections.end())
        {
            sortedUniqueIntersections.insert(std::make_pair(RigMDEnterLeaveCellIdxKey(it->first.measuredDepth, it->first.isEnteringCell, it->first.hexIndex),
                it->second));
            ++it;
        }
    }

    // Add points for the endpoint of the wellpath, if it starts/ends inside a cell
    {
        // Add an intersection for the well startpoint that is inside the first cell
        std::map<RigMDEnterLeaveCellIdxKey, HexIntersectionInfo >::iterator it = sortedUniqueIntersections.begin();
        if (it != sortedUniqueIntersections.end() && !it->first.isEnteringCell) // Leaving a cell as first intersection. Well starts inside a cell.
        {
            // Needs wellpath start point in front
            HexIntersectionInfo firstLeavingPoint = it->second;
            firstLeavingPoint.m_intersectionPoint =  m_wellPath->m_wellPathPoints[0];
            firstLeavingPoint.m_face = cvf::StructGridInterface::NO_FACE;
            firstLeavingPoint.m_isIntersectionEntering = true;

            sortedUniqueIntersections.insert(std::make_pair(RigMDEnterLeaveCellIdxKey(m_wellPath->m_measuredDepths[0], 
                                                                                      true, 
                                                                                      firstLeavingPoint.m_hexIndex),
                                                            firstLeavingPoint));
        }

        // Add an intersection for the well endpoint possibly inside the last cell.
        std::map<RigMDEnterLeaveCellIdxKey, HexIntersectionInfo >::reverse_iterator rit = sortedUniqueIntersections.rbegin();
        if (rit != sortedUniqueIntersections.rend() && rit->first.isEnteringCell) // Entering a cell as last intersection. Well ends inside a cell.
        {
            // Needs wellpath end point at end
            HexIntersectionInfo lastEnterPoint = rit->second;
            lastEnterPoint.m_intersectionPoint =  m_wellPath->m_wellPathPoints.back();
            lastEnterPoint.m_isIntersectionEntering = false;
            lastEnterPoint.m_face = cvf::StructGridInterface::NO_FACE;

            sortedUniqueIntersections.insert(std::make_pair(RigMDEnterLeaveCellIdxKey(m_wellPath->m_measuredDepths.back(), 
                                                                                      false, 
                                                                                      lastEnterPoint.m_hexIndex),
                                                            lastEnterPoint));
        }
    }

    // Filter and store the intersections pairwise as cell enter-leave pairs 
    // Discard points that does not have a match .
    {
        std::map<RigMDEnterLeaveCellIdxKey, HexIntersectionInfo >::iterator it1 = sortedUniqueIntersections.begin();
        std::map<RigMDEnterLeaveCellIdxKey, HexIntersectionInfo >::iterator it2;

        while (it1 != sortedUniqueIntersections.end())
        {
            it2 = it1;
            ++it2;

            if (it2 == sortedUniqueIntersections.end()) break;

//.........这里部分代码省略.........
开发者ID:OPM,项目名称:ResInsight,代码行数:101,代码来源:RigWellLogExtractor.cpp

示例7: write

    void OBJWriter::write(const std::shared_ptr<gameplay::Model>& model,
                          const std::string& baseName,
                          const std::map<loader::TextureLayoutProxy::TextureKey, std::shared_ptr<gameplay::Material>>& mtlMap1,
                          const std::map<loader::TextureLayoutProxy::TextureKey, std::shared_ptr<gameplay::Material>>& mtlMap2,
                          const glm::vec3& ambientColor) const
    {
        Expects(model != nullptr);

        auto fullPath = m_basePath / baseName;

        Assimp::Exporter exporter;
        std::string formatIdentifier;
        for(size_t i = 0; i < exporter.GetExportFormatCount(); ++i)
        {
            auto descr = exporter.GetExportFormatDescription(i);
            BOOST_ASSERT(descr != nullptr);

            std::string exporterExtension = std::string(".") + descr->fileExtension;

            if(exporterExtension == fullPath.extension().string())
            {
                formatIdentifier = descr->id;
                break;
            }
        }

        if(formatIdentifier.empty())
        {
            BOOST_LOG_TRIVIAL(error) << "Failed to find an exporter for the supplied file extension";
            BOOST_LOG_TRIVIAL(info) << "Here's the list of registered exporters";

            for(size_t i = 0; i < exporter.GetExportFormatCount(); ++i)
            {
                auto descr = exporter.GetExportFormatDescription(i);
                BOOST_ASSERT(descr != nullptr);

                BOOST_LOG_TRIVIAL(info) << descr->description << ", extension `" << descr->fileExtension << "`, id `" << descr->id << "`";
            }

            BOOST_THROW_EXCEPTION(std::runtime_error("Failed to find an exporter for the supplied file extension"));
        }

        std::unique_ptr<aiScene> scene = std::make_unique<aiScene>();
        BOOST_ASSERT(scene->mRootNode == nullptr);
        scene->mRootNode = new aiNode();

        {
            size_t totalPartCount = 0;
            for( const auto& mesh : model->getMeshes() )
            {
                totalPartCount += mesh->getPartCount();
            }

            scene->mNumMaterials = totalPartCount;
            scene->mMaterials = new aiMaterial*[totalPartCount];
            std::fill_n(scene->mMaterials, totalPartCount, nullptr);

            scene->mNumMeshes = totalPartCount;
            scene->mMeshes = new aiMesh*[totalPartCount];
            std::fill_n(scene->mMeshes, totalPartCount, nullptr);

            scene->mRootNode->mNumMeshes = totalPartCount;
            scene->mRootNode->mMeshes = new unsigned int[totalPartCount];
            for( size_t i = 0; i < totalPartCount; ++i )
                scene->mRootNode->mMeshes[i] = i;
        }

        for( size_t mi = 0, globalPartIndex = 0; mi < model->getMeshes().size(); ++mi )
        {
            BOOST_ASSERT(mi < scene->mNumMeshes);
            const auto& mesh = model->getMeshes()[mi];

            for( size_t pi = 0; pi < mesh->getPartCount(); ++pi , ++globalPartIndex )
            {
                BOOST_ASSERT(globalPartIndex < scene->mNumMaterials);
                const std::shared_ptr<gameplay::MeshPart>& part = mesh->getPart(pi);

                scene->mMeshes[globalPartIndex] = new aiMesh();
                aiMesh* outMesh = scene->mMeshes[globalPartIndex];

                allocateElementMemory(mesh, outMesh);
                copyVertexData(mesh, outMesh);

                BOOST_ASSERT(part->getPrimitiveType() == gameplay::Mesh::PrimitiveType::TRIANGLES && part->getIndexCount() % 3 == 0);
                outMesh->mMaterialIndex = globalPartIndex;
                scene->mMaterials[globalPartIndex] = new aiMaterial();
                scene->mMaterials[globalPartIndex]->AddProperty(new aiColor4D(ambientColor.r, ambientColor.g, ambientColor.b, 1), 1, AI_MATKEY_COLOR_AMBIENT);

                {
                    // try to find the texture for our material

                    using Entry = decltype(*mtlMap1.begin());
                    auto finder = [&part](const Entry& entry)
                        {
                            return entry.second == part->getMaterial();
                        };

                    auto texIt = std::find_if(mtlMap1.begin(), mtlMap1.end(), finder);

                    bool found = false;
//.........这里部分代码省略.........
开发者ID:stohrendorf,项目名称:EdisonEngine,代码行数:101,代码来源:objwriter.cpp

示例8: UpdateAI

    void UpdateAI(const uint32 diff)
    {
        if (!UpdateVictim())
        {
            if (checkTimer < diff)
            {
                if (phase != EVENT_NULL && phase != EVENT_FIGHT)
                {
                    bool found = false;
                    for (std::map<uint64, uint8>::iterator it = prisoners.begin(); it != prisoners.end(); it++)
                    {
                        if (it->second == phase)
                        {
                            if (Creature *pPrisoner = me->GetCreature(it->first))
                            {
                                if (pPrisoner->isAlive())
                                {
                                    found = true;
                                    break;
                                }
                            }
                        }
                    }

                    if (!found)
                        DoAction(uint8(phase) +1);
                }
                checkTimer = 2000;
            }
            else
                checkTimer -= diff;

            return;
        }

        if (AcidSpray_Timer < diff)
        {
            AddSpellToCast(me->getVictim(),SPELL_SLIME_SPRAY);
            AcidSpray_Timer = urand(4000, 12000);
        }
        else
            AcidSpray_Timer -=diff;

        if (PoisonBolt_Timer < diff)
        {
            AddSpellToCast(me->getVictim(), SPELL_POISON_BOLT);
            PoisonBolt_Timer = urand(4000, 12000);;
        }
        else
            PoisonBolt_Timer -=diff;

        if (PoisonSpawn_Timer < diff)
        {
            AddSpellToCast(me, SPELL_POISON_CLOUD);
            PoisonSpawn_Timer = 20000;
        }
        else
            PoisonSpawn_Timer -=diff;

        CastNextSpellIfAnyAndReady();
        DoMeleeAttackIfReady();
    }
开发者ID:Dolmero,项目名称:L4G_Core,代码行数:62,代码来源:boss_broggok.cpp

示例9: main

int main(int argc, char **argv) {

//  GLUT initialization
	glutInit(&argc, argv);

	glutInitDisplayMode(GLUT_DEPTH|GLUT_DOUBLE|GLUT_RGBA|GLUT_MULTISAMPLE);

	glutInitContextVersion (3, 3);
	glutInitContextFlags (GLUT_COMPATIBILITY_PROFILE );

	glutInitWindowPosition(100,100);
	glutInitWindowSize(320,320);
	glutCreateWindow("Lighthouse3D - Assimp Demo");
		

//  Callback Registration
	glutDisplayFunc(renderScene);
	glutReshapeFunc(changeSize);
	glutIdleFunc(renderScene);

//	Mouse and Keyboard Callbacks
	glutKeyboardFunc(processKeys);
	glutMouseFunc(processMouseButtons);
	glutMotionFunc(processMouseMotion);
	
	glutMouseWheelFunc ( mouseWheel ) ;

//	Init GLEW
	//glewExperimental = GL_TRUE;
	glewInit();
	if (glewIsSupported("GL_VERSION_3_3"))
		printf("Ready for OpenGL 3.3\n");
	else {
		printf("OpenGL 3.3 not supported\n");
		return(1);
	}

//  Init the app (load model and textures) and OpenGL
	if (!init())
		printf("Could not Load the Model\n");

   printf ("Vendor: %s\n", glGetString (GL_VENDOR));
   printf ("Renderer: %s\n", glGetString (GL_RENDERER));
   printf ("Version: %s\n", glGetString (GL_VERSION));
   printf ("GLSL: %s\n", glGetString (GL_SHADING_LANGUAGE_VERSION));


   // return from main loop
	glutSetOption(GLUT_ACTION_ON_WINDOW_CLOSE, GLUT_ACTION_GLUTMAINLOOP_RETURNS);

//  GLUT main loop
	glutMainLoop();

	// cleaning up
	textureIdMap.clear();  

	// clear myMeshes stuff
	for (unsigned int i = 0; i < myMeshes.size(); ++i) {
			
		glDeleteVertexArrays(1,&(myMeshes[i].vao));
		glDeleteTextures(1,&(myMeshes[i].texIndex));
		glDeleteBuffers(1,&(myMeshes[i].uniformBlockIndex));
	}
	// delete buffers
	glDeleteBuffers(1,&matricesUniBuffer);

	return(0);
}
开发者ID:bjnix,项目名称:model-viewer,代码行数:68,代码来源:l3dassimpimport.cpp

示例10: ModLoad

bool ModLoad(uint Base, uint Size, const char* FullPath)
{
    //
    // Handle a new module being loaded
    //
    // TODO: Do loaded modules always require a path?
    if(!Base || !Size || !FullPath)
        return false;

    MODINFO info;

    // Copy the module path in the struct
    strcpy_s(info.path, FullPath);

    // Break the module path into a directory and file name
    char dir[MAX_PATH] = "";
    char file[MAX_MODULE_SIZE] = "";
    strcpy_s(dir, FullPath);
    _strlwr(dir);
    char* fileStart = strrchr(dir, '\\');
    if(fileStart)
    {
        strcpy_s(file, fileStart + 1);
        *fileStart = '\0';
    }

    //calculate module hash from full file name
    info.hash = ModHashFromName(file);

    // Copy the extension into the module struct
    {
        char* extensionPos = strrchr(file, '.');

        if(extensionPos)
        {
            strcpy_s(info.extension, extensionPos);
            extensionPos[0] = '\0';
        }
    }

    // Copy the name to the module struct
    strcpy_s(info.name, file);

    // Module base address/size
    info.base = Base;
    info.size = Size;

    // Process module sections
    info.sections.clear();

    WString wszFullPath = StringUtils::Utf8ToUtf16(FullPath);
    if(StaticFileLoadW(wszFullPath.c_str(), UE_ACCESS_READ, false, &info.Handle, &info.FileMapSize, &info.MapHandle, &info.FileMapVA))
    {
        // Get the entry point
        info.entry = GetPE32DataFromMappedFile(info.FileMapVA, 0, UE_OEP) + info.base;

        // Enumerate all PE sections
        int sectionCount = (int)GetPE32DataFromMappedFile(info.FileMapVA, 0, UE_SECTIONNUMBER);

        for(int i = 0; i < sectionCount; i++)
        {
            MODSECTIONINFO curSection;

            curSection.addr = GetPE32DataFromMappedFile(info.FileMapVA, i, UE_SECTIONVIRTUALOFFSET) + info.base;
            curSection.size = GetPE32DataFromMappedFile(info.FileMapVA, i, UE_SECTIONVIRTUALSIZE);
            const char* sectionName = (const char*)GetPE32DataFromMappedFile(info.FileMapVA, i, UE_SECTIONNAME);

            // Escape section name when needed
            strcpy_s(curSection.name, StringUtils::Escape(sectionName).c_str());

            // Add entry to the vector
            info.sections.push_back(curSection);
        }
    }

    // Add module to list
    EXCLUSIVE_ACQUIRE(LockModules);
    modinfo.insert(std::make_pair(Range(Base, Base + Size - 1), info));
    EXCLUSIVE_RELEASE();

    SymUpdateModuleList();
    return true;
}
开发者ID:StGlolry,项目名称:x64dbg,代码行数:83,代码来源:module.cpp

示例11: deleteAtrac

void deleteAtrac(int atracID) {
	if (atracMap.find(atracID) != atracMap.end()) {
		delete atracMap[atracID];
		atracMap.erase(atracID);
	}
}
开发者ID:nachume,项目名称:ppsspp,代码行数:6,代码来源:sceAtrac.cpp

示例12: if

//------------------------------------------------------------------------
//------------------------------------------------------------------------
SmartPointer<Texture> Texture::open(std::string filename,bool bUseCacheIfPossible,bool bCacheInMemory)
{
	if (!filename.length()) 
	{
		Log::printf("Texture::open cannot open texture because filename is empty\n");
		return SmartPointer<Texture>();
	}

	//use cache?
	if (bUseCacheIfPossible)
	{
		if (textures_in_cache.find(Utils::ToLower(filename))!=textures_in_cache.end())
		{
			//Log::printf("Opened texture file %s from cache (already in memory)\n",Filename.c_str());
			return textures_in_cache[Utils::ToLower(filename)];
		}
	}


	//opening from disk
  juce::File   jfile(juce::File::getCurrentWorkingDirectory().getChildFile(filename.c_str()));
  juce::String jext=jfile.getFileExtension().toLowerCase();

  SmartPointer<Texture> ret;
  if (jext==".tga")
  {
    ret=readTga(filename);

    if (!ret)
      return ret; //failed
  }
  else
  {
    juce::Image jimg=juce::ImageFileFormat::loadFrom(jfile);

    if (!jimg.isValid())
	  {
		  Log::printf("Texture::open cannot open texture file %s \n",filename.c_str());
		  return SmartPointer<Texture>();
	  }

	  int width  = jimg.getWidth();
	  int height = jimg.getHeight();
	  int bpp    = jimg.getFormat()==juce::Image::ARGB? 32 : (jimg.getFormat()==juce::Image::RGB? 24 : (jimg.getFormat()==juce::Image::SingleChannel? 8:0));

	  if((width == 0) || (height == 0) || !(bpp==24 || bpp==32 || bpp==8))
	  {
		  Log::printf("Texture::open failed to load the texture file %s (reason  unsupported type bpp=%d width=%d height=%d\n",filename.c_str(),bpp,width,height);
		  return SmartPointer<Texture>();
	  }

	  ret=SmartPointer<Texture>(new Texture(width,height,bpp,0));
    unsigned char* dst=ret->buffer;

	  //Alpha
	  if (bpp==8)
	  {
		  for (int Y=0;Y<height;Y++) {
		  for (int X=0;X<width ;X++) {
        juce::Colour colour=jimg.getPixelAt(X,height-Y-1); //mirror y
			  *dst++=colour.getAlpha();
		  }}
	  }
	  //RGB
	  else if (bpp==24)
	  {	
		  for (int Y=0;Y<height;Y++) {
		  for (int X=0;X<width ;X++) {
        juce::Colour colour=jimg.getPixelAt(X,height-Y-1); //mirror y
			  *dst++=colour.getRed  ();
			  *dst++=colour.getGreen();
			  *dst++=colour.getBlue ();
		  }}
	  }
	  //RGBA
	  else if (bpp==32)
	  {
		  for (int Y=0;Y<height;Y++) {
		  for (int X=0;X<width ;X++) {
        juce::Colour colour=jimg.getPixelAt(X,height-Y-1); //mirror y
			  *dst++=colour.getRed  ();
			  *dst++=colour.getGreen();
			  *dst++=colour.getBlue ();
        *dst++=colour.getAlpha();
		  }}
	  }
  }

	Log::printf("image file %s loaded from disk width(%d) height(%d) bpp(%d)\n",filename.c_str(),ret->width,ret->height,ret->bpp);

	if (bCacheInMemory)
		textures_in_cache[Utils::ToLower(filename)]=ret;

	ret->filename=filename;
	return ret;

}
开发者ID:AlessandroGiacomini,项目名称:pyplasm,代码行数:99,代码来源:texture.cpp

示例13: Operaciones

 Operaciones(){
     operaciones.insert(std::make_pair("suma", new Sum<T, Func>()));
 };
开发者ID:legalgui,项目名称:clase2016,代码行数:3,代码来源:main.cpp

示例14: insertBack

 void insertBack(std::string s, Func f){
     operacionesConApuntadores.insert(std::make_pair(s,f));
     
 };
开发者ID:legalgui,项目名称:clase2016,代码行数:4,代码来源:main.cpp

示例15: OnUnload

		virtual void OnUnload() override
		{
			extdata.clear();
		}
开发者ID:sigsegv-mvm,项目名称:sigsegv-mvm,代码行数:4,代码来源:ecattr_extensions.cpp


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