Making a viewport should be easy but I would like to know the best way. I'm making an arena shmup and need to know how to make a view that only shows a 800x600 portion of the arena. I have a feeling that there is an inbuilt function but I don't know.
Viewport issues.
BlitzMax Forums/BlitzMax Beginners Area/Viewport issues. PixmapWindow()?
SetViewport()?
Is SetViewport already bugfree? (it seems that on some cards the lower viewport border isn't processed at all)
yes it may be better to use some of the alternative code to viewports floating around like these two (not by me):
' ----------------------------------------------------------------------------- ' cctg_drawimagerect by TonyG (slow?) ' ----------------------------------------------------------------------------- Function cctg_DrawImageRect(image:TImage,x:Int,y:Int,xs:Int,ys:Int,width:Int,height:Int) DrawImage LoadImage(PixmapWindow(LockImage(image),xs,ys,width,height)),x,y End Function ' ----------------------------------------------------------------------------- ' ccDrawImageArea by Ian Duff (faster?) ' ----------------------------------------------------------------------------- Function ccDrawImageArea(image:TImage, x#, y#, rx#, ry#, rw#, rh#, frame=0) 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 End Function
GA, the code I posted is not a viewport replacement but for old, simple drawimagerect in Bmax.
Both the examples in your post work on images and not the render 'screen'.
What is wrong with setviewport?
?
Ryan, what problem, if any, did you have using setviewport? What is it making you look for better methods?
Post some code and then people can see if there's anything that can be done better.
Both the examples in your post work on images and not the render 'screen'.
What is wrong with setviewport?
SuperStrict Graphics 640 , 480 Local image:TImage = LoadImage("max.png") SetViewport 100,100,400,300 While Not KeyHit(key_escape) TileImage image , 0 , 0 Flip Wend
?
Ryan, what problem, if any, did you have using setviewport? What is it making you look for better methods?
Post some code and then people can see if there's anything that can be done better.
oops. Sorry I was using set viewport to draw part of a larger image onto a main image (a loading bar in fact), and I heard that View Ports don't work properly on all cards so I looked into a BPlus style DrawImageRect which you supplied.
Ok I see what happened, i thought setviewport() set the location of the camera, rather i just sets the location of the viewing window. I need to move the camera not the viewing window.
SetOrigin is possibly the command you are after then.