Skip to content

Totally retro 1980s graphics library for C++ with basically no dependencies, with WebAssembly demo.

License

Notifications You must be signed in to change notification settings

jonathan-markland/80GFX

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

80GFX / WebAssembly

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.

Shapes

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.

Polygons and Brushes

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.

Fonts

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

"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".

Implementation Notes

  • 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

Redesign notes

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.

Demonstration Images (as jpegs)

Bar chart with patterned brush.

Bar chart

Pie chart with patterned brush fills, and thick pen outline (circular nib).

Pie chart

Polygon scan converted capital letter 'A' (no beziers).

Capital A

Polygon scan converted Omega symbol with lines and bezier curves, and thickened outline.

Omega demo - filled and outline shape with beziers

Multiple basic shapes contributing to a polygon that is scan-converted in a single pass.

Polygon with holes

Multiple basic shapes contributing to a polygon that is scan-converted in a single pass.

Polygon with holes

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!

Brushes

Font demonstration. Bitmap fonts supported, of user-definable formats.

Font demo

"Direct" drawing: Drawing filled shapes without a polygon scan conversion buffer (or it's associated sort() ! ).

Direct drawing functions

Stretched bitmap drawing used to show a palette.

Palette bitmap demo

Metafile Example

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

About

Totally retro 1980s graphics library for C++ with basically no dependencies, with WebAssembly demo.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages