[gameprogrammer] Re: creating a gui

On Wed, 2005-12-07 at 08:40 -0500, Roger D Vargas wrote:
> Yes, Im using C++. I was thinking about a singleton, but I m not 
> experienced enough with advanced topics and when I try such things 
> usually I end with a lot of weird errors.

That is how you become experienced with advanced topics. You try them,
get the weird errors, figure out the errors, do it right, and now you
know the topic. No one ever gets these things right the first time.

As the old saying goes "Anything worth doing is worth doing poorly, no
body ever did anything well the first time".

                Bob Pendleton

> 
> Bob Pendleton wrote:
> > On Tue, 2005-12-06 at 18:22 -0500, Roger D Vargas wrote:
> > 
> >>Perhaps Im using the wrong method, but when I define a global variable 
> >>in the header file I got a lot of errors concerning already defined 
> >>symbol. I had that problem when moved the widget list outside a class. 
> >>So I have to declare the variable as static, and that makes it accesible 
> >>only to that file, I think.
> > 
> > 
> > What language are you using? In C/C++ if you put a variable declaration
> > in a header file it will be created in every source file that includes
> > the header file and that means you will have the same variable defined
> > in multiple places.
> > 
> > You need to put it in the header file as an extern so that it is defined
> > but not declared in every file that uses the header file and then you
> > need to actually declare it in a single file. To get a better
> > understanding try searching on google for "extern C++ variable" (with
> > out the "s for obvious reasons).
> > 
> > Also, if you are using C++ or other similar language you should look up
> > the "singleton" pattern for your language and use that. Using the
> > singleton pattern makes sure that there is one, and only one, copy of
> > the object in existence in your program.
> > 
> >             Bob Pendleton
> > 
> > 
> >>
> >>Olof Bjarnason wrote:
> >>
> >>>
> >>>On 12/6/05, *Bob Pendleton* <bob@xxxxxxxxxxxxx 
> >>><mailto:bob@xxxxxxxxxxxxx>> wrote:
> >>>
> >>>    On Tue, 2005-12-06 at 21:14 +0100, Olof Bjarnason wrote:
> >>>     > If your not in a multi-threaded application, use a global
> >>>    variable (or
> >>>     > static member) pointing to the resource manager
> >>>
> >>>    If it is multithreaded then do the same thing but use mutexes to
> >>>    serialize access to the static object.
> >>>
> >>>
> >>>right! great that's the way.
> >>>
> >>>quite a lot of people (including myself) have heard so many times 
> >>>"global variables are BAD BAD BAD" from "authorities" that we have a big 
> >>>anxiety just thinking of global variables. maybe a combination of 
> >>>pre-namespace-languages and hard-to-teach (and more serious problem) 
> >>>concurrency?
> >>>
> >>>                    Bob Pendleton
> >>>
> >>>     >
> >>>     > On 12/6/05, Roger D Vargas < luo_hei@xxxxxxxx
> >>>    <mailto:luo_hei@xxxxxxxx>> wrote:
> >>>     >         Im creating a widget set for my game and I have a big doubt
> >>>     >         when comes
> >>>     >         to implementing a theme.
> >>>     >         the theme manager class will contain all required
> >>>    textures and
> >>>     >         data that
> >>>     >         will be used to draw elements. The problem is that I dont
> >>>    know
> >>>     >         the right
> >>>     >         way to make the this class accesible to all widgets.
> >>>     >         Can somebody recommend me something?
> >>>     >
> >>>     >         --
> >>>     >         Roger D. Vargas
> >>>     >         http://dsgp.blogspot.com | Linux, programación, juegos
> >>>     >
> >>>     >
> >>>     >
> >>>     >         ______________________________________________
> >>>     >         Renovamos el Correo Yahoo!
> >>>     >         Nuevos servicios, más seguridad
> >>>     >         http://correo.yahoo.es
> >>>     >
> >>>     >
> >>>     >         ---------------------
> >>>     >         To unsubscribe go to
> >>>     >         http://gameprogrammer.com/mailinglist.html
> >>>     >
> >>>     >
> >>>     >
> >>>    --
> >>>    +--------------------------------------+
> >>>    + Bob Pendleton: writer and programmer +
> >>>    + email: Bob@xxxxxxxxxxxxx <mailto:Bob@xxxxxxxxxxxxx>             +
> >>>    + web: www.GameProgrammer.com <http://www.GameProgrammer.com>          
> >>> +
> >>>    + www.Wise2Food.com <http://www.Wise2Food.com>                    +
> >>>    + nutrient info on 7,000+ common foods +
> >>>    +--------------------------------------+
> >>>
> >>>
> >>>
> >>>    ---------------------
> >>>    To unsubscribe go to http://gameprogrammer.com/mailinglist.html
> >>>
> >>>
> >>>
> >>
> 
> -- 
> Roger D. Vargas
> http://dsgp.blogspot.com | Linux, programación, juegos
> 
>               
> ______________________________________________ 
> Renovamos el Correo Yahoo! 
> Nuevos servicios, más seguridad 
> http://correo.yahoo.es
> 
> 
> ---------------------
> To unsubscribe go to http://gameprogrammer.com/mailinglist.html
> 
> 
> 
-- 
+--------------------------------------+
+ Bob Pendleton: writer and programmer +
+ email: Bob@xxxxxxxxxxxxx             +
+ web: www.GameProgrammer.com          +
+ www.Wise2Food.com                    +
+ nutrient info on 7,000+ common foods +
+--------------------------------------+



---------------------
To unsubscribe go to http://gameprogrammer.com/mailinglist.html


Other related posts: