LockRect errors (D3D9)

Started by
6 comments, last by Sfpiano 20 years, 9 months ago
So far everything I've seen has something to do with using ddraw surfaces, but I'm not using ddraw in my program.
//------------------------------------------------------------------------------------------------------The great logician Bertrand Russell once claimed that he could prove anything if given that 1+1=1. So one day, some fool asked him, "Ok. Prove that you're the Pope." He thought for a while and proclaimed, "I am one. The Pope is one. Therefore, the Pope and I are one."
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

Simon O'Connor | Technical Director (Newcastle) Lockwood Publishing | LinkedIn | Personal site

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.
//------------------------------------------------------------------------------------------------------The great logician Bertrand Russell once claimed that he could prove anything if given that 1+1=1. So one day, some fool asked him, "Ok. Prove that you're the Pope." He thought for a while and proclaimed, "I am one. The Pope is one. Therefore, the Pope and I are one."
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(...)
//------------------------------------------------------------------------------------------------------The great logician Bertrand Russell once claimed that he could prove anything if given that 1+1=1. So one day, some fool asked him, "Ok. Prove that you're the Pope." He thought for a while and proclaimed, "I am one. The Pope is one. Therefore, the Pope and I are one."
the texture has to be in D3DPOOL_MANAGED to lock. the D3D debug runtime would have told you this
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]
//------------------------------------------------------------------------------------------------------The great logician Bertrand Russell once claimed that he could prove anything if given that 1+1=1. So one day, some fool asked him, "Ok. Prove that you're the Pope." He thought for a while and proclaimed, "I am one. The Pope is one. Therefore, the Pope and I are one."
no one knows?
Now it''s saying: (ERROR) ool must be D3DPOOL_DEFAULT for RenderTarget and DepthStencil Usages
//------------------------------------------------------------------------------------------------------The great logician Bertrand Russell once claimed that he could prove anything if given that 1+1=1. So one day, some fool asked him, "Ok. Prove that you're the Pope." He thought for a while and proclaimed, "I am one. The Pope is one. Therefore, the Pope and I are one."

This topic is closed to new replies.

Advertisement