public SDX_Surface() { mDisplay = Display.Impl as SDX_Display; mDevice = mDisplay.D3D_Device; InitVerts(); }
public SDX_Surface(Size size) { mSrcRect = new Rectangle(new Point(0, 0), size); mDisplay = Display.Impl as SDX_Display; mDevice = mDisplay.D3D_Device; mTexture = new Ref <Texture>(new Texture(mDevice.Device, size.Width, size.Height, 1, Usage.None, Format.A8R8G8B8, Pool.Managed)); RenderToSurface render = new RenderToSurface(mDevice.Device, size.Width, size.Height, Format.A8R8G8B8, Format.D16); Viewport v = new Viewport(0, 0, size.Width, size.Height); render.BeginScene(mTexture.Value.GetSurfaceLevel(0), v); mDevice.Clear(ClearFlags.Target, Color.FromArgb(0, 0, 0, 0).ToArgb(), 1.0f, 0); render.EndScene(Filter.None); render.Dispose(); render = null; mTextureSize = mSrcRect.Size; InitVerts(); }
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( }
public SDX_Surface(Ref <Texture> texture, Rectangle sourceRect) { mSrcRect = sourceRect; mDisplay = Display.Impl as SDX_Display; mDevice = mDisplay.D3D_Device; mTexture = new Ref <Texture>(texture); mTextureSize = new Size(mTexture.Value.GetSurfaceLevel(0).Description.Width, mTexture.Value.GetSurfaceLevel(0).Description.Height); InitVerts(); }
public SDX_Surface(Stream stream) { mDisplay = Display.Impl as SDX_Display; mDevice = mDisplay.D3D_Device; if (mDevice == null) { throw new Exception("Error: It appears that AgateLib has not been initialized yet. Have you created a DisplayWindow?"); } LoadFromStream(stream); InitVerts(); }
public SDX_Surface(string fileName) { mFileName = fileName; mDisplay = Display.Impl as SDX_Display; mDevice = mDisplay.D3D_Device; if (mDevice == null) { throw new Exception("Error: It appears that AgateLib has not been initialized yet. Have you created a DisplayWindow?"); } LoadFromFile(); //mDevice.Device.DeviceReset += new EventHandler(mDevice_DeviceReset); InitVerts(); }
internal void Initialize(SDX_DisplayWindow window, CreateWindowParams windowParams) { if (mInitialized) { return; } if (window.RenderTarget.TopLevelControl == null) { throw new ArgumentException("The specified render target does not have a Form object yet. " + "It's TopLevelControl property is null. You may not create DisplayWindow objects before " + "the control to render to is added to the Form."); } mInitialized = true; // ok, create D3D device PresentParameters present = windowParams.IsFullScreen ? CreateFullScreenPresentParameters(window, windowParams.Width, windowParams.Height, windowParams.Bpp) : CreateWindowedPresentParameters(window, 0, 0, 32); DeviceType dtype = DeviceType.Hardware; int adapterOrdinal = mDirect3Dobject.Adapters.DefaultAdapter.Adapter; var caps = mDirect3Dobject.GetDeviceCaps(adapterOrdinal, Direct3D.DeviceType.Hardware); var flags = Direct3D.CreateFlags.SoftwareVertexProcessing; // Is there support for hardware vertex processing? If so, replace // software vertex processing. if ((caps.DeviceCaps & DeviceCaps.HWTransformAndLight) == DeviceCaps.HWTransformAndLight) { flags = Direct3D.CreateFlags.HardwareVertexProcessing; } // Does the device support a pure device? if ((caps.DeviceCaps & DeviceCaps.PureDevice) == DeviceCaps.PureDevice) { flags |= Direct3D.CreateFlags.PureDevice; } Device device = new Device(mDirect3Dobject, adapterOrdinal, dtype, window.RenderTarget.TopLevelControl.Handle, flags, present); try { Format f = (Format)device.DepthStencilSurface.Description.Format; SetHaveDepthStencil(f); } catch { mHasDepth = true; mHasStencil = false; SetHaveDepthStencil(Format.D16); } //device.DeviceLost += new EventHandler(mDevice_DeviceLost); //device.DeviceReset += new EventHandler(mDevice_DeviceReset); device.SetRenderState(RenderState.StencilEnable, false); device.SetRenderState(RenderState.ZEnable, true); mDevice = new D3DDevice(device); //InitializeShaders(); mPosColorDecl = SDX_VertexBuffer.CreateVertexDeclaration(device, PositionColor.VertexLayout); }
public DrawBuffer(D3DDevice device) { mDevice = device; AllocateVerts(); }