#### Archived

This topic is now archived and is closed to further replies.

# How does pitch work???

This topic is 6266 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

## Recommended Posts

Hi everyone...I have a simple but...I am currently confused on how it works..anyway here I go. I was just using the regular way to init my d3d device(I am using directx8) and the thing is I am having problems drawing to the back buffer due to the fact that I don''t know what to divide the pitch by to get the right offset amount. You know for 32 bits you divide the pitch by 4 meaning your accessing 32 bits at a time...well what about a format of R5G6B5 what do you divide the pitch by...the reason I am asking this is because I am getting some funny results dividing by 2???....I thought that you divide by 4 because you want to convert the pitch to 4 bytes each??? anyway can anyone help me explain what is pitch and how to properly format it.....I am doing this because I am adding transparency to my engine and I want to use this method of doing it ....Any help is appreciated.

##### Share on other sites
5+6+5 = 16 = 16bits.

8bits = 1 byte.

1 DWORD = 4 bytes = 32bits
1 WORD = 2 bytes = 16bits

So divide by 2 if you want to access a pixel at a time 16 bit.

But how much you divide by depends on the size of the data type you use to access the memory. For 16bit, this is WORD, for 32bit this is DWORD.

[BTW: I assume you have some valid reason for locking the backbuffer and playing with pixels - it''s the worst way to do graphics on modern PCs - everything is totally serialised - bad...]

--
Simon O''''Connor
Creative Asylum Ltd
www.creative-asylum.com

##### Share on other sites
What you want to do is cast a (DWORD*) pointer to your pitch for processing . ALso Pitch is the piece of memory for display that never gets displayed . Kinda like you can be a millionaire, you carry around 50 bux on you at all times, but the rest of your money is in the bank.

Eric Wright o0Programmer0o

AcidRain Productions

##### Share on other sites
Thanks alot guys....you have helped alot.
I have found the problem and killed it too.

Frank

1. 1
Rutin
62
2. 2
3. 3
4. 4
5. 5

• 13
• 10
• 29
• 20
• 9
• ### Forum Statistics

• Total Topics
633412
• Total Posts
3011754
• ### Who's Online (See full list)

There are no registered users currently online

×