/// <summary>
        /// Initializes graphics objects by loading a specified assembly, instancing the first type that implements
        /// <see cref="IGraphicsFactory"/>, and using the result to initialize the other graphics objects
        /// </summary>
        public static void Initialize( GraphicsInitialization init )
        {
            AppDomain.CurrentDomain.AssemblyResolve +=
                delegate( object sender, ResolveEventArgs args )
                {
                    string renderingDir = Path.GetDirectoryName( init.RenderingAssembly );
                    return Assembly.LoadFrom( Path.Combine( renderingDir, args.Name + ".dll" ) );
                };

            Assembly assembly;
            if ( File.Exists( init.RenderingAssembly ) )
            {
                assembly = Assembly.LoadFrom( init.RenderingAssembly );
            }
            else
            {
                assembly = AppDomain.CurrentDomain.Load( init.RenderingAssembly );
            }
            IGraphicsFactory factory = GetGraphicsFactoryFromAssembly( assembly, init );
            factory.CustomTypes.ScanAssembly( assembly );
            Initialize( factory );
        }
 /// <summary>
 /// Creates graphics initialization data for OpenGl on windows
 /// </summary>
 public static GraphicsInitialization OpenGlCgWindows( )
 {
     GraphicsInitialization init = new GraphicsInitialization
         (
             "Rb.Rendering.OpenGl",
             "Rb.Rendering.OpenGl.Cg",
             "Rb.Rendering.OpenGl.Windows"
         );
     return init;
 }
        /// <summary>
        /// Finds a type in the specified assembly that implements IGraphicsFactory, and returns an instance of that type
        /// </summary>
        private static IGraphicsFactory GetGraphicsFactoryFromAssembly( Assembly assembly, GraphicsInitialization init )
        {
            foreach ( Type type in assembly.GetTypes( ) )
            {
                if ( type.GetInterface( typeof( IGraphicsFactory ).Name ) != null )
                {
                    IGraphicsFactory factory = ( IGraphicsFactory )Activator.CreateInstance( type, init );
                    return factory;
                }
            }

            throw new ArgumentException( string.Format( "No type in assembly \"{0}\" implemented IGraphicsFactory", assembly.FullName ) );
        }