DirectX 8, And Older VooDoo Cards

Started by
17 comments, last by Rook 23 years, 3 months ago
I want this info, because I want to know what way I should be ordering the bits in my own graphics format.

  for(Y=0;Y<sizey;Y++){	for(X=0;X<sizex;X++)	{		// Currently RGB		// First Byte		*lpd=0;		lpd++;		byte_offset++;		// Second Byte		*lpd=224;		lpd++;		byte_offset++;	}	lpd+=dyoffset;}  


This testing code will give pure red. (I''ve also tested the pure blue/green). this is where I''m getting the
GGG BBBBB/RRRRR GGG format from.

Ro_Akira
Advertisement
You shouldn''t assume that this format will remain the same, particularly if you want it to work on more than one type of graphics card. Ideally you should check the surface format and reformat your images when they are loaded.
My EnumerateDirectDrawDevices() function reports the position of the R,G and B bits of my Voodoo2 as being:
R G B
11 5 0

This flies in the face of the GGG BBBBB/RRRRR GGG, obviously. But how come that code above does that then? (See diagram down below)

  This is showing what''s being put on the surface, (those binary ''1''s make up the 224. Note how they seem match the GGG BBBBB/RRRRR GGG ''theory''.    byte 1                  byte 2bit 15 14 13 12 11 10 9 8   7 6 5 4 3 2 1 0bin 0  0  0  0  0  0  0 0   1 1 1 1 1 0 0 0[\source]Ro_Akira  
224 makes 11100000 binary, also you are writing it to the second byte which, I think, is the reds (intel is byte reversed)
Try writing 31 (0001 1111) and see if it comes out blue.
Aha! Your right. 1110 0000 does make 224.

(Just to clear this up: Intel bytes are LSByte first (let''s say, in a 16-bit value), and the bits go MSBit first (from left to right?) Also, I''m writing bytes at a time, (instead of WORDs, this shouldn''t matter though...)

Writing 31 to the first byte does make it blue. And writing 248 (which is 1111 1000), to the second makes it red. I''m building up the pixture now of...

XXXB BBBB/RRRRR XXX where X''s are presumed to be the remaining greens... ugh! That looks familiar!I''m not drinking enough coffee or something...

This all leads me to this...
Is it true that when people talk about RGB (or presumably
RRRRR GGG/GGG BBBBB) that in fact, because of Intels way of doing bytes, it actually ends up like GGGB BBBB/RRRRR GGG, for example in a file.

Eh?

P.S. Thanks for this help!

Ro_Akira

Well, if you store it in a word it would be like this

RRRRRGGGGGGBBBBB

but because you are writing one byte at a time, you write like this

GGGBBBBB RRRRRGGG

Because when you write a word to memory the cpu automatically stores it the ''wrong'' way round.

Stick to writing with words (or better still, dwords) as it takes the same time to write 32bits as it does to write 8bits (as long as the data is aligned).
Argh! Excellent. So is this officially RGB, or BGR?! (Just so I''ll know)

Ro_Akira
I''d say, RGB, seeing as red is the most significant
Ah, ''excellent'' (to quote a certain nuclear power plant owner).

Then it''s that RRRRR GGGGGG BBBBB way that I should be writing to my file then (I assume that''s how most 16-bit images are stored).

Thanks for clearing that whole sorry mess up!
Ro_Akira

This topic is closed to new replies.

Advertisement