PDA

View Full Version : Screen to Texture



NecroDOME
05-10-2006, 05:20 PM
Hi,

I render my wolrd to the screen. Now I want my wolrd to be renderd to a texture FROM the screen.

ps. I can render the world to a texture and render that texture to the screen, but thats not what I want...

jdarling
05-10-2006, 05:26 PM
Is this in OpenGL, SDL, DirectX, or what? In SDL this is easily done with SDL_SaveBMP(Surface, FileName) witch will return a 0 if it fails and >0 if it succeeds (if I remember properly). Same is true for OpenGL and DirectX, I just don't know the calls by heart :)

NecroDOME
05-10-2006, 08:48 PM
I'm using DirectX.

It's not that I need to save it as a bitmap, I just want my world to be on a texture so I can add some calculations on it and render it back to the screen.

grudzio
05-10-2006, 09:39 PM
Why can't you render the scene to the texture with the same dimensions as screen?

JSoftware
06-10-2006, 07:10 AM
Edit: sorry misread your post

NecroDOME
06-10-2006, 12:52 PM
Why can't you render the scene to the texture with the same dimensions as screen?

I already do that. But somhow it gives some wierd results.

See movie:
http://necrodome.homeftp.net/zooi/ScagBug.wmv
http://necrodome.homeftp.net/zooi/ScagBug2.wmv

If I render it directly to the screen, everything is just normal without the black stuff

grudzio
06-10-2006, 01:28 PM
Have you tried to render to texture and render back to screen without any postproccessing? In my opinion there can be two possibilities - wrong texture format (i. e. pixel format) or something is wrong during postproccessing.

If it is not the case then I can't help you (I am OpenGL person). Have you looked at DirectX documentation (http://msdn.microsoft.com/library/default.asp?url=/library/en-us/directx9_c/dx9_graphics_reference.asp)? Maybe there you find something.

JSoftware
06-10-2006, 02:13 PM
do you do something weird to the depth buffer? set alpha or something?

alexione
06-10-2006, 02:59 PM
Hi!

Have you cleared both color and depth buffer before rendering to texture? It is not always sufficient to render background, you need to clear color buffer manually.

Also, you will probably need to clear everything once when you are ready to render texture to screen.

NecroDOME
07-10-2006, 11:32 AM
I clear it when rendering to the texture and I clear everything when rendering the texture to the screen...

The blend mode used for tha particles is Invert Alpha or something.
When I use another blendmode everything is just normal. So it has nothing to do with the z-buffer....

Altrough it could be used to make some funny effects :P

Clootie
07-10-2006, 02:15 PM
You can use IDirect3DDevice9::StretchRect, but it's really not recommended. Most often StretchRect is used in 3D rendering to downsample ("resolve") multisampled render target to plain aliased texture.