Ejemplo n.º 1
0
        private void OnFinishCallback(FLProgram obj, string outputFile)
        {
            Logger.Log(LogType.Log, "Saving Output File: " + Path.GetFullPath(outputFile), 1);
            FLBuffer result = obj.GetActiveBuffer(false);
            Bitmap   bmp    = new Bitmap(result.Width, result.Height);

            CLAPI.UpdateBitmap(CLAPI.MainThread, bmp,
                               CLAPI.ReadBuffer <byte>(CLAPI.MainThread, result.Buffer, (int)result.Size));
            bmp.Save(outputFile);
            result.Dispose();
        }
Ejemplo n.º 2
0
        private static void SaveOutput(string subcategory, Bitmap bmp, FLProgram program, FLSetup setup, string file)
        {
            FLBuffer outP = program.GetActiveBuffer(false);

            CLAPI.UpdateBitmap(CLAPI.MainThread, bmp, outP.Buffer);
            outP.Dispose();
            string p         = Path.GetFileNameWithoutExtension(file) + ".png";
            Stream bmpStream = setup.GetDataFileStream(Path.Combine(subcategory, p));

            bmp.Save(bmpStream, ImageFormat.Png);
            bmpStream.Close();
        }
Ejemplo n.º 3
0
        protected override void InitializeScene()
        {
            creator       = BufferCreator.CreateWithBuiltInTypes();
            iset          = FLInstructionSet.CreateWithBuiltInTypes(CLAPI.MainThread, "assets/kernel/");
            checkPipeline = FLProgramCheckBuilder.CreateDefaultCheckBuilder(iset, creator);
            parser        = new FLParser(iset, creator);
            checkPipeline.Attach(parser, true);

            Add(DebugConsoleComponent.CreateConsole());
            Matrix4 proj = Matrix4.CreatePerspectiveFieldOfView(
                MathHelper.DegreesToRadians(75f), //Field of View Vertical
                16f / 9f,                         //Aspect Ratio
                0.1f,                             //Near Plane
                1000f);                           //Far Plane

            BasicCamera bc = new BasicCamera(proj, Vector3.Zero);

            Add(bc);       //Adding the BasicCamera(That is a gameobject under the hood) to the scene to receive events
            SetCamera(bc); //Sets the Camera as the "active" camera that the scene will be rendered from.


            GameObject box = new GameObject(-Vector3.UnitZ * 4, "Box");  //Creating a new Empty GameObject
            LitMeshRendererComponent lmr = new LitMeshRendererComponent( //Creating a Renderer Component
                DefaultFilepaths.DefaultLitShader,                       //The OpenGL Shader used(Unlit and Lit shaders are provided)
                Prefabs.Cube,                                            //The Mesh that is going to be used by the MeshRenderer
                tex,                                                     //Diffuse Texture to put on the mesh
                1);                                                      //Render Mask (UI = 1 << 30)

            box.AddComponent(lmr);                                       //Attaching the Renderer to the GameObject
            box.AddComponent(new RotateSelfComponent());                 //Adding a component that rotates the Object on the Y-Axis
            Add(box);                                                    //Adding the Object to the Scene.


            FLBuffer buffer =
                new FLBuffer(TextureLoader.TextureToMemoryBuffer(CLAPI.MainThread, tex, "BufferForFLProgram"), 128,
                             128);


            FLProgram program = parser.Process(new FLParserInput("assets/filter/red.fl")).Initialize(iset);


            program.Run(CLAPI.MainThread, buffer, true);

            FLBuffer result = program.GetActiveBuffer(false);

            byte[] dat = CLAPI.ReadBuffer <byte>(CLAPI.MainThread, result.Buffer, (int)result.Buffer.Size);
            //Create a texture from the output.
            TextureLoader.Update(tex, dat, 128, 128);
            result.Dispose();
        }