Sign in to follow this  

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

Recommended Posts

tonymontana    100
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
jollyjeffers    1570
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.


Share this post

Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this