public void MainLoop(bool newScreen) { if (device != null) { //if (newScreen) //Texture seems to be destroyed after being displayed once { unsafe { DataRectangle drt = texture.Map(0, MapMode.WriteDiscard, SlimDX.Direct3D10.MapFlags.None); fixed(uint *screenPTR = screen) { imageScaler.PerformScale(screenPTR, (uint *)drt.Data.DataPointer); } texture.Unmap(0); } } device.ClearRenderTargetView(renderTargetView, new Color4(0.0f, 0.0f, 0.0f)); device.InputAssembler.SetInputLayout(inputLayout); device.InputAssembler.SetPrimitiveTopology(SlimDX.Direct3D10.PrimitiveTopology.TriangleStrip); device.InputAssembler.SetVertexBuffers(0, new VertexBufferBinding(vertexBuffer, Marshal.SizeOf(typeof(Vertex)), 0)); pass.Apply(); device.Draw(4, 0); DrawMessageEvent(this, null); swapChain.Present(0, PresentFlags.None); } }
public void MainLoop(bool newScreen) { unsafe { if (newScreen) { BitmapData bmd = texture.LockBits(new Rectangle(Point.Empty, texture.Size), ImageLockMode.WriteOnly, PixelFormat.Format32bppArgb); fixed(uint *screenPTR = screen) imageScaler.PerformScale(screenPTR, (uint *)bmd.Scan0); texture.UnlockBits(bmd); } renderGfx.Graphics.DrawImage(texture, renderSize); DrawMessageEvent(this, null); renderGfx.Render(); } }
public void MainLoop(bool newScreen) { try { unsafe { GL.BindTexture(TextureTarget.Texture2D, textureName); fixed(uint *scaledPTR = scaledScreen) { if (newScreen) { fixed(uint *screenPTR = screen) { imageScaler.PerformScale(screenPTR, scaledPTR); } } GL.TexImage2D(TextureTarget.Texture2D, 0, PixelInternalFormat.Rgba, imageScaler.ResizedX, imageScaler.ResizedY, 0, PixelFormat.Bgra, PixelType.UnsignedByte, (IntPtr)scaledPTR); } GL.Clear(ClearBufferMask.ColorBufferBit | ClearBufferMask.DepthBufferBit); GL.MatrixMode(MatrixMode.Modelview); GL.LoadIdentity(); GL.Begin(BeginMode.Quads); GL.TexCoord2(0.0f, 0.0f); GL.Vertex3(0, 0, 1); GL.TexCoord2(1.0f, 0.0f); GL.Vertex3(renderTarget.Width, 0, 1); GL.TexCoord2(1.0f, 1.0f); GL.Vertex3(renderTarget.Width, renderTarget.Height, 1); GL.TexCoord2(0.0f, 1.0f); GL.Vertex3(0, renderTarget.Height, 1); GL.End(); DrawMessageEvent(this, null); glControl.SwapBuffers(); } } catch //Crazy crash on winkey + d, similar issues in directx 9 driver, need to figure out whats happening. { Reset(); } }