/// <inheritdoc/>
        public void Initialize(UltravioletContext owner, UltravioletFactory factory)
        {
            // Core classes.
            factory.SetFactoryMethod <PlatformNativeSurfaceFactory>((source) => new SDL2PlatformNativeSurface(source));
            factory.SetFactoryMethod <Surface2DFactory>((uv, width, height, options) => new SDL2Surface2D(uv, width, height, options));
            factory.SetFactoryMethod <Surface2DFromSourceFactory>((uv, source, options) => new SDL2Surface2D(uv, source, options));
            factory.SetFactoryMethod <Surface2DFromNativeSurfaceFactory>((uv, surface, options) => new SDL2Surface2D(uv, surface, options));
            factory.SetFactoryMethod <Surface3DFactory>((uv, width, height, depth, bytesPerPixel, options) => new SDL2Surface3D(uv, width, height, depth, bytesPerPixel, options));
            factory.SetFactoryMethod <CursorFactory>((uv, surface, hx, hv) => new SDL2Cursor(uv, surface, hx, hv));

            // Platform services
            var msgboxService = new SDL2MessageBoxService();

            factory.SetFactoryMethod <MessageBoxServiceFactory>(() => msgboxService);

            var clipboardService = new SDL2ClipboardService();

            factory.SetFactoryMethod <ClipboardServiceFactory>(() => clipboardService);

            var powerManagementService = new SDL2PowerManagementService();

            factory.SetFactoryMethod <PowerManagementServiceFactory>(() => powerManagementService);

            // Graphics API services
            factory.SetFactoryMethod <OpenGLEnvironmentFactory>((uv) => new SDL2OpenGLEnvironment(uv));
        }
        /// <inheritdoc/>
        public void Initialize(UltravioletContext owner, UltravioletFactory factory)
        {
            factory.SetFactoryMethod <SongPlayerFactory>((uv) => new FMODSongPlayer(uv));
            factory.SetFactoryMethod <SoundEffectPlayerFactory>((uv) => new FMODSoundEffectPlayer(uv));

            try
            {
                if (UltravioletPlatformInfo.CurrentPlatform == UltravioletPlatform.Android)
                {
                    var shim = Assembly.Load("Ultraviolet.Shims.Android.FMOD.dll");
                    var type = shim.GetTypes().Where(x => x.IsClass && !x.IsAbstract && typeof(FMODPlatformSpecificImplementationDetails).IsAssignableFrom(x)).SingleOrDefault();
                    if (type == null)
                    {
                        throw new InvalidOperationException(FMODStrings.CannotFindPlatformShimClass);
                    }

                    factory.SetFactoryMethod <FMODPlatformSpecificImplementationDetailsFactory>(
                        (uv) => (FMODPlatformSpecificImplementationDetails)Activator.CreateInstance(type));
                }
            }
            catch (FileNotFoundException e)
            {
                throw new InvalidCompatibilityShimException(UltravioletStrings.MissingCompatibilityShim.Format(e.FileName));
            }
        }
        /// <inheritdoc/>
        public void Initialize(UltravioletContext owner, UltravioletFactory factory)
        {
            MonoMac.AppKit.NSApplication.Init();

            factory.RemoveFactoryMethod <SurfaceSourceFactory>();
            factory.RemoveFactoryMethod <SurfaceSaverFactory>();
            factory.RemoveFactoryMethod <IconLoaderFactory>();
            factory.RemoveFactoryMethod <ScreenDensityServiceFactory>();

            factory.SetFactoryMethod <SurfaceSourceFactory>((stream) => new OSXSurfaceSource(stream));
            factory.SetFactoryMethod <SurfaceSaverFactory>(() => new OSXSurfaceSaver());
            factory.SetFactoryMethod <IconLoaderFactory>(() => new OSXIconLoader());
            factory.SetFactoryMethod <ScreenDensityServiceFactory>((display) => new OSXScreenDensityService(display));
        }
		/// <inheritdoc/>
		public void Initialize(UltravioletContext owner, UltravioletFactory factory)
		{
			MonoMac.AppKit.NSApplication.Init();

			factory.RemoveFactoryMethod<SurfaceSourceFactory>();
			factory.RemoveFactoryMethod<SurfaceSaverFactory>();
			factory.RemoveFactoryMethod<IconLoaderFactory>();
			factory.RemoveFactoryMethod<ScreenDensityServiceFactory>();

			factory.SetFactoryMethod<SurfaceSourceFactory>((stream) => new OSXSurfaceSource(stream));
			factory.SetFactoryMethod<SurfaceSaverFactory>(() => new OSXSurfaceSaver());
			factory.SetFactoryMethod<IconLoaderFactory>(() => new OSXIconLoader());
			factory.SetFactoryMethod<ScreenDensityServiceFactory>((display) => new OSXScreenDensityService(display));
		}
Example #5
0
        /// <inheritdoc/>
        public override void Initialize(UltravioletContext uv, UltravioletFactory factory)
        {
            Contract.Require(uv, nameof(uv));

            library.InitializeResource();

            var content  = uv.GetContent();
            var existing = content.Importers.FindImporter(".ttf");

            if (existing != null)
            {
                if (existing.GetType() == typeof(FreeTypeFontImporter))
                {
                    throw new InvalidOperationException(FreeTypeStrings.PluginAlreadyInitialized);
                }
                else
                {
                    throw new InvalidOperationException(FreeTypeStrings.AlternativePluginAlreadyInitialized);
                }
            }

            content.RegisterImportersAndProcessors(typeof(FreeTypeFontPlugin).Assembly);

            factory.SetFactoryMethod <TextShaperFactory>((uvctx, capacity) => new HarfBuzzTextShaper(uvctx, capacity));
        }
        /// <summary>
        /// Registers <see cref="dotTraceProfiler"/> as the profiler for the current Ultraviolet context.
        /// </summary>
        /// <param name="owner">The Ultraviolet context with which to register the profiler.</param>
        /// <param name="factory">The Ultraviolet factory for the Ultraviolet context.</param>
        /// <remarks>This method must be called during the application's initialization phase, before any 
        /// of the static methods on <see cref="UltravioletProfiler"/> have been invoked.</remarks>
        public static void RegisterProfiler(UltravioletContext owner, UltravioletFactory factory)
        {
            Contract.Require(owner, "owner");
            Contract.Require(factory, "factory");

            factory.RemoveFactoryMethod<UltravioletProfilerFactory>();
            factory.SetFactoryMethod<UltravioletProfilerFactory>(uv => new dotTraceProfiler(uv));
        }
Example #7
0
        /// <summary>
        /// Registers <see cref="dotTraceProfiler"/> as the profiler for the current Ultraviolet context.
        /// </summary>
        /// <param name="owner">The Ultraviolet context with which to register the profiler.</param>
        /// <param name="factory">The Ultraviolet factory for the Ultraviolet context.</param>
        /// <remarks>This method must be called during the application's initialization phase, before any
        /// of the static methods on <see cref="UltravioletProfiler"/> have been invoked.</remarks>
        public static void RegisterProfiler(UltravioletContext owner, UltravioletFactory factory)
        {
            Contract.Require(owner, nameof(owner));
            Contract.Require(factory, nameof(factory));

            factory.RemoveFactoryMethod <UltravioletProfilerFactory>();
            factory.SetFactoryMethod <UltravioletProfilerFactory>(uv => new dotTraceProfiler(uv));
        }
        /// <inheritdoc/>
        public void Initialize(UltravioletContext owner, UltravioletFactory factory)
        {
            factory.SetFactoryMethod <SurfaceSourceFactory>((stream) => new AndroidSurfaceSource(stream));
            factory.SetFactoryMethod <SurfaceSaverFactory>(() => new AndroidSurfaceSaver());
            factory.SetFactoryMethod <IconLoaderFactory>(() => new AndroidIconLoader());
            factory.SetFactoryMethod <FileSystemServiceFactory>(() => new FileSystemService());
            factory.SetFactoryMethod <ScreenRotationServiceFactory>((display) => new AndroidScreenRotationService(display));
            factory.SetFactoryMethod <ScreenDensityServiceFactory>((display) => new AndroidScreenDensityService(display));
            factory.SetFactoryMethod <AssemblyLoaderServiceFactory>(() => new AndroidAssemblyLoaderService());

            var softwareKeyboardService = new AndroidSoftwareKeyboardService();

            factory.SetFactoryMethod <SoftwareKeyboardServiceFactory>(() => softwareKeyboardService);
        }
        /// <summary>
        /// Initializes the specified factory.
        /// </summary>
        /// <param name="owner">The Ultraviolet context that owns the initializer.</param>
        /// <param name="factory">The <see cref="UltravioletFactory"/> to initialize.</param>
        public void Initialize(UltravioletContext owner, UltravioletFactory factory)
        {
            factory.SetFactoryMethod<SurfaceSourceFactory>((stream) => new DesktopSurfaceSource(stream));
            factory.SetFactoryMethod<SurfaceSaverFactory>(() => new DesktopSurfaceSaver());
            factory.SetFactoryMethod<IconLoaderFactory>(() => new DesktopIconLoader());
            factory.SetFactoryMethod<FileSystemServiceFactory>(() => new FileSystemService());
            factory.SetFactoryMethod<ScreenRotationServiceFactory>((display) => new DesktopScreenOrientationService(display));
            factory.SetFactoryMethod<ScreenDensityServiceFactory>((display) => new DesktopScreenDensityService(owner, display));

            var softwareKeyboardService = new DesktopSoftwareKeyboardService();
            factory.SetFactoryMethod<SoftwareKeyboardServiceFactory>(() => softwareKeyboardService);
        }
Example #10
0
        /// <summary>
        /// Initializes the specified factory.
        /// </summary>
        /// <param name="owner">The Ultraviolet context that owns the initializer.</param>
        /// <param name="factory">The <see cref="UltravioletFactory"/> to initialize.</param>
        public void Initialize(UltravioletContext owner, UltravioletFactory factory)
        {
            factory.SetFactoryMethod <SurfaceSourceFactory>((stream) => new NETCore2SurfaceSource(stream));
            factory.SetFactoryMethod <SurfaceSaverFactory>(() => new NETCore2SurfaceSaver());
            factory.SetFactoryMethod <IconLoaderFactory>(() => new NETCore2IconLoader());
            factory.SetFactoryMethod <FileSystemServiceFactory>(() => new FileSystemService());
            factory.SetFactoryMethod <ScreenRotationServiceFactory>((display) => new NETCore2ScreenOrientationService(display));

            switch (UltravioletPlatformInfo.CurrentPlatform)
            {
            case UltravioletPlatform.Windows:
                factory.SetFactoryMethod <ScreenDensityServiceFactory>((display) => new NETCore2ScreenDensityService_Windows(owner, display));
                break;

            default:
                factory.SetFactoryMethod <ScreenDensityServiceFactory>((display) => new NETCore2ScreenDensityService(owner, display));
                break;
            }

            var softwareKeyboardService = new NETCore2SoftwareKeyboardService();

            factory.SetFactoryMethod <SoftwareKeyboardServiceFactory>(() => softwareKeyboardService);
        }
        /// <inheritdoc/>
        public void Initialize(UltravioletContext owner, UltravioletFactory factory)
        {
            // Core classes
            factory.SetFactoryMethod<CursorFactory>((uv, surface, hx, hv) => new OpenGLCursor(uv, surface, hx, hv));
            factory.SetFactoryMethod<GeometryStreamFactory>((uv) => new OpenGLGeometryStream(uv));
            factory.SetFactoryMethod<VertexBufferFactory>((uv, vdecl, vcount) => new OpenGLVertexBuffer(uv, vdecl, vcount, gl.GL_STATIC_DRAW));
            factory.SetFactoryMethod<IndexBufferFactory>((uv, itype, icount) => new OpenGLIndexBuffer(uv, itype, icount, gl.GL_STATIC_DRAW));
            factory.SetFactoryMethod<DynamicVertexBufferFactory>((uv, vdecl, vcount) => new OpenGLVertexBuffer(uv, vdecl, vcount, gl.GL_DYNAMIC_DRAW));
            factory.SetFactoryMethod<DynamicIndexBufferFactory>((uv, itype, icount) => new OpenGLIndexBuffer(uv, itype, icount, gl.GL_DYNAMIC_DRAW));
            factory.SetFactoryMethod<Surface2DFactory>((uv, width, height) => new OpenGLSurface2D(uv, width, height));
            factory.SetFactoryMethod<Surface2DFromSourceFactory>((uv, source) => new OpenGLSurface2D(uv, source));
            factory.SetFactoryMethod<Texture2DFactory>((uv, width, height, immutable) => new OpenGLTexture2D(uv, width, height, immutable));
            factory.SetFactoryMethod<RenderTarget2DFactory>((uv, width, height, usage) => new OpenGLRenderTarget2D(uv, width, height, usage));
            factory.SetFactoryMethod<RenderBuffer2DFactory>((uv, format, width, height, options) => new OpenGLRenderBuffer2D(uv, format, width, height, options));

            // Core effects
            factory.SetFactoryMethod<BasicEffectFactory>((uv) => new OpenGLBasicEffect(uv));
            factory.SetFactoryMethod<SpriteBatchEffectFactory>((uv) => new OpenGLSpriteBatchEffect(uv));
            factory.SetFactoryMethod<BlurEffectFactory>((uv) => new OpenGLBlurEffect(uv));

            // BlendState
            var blendStateOpaque = OpenGLBlendState.CreateOpaque(owner);
            var blendStateAlphaBlend = OpenGLBlendState.CreateAlphaBlend(owner);
            var blendStateAdditive = OpenGLBlendState.CreateAdditive(owner);
            var blendStateNonPremultiplied = OpenGLBlendState.CreateNonPremultiplied(owner);

            factory.SetFactoryMethod<BlendStateFactory>((uv) => new OpenGLBlendState(uv));
            factory.SetFactoryMethod<BlendStateFactory>("Opaque", (uv) => blendStateOpaque);
            factory.SetFactoryMethod<BlendStateFactory>("AlphaBlend", (uv) => blendStateAlphaBlend);
            factory.SetFactoryMethod<BlendStateFactory>("Additive", (uv) => blendStateAdditive);
            factory.SetFactoryMethod<BlendStateFactory>("NonPremultiplied", (uv) => blendStateNonPremultiplied);

            // DepthStencilState
            var depthStencilStateDefault = OpenGLDepthStencilState.CreateDefault(owner);
            var depthStencilStateDepthRead = OpenGLDepthStencilState.CreateDepthRead(owner);
            var depthStencilStateNone = OpenGLDepthStencilState.CreateNone(owner);

            factory.SetFactoryMethod<DepthStencilStateFactory>((uv) => new OpenGLDepthStencilState(uv));
            factory.SetFactoryMethod<DepthStencilStateFactory>("Default", (uv) => depthStencilStateDefault);
            factory.SetFactoryMethod<DepthStencilStateFactory>("DepthRead", (uv) => depthStencilStateDepthRead);
            factory.SetFactoryMethod<DepthStencilStateFactory>("None", (uv) => depthStencilStateNone);

            // RasterizerState
            var rasterizerStateCullClockwise = OpenGLRasterizerState.CreateCullClockwise(owner);
            var rasterizerStateCullCounterClockwise = OpenGLRasterizerState.CreateCullCounterClockwise(owner);
            var rasterizerStateCullNone = OpenGLRasterizerState.CreateCullNone(owner);

            factory.SetFactoryMethod<RasterizerStateFactory>((uv) => new OpenGLRasterizerState(uv));
            factory.SetFactoryMethod<RasterizerStateFactory>("CullClockwise", (uv) => rasterizerStateCullClockwise);
            factory.SetFactoryMethod<RasterizerStateFactory>("CullCounterClockwise", (uv) => rasterizerStateCullCounterClockwise);
            factory.SetFactoryMethod<RasterizerStateFactory>("CullNone", (uv) => rasterizerStateCullNone);

            // SamplerState
            var samplerStatePointClamp = OpenGLSamplerState.CreatePointClamp(owner);
            var samplerStatePointWrap = OpenGLSamplerState.CreatePointWrap(owner);
            var samplerStateLinearClamp = OpenGLSamplerState.CreateLinearClamp(owner);
            var samplerStateLinearWrap = OpenGLSamplerState.CreateLinearWrap(owner);
            var samplerStateAnisotropicClamp = OpenGLSamplerState.CreateAnisotropicClamp(owner);
            var samplerStateAnisotropicWrap = OpenGLSamplerState.CreateAnisotropicWrap(owner);

            factory.SetFactoryMethod<SamplerStateFactory>((uv) => new OpenGLSamplerState(uv));
            factory.SetFactoryMethod<SamplerStateFactory>("PointClamp", (uv) => samplerStatePointClamp);
            factory.SetFactoryMethod<SamplerStateFactory>("PointWrap", (uv) => samplerStatePointWrap);
            factory.SetFactoryMethod<SamplerStateFactory>("LinearClamp", (uv) => samplerStateLinearClamp);
            factory.SetFactoryMethod<SamplerStateFactory>("LinearWrap", (uv) => samplerStateLinearWrap);
            factory.SetFactoryMethod<SamplerStateFactory>("AnisotropicClamp", (uv) => samplerStateAnisotropicClamp);
            factory.SetFactoryMethod<SamplerStateFactory>("AnisotropicWrap", (uv) => samplerStateAnisotropicWrap);

            // Platform services
            var powerManagementService = new SDL2PowerManagementService();
            factory.SetFactoryMethod<PowerManagementServiceFactory>(() => powerManagementService);
        }
Example #12
0
        /// <inheritdoc/>
        public void Initialize(UltravioletContext owner, UltravioletFactory factory)
        {
            // Core classes
            factory.SetFactoryMethod <GeometryStreamFactory>((uv) => new OpenGLGeometryStream(uv));
            factory.SetFactoryMethod <VertexBufferFactory>((uv, vdecl, vcount) => new OpenGLVertexBuffer(uv, vdecl, vcount, gl.GL_STATIC_DRAW));
            factory.SetFactoryMethod <IndexBufferFactory>((uv, itype, icount) => new OpenGLIndexBuffer(uv, itype, icount, gl.GL_STATIC_DRAW));
            factory.SetFactoryMethod <DynamicVertexBufferFactory>((uv, vdecl, vcount) => new OpenGLVertexBuffer(uv, vdecl, vcount, gl.GL_DYNAMIC_DRAW));
            factory.SetFactoryMethod <DynamicIndexBufferFactory>((uv, itype, icount) => new OpenGLIndexBuffer(uv, itype, icount, gl.GL_DYNAMIC_DRAW));
            factory.SetFactoryMethod <Texture2DFromRawDataFactory>((uv, pixels, width, height, bytesPerPixel, srgb) => new OpenGLTexture2D(uv, pixels, width, height, bytesPerPixel, srgb));
            factory.SetFactoryMethod <Texture2DFactory>((uv, width, height, options) => new OpenGLTexture2D(uv, width, height, options));
            factory.SetFactoryMethod <Texture3DFromRawDataFactory>((uv, layers, width, height, bytesPerPixel, srgb) => new OpenGLTexture3D(uv, layers, width, height, bytesPerPixel, srgb));
            factory.SetFactoryMethod <Texture3DFactory>((uv, width, height, depth, options) => new OpenGLTexture3D(uv, width, height, depth, options));
            factory.SetFactoryMethod <RenderTarget2DFactory>((uv, width, height, usage) => new OpenGLRenderTarget2D(uv, width, height, usage));
            factory.SetFactoryMethod <RenderBuffer2DFactory>((uv, format, width, height, options) => new OpenGLRenderBuffer2D(uv, format, width, height, options));
            factory.SetFactoryMethod <DynamicTexture2DFactory>((uv, width, height, options, state, flushed) => new OpenGLDynamicTexture2D(uv, width, height, options, state, flushed));
            factory.SetFactoryMethod <DynamicTexture3DFactory>((uv, width, height, depth, options, state, flushed) => new OpenGLDynamicTexture3D(uv, width, height, depth, options, state, flushed));
            factory.SetFactoryMethod <SwapChainManagerFactory>((uv) => new OpenGLSwapChainManager(uv));

            // Core effects
            factory.SetFactoryMethod <BasicEffectFactory>((uv) => new OpenGLBasicEffect(uv));
            factory.SetFactoryMethod <SkinnedEffectFactory>((uv) => new OpenGLSkinnedEffect(uv));
            factory.SetFactoryMethod <SpriteBatchEffectFactory>((uv) => new OpenGLSpriteBatchEffect(uv));
            factory.SetFactoryMethod <BlurEffectFactory>((uv) => new OpenGLBlurEffect(uv));

            // BlendState
            var blendStateOpaque           = OpenGLBlendState.CreateOpaque(owner);
            var blendStateAlphaBlend       = OpenGLBlendState.CreateAlphaBlend(owner);
            var blendStateAdditive         = OpenGLBlendState.CreateAdditive(owner);
            var blendStateNonPremultiplied = OpenGLBlendState.CreateNonPremultiplied(owner);

            factory.SetFactoryMethod <BlendStateFactory>((uv) => new OpenGLBlendState(uv));
            factory.SetFactoryMethod <BlendStateFactory>("Opaque", (uv) => blendStateOpaque);
            factory.SetFactoryMethod <BlendStateFactory>("AlphaBlend", (uv) => blendStateAlphaBlend);
            factory.SetFactoryMethod <BlendStateFactory>("Additive", (uv) => blendStateAdditive);
            factory.SetFactoryMethod <BlendStateFactory>("NonPremultiplied", (uv) => blendStateNonPremultiplied);

            // DepthStencilState
            var depthStencilStateDefault   = OpenGLDepthStencilState.CreateDefault(owner);
            var depthStencilStateDepthRead = OpenGLDepthStencilState.CreateDepthRead(owner);
            var depthStencilStateNone      = OpenGLDepthStencilState.CreateNone(owner);

            factory.SetFactoryMethod <DepthStencilStateFactory>((uv) => new OpenGLDepthStencilState(uv));
            factory.SetFactoryMethod <DepthStencilStateFactory>("Default", (uv) => depthStencilStateDefault);
            factory.SetFactoryMethod <DepthStencilStateFactory>("DepthRead", (uv) => depthStencilStateDepthRead);
            factory.SetFactoryMethod <DepthStencilStateFactory>("None", (uv) => depthStencilStateNone);

            // RasterizerState
            var rasterizerStateCullClockwise        = OpenGLRasterizerState.CreateCullClockwise(owner);
            var rasterizerStateCullCounterClockwise = OpenGLRasterizerState.CreateCullCounterClockwise(owner);
            var rasterizerStateCullNone             = OpenGLRasterizerState.CreateCullNone(owner);

            factory.SetFactoryMethod <RasterizerStateFactory>((uv) => new OpenGLRasterizerState(uv));
            factory.SetFactoryMethod <RasterizerStateFactory>("CullClockwise", (uv) => rasterizerStateCullClockwise);
            factory.SetFactoryMethod <RasterizerStateFactory>("CullCounterClockwise", (uv) => rasterizerStateCullCounterClockwise);
            factory.SetFactoryMethod <RasterizerStateFactory>("CullNone", (uv) => rasterizerStateCullNone);

            // SamplerState
            var samplerStatePointClamp       = OpenGLSamplerState.CreatePointClamp(owner);
            var samplerStatePointWrap        = OpenGLSamplerState.CreatePointWrap(owner);
            var samplerStateLinearClamp      = OpenGLSamplerState.CreateLinearClamp(owner);
            var samplerStateLinearWrap       = OpenGLSamplerState.CreateLinearWrap(owner);
            var samplerStateAnisotropicClamp = OpenGLSamplerState.CreateAnisotropicClamp(owner);
            var samplerStateAnisotropicWrap  = OpenGLSamplerState.CreateAnisotropicWrap(owner);

            factory.SetFactoryMethod <SamplerStateFactory>((uv) => new OpenGLSamplerState(uv));
            factory.SetFactoryMethod <SamplerStateFactory>("PointClamp", (uv) => samplerStatePointClamp);
            factory.SetFactoryMethod <SamplerStateFactory>("PointWrap", (uv) => samplerStatePointWrap);
            factory.SetFactoryMethod <SamplerStateFactory>("LinearClamp", (uv) => samplerStateLinearClamp);
            factory.SetFactoryMethod <SamplerStateFactory>("LinearWrap", (uv) => samplerStateLinearWrap);
            factory.SetFactoryMethod <SamplerStateFactory>("AnisotropicClamp", (uv) => samplerStateAnisotropicClamp);
            factory.SetFactoryMethod <SamplerStateFactory>("AnisotropicWrap", (uv) => samplerStateAnisotropicWrap);
        }
 /// <summary>
 /// Initializes the specified factory.
 /// </summary>
 /// <param name="owner">The Ultraviolet context that owns the initializer.</param>
 /// <param name="factory">The <see cref="UltravioletFactory"/> to initialize.</param>
 public void Initialize(UltravioletContext owner, UltravioletFactory factory)
 {
     factory.SetFactoryMethod(owner.IsRunningInServiceMode ?
         new SpriteBatchFactory((uv) => null) : new SpriteBatchFactory((uv) => new SpriteBatch(uv)));
 }
        /// <summary>
        /// Initializes the specified factory.
        /// </summary>
        /// <param name="owner">The Ultraviolet context that owns the initializer.</param>
        /// <param name="factory">The factory to initialize.</param>
        public void Initialize(UltravioletContext owner, UltravioletFactory factory)
        {
            // Core classes
            factory.SetFactoryMethod <CursorFactory>((uv, surface, hx, hv) => new OpenGLCursor(uv, surface, hx, hv));
            factory.SetFactoryMethod <GeometryStreamFactory>((uv) => new OpenGLGeometryStream(uv));
            factory.SetFactoryMethod <VertexBufferFactory>((uv, vdecl, vcount) => new OpenGLVertexBuffer(uv, vdecl, vcount, gl.GL_STATIC_DRAW));
            factory.SetFactoryMethod <IndexBufferFactory>((uv, itype, icount) => new OpenGLIndexBuffer(uv, itype, icount, gl.GL_STATIC_DRAW));
            factory.SetFactoryMethod <DynamicVertexBufferFactory>((uv, vdecl, vcount) => new OpenGLVertexBuffer(uv, vdecl, vcount, gl.GL_DYNAMIC_DRAW));
            factory.SetFactoryMethod <DynamicIndexBufferFactory>((uv, itype, icount) => new OpenGLIndexBuffer(uv, itype, icount, gl.GL_DYNAMIC_DRAW));
            factory.SetFactoryMethod <Surface2DFactory>((uv, width, height) => new OpenGLSurface2D(uv, width, height));
            factory.SetFactoryMethod <Surface2DFromSourceFactory>((uv, source) => new OpenGLSurface2D(uv, source));
            factory.SetFactoryMethod <Texture2DFactory>((uv, width, height, immutable) => new OpenGLTexture2D(uv, width, height, immutable));
            factory.SetFactoryMethod <RenderTarget2DFactory>((uv, width, height, usage) => new OpenGLRenderTarget2D(uv, width, height, usage));
            factory.SetFactoryMethod <RenderBuffer2DFactory>((uv, format, width, height, options) => new OpenGLRenderBuffer2D(uv, format, width, height, options));

            // Core effects
            factory.SetFactoryMethod <BasicEffectFactory>((uv) => new OpenGLBasicEffect(uv));
            factory.SetFactoryMethod <SpriteBatchEffectFactory>((uv) => new OpenGLSpriteBatchEffect(uv));
            factory.SetFactoryMethod <BlurEffectFactory>((uv) => new OpenGLBlurEffect(uv));

            // BlendState
            var blendStateOpaque           = OpenGLBlendState.CreateOpaque(owner);
            var blendStateAlphaBlend       = OpenGLBlendState.CreateAlphaBlend(owner);
            var blendStateAdditive         = OpenGLBlendState.CreateAdditive(owner);
            var blendStateNonPremultiplied = OpenGLBlendState.CreateNonPremultiplied(owner);

            factory.SetFactoryMethod <BlendStateFactory>((uv) => new OpenGLBlendState(uv));
            factory.SetFactoryMethod <BlendStateFactory>("Opaque", (uv) => blendStateOpaque);
            factory.SetFactoryMethod <BlendStateFactory>("AlphaBlend", (uv) => blendStateAlphaBlend);
            factory.SetFactoryMethod <BlendStateFactory>("Additive", (uv) => blendStateAdditive);
            factory.SetFactoryMethod <BlendStateFactory>("NonPremultiplied", (uv) => blendStateNonPremultiplied);

            // DepthStencilState
            var depthStencilStateDefault   = OpenGLDepthStencilState.CreateDefault(owner);
            var depthStencilStateDepthRead = OpenGLDepthStencilState.CreateDepthRead(owner);
            var depthStencilStateNone      = OpenGLDepthStencilState.CreateNone(owner);

            factory.SetFactoryMethod <DepthStencilStateFactory>((uv) => new OpenGLDepthStencilState(uv));
            factory.SetFactoryMethod <DepthStencilStateFactory>("Default", (uv) => depthStencilStateDefault);
            factory.SetFactoryMethod <DepthStencilStateFactory>("DepthRead", (uv) => depthStencilStateDepthRead);
            factory.SetFactoryMethod <DepthStencilStateFactory>("None", (uv) => depthStencilStateNone);

            // RasterizerState
            var rasterizerStateCullClockwise        = OpenGLRasterizerState.CreateCullClockwise(owner);
            var rasterizerStateCullCounterClockwise = OpenGLRasterizerState.CreateCullCounterClockwise(owner);
            var rasterizerStateCullNone             = OpenGLRasterizerState.CreateCullNone(owner);

            factory.SetFactoryMethod <RasterizerStateFactory>((uv) => new OpenGLRasterizerState(uv));
            factory.SetFactoryMethod <RasterizerStateFactory>("CullClockwise", (uv) => rasterizerStateCullClockwise);
            factory.SetFactoryMethod <RasterizerStateFactory>("CullCounterClockwise", (uv) => rasterizerStateCullCounterClockwise);
            factory.SetFactoryMethod <RasterizerStateFactory>("CullNone", (uv) => rasterizerStateCullNone);

            // SamplerState
            var samplerStatePointClamp       = OpenGLSamplerState.CreatePointClamp(owner);
            var samplerStatePointWrap        = OpenGLSamplerState.CreatePointWrap(owner);
            var samplerStateLinearClamp      = OpenGLSamplerState.CreateLinearClamp(owner);
            var samplerStateLinearWrap       = OpenGLSamplerState.CreateLinearWrap(owner);
            var samplerStateAnisotropicClamp = OpenGLSamplerState.CreateAnisotropicClamp(owner);
            var samplerStateAnisotropicWrap  = OpenGLSamplerState.CreateAnisotropicWrap(owner);

            factory.SetFactoryMethod <SamplerStateFactory>((uv) => new OpenGLSamplerState(uv));
            factory.SetFactoryMethod <SamplerStateFactory>("PointClamp", (uv) => samplerStatePointClamp);
            factory.SetFactoryMethod <SamplerStateFactory>("PointWrap", (uv) => samplerStatePointWrap);
            factory.SetFactoryMethod <SamplerStateFactory>("LinearClamp", (uv) => samplerStateLinearClamp);
            factory.SetFactoryMethod <SamplerStateFactory>("LinearWrap", (uv) => samplerStateLinearWrap);
            factory.SetFactoryMethod <SamplerStateFactory>("AnisotropicClamp", (uv) => samplerStateAnisotropicClamp);
            factory.SetFactoryMethod <SamplerStateFactory>("AnisotropicWrap", (uv) => samplerStateAnisotropicWrap);

            // Platform services
            var powerManagementService = new SDL2PowerManagementService();

            factory.SetFactoryMethod <PowerManagementServiceFactory>(() => powerManagementService);
        }
 /// <summary>
 /// Initializes the specified factory.
 /// </summary>
 /// <param name="owner">The Ultraviolet context that owns the initializer.</param>
 /// <param name="factory">The factory to initialize.</param>
 public void Initialize(UltravioletContext owner, UltravioletFactory factory)
 {
     factory.SetFactoryMethod<SongPlayerFactory>((uv) => new BASSSongPlayer(uv));
     factory.SetFactoryMethod<SoundEffectPlayerFactory>((uv) => new BASSSoundEffectPlayer(uv));
 }
 /// <inheritdoc/>
 public void Initialize(UltravioletContext owner, UltravioletFactory factory)
 {
     factory.SetFactoryMethod <UIViewFactory>((uv, uiPanel, uiPanelDefinition, vmfactory) => ImGuiView.Create(uv, uiPanel, uiPanelDefinition, vmfactory));
 }
 /// <inheritdoc/>
 public void Initialize(UltravioletContext owner, UltravioletFactory factory)
 {
     factory.SetFactoryMethod <FMODPlatformSpecificImplementationDetailsFactory>((uv) => new FMODAndroidSpecificImplementationDetails());
 }
 /// <inheritdoc/>
 public void Initialize(UltravioletContext owner, UltravioletFactory factory)
 {
     factory.SetFactoryMethod<UIViewProviderInitializerFactory>(() => new PresentationFoundationInitializer());
     factory.SetFactoryMethod<UIViewFactory>((uv, uiPanel, uiPanelDefinition, vmfactory) => PresentationFoundationView.Load(uv, uiPanel, uiPanelDefinition, vmfactory));
     factory.SetFactoryMethod<MessageBoxScreenFactory>((mb, mbowner) => new MessageBoxScreen(mb, mbowner.GlobalContent));
 }
 /// <inheritdoc/>
 public void Initialize(UltravioletContext owner, UltravioletFactory factory)
 {
     factory.SetFactoryMethod <SongPlayerFactory>((uv) => new BASSSongPlayer(uv));
     factory.SetFactoryMethod <SoundEffectPlayerFactory>((uv) => new BASSSoundEffectPlayer(uv));
 }
 /// <inheritdoc/>
 public void Initialize(UltravioletContext owner, UltravioletFactory factory)
 {
     factory.SetFactoryMethod <UIViewProviderInitializerFactory>(() => new PresentationFoundationInitializer());
     factory.SetFactoryMethod <UIViewFactory>((uv, uiPanel, uiPanelDefinition, vmfactory) => PresentationFoundationView.Load(uv, uiPanel, uiPanelDefinition, vmfactory));
     factory.SetFactoryMethod <MessageBoxScreenFactory>((mb, mbowner) => new MessageBoxScreen(mb, mbowner.GlobalContent));
 }