home *** CD-ROM | disk | FTP | other *** search
- 3 GRAPHICS
-
- 3.1 LOW LEVEL GRAPHICS ROUTINES
-
- Example1
- This example shows how to create your own display, and fill
- it with a lot of pixels in seven different colours.
-
- Example2
- This example shows how to create a large Raster and a smaller
- display. We fill the Raster with a lot of pixels in seven
- different colours and by altering the RxOffset and RyOffset
- values in the RasInfo structure, the Raster is scrolled in
- all directions. This method to scroll a large drawing in full
- speed is used in many games and was even used in my own
- racing game "Car".
-
- Example3
- This example shows how to create a display that covers the
- entire display. This method is called "Overscan", and is
- primarily used in video and graphics programs, but can also
- be used in games etc to make the display more interesting.
-
- Example4
- This example demonstrates how to open two different ViewPorts
- on the same display. The first ViewPort is in low resolution
- and use 32 colours, while the second ViewPort is in high
- resolution and only use 2 colours.
-
- Example5
- This example demonstrates how to open a ViewPort in interlace
- mode.
-
- Example6
- This example demonstrates how to create a ViewPort in dual
- playfield mode. Playfield 1 use four colours and is placed
- behind playfield 2 which only use two colours (transparent
- and grey). Playfield 1 is filled with a lot of dots and is
- scrolled around while playfield 2 is is not moved and is
- filled with only five grey rectangles.
-
- Example7
- This example demonstrates how to create a ViewPort with the
- special display mode "Hold and Modify".
-
- Example8
- This example shows how to use the functions: SetAPen(),
- SetBPen(), SetOPen(), SetDrMd(), SetDrPt(), WritePixel(),
- ReadPixel(), Move(), Draw(), Text() and finally PolyDraw().
-
- Example9
- This example shows how to flood fill a figure, and how to
- draw filled rectangles (both solid as well as filled with
- single and multi coloured patterns).
-
- Example10
- This example demonstrate how to use the Area Fill functions.
- [ AreaMove(), AreaDraw() and AreaEnd(). ]
-
- Example11
- This example demonstrate how to copy rectangular memory areas
- with help of the blitter.
-
-
-
- 3.2 FONTS
-
- Example 1
- This example shows how to open the ROM font "Topaz". (Topaz
- is the standard system font, and is placed in ROM on all
- Amigas. If you have told preferences to use a 60-character
- display the 9 pixel size will be used, else (80-character
- display) the 8 pixel size will be used. This example prints
- some text in both sizes.
-
- Example 2
- This example demonstrates how to change the style of a font.
- We will open the ROM font "Topaz" and change the style to
- underlined, bold and italic. Well, we try to use all
- mentioned styles, but it may happen that we are not allowed
- to use some styles.
-
- Example 3
- This example demonstrates how to open a disk font (Opal, 12)
- and prints some characters with the new font in a window.
- Note! The font "Opal" must exist in the systems FONT:
- directory or you will receive an error message!
-
- Example 4
- This example opens disk fonts and prints some interesting
- information about them. (Height, width, flags, style, etc...)
- Syntax: Example4 [font1] [font2] [font3] ...
- (The largest size of each font will be used.)
-
- Example 5
- This example demonstrates how to use the AvailFonts()
- function. All available fonts (both on the disk as well as in
- the memory) will be listed together with some useful
- information about them.
-
- Example 6
- This example demonstrates how you can use a font loaded from
- a disk in your own Intuition programs.
-
-
-
- 3.3 SPRITES
-
- Example1
- This program shows how to declare and initialize some sprite
- data and a SimpleSprite structure. It also shows how to
- reserve a sprite (sprite 2), and how to move it around. The
- user moves the sprite by pressing the arrow keys.
-
- Example2
- This program shows how to declare and initialize some sprite
- data and a SimpleSprite structure. It also shows how to
- reserve a sprite (sprite 2), and how to move it around. The
- user moves the sprite by pressing the arrow keys. In this
- example we animate the sprite (6 frames, taken from
- the arcade game Miniblast).
-
- Example3
- This program shows how to set up a 15 coloured sprite, and
- how to move it around.
-
-
-
- 3.4 VSPRITES
-
- Example1
- This example demonstrates how to get and use a VSprite.
- The VSprite can be moved around by the user by pressing
- the arrow keys.
-
- Example2
- This example demonstrates how to use several VSprites each
- with its own colour table.
-
- Example3
- This program demonstrates how to animate several (!) VSprites.
-
- Example4
- This example demonstrates how to use a VSpriteon a display
- you have created yourself. We must now use the low level
- functions MrgCop(), and LoadView(), instead of the more
- sophisticated functions MakeScreen(), RethinkDisplay().
-
-
-
- 3.5 BOBS
-
- Example 1
- This example demonstrates how to use a BOB. This BOB does
- not have any features like saving the background, have
- transparent parts etc. It is simply a BOB which can be
- moved around the screen by pressing the arrow keys.
-
- Since this BOB will not restore the background, it will
- leave a trace of lines after itself while it is moving.
- As you will also notice, the BOB will not have any
- transparent parts. If you move the BOB over some lines
- there will appear to be a box around the BOB.
-
- Example 2
- This example demonstrates how to use a BOB that restores
- the background as it is moving around on the display. This
- time we use a high resolution screen, and the BOB will
- therefore also be smaller than in the previous example.
- Normal hardware sprites as well as VSprites are not
- affected by the display modes, while BOBs are.
-
- Example 3
- This example demonstrates how to use a BOB that has
- transparent areas. The BOB will also restore the
- background while it is moving around. This BOB will
- therefore act like a normal sprite, but can be much
- larger, have more colours, and there is no limit on
- how many BOBs can be used at the same time.
-
- Example 4
- This example demonstrates how to use a BOB on a display
- which we have created ourself. This BOB will also use
- three different images which we switch between to make
- the missile really look like it is flying.
-
- Example 5
- This example demonstrates how to use several BOBs on a
- single display. Note that the BOBs are some times
- flashing and may appear to "flicker". The reason why
- it looks like that is that the Amiga does not manage
- to draw all BOBs before they are displayed. If you
- only intend to use a small limited number of BOBs there
- is usually not any problems. However, if you are using
- many BOBs, as this example demonstrates, they may start
- to "flicker". See next example on how to solve this
- problem.
-
- Example 6
- This example demonstrates how to use a BOB on a double
- buffered display. If you have to use several BOBS it
- may happen that the user can see that the BOBs are
- drawn, and they appear to "flicker". By using a double
- buffered display we can draw the BOBs into one bitmap
- while we are displaying the other. When all objects
- have been drawn we switch bitmap and prepares the
- other and so on...
-
- Example 7
- This example demonstrates how to use several BOBs on a
- double buffered display. No matter how many BOBS we draw
- they will never "flicker" as would happen if we used a
- normal single display. Try and change the "BOB_NR" to 50
- (or even higher) and watch your Amiga sweat!
-
- This example also demonstrates how you can use one single
- image and yet draw the BOBs in several different colours.
-
- Example 8
- This example demonstrates how to use the automatic collision
- routines. 15 BOBs will be randomly placed on the screen. The
- BOBs will have the colours red, green and blue (set randomly).
- The BOBs will then start to move in all directions. If a BOB
- has hit the border of the display the collision routine will
- detect this and change that BOB's direction. If a BOB hits
- another BOB three things may happen:
-
- 1. If one of the BOB was green and the other red both will
- become yellow.
-
- 2. If a blue BOB has hit a green or red BOB the green or red
- BOB will become yellow, while the blue BOB is unchanged.
-
- 3. If a yellow BOB hits another BOB nothing will happen. (No
- collision events will be triggered.)
-
- Example 9
- In this example are we using a BOB as a planet rotating
- around another BOB which is the sun. The planet consists
- of 13 images all in different sizes. By moving the planet
- from side to side and at the same time changing the size of
- the image it looks like the planet is moving around the
- sun. To make the impression realistic we have to place the
- planet in front of the sun when the image of the planet is
- large, and place it behind the sun when the image is small.
-
- This is a simple demonstration how you can use the "Before"
- and "After" fields of the Bob structure. To add a "little
- extra touch" to the program are we altering the colours of
- the planet as it is moving around the sun.
-
- Since we are using quite a lot of graphics I have divided
- this example into three parts. The main module is this file
- "Example9.c". All graphics is placed in the second file
- "Example9Graphics.c", and all constants are declared in the
- third file "Example9.h" which is included by the two other
- modules. Both this file and the graphics file are compiled
- separately and then linked together.
-
- If you are using the SAS (Lattice) C Compiler you simply do
- the following things: (If you do not have the SAS (Lattice)
- C compiler you should check your own manual for more
- information about how to link two modules together.)
- 1. Compile this module: "lc Example9.c"
- 2. Compile the graphic module: "lc Example9Graphics.c"
- 3. Link both files together: "blink with Example9.lnk"
- (The file "Example9.lnk" contains all information the
- linker needs to tie the two modules together.)
-
-
-
- 3.6 GRAPHICAL TRICKS
-
- Example 1
- This example demonstrates how you can use the Blitter to
- copy areas and do logical operations like "AND", "OR", and
- "INVERT". These types of operations are necessary if you
- want to place a picture on top of a background area, but
- leave some areas unchanged.
-
- In this example we will copy a "source" picture on top of
- a "background". Only the masked areas should be copied,
- and the rest of the background should be left unchanged.
- TO illustrate how the binary operations are executed we
- are using two simple areas which should be combined, and we
- are only using four colours.
-
- Source + Destination + Mask = Result
- ------ ----------- ---- ------
- 0110 0123 0110 0113
- 0220 1230 0110 1220
- 3312 2301 1111 3312
- 1002 3012 1001 1012
-
- Example 2
- This example demonstrates what happens if you copy an
- image on top of a background and do not use a mask. As
- you will see, a complete copy of the image will replace
- the background. Even the background colour (black) will
- be copied.
-
- Sometimes you may want to place a picture on top of a
- background, but do not want to copy everything. You may
- for example only want to copy the image, but not the
- background colour around it. To do this you have to use
- a "mask" which tells the computer which pixels of the
- background should be modified, and which should not.
- Next example demonstrates this.
-
- Example 3
- This example demonstrates how you can draw an graphical
- image on top of a background. The interesting thing about
- this example is that we are using the Blitter to draw
- the image together with a mask that makes some areas of
- the image transparent.
-
- Example 4
- This example demonstrates how to use a double buffered
- display. Although we draw a lot of lines the animation
- is smooth and does not "flicker".
-
- Example 5
- This example demonstrates how you can use some small
- graphical blocks ("map blocks") to compose a whole
- display. With this technique can you create hundreds
- of different maps, and still not use much memory.
-
- Example 6
- This example demonstrates how to scroll a large mountain.
- The mountain is much wider than the screen. We can
- therefore only see a part of the mountain as we scroll it.
-
- Note that the mountain is sometimes "flashing"! The reason
- why this happens is that we are scrolling the mountain at
- the same time as we display it. If we are unlucky we have
- only scrolled some of the BitPlanes when the mountain is
- redrawn, and thus the wrong coulours are used. (When we
- scroll a RastPort we actually move the BitPlanes
- separately. If you are using a display with a lot of
- colours, BitPlanes, it may happen that we do not manage to
- move all of them within one display frame.)
-
- To avoid this flickering we need to use a double buffered
- display, where we show one of the screens as we scroll and
- redraw the other. See next example.
-
- Example 7
- This example is very similar to the previous example,
- but this time are we using a double buffered display.
- The mountain will therefore not appear to flash like
- it did before.
-
- Example 8
- This example demonstrates how you can write programs that
- are scrolling huge maps. The maps are of course built with
- help of several map blocks. We are also using a double
- buffered display to avoid any flickering and create smooth
- scrolling. (The scrolling is not perfectly smooth since
- other tasks running at the same time are now and then
- stealing the processor from our program. If you add more
- things to the program like BOBs etc the scrolling will be
- a bit slower but actually also smoother.)
-
- Example 9
- This example demonstrates how you can write a "Text Scroller".
- It can use fonts of any size, and will automatically adjust
- the size of the display. To make the scrolling smooth and nice
- are we using a double buffered display.
-
- Synopsis: Example9 <fontname.font> <size> <textfile>
- fontname: Name of the font you want to use. Eg: Coop.font
- size: Height of the font. Eg: 42
- textfile: File name of the text file. The characters in the
- file will be printed. Eg: Text.doc
-
- E.g.: Example9 Coop.font 42 Text.doc
-
-
-
- 3.7 3D
-
- Box3D
- In this example we will rotate a 3D-rectangle. We will turn
- it in all three dimensions (x, y and z) and use perspective
- (the further away from the eye the smaller the object will
- be).
-
- Commodore3D
- In this example we will rotate a more complex 3D-object. We
- will turn it in all three dimensions (x, y, and z) and use
- perspective.
-
-
-
- 3.8 COPPER
-
- Example 1
- This example demonstrates how you can use your own copper
- list. The copper list is connected to a screen running under
- Intuition.
-
- Example 2
- This example demonstrates how you can use your own copper
- list. The copper list is connected to a display which we have
- made ourself.
-
- Example 3
- This example demonstrates how you can write a "Text Scroller"
- which is both using a double buffered display to create
- smooth scrolling and our own colour copper list.
-
- The font we are using is not loaded from the disk. We have
- instead included it in the program code itself with help of
- "IncludeFont". The copper lists in all these examples were
- made by CopperDraw.
-
- This program is a nice example on how you can combine the
- examples and utilities in this manual to create impressive
- programs, games and demos.
-
- To start the program you have to give it one argument, a file-
- name to the text file which will be printed:
-
- Synopsis: Example3 <textfile>
-
-
-
-