Second Life source analysis (46) Get the thread of the texture picture

Source: Internet
Author: User
Tags thread class
Texture pictures for the 3D program is more important data, if there is no texture pictures, there is no bright appearance, there is no rich and colorful world. In the second life, texture pictures are not released with the program, but are constantly downloaded from the server, this is not like other games, all the pictures in advance to download all the good. Here is an analysis of the texture download thread's working process. First from the program: Llappviewer::gettexturefetch ()->createrequest (GetID (), Gettargethost (), Decode_priority, W, H, C, desired_ Discard, Needsaux ()) calls the Createrequest function to create a texture picture download. Then the Lltexturefetch::update function is called in the texture download thread to update the request, and the texture thread lltexturefetch is started to get the texture picture. The thread class Lltexturefetch is inherited from the Llworkerthread thread class, so it is also called a worker thread to run.   If you download a texture picture from the network, how to execute it. First look at the following code: #001  void lltexturefetch::addtonetworkqueue (lltexturefetchworker* worker) #002  {#003        if (Mrequestmap.find (worker->mid)!= mrequestmap.end ()) #004         {#005              //Only add to the queue if in the Request Map #006              //i.e. a delete has not been r equested #007               Mnetworkqueue.insert (Worker->mid); #008       } #009        for (cancel_queue_t::iterator iter1 = Mcancelqueue.begin (); #010                iter1!= mcancelqueue.end (); ++iter1) #011        {#012                iter1->second.erase (Worker->mid); #013       } #014 &nbsp}   The code above is to add this texture picture to the network download queue mnetworkqueue, and then send a request for the download picture to the server from the network layer.   #001  s32 lltexturefetch::update (U32 max_time_ms) #002  {#003        S32 Res; 004       res = llworkerthread::update (Max_time_ms); #005        #006        const F32 request_time = 1.F; #007   #008       //Periodically, gather the "list of textures" need data from the Networ K#009       //and send the requests out to the simulators #010        if (Mnetworktimer.getelapsedtimef32 () >= request_time) #011        {#012     & nbsp;         Mnetworktimer.reset (); #013               sendrequestlisttosimulators (); #014       } #015        #016        return Res #017 &nbsp}   The above code is to continuously send the ID to the network request to download the texture to the server, mainly through the function sendrequestlisttosimulators to implement, the function of the code is longer, the next time to analyze it.

 

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.