Here is what am i doing and what i need:
I am trying to create scene manager class and manage resources that it holds.
I need some type of container that can hold just pointers to data/resources that does not
allocate/deallocate nothing since i am doing it by hand. Here is some half pseudo (inserting into container):
LightSceneElement* SceneManager::AddLightSceneElement(SceneElement* parent, ELightType type){ LightSceneElement* pLight = new LightSceneElement(); pLight->Init(this, parent, type);// intit basic properties conatainerLights.insert(pLight);// this should be my imagenary container return pLight;// return pLight so i can take control elswhere and manipulate it}
then when finished delete all data:
void SceneManager::Close(){ ... foreach element in containerLights { LightSceneElement* pLight = *containerLights.iter;//obtain pointer delete pLight; //delete data that it points to pLight = 0; }}
It should have fast function to sort my elements (that i have talked about in linked thread)
and it should be fast at inserting elements:
void SceneManager::Draw(){ ... // for example render static meshes container<SceneElement*> containerNotCulledStaticMeshes;// name shoud be obvious foreach static mesh in containerAllStaticMeshes // container that holds all static meshes { if seen by camera { SceneElement* pCurrentMesh = *containerAllStaticMeshes.iter;//obtain pointer containerNotCulledStaticMeshes.insert(pCurrentMesh);//just insert pointer } } ... containerNotCulledStaticMeshes.sort(SceneElement::BackToFront());//sort meshes foreach static mesh in containerNotCulledStaticMeshes { SceneElement* pElement = *containerNotCulledStaticMeshes.iter;//obtain pointer SetShader(); pElement->Draw(); }}
Is there some kind of "container" for this?