Programming with OpenGL #5

Posted by Mordi on May 5, 2012, 5:43 a.m.

Finally got my spritefont to work properly.

Before, I simply had an array of 223 characters, drawing each texture separately. Now I've optimized it further by including all characters into one single texture. I've also contained all the info I need about each character into a struct, which is much better than having 5-6 separate arrays of 223 integers/floats.

Next up is getting my load-routine to work properly, using a thread.

Comments

Rob 12 years ago

Programming Thousands of Hamsters #5

Alert Games 12 years ago

Looks great!

A struct huh? I've never even used those since I went straight to using classes.

Mordi 12 years ago

Structs are pretty cool. You basically already know how to use it if you know how to use a class. A struct is like a class without any functions, just members.

sirxemic 12 years ago

Actually a struct is semantically almost identical to a class, the *only* difference is the default access specifier (being private for classes and public for structs).

E.g. the following two are identical.

struct Test{
public:
    Test() { ... }
private:
    int lol;
};

and

class Test{
public:
    Test() { ... }
private:
    int lol;
};

Mordi 12 years ago

Oh. So structs can have functions also? The more you know…

Rob 12 years ago

…I honestly didn't know they could have constructors…

Can they have destructors too?

sirxemic 12 years ago

Sure. Again, structs and classes are identical, except for the default access specifier :P

But it's kind of a convention I think (don't quote me on this) to use structs mostly for packed data elements, like Mordi is using them.

Rob 12 years ago

What about inheritance and shit?

LAR Games 12 years ago

Hey rob, why haven't we seen you on teamspeak? We miss you.

sirxemic 12 years ago

Quote:
What about inheritance and shit?
Same story. structs default access specifier for inheritance is public, and that of classes is private :P