Discuss the development of new homebrew software, tools and libraries.
Moderators: cheriff, TyRaNiD
-
_BenJi
- Posts: 7
- Joined: Wed Jan 16, 2008 6:38 am
Post
by _BenJi »
Hi,
Yeah, I'm noob, but I don't know how to convert an RGB colour to an u32 colour.
I get the framebuffer with 'sceDisplayGetFrameBuf', and I want to change the colour of some pixels.
With SDL there is the function 'SDL_MapRGBA' but I don't want to use SDL. And there isn't the 'uint32_pack' for the PSP (or I didn't find it)
Can someone help me ? :(
Solution :
Code: Select all
color = (b<<16) + (g<<8) + r;
-
CpuWhiz
- Posts: 42
- Joined: Mon Jun 04, 2007 1:30 am
Post
by CpuWhiz »
They are in pspgu.h:
Code: Select all
/* Color Macros, maps 8 bit unsigned channels into one 32-bit value */
#define GU_ABGR(a,b,g,r) (((a) << 24)|((b) << 16)|((g) << 8)|(r))
#define GU_ARGB(a,r,g,b) GU_ABGR((a),(b),(g),(r))
#define GU_RGBA(r,g,b,a) GU_ARGB((a),(r),(g),(b))
/* Color Macro, maps floating point channels (0..1) into one 32-bit value */
#define GU_COLOR(r,g,b,a) GU_RGBA((u32)((r) * 255.0f),(u32)((g) * 255.0f),(u32)((b) * 255.0f),(u32)((a) * 255.0f))
So:
Code: Select all
color = GU_RGBA(r, g, b, 255);