Sign in to follow this  
arva

Binding an offscreen surface as RT and my actual render target as a texture.

Recommended Posts

arva    100
Hey, as I wrote in topic I have a problem to bind an offscreen surface as RT and my actual render target as a texture. I searched in google about it but it didn't find anything sensible. It finds pages that are telling my that I have to bind something but they are not telling how to do it. I would be grateful If someone would tell me in steps what should I do. Giving some samples for analyze would be also nice.

Share this post


Link to post
Share on other sites
MJP    19787
It basically works like this:

-During initialization, you create a render target texture by using IDirect3DDevice9::CreateTexture and passing D3DUSAGE_RENDERTARGET (make sure you also place it in the DEFAULT pool). Typically you only use 1 mip level.

-When you want to render to that render target, you obtain its top-level surface by calling IDirect3DTexture9::GetSurfaceLevel and passing 0 as the index. You then set that surface as the current render target by calling IDirect3DDevice9::SetRenderTarget.

-When you want to render to the backbuffer again, call IDirect3DDevice9::GetBackBuffer with index 0 and set it as the render target

-You can then use the render target the render target just like any other regular texture. Just make sure it's not set as the current render target when you read from it.

Share this post


Link to post
Share on other sites
arva    100
I must say that I am not sure if I have understood everything in DirectX correctly. How does it works? The game is rendering a scene into a backbuffer, a backbuffer sends it to the front buffer, and the front buffer to the render target? And how does the memory look like in DirectX programs? That is what I've understood: Backbuffer, front buffer and render target are placed in video memory and they are placed there lineary. I'm also not sure if the video memory is in the shared mapped memory. Mainly I want to grab the backbuffer surface of a different, running DirectX application whose source code I don't have. To do that I have to hook DirectX. I've found some tutorials about this but unfortunatelly I find them too poorly explained:/ All I understood (or maybe misunderstood) is that I have to use some memory functions (and for this I have to get how does the memory work-how to get know where the backbuffer lays). Although I hope that there is a function that returns a backbuffer surface only by Window handle. I have to admit that I just started learning DirectX and imediatelly begin to play with hooking - right, know I'm tired - what I do is really going uphill but I don't want to learn for now about these things when I have not enough time. The only things I want to do is grabbing the BackBuffer and then use Pixel Shader for pixel analyzing(I want to check if their color is blue). I also would be grateful for information how to check what is the Pixel format of exterior application pixels(I get know that converting pixels from source buffer to destinated buffer is slowing copying very much). With pixel shader I suppose will also not be easy looking on what I found about it. So in this area I would like also to ask for help - for this moment I'm interesting in nothing more than checking what are the colors of pixels by Pixel Shader. My main problem is that I don't have a larger view of all this stuff :/, however I know how to create basic Direct Window and draw into it, I think I got more or less the DirectX way of working but it is still not enough to do what I try to do. The worst thing in that is that I spend hours and days with absolutely nothing - It goes to this that I have to learn everything step by step spending a lot of time for this. But In that moment I already have other directions in which I want and have to develop so I just can't learn everything right know. That's way I'm asking you for some LARGER AND MORE DETAILED EXPLANATIONS on(I think without clearly saying what functions and variables I have to use I won't be able to understand this):

1. Grabbing the BackBuffer surface from external application to a surface.

2. Getting pixels colors from this surface by Pixel Shader and checking if they are blue.

For all responses Thank You in advance.

Share this post


Link to post
Share on other sites

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