コード例 #1
0
        /// <summary>
        /// Creates a content manager that creates OpenGL object instances, like textures
        /// </summary>
        /// <param name="resourceAssembly">The assembly that contains the resources.</param>
        /// <param name="solutionMode">Should shaders be built with solution on or off</param>
        /// <returns>A content manager instance</returns>
        public static FileContentManager Create(Assembly resourceAssembly, bool solutionMode)
        {
            var streamLoaderCollection = new NamedStreamLoaderCollection();

            //streamLoaderCollection.Add(new NamedFileStreamLoader()); //load arbitrary files TODO: file name resolution
            streamLoaderCollection.Add(new NamedResourceStreamLoader(resourceAssembly));
            streamLoaderCollection.Add(new NamedResourceStreamLoader(Assembly.GetExecutingAssembly()));             //Zenseless.OpenGL resources

            var mgr = new FileContentManager(streamLoaderCollection);

            mgr.RegisterImporter((res) => ContentImporters.StringBuilder(res).ToString());
            mgr.RegisterImporter(ContentImporters.StringBuilder);
            mgr.RegisterImporter <Stream>((it) =>
            {
                var input = it.First().Stream;
                var s     = new MemoryStream();
                it.First().Stream.CopyTo(s);
                s.Position = 0;
                return(s);
            }
                                          );
            mgr.RegisterUpdater <StringBuilder>(ContentImporters.Update);
            mgr.RegisterImporter(ContentImporters.ByteBuffer);
            mgr.RegisterImporter(ContentImporters.DefaultMesh);
            mgr.RegisterImporter(BitmapImporter);
            mgr.RegisterUpdater <Texture2dGL>(Update);
            mgr.RegisterImporter(TextureArrayImporter);
            mgr.RegisterUpdater <TextureArray2dGL>(Update);
            mgr.RegisterImporter((namedStreams) => ShaderProgramImporter(namedStreams, solutionMode, mgr));
            mgr.RegisterUpdater <ShaderProgramGL>((prog, namedStreams) => Update(prog, namedStreams, solutionMode, mgr));
            return(mgr);
        }
コード例 #2
0
        /// <summary>
        /// Creates a content manager that creates OpenGL object instances, like textures
        /// </summary>
        /// <param name="resourceAssembly">The resource assembly that contains the resources.</param>
        /// <returns>A content manager instance</returns>
        public static FileContentManager Create(Assembly resourceAssembly)
        {
            var streamLoader = new StreamLoader();

            streamLoader.AddMappings(resourceAssembly);
            streamLoader.AddMappings(Assembly.GetExecutingAssembly());

            var mgr = new FileContentManager(streamLoader);

            mgr.RegisterImporter(ContentImporters.String);
            mgr.RegisterImporter(ContentImporters.ByteBuffer);
            mgr.RegisterImporter(ContentImporters.DefaultMesh);
            mgr.RegisterImporter(BitmapImporter);
            mgr.RegisterImporter(TextureArrayImporter);
            mgr.RegisterImporter(ShaderProgramImporter);
            mgr.RegisterUpdater <Texture2dGL>(Update);
            mgr.RegisterUpdater <ShaderProgramGL>(Update);
            mgr.RegisterUpdater <TextureArray2dGL>(Update);
            return(mgr);
        }
コード例 #3
0
        /// <summary>
        /// Creates a content manager that creates OpenGL object instances, like textures
        /// </summary>
        /// <param name="resourceAssembly">The assembly that contains the resources.</param>
        /// <param name="solutionMode">Should shaders be built with solution on or off</param>
        /// <returns>A content manager instance</returns>
        public static FileContentManager Create(Assembly resourceAssembly, bool solutionMode)
        {
            var streamLoader = new StreamLoader();

            streamLoader.AddMappings(resourceAssembly);
            streamLoader.AddMappings(Assembly.GetExecutingAssembly()); //Zenseless.OpenGL resources

            var mgr = new FileContentManager(streamLoader);

            mgr.RegisterImporter(ContentImporters.String);
            mgr.RegisterImporter(ContentImporters.ByteBuffer);
            mgr.RegisterImporter(ContentImporters.DefaultMesh);
            mgr.RegisterImporter(BitmapImporter);
            mgr.RegisterUpdater <Texture2dGL>(Update);
            mgr.RegisterImporter(TextureArrayImporter);
            mgr.RegisterUpdater <TextureArray2dGL>(Update);
            mgr.RegisterImporter((namedStreams) => ShaderProgramImporter(namedStreams, solutionMode));
            mgr.RegisterUpdater <ShaderProgramGL>((prog, namedStreams) => Update(prog, namedStreams, solutionMode));

            return(mgr);
        }