Jump to content
  • Advertisement

Archived

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

chris1234

reading pixels...

This topic is 5996 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

hi, I have two question: 1. how do I read the color values of a single pixel from a texture under Directx8? I''m ussing textured reqtangles which I store in vertexbuffers to make a simple 2d game now for my pixel perfect collision detection I need to know how to read a single pixel from a surface....? or is there maybe a better way to do this? 2. are vertex buffers the best way to store 2 traingles that form a square? or is the a better way and if so...what would that be? any help would be appreciated...thanks Chris

Share this post


Link to post
Share on other sites
Advertisement
1) See below, this is what I do to read a single pixel from a texture. The texture I have is created D3DPOOL_SCRATCH... SCRATCH leaves the file format in CPU memory and I believe it makes its a standard format... So it always ends up being 32 bit even if its a 8 bit greyscale bmp... So my algorithm assumes its 32 bit. (y and x are the location on the BMP)



D3DLOCKED_RECT info;

p_Tex->LockRect(0, &info, 0, D3DLOCK_READONLY | D3DLOCK_NO_DIRTY_UPDATE);

char *pointer;

pointer = (char *)info.pBits;
pointer += (info.Pitch * y);
pointer += (4 * x);

col.b = *pointer;
col.g = *(pointer + 1);
col.r = *(pointer + 2);
col.a = *(pointer + 3);

p_Tex->UnlockRect(0);



2) Yes... Have everything in VertexBuffer.

Share this post


Link to post
Share on other sites

  • Advertisement
×

Important Information

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

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!