- Timestamp:
- 06/28/08 16:12:59 (16 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
GTP/trunk/App/Demos/Vis/FriendlyCulling/src/RenderQueue.h
r2801 r2802 10 10 11 11 class RenderState; 12 class Camera; 12 13 13 14 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 */ 17 struct 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 16 38 */ 17 39 class RenderQueue … … 24 46 /** Constructor taking a render queue 25 47 */ 26 RenderQueue(RenderState *state); 27 /** Enqueues an entity 48 RenderQueue(RenderState *state, Camera *cam); 49 50 ~RenderQueue(); 51 /** Enqueues an entity. 28 52 */ 29 53 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 68 protected: 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(); 30 78 /** Renders the contents of the render queue. 31 79 */ 32 80 void Render(); 33 /** Sets the current render state34 */35 void SetRenderState(RenderState *state);36 /** Clears the render queue37 */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();45 81 /** Prints the current state of the render queue. 46 82 */ 47 83 void Print(); 48 84 49 protected:50 51 /** Sorts the render queue by materials / textures.52 */53 void Sort();54 55 56 85 /////////// 57 86 58 87 RenderState *mState; 59 SceneEntityContainer mEntities; 88 Camera *mCamera; 89 //SceneEntityContainer mEntities; 60 90 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; 61 96 }; 62 63 /// measures sort time for detailed benchmarks64 static PerfTimer sortTimer;65 97 66 98
Note: See TracChangeset
for help on using the changeset viewer.