Jump to content
  • Advertisement

Archived

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

Sfpiano

LockRect errors (D3D9)

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

So far everything I've seen has something to do with using ddraw surfaces, but I'm not using ddraw in my program.

Share this post


Link to post
Share on other sites
Advertisement
So you''re using D3D then?

If so, by far the most usual way of doing this is to use a texture format with an alpha channel. Any areas you want to be totally transparent have an alpha value of 0, and areas you want to be opaque have an alpha value of 1 (i.e. 255 with an 8bit alpha channel, 15 with a 4bit alpha channel etc).

You can use alpha test to accept/reject pixels based on the value in the alpha channel. Alpha blending doesn''t need to be enabled for alpha test either.


Most of the methods of making the above work based on an RGB colour value would still involve getting the pixels of that colour into the alpha channel. The easiest would be to do this when you load the surface/texture, the D3DX texture loading functions already have a "colour key" value and it''ll do this work for you. Alternatively you could use the pixel pipeline to convert the colour at runtime (for example using a pixel shader to set alpha to 0 when the pixel is a certain colour or 1 when it''s not).



--
Simon O''Connor
ex -Creative Asylum
Programmer &
Microsoft MVP

Share this post


Link to post
Share on other sites
Perhaps ''key'' was the wrong word, I apologize. I want to click on my texture with the mouse, and determine what the color is at that pixel.

Share this post


Link to post
Share on other sites

LPDIRECT3DTEXTURE9 pTex;
D3DXCreateTextureFromFileEx(g_pD3DDevice, "mouseMap.bmp", D3DX_DEFAULT,
D3DX_DEFAULT, D3DX_DEFAULT, D3DUSAGE_RENDERTARGET, D3DFMT_UNKNOWN,
D3DPOOL_DEFAULT, D3DX_FILTER_NONE, D3DX_DEFAULT,
D3DCOLOR_XRGB(0,0,0), NULL, NULL, &pTex);

D3DLOCKED_RECT info;
DWORD pixel;
DWORD Offset;
int i, j;
pTex->LockRect(0, &info,NULL,D3DLOCK_READONLY);
for(i=0; i<64; i++){
for(j=0; j<32; j++){
Offset = (j * info.Pitch) + (i*2);
pixel = *(DWORD *)((DWORD)(info.pBits) + Offset);
outFile< }
}
pTex->UnlockRect(0);


When I run the above code, my program crashes once I call pTex->LockRect(...)

Share this post


Link to post
Share on other sites
I changed it to managed and it still didn't work.

Also, I do have the debug runtime (I believe). How do I set it up to tell me these things?

[edited by - Sfpiano on July 5, 2003 7:16:54 PM]

Share this post


Link to post
Share on other sites
Guest Anonymous Poster
no one knows?

Share this post


Link to post
Share on other sites
Now it''s saying: (ERROR) ool must be D3DPOOL_DEFAULT for RenderTarget and DepthStencil Usages

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!