Facilis.Graphics Tutorial 1: Hello World!

This tutorial demonstrates how to start coding with the Facilis.Graphics namespace. It does nothing more impressive than create a window and clear it with blue. Remember, Facilis.Graphics is simply a wrapper around rendering APIs like OpenGL and DirectX, so is very low level. If you don't like doing things yourself, then you don't want to use it. Refer to the Facilis.Graphics.Engine tutorials instead. This tutorial will also assume that you have some previous knowledge of graphics programming.

Create a basic c# console application. Add the assemblies Facilis.dll and Facilis.Graphics.OpenGL.dll as references.

You could also add Facilis.Graphics.ManagedDirect3D9.dll, so long as you have the appropriate DirectX SDK or runtimes installed (Feb 2006 as of this writing). You'll also need to disable throwing of the LoaderLock managed debugging assistant; by going to Debug->Exceptions->Managed Debugging Assistants and unchecking LoaderLock.

If you're using VS.NET 2005, replace the automatically generated code in Program.cs with the following. Otherwise, do whatever is appropriate for your platform (paste it into monodevelop, or a text editor, etc).

using System;
using System.Collections.Generic;
using System.Text;

using Facilis;
using Facilis.Graphics;

namespace HelloWorld
    class Program
        static void Main( string[] args )
            RenderSystem renderSystem = new Facilis.Graphics.OpenGL.GLRenderSystem();
            Window window = renderSystem.CreateWindow( 800, 600, 32, false );
            window.Text = "Hello world!";

            while ( window.Created )
                window.BeginRendering( new Viewport( 0.0f, 1.0f, 0.0f, 1.0f, 
                    new ColorValue( 0.0f, 0.0f, 1.0f, 1.0f ) ) );
                window.ClearBuffers( RenderBuffer.Color | RenderBuffer.Depth );


That's all there is to it!

In a nutshell: