Exemplo n.º 1
0
        //public void AddTexture(string name)
        //{
        //    _context.Capture();
        //    if (!PAT0Textures.ContainsKey(name))
        //    {
        //        TEX0Node texture = RootNode.FindChild("Textures(NW4R)/" + name, true) as TEX0Node;
        //        PAT0Textures[name] = new GLTexture(_context, 0, 0);
        //        Bitmap bmp = texture.GetImage(0);
        //        if (bmp != null)
        //        {
        //            int w = bmp.Width, h = bmp.Height, size = w * h;

        //            PAT0Textures[name]._width = w;
        //            PAT0Textures[name]._height = h;
        //            BitmapData data = bmp.LockBits(new Rectangle(0, 0, w, h), ImageLockMode.ReadOnly, PixelFormat.Format32bppArgb);
        //            try
        //            {
        //                using (UnsafeBuffer buffer = new UnsafeBuffer(size << 2))
        //                {
        //                    ARGBPixel* sPtr = (ARGBPixel*)data.Scan0;
        //                    ABGRPixel* dPtr = (ABGRPixel*)buffer.Address;

        //                    for (int i = 0; i < size; i++)
        //                        *dPtr++ = (ABGRPixel)(*sPtr++);

        //                    int res = _context.gluBuild2DMipmaps(GLTextureTarget.Texture2D, GLInternalPixelFormat._4, w, h, GLPixelDataFormat.RGBA, GLPixelDataType.UNSIGNED_BYTE, buffer.Address);
        //                    if (res != 0)
        //                    {
        //                    }
        //                }
        //            }
        //            finally
        //            {
        //                bmp.UnlockBits(data);
        //                bmp.Dispose();
        //            }
        //        }
        //        PAT0Textures[name].Bind();
        //    }
        //}

        public void Reload()
        {
            if (_context == null)
            {
                return;
            }

            _context.Capture();
            Load();
        }