Quick/"Smart" way to look behind the canvas?

BlitzMax Forums/BlitzMax Programming/Quick/"Smart" way to look behind the canvas?

kronholm(Posted 2007) [#1]
Bad topic description :) What I want is this:

Mirror-reverse whatever is drawn on the screen, so it looks as if you're looking at it from behind. Maybe it's possible to position the 2d ortho cam behind the canvas, or maybe there's another easy solution.. Anyone know please?


tonyg(Posted 2007) [#2]
You could reverse the UV using SetUV which would be pretty quick. It seems the BlitzMax way is to use XFlipPixmap and YFlipPixmap. Finally, the easy way, you can setscale -1.0,1.0 to flip around X but it moves the imagehandle as well (which you can simply move back with setimagehandle)
Graphics 800 , 600
Local image:TImage = LoadImage("max.png")
'SetImageHandle (image,ImageWidth(image),0)
While Not KeyHit(key_escape)
	Cls
	SetScale -1.0 , 1.0
	DrawImage image , 200 , 200
	Flip
Wend



kronholm(Posted 2007) [#3]
The scale thing really screws up things because of handles :( I've got a lot of different images and they all have default handle (top left corner) set. I don't think it's an option to save the entire screen as a pixmap and then flip it using flippixmap, that would be too slow I think, so I'm left with trying the UV method you mention.

However I was unable to find any info on this command or method (google+forum search), can you perhaps be a bit more specific?


tonyg(Posted 2007) [#4]
The setscale shouldn't be that big a deal if you create a sprite object with a method to switch the handles.
As for SetUv, search the Bmax forums here with 'Setuv'.
and they'll be lots of lovely discussions.
Basically, you reverse the UV drawing so, rather than 0.0,0.0,1.0,1.0 you make it 1.0,1.0,0.0,0.0 (I think).
Here's a quick bit of code :
Function my_setuv(image:TImage,frame:Int,u0#,v0#,u1#,v1#)
	TD3D7ImageFrame(image.frame(frame)).SetUV(u0#,v0#,u1#,v1#)
End Function


Graphics 640,480,0

SetClsColor 255,255,255
Cls

Local base:Timage = LoadImage("max.png")
Local u0#			= 1.0
Local v0#			= 0.0
Local u1#			= 0.0
Local v1#			= 1.0
Local frame:Byte	        = 0
my_setuv(base , 0 , u0 , v0 , u1 , v1)
DrawImage(base,0,0)
Flip
WaitKey()

(obviously that's DX only).
You might also want to look at any code for Textured Polys (texturedpoly) which should use the same SetUV mechanism and might have OGL versions.


Dreamora(Posted 2007) [#5]
any reason that handles need to be at 0,0 instead of automidhandle which would solve this (and I would assume at a later date rotation issues) in a very simple way.


kronholm(Posted 2007) [#6]
The problem with just using setscale -1,-1 is that the sprites will just flip over where they are, it's not the entire screen being flipped, it's just them, if you know what I mean.


Gabriel(Posted 2007) [#7]
Flipping the drawing coordinates would just be a case of this, wouldn't it?

Const ScreenWidth:Int=640
Const HalfWidth:Int=ScreenWidth/2

DrawImage Image,HalfWidth-(X-HalfWidth),Y


Of course, you can probably flip the projection matrix horizontally with Tim's Projection Matrix code and do it without changing any code at all.


kronholm(Posted 2007) [#8]
Got any links for that gabriel?