Round ViewPort... or something like this
BlitzMax Forums/BlitzMax Programming/Round ViewPort... or something like this
| ||
Hi I've programmed a nice, round radarscreen. You can see rotated Images on it, describing kind and direction of what's displayed. Now I've got the Problem that, if some Object has a very big Image, it will overlap and hang around beneath the round radarscreens border. But I want my radarimages to stay in there. I haven't found a round viewport or something so far, so I'd be glad, if anyone knew how to do something like that. |
| ||
Is it not possible to just displayed an image with a hole cut in it over the radar after all other elements have been rendered to it, this would mask out the unwanted parts. Jason. |
| ||
Hm, I wouldn't have a clue with Blitzmax. Good question though... |
| ||
I can't mask it, it would be too slow if I had to grab image each frame... :/ |
| ||
I *think* you're saying your main images are overlapping into your radar. Is that right? Can't you... a) Draw your big images b) Set your radar viewport c) cls d) Draw your radar images. e) Draw your radar circular masking image (i.e. Rectangle with black/transparent) circle. |
| ||
What do you mean with "radar viewport"? My radar is round, it has no viewport. |
| ||
Create a rectangular viewport, cls, draw your radar images to it, then draw an image the same size as your viewport with a circle drawn with transparent colour. *very* quick code... Graphics 800,600,0 image:TImage=LoadImage("max.png") viewport:TImage=CreateImage(100,100) SetColor 255,0,0 DrawRect 0,0,100,100 SetColor 0,0,0 DrawOval 0,0,100,100 GrabImage(viewport,0,0) SetColor 255,255,255 Cls While Not KeyHit(key_escape) Cls DrawImage image,0,0 SetViewport 0,0,100,100 Cls DrawRect 20,20,10,10 DrawImage viewport,0,0 SetViewport 0,0,800,600 Flip Wend You could also draw the oval with colour 1,1,1, draw the viewport image and then the radar images so you don't need the viewport cls. |
| ||
What about angular clip planes? I think DX7 allows upto 32 Simultaneous Clipplanes so you should be able to get a reasonably round circle from that. |
| ||
Sounds like a job for stencil buffers. I know Shagwana did some stuff in Bmax with them. I found these two posts: http://www.blitzbasic.com/Community/posts.php?topic=42622 http://blitzbasic.com/Community/posts.php?topic=49374 |
| ||
why can't you have a round radar image anyway and just draw things inside it? if you're careful it'll still look good without need for clipping stuff. |
| ||
Without viewport you could do this...Graphics 800,600,0 image:TImage=LoadImage("max.png") radar:TImage=LoadImage("radar.png") viewport:TImage=CreateImage(100,100) While Not KeyHit(key_escape) Cls DrawImage image,0,0 DrawImage radar,0,0 DrawRect 20,20,10,10 Flip Wend where viewport image has a 0,0,0 border with a 1,1,1 inner circle. So many possibilities. |
| ||
Sorry, but my radar is halftransparent, I need the Background of it to stay. There is no way of overdrawing anything beneath the radarcircle. :/ |
| ||
I'd do what Beaker says: going for Stencil Buffers. In fact I've been getting some info on how they work, and can be very useful for these things among others |
| ||
I'm not sure about DirectX but in OpenGL, using the Stencil Buffer will help you. You can draw a circle, setting the bits in the stencil buffer, then taking the stencil buffer into account when you render by enable the appropriate testing. It will then only draw where the stencil bits are. You can easily switch it off to draw outside the circle. |
| ||
Hm, okay, I'll try this. |