150 likes | 285 Views
Introduction to demo programming. Martti Nurmikari - Assembly’08. What is a demo?. Programmed, realtime demonstration that combines visuals and audio. What goes in a demo?. Effects (visuals in general) Interface to OS (windowing etc) Resources (images, meshes, shaders..)
E N D
Introduction to demo programming Martti Nurmikari - Assembly’08
What is a demo? • Programmed, realtime demonstration that combines visuals and audio
What goes in a demo? • Effects (visuals in general) • Interface to OS (windowing etc) • Resources (images, meshes, shaders..) • Timeline (what happens when) • Synchronization (visuals to music) • Utilities • Parameters / tweaking
Which platform to choose? • DirectX • modern, Windows only • OpenGL • easy, partly outdated, all modern platforms • Oldskool (c64, MSX, homebrew) • Software rendering • own charm • kind of outdated
The two schools of demomaking • “The Artist’s Way” • Programmer makes a tool that someone (usually artist) uses to make a demo • Big project • Fairlight, Farbrausch, Conspiracy, Still • “The Programmer’s Way” • Better to start out with • Programmer codes visuals • mfx/synesthetics, ASD, Traction..
Some basic goals • Be smart! • learn your programming tools and languages (especially STL!) • Be sensible! • don’t overengineer, stick to simple solutions that work • Be lazy! • write good, reusable code • write systems, not bits of code
Code structure • Keep code and data separate • Always think of reusability
Interface to your operating system • Windowing, keyboard handling, boring stuff • SDL for OpenGL • DirectX SDK examples • Lots of audio libraries (FMOD, BASS) and image libraries (OpenIL, libjpeg, libpng) • Be lazy! • Other people have already written a lot of stuff you can use
Utilities • Simple, small stuff like mathematics, file handling etc. • Primitive rendering/drawing (simple shapes like cubes etc, overlays/images) • Font system
Resources • Do not handle them manually • too much work, easy to create bugs, difficult to share resources between effects • The Manager Pattern • one line of code to bind a texture, for example • easy to implement with a Map • one single point of all operations • good for debugging and tweaking
Timeline • Thousands of lines of if statements..? • why not? • Base effect/scene class from which all other classes are inherited from • each object contains start time, end time, render priority • engine renders them automatically
Synchronization • Triggers • Events • Beat calculation • FFT/audio data • Time in seconds / beat measures
Parameters / tweaking • Some way of tweaking effect values while the demo is running • saves a lot of time and frustration • Read from a text file / XML for example • Play/Pause/Rewind/Reload/Reinit • Add a GUI and you’re halfway to a demotool...
And last, but not least.. the Effects! • Concepts vs. Technology? • preferably both • Source codes to demos available • There is nothing special about demo effects • learn graphics programming properly (or improperly) and you too can make demos • “Sin and cos can build cathedrals”
Question time! • #scenebooth @ IRCNet • I’m on IRC as elsewhere/elsewhere_, or you can mail me at syksyisin@gmail.com • come talk to me in person :) • http://in4k.untergrund.net for 4k intros • http://frontend.outtracks.net for a good example demo/game engine with source codes to demos as well.