C/C++ Animation Windows Graphics

ZSystem

ZSystem, a design for generating a whole universe from seeds, has its own article now, with its test programs ZSystem t2 and zterrain running live: ZSystem.

Lewpen's pattern generator and ZGo

Lewpen's pattern generator, a family of programs that each compute an animated pattern every frame, and ZGo, the networks of functions that grew out of it, have their own article now, with live versions: Lewpen's pattern generator.

Triangle rendering in Windows

A Win32 program for drawing texture-mapped triangles; its About box reads “Copyright (C) 2000”. The work is in the Heffer library, with two text files of triangle fillers for 16-bit screens. triangle.cpp opens with a hand-scheduled inner loop:

VERSION 1 - 8 clocks

    ;AGI

    mov eax, ebx
    add edx, 0x00000000       //  SM

START:

    rol eax, width

    and eax, mask
    adc ebx, 0x00000000       //  SM

    add esi, 0x00000000       //  SM

    mov ax, [eax+0x00000000]  //  SM

    mov [edi+ebp], ax

    mov eax, ecx

    rol eax, width

    and eax, mask
    adc ecx, 0x00000000       //  SM

    add edx, 0x00000000       //  SM

    mov ax, [eax+0x00000000]  //  SM

    mov [edi+ebp+1], ax

    mov eax, ebx

    add ebp, 2
    jnc start
Version 1 of the texture-mapping loop, counted at 8 clocks, fetching two texels and writing them out on each pass

Source

PixelText

PixelText 001
-------------

  . Basic render framework
The changelog for PixelText's only version

The font is drawn in a text file, one letter beside the next:

 aaa  aaaa   aaa  aaaa  aaaaa aaaaa  aaa  a   a aaaaa aaaaa a   a a     a   a a   a  aaa  aaaa   aaa  aaaa   aaa  aaaaa a   a a   a a   a a   a a   a aaaaa
a   a a   a a   a a   a a     a     a     a   a   a      a  a  a  a     aa aa aa  a a   a a   a a   a a   a a       a   a   a a   a a   a  a a   a a     a
aaaaa aaaa  a     a   a aaaa  aaaa  a  aa aaaaa   a      a  aaa   a     a a a a a a a   a aaaa  a   a aaaa   aaa    a   a   a a   a a a a   a     a     a
a   a a   a a   a a   a a     a     a   a a   a   a   a  a  a  a  a     a   a a  aa a   a a     a  a  a   a     a   a   a   a  a a  aa aa  a a    a    a
a   a aaaa   aaa  aaaa  aaaaa a      aaa  a   a aaaaa  aa   a   a aaaaa a   a a   a  aaa  a      aa a a   a  aaa    a    aaa    a   a   a a   a   a   aaaaa
The letters A to Z, five pixels high, drawn with the letter a

Source

PolyCSG: boolean operations on polygons August 2002

Constructive solid geometry for 2D polygons: XOR, AND, subtract and OR of polygons, rendered a scanline at a time. There are eleven versions. The changelog at the top of PolyCSG.cpp covers the first nine and then a list of TODOs, and versions 010 and 011 carry the same changelog without adding to it. Version 007 is dated 26 August 2002:

PolyCSG 001
-----------

. Basic render framework up and running

PolyCSG 002
-----------

  . Added Image class
  . Converted buffer to Image class

> First draft of polygon class

  . Polygon edge rendering (scanline based)
  . Not yet tested

PolyCSG 003
-----------

  . Solid rendering

  . Added scanline class
  . Use scanline class for polygon rendering
  . Moved classes to seperate cpp & h files

  . Pass polygon into buffer to render

PolyCSG 004
-----------

  . Removed Poly.render - have to use Image.drawPolygon
  . Added first CSG option - XOR
  . XORPoly.render used to render

PolyCSG 005
-----------

  . Get poly subclass rendering working ( Image.drawPolygon )
  . Add ANDPoly class
  . Polygon intersection (AND) up and running!

PolyCSG 006
-----------

  . Fix in ANDPoly class ( oka && okb -> oka || okb )
  . Added SUBPoly
  . Added ORPoly

PolyCSG 007
-----------

  2002/08/26 01:00 (while smackdown was on after playing cards at the house - Steve won)

  . Added getVScanline function to all polys
  . Added or,and,sub class declarations to main file
  . Renamed Image.drawPolygon to Image.fillPolygon
  . Renamed Image.drawScanline to Image.fillScanline + made private
  . Added Image.drawPolygon, Image.drawScanline, Image.drawVScanline
  . Removed Poly.render (use Image.fillPolygon instead)

  NOW SUPPORTS RENDERING FILLED AND UNFILLED POLYS

PolyCSG 008
-----------

  ~ Antialiased poly functions
  . Added Image.blendCol
  . Initial AA tests.. need edge gradients stored in scanline points

  . RotatePoly class added
  . Poly.firstPoint, nextPoint & peekPoint added

  POLYGON ROTATION WORKING

  . Added pixel text functions to Image

PolyCSG 009
-----------

  . Added TranslatePoly class
  . Fixed memory leak in Redraw() - was not deleting all Poly's

  > Interesting poly shapes

TODOs
-----

  . Poly.recalc function instead of re-making tree each time
    - starts off manual (must be called from main code)
    - change to automatic (use frame counter to avoid re-recalc-ing)
  . TranslatePoly class
  . Predefined polygon classes
    . Regular
    . Star
    . Cog
  . Demo showing different effects

  . Get translation and rotation working for boolean op polygons

  . Optimisation: know v & h bounds of polygon to make render loop quicker
The PolyCSG changelog from 001 to 009, with the list of things still to do

The same class library went on into the RTRay raytracer and the animations below.

Source

Circle animation, Oil and Waves

Three small animations on the same Classes library (image, scanline, polygon and raytrace classes), each starting from the PolyCSG / Motion / RTRay changelog. Circle animation adds:

Animation 001
-------------

  . Renders scrolling array of circles with pulsing wave
The one changelog entry Circle animation adds

Oil is the “basic image template”, with version 001 dated 5 August 2004; Waves is built from the same template.

Source