Rear-view mirror - camera or mirror?

Blitz3D Forums/Blitz3D Programming/Rear-view mirror - camera or mirror?

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.

Use CopyRect to copy each vertical line in the 'mirror' image and flip it horizontally.

I might have some code somewhere...

[edit] Found it. Its a bit untidy, and not commented as it was never written for anybody else to use, but its not difficult to understand.

XX, YY, W and H are the X/Y coords, width and height of the rear view mirror image (which is drawn directly onto the screen with RenderWorld).

The rear view mirror image is then grabbed to an imagebuffer (tmp), flipped horizontally in the For/Next loop into imagebuffer tmp2, and then pasted back to its original position (XX,YY). Finally, the two temporary Imagebuffers are freed.

Function RearViewMirror()
	If CameraMode = 1 Or CameraMode = 3
		XX = (GraphicsWidth() / 2) - ((GraphicsWidth()/4)/2)
		YY = GraphicsHeight() *.05
		W = GraphicsWidth()/4
		H = GraphicsHeight()/12		
		tmp = CreateImage(W,H)
		GrabImage tmp,XX,YY
		tmp2 = CreateImage(W,H)
		SetBuffer ImageBuffer(tmp2)
		For X = 0 To W-1
			CopyRect X,0,1,H-1,W-X,0,ImageBuffer(tmp)
		Next
		Color 0,0,0
		Rect 0,0,ImageWidth(tmp2),ImageHeight(tmp2),False
		SetBuffer BackBuffer()
		DrawBlock tmp2,XX,YY
		FreeImage tmp2
		FreeImage tmp
	EndIf
End Function