Retro 1980's computer graphics rendering library with classic mid-1980s features. Written by Jonathan Markland, using mainly template-based C++, with separated architecture.
May be of interest to eg: hobby OS writers who would like some routines that do software-rendering without dependencies on loads of other stuff.
Could be a good source for enthusiasts who wish to "pick and choose" while making their own graphics library.
Integer-arithmetic implementation.
UPDATE OCT 2018 - Check out the WebAssembly folder for the WebAssembly demo of this.
The library offers a classic list of shapes:
- Point
- Line
- Rectangle
- Triangle
- Bezier curve
- Polygon
- Arc
- Pie slice
- Secant
- Ellipse
- Polygon
All shapes available as outline or filled.
Any shape can "contribute" to a polygon data buffer, which can be scan-converted using a variety of brushes.
- Solid Brush
- Pattern Brush
- Average Mix Brush
Pen facility is present, including a fast solid colour single-pixel pen, and a thickened circular pen of any size, that draws using a brush.
1980s style super-retro blocky fonts rendered from various sources. No anti-aliasing because it's not retro enough. Re-scaling supported.
- 8*N pixel fonts, rendered from statically-allocated font definition.
- Coloured fonts from TGA files (a format Jonathan invented).
"Device" architecture for drawing to:-
- Bitmaps (ie: 2D memory array, or linear frame buffer)
- Measuring extents of any shapes eg: polygons!
- Metafiles (another format Jonathan invented)
- Scaling and translation "device" that adjusts coordinates before piping through to any other "device".
Metafile parsing and replay is supported, targetting any "device".
-
Template based implementation, parameterisable PIXEL type.
-
The "Device" architecture is optional, you can "get in underneath" on a lot of things.
-
Separated point-plot and raster-painting routines.
Shapes can have their outline lines sent to any "Line Receiver" which means:
- Plot on the screen as pixel lines,
- Store in a polygon buffer for scan conversion.
- Store in a fixed-sized array of left/right edge extents, useful for rendering solid-filled triangles without needing a full polygon scan converting "sort" to be done!
Bresenham implementation for lines, circles, and Jonathan's adaptation to ellipses.
- Colour and Mono bitmaps supporting transparent sections by keyed colour
The device interface has some oddities that the user will see. The code contains TODOs to smooth internal design. I am in a process of reviewing the entire design. There are also some optimisation opportunities currently missed.
Bar chart with patterned brush.
Pie chart with patterned brush fills, and thick pen outline (circular nib).
Polygon scan converted capital letter 'A' (no beziers).
Polygon scan converted Omega symbol with lines and bezier curves, and thickened outline.
Multiple basic shapes contributing to a polygon that is scan-converted in a single pass.
Multiple basic shapes contributing to a polygon that is scan-converted in a single pass.
Demonstration of brush types: Solid, Patterned, Average Mix, and painting the R,G,B channels independently. Average Mix isn't very retro, but its in!
Font demonstration. Bitmap fonts supported, of user-definable formats.
"Direct" drawing: Drawing filled shapes without a polygon scan conversion buffer (or it's associated sort() ! ).
Stretched bitmap drawing used to show a palette.
The following illustrates the content of a metafile generated by the system:
brush 4294967295
>poly
rectangle 0 0 640 480
<poly
brush 4278190080
>poly
moveto 286 52
lineto 348 52
lineto 491 430
lineto 438 430
lineto 404 335
lineto 232 335
lineto 196 431
lineto 143 431
lineto 286 52
moveto 316 102
lineto 386 291
lineto 247 291
lineto 316 102
<poly