Skip to main content
GameDev.net gamedev.net
🔒 Locked

Pixel Plotting a texture?

Started by Fourty_Two Jul 13, 2003 at 3:48 PM 1 replies 300+ views
Original Post
Fourty_Two
Fourty_Two
From what I gather from the DirectX SDK you cannot use LockRect() on a texture created with the D3DPOOL_DEFAULT tag, and if you call GetSurfaceLevel() the surface passed retains that inability to be locked. Is there another way for me to get the color of a certain pixel off of a texture?
higherspeed
higherspeed
I''ve had a similar problem in one of my programs. Although I was overwriting a texture. There''s a function that copies one surface to another. In fact there are two functions. One to copy from the default to a systemmem texture and one the other way round. I wanted to copy from a default to a default. So used both.

Now this is a bit of a hack and I imagine there must be a better way. In my program speed didn''t matter, I was only rendering once a mouseclick anyway.

Using this method you can copy to a systemmem texture and check that.


D3DDevice->GetRenderTargetData(surf, interSurf);
D3DDevice->UpdateSurface(interSurf, NULL, texSurf, NULL);



PS. Are you the fourty-two from the Wavelength forums?
Nik02
Nik02
You could create dynamic textures, given your hardware supports it.


Quote from dx sdk:


Keep the following things in mind when working with dynamic textures.

They cannot be managed. For example, their pool cannot be D3DPOOL_MANAGED.
Dynamic textures can be locked, even if they are created in D3DPOOL_DEFAULT.
D3DLOCK_DISCARD is a valid lock flag for dynamic textures.



Though i just realized that you want to read back pixels, then dynamic texs won't work.

[edited by - Nik02 on July 13, 2003 6:32:46 PM]
Niko Suni

Topic Locked

This topic has been locked by a moderator. New replies are not allowed.

Sign in to reply to this topic.