r2t - Sourcecode.
BlitzMax Forums/BlitzMax Programming/r2t - Sourcecode.
| ||
Author: Tim Fisher License: Indiepath License for non warranted software Summary: This software is free to use, you may distribute within a pre-compiled executable file only. If you have a license question then ask, don't assume! If you don't have a copy of the license then get one. |
| ||
Well, first question about the license.. where is it? |
| ||
I have it (from precompiled 1.18 version) ... its the "default" non-waranty license should should be able to find on license page. ie: the code is licensed to you but still owned by Tim, no waranty in case of damage etc ... Most likely the same as any application either has as license or as some explicit EULA paragraphs. |
| ||
Thanks for the code Tim. Much appreciated as always. |
| ||
Hi Tim, This doesn't look right... Strict Import Indiepath.Render2Texture HideMouse() 'SetGraphicsDriver GLMax2DDriver() Graphics 512,512 tRender.Initialise() Local myImage:TImage = tRender.Create(256,256) Local image:TImage=LoadImage("max.png") Delay (500) ' Do Normal Render to Backbuffer Local ms=MilliSecs() tRender.BackBufferRender_Begin() Cls DrawImage image , 0 , 0 SetColor 255,0,0 DrawRect 100 , 100 , 100 , 100 SetColor 255,255,255 tRender.BackBufferRender_End() Flip 0 Print MilliSecs()-ms WaitKey() Cls ' Do Render To Texture Then draw Textured image on screen ms=MilliSecs() tRender.TextureRender_Begin(myImage) Cls DrawImage image , 0 , 0 SetColor 255,0,0 DrawRect 100 , 100 , 100 , 100 SetColor 255,255,255 tRender.TextureRender_End() SetColor 255,255,255 tRender.BackBufferRender_Begin() Cls DrawImage myImage,20,0 tRender.BackBufferRender_End() Flip 0 Print MilliSecs()-ms WaitKey() The render-to-texture image size is reduced. |
| ||
Thats great news. now i have the source to all modules i use :) |
| ||
TextureRender_Begin has a viewport flag. As a default the viewport is always resized to the size of the render texture. This is a true viewport and as such will re-scale all the GFX to fit within the image bounds. |
| ||
OK, tried it and it works. Thanks |
| ||
Hi, anyone know how to fix it? I can't clean the texture before draw in it (in real size). edit: solved, using rects instead whole buffer (null). Strict Import Indiepath.Render2Texture SetGraphicsDriver D3D7Max2DDriver() Graphics 640,480,0 SetBlend(ALPHABLEND) tRender.Initialise() Local image:TImage=LoadImage("bmax160_2.png") MidHandleImage(image) Local myImage1:TImage = tRender.Create(256,256) Local myImage2:TImage = tRender.Create(256,256) Local rot:Int,x:Int,y:Int Repeat rot:+1 If rot>10 Then rot=0; x=Rand(100,400); y=Rand(100,400) tRender.TextureRender_Begin(myImage1,0) 'fit to the screen size tRender.Cls($90FF0000) DrawImage image,x,y tRender.TextureRender_End() tRender.TextureRender_Begin(myImage2,1) 'fit to the image size tRender.Cls($900000FF) DrawImage image,x,y tRender.TextureRender_End() tRender.BackBufferRender_Begin() tRender.Cls($FF000000) SetScale 10,10 DrawText "********",0,0 DrawText "********",0,130 SetScale 1,1 DrawImage myImage1,0,0 DrawImage myImage2,320,0 tRender.BackBufferRender_End() Flip Until KeyHit(KEY_ESCAPE) |
| ||
K, I've got problems on when I try to use this on a canvas. I get an unhandled memory exception error when I try to switch to a different graphics canvas in my windowed program. So I SetGraphics CanvasGraphics(), then tRender.Initialise, then do my drawing to an image, and when I'm done, display it on one canvas, then switch canvas to update another image (which isn't using the render2texture capabilities) and right when it tries to SetGraphics again ... error. Please help! Thanks. |
| ||
That does not work. The initialisation is special, the image are no BM images and can not be transfered. They are lost if the context is shut down. You would need to copy the render texture content to a regular image if you want to use it on a different canvas. |
| ||
Ok, thanks for the info! I may have a better way of doing it, but only time (and my lack of skill) will tell :D Thank again. |
| ||
I can only agree with that since using Grabimage doesn't work in some situations (while the game is minimized or Alt-tabbed, grabimage isn't mask friendly too). I didn't found anything working yet with the max2D driver :( |