On 27.04.2012 16:54, Rene Zwanenburg wrote:
[snip]

True, but what would using structs do to fix the problem?

The reason I'm using (final) classes is because a resource can be used
by multiple objects. If two meshes use the same texture, I don't want to
load that texture twice.

Don't. If I still worth anything in GL texture is bound to an opaque uint of sorts. There is no problem copying this number around. There is no point in holding multiple references to 42 ;) Just copy the number.

Reference to class is cleaner than pointer to
struct.

Use struct as reference-like type with some alias this magic you may also gain interesting properties. This way you can hide inside a delay-loading scheme of sorts. Say counting usage rates then once resource usage hits a margin you go through the whole list or resources releasing those that are rarely used.

Also let us not forget that each class instance holds monitor object. Even though it's lazying initialized it still occupies extra space.

--
Dmitry Olshansky

Reply via email to