I can't get this to work (Additive Blend function)

Blitz3D Forums/Blitz3D Beginners Area/I can't get this to work (Additive Blend function)

The forum is locked. These are the original blitzbasic.com forums, kept so they can still be read. No new topics, replies or edits can be made here. To join in, head over to the Blitz3D+ forums.

Easy


Graphics3D 800,600,16,0
camera=CreateCamera()

Global Target= CreateImage(64,64)
Global Source1= LoadImage("tex1.bmp")
Global Source2= LoadImage("tex2.bmp")

AddBlend(Source1,Source2,Target)

Repeat
Mil1=MilliSecs() 
UpdateWorld
RenderWorld
SetBuffer BackBuffer()
CopyRect 0,0,64,64,0,0,ImageBuffer(Target),BackBuffer() 
Mil2= MilliSecs() 
Color 255,255,0
Text 4,500,"Render time: "+(Mil2-Mil1)
Flip
Until KeyDown(1)

Function AddBlend(SourceTexture1,SourceTexture2,TargetTexture)
  For x = 0 To 64
    For y = 0 To 64
      SetBuffer ImageBuffer(SourceTexture1)
      GetColor x,y
      r1#=ColorRed()
      g1#=ColorGreen()
      b1#=ColorBlue()
      SetBuffer ImageBuffer(SourceTexture2)
      GetColor x,y
      r2#=ColorRed()
      g2#=ColorGreen()
      b2#=ColorBlue()
      SetBuffer ImageBuffer(TargetTexture)
	Color r1#+r2#,g1#+g2#,b1#+b2#
      Plot x,y
    Next
  Next
End Function



Edit:

r1#+r2# might been higher than 255 and might loop to 0

DrawImage might be faster than CopyRect