There are a few methods to do this but the set viewport method appears to cause problems. If there any advantages doing it another way (or problems with this
way) then please post.
This method has cropped up in a few posts so thanks to those who raised it.
P.S. This post is in relation to :
BlitzMaxier 2D? thread
way) then please post.
This method has cropped up in a few posts so thanks to those who raised it.
Strict 'SetGraphicsDriver GLMax2DDriver() Graphics 800,600 Global Image:Timage = LoadImage ("max.png") While Not KeyDown (KEY_ESCAPE) Cls SetColor 255, 255,255 ce_DrawImageRect( Image, 250,100,100,100) ce_DrawImagerect( Image, 250,300, 0, 0, 100,100) Flip Wend End Function ce_DrawImagerect(image:TImage, x#, y#, rx#, ry#, rw#=0, rh#=0, frame=0) If rw=0 And rh=0 DrawImageRect( Image, 250,100,100,100) Else Local origin_x#, origin_y# ; GetOrigin (origin_x, origin_y) Local tw = Pow2Size(image.width) Local th = Pow2Size(image.height) Local rw1# = rx + rw Local rh1# = ry + rh Local x0# = -image.handle_x, x1# = x0 + rw Local y0# = -image.handle_y, y1# = y0 + rh If rw1 > image.width x1 = x0 + rw + image.width - rw1 rw1 = image.width EndIf If rh1 > image.height y1 = y0 + rh + image.height - rh1 rh1 = image.height EndIf ?Win32 If TD3D7ImageFrame(image.frame(frame)) Local frame:TD3D7ImageFrame = TD3D7ImageFrame(image.frame(frame)) frame.setUV(rx / tw, ry / th, rw1 / tw, rh1 / th) frame.Draw x0, y0, x1, y1, x + origin_x, y + origin_y frame.setUV(0, 0, image.width / Float(tw), image.height / Float(th)) Else ? Local frame:TGLImageFrame = TGLImageFrame (image.frame(frame)) frame.u0 = rx / tw frame.v0 = ry / th frame.u1 = rw1 / tw frame.v1 = rh1 / th frame.Draw x0, y0, x1, y1, x + origin_x, y + origin_y frame.u0 = 0 frame.v0 = 0 frame.u1 = image.width / Float(tw) frame.v1 = image.height / Float(th) ?Win32 EndIf ? Function Pow2Size(n) Local ry = 1 While ry < n ry :* 2 Wend Return ry End Function EndIf End Function
P.S. This post is in relation to :
BlitzMaxier 2D? thread