Пример #1
0
        private static void UpdateRect(msurface_t fa, ref glRect_t theRect)
        {
            if (fa.light_t < theRect.t)
            {
                if (theRect.h != 0)
                {
                    theRect.h += (byte)(theRect.t - fa.light_t);
                }
                theRect.t = (byte)fa.light_t;
            }
            if (fa.light_s < theRect.l)
            {
                if (theRect.w != 0)
                {
                    theRect.w += (byte)(theRect.l - fa.light_s);
                }
                theRect.l = (byte)fa.light_s;
            }
            int smax = (fa.extents[0] >> 4) + 1;
            int tmax = (fa.extents[1] >> 4) + 1;

            if ((theRect.w + theRect.l) < (fa.light_s + smax))
            {
                theRect.w = (byte)((fa.light_s - theRect.l) + smax);
            }
            if ((theRect.h + theRect.t) < (fa.light_t + tmax))
            {
                theRect.h = (byte)((fa.light_t - theRect.t) + tmax);
            }
        }
Пример #2
0
        private static void CommitLightmap(int i)
        {
            _LightMapModified[i] = false;
            glRect_t theRect = _LightMapRectChange[i];
            GCHandle handle  = GCHandle.Alloc(_LightMaps, GCHandleType.Pinned);

            try
            {
                long addr = handle.AddrOfPinnedObject().ToInt64() +
                            (i * BLOCK_HEIGHT + theRect.t) * BLOCK_WIDTH * _LightMapBytes;
                GL.TexSubImage2D(TextureTarget.Texture2D, 0, 0, theRect.t,
                                 BLOCK_WIDTH, theRect.h, Drawer.LightMapFormat,
                                 PixelType.UnsignedByte, new IntPtr(addr));
            }
            finally
            {
                handle.Free();
            }
            theRect.l = BLOCK_WIDTH;
            theRect.t = BLOCK_HEIGHT;
            theRect.h = 0;
            theRect.w = 0;
            _LightMapRectChange[i] = theRect;
        }