rifter1818
Junior Contributor
How do i get a texture from a surface in D3D. Note that my surface contains the frontbuffer image.... Thanks, Oh PS YAY 100th Post
// being "display" the D3D Device
// and being "renderedTexture" created with the RenderTarget flag
Surface renderedSurface=renderedTexture.GetSurfaceLevel(0);
display.SetRenderTarget(0, renderedSurface);
// do render here
// clean up if needed
What i need is the code to render to the surface... From a surface. The previous quote shows how to set the surface of the texture as the render target so i can effectivly Draw on the Texture now i allready have a surface that i want to draw on the texture, Thinking about it could i not go ...Menge said:what do you want to do afterall?
- Surfaces cannot be applied as a map on polygons. Textures are there for that.
- Textures are composed of various levels which can be retrieved as Surfaces.
to render to a Surface, just do Device.SetRenderTarget(0, SURFACE);
- The only Textures that have Surfaces that can be rendered to are the ones created with the RenderTarget flag
- These being said, to render to a Texture, u get the Surface of a level and render to that surface.
btw, the last post showed how to render to a texture.
Public Function GetScreenTexture() as texture
Dim tTex as texture
Dim Surf1 as Surface = tTex.GetSurfaceLevel(0)
Dim Surf2 as surface = Device.CreateOffscreenPlainSurface(Screen.width,Screen.Height,Sceen.Format,Pool.Systemmemory)
Device.GetFrontBuffer(0,Surf2)
Surf1 = Surf2
Return tTex
End Function
Surface FrontBufferCopy = Device.CreateOffscreenPlainSurface(WIDTH, HEIGHT, FORMAT, POOL);
Device.GetFrontBufferData(0, FrontBufferCopy);
// according to the documentation, now FrontBufferCopy has a copy of the Front Buffer
// to create the surface
Surface RenderSurface = Device.CreateRenderTarget(WIDTH, HEIGHT, FORMAT, MultiSampleType.None, 0, true);
Device.SetRenderTarget(0, RenderSurface);
// whatever you render between the BeginScene() and EndScene() calls WILL end up on RenderSurface
Surface BackBuffer = Device.GetBackBuffer();
Device.SetRenderTarget(0, BackBuffer);
// whatever you render after this will end up on the backbuffer
Yes im Sorry that my question was a little less than concise. However i still dont see the answer to it here. I still need to make a texture out of a surface. And i dont see the answer here it may be with that locking a surface as a render target but then What i need to know is how do i render the surface onto it.Menge said:ok, glad this was solved for ya.
next time, try to be more concise and clear on what you are asking. doing so usually gets questions answered quicker
Im am just out of it this week (probably may have something to do with the leaky oil tank across the street... Oh well, Thank you for your help. the Update Surface method should work i think.Menge said:well you might want to read my 3 option post again. the code's all there.