Writing a program

Now that we’ve covered the basics of the language, let’s write a simple program

You’ll notice a few things (I’ll reiterate what the code says):

  • Just like in Javascript any code at the root of the file is executed once at the start of the program
  • The main function is called every frame repeatedly after the root code is executed
    • You can expect this to run at roughly 60-120 times per second depending on the end user’s monitor refresh rate. The “framerate” will also slow down if you perform heavy operations inside
    • we call it a “frame” because in the context of drawing we expect the screen to be redrawn every frame
  • The print function is just like console.log in Javascript, feel free to throw any number arguments of any type at it.

Next we'll finally draw a shader!