Viewport?

Just starting out? Need help? Post your questions and find answers here.
Dither
New User
New User
Posts: 5
Joined: Thu Jul 16, 2015 4:32 pm

Viewport?

Post 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!
User avatar
Comtois
Addict
Addict
Posts: 1431
Joined: Tue Aug 19, 2003 11:36 am
Location: Doubs - France

Re: Viewport?

Post by Comtois »

use CreateCamera() to define a viewport
Please correct my english
http://purebasic.developpez.com/
Dither
New User
New User
Posts: 5
Joined: Thu Jul 16, 2015 4:32 pm

Re: Viewport?

Post 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?
User avatar
Comtois
Addict
Addict
Posts: 1431
Joined: Tue Aug 19, 2003 11:36 am
Location: Doubs - France

Re: Viewport?

Post 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
Please correct my english
http://purebasic.developpez.com/
Dither
New User
New User
Posts: 5
Joined: Thu Jul 16, 2015 4:32 pm

Re: Viewport?

Post by Dither »

Comtois,

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

Best regards.
Julian
Enthusiast
Enthusiast
Posts: 276
Joined: Tue May 24, 2011 1:36 pm

Re: Viewport?

Post by Julian »

Dither
New User
New User
Posts: 5
Joined: Thu Jul 16, 2015 4:32 pm

Re: Viewport?

Post 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.
User avatar
Comtois
Addict
Addict
Posts: 1431
Joined: Tue Aug 19, 2003 11:36 am
Location: Doubs - France

Re: Viewport?

Post by Comtois »

Dither wrote:Thanks, Julian. That is good to know, but ClipOutput does not appear to work with sprites.
Use ClipSprite()
Please correct my english
http://purebasic.developpez.com/
Post Reply