Original Post
How to read pixels from the render target at a certain screen location? Is there any method equivalent to glReadPixels? or is it a bit more tricky?
Quote:The pitch you get told when you lock the backbuffer (You get a D3DLOCKED_RECT structure back, which contains the pointer to the data and the pitch). As for the format - you told D3D what format it was in when you created the device, so you should know [smile]. The format is the same as the format of your presentation parameter's BackBufferFormat member. For instance, if you're using D3DFMT_X8R8G8B8, then each pixel is made up of 32 bits (4 bytes). The first byte is unused, the second contains the red value, the third is the green, and the fourth is the blue.
Original post by quaker
And how can I tell the exact order of the color format, bytes are laid out, and what about the pitch thing? All these sound scary to me, as a beginner.
Thanks.
Quote:
Original post by Evil Steve
Bear in mind that this is very slow (I'd imagine it's probably slow in OpenGL too), and you definitely should avoid doing this every frame unless you want to take a severe performance hit.
Quote:So very wrong unfortunately [sad]
Original post by quaker
I'm not intending to read more than a pixel per frame so there will be no performance hit i guess.
Quote:Make sure you check that assumption [wink]
Original post by quaker
It's still not a big hit when it comes to only one pixel per frame.
Quote:Well casting it to a DWORD should work for a 1x1 rect. Anything beyond a 1x1 rect will be more complex though [smile]
Original post by quaker
What should be the equation to read say A8R8G8B8 format from a 1x1 rect (1 pixel)? Thanks alot.
Quote:
Original post by quaker
It's still not a big hit when it comes to only one pixel per frame.
This topic has been locked by a moderator. New replies are not allowed.
With your permission, GameDev.net uses analytics cookies to understand how people use the platform. You can accept analytics or continue with necessary cookies only. Learn more