当前位置: 首页>>代码示例>>C#>>正文


C# Texture.GetSurfaceLevel方法代码示例

本文整理汇总了C#中Texture.GetSurfaceLevel方法的典型用法代码示例。如果您正苦于以下问题:C# Texture.GetSurfaceLevel方法的具体用法?C# Texture.GetSurfaceLevel怎么用?C# Texture.GetSurfaceLevel使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Texture的用法示例。


在下文中一共展示了Texture.GetSurfaceLevel方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: CreateMinimap

        public void CreateMinimap(ADT.IADTFile file)
        {
            string fileName = "";
            if (!gMinimapDir.getMinimapEntry(file.Continent, (int)file.IndexX, (int)file.IndexY, ref fileName))
                return;

            Video.ShaderCollection.TerrainShader.SetValue("minimapMode", true);
            var oldCamera = Game.GameManager.GraphicsThread.GraphicsManager.Camera;
            var oldTarget = Game.GameManager.GraphicsThread.GraphicsManager.Device.GetRenderTarget(0);
            Game.GameManager.GraphicsThread.GraphicsManager.Device.SetRenderTarget(0, mRenderSurface);
            Game.GameManager.GraphicsThread.GraphicsManager.Device.Clear(ClearFlags.Target | ClearFlags.ZBuffer, System.Drawing.Color.CornflowerBlue, 1, 0);

            var newCamera = new Video.OrthogonalCamera(1, 1, false);
            newCamera.ViewFrustum.PassAllTests = true;
            newCamera.PreventWorldUpdate = true;
            Game.GameManager.GraphicsThread.GraphicsManager.Camera = newCamera;
            Game.GameManager.GraphicsThread.GraphicsManager.Camera.SetPosition(new Vector3(Utils.Metrics.Tilesize / 2.0f, Utils.Metrics.Tilesize / 2.0f, 1000.0f), true);

            file.RenderADT(Matrix.Translation(-file.IndexX * Utils.Metrics.Tilesize + Utils.Metrics.MidPoint, -file.IndexY * Utils.Metrics.Tilesize + Utils.Metrics.MidPoint, 0));
            Game.GameManager.GraphicsThread.GraphicsManager.Device.SetRenderTarget(0, oldTarget);

            Game.GameManager.WorldManager.FogStart = 530.0f;
            Game.GameManager.GraphicsThread.GraphicsManager.Camera = oldCamera;

            Texture saveTexture = new Texture(mRenderSurface.Device, 256, 256, 1, Usage.None, Format.X8R8G8B8, Pool.Managed);
            Surface surf = saveTexture.GetSurfaceLevel(0);
            Surface.FromSurface(surf, mRenderSurface, Filter.Box, 0);
            surf.Dispose();

            Video.TextureConverter.SaveTextureAsBlp(Video.TextureConverter.BlpCompression.Dxt3, saveTexture, fileName);
            saveTexture.Dispose();
            Video.ShaderCollection.TerrainShader.SetValue("minimapMode", false);
        }
开发者ID:remixod,项目名称:sharpwow,代码行数:33,代码来源:MinimapRender.cs

示例2: Setup

        private void Setup()
        {
            try
            {
                EdgeMap = new Texture(SlimMMDXCore.Instance.Device, width, height, 1, Usage.RenderTarget, Format.A8R8G8B8, Pool.Default);
            }
            catch (Direct3D9Exception)
            {
                //あれ?ABGRで無いとダメなん?
                EdgeMap = new Texture(SlimMMDXCore.Instance.Device, width, height, 1, Usage.RenderTarget, Format.A8B8G8R8, Pool.Default);
            }
            renderSurface = EdgeMap.GetSurfaceLevel(0);
            depthBuffer = Surface.CreateDepthStencil(SlimMMDXCore.Instance.Device, width, height, Format.D16, MultisampleType.None, 0, true);
            //エッジ用エフェクト読み込み
            if (effect != null)
            {
                effect.OnResetDevice();
            }
            else
            {
                effect = Effect.FromMemory(SlimMMDXCore.Instance.Device, MMDXResource.MMDEdgeEffect,
#if DEBUG
 ShaderFlags.OptimizationLevel0 | ShaderFlags.Debug
#else
                        ShaderFlags.OptimizationLevel3
#endif
);
            }
            effect.SetValue("EdgeWidth", EdgeWidth);
            effect.Technique = "MMDEdgeEffect";
            
            effect.SetValue("ScreenResolution", new Vector2(width, height));
            CreateScreenVertex();
        }
开发者ID:himapo,项目名称:ccm,代码行数:34,代码来源:EdgeManager.cs

示例3: MafiaVideo

        public MafiaVideo(Form form, bool fullscreen)
        {
            this.form = form;
            this.fullscreen = fullscreen;

            if (fullscreen)
            {
                form.FormBorderStyle = FormBorderStyle.None;
            }
            else
            {
                form.FormBorderStyle = FormBorderStyle.Sizable;
            }

            try
            {
                device = new Device(0, DeviceType.Hardware, form, CreateFlags.HardwareVertexProcessing, GetDefaultPresentParameters(fullscreen));
            }
            catch (InvalidCallException)
            {
                try
                {
                    device = new Device(0, DeviceType.Hardware, form, CreateFlags.SoftwareVertexProcessing, GetDefaultPresentParameters(fullscreen));
                }
                catch (InvalidCallException)
                {
                    try
                    {
                        device = new Device(0, DeviceType.Software, form, CreateFlags.SoftwareVertexProcessing, GetDefaultPresentParameters(fullscreen));
                    }
                    catch (InvalidCallException)
                    {
                        throw new Exception("Direct3Dデバイスの生成に失敗しました。");
                    }
                }
            }
            deviceLost = new EventHandler(OnDeviceLost);
            deviceReset = new EventHandler(OnDeviceReset);
            deviceResizing = new CancelEventHandler(OnDeviceResizing);
            device.DeviceLost += deviceLost;
            device.DeviceReset += deviceReset;
            device.DeviceResizing += deviceResizing;
            device.Clear(ClearFlags.Target, Color.FromArgb(212, 208, 200), 0.0f, 0);

            sprite = new Sprite(device);

            backBuffer = device.GetBackBuffer(0, 0, BackBufferType.Mono);
            offScreenImage = new Texture(device, Mafia.SCREEN_WIDTH, Mafia.SCREEN_HEIGHT, 1, Usage.RenderTarget, Manager.Adapters[0].CurrentDisplayMode.Format, Pool.Default);
            offScreenSurface = offScreenImage.GetSurfaceLevel(0);

            texture = MafiaLoader.DefaultLoader.GetTexture(device, "mafia.bmp");

            if (fullscreen)
            {
                Cursor.Hide();
            }

            // form.ClientSize = new Size(Mafia.SCREEN_WIDTH, Mafia.SCREEN_HEIGHT);
            form.ClientSize = new Size(Mafia.SCREEN_WIDTH * 2, Mafia.SCREEN_HEIGHT * 2);
        }
开发者ID:sinshu,项目名称:mafia,代码行数:60,代码来源:MafiaVideo.cs

示例4: MinimapRender

        public MinimapRender()
        {
            mRenderTarget = new Texture(Game.GameManager.GraphicsThread.GraphicsManager.Device,
                2048, 2048, 1, Usage.RenderTarget, Format.X8R8G8B8, Pool.Default);

            mRenderSurface = mRenderTarget.GetSurfaceLevel(0);
        }
开发者ID:remixod,项目名称:sharpwow,代码行数:7,代码来源:MinimapRender.cs

示例5: D3DTexture2D

 public D3DTexture2D(Texture pTexture, ImageInformation pImageInfo, string szName)
 {
     m_pTexture = pTexture;
     m_pImageInfo = pImageInfo;
     m_szName = szName;
     m_pBaseSurface = pTexture.GetSurfaceLevel(0);
     m_nFrames = 1;
 }
开发者ID:sgrzeda,项目名称:rose,代码行数:8,代码来源:D3DTexture2D.cs

示例6: EncodeProcess

        private void EncodeProcess()
        {
            try
            {
                // calc info
                int totalFrames = (int)((float)settings.FramesPerSecond * (float)recording.Duration.Seconds);
                // start encoding
                IOutputStream stream = VideoEncodingInterface.CreateVideoStream(outFilename, settings.Codec,
                                                                                settings.Width, settings.Height,
                                                                                16, settings.FramesPerSecond, TimeSpan.MinValue, null);
                // create local buffer
                int pixels = settings.Width * settings.Height;
                byte[] buffer = new byte[settings.Width * settings.Height * 4];
                Device device = renderer.Device;
                Surface bb = device.GetBackBuffer(0, 0, BackBufferType.Mono);
                Texture t = new Texture(device, settings.Width, settings.Height, 1, bb.Description.Usage, bb.Description.Format, bb.Description.Pool);
                Surface target = t.GetSurfaceLevel(0);

                Texture sysT = new Texture(device, settings.Width, settings.Height, 1, bb.Description.Usage, bb.Description.Format, bb.Description.Pool);
                Surface sysTarget = sysT.GetSurfaceLevel(0);

                byte[] pBuf = new byte[4];
                for (int frame = 0; frame < totalFrames; frame++)
                {
                    // Draw frame
                    renderer.Render(0, target);

                    //Bitmap b = new Bitmap(TextureLoader.SaveToStream(ImageFileFormat.Bmp, t));
                    //BitmapData data = b.LockBits(new Rectangle(0, 0, settings.Width, settings.Height), System.Drawing.Imaging.ImageLockMode.ReadOnly, System.Drawing.Imaging.PixelFormat.Format32bppArgb);
                    device.GetRenderTargetData(target, sysTarget);

                    GraphicsStream gStream = sysTarget.LockRectangle(LockFlags.ReadOnly);
                    // copy over to right format
                    // Format.X8R8G8B8 > RGBA
                    int bIdx = 0;
                    for (int pixel = 0; pixel < pixels; pixel++)
                    {
                        gStream.Read(pBuf, 0, 4);
                        buffer[bIdx++] = pBuf[1]; // r
                        buffer[bIdx++] = pBuf[2]; // g
                        buffer[bIdx++] = pBuf[3]; // b
                        buffer[bIdx++] = pBuf[0]; // a
                    }

                    // encode frame
                    stream.PutFrame(buffer);
                }

                int totalBytes = 0;
                stream.Close(out totalBytes);
            }
            catch (ThreadAbortException) { }

            complete = true;
        }
开发者ID:xuchuansheng,项目名称:GenXSource,代码行数:55,代码来源:EncodingDlg.cs

示例7: D3D_background

 /// <summary>
 /// Sets up the background Object
 /// </summary>
 /// <param name="device">The DirectX Device that the Background will be assigned to.</param>
 /// <param name="BackgroundImagePath">The Full path and filename to the Image file to be used as the background</param>
 public D3D_background(Device device, string BackgroundImagePath)
 {
     backgroundImagePath = BackgroundImagePath;
     // Load in the background texture from the file and assign it to
     // the sprite
     backgroundSpriteTexture = TextureLoader.FromFile(device, backgroundImagePath);
     using (Surface s = backgroundSpriteTexture.GetSurfaceLevel(0))
     {
         SurfaceDescription desc = s.Description;
         backgroundTextureSize = new Rectangle(0, 0, desc.Width, desc.Height);
     }
     backgroundSprite = new Sprite(device);
 }
开发者ID:iManbot,项目名称:monoslam,代码行数:18,代码来源:D3D_background.cs

示例8: GenerateTexture

        private void GenerateTexture(ref Texture texture, int width, int height, EffectHandle function)
        {
            texture = new Texture(device, width, height, 1, Usage.RenderTarget, Format.X8R8G8B8, Pool.Default);

            device.SetRenderTarget(0, texture.GetSurfaceLevel(0));
            device.Clear(ClearFlags.Target | ClearFlags.ZBuffer, Color.Black, 1, 0);

            device.BeginScene();

            device.EndScene();

            device.Present();
        }
开发者ID:xuchuansheng,项目名称:GenXSource,代码行数:13,代码来源:PerlinImprovedNoiseEffect.cs

示例9: IconTexture

		/// <summary>
		/// Initializes a new instance of the <see cref= "T:WorldWind.Renderable.IconTexture"/> class 
		/// from a texture file on disk.
		/// </summary>
		public IconTexture(Device device, string textureFileName)
		{
            if ((textureFileName != null) && textureFileName.Length > 0)
            {
                if (textureFileName.ToLower().StartsWith("http://") && BaseSavePath != null)
                {
                    // download it
                    try
                    {
                        Uri uri = new Uri(textureFileName);

                        // Set the subdirectory path to the hostname and replace . with _
                        string savePath = uri.Host;
                        savePath = savePath.Replace('.', '_');

                        // build the save file name from the component pieces
                        savePath = BaseSavePath + @"\" + savePath + uri.AbsolutePath;
                        savePath = savePath.Replace('/', '\\');

                        WorldWind.Net.WebDownload webDownload = new WorldWind.Net.WebDownload(textureFileName);
                        webDownload.DownloadType = WorldWind.Net.DownloadType.Unspecified;
                        webDownload.DownloadFile(savePath);

                        // reset the texture file name for later use.
                        textureFileName = savePath;
                    }
                    catch { }
                }
            }

            if(ImageHelper.IsGdiSupportedImageFormat(textureFileName))
			{
				// Load without rescaling source bitmap
				using(Image image = ImageHelper.LoadImage(textureFileName))
					LoadImage(device, image);
			}
			else
			{
				// Only DirectX can read this file, might get upscaled depending on input dimensions.
				Texture = ImageHelper.LoadIconTexture( textureFileName );
				// Read texture level 0 size
				using(Surface s = Texture.GetSurfaceLevel(0))
				{
					SurfaceDescription desc = s.Description;
					Width = desc.Width;
					Height = desc.Height;
				}
			}
		}
开发者ID:jpespartero,项目名称:WorldWind,代码行数:53,代码来源:Icon.cs

示例10: Obj_Window

        public Obj_Window(Device device)
        {
            _background = new Sprite(device);

            Assembly assem = this.GetType().Assembly;
            Stream strm = assem.GetManifestResourceStream("GameLib.images.window.png");
            _window_background = Texture.FromStream(device, strm, Usage.None, Pool.Managed);

            using (Surface s = _window_background.GetSurfaceLevel(0))
            {
                _window_texture_height = s.Description.Height;
                _window_texture_width = s.Description.Width;
            }
            strm.Close();

        }
开发者ID:wshanshan,项目名称:DDD,代码行数:16,代码来源:Obj_Window.cs

示例11: UpdateTexture

		public void UpdateTexture(Texture texture)
		{
			if (!Initialised)
				return;

			if (!FImageInput.ImageChanged || !FImageInput.Allocated)
				return;

			if (FImageInput.ImageAttributesChanged)
			{
				FImageInput.ImageAttributesChanged = true; //reset flag as it will now have dropped
				return;
			}

			Surface srf = texture.GetSurfaceLevel(0);
			DataRectangle rect = srf.LockRectangle(LockFlags.Discard);

			FImageInput.LockForReading();
			try
			{
				CVImage buffer;
				if (FNeedsConversion)
				{
					CVImageUtils.CopyImageConverted(FImageInput.Image, FBufferConverted);
					buffer = FBufferConverted;
				}
				else
				{
					buffer = FImageInput.Image;
				}
				rect.Data.WriteRange(buffer.Data, buffer.ImageAttributes.BytesPerFrame);
			}
			finally
			{
				FImageInput.ReleaseForReading();
			}
				
			srf.UnlockRectangle();
		}
开发者ID:circuitb,项目名称:VVVV.Nodes.EmguCV,代码行数:39,代码来源:AsTextureImageInstance.cs

示例12: SetBackBufferSlimDX

        public void SetBackBufferSlimDX(SlimDX.Direct3D11.Texture2D Texture)
        {
            if (SharedTexture != null)
            {
                SharedTexture.Dispose();
                SharedTexture = null;
            }

            if (Texture == null)
            {
                if (SharedTexture != null)
                {
                    SharedTexture = null;
                    Lock();
                    SetBackBuffer(D3DResourceType.IDirect3DSurface9, IntPtr.Zero);
                    Unlock();
                }
            }
            else if (IsShareable(Texture))
            {
                Format format = TranslateFormat(Texture);
                if (format == Format.Unknown)
                    throw new ArgumentException("Texture format is not compatible with OpenSharedResource");

                IntPtr Handle = GetSharedHandle(Texture);
                if (Handle == IntPtr.Zero)
                    throw new ArgumentNullException("Handle");

                SharedTexture = new Texture(D3DDevice, Texture.Description.Width, Texture.Description.Height, 1, Usage.RenderTarget, format, Pool.Default, ref Handle);
                using (Surface Surface = SharedTexture.GetSurfaceLevel(0))
                {
                    Lock();
                    SetBackBuffer(D3DResourceType.IDirect3DSurface9, Surface.ComPointer);
                    Unlock();
                }
            }
            else
                throw new ArgumentException("Texture must be created with ResourceOptionFlags.Shared");
        }
开发者ID:DelvarWorld,项目名称:shadercomposer,代码行数:39,代码来源:SlimDXImage.cs

示例13: DrawFloor

        private void DrawFloor()
        {

            if (_floorTexture == null || _floorTexture.Disposed)
            {
                _floorTexture = new Texture(DXManager.Device, Settings.ScreenWidth, Settings.ScreenHeight, 1, Usage.RenderTarget, Format.A8R8G8B8, Pool.Default);
                _floorTexture.Disposing += FloorTexture_Disposing;
                _floorSurface = _floorTexture.GetSurfaceLevel(0);
            }


            Surface oldSurface = DXManager.CurrentSurface;

            DXManager.SetSurface(_floorSurface);
            DXManager.Device.Clear(ClearFlags.Target, Color.Black, 0, 0);

            int index;
            int drawY, drawX;

            for (int y = User.Movement.Y - ViewRangeY; y <= User.Movement.Y + ViewRangeY; y++)
            {
                if (y <= 0 || y % 2 == 1) continue;
                if (y >= Height) break;
                drawY = (y - User.Movement.Y + OffSetY) * CellHeight + User.OffSetMove.Y; //Moving OffSet

                for (int x = User.Movement.X - ViewRangeX; x <= User.Movement.X + ViewRangeX; x++)
                {
                    if (x <= 0 || x % 2 == 1) continue;
                    if (x >= Width) break;
                    drawX = (x - User.Movement.X + OffSetX) * CellWidth - OffSetX + User.OffSetMove.X; //Moving OffSet
                    if ((M2CellInfo[x, y].BackImage == 0) || (M2CellInfo[x, y].BackIndex == -1)) continue;
                    index = (M2CellInfo[x, y].BackImage & 0x1FFFF) - 1;
                    Libraries.MapLibs[M2CellInfo[x, y].BackIndex].Draw(index, drawX, drawY);
                }
            }

            for (int y = User.Movement.Y - ViewRangeY; y <= User.Movement.Y + ViewRangeY + 5; y++)
            {
                if (y <= 0) continue;
                if (y >= Height) break;
                drawY = (y - User.Movement.Y + OffSetY) * CellHeight + User.OffSetMove.Y; //Moving OffSet

                for (int x = User.Movement.X - ViewRangeX; x <= User.Movement.X + ViewRangeX; x++)
                {
                    if (x < 0) continue;
                    if (x >= Width) break;
                    drawX = (x - User.Movement.X + OffSetX) * CellWidth - OffSetX + User.OffSetMove.X; //Moving OffSet

                    index = M2CellInfo[x, y].MiddleImage - 1;

                    if ((index < 0) || (M2CellInfo[x, y].MiddleIndex == -1)) continue;
                    if (M2CellInfo[x, y].MiddleIndex > 199)
                    {//mir3 mid layer is same level as front layer not real middle + it cant draw index -1 so 2 birds in one stone :p
                        Size s = Libraries.MapLibs[M2CellInfo[x, y].MiddleIndex].GetSize(index);

                        if (s.Width != CellWidth || s.Height != CellHeight) continue;
                    }
                    Libraries.MapLibs[M2CellInfo[x, y].MiddleIndex].Draw(index, drawX, drawY);
                }
            }
            for (int y = User.Movement.Y - ViewRangeY; y <= User.Movement.Y + ViewRangeY + 5; y++)
            {
                if (y <= 0) continue;
                if (y >= Height) break;
                drawY = (y - User.Movement.Y + OffSetY) * CellHeight + User.OffSetMove.Y; //Moving OffSet

                for (int x = User.Movement.X - ViewRangeX; x <= User.Movement.X + ViewRangeX; x++)
                {
                    if (x < 0) continue;
                    if (x >= Width) break;
                    drawX = (x - User.Movement.X + OffSetX) * CellWidth - OffSetX + User.OffSetMove.X; //Moving OffSet

                    index = (M2CellInfo[x, y].FrontImage & 0x7FFF) - 1;
                    if (index == -1) continue;
                    int fileIndex = M2CellInfo[x, y].FrontIndex;
                    if (fileIndex == -1) continue;
                    Size s = Libraries.MapLibs[fileIndex].GetSize(index);
                    if (fileIndex == 200) //could break maps i have no clue anymore :( fixes random bad spots on old school 4.map tho
                        continue;
                    if (index < 0 || ((s.Width != CellWidth || s.Height != CellHeight) && ((s.Width != CellWidth * 2) || (s.Height != CellHeight * 2)))) continue;
                    Libraries.MapLibs[fileIndex].Draw(index, drawX, drawY);
                }
            }

            DXManager.SetSurface(oldSurface);

            FloorValid = true;
        }
开发者ID:ElijahLOMCN,项目名称:mir2,代码行数:88,代码来源:GameScene.cs

示例14: InternalPresentImage


//.........这里部分代码省略.........
        }
        else
        {
          _shouldRenderTexture = false;
        }

        //clear screen

        _debugStep = 5;

        lock (GUIGraphicsContext.RenderModeSwitch)
        {
          // in case of GUIGraphicsContext.BlankScreen == true always use old method
          // for painting blank screen

          if (GUIGraphicsContext.BlankScreen ||
              GUIGraphicsContext.Render3DMode == GUIGraphicsContext.eRender3DMode.None ||
              GUIGraphicsContext.Render3DMode == GUIGraphicsContext.eRender3DMode.SideBySideTo2D ||
              GUIGraphicsContext.Render3DMode == GUIGraphicsContext.eRender3DMode.TopAndBottomTo2D ||
              GUIGraphicsContext.Render3DMode == GUIGraphicsContext.eRender3DMode.SideBySideFrom2D)
          {
            if (GUIGraphicsContext.Render3DMode == GUIGraphicsContext.eRender3DMode.SideBySideFrom2D)
              // convert 2D to 3D
            {
              Surface backbuffer = GUIGraphicsContext.DX9Device.GetBackBuffer(0, 0, BackBufferType.Mono);

              // create texture/surface for preparation for 3D output 

              Texture auto3DTexture = new Texture(GUIGraphicsContext.DX9Device,
                backbuffer.Description.Width,
                backbuffer.Description.Height, 0, Usage.RenderTarget,
                backbuffer.Description.Format, Pool.Default);

              Surface auto3DSurface = auto3DTexture.GetSurfaceLevel(0);

              // left half

              RenderFor3DMode(GUIGraphicsContext.eRender3DModeHalf.SBSLeft,
                timePassed, backbuffer, auto3DSurface,
                new Rectangle(0, 0, backbuffer.Description.Width/2, backbuffer.Description.Height));

              // right half

              RenderFor3DMode(GUIGraphicsContext.eRender3DModeHalf.SBSRight,
                timePassed, backbuffer, auto3DSurface,
                new Rectangle(backbuffer.Description.Width/2, 0, backbuffer.Description.Width/2,
                  backbuffer.Description.Height));

              if (!GUIGraphicsContext.Render3DSubtitle)
              {
                SubtitleRenderer.GetInstance().Render();
                SubEngine.GetInstance().Render(_subsRect, _destinationRect, 0);
              }

              GUIGraphicsContext.DX9Device.Present();
              backbuffer.Dispose();

              auto3DSurface.Dispose();
              auto3DTexture.Dispose();

              GUIGraphicsContext.LastFramesIndex++;

              if (GUIGraphicsContext.LastFramesIndex > GUIGraphicsContext.LastFrames.Count - 1)
                GUIGraphicsContext.LastFramesIndex = 0;
            }
            else // normal 2D output
开发者ID:MediaPortal,项目名称:MediaPortal-1,代码行数:67,代码来源:PlaneScene.cs

示例15: DrawLights

        private void DrawLights(LightSetting setting)
        {
            if (DXManager.Lights == null || DXManager.Lights.Count == 0) return;

            if (_lightTexture == null || _lightTexture.Disposed)
            {
                _lightTexture = new Texture(DXManager.Device, Settings.ScreenWidth, Settings.ScreenHeight, 1, Usage.RenderTarget, Format.A8R8G8B8, Pool.Default);
                _lightTexture.Disposing += FloorTexture_Disposing;
                _lightSurface = _lightTexture.GetSurfaceLevel(0);
            }

            Surface oldSurface = DXManager.CurrentSurface;
            DXManager.SetSurface(_lightSurface);

            DXManager.Device.Clear(ClearFlags.Target, setting == LightSetting.Night ? Color.Black : Color.FromArgb(255, 50, 50, 50), 0, 0);

            int light;
            Point p;
            DXManager.SetBlend(true);
            DXManager.Device.RenderState.SourceBlend = Blend.SourceAlpha;

            for (int i = 0; i < Objects.Count; i++)
            {
                MapObject ob = Objects[i];
                if (ob.Light > 0 && (!ob.Dead || ob == MapObject.User || ob.Race == ObjectType.Spell))
                {

                    light = ob.Light;

                    if (light >= DXManager.Lights.Count)
                        light = DXManager.Lights.Count - 1;

                    p = ob.DrawLocation;
                    p.Offset(((light + 1)*-65 + CellWidth)/2, ((light + 1)*-50 + CellHeight)/2);

                    if (DXManager.Lights[light] != null && !DXManager.Lights[light].Disposed)
                        DXManager.Sprite.Draw2D(DXManager.Lights[light], PointF.Empty, 0, p, ob is MonsterObject && ob.AI != 6 ? Color.PaleVioletRed : Color.White);
                }

                if (!Settings.Effect) continue;
                for (int e = 0; e < ob.Effects.Count; e++)
                {
                    Effect effect = ob.Effects[e];
                    if (!effect.Blend || CMain.Time < effect.Start || (!(effect is Missile) && effect.Light < ob.Light)) continue;

                    light = effect.Light;

                    p = effect.DrawLocation;
                    p.Offset(((light + 1)*-65 + CellWidth)/2, ((light + 1)*-50 + CellHeight)/2);

                    if (DXManager.Lights[light] != null && !DXManager.Lights[light].Disposed)
                        DXManager.Sprite.Draw2D(DXManager.Lights[light], PointF.Empty, 0, p, Color.White);

                }
            }

            if (Settings.Effect)
                for (int e = 0; e < Effects.Count; e++)
                {
                    Effect effect = Effects[e];
                    if (!effect.Blend || CMain.Time < effect.Start) continue;

                    light = effect.Light;

                    p = effect.DrawLocation;
                    p.Offset(((light + 1)*-65 + CellWidth)/2, ((light + 1)*-50 + CellHeight)/2);

                    if (DXManager.Lights[light] != null && !DXManager.Lights[light].Disposed)
                        DXManager.Sprite.Draw2D(DXManager.Lights[light], PointF.Empty, 0, p, Color.White);
                }

            for (int y = MapObject.User.Movement.Y - ViewRangeY - 10; y <= MapObject.User.Movement.Y + ViewRangeY + 10; y++)
            {
                if (y < 0) continue;
                if (y >= Height) break;
                for (int x = MapObject.User.Movement.X - ViewRangeX - 10; x < MapObject.User.Movement.X + ViewRangeX + 10; x++)
                {
                    if (x < 0) continue;
                    if (x >= Width) break;
                    int imageIndex = (M2CellInfo[x, y].FrontImage & 0x7FFF) - 1;
                    if (M2CellInfo[x, y].Light <= 0 || M2CellInfo[x, y].Light >= 10) continue;
                    light = M2CellInfo[x, y].Light*3;
                    int fileIndex = M2CellInfo[x, y].FileIndex;

                    p = new Point(
                        (x + OffSetX - MapObject.User.Movement.X) * CellWidth + MapObject.User.OffSetMove.X,
                        (y + OffSetY - MapObject.User.Movement.Y) * CellHeight + MapObject.User.OffSetMove.Y + 32);
                    p.Offset(((light + 1)*-65 + CellWidth)/2, ((light + 1)*-50 + CellHeight)/2);

                    if (M2CellInfo[x, y].AnimationFrame > 0)
                        p.Offset(Libraries.Objects[fileIndex].GetOffSet(imageIndex));

                    if (light > DXManager.Lights.Count)
                        light = DXManager.Lights.Count - 1;

                    if (DXManager.Lights[light] != null && !DXManager.Lights[light].Disposed)
                        DXManager.Sprite.Draw2D(DXManager.Lights[light], PointF.Empty, 0, p, Color.White);
                }
            }
            DXManager.SetBlend(false);
//.........这里部分代码省略.........
开发者ID:WillMcKill,项目名称:MirRage,代码行数:101,代码来源:GameScene.cs


注:本文中的Texture.GetSurfaceLevel方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。