コード例 #1
0
ファイル: ParticleEditCtl.cs プロジェクト: xxxxst/gifEdit
        public int createEmitter()
        {
            ParticleResourceModel resMd = new ParticleResourceModel();

            md.lstResource.Add(resMd);

            int idx = lstVM.Count;

            if (idx > 0)
            {
                lstVM[idx - 1].IsLast = false;
            }

            ParticleEditVM vm = new ParticleEditVM()
            {
                idx    = idx,
                md     = resMd,
                Image  = null,
                IsLast = true
            };

            lstVM.Add(vm);

            return(idx);
        }
コード例 #2
0
        public ParticleEmitter(ParticleResourceModel _md, int _maxRenderTime)
        {
            md = _md;
            //zIndex = _zIndex;
            maxRenderTime = _maxRenderTime;

            attrBufferId = Gl.GenBuffer();
            //bufferId = Gl.GenVertexArray();
            texId = Gl.GenTexture();
            //texFraBufferId = Gl.GenFramebuffer();

            string[] vetex    = ComUtil.loadEmbedShader("vParticleEmitter.glsl");
            string[] fragment = ComUtil.loadEmbedShader("fParticleEmitter.glsl");

            using (GlObject vObject = new GlObject(ShaderType.VertexShader, vetex))
                using (GlObject fObject = new GlObject(ShaderType.FragmentShader, fragment)) {
                    // Create program
                    ProgramName = Gl.CreateProgram();
                    // Attach shaders
                    Gl.AttachShader(ProgramName, vObject.ShaderName);
                    Gl.AttachShader(ProgramName, fObject.ShaderName);
                    // Link program
                    Gl.LinkProgram(ProgramName);

                    // Check linkage status
                    Gl.GetProgram(ProgramName, ProgramProperty.LinkStatus, out int linked);

                    if (linked == 0)
                    {
                        const int logMaxLength = 1024;

                        StringBuilder infolog = new StringBuilder(logMaxLength);
                        int           infologLength;

                        Gl.GetProgramInfoLog(ProgramName, 1024, out infologLength, infolog);

                        throw new InvalidOperationException($"unable to link program: {infolog}");
                    }

                    LocationMVP     = getUniformId("uMVP");
                    LocationIndex   = getAttrId("index");
                    LocationCoord   = getAttrId("vCoord");
                    LocationTex     = getUniformId("tex");
                    LocationNowTime = getUniformId("nowTime");
                    //LocationZIndex = getUniformId("zIndex");
                    LocationTotalLifeTime = getUniformId("totalLifeTime");
                    LocationParticleCount = getUniformId("particleCount");
                    LocationStartPos      = getUniformId("startPos");
                }

            updateImage();
            updateAttr();
        }