XEngine Forums Forum Index XEngine Forums
XEngine Discussion Forums
Back to the XEngine project page
 
 FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister 
 ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in 

RenderContext and Renderer Classes Use boost:shared_ptr

 
Post new topic   Reply to topic    XEngine Forums Forum Index -> Development & Bug Reports
View previous topic :: View next topic  
Author Message
Asgard
Site Admin


Joined: 26 Nov 2002
Posts: 228
Location: Austria

PostPosted: Sun Nov 14, 2004 9:31 pm    Post subject: RenderContext and Renderer Classes Use boost:shared_ptr Reply with quote

Instead of using raw pointers, instances of the RenderContext and Renderer classes are now (in current CVS) also passed around as boost::shared_ptr, just like RenderResource or RenderTarget objects. This makes it easier to write exception-safe client code.

RenderContext and Renderer destruction works like this (which has basically not changed):
- A Renderer object is destroyed when the last RenderContext that was created by that Renderer is destroyed and the client holds no further shared_ptrs to it. When the Renderer object is destroyed, the corresponding dynamic shared library is automatically unloaded.
- A RenderContext object is destroyed when the client releases the last shared_ptr it holds to the RenderContext.
- When a RenderContext is destroyed, all RenderResource and RenderTarget objects created by it must have already been destroyed. The debug build will assert if this is not the case.

Regarding interaction with wxWidgets there is one important thing to consider: If the wxApp-derived class holds a shared_ptr to a RenderContext (or a RenderResource or RenderTarget), that shared_ptr must be destroyed before wxApp::CleanUp is called. In order to ensure this, either make sure the RenderContext shared_ptr is kept in a wxWindow-derived class or any other class whose objects are destroyed before wxApp::CleanUp is called, or override wxApp::CleanUp in your application class and call reset() on the shared_ptr before making the upcall to wxApp::CleanUp. For an example of this, see the MultiWin sample.
Back to top
View user's profile Send private message Send e-mail Visit poster's website
Display posts from previous:   
Post new topic   Reply to topic    XEngine Forums Forum Index -> Development & Bug Reports All times are GMT
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © 2001, 2005 phpBB Group