![]() |
|
This thread is locked; no one can reply to it.
![]() ![]() |
1
2
|
No red, only green and blue! |
boulifb
Member #7,909
October 2006
|
Hello Allegro gurus, I am currently working on my game project and I have some strange behaviours with the colors. When I use 15 bits colors (values taken from the game boy palettes) I get the correct display colors when I use the getr15, getg15 and getb15 under Windows. When I recompile the project on Mac OS X (tiger-intel c2d and Xeon) I get wrong colors: I have only green and blue composites and no red. I have declared 32bits color depth on my bitmaps. When I check the degugging values I have the corect colors values on both Windows and Tiger but the display result differ. Is there a problem with colors on Mac OS X? Did I missed something somewhere? (yes, I have used the set_color_depth function before initializing the set_gfx_mode function) Thanks in advance for the help. Best regards. Fred. OK I solved the problem: |
Thomas Harte
Member #33
April 2000
![]() |
Are you composing the 32bit colours yourself with fixed code? If so then you may face compatibility issues - not all Windows machines go RGB and I dare guess that not all OS X machines go BGR. I definitely wouldn't be surprised if the order of colours within a word varies between Intel and PowerPC for obvious reasons. makecol32 will sort things out for you though... [My site] [Tetrominoes] |
boulifb
Member #7,909
October 2006
|
What is really surprising is that I have intel Macs. 1 Macbook Pro Core2Duo and a Mac Pro (Xeon x64). I should get the same bit order as it is intel based processors. I suspect a Mac OS legacy. Other people will have the information now Best regards. Fred. |
Thomas Harte
Member #33
April 2000
![]() |
Quote: I should get the same bit order as it is intel based processors. Only if they're using the same video cards in the same video modes. Windows (pre-Vista) makes applications write straight to the framebuffer. OS X keeps a buffer of the current state of each application which, starting with 10.2, is in VRAM (so the graphics card can do window composition). So, in Windows, RGB/BGR/whatever ordering is determined by the order used by the framebuffer. In OS X, BGR/RGB/whatever ordering is determined by the order OS X selects for its texture format. After that it is purely hardware driven - OS X will not and cannot impose any legacy order if the hardware doesn't support it. Neither OS guarantees either order. Allegro figures out the order at runtime, and provides makecol32 so that you can build your 32bit words correctly. If you assume a byte order based solely on OS then your program will not work on all hardware. [My site] [Tetrominoes] |
boulifb
Member #7,909
October 2006
|
as I said, I use 15 bits colors from the Game Boy that I transform into 32 bits colors for Allegro platform (Mac OS X and Windows). When I apply the 15bits color I use the current code: on Windows: RGB values are just inverted. |
Ron Novy
Member #6,982
March 2006
![]() |
If there is a way to detect what order OSX is using then it should be used instead. In either case I believe this issue has been discussed many times for OSX but I've never seen a solution that caused a good working patch to the lib... Maybe someone with better skills on OSX can create a patch for set_gfx_mode that detects the RGB/BGR order and sets things up appropriately. ---- |
X-G
Member #856
December 2000
![]() |
Quote: colDest=makecol(getb15(palette[colorIndex]), getg15(palette[colorIndex]), getr15(palette[colorIndex])); Uh... makecol always takes its arguments in the order R, G, B, regardless of platform. -- |
Evert
Member #794
November 2000
![]() |
Quote: In either case I believe this issue has been discussed many times for OSX but I've never seen a solution that caused a good working patch to the lib.. Eh? @OP: Make sure you're loading/creating your graphics after you call set_gfx_mode. Allegro doesn't know the RGB ordering until you call set_gfx_mode(). You may get lucky on one system, but it will fail on others. |
boulifb
Member #7,909
October 2006
|
Actually, I think it is because of the coding of the palettes . I'm not sure yet it comes from the makecol function, but maybe the coding of a word. As I use universal binary compiler, it is maybe the cause. I'll try tonight with the intel compiler. maybe it'll give the correct sorted values (RGB, not BGR). On Windows either virtual running under Parallels Desktop for Mac or native (standard ISO insall on mac or PC) the compistes are RGB sorted, and only on Mac OS X (tiger 10.4.8 - intel) values are BGR. fred. |
Evert
Member #794
November 2000
![]() |
Quote:
Actually, I think it is because of the coding of the palettes . This makes no sense to me... what do you mean? Can you post some sample code to show what you're doing? Aside, can a moderator move this topic to Programming Questions instead of Allegro Development? |
boulifb
Member #7,909
October 2006
|
I do the following:
I call the function that way:
I'm obliged to reverse the color to have the correct display on Windows and Mac OS. Fred. |
Evert
Member #794
November 2000
![]() |
Right. Solution: extract the components from your encoded numbers manually (it only takes a shift and a logical and), or store them as RGB triplets. |
boulifb
Member #7,909
October 2006
|
you mean that I should not use the getr15 getg15 and getb15 functions and I have to rewrite them??? |
Evert
Member #794
November 2000
![]() |
I meant what I wrote. |
boulifb
Member #7,909
October 2006
|
Damned, these functions are so convinient. |
Thomas Harte
Member #33
April 2000
![]() |
I don't know the GBA colour encoding, but if it's 15 bit then something like: ... somewhere in your source before you use them ... #define gba_getb(v) (v&31) #define gba_getg(v) ((v >> 5)&31) #define gba_getr(v) (v >> 10) ... to use them ... r = gba_getr(col); g = gba_getg(col); b = gba_getb(col); Though I may have r, g and b the wrong way round. "&31" effectively says "throw away all but the lowest five bits" and ">> 5" says "move all the bits 5 positions to the right, throw away any that cross the decimal point". [My site] [Tetrominoes] |
boulifb
Member #7,909
October 2006
|
the macros does not seem to work properly: all is almost black GB's colors work like this: As it is 5 bits per color, the MSB is ignored. The goal is to transform 15 bits colors into 32 bits colors using the hardcoded palettes I shown. As shown, the values of the palettes values are coded as a word (unsigned short) which is 16 bits wide. I don't really know how to do that while Allegro does it I use the getr15, getg15 and getb15 functions. |
X-G
Member #856
December 2000
![]() |
Harte's macros will do exactly that. -- |
Evert
Member #794
November 2000
![]() |
The colour values you get out are in the range 0-31, while Allegro's makcol function takes values in the range 0-255, so you'll need to scale them (by a factor 8 or so, though using 255./31. would give you a better result). |
boulifb
Member #7,909
October 2006
|
indeed, I get better results by multiply the composites by 8. I'll tell you tonight how it is on the Macintosh. If I understood well, normally, with this method, it should get the same display results no mater the platform and OS. right? |
X-G
Member #856
December 2000
![]() |
Quote: also, I have to use the makecol24 function instead of makecol and things seems to be ok on Windows. What? Why? Where are you calling it? -- |
boulifb
Member #7,909
October 2006
|
I call makecol24 after the extraction of the 15bits RGB values before applying the color to the pixel. Why? |
X-G
Member #856
December 2000
![]() |
Because there's no reason makecol() should fail unless you're trying to use it before calling allegro_init() and set_gfx_mode() (Assuming you still have to do that). -- |
boulifb
Member #7,909
October 2006
|
Any way, I have just tried on Mac OS X what we did today on Windows that is manully extracting the RGB composites and convert them manually to 32 bits colors. While it is working on Windows, again, colors are still reverted on Mac OS. That's really odd!!! My goal is to have a unique source code based on allegro, no matter the OS it will run on. For better results, I wish to keep the hard coded 15 bits colors in palettes that I apply to the tile sets when loading them. I have supplied the ApplyPalette function to see how I apply the colors. If you have any idea to solve this reversion problem, let me know, I'm opened to any idea. I'm stucked! |
Evert
Member #794
November 2000
![]() |
Post a small example program that reproduces the error. Not a section of code, but something we can compile and run. |
|
1
2
|