Ejemplo n.º 1
0
    public 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);
        }
    }
Ejemplo n.º 2
0
        public BaseTexture(BaseDevice device, BaseTextureDesc desc)
        {
            Device = device;
            Desc   = desc;

            TexturePool.Add(desc.Name, this);

            if (Desc.IsLightMap)
            {
                LightMapData       = new Int32[RenderDef.MAX_LIGHTMAPS, RenderDef.BLOCK_WIDTH];
                LightMapRectChange = new glRect_t[RenderDef.MAX_LIGHTMAPS];       // lightmap_rectchange
                LightMapModified   = new System.Boolean[RenderDef.MAX_LIGHTMAPS]; // lightmap_modified
            }
        }
Ejemplo n.º 3
0
    public static void CommitLightmap(int i)
    {
        lightmap_modified[i] = false;
        glRect_t theRect = lightmap_rectchange[i];
        GCHandle handle  = GCHandle.Alloc(lightmaps, GCHandleType.Pinned);

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