DX Render to Texture

BlitzMax Forums/BlitzMax Programming/DX Render to Texture

tonyg(Posted 2006) [#1]
This is a bit hacky and, I'm sure, could be cleaned up.
I have tried to comment but, in some cases, I had no idea what I was doing.
Feedback and comments appreciated.

P.S. Not a huge amount of testing done on this either.
<edit> Hmmm, oddly it remembers images drawn to it between renders but not primitives when they're drawn in the mainloop. Anybody see what's wrong?
<edit> Actually, it just doesn't remember what was rendered. It must be an error in my blt.


TartanTangerine (was Indiepath)(Posted 2006) [#2]
' Because Bmax users DX Texture Manager it is necessary to create a dummy rendertarget surface
' and then blit from that surface to the image surface.

So there is no benefit in using this then? Seems like it would be just as slow to render to the backbuffer, and blit from there to a texture.

You might also want to consider how you would render an entire scene to a texture and how you would deal with transparency.


Grey Alien(Posted 2006) [#3]
or just use Tim's, it's free :-)


tonyg(Posted 2006) [#4]
So there is no benefit in using this then?

Well, the fact it doesn't work is probably more of a limiting factor.
or just use Tim's, it's free :-)

...happier to do that now the source has been released.


tonyg(Posted 2006) [#5]
Tim, I just double-checked your R2T code and it renders to a seperate surface which it then displays.
What I am trying to do here is change the image's texture which is why I need the blt... unless I have missed something.
<edit> In fact, I think we're doing the same thing. My render surface displays correctly and can be drawn. However, I need to then blt the contents of that surface to the image surface.
Does anybody know if this is right...
	Local src[]=[0,0,ImageWidth(image),ImageHeight(image)]  	
	Local dest[]=[0,0,ImageWidth(image),ImageHeight(image)]  
	dest[2]:+dest[0]
	dest[3]:+dest[1]
	' Do the blit from the dummy rendertarget to the image surface.
	TD3D7ImageFrame(image.frame(frame)).surface.Blt dest,mysurf,src,0,Null

?


tonyg(Posted 2006) [#6]
Hmmm... the blit does work but a 'cls' was removing the render. Without it there is a bit of corruption at high speeds
Still lots I don't understand. Once the render-to-texture is complete I want to replace the image surface with the render surface. I guess the only way to do this is to blt *(or bitblt).
Anybody?