Get yer Render 2 Texture Module Here!!

BlitzMax Forums/BlitzMax Programming/Get yer Render 2 Texture Module Here!!

TartanTangerine (was Indiepath)(Posted 2006) [#1]
Mac and Win32 versions in same archive.

Mac users get the OSX version of WinRar from http://www.rarlab.com/download.htm

**Don't use MIPMAPPEDIMAGE, It Dont Work!!!

Get it before it's gone :: http://indiepath.com/public/tRender.rar

Examples and Documentation included....

NOTE: This module is free, support and upgrades are not.


GW(Posted 2006) [#2]
Thanks!


Amon(Posted 2006) [#3]
Thanks dude.


ImaginaryHuman(Posted 2006) [#4]
Cool, although Mac users wont need the rar program - stuffit expander is included in the os afaik and handles rar files.


jkrankie(Posted 2006) [#5]
rar files are handled natively, without stuffit. part of that UNIX bit don't you know

cheers
charlei


jkrankie(Posted 2006) [#6]
in the interests of knowing if i'm using this right, does this make effective use of what the module can achieve?



Strict
Import Indiepath.Render2Texture

Graphics 512,512,0

tRender.Initialise()

Local particleX#[36,100]
Local particleY#[36,100]
Local particleVelocity#=2
Local particleRadius#[36,100]
Local particleAngle#[36,100]
Local particleExists[36,100]
Local i=0
Local o=0
Local ms=MilliSecs()


Local image1:TImage = tRender.Create(512,512)


Global Milisegundos:Int=MilliSecs() 
    Global Fps_Contador:Int=0 
    Global Fps:Int=0 

'set particles into a number of rings

For  i=0 To 35
	For  o=0 To 99
	
	'angle is set so one particle is placed every 10 degrees
	particleAngle[i,o] = i*10
	'and each ring is place ten pixels behing the one in front
	particleRadius[i,o] = -o*10
	
	Next
Next

While Not KeyHit(key_escape)
	
tRender.TextureRender_Begin(image1)
	tRender.BackBufferRender_Begin()
		SetAlpha 0.99
		SetColor 255,0,255
		SetBlend lightblend
	  	DrawImage image1,-10,0
		
		
		For i=0 To 35
			For o=0 To 99
					particleRadius[i,o]=particleRadius[i,o]+particleVelocity
				
					particleAngle[i,o]:+0.1'particleAngle[i,o]+particleVelocity*o/2
				
					particleX[i,o]=(Cos(particleAngle[i,o])*particleRadius[i,o])+320
					particley[i,o]=(Sin(particleAngle[i,o])*particleRadius[i,o])+240
				
					If particleRadius[i,o]>=320
						particleRadius[i,o] = -particleRadius[i,o]
					End If 
				
					If particleRadius[i,o]>=0
						DrawOval particleX[i,o],particley[i,o],3,3
					End If
			Next
		Next
	
	tRender.BackBufferRender_End()
tRender.TextureRender_End()	

Flip 0
Cls
Wend




TartanTangerine (was Indiepath)(Posted 2006) [#7]
Um, not really.

Tell me what you are attempting to do and perhaps I can help.

Tim.


jkrankie(Posted 2006) [#8]
i'm trying to make an image of the whole of the screens contents, then draw it back next frame as well as whatever else is being drawn (spirally thing).

the code does compile and run (and behaves as expected, and is definitely faster than what i have achieved using max2d) but i'm not sure the code is using the module correctly.

the image created is placed at an offset in order to make it look like it's moving.


TartanTangerine (was Indiepath)(Posted 2006) [#9]
Well it's certainly doing what you wanted it to do then but I think you would get the same effect by just rendering normally and not using the CLS command.

These are the steps you should take

1) Begin Render 2 Texture
2) Render All Images to Texture
3) End Render 2 Texture
4) Begin Render 2 Backbuffer
5) Draw All images to Screen
6) Draw Texture as Overlay
7) End Render 2 Backbuffer

Don't Nest the Render Commands as they will have unpredictible results.

Note: Don't use the normal Cls command, use the new tRender.Cls() as it will clear the viewport correctly and allow you to account for alpha backgrounds.


jkrankie(Posted 2006) [#10]
ok, i tried what you suggested, but using render2backbuffer just filled the screen pink (my color in the code), so i removed the render2backbuffer bit.

i thought i would have needed to use the backbuffer, but obviously not. anyway, this code doss exactly what i want quickly.

Strict
Import Indiepath.Render2Texture

Graphics 512,512,0

tRender.Initialise()

Local particleX#[36,100]
Local particleY#[36,100]
Local particleVelocity#=2
Local particleRadius#[36,100]
Local particleAngle#[36,100]
Local particleExists[36,100]
Local i=0
Local o=0
Local image1:TImage = tRender.Create(512,512,MIPMAPPEDIMAGE|FILTEREDIMAGE)

For  i=0 To 35
	For  o=0 To 99
	particleAngle[i,o] = i*10
	particleRadius[i,o] = -o*10
	Next
Next

While Not KeyHit(key_escape)
	
tRender.TextureRender_Begin(image1)

		SetColor 255,0,255
		SetBlend lightblend
		SetRotation MouseX()
	  	DrawImage image1,-10,0
		SetRotation 0
		
		For i=0 To 35
			For o=0 To 99
					particleRadius[i,o]=particleRadius[i,o]+particleVelocity
				
					particleAngle[i,o]:+0.1'=particleAngle[i,o]+particleVelocity*o/2
				
					particleX[i,o]=(Cos(particleAngle[i,o])*particleRadius[i,o])+256
					particley[i,o]=(Sin(particleAngle[i,o])*particleRadius[i,o])+256
				
					If particleRadius[i,o]>=320
						particleRadius[i,o] = -particleRadius[i,o]
					End If 
				
					If particleRadius[i,o]>=0
						DrawOval particleX[i,o],particley[i,o],3,3
					End If
			Next
		Next
	
tRender.TextureRender_End()	

Flip 0

tRender.Cls()
Wend




jkrankie(Posted 2006) [#11]
this module is really cool! look at these things (i think the effect is called feedback)




cheers
cahrlie


TartanTangerine (was Indiepath)(Posted 2006) [#12]
Yeah that's feeback :D

Try making every other frame LIGHTBLEND :D


TaskMaster(Posted 2007) [#13]
Edit: Nevermind, I found a post with the source. Thanks.


Link no workie...

Indiepath, is this still available?

Thanks.


MGE(Posted 2007) [#14]
Where is the post? I'd like to have a peek as well. Thanks!


popcade(Posted 2007) [#15]
This?

http://www.blitzbasic.com/Community/posts.php?topic=60428

Many things need to be fixed, this code is before the newst DX driver change.


TartanTangerine (was Indiepath)(Posted 2007) [#16]
yes, if you want the source then please contact me via indiepath.com


ninjarat(Posted 2007) [#17]
Ooh, this is really cool. I was just wondering how to do that in OpenGL.