16 bit graphics?

Blitz3D Forums/Blitz3D Programming/16 bit graphics?

Mr.Waterlily(Posted 2007) [#1]
Hi,

I was wondering how Blitz handles 16 bit fullscreens.
Now, I havenīt done much research on this myself so Iīm merely asking you to perhaps save me some time ;)

16 bit pixels usually has 5bit for red, 5 bit for green and 5 bits for blue, with the last bit sometimes used for alpha masking. Thatīs 32 colors for each element.

But all of the command in Blitz are based around 24/32 bits where each element has 256 values.

So how does this work with 16 bit screen? My first guess is that Blitz doesnīt truly support this mode, but as I said, I havent done any research.

Any thoughts?


Dreamora(Posted 2007) [#2]
It supports it but wraps to the target caps. That and it uses dithering in 16bit mode.


Floyd(Posted 2007) [#3]
Any time I've tested this I got 5-6-5, i.e. 6-bit green.

I think 5-5-5 may be possible. It is listed in the BlitzPlus docs for LockedFormat.

But I've never seen 5-5-5 in Blitz3D.


Mr.Waterlily(Posted 2007) [#4]
Hmm, so what can I actually do with a 16 bit screen then?
If I do a ReadPixel() donīt I get the 24 bit values?

And the Load and SaveImage functions, does they truly work with 16 bits if the files/screen is in 16 bit?

"It supports it but wraps to the target caps"
What does this mean? That I always need to do my own conversions(24 bit to 16 bit) if I want the actual 16 bit color values from a pixel on a 16 bit screen?

And about LockedFormat(). Can I somehow set the format of the screen? If it does support both 565 and 555, when are these two formats used, and why?

It seems to me that Blitz requires me to always "think" 24 or 32 bit, and that a 16 bit screen is only there to be compatible with some gfx-cards, or something.


jfk EO-11110(Posted 2007) [#5]
I think you can answer most of your questions with some simple tests. Fact is some grapicscards have a max of 64k Colors. You can load all content as usual, only the output will be 16 Bit. Although, there are some problems, example:

I used to draw circles to the backbuffer , then copied a rectangle to a texturebuffer, then copied the blue channel to the alpha channel (lowest significant byte of the 32 bits to the highest significant byte). This works nicely in 32 Bit mode, but doesn't in 16bit mode.

I didn't have the time to work out a sophisticated solution for this problem, so I simply used LoadTexture with a 32bit pre-made texture (already containing the alpha channel), this works in all modes.