You are an experienced programmer and have a problem with the engine, shaders, or advanced effects? Here you'll get answers. No questions about C++ programming or topics which are answered in the tutorials!
how can i design my classes so scene manager can be accessed by other classes.
i have now the class in which all the models are loaded and rendered,but things got to complicated,i have many models and textures and i thought that the best should be to write clasess that will handle similiar things.like player class,that should handle all player model loading,weapons class that should handle all weapons loading,etc...but how can i access scnene manager from these classess?i tried many things,but i think that i should rewrite all from the scratch so what is the best way to do this.
you should look up inheritance , composition and polymorphism in a book or google for it to find examples how to do it.
see this site for a good book (thinking in c++ by bruce eckel), which is also available for download.
Maybe I don't understand the question, but if the only thing you want to do ist to have the scene manager available for everyone, why don't you simply make smgr a global variable? And then declare it on the beggining of each .cpp filr? Like:
Well, for one, they are global. This runs into a whole potential slew of redefinition errors, etc...
No gaurantee of state. Its hard to gaurantee when a global is initialized, so either you have potentially uninit'ed variables, or you have to put a ton of "just in case" tests to see if its properly set, or you have potentially volitile code.
As above, with a global variable, it could also be deleted or corupted at any point in your code, which for one makes debugging hell.
Hard to tell, or properly control when, or if, memory is released.
Global makes for name collision issues, as the global variable namespace will be available at every scope. Using a unique identifier such as g_myVar is a fairly effective work around.
In almost every case, a singleton is a better method to use then a global. Really all a singleton is, is a global object wrapper around an instance variable. The largest benefits are 1) you are gauranteed that the object varaible has been initialized 2) memory isnt allocated until first use 3) slightly more namespace friendly.
The biggest downside, is the minor overhead to the call... which can be minimalized to a large extent in most cases. If however, the varaible is going to be called a number of times in a fairly tight loop, you are better of creating a local reference and using it.