public void OnDeviceReset(object sender, EventArgs e) { _control = sender as DirectxControl; if (_control == null) { throw new ArgumentNullException(nameof(sender)); } _sprite?.Dispose(); _sprite = new Dx9.Sprite(_control.Device); _shipSprite?.Dispose(); _shipSprite = new Dx9.Sprite(_control.Device); if (_texture == null) { _texture = Dx9.Texture.FromFile(_control.Device, "Ressources\\maxresdefault.jpg", _control.Device.Viewport.Width, _control.Device.Viewport.Height, 0, Dx9.Usage.None, Dx9.Format.Unknown, Dx9.Pool.Default, Dx9.Filter.Default, Dx9.Filter.Default, 0, out _imageInformation); } if (_shipTexture == null) { _shipTexture = Dx9.Texture.FromFile(_control.Device, "Ressources\\Voyager.png", 200, 200, 0, Dx9.Usage.None, Dx9.Format.Unknown, Dx9.Pool.Default, Dx9.Filter.Default, Dx9.Filter.Default, 0); } if (_circleTexture == null) { _circleTexture = Dx9.Texture.FromFile(_control.Device, "Ressources\\200px-65537-gon.svg.png", 20, 20, 0, Dx9.Usage.None, Dx9.Format.Unknown, Dx9.Pool.Default, Dx9.Filter.Default, Dx9.Filter.Default, 0); } if (_font == null) { SD.Font f = new SD.Font("Arial", 20f, SD.FontStyle.Regular); _font = new Dx9.Font(_control.Device, f); } }
private void UpdateTexture(CefBrowser browser, EX9.Texture texture) { // IntPtr buffer = Marshal.AllocHGlobal(FWidth * FHeight * 4); // FBrowser.GetImage(CefPaintElementType.View, FWidth, FHeight, buffer); // WriteToTexture(new Rectangle(0, 0, FWidth, FHeight), buffer, FWidth * 4, texture); // Marshal.FreeHGlobal(buffer); }
private void WriteToTexture(Rectangle rect, IntPtr buffer, int stride, EX9.Texture texture) { // TODO: Do not lock entire surface. var dataRect = texture.LockRectangle(0, rect, LockFlags.None); try { var dataStream = dataRect.Data; if (rect.Width == FWidth && rect.Height == FHeight && dataRect.Pitch == stride) { dataStream.WriteRange(buffer, FHeight * dataRect.Pitch); } else { var offset = stride * rect.Y + 4 * rect.X; var source = buffer + offset; for (int y = 0; y < rect.Height; y++) { dataStream.Position = y * dataRect.Pitch; dataStream.WriteRange(source + y * stride, rect.Width * 4); } } } finally { texture.UnlockRectangle(0); } }
void Cleanup() { if (RedTexture != null) { RedTexture.Dispose(); RedTexture = null; } /* * if (OrangeTexture != null) * { * OrangeTexture.Dispose(); * OrangeTexture = null; * } * * if (MenuFont != null) * { * MenuFont.Dispose(); * MenuFont = null; * } * * if (MenuLine != null) * { * MenuLine.Dispose(); * MenuLine.Dispose(); * } */ }
public FrameBufferSurface(Size size) { mDisplay = Display.Impl as SDX_Display; mDevice = mDisplay.D3D_Device; mSize = size; try { mTexture = new Texture(mDevice.Device, mSize.Width, mSize.Height, 0, Usage.RenderTarget, Format.A8R8G8B8, Pool.Default); } catch { Size newSize = SDX_Surface.NextPowerOfTwo(mSize); mTexture = new Texture(mDevice.Device, newSize.Width, newSize.Height, 0, Usage.RenderTarget, Format.A8R8G8B8, Pool.Default); } mRenderTarget = mTexture.GetSurfaceLevel(0); mAgateSurface = new SDX_Surface(new AgateLib.Utility.Ref <Texture>(mTexture), new Rectangle(Point.Empty, Size)); //SetHasDepthStencil( }
private void WriteToTexture(Rectangle rect, IntPtr buffer, int stride, EX9.Texture texture) { // Rect needs to be inside of Width/Height rect = Rectangle.Intersect(new Rectangle(0, 0, FSize.Width, FSize.Height), rect); if (rect == Rectangle.Empty) { return; } var dataRect = texture.LockRectangle(0, rect, LockFlags.None); try { var dataStream = dataRect.Data; if (rect.Width == FSize.Width && rect.Height == FSize.Height && dataRect.Pitch == stride) { dataStream.WriteRange(buffer, FSize.Height * dataRect.Pitch); } else { var offset = stride * rect.Y + 4 * rect.X; var source = buffer + offset; for (int y = 0; y < rect.Height; y++) { dataStream.Position = y * dataRect.Pitch; dataStream.WriteRange(source + y * stride, rect.Width * 4); } } } finally { texture.UnlockRectangle(0); } }
public Texture2d LoadTexture(BitmapBuffer bmp) { var tex = new d3d9.Texture(dev, bmp.Width, bmp.Height, 1, d3d9.Usage.None, d3d9.Format.A8R8G8B8, d3d9.Pool.Managed); var ret = new Texture2d(this, IntPtr.Zero, tex, bmp.Width, bmp.Height); LoadTextureData(ret, bmp); return(ret); }
private void DestroyTexture(CefBrowser browser, EX9.Texture texture) { lock (FTextures) { FTextures.Remove(texture); texture.Dispose(); } }
private void DestroyTexture(CefBrowser browser, EX9.Texture texture, DestroyReason reason) { lock (FTextureResource) { var sysmemTexture = texture.Tag as EX9.Texture; sysmemTexture.Dispose(); texture.Dispose(); } }
public MyRenderer() { _texture = null; _font = null; _shipVector3 = new Vector3(0, 0, 0); _mapVector3 = new Vector3(0, 0, 100); _mousePosition = new Vector3(0, 0, 0); _rotation = 0f; }
public Texture(Device device, string name, Size size) { RawTexture = new D3D.Texture(device.RawDevice, (int)size.Width, (int)size.Height, 1, D3D.Usage.RenderTarget, D3D.Format.A8R8G8B8, D3D.Pool.Default); Name = name; Width = (int)size.Width; Height = (int)size.Height; this.imageFileFormat = D3D.ImageFileFormat.Bmp; }
public void LoadTextureData(Texture2d tex, BitmapBuffer bmp) { sdi.BitmapData bmp_data = bmp.LockBits(); d3d9.Texture dtex = tex.Opaque as d3d9.Texture; var dr = dtex.LockRectangle(0, LockFlags.None); //TODO - do we need to handle odd sizes, weird pitches here? dr.Data.WriteRange(bmp_data.Scan0, bmp.Width * bmp.Height); dtex.UnlockRectangle(0); bmp.UnlockBits(bmp_data); }
public RenderTarget CreateRenderTarget(int w, int h) { var d3dtex = new d3d9.Texture(dev, w, h, 1, d3d9.Usage.RenderTarget, d3d9.Format.A8R8G8B8, d3d9.Pool.Default); var tw = new TextureWrapper() { Texture = d3dtex }; var tex = new Texture2d(this, tw, w, h); RenderTarget rt = new RenderTarget(this, tw, tex); return(rt); }
public void SetSpeccyScreenSize(int width, int height) { ScreenWidth = width; ScreenHeight = height; //display.Dispose(); //displaySurface.Dispose(); screenRect = new System.Drawing.Rectangle(0, 0, ScreenWidth, ScreenHeight); gdiDisplay = new System.Drawing.Bitmap(ScreenWidth, ScreenHeight, System.Drawing.Imaging.PixelFormat.Format32bppRgb); // Create the device. dxDisplay = new Texture(dxDevice, ScreenWidth, ScreenHeight, 1, Usage.None, currentParams.BackBufferFormat, Pool.Managed); displaySurface = dxDisplay.GetSurfaceLevel(0); }
public void Dispose() { SetBackBufferSlimDX(null); if (SharedTexture != null) { SharedTexture.Dispose(); SharedTexture = null; } NumActiveImages--; ShutdownD3D9(); }
public Texture2d LoadTexture(BitmapBuffer bmp) { var tex = new d3d9.Texture(dev, bmp.Width, bmp.Height, 1, d3d9.Usage.None, d3d9.Format.A8R8G8B8, d3d9.Pool.Managed); var tw = new TextureWrapper() { Texture = tex }; var ret = new Texture2d(this, tw, bmp.Width, bmp.Height); LoadTextureData(ret, bmp); return(ret); }
void RestoreRenderTarget(RenderTarget rt) { var tw = rt.Texture2d.Opaque as TextureWrapper; int w = rt.Texture2d.IntWidth; int h = rt.Texture2d.IntHeight; var d3dtex = new d3d9.Texture(dev, w, h, 1, d3d9.Usage.RenderTarget, d3d9.Format.A8R8G8B8, d3d9.Pool.Default); tw.Texture = d3dtex; //i know it's weird, we have to re-add ourselves to the list //bad design.. ResetHandlers.Add(rt, "RenderTarget", () => ResetRenderTarget(rt), () => RestoreRenderTarget(rt)); }
private void DestroyTexture(FrameInfo frameInfo, EX9.Texture texture, DestroyReason reason) { if (texture != null) { // Put the texture back in the pool FTexturePool.PutTexture(texture); if (reason == DestroyReason.DeviceLost) { // Release this device if it got lost FTexturePool.Release(texture.Device); } } }
/// <summary> /// Acquires a new or used alpha texture from the ADTAlphaHandler and then loads the surface with AlphaData /// </summary> private void LoadAlphaTexture() { mAlphaTexture = ADTAlphaHandler.FreeTexture(); if (mAlphaTexture == null) { mAlphaTexture = new SlimDX.Direct3D9.Texture(Game.GameManager.GraphicsThread.GraphicsManager.Device, 64, 64, 1, Usage.None, Format.A8R8G8B8, Pool.Managed); } Surface baseSurf = mAlphaTexture.GetSurfaceLevel(0); System.Drawing.Rectangle rec = System.Drawing.Rectangle.FromLTRB(0, 0, 64, 64); Surface.FromMemory(baseSurf, AlphaData, Filter.Box, 0, Format.A8R8G8B8, 4 * 64, rec); baseSurf.Dispose(); }
private EX9.Texture CreateTexture(CefBrowser browser, Device device) { // TODO: Fix exceptions on start up. lock (FTextureResource) { var usage = Usage.None & ~Usage.AutoGenerateMipMap; var texture = new EX9.Texture(device, FSize.Width, FSize.Height, 1, usage, Format.A8R8G8B8, Pool.Default); var sysmemTexture = new EX9.Texture(device, FSize.Width, FSize.Height, 1, usage, Format.A8R8G8B8, Pool.SystemMemory); texture.Tag = sysmemTexture; var rect = new CefRect(0, 0, FSize.Width, FSize.Height); FBrowser.Invalidate(rect); return(texture); } }
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 SlimDX.Direct3D9.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"); } }
private EX9.Texture CreateTexture(CefBrowser browser, Device device) { // TODO: Fix exceptions on start up. lock (FTextures) { var usage = Usage.None & ~Usage.AutoGenerateMipMap; var pool = Pool.Managed; if (device is DeviceEx) { usage = Usage.Dynamic & ~Usage.AutoGenerateMipMap; pool = Pool.Default; } var texture = new EX9.Texture(device, FSize.Width, FSize.Height, 1, usage, Format.A8R8G8B8, pool); var rect = new CefRect(0, 0, FSize.Width, FSize.Height); FBrowser.Invalidate(rect); FTextures.Add(texture); return(texture); } }
public void OnDeviceLost(object sender, EventArgs e) { if (_sprite != null && !_sprite.Disposed) { _sprite.Dispose(); } if (_shipSprite != null && !_shipSprite.Disposed) { _shipSprite.Dispose(); } if (_texture != null && !_texture.Disposed) { _texture.Dispose(); _texture = null; } if (_font != null && !_font.Disposed) { _font.Dispose(); _font = null; } }
public unsafe BitmapBuffer ResolveTexture2d(Texture2d tex) { //TODO - lazy create and cache resolving target in RT var target = new d3d9.Texture(dev, tex.IntWidth, tex.IntHeight, 1, d3d9.Usage.None, d3d9.Format.A8R8G8B8, d3d9.Pool.SystemMemory); var tw = tex.Opaque as TextureWrapper; dev.GetRenderTargetData(tw.Texture.GetSurfaceLevel(0), target.GetSurfaceLevel(0)); var dr = target.LockRectangle(0, LockFlags.ReadOnly); if (dr.Pitch != tex.IntWidth * 4) { throw new InvalidOperationException(); } int[] pixels = new int[tex.IntWidth * tex.IntHeight]; dr.Data.ReadRange(pixels, 0, tex.IntWidth * tex.IntHeight); var bb = new BitmapBuffer(tex.IntWidth, tex.IntHeight, pixels); target.UnlockRectangle(0); target.Dispose(); //buffer churn warning return(bb); }
void ShutdownD3D9() { if (NumActiveImages == 0) { if (SharedTexture != null) { SharedTexture.Dispose(); SharedTexture = null; } if (D3DDevice != null) { D3DDevice.Dispose(); D3DDevice = null; } if (D3DContext != null) { D3DContext.Dispose(); D3DContext = null; } } }
public RenderTarget CreateRenderTarget(int w, int h) { var d3dtex = new d3d9.Texture(dev, w, h, 1, d3d9.Usage.RenderTarget, d3d9.Format.A8R8G8B8, d3d9.Pool.Default); var tw = new TextureWrapper() { Texture = d3dtex }; var tex = new Texture2d(this, tw, w, h); RenderTarget rt = new RenderTarget(this, tw, tex); ResetHandlers.Add(rt, "RenderTarget", () => { d3dtex.Dispose(); tw.Texture = null; }, () => { d3dtex = new d3d9.Texture(dev, w, h, 1, d3d9.Usage.RenderTarget, d3d9.Format.A8R8G8B8, d3d9.Pool.Default); tw.Texture = d3dtex; } ); return(rt); }
public override void Init() { Content.ContentPath = "Data"; scene = new Scene(); scene.View = this; scene.Camera = new LookatCartesianCamera() { Position = new Vector3(10, 10, 10), Lookat = Vector3.Zero, ZFar = 100, AspectRatio = AspectRatio }; //heightmap = TextureUtil.ToHeightmap(Content.Peek<Texture>(new TextureFromFile("testheightmap.png")), 100); texture = new Graphics.Software.Texture<Graphics.Software.Texel.A8R8G8B8>( new Graphics.Software.Texel.A8R8G8B8[250, 250]); var r = new Random(); for(int y=0; y < texture.Size.Height; y++) for(int x=0; x < texture.Size.Width; x++) texture[y, x] = new Graphics.Software.Texel.A8R8G8B8 { //R = 1f,//(float)r.NextDouble(), //G = (float)r.NextDouble(), //B = (float)r.NextDouble(), A = 1f, }; scene.Add(ground = new TestGround { Size = new SizeF(100, 100), //Texture = new SingleColorTexture(Color.Orange), NPieces = new Size(20, 20), }); ground.ConstructPieces(); dxTexture = texture.ToTexture9(Device9); UpdateTexture(); groundTextureEditor = new Graphics.Editors.GroundTextureEditor { Camera = scene.Camera, Viewport = Viewport, SoftwareTexture = new ITexture[] { texture }, Texture9 = new[] {dxTexture}, Position = ground.Translation, Size = ground.Size, GroundIntersect = new WorldViewProbe(this, scene.Camera) { WorldProbe = new GroundProbe() }, Pencil = new Graphics.Editors.GroundTexturePencil { Color = new Vector4(1, 0, 0, 0), Radius = 30, Type = Graphics.Editors.GroundTexturePencilType.Add } }; groundTextureEditor.TextureValuesChanged += new Graphics.Editors.TextureValuesChangedEventHandler((o, e) => { UpdateTexture(); foreach (var v in ground.Children) v.Invalidate(); }); InputHandler = new WalkaroundCameraInputHandler { Camera = (LookatCartesianCamera)scene.Camera, InputHandler = groundTextureEditor }; renderer = new Graphics.Renderer.Renderer(Device9) { Scene = scene, StateManager = new Device9StateManager(Device9) }; renderer.Initialize(this); sceneRendererConnector = new SortedTestSceneRendererConnector { Scene = scene, Renderer = renderer }; sceneRendererConnector.Initialize(); }
public RenderTarget CreateRenderTarget(int w, int h) { var d3dtex = new d3d9.Texture(dev, w, h, 1, d3d9.Usage.RenderTarget, d3d9.Format.A8R8G8B8, d3d9.Pool.Default); var tw = new TextureWrapper() { Texture = d3dtex }; var tex = new Texture2d(this, tw, w, h); RenderTarget rt = new RenderTarget(this, tw, tex); return rt; }
public unsafe BitmapBuffer ResolveTexture2d(Texture2d tex) { //TODO - lazy create and cache resolving target in RT var target = new d3d9.Texture(dev, tex.IntWidth, tex.IntHeight, 1, d3d9.Usage.None, d3d9.Format.A8R8G8B8, d3d9.Pool.SystemMemory); var tw = tex.Opaque as TextureWrapper; dev.GetRenderTargetData(tw.Texture.GetSurfaceLevel(0), target.GetSurfaceLevel(0)); var dr = target.LockRectangle(0, LockFlags.ReadOnly); if (dr.Pitch != tex.IntWidth * 4) throw new InvalidOperationException(); int[] pixels = new int[tex.IntWidth * tex.IntHeight]; dr.Data.ReadRange(pixels, 0, tex.IntWidth * tex.IntHeight); var bb = new BitmapBuffer(tex.IntWidth, tex.IntHeight, pixels); target.UnlockRectangle(0); target.Dispose(); //buffer churn warning return bb; }
public override void Init() { Content.ContentPath = "Data"; scene = new Scene(); scene.View = this; scene.Camera = new LookatCartesianCamera() { Position = new Vector3(10, 10, 10), Lookat = Vector3.Zero, ZFar = 100, AspectRatio = AspectRatio }; //heightmap = TextureUtil.ToHeightmap(Content.Peek<Texture>(new TextureFromFile("testheightmap.png")), 100); texture = new Graphics.Software.Texture <Graphics.Software.Texel.A8R8G8B8>( new Graphics.Software.Texel.A8R8G8B8[250, 250]); var r = new Random(); for (int y = 0; y < texture.Size.Height; y++) { for (int x = 0; x < texture.Size.Width; x++) { texture[y, x] = new Graphics.Software.Texel.A8R8G8B8 { //R = 1f,//(float)r.NextDouble(), //G = (float)r.NextDouble(), //B = (float)r.NextDouble(), A = 1f, } } } ; scene.Add(ground = new TestGround { Size = new SizeF(100, 100), //Texture = new SingleColorTexture(Color.Orange), NPieces = new Size(20, 20), }); ground.ConstructPieces(); dxTexture = texture.ToTexture9(Device9); UpdateTexture(); groundTextureEditor = new Graphics.Editors.GroundTextureEditor { Camera = scene.Camera, Viewport = Viewport, SoftwareTexture = new ITexture[] { texture }, Texture9 = new[] { dxTexture }, Position = ground.Translation, Size = ground.Size, GroundIntersect = new WorldViewProbe(this, scene.Camera) { WorldProbe = new GroundProbe() }, Pencil = new Graphics.Editors.GroundTexturePencil { Color = new Vector4(1, 0, 0, 0), Radius = 30, Type = Graphics.Editors.GroundTexturePencilType.Add } }; groundTextureEditor.TextureValuesChanged += new Graphics.Editors.TextureValuesChangedEventHandler((o, e) => { UpdateTexture(); foreach (var v in ground.Children) { v.Invalidate(); } }); InputHandler = new WalkaroundCameraInputHandler { Camera = (LookatCartesianCamera)scene.Camera, InputHandler = groundTextureEditor }; renderer = new Graphics.Renderer.Renderer(Device9) { Scene = scene, StateManager = new Device9StateManager(Device9) }; renderer.Initialize(this); sceneRendererConnector = new SortedTestSceneRendererConnector { Scene = scene, Renderer = renderer }; sceneRendererConnector.Initialize(); }
public void SetProperties(int width, int height, uint handle, EnumEntry formatEnum, EnumEntry usageEnum) { this.FHandle = (IntPtr)unchecked((int)handle); if (handle == 0) { throw (new Exception("No shared texture handle set")); } var format = enumToFormat(formatEnum); var usage = enumToUsage(usageEnum); if (width != this.FWidth || height != this.FHeight || format != this.FFormat || usage != this.FUsage) { Allocate(width, height, format, usage); } this.FTextureShared = new Texture(this.FDevice, width, height, 1, usage, format, Pool.Default, ref this.FHandle); }
public void Render(Grid.GridRange range, Rectangle viewport) { // 1. Remove previous tiles. //// foreach (var cellList in visibleCells.Values) { cellList.Clear(); } // 1. Fill //// foreach (Grid.GridCell cell in range) { if (cell.Data == null) { continue; } BlobImage image = cell.Data.Floor.Image; if (!visibleCells.ContainsKey(image)) { Bitmap bitmap = image.Image; using (Stream s = new MemoryStream()) { bitmap.Save(s, ImageFormat.Png); s.Seek(0, SeekOrigin.Begin); Texture tex = Texture.FromStream(device, s, bitmap.Width, bitmap.Height, 0, Usage.None, Format.Unknown, Pool.Managed, Filter.None, Filter.None, 0); textures.Add(image, tex); visibleCells.Add(image, new List <TexturedVertex>()); } } List <TexturedVertex> currentList = visibleCells[image]; int pixelsPerCell = 8; int x = (cell.X * pixelsPerCell) - viewport.X; int y = (cell.Y * pixelsPerCell) - viewport.Y; int w = 8; int h = 8; // Calculate the (u,v) we need to use based on the tile coordinates. float scaleW = 8.0f / image.Image.Width; float scaleH = 8.0f / image.Image.Height; float uStart = cell.X * scaleW; float vStart = cell.Y * scaleH; float uEnd = uStart + scaleW; float vEnd = vStart + scaleH; // Clockwise winding // TODO: Index these vertices! argh var v0 = new TexturedVertex(new Vector4(x, y, RenderingZOffset, 1.0f), new Vector2(uStart, vStart)); var v1 = new TexturedVertex(new Vector4(x + w, y, RenderingZOffset, 1.0f), new Vector2(uEnd, vStart)); var v2 = new TexturedVertex(new Vector4(x + w, y + h, RenderingZOffset, 1.0f), new Vector2(uEnd, vEnd)); var v3 = new TexturedVertex(new Vector4(x, y, RenderingZOffset, 1.0f), new Vector2(uStart, vStart)); var v4 = new TexturedVertex(new Vector4(x + w, y + h, RenderingZOffset, 1.0f), new Vector2(uEnd, vEnd)); var v5 = new TexturedVertex(new Vector4(x, y + h, RenderingZOffset, 1.0f), new Vector2(uStart, vEnd)); currentList.Add(v0); currentList.Add(v1); currentList.Add(v2); currentList.Add(v3); currentList.Add(v4); currentList.Add(v5); } // 2. Fill buffer. //// DataStream stream = vertexBuffer.Lock(0, 0, LockFlags.Discard); foreach (var vertexList in visibleCells) { if (vertexList.Value.Count == 0) { continue; } stream.WriteRange(vertexList.Value.ToArray()); } vertexBuffer.Unlock(); // 3. Draw. //// device.SetSamplerState(0, SamplerState.MinFilter, TextureFilter.Linear); device.SetStreamSource(0, vertexBuffer, 0, TexturedVertex.Size); device.VertexDeclaration = vertexDecl; int offset = 0; foreach (var vertexList in visibleCells) { var texture = textures[vertexList.Key]; device.SetTexture(0, texture); int tilesToDraw = vertexList.Value.Count / 3; device.DrawPrimitives(PrimitiveType.TriangleList, offset, tilesToDraw); offset += tilesToDraw * 3; } }
private void UpdateTexture(FrameInfo frameInfo, EX9.Texture texture) { }
public override void Init() { Content.ContentPath = ""; Content.ContentCachePath = "Cache/"; Meshes.Load(Device); billboard = Meshes.PositionTexcoord(Device, Meshes.IndexedPlane(-8.1640625f, -62f / 20f, 38, 62 / 2f)); plane = Meshes.PositionTexcoord(Device, Meshes.IndexedGrid(new Vector3(-0.5f, -0.5f, 0), new Vector2(1, 1), 128, 128, Vector2.Zero, new Vector2(1, 1))); tree = SlimDX.Direct3D9.Mesh.FromFile(Device, "spruce.x", MeshFlags.Managed); unit = SlimDX.Direct3D9.Mesh.FromFile(Device, "unitcylinder.x", MeshFlags.Managed); Reloadable.Load((efn) => { Effect e = EffectUtil.LoadWithDebugger(Device, efn); if(e == null) return; if (ef != null) ef.Dispose(); ef = e; }, "geomorph.fx"); text = Texture.FromFile(Device, "ground.jpg", Usage.None, Pool.Managed); text.GenerateMipSublevels(); treeMap = Texture.FromFile(Device, "spruce.tga", Usage.None, Pool.Managed); treeMap.GenerateMipSublevels(); treeBillboard = Texture.FromFile(Device, "spruceBillboard.tga", Usage.None, Pool.Managed); treeBillboard.GenerateMipSublevels(); String hm = "heightmap-landscape.tga"; HeightmapProcessor heightmapProcessor = new HeightmapProcessor(); Reloadable.Load((h) => { if (heightMap != null) heightMap.Dispose(); heightMap = heightmapProcessor.Load(Device, h); }, hm); textureSize = heightMap.GetLevelDescription(0).Width; terrain = new GeoclipmappedTerrain(Device, resolution); DataRectangle r = heightMap.LockRectangle(0, LockFlags.ReadOnly); data = TextureUtil.ReadTexture<ClientCommon.TextureColor.R32G32B32A32F>(r, textureSize); heightMap.UnlockRectangle(0); DataRectangle r2 = heightMap.LockRectangle(5, LockFlags.ReadOnly); dataLod2 = TextureUtil.ReadTexture<ClientCommon.TextureColor.R32G32B32A32F>(r2, textureSize/(int)Math.Pow(2, 5)); heightMap.UnlockRectangle(5); float prev = 20; cam = new WalkaroundCamera(this, (float x, float y) => { float z = HeightAt(data, x, y); float re = z * 0.05f + prev * 0.95f; prev = re; return re + 1.8f; }); cam.ZFar *= 100; cam.Speed = 2; values = new Values(); values.Show(); instanceVD = new VertexDeclaration(Device, instanceVES); instancingVB = new VertexBuffer(Device, ntrees * Vector3.SizeInBytes, Usage.None, VertexFormat.None, Pool.Managed); Random ra = new Random(0); trees = new Vector3[ntrees]; treeRidgeDiff = new float[ntrees]; for (int i = 0; i < ntrees/40; i++) { float x = ((float)ra.NextDouble() - 0.5f) * heightmapScale; float y = ((float)ra.NextDouble() - 0.5f) * heightmapScale * 0.5f; for (int k = 0; k < 40; k++) { float x1 = x + ((float)ra.NextDouble() - 0.5f) * 100; float y1 = y + ((float)ra.NextDouble() - 0.5f) * 100; float z = HeightAt(data, x1, y1); trees[i*40 + k] = new Vector3(x1, y1, z); treeRidgeDiff[i*40 + k] = HeightAt(dataLod2, x1, y1) - z; } } //Fullscreen = false; }
private void LoadNormalTexture() { Debug.Assert( TextureType == TextureType.OneD || TextureType == TextureType.TwoD ); if ( Name.EndsWith( ".dds" ) ) { Stream stream = ResourceGroupManager.Instance.OpenResource( Name, Group, true, this ); int numMips = this.RequestedMipmapCount + 1; // check if mip map volume textures are supported if ( ( _devCaps.TextureCaps & D3D.TextureCaps.MipCubeMap ) != D3D.TextureCaps.MipCubeMap ) { // no mip map support for this kind of textures :( this.MipmapCount = 0; numMips = 1; } _d3dPool = ( Usage & TextureUsage.Dynamic ) != 0 ? D3D.Pool.Default : D3D.Pool.Managed; try { // load the cube texture from the image data stream directly this._normTexture = D3D.Texture.FromStream( _device, stream, (int)stream.Length, 0, 0, numMips, D3D.Usage.None, D3D.Format.Unknown, _d3dPool, D3D.Filter.None, D3D.Filter.None, 0 ); } catch ( Exception ex ) { FreeInternalResources(); throw new Exception( "Can't create texture.", ex ); } // store off a base reference _texture = _normTexture; // set src and dest attributes to the same, we can't know D3D.SurfaceDescription desc = _normTexture.GetLevelDescription( 0 ); _d3dPool = desc.Pool; SetSrcAttributes( desc.Width, desc.Height, 1, D3DHelper.ConvertEnum( desc.Format ) ); SetFinalAttributes( desc.Width, desc.Height, 1, D3DHelper.ConvertEnum( desc.Format ) ); internalResourcesCreated = true; } else { // find & load resource data intro stream to allow resource group changes if required Stream strm = ResourceGroupManager.Instance.OpenResource( Name, Group, true, this ); int pos = Name.LastIndexOf( "." ); String ext = Name.Substring( pos + 1 ); // Call internal LoadImages, not LoadImage since that's external and // will determine load status etc again var image = Image.FromStream( strm, ext ); LoadImages( new Image[] { image } ); image.Dispose(); strm.Close(); } }
private void CreateNormalTexture() { Debug.Assert( SrcWidth > 0 && SrcHeight > 0 ); // determine which D3D9 pixel format we'll use D3D.Format d3dPixelFormat = ChooseD3DFormat(); // set the appropriate usage based on the usage of this texture D3D.Usage d3dUsage = ( ( Usage & TextureUsage.RenderTarget ) == TextureUsage.RenderTarget ) ? D3D.Usage.RenderTarget : D3D.Usage.None; // how many mips to use? int numMips = RequestedMipmapCount + 1; D3D.TextureRequirements texRequire = new D3D.TextureRequirements(); texRequire.Width = SrcWidth; texRequire.Height = SrcHeight; // check texture requirements texRequire.MipLevelCount = numMips; texRequire.Format = d3dPixelFormat; //// NOTE: Although texRequire is an out parameter, it actually does //// use the data passed in with that object. texRequire = D3D.Texture.CheckRequirements( _device, SrcWidth, SrcHeight, numMips, d3dUsage, d3dPixelFormat, D3D.Pool.Default ); // Save updated texture requirements numMips = texRequire.MipLevelCount; d3dPixelFormat = texRequire.Format; if ( ( Usage & TextureUsage.Dynamic ) == TextureUsage.Dynamic ) { if ( CanUseDynamicTextures( d3dUsage, D3D.ResourceType.Texture, d3dPixelFormat ) ) { d3dUsage |= D3D.Usage.Dynamic; _dynamicTextures = true; } else { _dynamicTextures = false; } } // check if mip maps are supported on hardware MipmapsHardwareGenerated = false; if ( ( _devCaps.TextureCaps & D3D.TextureCaps.MipMap ) == D3D.TextureCaps.MipMap ) { if ( ( ( Usage & TextureUsage.AutoMipMap ) == TextureUsage.AutoMipMap ) && RequestedMipmapCount > 0 ) { MipmapsHardwareGenerated = this.CanAutoGenMipMaps( d3dUsage, D3D.ResourceType.Texture, d3dPixelFormat ); if ( MipmapsHardwareGenerated ) { d3dUsage |= D3D.Usage.AutoGenerateMipMap; numMips = 0; } } } else { // no mip map support for this kind of texture MipmapCount = 0; numMips = 1; } // create the texture _normTexture = new D3D.Texture( _device, SrcWidth, SrcHeight, numMips, d3dUsage, d3dPixelFormat, _d3dPool ); // store base reference to the texture _texture = _normTexture; // set the final texture attributes D3D.SurfaceDescription desc = _normTexture.GetLevelDescription( 0 ); SetFinalAttributes( desc.Width, desc.Height, 1, D3DHelper.ConvertEnum( desc.Format ) ); if ( MipmapsHardwareGenerated ) { _texture.AutoMipGenerationFilter = GetBestFilterMethod(); } }
public override void Unload() { base.Unload(); if ( IsLoaded ) { if ( this._texture != null ) { this._texture.Dispose(); this._texture = null; } if ( this._normTexture != null ) { LogManager.Instance.Write( "Disposed normal texture {0}", this.Name ); this._normTexture.Dispose(); this._normTexture = null; } if ( this._cubeTexture != null ) { this._cubeTexture.Dispose(); this._cubeTexture = null; } if ( this._volumeTexture != null ) { this._volumeTexture.Dispose(); this._volumeTexture = null; } } }
///<summary> /// Copies a region of this pixelbuffer to normal memory. ///</summary> ///<param name="srcBox">BasicBox describing the source region of this buffer</param> ///<param name="dst">PixelBox describing the destination pixels and format in memory</param> ///<remarks> /// The source and destination regions don't have to match, in which /// case scaling is done. /// Only call this function when the buffer is unlocked. ///</remarks> public override void BlitToMemory( BasicBox srcBox, PixelBox dst ) { // Decide on pixel format of temp surface PixelFormat tmpFormat = Format; if ( D3DHelper.ConvertEnum( dst.Format ) == D3D.Format.Unknown ) tmpFormat = dst.Format; if ( surface != null ) { Debug.Assert( srcBox.Depth == 1 && dst.Depth == 1 ); // Create temp texture D3D.Texture tmp = new D3D.Texture( device, dst.Width, dst.Height, 1, // 1 mip level ie topmost, generate no mipmaps 0, D3DHelper.ConvertEnum( tmpFormat ), D3D.Pool.Scratch ); D3D.Surface subSurface = tmp.GetSurfaceLevel( 0 ); // Copy texture to this temp surface System.Drawing.Rectangle destRect, srcRect; srcRect = ToD3DRectangle( srcBox ); destRect = ToD3DRectangleExtent( dst ); D3D.Surface.FromSurface( subSurface, surface, D3D.Filter.None, 0, srcRect, destRect ); // Lock temp surface and copy it to memory int pitch; // Filled in by D3D DX.DataRectangle data = subSurface.LockRectangle( D3D.LockFlags.ReadOnly ); // Copy it PixelBox locked = new PixelBox( dst.Width, dst.Height, dst.Depth, tmpFormat ); FromD3DLock( locked, data ); PixelConverter.BulkPixelConversion( locked, dst ); subSurface.UnlockRectangle(); // Release temporary surface and texture subSurface.Dispose(); tmp.Dispose(); } else { // Create temp texture D3D.VolumeTexture tmp = new D3D.VolumeTexture( device, dst.Width, dst.Height, dst.Depth, 0, D3D.Usage.None, D3DHelper.ConvertEnum( tmpFormat ), D3D.Pool.Scratch ); D3D.Volume subVolume = tmp.GetVolumeLevel( 0 ); // Volume D3D.Box ddestBox = ToD3DBoxExtent( dst ); D3D.Box dsrcBox = ToD3DBox( srcBox ); D3D.Volume.FromVolume( subVolume, volume, D3D.Filter.None, 0, dsrcBox, ddestBox ); // Lock temp surface and copy it to memory //D3D.LockedBox lbox; // Filled in by D3D DX.DataBox data = subVolume.LockBox( D3D.LockFlags.ReadOnly ); // Copy it PixelBox locked = new PixelBox( dst.Width, dst.Height, dst.Depth, tmpFormat ); FromD3DLock( locked, data ); PixelConverter.BulkPixelConversion( locked, dst ); subVolume.UnlockBox(); // Release temporary surface and texture subVolume.Dispose(); tmp.Dispose(); } }
public tMesh(Mesh mesh, SlimDX.Direct3D9.Texture texture) { MeshData = mesh; TexData = texture; }
public RenderTarget CreateRenderTarget(int w, int h) { var d3dtex = new d3d9.Texture(dev, w, h, 1, d3d9.Usage.RenderTarget, d3d9.Format.A8R8G8B8, d3d9.Pool.Default); var tw = new TextureWrapper() { Texture = d3dtex }; var tex = new Texture2d(this, tw, w, h); RenderTarget rt = new RenderTarget(this, tw, tex); ResetHandlers.Add(rt, "RenderTarget", () => { d3dtex.Dispose(); tw.Texture = null; }, () => { d3dtex = new d3d9.Texture(dev, w, h, 1, d3d9.Usage.RenderTarget, d3d9.Format.A8R8G8B8, d3d9.Pool.Default); tw.Texture = d3dtex; } ); return rt; }
public Texture2d LoadTexture(BitmapBuffer bmp) { var tex = new d3d9.Texture(dev, bmp.Width, bmp.Height, 1, d3d9.Usage.None, d3d9.Format.A8R8G8B8, d3d9.Pool.Managed); var ret = new Texture2d(this, IntPtr.Zero, tex, bmp.Width, bmp.Height); LoadTextureData(ret, bmp); return ret; }
void Deallocate() { if (this.FDevice != null) { this.FDevice.Dispose(); this.FDevice = null; } if (this.FTextureShared != null) { this.FTextureShared.Dispose(); this.FTextureShared = null; } foreach(var saver in FSavers) { saver.Dispose(); } FSavers.Clear(); FInitialised = false; }
protected override void freeInternalResources() { if ( this._texture != null && !_texture.Disposed ) { this._texture.Dispose(); this._texture = null; } if ( this._normTexture != null && !_normTexture.Disposed ) { this._normTexture.Dispose(); this._normTexture = null; } if ( this._cubeTexture != null && !_cubeTexture.Disposed ) { this._cubeTexture.Dispose(); this._cubeTexture = null; } if ( this._volumeTexture != null && !_volumeTexture.Disposed ) { this._volumeTexture.Dispose(); this._volumeTexture = null; } }
public override void Init() { Content.ContentPath = "Data"; Instance = this; scene = new Scene(); scene.View = this; scene.Camera = new LookatCartesianCamera() { Position = new Vector3(10, 10, 10), Lookat = Vector3.Zero, ZFar = 100, AspectRatio = AspectRatio }; //heightmap = TextureUtil.ToHeightmap(Content.Peek<Texture>(new TextureFromFile("testheightmap.png")), 100); texture = new Graphics.Software.Texture<Graphics.Software.Texel.A8R8G8B8>(new Graphics.Software.Texel.A8R8G8B8[250, 250]); scene.Add(ground = new TestGround { Size = new SizeF(100, 100), //Texture = new SingleColorTexture(Color.Orange), NPieces = new Size(20, 20), }); ground.ConstructPieces(); dxTexture = texture.ToTexture9(Device9); ground.Texture = new UnmanagedResource<SlimDX.Direct3D9.Texture, SlimDX.Direct3D10.Texture2D> { Resource9 = dxTexture }; groundTextureEditor = new Graphics.Editors.GroundTextureEditor { Camera = scene.Camera, Viewport = Viewport, SoftwareTexture = new[] {texture}, Texture9 = new[] {dxTexture}, Position = ground.Translation, Size = ground.Size, GroundIntersect = new WorldViewProbe(this, scene.Camera) { WorldProbe = new GroundProbe() }, Pencil = new Graphics.Editors.GroundTexturePencil { Color = new Vector4(0, 0, 1, 0), Radius = 5, Type = Graphics.Editors.GroundTexturePencilType.AddSaturate } }; groundTextureEditor.TextureValuesChanged += new Graphics.Editors.TextureValuesChangedEventHandler((o, e) => { }); InputHandler = new WalkaroundCameraInputHandler { Camera = (LookatCartesianCamera)scene.Camera, InputHandler = groundTextureEditor, }; renderer = new Graphics.Renderer.Renderer(Device9) { Scene = scene, StateManager = new Device9StateManager(Device9) }; renderer.Initialize(this); sceneRendererConnector = new SortedTestSceneRendererConnector { Renderer = renderer, Scene = scene }; sceneRendererConnector.Initialize(); }
public Texture2d LoadTexture(BitmapBuffer bmp) { var tex = new d3d9.Texture(dev, bmp.Width, bmp.Height, 1, d3d9.Usage.None, d3d9.Format.A8R8G8B8, d3d9.Pool.Managed); var tw = new TextureWrapper() { Texture = tex }; var ret = new Texture2d(this, tw, bmp.Width, bmp.Height); LoadTextureData(ret, bmp); return ret; }
int DrawIndexedPrimitivesHook(IntPtr devicePtr, SlimDX.Direct3D9.PrimitiveType primitiveType, int baseVertexIndex, int minimumVertexIndex, int numVertices, int startIndex, int primCount) { using (SlimDX.Direct3D9.Device device = SlimDX.Direct3D9.Device.FromPointer(devicePtr)) { Primitive prim = new Primitive(primCount, numVertices); int hRet = 0; try { if (Interface.CaptureFrame) { RipModel(device, primitiveType, baseVertexIndex, startIndex, primCount); } //if new primitive being rendered, add it to our list if (!prims.Contains(prim)) { prims.Add(prim); } Primitive selectedPrim = prims.GetSelectedPrimitive(); if (selectedPrim != null) { if (selectedPrim.Equals(prim)) { if (RedTexture == null) { RedTexture = SlimDX.Direct3D9.Texture.FromMemory(device, red); } if (Interface.chamed == true) { selectedPrim.Chamed = true; Interface.Togglecham(); } device.SetRenderState(SlimDX.Direct3D9.RenderState.FillMode, SlimDX.Direct3D9.FillMode.Solid); device.SetTexture(0, RedTexture); if (selectedPrim.Chamed) { //device.Clear(ClearFlags.ZBuffer, Color.Red, 1.0f, 0); device.SetRenderState(SlimDX.Direct3D9.RenderState.ZEnable, false); hRet = device.DrawIndexedPrimitives(primitiveType, baseVertexIndex, minimumVertexIndex, numVertices, startIndex, primCount).Code; device.SetRenderState(SlimDX.Direct3D9.RenderState.ZEnable, true); } if (Interface.rip) { if (!Interface.CaptureFrame) { RipModel(device, primitiveType, baseVertexIndex, startIndex, primCount); Interface.ToggleRip(); } } hRet = device.DrawIndexedPrimitives(primitiveType, baseVertexIndex, minimumVertexIndex, numVertices, startIndex, primCount).Code; } } //if not to display, don't render if (prims.IndexOf(prim) != -1) { if (prims[prims.IndexOf(prim)].Displayed == false) { return(0); } } } catch (Exception e) { Interface.ReportException(e); return(hRet); } if (hRet == 0) { if (prims[prims.IndexOf(prim)].Chamed == false) { hRet = device.DrawIndexedPrimitives(primitiveType, baseVertexIndex, minimumVertexIndex, numVertices, startIndex, primCount).Code; } else { PixelShader previous = device.PixelShader; if (chamPixelShader == null) { chamPixelShader = new PixelShader(device, ShaderBytecode.Compile("float4 PShader(float4 position : SV_POSITION) : SV_Target\n" + "{\nreturn float4(1.0f, 1.0f, 0.0f, 1.0f);\n}", "PShader", "ps_3_0", ShaderFlags.None)); } device.PixelShader = chamPixelShader; hRet = device.DrawIndexedPrimitives(primitiveType, baseVertexIndex, minimumVertexIndex, numVertices, startIndex, primCount).Code; device.SetRenderState(SlimDX.Direct3D9.RenderState.ZEnable, false); hRet = device.DrawIndexedPrimitives(primitiveType, baseVertexIndex, minimumVertexIndex, numVertices, startIndex, primCount).Code; device.SetRenderState(RenderState.ZEnable, true); device.PixelShader = previous; } } return(hRet); } }
int DrawIndexedPrimitivesHook(IntPtr devicePtr, SlimDX.Direct3D9.PrimitiveType primitiveType, int baseVertexIndex, int minimumVertexIndex, int numVertices, int startIndex, int primCount) { using (SlimDX.Direct3D9.Device device = SlimDX.Direct3D9.Device.FromPointer(devicePtr)) { Primitive prim = new Primitive(primCount, numVertices); int hRet = 0; try { if(Interface.CaptureFrame) RipModel(device, primitiveType, baseVertexIndex, startIndex, primCount); //if new primitive being rendered, add it to our list if (!prims.Contains(prim)) { prims.Add(prim); } Primitive selectedPrim = prims.GetSelectedPrimitive(); if (selectedPrim != null) { if (selectedPrim.Equals(prim)) { if (RedTexture == null) RedTexture = SlimDX.Direct3D9.Texture.FromMemory(device, red); if (Interface.chamed == true) { selectedPrim.Chamed = true; Interface.Togglecham(); } device.SetRenderState(SlimDX.Direct3D9.RenderState.FillMode, SlimDX.Direct3D9.FillMode.Solid); device.SetTexture(0, RedTexture); if (selectedPrim.Chamed) { //device.Clear(ClearFlags.ZBuffer, Color.Red, 1.0f, 0); device.SetRenderState(SlimDX.Direct3D9.RenderState.ZEnable, false); hRet = device.DrawIndexedPrimitives(primitiveType, baseVertexIndex, minimumVertexIndex, numVertices, startIndex, primCount).Code; device.SetRenderState(SlimDX.Direct3D9.RenderState.ZEnable, true); } if (Interface.rip) { if (!Interface.CaptureFrame) { RipModel(device, primitiveType, baseVertexIndex, startIndex, primCount); Interface.ToggleRip(); } } hRet = device.DrawIndexedPrimitives(primitiveType, baseVertexIndex, minimumVertexIndex, numVertices, startIndex, primCount).Code; } } //if not to display, don't render if(prims.IndexOf(prim) != -1) if (prims[prims.IndexOf(prim)].Displayed == false) return 0; } catch (Exception e) { Interface.ReportException(e); return hRet; } if (hRet == 0) { if (prims[prims.IndexOf(prim)].Chamed == false) { hRet = device.DrawIndexedPrimitives(primitiveType, baseVertexIndex, minimumVertexIndex, numVertices, startIndex, primCount).Code; } else { PixelShader previous = device.PixelShader; if(chamPixelShader == null) chamPixelShader = new PixelShader(device, ShaderBytecode.Compile("float4 PShader(float4 position : SV_POSITION) : SV_Target\n" + "{\nreturn float4(1.0f, 1.0f, 0.0f, 1.0f);\n}", "PShader", "ps_3_0", ShaderFlags.None)); device.PixelShader = chamPixelShader; hRet = device.DrawIndexedPrimitives(primitiveType, baseVertexIndex, minimumVertexIndex, numVertices, startIndex, primCount).Code; device.SetRenderState(SlimDX.Direct3D9.RenderState.ZEnable, false); hRet = device.DrawIndexedPrimitives(primitiveType, baseVertexIndex, minimumVertexIndex, numVertices, startIndex, primCount).Code; device.SetRenderState(RenderState.ZEnable, true); device.PixelShader = previous; } } return hRet; } }
private void Main_Load(object sender, EventArgs e) { HotKey = new Hotkey(); HotKey.enable(this.Handle, Hotkey.Modifiers.None, Keys.Insert); // Delete //Insert HotKey.enable(this.Handle, Hotkey.Modifiers.Alt, Keys.F1); HotKey.enable(this.Handle, Hotkey.Modifiers.None, Keys.N); HotKey.enable(this.Handle, Hotkey.Modifiers.Alt, Keys.F3); HotKey.enable(this.Handle, Hotkey.Modifiers.Alt, Keys.F5); //HotKey.enable(base.Handle, Hotkey.Modifiers.None, Keys.CapsLock); //HotKey.enable(base.Handle, Hotkey.Modifiers.None, Keys.Q); Native.SetWindowLong(this.Handle, -20, (IntPtr)((Native.GetWindowLong(this.Handle, -20) ^ 0x80000) ^ 0x20)); Native.SetLayeredWindowAttributes(this.Handle, 0, 0xff, 2); PresentParameters parameters = new SlimDX.Direct3D9.PresentParameters(); parameters.Windowed = true; parameters.SwapEffect = SwapEffect.Discard; parameters.BackBufferFormat = Format.A8R8G8B8; parameters.BackBufferHeight = this.Height; parameters.BackBufferWidth = this.Width; parameters.PresentationInterval = PresentInterval.One; DXDevice = new SlimDX.Direct3D9.Device(new Direct3D(), 0, DeviceType.Hardware, this.Handle, CreateFlags.HardwareVertexProcessing, new PresentParameters[] { parameters }); if (System.IO.File.Exists("map_large.png")) DXTextrureMapLarge = SlimDX.Direct3D9.Texture.FromFile(DXDevice, "map_large.png"); if (System.IO.File.Exists("map.png")) DXTextrureMap = SlimDX.Direct3D9.Texture.FromFile(DXDevice, "map.png"); if (System.IO.File.Exists("LagerMap.jpg")) DXTextureGameMap = SlimDX.Direct3D9.Texture.FromFile(DXDevice, "LagerMap.jpg"); CircleVertices = new VertexBuffer(DXDevice, (circleComplexity + 2) * TexVertex.SizeBytes, Usage.WriteOnly, VertexFormat.None, Pool.Managed); DXSprite = new SlimDX.Direct3D9.Sprite(DXDevice); DXLine = new SlimDX.Direct3D9.Line(DXDevice); DXFont = new SlimDX.Direct3D9.Font(DXDevice, new System.Drawing.Font("NewRoman", 9f)); //NewRoman DXFontB = new SlimDX.Direct3D9.Font(DXDevice, new System.Drawing.Font("Tahoma", 12f)); //NewRoman if (this.GameMemory.Attach("H1Z1 PlayClient (Live)") == false) { Application.Exit(); return; } Thread dxThread = new Thread(new ThreadStart(DoProcess)); dxThread.IsBackground = true; dxThread.Start(); //Thread aimThread = new Thread(new ThreadStart(DoAiming)); //aimThread.IsBackground = true; //aimThread.Start(); }
void Cleanup() { if (RedTexture != null) { RedTexture.Dispose(); RedTexture = null; } /* if (OrangeTexture != null) { OrangeTexture.Dispose(); OrangeTexture = null; } if (MenuFont != null) { MenuFont.Dispose(); MenuFont = null; } if (MenuLine != null) { MenuLine.Dispose(); MenuLine.Dispose(); } */ }