コード例 #1
0
ファイル: RenderTargetBlend.cs プロジェクト: Zulkir/Beholder
        public RenderTargetBlend(RenderTargetBlendDescription bRenderTargetBlend)
        {
            if (bRenderTargetBlend.BlendEnable)
            {
                SrcFactor = CtObjectGL.BlendFactor(bRenderTargetBlend.SourceBlend);
                DestFactor = CtObjectGL.BlendFactor(bRenderTargetBlend.DestinationBlend);
                EquationMode = CtObjectGL.BlendFunc(bRenderTargetBlend.BlendOperation);

                SrcFactorAlpha = CtObjectGL.BlendFactor(bRenderTargetBlend.SourceBlendAlpha);
                DestFactorAlpha = CtObjectGL.BlendFactor(bRenderTargetBlend.DestinationBlendAlpha);
                EquationModeAlpha = CtObjectGL.BlendFunc(bRenderTargetBlend.BlendOperationAlpha);
            }
            else
            {
                SrcFactor = BlendFactor.One;
                DestFactor = BlendFactor.Zero;
                EquationMode = BlendFunc.Add;

                SrcFactorAlpha = BlendFactor.One;
                DestFactorAlpha = BlendFactor.Zero;
                EquationModeAlpha = BlendFunc.Add;
            }

            Separate = SrcFactor != SrcFactorAlpha || DestFactor != DestFactorAlpha || EquationMode != EquationModeAlpha;
        }
コード例 #2
0
 public override void AlphaBlendFunc(BlendFunc srcFunc, BlendFunc dstFunc)
 {
     srcBlendFunc = blendFuncs[(int)srcFunc];
     dstBlendFunc = blendFuncs[(int)dstFunc];
     device.SetRenderState(RenderState.SourceBlend, (int)srcBlendFunc);
     device.SetRenderState(RenderState.DestinationBlend, (int)dstBlendFunc);
 }
コード例 #3
0
 public override void RGBAlphaBlendFunc(BlendFunc srcFuncRGB, BlendFunc dstFuncRGB, BlendFunc srcFuncAlpha, BlendFunc dstFuncAlpha)
 {
     srcBlendFunc      = blendFuncs[(int)srcFuncRGB];
     dstBlendFunc      = blendFuncs[(int)dstFuncRGB];
     srcBlendFuncAlpha = blendFuncs[(int)srcFuncAlpha];
     dstBlendFuncAlpha = blendFuncs[(int)dstFuncAlpha];
     device.SetRenderState(RenderState.SourceBlend, (int)srcBlendFunc);
     device.SetRenderState(RenderState.DestinationBlend, (int)dstBlendFunc);
     device.SetRenderState(RenderState.SourceBlendAlpha, (int)srcBlendFuncAlpha);
     device.SetRenderState(RenderState.DestinationBlendAlpha, (int)dstBlendFuncAlpha);
 }
コード例 #4
0
ファイル: BlendFunc.cs プロジェクト: WebAssembly/ilwasm
    public static void rasterize (BlendFunc bf, byte* src, byte* dest) {
        checkerboard(src,  numPixels, 0x0);
        checkerboard(dest, numPixels, 0xFF);

        var rowSize = width * 3;

        for (var y = 0; y < height; y++) {
            bf(src, dest, width);
            src += rowSize;
            dest += rowSize;
        }
    }
コード例 #5
0
    public static void rasterize(BlendFunc bf, byte *src, byte *dest)
    {
        checkerboard(src, numPixels, 0x0);
        checkerboard(dest, numPixels, 0xFF);

        var rowSize = width * 3;

        for (var y = 0; y < height; y++)
        {
            bf(src, dest, width);
            src  += rowSize;
            dest += rowSize;
        }
    }
コード例 #6
0
        public static All GetGLBlendEquationMode(BlendFunc func)
        {
            switch (func)
            {
            case BlendFunc.Add:
                return(All.FuncAdd);

            case BlendFunc.Subtract:
                return(All.FuncSubtract);

            case BlendFunc.ReverseSubtract:
                return(All.FuncReverseSubtract);

            default:
                throw new ArgumentException(nameof(func));
            }
        }
コード例 #7
0
ファイル: GLExtensions.cs プロジェクト: aologos/Citrus
        public static BlendEquationMode ToGLBlendEquationMode(this BlendFunc value)
        {
            switch (value)
            {
            case BlendFunc.Add:
                return(BlendEquationMode.FuncAdd);

            case BlendFunc.Subtract:
                return(BlendEquationMode.FuncSubtract);

            case BlendFunc.ReverseSubtract:
                return(BlendEquationMode.FuncReverseSubtract);

            default:
                throw new NotSupportedException();
            }
        }
コード例 #8
0
        public static SharpVulkan.BlendOperation GetVKBlendOp(BlendFunc func)
        {
            switch (func)
            {
            case BlendFunc.Add:
                return(SharpVulkan.BlendOperation.Add);

            case BlendFunc.Subtract:
                return(SharpVulkan.BlendOperation.Subtract);

            case BlendFunc.ReverseSubtract:
                return(SharpVulkan.BlendOperation.ReverseSubtract);

            default:
                throw new ArgumentException(nameof(func));
            }
        }
コード例 #9
0
ファイル: CMB.cs プロジェクト: week9/Switch-Toolbox
        private PICABlendFunc ConvertBlendFunc(BlendFunc factor)
        {
            switch (factor)
            {
            case BlendFunc.ConstantAlpha: return(PICABlendFunc.ConstantAlpha);

            case BlendFunc.ConstantColor: return(PICABlendFunc.ConstantColor);

            case BlendFunc.DestinationAlpha: return(PICABlendFunc.DestinationAlpha);

            case BlendFunc.DestinationColor: return(PICABlendFunc.DestinationColor);

            case BlendFunc.One: return(PICABlendFunc.One);

            case BlendFunc.OneMinusConstantAlpha: return(PICABlendFunc.OneMinusConstantAlpha);

            case BlendFunc.OneMinusConstantColor: return(PICABlendFunc.OneMinusConstantColor);

            case BlendFunc.OneMinusDestinationAlpha: return(PICABlendFunc.OneMinusDestinationAlpha);

            case BlendFunc.OneMinusDestinationColor: return(PICABlendFunc.OneMinusDestinationColor);

            case BlendFunc.OneMinusSourceAlpha: return(PICABlendFunc.OneMinusSourceAlpha);

            case BlendFunc.OneMinusSourceColor: return(PICABlendFunc.OneMinusSourceColor);

            case BlendFunc.SourceAlpha: return(PICABlendFunc.SourceAlpha);

            case BlendFunc.SourceColor: return(PICABlendFunc.SourceColor);

            case BlendFunc.SourceAlphaSaturate: return(PICABlendFunc.SourceAlphaSaturate);

            case BlendFunc.Zero: return(PICABlendFunc.Zero);

            default: return(PICABlendFunc.Zero);
            }
        }
コード例 #10
0
 /// <summary> Sets the alpha blend function that is used when alpha blending is enabled. </summary>
 public abstract void AlphaBlendFunc(BlendFunc srcFunc, BlendFunc dstFunc);
コード例 #11
0
ファイル: IO.cs プロジェクト: noob601/Zenith-MIDI-Modded
 public static void SetBlendFunc(BlendFunc function) => setBlendFunc(function);
コード例 #12
0
 private void InitializeOpenGlBlendMode()
 {
     //These are copied from GameEngine2d. I only have a vague idea what they do.
     NoBlendFunc = new BlendFunc(BlendFuncMode.Add, BlendFuncFactor.One, BlendFuncFactor.One);
     NormalBlendFunc = new BlendFunc(BlendFuncMode.Add, BlendFuncFactor.SrcAlpha, BlendFuncFactor.OneMinusSrcAlpha);
     AdditiveBlendFunc = new BlendFunc(BlendFuncMode.Add, BlendFuncFactor.One, BlendFuncFactor.One);
     MultiplicativeBlendFunc = new BlendFunc(BlendFuncMode.Add, BlendFuncFactor.DstColor, BlendFuncFactor.Zero);
     PremultipliedAlphaBlendFunc = new BlendFunc(BlendFuncMode.Add, BlendFuncFactor.One, BlendFuncFactor.OneMinusSrcAlpha);
 }
コード例 #13
0
 public void BlendFunc(BlendFunc srcBlend, BlendFunc dstBlend)
 {
     GlBindings.BlendFunc(srcBlend, dstBlend);
 }
コード例 #14
0
ファイル: OpenGLApi.cs プロジェクト: TheMegaPVP/ClassiCubeSVL
 public override void RGBAlphaBlendFunc(BlendFunc srcFuncRGB, BlendFunc dstFuncRGB, BlendFunc srcFuncAlpha, BlendFunc dstFuncAlpha)
 {
     GL.BlendFuncSeparate(blendFuncs[(int)srcFuncRGB], blendFuncs[(int)dstFuncRGB], blendFuncs[(int)srcFuncAlpha], blendFuncs[(int)dstFuncAlpha]);
 }
コード例 #15
0
 private void SetBlendMode(BlendFunc blendFunc)
 {
     //Checking just as slow as setting?
     //if(!GraphicsContext.IsEnabled(EnableMode.Blend))
     GraphicsContext.Enable(EnableMode.Blend);
     GraphicsContext.SetBlendFunc(blendFunc);
     SetRenderRequired();
 }
コード例 #16
0
        public void Init()
        {
            quadShader        = MakeShader(quadShaderVert, quadShaderFrag);
            inverseQuadShader = MakeShader(quadShaderVert, invertQuadShaderFrag);
            evenquadShader    = MakeShader(quadShaderVert, evenQuadShaderFrag);

            int loc;

            int[] samplers = new int[12];
            for (int i = 0; i < 12; i++)
            {
                samplers[i] = i;
            }

            GL.UseProgram(quadShader);
            for (int i = 0; i < 12; i++)
            {
                loc = GL.GetUniformLocation(quadShader, "textureSampler" + (i + 1));
                GL.Uniform1(loc, i);
            }
            GL.UseProgram(inverseQuadShader);
            for (int i = 0; i < 12; i++)
            {
                loc = GL.GetUniformLocation(inverseQuadShader, "textureSampler" + (i + 1));
                GL.Uniform1(loc, i);
            }
            GL.UseProgram(evenquadShader);
            for (int i = 0; i < 12; i++)
            {
                loc = GL.GetUniformLocation(evenquadShader, "textureSampler" + (i + 1));
                GL.Uniform1(loc, i);
            }

            quadVertexbuff = new double[quadBufferLength * 8];
            quadColorbuff  = new float[quadBufferLength * 16];
            quadUVbuff     = new double[quadBufferLength * 8];
            quadTexIDbuff  = new float[quadBufferLength * 4];

            GL.GenBuffers(1, out vertexBufferID);
            GL.GenBuffers(1, out colorBufferID);
            GL.GenBuffers(1, out uvBufferID);
            GL.GenBuffers(1, out texIDBufferID);
            for (uint i = 0; i < indexes.Length / 6; i++)
            {
                indexes[i * 6 + 0] = i * 4 + 0;
                indexes[i * 6 + 1] = i * 4 + 1;
                indexes[i * 6 + 2] = i * 4 + 3;
                indexes[i * 6 + 3] = i * 4 + 1;
                indexes[i * 6 + 4] = i * 4 + 3;
                indexes[i * 6 + 5] = i * 4 + 2;
            }

            GL.GenBuffers(1, out indexBufferId);
            GL.BindBuffer(BufferTarget.ElementArrayBuffer, indexBufferId);
            GL.BufferData(
                BufferTarget.ElementArrayBuffer,
                (IntPtr)(indexes.Length * 4),
                indexes,
                BufferUsageHint.StaticDraw);

            if (currScript != null)
            {
                try
                {
                    LoadScript(currScript);
                }
                catch
                {
                    currScript           = null;
                    lastScriptChangeTime = 0;
                }
            }
            CheckScript();

            IO.renderQuad      = RenderQuad;
            IO.renderShape     = RenderShape;
            IO.forceFlush      = () => FlushQuadBuffer(false);
            IO.selectTexShader = (s) =>
            {
                if (currentShader != s)
                {
                    FlushQuadBuffer(false);
                }
                if (s == TextureShaders.Normal)
                {
                    GL.UseProgram(quadShader);
                }
                if (s == TextureShaders.Inverted)
                {
                    GL.UseProgram(inverseQuadShader);
                }
                if (s == TextureShaders.Hybrid)
                {
                    GL.UseProgram(evenquadShader);
                }
                currentShader = s;
            };
            IO.setBlendFunc = (f) =>
            {
                if (currentBlendFunc != f)
                {
                    FlushQuadBuffer(false);
                }
                if (f == BlendFunc.Mix)
                {
                    OpenTK.Graphics.OpenGL4.GL.BlendFuncSeparate(OpenTK.Graphics.OpenGL4.BlendingFactorSrc.SrcAlpha, OpenTK.Graphics.OpenGL4.BlendingFactorDest.OneMinusSrcAlpha, OpenTK.Graphics.OpenGL4.BlendingFactorSrc.One, OpenTK.Graphics.OpenGL4.BlendingFactorDest.One);
                }
                if (f == BlendFunc.Add)
                {
                    OpenTK.Graphics.OpenGL4.GL.BlendFuncSeparate(OpenTK.Graphics.OpenGL4.BlendingFactorSrc.SrcAlpha, OpenTK.Graphics.OpenGL4.BlendingFactorDest.One, OpenTK.Graphics.OpenGL4.BlendingFactorSrc.One, OpenTK.Graphics.OpenGL4.BlendingFactorDest.One);
                }
                currentBlendFunc = f;
            };
            IO.getTextSize = (Font f, string t) =>
            {
                var bb = f.engine.GetBoundBox(t);
                return(bb.Width / (double)bb.Height / renderSettings.width * renderSettings.height);
            };
            IO.renderText = (double left, double bottom, double height, Color4 color, Font f, string text) =>
            {
                if (text.Contains("\n"))
                {
                    throw new Exception("New line characters not allowed when rendering text (yet)");
                }

                FlushQuadBuffer(false);

                var     size      = f.engine.GetBoundBox(text);
                Matrix4 transform = Matrix4.Identity;
                transform = Matrix4.Mult(transform, Matrix4.CreateScale(1.0f / renderSettings.width * renderSettings.height / f.fontPixelSize * (float)height, -1.0f / f.fontPixelSize * (float)height, 1.0f));
                transform = Matrix4.Mult(transform, Matrix4.CreateTranslation((float)left * 2 - 1, (float)(bottom + height * 0.7) * 2 - 1, 0));

                f.engine.Render(text, transform, color);

                if (currentShader == TextureShaders.Normal)
                {
                    GL.UseProgram(quadShader);
                }
                if (currentShader == TextureShaders.Inverted)
                {
                    GL.UseProgram(inverseQuadShader);
                }
                if (currentShader == TextureShaders.Hybrid)
                {
                    GL.UseProgram(evenquadShader);
                }
            };

            Initialized = true;
            Console.WriteLine("Initialised ScriptedRender");
        }
コード例 #17
0
        /// <summary>
        /// Decodes a byte[] array into a ParticleSystem Object
        /// </summary>
        /// <param name="data">ParticleSystem object</param>
        /// <param name="pos">Start position for BitPacker</param>
        public ParticleSystem(byte[] data, int pos)
        {
            BlendFuncSource = BlendFunc.SourceAlpha;
            BlendFuncDest   = BlendFunc.OneMinusSourceAlpha;

            MaxAge           = 0.0f;
            StartAge         = 0.0f;
            InnerAngle       = 0.0f;
            OuterAngle       = 0.0f;
            BurstRate        = 0.0f;
            BurstRadius      = 0.0f;
            BurstSpeedMin    = 0.0f;
            BurstSpeedMax    = 0.0f;
            AngularVelocity  = Vector3.Zero;
            PartAcceleration = Vector3.Zero;
            Texture          = UUID.Zero;
            Target           = UUID.Zero;
            PartStartColor   = ColorAlpha.Black;
            PartEndColor     = ColorAlpha.Black;
            PartStartScaleX  = 0.0f;
            PartStartScaleY  = 0.0f;
            PartEndScaleX    = 0.0f;
            PartEndScaleY    = 0.0f;

            int size = data.Length - pos;
            var pack = new BitPacker(data, pos);

            if (size == LegacyDataBlockSize)
            {
                UnpackSystem(pack);
                UnpackLegacyData(pack);
            }
            else if (size > LegacyDataBlockSize && size <= MaxDataBlockSize)
            {
                int sysSize = pack.UnpackSignedBits(32);
                if (sysSize != SysDataSize)
                {
                    return; // unkown particle system data size
                }
                UnpackSystem(pack);
                /*int dataSize = */ pack.UnpackSignedBits(32);
                UnpackLegacyData(pack);

                if ((PartDataFlags & ParticleDataFlags.DataGlow) == ParticleDataFlags.DataGlow)
                {
                    if (pack.Data.Length - pack.BytePos < 2)
                    {
                        return;
                    }
                    uint glow = pack.UnpackUnsignedBits(8);
                    PartStartGlow = glow / 255f;
                    glow          = pack.UnpackUnsignedBits(8);
                    PartEndGlow   = glow / 255f;
                }

                if ((PartDataFlags & ParticleDataFlags.DataBlend) == ParticleDataFlags.DataBlend)
                {
                    if (pack.Data.Length - pack.BytePos < 2)
                    {
                        return;
                    }
                    BlendFuncSource = (BlendFunc)pack.UnpackUnsignedBits(8);
                    BlendFuncDest   = (BlendFunc)pack.UnpackUnsignedBits(8);
                }
            }
        }
コード例 #18
0
 private void CleanupOpenGlBlendMode()
 {
     NoBlendFunc = default(BlendFunc);
     NormalBlendFunc = default(BlendFunc);
     AdditiveBlendFunc = default(BlendFunc);
     MultiplicativeBlendFunc = default(BlendFunc);
     PremultipliedAlphaBlendFunc = default(BlendFunc);
 }
コード例 #19
0
 /// <summary> Sets the alpha and RGB blend functions that are used when blending is enabled. </summary>
 public abstract void RGBAlphaBlendFunc(BlendFunc srcFuncRGB, BlendFunc dstFuncRGB, BlendFunc srcFuncAlpha, BlendFunc dstFuncAlpha);
コード例 #20
0
        public void Init()
        {
            quadShader        = MakeShader(quadShaderVert, quadShaderFrag);
            inverseQuadShader = MakeShader(quadShaderVert, invertQuadShaderFrag);
            evenquadShader    = MakeShader(quadShaderVert, evenQuadShaderFrag);

            int loc;

            int[] samplers = new int[12];
            for (int i = 0; i < 12; i++)
            {
                samplers[i] = i;
            }

            GL.UseProgram(quadShader);
            for (int i = 0; i < 12; i++)
            {
                loc = GL.GetUniformLocation(quadShader, "textureSampler" + (i + 1));
                GL.Uniform1(loc, i);
            }
            GL.UseProgram(inverseQuadShader);
            for (int i = 0; i < 12; i++)
            {
                loc = GL.GetUniformLocation(inverseQuadShader, "textureSampler" + (i + 1));
                GL.Uniform1(loc, i);
            }
            GL.UseProgram(evenquadShader);
            for (int i = 0; i < 12; i++)
            {
                loc = GL.GetUniformLocation(evenquadShader, "textureSampler" + (i + 1));
                GL.Uniform1(loc, i);
            }

            quadVertexbuff = new double[quadBufferLength * 8];
            quadColorbuff  = new float[quadBufferLength * 16];
            quadUVbuff     = new double[quadBufferLength * 8];
            quadTexIDbuff  = new float[quadBufferLength * 4];

            GL.GenBuffers(1, out vertexBufferID);
            GL.GenBuffers(1, out colorBufferID);
            GL.GenBuffers(1, out uvBufferID);
            GL.GenBuffers(1, out texIDBufferID);
            for (uint i = 0; i < indexes.Length / 6; i++)
            {
                indexes[i * 6 + 0] = i * 4 + 0;
                indexes[i * 6 + 1] = i * 4 + 1;
                indexes[i * 6 + 2] = i * 4 + 3;
                indexes[i * 6 + 3] = i * 4 + 1;
                indexes[i * 6 + 4] = i * 4 + 3;
                indexes[i * 6 + 5] = i * 4 + 2;
            }

            GL.GenBuffers(1, out indexBufferId);
            GL.BindBuffer(BufferTarget.ElementArrayBuffer, indexBufferId);
            GL.BufferData(
                BufferTarget.ElementArrayBuffer,
                (IntPtr)(indexes.Length * 4),
                indexes,
                BufferUsageHint.StaticDraw);

            if (currScript != null)
            {
                try
                {
                    LoadScript(currScript);
                }
                catch
                {
                    currScript           = null;
                    lastScriptChangeTime = 0;
                }
            }
            CheckScript();

            IO.renderQuad      = RenderQuad;
            IO.renderShape     = RenderShape;
            IO.forceFlush      = () => FlushQuadBuffer(false);
            IO.selectTexShader = (s) =>
            {
                if (currentShader != s)
                {
                    FlushQuadBuffer(false);
                }
                if (s == TextureShaders.Normal)
                {
                    GL.UseProgram(quadShader);
                }
                if (s == TextureShaders.Inverted)
                {
                    GL.UseProgram(inverseQuadShader);
                }
                if (s == TextureShaders.Hybrid)
                {
                    GL.UseProgram(evenquadShader);
                }
                currentShader = s;
            };
            IO.setBlendFunc += (f) =>
            {
                if (currentBlendFunc != f)
                {
                    FlushQuadBuffer(false);
                }
                if (f == BlendFunc.Mix)
                {
                    OpenTK.Graphics.OpenGL4.GL.BlendFuncSeparate(OpenTK.Graphics.OpenGL4.BlendingFactorSrc.SrcAlpha, OpenTK.Graphics.OpenGL4.BlendingFactorDest.OneMinusSrcAlpha, OpenTK.Graphics.OpenGL4.BlendingFactorSrc.One, OpenTK.Graphics.OpenGL4.BlendingFactorDest.One);
                }
                if (f == BlendFunc.Add)
                {
                    OpenTK.Graphics.OpenGL4.GL.BlendFuncSeparate(OpenTK.Graphics.OpenGL4.BlendingFactorSrc.SrcAlpha, OpenTK.Graphics.OpenGL4.BlendingFactorDest.One, OpenTK.Graphics.OpenGL4.BlendingFactorSrc.One, OpenTK.Graphics.OpenGL4.BlendingFactorDest.One);
                }
                currentBlendFunc = f;
            };

            Initialized = true;
            Console.WriteLine("Initialised ScriptedRender");
        }
コード例 #21
0
 private void Form1_Load(object sender, EventArgs e)
 {
     radioButton1.Checked = true;
     alphaTick = 0;
     alphaLabel.Text = "Alpha: " + alphaTick;
     func = BlendFunc.CPP;
     blendWindow.Text = "Blend Image";
     originalWindow.Text = "Original Image";
     finalWindow.Text = "Final Image";
 }
コード例 #22
0
 private void radioButton3_CheckedChanged(object sender, EventArgs e)
 {
     func = BlendFunc.SSE;
 }
コード例 #23
0
ファイル: OpenGLApi.cs プロジェクト: bejita968/ClassicalSharp
 public override void AlphaBlendFunc(BlendFunc srcFunc, BlendFunc dstFunc)
 {
     GL.BlendFunc(blendFuncs[(int)srcFunc], blendFuncs[(int)dstFunc]);
 }
コード例 #24
0
ファイル: FeatureCatalog.cs プロジェクト: weimingtom/Sakura
    public static Scene MakeMultiTouchScene()
    {
        Trail <Vector2>[] touch       = new Trail <Vector2> [Input2.Touch.MaxTouch];
        Grid[]            trail_polys = new Grid[Input2.Touch.MaxTouch];

        for (int i = 0; i < touch.Length; ++i)
        {
            touch[i] = new Trail <Vector2>(16);
        }

        Vector2i grid_size = new Vector2i(20, 24);

        for (int i = 0; i < trail_polys.Length; ++i)
        {
            trail_polys[i] = new Grid(grid_size);
        }

        Vector2[] curve_points  = new Vector2[grid_size.Y];
        Vector2[] circle_points = new Vector2[grid_size.X];
        for (int i = 0; i < circle_points.Length; ++i)
        {
            circle_points[i] = Vector2.Rotation(Math.TwicePi * (float)i / (float)(circle_points.Length - 1));
        }

        List <Vector2> control_points = new List <Vector2>();

        Vector4[] colors =
        {
//			Colors.Black,
            Colors.Red,
            Colors.Green,
            Colors.Yellow,
            Colors.Blue,
            Colors.Magenta,
            Colors.Cyan,
            Colors.White,
            Colors.Lime,
            Colors.LightBlue,
            Colors.Pink,
            Colors.Orange,
            Colors.LightCyan,
            Colors.Purple,
        };

        var scene = new Scene();

        {
            var info = new Label();
            info.Camera      = UICamera;
            info.Position    = UICamera.CalcBounds().Point00;
            info.FontMap     = UIFontMap;
            info.HeightScale = UICamera.GetPixelSize();
            info.Text        = "try touch the screen at multiple points at the same time";

            scene.AddChild(info);
        }

        scene.OnExitEvents += () => {
            foreach (Grid grid in trail_polys)
            {
                grid.Dispose();
            }
            trail_polys = null;
        };

        scene.AdHocDraw += () =>

        {
            BlendFunc blend_func = Director.Instance.GL.Context.GetBlendFunc();
            DepthFunc depth_func = Director.Instance.GL.Context.GetDepthFunc();

            for (int k = 0; k < touch.Length; ++k)
            {
                bool    down  = Input2.Touch.GetData(0)[k].Down;
                bool    press = Input2.Touch.GetData(0)[k].Press;
                Vector2 p     = Director.Instance.CurrentScene.GetTouchPos(k);

                if (!down)
                {
                    continue;
                }

                // press means a new touch data has just been "created"
                // -> fill the whole trail to the new position
                if (press)
                {
                    touch[k].Fill(p);
                }

                touch[k].Add(p);

                control_points.Clear();
                control_points.Add(touch[k].At(0));
                for (int i = 0; i < touch[k].Count; ++i)
                {
                    control_points.Add(touch[k].At(i));
                }

                {
                    Vector4 start_color  = colors[k];
                    Vector4 end_color    = Math.SetAlpha(start_color, 0.0f);
                    float   start_radius = 2.0f;
                    float   end_radius   = 1.8f;

                    Grid grid = trail_polys[k];

                    for (int i = 0; i < curve_points.Length; ++i)
                    {
                        curve_points[i] = Curves.CatmullRom((float)i / (float)(curve_points.Length - 1), control_points, false);
                    }

                    for (int j = 0; j < grid.Size.Y; ++j)
                    {
                        float y = (float)j / (float)(grid.Size.Y - 1);

                        for (int i = 0; i < grid.Size.X; ++i)
                        {
                            grid.TmpVertices[i + j * grid.Size.X] = new DrawHelpers.Vertex((curve_points[j] + circle_points[i] * Math.Lerp(start_radius, end_radius, y)).Xy01
                                                                                           , Math.Lerp(start_color, end_color, y));
                        }
                    }

                    grid.VertexBuffer.SetVertices(grid.TmpVertices, 0, 0, grid.NumVertices);
                    Director.Instance.GL.SetBlendMode(BlendMode.Normal);
                    Director.Instance.DrawHelpers.ShaderPush();
                    grid.Draw();

                    {
                        Director.Instance.DrawHelpers.ImmBegin(DrawMode.TriangleFan, (uint)grid.Size.X);
                        for (int i = 0; i < grid.Size.X; ++i)
                        {
                            Director.Instance.DrawHelpers.ImmVertex(new DrawHelpers.Vertex((curve_points[0] + circle_points[i] * start_radius).Xy01
                                                                                           , start_color));
                        }
                        Director.Instance.DrawHelpers.ImmEnd();
                    }

                    Director.Instance.DrawHelpers.ShaderPop();
                }
            }

            // restore states

            Director.Instance.GL.Context.Disable(EnableMode.DepthTest);

            Director.Instance.GL.Context.SetDepthFunc(depth_func);
            Director.Instance.GL.Context.SetBlendFunc(blend_func);
        };

        return(scene);
    }
コード例 #25
0
 public BlendMode(bool enabled, BlendFunc blend_func)
 {
     this.Enabled   = enabled;
     this.BlendFunc = blend_func;
 }
コード例 #26
0
ファイル: BlendMode.cs プロジェクト: artron33/PsmFramework
 public BlendMode( bool enabled, BlendFunc blend_func )
 {
     Enabled = enabled;
     BlendFunc = blend_func;
 }
コード例 #27
0
        public void RenderFrame(FastList <Note> notes, double midiTime, int finalCompositeBuff)
        {
            CheckScript();

            if (currScript == null || currScript.error)
            {
                return;
            }


            GL.Enable(EnableCap.Blend);
            GL.EnableClientState(ArrayCap.VertexArray);
            GL.EnableClientState(ArrayCap.ColorArray);
            GL.Enable(EnableCap.Texture2D);

            GL.EnableVertexAttribArray(0);
            GL.EnableVertexAttribArray(1);
            GL.EnableVertexAttribArray(2);
            GL.EnableVertexAttribArray(3);

            GL.BlendFunc(BlendingFactor.SrcAlpha, BlendingFactor.OneMinusSrcAlpha);
            GL.BlendEquationSeparate(BlendEquationMode.FuncAdd, BlendEquationMode.Max);
            OpenTK.Graphics.OpenGL4.GL.BlendEquationSeparate(OpenTK.Graphics.OpenGL4.BlendEquationMode.FuncAdd, OpenTK.Graphics.OpenGL4.BlendEquationMode.FuncAdd);
            OpenTK.Graphics.OpenGL4.GL.BlendFuncSeparate(OpenTK.Graphics.OpenGL4.BlendingFactorSrc.SrcAlpha, OpenTK.Graphics.OpenGL4.BlendingFactorDest.OneMinusSrcAlpha, OpenTK.Graphics.OpenGL4.BlendingFactorSrc.One, OpenTK.Graphics.OpenGL4.BlendingFactorDest.One);
            GL.BindFramebuffer(FramebufferTarget.Framebuffer, finalCompositeBuff);
            GL.Viewport(0, 0, renderSettings.width, renderSettings.height);
            GL.Clear(ClearBufferMask.ColorBufferBit);

            #region Vars
            for (int i = 0; i < 12; i++)
            {
                activeTexIds[i] = -1;
            }
            currentShader    = TextureShaders.Normal;
            currentBlendFunc = BlendFunc.Mix;

            #endregion

            GL.UseProgram(quadShader);
            currentShader = TextureShaders.Normal;

            var options = GetRenderOptions(midiTime);

            CopyScriptValues();
            currScript.instance.Render((IEnumerable <Note>)notes, options);
            CopyScriptValues();

            FlushQuadBuffer(false);

            OpenTK.Graphics.OpenGL4.GL.BlendEquationSeparate(OpenTK.Graphics.OpenGL4.BlendEquationMode.FuncAdd, OpenTK.Graphics.OpenGL4.BlendEquationMode.FuncAdd);

            GL.ActiveTexture(TextureUnit.Texture0);
            GL.Disable(EnableCap.Blend);
            GL.DisableClientState(ArrayCap.VertexArray);
            GL.DisableClientState(ArrayCap.ColorArray);
            GL.Disable(EnableCap.Texture2D);

            GL.DisableVertexAttribArray(0);
            GL.DisableVertexAttribArray(1);
            GL.DisableVertexAttribArray(2);
            GL.DisableVertexAttribArray(3);
        }
コード例 #28
0
 public override void AlphaBlendFunc(BlendFunc srcFunc, BlendFunc destFunc)
 {
 }