public Direct3D9Api(Game game) { MinZNear = 0.05f; IntPtr windowHandle = ((WinWindowInfo)game.window.WindowInfo).WindowHandle; d3d = new Direct3D(); int adapter = d3d.Adapters[0].Adapter; InitFields(); FindCompatibleFormat(adapter); PresentParameters args = GetPresentArgs(640, 480); try { device = d3d.CreateDevice(adapter, DeviceType.Hardware, windowHandle, createFlags, args); } catch (SharpDXException) { createFlags = CreateFlags.MixedVertexProcessing; try { device = d3d.CreateDevice(adapter, DeviceType.Hardware, windowHandle, createFlags, args); } catch (SharpDXException) { createFlags = CreateFlags.SoftwareVertexProcessing; device = d3d.CreateDevice(adapter, DeviceType.Hardware, windowHandle, createFlags, args); } } caps = device.Capabilities; viewStack = new MatrixStack(32, device, TransformState.View); projStack = new MatrixStack(4, device, TransformState.Projection); texStack = new MatrixStack(4, device, TransformState.Texture0); SetDefaultRenderStates(); InitDynamicBuffers(); }
public Direct3D9Api(Game game) { MinZNear = 0.05f; IntPtr windowHandle = game.window.WindowInfo.WinHandle; d3d = new Direct3D(); int adapter = d3d.Adapters[0].Adapter; InitFields(); FindCompatibleFormat(adapter); PresentParameters args = GetPresentArgs(640, 480); try { device = d3d.CreateDevice(adapter, DeviceType.Hardware, windowHandle, createFlags, args); } catch (SharpDXException) { createFlags = CreateFlags.MixedVertexProcessing; try { device = d3d.CreateDevice(adapter, DeviceType.Hardware, windowHandle, createFlags, args); } catch (SharpDXException) { createFlags = CreateFlags.SoftwareVertexProcessing; device = d3d.CreateDevice(adapter, DeviceType.Hardware, windowHandle, createFlags, args); } } CustomMipmapsLevels = true; caps = device.Capabilities; SetDefaultRenderStates(); InitDynamicBuffers(); }
public Direct3D9Api(INativeWindow window) { MinZNear = 0.05f; IntPtr winHandle = window.WinHandle; d3d = Direct3D.Direct3DCreate9(Direct3D.SdkVersion); const int adapter = 0; // default adapter InitFields(); FindCompatibleFormat(adapter); PresentParameters args = GetPresentArgs(640, 480); try { device = Direct3D.CreateDevice(d3d, adapter, DeviceType.Hardware, winHandle, createFlags, &args); } catch (SharpDXException) { createFlags = CreateFlags.Mixed; try { device = Direct3D.CreateDevice(d3d, adapter, DeviceType.Hardware, winHandle, createFlags, &args); } catch (SharpDXException) { createFlags = CreateFlags.Software; device = Direct3D.CreateDevice(d3d, adapter, DeviceType.Hardware, winHandle, createFlags, &args); } } Capabilities caps; Device.GetCapabilities(device, &caps); MaxTexWidth = caps.MaxTextureWidth; MaxTexHeight = caps.MaxTextureHeight; CustomMipmapsLevels = true; SetDefaultRenderStates(); InitCommon(); }