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 11 years, 12 months ago

Programming Thousands of Hamsters #5

Alert Games 11 years, 12 months ago

Looks great!

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

Mordi 11 years, 12 months 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 11 years, 12 months 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 11 years, 12 months ago

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

Rob 11 years, 12 months ago

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

Can they have destructors too?

sirxemic 11 years, 12 months 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 11 years, 12 months ago

What about inheritance and shit?

LAR Games 11 years, 12 months ago

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

sirxemic 11 years, 12 months ago

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