Page 1 of 1

Viewport?

Posted: Thu Jul 16, 2015 4:47 pm
by Dither
Hi all,

Does Purebasic have an equivalent to the 'viewport' command in Blitz Basic? This command allows you to specify the location and dimensions (in pixels) of a rectangular area on the screen. After it is called, all rendering occurs inside this area without affecting the rest of the screen. This has many uses in games, such as for making a radar display, or a "split screen" mode for a two-player game.

If PB does not have an equivalent command, how would one go about achieving this functionality?

Thanks in advance for any help you can offer!

Re: Viewport?

Posted: Thu Jul 16, 2015 8:53 pm
by Comtois
use CreateCamera() to define a viewport

Re: Viewport?

Posted: Thu Jul 16, 2015 9:03 pm
by Dither
Comtois wrote:use CreateCamera() to define a viewport
Thank you for your reply. I apologize for not clarifying this before: What I am talking about is for 2d graphics. If I understand it correctly, CreateCamera() works with 3d only?

Re: Viewport?

Posted: Thu Jul 16, 2015 9:32 pm
by Comtois
Dither wrote:If I understand it correctly, CreateCamera() works with 3d only?
Yes.
What I am talking about is for 2d graphics.
May be this can help ?

http://www.purebasic.fr/english/viewtop ... 23&start=2

Re: Viewport?

Posted: Fri Jul 17, 2015 12:29 am
by Dither
Comtois,

Thank you for the link! I will study your code example.

Best regards.

Re: Viewport?

Posted: Fri Jul 17, 2015 11:31 am
by Julian

Re: Viewport?

Posted: Fri Jul 17, 2015 6:01 pm
by Dither
Julian wrote:ClipOutput(x, y, Width, Height)

http://www.purebasic.com/documentation/ ... utput.html
Thanks, Julian. That is good to know, but ClipOutput does not appear to work with sprites. Also, it gave a very strange and garbled result when I tried it with a loaded image on a screen (Mac version).

I think my workaround is to draw my 'viewport' contents to the backbuffer, then 'grab' them into a new sprite. Then draw the normal screen contents, with the 'viewport' sprite being added last before flipping the buffers.

Thanks again.

Re: Viewport?

Posted: Sat Jul 18, 2015 8:49 am
by Comtois
Dither wrote:Thanks, Julian. That is good to know, but ClipOutput does not appear to work with sprites.
Use ClipSprite()