• 09-11-2006
blackstar
hello there everybody
i`m new to game programming and directx please can anyone tell what do this sentence mean ?

int index = i * lockRect.Pitch / 4 + j;

imageData[index] = 0xffff0000;

what i cant understand why did i multiplyed lockedrect.pitch with i and then divide it by 4+j ?
• 09-11-2006
cboard_member
We're going to need to see more than those two lines. Post us the full program / function.
EDIT: Oh and code tags plskkkthxbai :)
• 09-11-2006
Sentral
Maybe, you should learn the English language before you move onto C++! :)

What are you trying to accomplish with that code? It does nothing from what I can see.
• 09-11-2006
VirtualAce
Quote:

int index = i * lockRect.Pitch / 4 + j;

imageData[index] = 0xffff0000;
The divide by 4 is to convert bytes into DWORDs or UINTs.. Pitch is expressed in bytes. 1 UINT or DWORD is 4 bytes.
You should group your operations with parentheses to make for easier reading of the code.

Code:

```int index = i * (lockRect.Pitch >> 2) + j; imageData[index] = 0xffff0000;```
Shift right is same as dividing by 2^shift.
Shift left is same as multiplying by 2^shift.

I would say your code worked as planned because multiplication is first, then division, then addition, etc, etc. But it's always a good idea to group the operations for clarity and to ensure the operations are being done in the correct order.
• 09-12-2006
blackstar
thanks everybody for the replays
bubba thanks for the explanation
• 09-12-2006
cboard_member
Ah, so we didn't need it all. Rather, Bubba didn't. Good ol' Bubs :)
• 09-12-2006
VirtualAce
I'm here for ya's all. :D

So don't go posting stuff I don't know anything about and we'll get along just fine. The stuff I don't know is pretty much everything John Carmack knows....so no John Carmack threads. :)
• 09-13-2006
Sentral
What are Mega-Textures(tm)? :)
• 09-13-2006
VirtualAce
Those crazy things he talked about for terrain and such which I still don't quite understand how they work or would work. I read the article but it was quite sparse and didn't make sense.
I think it means generating a huge texture and then using it on a surface. The texture is so big that you would not get any repeating or tiling.