Slimelite BBS

Rasty things

Back to AMOS_ECHO

From Carl Ireland · 1992-09-02 18:58 · #75529 in AMOS_ECHO

In reply to Rasty things by Graham MacDonald

Pondering the matter of Rasty things,
Graham MacDonald did make public some thoughts to All.

 GM> Has anyone got any documents about rastports and other rast-type
 GM> things?  The only thing I need to know is, what are they???  I've got
 GM> the intuition autdocs, and I'm tyring to understand how to set up a
 GM> screen for graphic use, so I need to know what the best settings are. 
 GM> Am I correct in assuming that the rastport is to do with graphics?  If
 GM> there are no detailed documents, then what RKRMs will I need or are
 GM> there any other good books.  Ta:-)

Well, the RKRM:Libraries describes how the gfx system is organised. Here's the blag:

 There are four important levels to the gfx system: views,viewports,rastports and layers.
 At any one time there is only one 'view', although many can be stored in mem, only one can ever be visible - the reason being that the 'view' is the entire display - all windows,screens etc come together under a single view. Despite it's importance, the view is fairly uninteresting and mainly forms the basis to which other important structures are "attached" - most notably viewports.
 Viewports are the underlying structure of intuition's screens and are an artefact of the copper hardware. Notice how you can have two screens, one pulled down in front of the other, where one has a completely different palette to the other and even a different resolution? Well, what happens is, the copper is runs synchronised to the raster beam on your monitor and can be programmed to automatically affect the custom chips when it gets to a certain position on the screen - and typically this will involve changing the palette, depth etc. Notice how, when you pull a screen down in front of another there a few lines at the top of the front screen that are sort of unused? Well, the length of those lines is determined by the amount of work the copper has to do - during that time the display is in an limbo state and nothing is displayed. You don't have to have a screen to have a viewport - you can create custom viewports and custom views using graphics.library, but it is fairly tricky. The principal reason you might do this is if you don't want a rastport - and hence, if you're writing a game or some such that you want to be fairly OS friendly, you can gain a speed increase of about 20% on gfx rendering.
 Viewports have a substructure attached to them called a 'rasinfo' structure
- this contains information about the position of the viewport relative to the view and the location of the viewport's bitmap. Notice that although viewports and rastports have bitmaps, the view doesn't - it doesn't require one since it's really just a combination of all the viewports. Notice also that viewports can only be stacked vertically, not horizontally.
 Whilst views and viewports are basically a product the hardware, rastports are entirely a software artefact. Simply put, a rastport is a normal bitmap, of any size, which has extra data associated with it. Most importantly, a rastport is associated with one of the available viewports. The rastport is the underlying structure of windows and consequently the other features of rastports are reflected in intuition's windows - i.e. specific "pens" - the APen, BPen, AOLPen etc. Also, rastports have a set of simplified drawing functions e.g. RectFill() associated with them. A rastport is nothing special - it's just a bitmap with some extra data to facilitate rendering operations. They're not much good for complex pictures (a rastport has a normal bitmap associated with it so you can always just draw straight into that and ignore all the fancy stuff) but are ideal for simple rendering - as one finds in windows.
 Layers are another software feature and are usually attached to rastports, but can exist on their own. Windows and screens are examples of layered rastports, but it is possible to have a non-layered rastport. Layers are used to enable the ability of windows to be behind one another without the data of the behind-layer being lost. Most of the time you don't need to worry about them except when (a) You are deciding the refresh mode of your window (b) You are being extremely flash! :> Seriously, the layers functions are amongst the worse documented and consequently most underused parts of the OS, which is a shame 'cos you can do some excellent stuff very simply - like having a pseudo-window within a window without having to worry about clipping (chopping text/gfx when they reach the borders of a window/layer) and, even better, you can do backfill hooks which means that your window can have a nice picture/pattern in the gaps between the gadgets - like WB's backdrops. (And, notably, in MUI windows) They're so easy, but because they're poorly documented you don't see them very often.

 Last word: sprites. Sprites are completely seperate, being another hardware artefact. They can be moved anywhere withing the confines of the current view but have independent resolution and an (almost) independent palette.

And that, as they say, is the blag.

   _   _   _ 
  |_) / \ |_)    AKA:     Carl Ireland
  |_) \_/ |_)    FidoNet: 2:2502/64.73

... A clean desk is a sign of a cluttered desk drawer.
--- Spot 1.3a Unregistered
 * Origin: Clod of Clay (2:2502/64.73)