Skip to main content
gamedev.net
🔒 Locked

scene graph, memory management...

Started by no one Jan 25, 2004 at 3:07 AM 0 replies 350+ views
Original Post
no one
no one
Hello I have written a few classes such as a smart pointer class, a linked list class and I recently added a link list system to my entity class. The smart pointer I guess is only used so that when you create a *new* instance of a class and store the object into the entity list, the pointer can be deleted without memory leaks. Anyway, the entity list I figured I could ecapsolate into a scene class which would do garbage collection and would process the entities function recrusively depending on if the entity has children. The garbage collection function though, right now it only loops through the entity list and looks for PARENT entities that are in active and then removes them and calls there free function, say the entity had children though, should you simple make the entities first child its own parent? ex: a charactor with a sword... the charactor dies, but the sword will stay for another charactor to pick up... I figured that only parent objects will be stored in the entity list since children entities will be connected to them thus making them not direct parents. Anway, that method has no refrence checking to see rather the entity is still in use thus making it error prone. How do you add that? Also, my texture class only deals with a single image pointer per each instance of the class. In the loading function, it loops through a loaded list to see if the texture has already been loaded and if so, it simply sets the new image pointer to that of the previously loaded. I think this is fine, but when it comes to freeing the image pointer from the list... I delete the OpenGL texture id, but Im not sure how to properly remove the pointer from the list. *note that I did make a function which frees the texture list at program exit time* Can anyone help me out here, this is very confusing to me... Thanks a ton in advance and Sorry about the thread length.
"Make it a habit to be loyal to the activities that serve the highest part of yourself."

Topic Locked

This topic has been locked by a moderator. New replies are not allowed.

Sign in to reply to this topic.