GithubHelp home page GithubHelp logo

4k-intro-template's Introduction

4k intro template

This is (yet another) example minimal template for building 4kB intros (but can apply to other sizes as well) on Windows, with an emphasis on being educational and beginner-friendly, and will eventually improve over time. It was initially inspired by Inigo Quilez's (iq) templates for 4k shader-based intros, but with a more explicit code and lots of comments. It is a command-line only alternative to existing frameworks and only requires Visual Studio Build Tools and common demoscene tools to be installed. This was made in order to clearly detail the compilation process without MSBuild/Visual Studio's automation. For more robust and Visual Studio compatible frameworks, you probably want to look into iq's one or Leviathan.

For complete beginners to demoscene, check out this article on how to Teach Yourself Demoscene in 14 Days.

This template itself contains a very simple example intro that can be built and run directly. The rendering and music generation is mostly based on iq's example, but the synthetizer is custom made (and probably a bad example). Of course, when designing a production demo, you will want adapt, inline, rewrite or remove some of the code here in addition to writing your own.

File structure

  • shaders/: the shaders' sources, minified into shaders.inl during build;
  • main.c: entrypoint, creates the window and starts the music and rendering loop;
  • config.h: global settings;
  • glext.h, khrplatform.h: self-contained interfaces of OpenGL functions;
  • fp.h: useful set of approximate floats (by iq);
  • intro.h/intro.c: rendering initialisation and update;
  • synth.h/synth.c: functions for the audio synthetizer;
  • music.h/music.c: music generation.
  • stb_image_write.h/stb_image_write.c: used to save frames to png, taken from stb;
  • capture.h/capture.c: set of functions used for video capture

Build

Building the intro

The compilation tricks to generate a small executable follow the recommandations described in this article by iq, with some updates. All the build process is contained in the build.ps1 PowerShell script and uses custom minimal JSON configuration files. By default, the debug.json configuration is used. You can add your own for specific configurations.

Building the project requires the following tools to be installed and accessible via a PowerShell command line (e.g. in PATH):

  • Microsoft Visual C++ compiler cl.exe and linker link.exe for x86 (e.g. using the Powershell Developer Command Prompt). These are bundled in the the Build Tools for Visual Studio (note that you don't need to install Visual Studio itself).
  • crinkler
  • shader_minifier

If you are using an antivirus software (Windows Defender included), it is likely to detect the compiled executable as a trojan. You'll need to whitelist the file or the entire folder in your antivirus before compiling or running it.

Build an uncompressed debug version (uses MSVC's linker):

.\build.ps1

or the compressed release (uses crinkler):

.\build.ps1 .\release.json

and run:

.\main.exe

To see all the build options enter:

Get-Help .\build.ps1

Video capture

This requires ffmpeg to be installed and accessible via the command line. Build the intro with the -Capture flag, and run the generated executable:

.\capture_main.exe

Note that the capture executable is non-compressed and fullscreen debug mode. Once capture is complete, frames and audio are stored in the newly created capture folder.

Generate the video file capture.mp4 by calling:

.\encode.ps1

To see encoding options enter:

Get-Help .\encode.ps1

4k-intro-template's People

Contributors

krafpy avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.