Sign in to follow this  

Pick a color from the screen

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

I'm trying to get a color from the mouse coords picked from a map that's placed on a quad and rendered. Is it possible to do it in a simple way and without a shader?

Share this post


Link to post
Share on other sites
As per the forum guidelines:
Quote:
Include all the information that might be needed for people to give a good answer, including the version of DirectX you are using, as well as the SDK version, and any details about your hardware that you think might apply to the problem. If you don't give enough information, people won't be able to help you until you do.


  • What version of DirectX are you using (7,8,9,10) and via what language (VB6,.Net,C,C++)

    I don't think a shader would be able to help you here as it's a write-only style of operation, you still have to use regular locking/reading to access the results of a shader.

    Look into IDirect3DDevice9::GetFrontBufferData() and then IDirect3DSurface9::LockRect() to access the data.

    hth
    Jack

    Share this post


    Link to post
    Share on other sites
    Quote:
    Original post by TheSLASH
    I'm using DirectX 9 and in C++.
    Then my suggestion holds. Once you've finished rendering your image do something like:

    LPDIRECT3DSURFACE9 *pTempSurf = NULL;
    if( SUCCEEDED( device->GetFrontBufferData( 0, pTempSurf ) ) )
    {
    D3DLOCKED_RECT data;
    if( SUCCEEDED( pTempSurf->LockRect( &data, NULL, 0 ) ) )
    {
    UINT32 *pPixelData = reinterpret_cast< UINT32* >( data.pBits );

    // look up the pixels value in 'pPixelData'

    pTempSurf->UnlockRect( );
    }
    }
    SAFE_RELEASE( pTempSurf );


    The above will be very slow (by design). Using GetBackBuffer() will probably be quicker, although it's worth noting that any operation directly on the swap chain will not be quick.

    hth
    Jack

    Share this post


    Link to post
    Share on other sites
    Thank you, for the the info.
    But I have some problem getting Front Buffer, I do get "D3DERR_INVALIDCALL" as result, can't figure out why.

    Should this be in some specific order? I asume that this should be done after the Present-fuction.

    Share this post


    Link to post
    Share on other sites

    This topic is 4301 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.

    Create an account or sign in to comment

    You need to be a member in order to leave a comment

    Create an account

    Sign up for a new account in our community. It's easy!

    Register a new account

    Sign in

    Already have an account? Sign in here.

    Sign In Now

    Sign in to follow this