Ignore:
Timestamp:
06/28/08 16:12:59 (16 years ago)
Author:
mattausch
Message:

worked on renderqueue

File:
1 edited

Legend:

Unmodified
Added
Removed
  • GTP/trunk/App/Demos/Vis/FriendlyCulling/src/RenderQueue.h

    r2801 r2802  
    1010 
    1111class RenderState; 
     12class Camera; 
    1213 
    1314 
    14 /** This class implements a render queue that sorts entities according to 
    15         their materials. 
     15/** Defines a bucket for scene entities that have the same properties. 
     16*/ 
     17struct RenderQueueBucket 
     18{ 
     19        /** should be full texture format, but we as use the same format for all textures 
     20            they differ only in size, and we implicitly assume that textures with the same  
     21            size have exactly the same format 
     22        */ 
     23        int mTextureSize; 
     24        bool mAlphaTestEnabled; 
     25 
     26        /// minimal distance to the camera 
     27        float mMinDistance; 
     28 
     29        SceneEntityContainer mEntities; 
     30}; 
     31 
     32 
     33/** This class implements a render queue that sorts renderable geometry in order 
     34        to minimize state changes while approximately keeping front-to-back order 
     35        The implementation roughly follows the suggested implemenation on Tom Forsyth's article 
     36        on render state changes. It requires sorting only on bucket level and therefore has very 
     37        low overhead 
    1638*/ 
    1739class RenderQueue 
     
    2446        /** Constructor taking a render queue 
    2547        */ 
    26         RenderQueue(RenderState *state); 
    27         /** Enqueues an entity 
     48        RenderQueue(RenderState *state, Camera *cam); 
     49 
     50        ~RenderQueue(); 
     51        /** Enqueues an entity. 
    2852        */ 
    2953        void Enqueue(SceneEntity *entity); 
     54        /** Sets the current render state 
     55        */ 
     56        void SetRenderState(RenderState *state); 
     57        /** Sets the current render state 
     58        */ 
     59        void SetCamera(Camera *cam); 
     60        /** Returns the number entities currently in the queue. 
     61        */ 
     62        inline int GetSize() const { return (int)mSize; } 
     63        /** Renders and clears the queue. 
     64        */ 
     65        void Apply(); 
     66 
     67 
     68protected: 
     69 
     70        inline bool FitsInBucket(SceneEntity *ent, size_t idx) const; 
     71 
     72        /** Sorts the render queue by materials / textures. 
     73        */ 
     74        void Sort(); 
     75        /** Clears the render queue 
     76        */ 
     77        void Clear(); 
    3078        /** Renders the contents of the render queue. 
    3179        */ 
    3280        void Render(); 
    33         /** Sets the current render state 
    34         */ 
    35         void SetRenderState(RenderState *state); 
    36         /** Clears the render queue 
    37         */ 
    38         void Clear(); 
    39         /** Returns the number entities currently in the queue. 
    40         */ 
    41         inline int GetSize() const { return (int)mEntities.size(); } 
    42         /** Renders and clears the queue. 
    43         */ 
    44         void Apply(); 
    4581        /** Prints the current state of the render queue. 
    4682        */ 
    4783        void Print(); 
    4884 
    49 protected: 
    50  
    51         /** Sorts the render queue by materials / textures. 
    52         */ 
    53         void Sort(); 
    54  
    55  
    5685        /////////// 
    5786 
    5887        RenderState *mState; 
    59         SceneEntityContainer mEntities; 
     88        Camera *mCamera; 
     89        //SceneEntityContainer mEntities; 
    6090        int mMinSizeForSorting; 
     91 
     92        /// each bucket contains objects with similar materials that don't cause a hard state change 
     93        std::vector<RenderQueueBucket *> mBuckets; 
     94 
     95        int mSize; 
    6196}; 
    62  
    63 /// measures sort time for detailed benchmarks 
    64 static PerfTimer sortTimer; 
    6597 
    6698 
Note: See TracChangeset for help on using the changeset viewer.