Improvements to libogc library
Posted: Thu Oct 06, 2011 3:34 am
Hey all, mucking around with libogc at the moment and have found that the entirely c-style setup can be a little bothersome at times, it works perfectly fine of course, but there are some things that could benefit from C++ if the user is using the language.
For instance:
That way C++ can get the added benefit of being able to define a color with the class constructor for GXColor. This removes a line or two from your own source with only the little bit of overhead from C++ classes.
I'm sure I'll find others... feel free to use these yourselves, after all, anyone can make them on their own XD
Note that GXColor is located in gx.h
Have a nice day.
For instance:
Code: Select all
#ifdef __cplusplus
class GXColor
{
public:
uint8_t r,g,b,a;
GXColor() {r=0; g=0; b=0; a=0;}
GXColor( u8 R, u8 G, u8 B, u8 A) : r(A), g(G), b(B), a(A) {}
};
#else
typedef struct _gx_color {
u8 r; /*!< Red color component. */
u8 g; /*!< Green color component. */
u8 b; /*!< Blue alpha component. */
u8 a; /*!< Alpha component. If a function does not use the alpha value, it is safely ignored. */
} GXColor;
#endif
I'm sure I'll find others... feel free to use these yourselves, after all, anyone can make them on their own XD
Note that GXColor is located in gx.h
Have a nice day.