123
-=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- (c) WidthPadding Industries 1987 0|655|0 -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=- -=+=-
Socoder -> Basic Basement -> Purebasic — no 'Viewport'?

Thu, 16 Jul 2015, 12:17
Dither
Hi all,

So I was pretty well settled on using Purebasic, and there's much I like about it. When I finally got around to playing with the game libraries, I was a little surprised not finding an equivalent to the 'AnimImage' commands from Blitz. But no big deal, as it's not hard to write my own routine for dealing with sprite strips.

Now I can't find anything like 'Viewport' from Blitz, for limiting all rendering to a specified rectangular space on the screen (such as for radar displays, etc.). Anyone know if there's a way to get this functionality in PB?

GLBasic has 'AnimImage' and 'Viewport' commands, but its sound functionality is very limited compared to PB's, and I couldn't even get it to play an MP3 or OGG file on my laptop without crashing.

Hmm. :/
Thu, 16 Jul 2015, 16:56
rockford
TrueFact - GLBasic didn't used to have AnimaImage until I made one in code and it was eventually implemented in the language itself...

Does PureBasic allow "virtual screens"? If so you could try drawing to the back buffer (virtual screen) so you can then "grab" your sprite(s).

PureBasic is not a new product, so someone out there on the dedicated forum(s)? must have solutions. Or maybe not?
Thu, 16 Jul 2015, 17:18
Dither
Wow, rockford, well done getting AnimImage into GLBasic! I wish I had the coding skills for something like that.

I have asked at the official forums. So far, I've gotten one response -- a link with some sample code that seems to show two viewports, each displaying a map composed of colored squares that can be scrolled independently of the other. I guess it's a split screen example of some sort. The viewports are both on top of a black background -- I don't know if there is the capability of having them appear over other graphics. I haven't yet examined the code very closely. It's long, the variable names are in French and, as I'm not a very experienced coder to begin with, it's a little overwhelming.

Yeah, PB uses double buffering. I think the solution you've suggested is the same one I was considering (please correct me if I've got this wrong): Clear the screen; then draw whatever is supposed to appear in the viewport onto the backbuffer; then "grab" the portion of this drawing that corresponds to the dimensions of the viewport; then clear the screen again; then do all the other drawing before popping the "grabbed" viewport sprite on top and flipping the buffers.

Sound about right?
Thu, 16 Jul 2015, 18:16
steve_ancell
I don't like AnimImage either, I can have frames of different sizes when I do my own.
Fri, 17 Jul 2015, 02:57
rockford
Clear the screen; then draw whatever is supposed to appear in the viewport onto the backbuffer; then "grab" the portion of this drawing that corresponds to the dimensions of the viewport; then clear the screen again; then do all the other drawing before popping the "grabbed" viewport sprite on top and flipping the buffers.


You could do it that way, but I wouldn't clear the screen a second time - I'd just completely draw over it with the new stuff. Also, you might only need to grab just a small part of the screen and not a full viewport's worth, so grabbing unnecessary area might waste precious CPU time.

AnimImage is great if you have lots of sprites of the same dimension (which is the norm), otherwise, yes, a tilemap tile-atlas is good. Both have pros and cons.

BTW My actual code wasn't used directly in GLBasic - I just showed that a command such as this was necessary in the grand scheme of things (for things like bitmap text and animated sprites etc. ) and that GLBasic's commands were lacking. Ergo it was introduced in the very next update.
Fri, 17 Jul 2015, 10:27
Dither
Thanks for the advice.
Fri, 17 Jul 2015, 11:02
Dither
Get this — Purebasic has the following command: ClipOutput(x, y, width, height)

But it doesn't work with sprites, only 2D drawing operations (lines, circles, DrawText, etc.). Bah!

It should also work with a loaded 'Image' (slower than a sprite), but I got some very strange results when I tried this — the picture was either relocated and broken into pieces, or else turned into noise.
Fri, 17 Jul 2015, 13:02
rockford
The way I look at things is this - if my current tools don't do the job I want them to do, and I cant force them to do the task, it's time to replace them.

I've replaced my development tools a dozen times over the years and I'm always looking for alternatives.

Pehaps it's time to look for alternatives to PureBasic?