Jump to content
  • Advertisement
Sign in to follow this  
tonymontana

how can i take x,y th texel RGB value()?

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

If you intended to correct an error in the post then please contact us.

Recommended Posts

i want to implement a full collision detection .Therefore, on last case i have to test if one pixel of a texture (texture1) is on another pixel of another texture( texture 2).Simply, all i want to do is actually is to test that x1,y1 pixel of Tex1 on x2,y2 pixel of Tex2.İ will do this by getting alpha value of the texels. How can i get that vale from a D3D Texture?

Share this post


Link to post
Share on other sites
Advertisement
You'll need to use IDirect3DTexture9::LockRect() and examine the raw binary data yourself. It's dependent on what format (D3DFMT_???) you used to create/load the resource, but it should be fairly simple.

As a general tip though, store a copy of the alpha map outside of Direct3D. Querying a single pixel from a D3D texture is likely to be very expensive by comparison to what it could be...

Often it's fairly common to store a "bitmask" for per-pixel collision. Arguably you need not go to the 1bpp level, but storing a Width*Height array of BYTE's in system memory will hardly break the bank - and it'll almost certainly be faster to access than any D3D-based resource.

hth
Jack

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

Participate in the game development conversation and more when you create an account on GameDev.net!

Sign me up!