예제 #1
0
        private void DrawFrame(int col, int row, int width, int height)
        {
            if (pallettePrevData.prevUseGPUTexture2D)
            {
                passData = new PassData
                {
                    col    = col,
                    row    = row,
                    width  = width,
                    height = height
                };

                Texture2D_GPU[,] tileTexsGPU = palletteData.tileTexsGPU;  //引用tiletexGPUss
                gpu.DrawFrame(ref passData, ref tileTexsGPU, ref frame);

                NeedApplyAtTile(col, row);  // 纹理Apply
            }
            else
            {
                passData = new PassData
                {
                    col    = col,
                    row    = row,
                    width  = width,
                    height = height
                };

                Texture2D[,] tileTexs = palletteData.tileTexs;  //引用tiletexss
                cpu.DrawFrame(ref passData, ref tileTexs, ref frame);

                NeedApplyAtTile(col, row);  // 纹理Apply
            }
        }
예제 #2
0
        internal void DrawFrame(ref PassData passData, ref Texture2D[,] tileTexs, ref Texture2D frame)
        {
            Texture2D tex = tileTexs[passData.col, passData.row];  //CPU

            Color[] cs = frame.GetPixels(passData.col * passData.width, passData.row * passData.height, passData.width, passData.height);
            if (cs != null && cs.Length != 0)
            {
                tex.SetPixels(0, 0, passData.width, passData.height, cs);  //CPU
            }
            else
            {
                //frame某个区域没有像素那就画color.clear
                int length = passData.width * passData.height;
                cs = new Color[length];

                for (int i = 0; i < length; i++)
                {
                    cs[length] = Color.clear;
                }

                tex.SetPixels(0, 0, passData.width, passData.height, cs);   //CPU
            }

            // TODO..纹理Apply
        }
예제 #3
0
        private void SetPixelIgnoringStacks(int x, int y, Color color)
        {
            //TODO..检查这个像素的pos是否在可绘制区域
            //TODO..检查颜色是否相同
            //TODO..绘制他!
            //Start..

            if (x < 0 || y < 0 || x >= pallettePrevData.prevTotalWidth || y >= pallettePrevData.prevTotalHeight)
            {
                return;
            }

            //数据初始化
            int col, row;

            col = x / pallettePrevData.prevTileWidth;
            row = y / pallettePrevData.prevTileHeight;

            if (pallettePrevData.prevUseGPUTexture2D)
            {
                passData = new PassData
                {
                    col    = col,
                    row    = row,
                    width  = pallettePrevData.prevTileWidth,
                    height = pallettePrevData.prevTileHeight,
                    x      = x,
                    y      = y,
                    color  = color
                };

                Texture2D_GPU[,] tileTexsGPU = palletteData.tileTexsGPU;    //引用tiletexGPUss
                gpu.SetPixelIgnoringStacks(ref passData, ref tileTexsGPU);

                NeedApplyAtTile(col, row);              //告诉他,这个位置的瓦片的纹理已经更改了,快去调用Apply()交给GPU渲染吧
            }
            else
            {
                passData = new PassData
                {
                    col    = col,
                    row    = row,
                    width  = pallettePrevData.prevTileWidth,
                    height = pallettePrevData.prevTileHeight,
                    x      = x,
                    y      = y,
                    color  = color
                };

                Texture2D[,] tileTexs = palletteData.tileTexs;      //引用tiletexss
                cpu.SetPixelIgnoringStacks(ref passData, ref tileTexs);

                NeedApplyAtTile(col, row);              //告诉他,这个位置的瓦片的纹理已经更改了,快去调用Apply()交给GPU渲染吧
            }
        }
예제 #4
0
        public void SetPixelIgnoringStacks(ref PassData passData, ref Texture2D_GPU[,] tileTexsGPU)
        {
            Texture2D_GPU texGPU = tileTexsGPU[passData.col, passData.row];     //GPU

            int tx = passData.x % passData.width;
            int ty = passData.y % passData.height;

            Color cs = texGPU.GetPixel(tx, ty);   //GPU

            if (cs == passData.color)
            {
                return;
            }

            texGPU.SetPixel(tx, ty, passData.color);    //GPU
        }
예제 #5
0
        internal void SetPixelIgnoringStacks(ref PassData passData, ref Texture2D[,] tileTexs)
        {
            Texture2D tex = tileTexs[passData.col, passData.row];             //CPU

            int tx = passData.x % passData.width;
            int ty = passData.y % passData.height;

            Color cs = tex.GetPixel(tx, ty);             //CPU

            if (cs == passData.color)
            {
                return;
            }

            tex.SetPixel(tx, ty, passData.color);      //这是调用了mono里边的更改纹理API     //CPU
        }
예제 #6
0
        public void DrawFrame(ref PassData passData, ref Texture2D_GPU[,] tileTexsGPU, ref Texture2D frame)
        {
            Texture2D_GPU texGPU = tileTexsGPU[passData.col, passData.row];       //GPU

            Color[] cs = frame.GetPixels(passData.col * passData.width, passData.row * passData.height, passData.width, passData.height);
            if (cs != null && cs.Length != 0)
            {
                texGPU.SetPixels(cs);     //GPU
            }
            else
            {
                //frame某个区域没有像素那就画color.clear
                int length = passData.width * passData.height;
                cs = new Color[length];

                for (int i = 0; i < length; i++)
                {
                    cs[length] = Color.clear;
                }

                texGPU.SetPixels(cs);     //GPU
            }
        }