Re: Do I need a singleton here? Or can I use std::move
"?? Tiib" <ootiib@hot.ee> wrote in message news:5b7de888-6637-4f92-8dc4->
483f95103ec2@l14g2000yqb.googlegroups.com...
On 20 okt, 22:09, "Jim Langston" <tazmas...@rocketmail.com> wrote:
The problem with a deep copy is that creating the font is extremely
expensive. I'm loading something like 10,000 chars and it takes
noticable
time to load the fonts. If I had to do a deep copy use of the font would
be
prohibitive.
I've been thinking about a shared pointer, but I remember that C++'s
implementation of the shared pointer was broken in places which is why I
don't use it, and I don't like using boost. I understand that 2010 uses
0x's shared pointers which fix the issues so I may use them, although I
think getting the move to work would be best.
OpenGL just follows what you order it to do, move just moves,
shared_ptr is pointer with refcount attached to it and map is a
weighted tree of pairs.
Therefore when writing graphics library then it is *you* who has to
manage both GPU and CPU resources and these above tools just may help
you. If you have lot of multimedia then everything does not fit in
memory at once anyway.
For example: Why you load in 10,000 glyphs? It sounds like for 200 x
50 text with all symbols unique. Do such things lazily, load the
glyphs on hint you may need them, say 100 per portion. Other example:
map of such fonts? Do you plan in perspective to have so long list of
different fonts loaded that you need a map to navigate among them?
Yes, I plan on having so long a list of different fonts loaded that I need a
map to navigate them. I will also allow the end user to choose their own
fonts to use. I plan on supporting multiple languages. although I'm quite
sure I'll need more than std::wstring for this. The new u16 and u32 look
promising. If I do use u16 and/or u32 I plan on using them the exact same
way I'm using string and wstring (although I know there are a lot of issues.
character sizes may not always be consistant).
But, even if I don't use a map, I want to be able to use a font in a map, or
vector, or set, or whatever container I want it in. For a useful class not
to be used in a container is a terrible thing to me and since I have
resolved the issue with assignable it works well. I can now use my class
anywhere I want. Well, as long as no one tries to copy it, which is
prohibitively expensive anyway. If a font is already loaded in opengl I see
no reason to need to load it again. Just use the one that's already loaded.