protected void InitializeLine(Device d) { _Line_ = new Line(d); }
public Form1() { InitializeComponent(); this.Text = GetUniqueKey(20); //Make the window's border completely transparant SetWindowLong(this.Handle, GWL_EXSTYLE, (IntPtr)(GetWindowLong(this.Handle, GWL_EXSTYLE) ^ WS_EX_LAYERED ^ WS_EX_TRANSPARENT)); //Set the Alpha on the Whole Window to 255 (solid) SetLayeredWindowAttributes(this.Handle, 0, 255, LWA_ALPHA); //Init DirectX //This initializes the DirectX device. It needs to be done once. //The alpha channel in the backbuffer is critical. D3D.PresentParameters presentParameters = new D3D.PresentParameters(); presentParameters.Windowed = true; presentParameters.SwapEffect = D3D.SwapEffect.Discard; presentParameters.BackBufferFormat = D3D.Format.A8R8G8B8; this.device = new D3D.Device(0, D3D.DeviceType.Hardware, this.Handle, D3D.CreateFlags.HardwareVertexProcessing, presentParameters); line = new D3D.Line(this.device); font = new D3D.Font(device, new System.Drawing.Font("Tahoma", 9, FontStyle.Regular)); Thread dx = new Thread(new ThreadStart(this.dxThread)); dx.IsBackground = true; dx.Start(); }
internal void Initialize(MDX1_DisplayWindow window) { 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 = CreateWindowedPresentParameters(window, 0, 0); present.BackBufferWidth = 1; present.BackBufferHeight = 1; DeviceType dtype = DeviceType.Hardware; int adapterOrdinal = Direct3D.Manager.Adapters.Default.Adapter; Direct3D.Caps caps = Direct3D.Manager.GetDeviceCaps(adapterOrdinal, Direct3D.DeviceType.Hardware); Direct3D.CreateFlags flags = Direct3D.CreateFlags.SoftwareVertexProcessing; // Is there support for hardware vertex processing? If so, replace // software vertex processing. if (caps.DeviceCaps.SupportsHardwareTransformAndLight) { flags = Direct3D.CreateFlags.HardwareVertexProcessing; } // Does the device support a pure device? if (caps.DeviceCaps.SupportsPureDevice) { flags |= Direct3D.CreateFlags.PureDevice; } Device device = new Device (0, dtype, window.RenderTarget.TopLevelControl.Handle, flags, present); device.DeviceLost += new EventHandler(mDevice_DeviceLost); device.DeviceReset += new EventHandler(mDevice_DeviceReset); mDevice = new D3DDevice(device); // create primitive objects mLine = new Direct3D.Line(device); //CreateSurfaceVB(); }
public override void Dispose() { if (mLine != null) { mLine.Dispose(); mLine = null; } mDevice.Dispose(); }
private void OnDeviceReset() { mLine = new Line(mDevice.Device); System.Diagnostics.Debug.Print("{0} Device Reset", DateTime.Now); if (DeviceReset != null) { DeviceReset(this, EventArgs.Empty); } }
public override void OnInitialize(Microsoft.DirectX.Direct3D.Device d) { ShowMouseCursor = true; d.RenderState.Lighting = true; d.RenderState.FillMode = FillMode.Solid; d.RenderState.ZBufferEnable = true; d.RenderState.ShadeMode = ShadeMode.Phong; d.RenderState.SpecularEnable = true; d.RenderState.AntiAliasedLineEnable = true; d.RenderState.MultiSampleAntiAlias = true; d.RenderState.Ambient = Color.White; d.Lights[0].Diffuse = Color.White; d.Lights[0].Type = LightType.Directional; d.Lights[0].Falloff = 132f; d.Lights[0].InnerConeAngle = 10; d.Lights[0].OuterConeAngle = 20; d.Lights[0].Specular = Color.White; d.Lights[0].Position = new Vector3(0, 0, -100); d.Lights[0].Direction = new Vector3(0, 0, 1); d.Lights[0].Update(); d.Lights[0].Enabled = true; _Projection_ = Matrix.PerspectiveFovLH(.8f, (float)d.Viewport.Width / (float)d.Viewport.Height, 1.0f, 100.0f); _View_ = Matrix.LookAtLH(new Vector3(0, 0, -4f), new Vector3(0, 0, 0), new Vector3(0, 1, 0)); selected_material.Diffuse = Color.Yellow; selected_material.Specular = Color.White; selected_material.SpecularSharpness = 32f; teapot_material.Diffuse = Color.DodgerBlue; teapot_material.Specular = Color.White; teapot_material.SpecularSharpness = 32f; font = new Microsoft.DirectX.Direct3D.Font(d, new System.Drawing.Font("Arial", 12)); teapot = Mesh.Teapot(d); _Line_ = new Microsoft.DirectX.Direct3D.Line(d); RenderLayers.Add(new RenderableLayer(this.Layer1)); RenderLayers.Add(new RenderableLayer(this.Layer2)); /* Remember to set the appropriate State, or risk being stuck in INIT * forever. To begin rendering set the scene state to RENDER. * */ State = SceneState.RENDER; }
public AGT_Heading(Microsoft.DirectX.Direct3D.Device d) { _line_points = new Vector2[2]; _line = new Line(d); _sprites = new AGT_SpriteManager(d); using (Bitmap b = new Bitmap(Assembly.GetExecutingAssembly().GetManifestResourceStream(Endpoint))) { EndpointId = _sprites.AddResource(Endpoint, b, 0, 0, 0); _sprites.SetCenter(EndpointId, (float)(b.Width * .5f), (float)(b.Height * .5f), 0); } }
private void OnDeviceLost() { if (mLine != null) { mLine.Dispose(); mLine = null; } System.Diagnostics.Debug.Print("{0} Device Lost", DateTime.Now); if (DeviceLost != null) { DeviceLost(this, EventArgs.Empty); } }
private void Form1_Load(object sender, EventArgs e) { SetWindowLong(this.Handle, GWL_EXSTYLE, (IntPtr)(GetWindowLong(this.Handle, GWL_EXSTYLE) ^ WS_EX_LAYERED ^ WS_EX_TRANSPARENT)); //Set the Alpha on the Whole Window to 255 (solid) SetLayeredWindowAttributes(this.Handle, 0, 255, LWA_ALPHA); //Init DirectX //This initializes the DirectX device. It needs to be done once. //The alpha channel in the backbuffer is critical. PresentParameters presentParameters = new PresentParameters(); presentParameters.Windowed = true; presentParameters.SwapEffect = SwapEffect.Discard; presentParameters.BackBufferFormat = Format.A8R8G8B8; this.device = new Device(0, DeviceType.Hardware, this.Handle, CreateFlags.HardwareVertexProcessing, presentParameters); drawLine = new D3D.Line(this.device); drawBoxLine = new D3D.Line(this.device); drawCircleLine = new D3D.Line(this.device); drawFilledBoxLine = new D3D.Line(this.device); drawTriLine = new D3D.Line(this.device); CenterX = (float)this.ClientSize.Width / 2; CenterY = (float)this.ClientSize.Height / 2; CenterrX = this.ClientSize.Width / 2; CenterrY = this.ClientSize.Height / 2; font = new D3D.Font(device, new System.Drawing.Font("Fixedsys Regular", 15, FontStyle.Bold)); Thread dx = new Thread(new ThreadStart(this.dxThread)); dx.IsBackground = true; dx.Start(); }
public AGT_Label(Microsoft.DirectX.Direct3D.Device d) { _line_points = new Vector2[2]; _line = new Line(d); }
/// <summary> /// Initializes the Managed Direct3D Wrapper. /// /// This overload is designed for displaying a diferent resolution then the controls size. /// </summary> /// <param name="renderWindow">Window to render to.</param> /// <param name="screenWidth">Width of the screen in pixels.</param> /// <param name="screenHeight">Height of the screen in pixels.</param> /// <param name="vsync">Should the renderer wait for a vsync before drawing?</param> /// <returns>true if successful, false otherwise.</returns> public bool InitManagedDirect3D(System.Windows.Forms.Control renderWindow, int screenWidth, int screenHeight, bool vsync) { try { // Now setup our D3D present parameters presentParams = new PresentParameters(); presentParams.BackBufferWidth = screenWidth; presentParams.BackBufferHeight = screenHeight; //taking out the option for fullscreen mode //presentParams.BackBufferFormat = (isWindowed) ? Format.Unknown : Format.R5G6B5; presentParams.BackBufferFormat = Format.Unknown; presentParams.BackBufferCount = 1; presentParams.MultiSample = MultiSampleType.None; presentParams.MultiSampleQuality = 0; presentParams.SwapEffect = SwapEffect.Copy;// Discard; presentParams.DeviceWindow = renderWindow; //taking out the option for fullscreen mode //presentParams.Windowed = isWindowed; presentParams.Windowed = true; presentParams.EnableAutoDepthStencil = false; presentParams.FullScreenRefreshRateInHz = 0; presentParams.PresentationInterval = (vsync) ? PresentInterval.Default : PresentInterval.Immediate; // only Create if we haven't done so already if(device == null) device = new Device(0, DeviceType.Hardware, renderWindow, CreateFlags.HardwareVertexProcessing, presentParams); //Create the SwapChain lSwapChains.Add(new ManagedSwapChain(device, presentParams)); } catch (Exception) { DialogResult r = MessageBox.Show("Failed to Create D3D Device", "ManagedDirect3D::Error", MessageBoxButtons.OK, MessageBoxIcon.Exclamation); return false; } try { sprite = new Microsoft.DirectX.Direct3D.Sprite(device); } catch (Exception) { DialogResult r = MessageBox.Show("Failed to Create the Sprite object", "ManagedDirect3D::Error", MessageBoxButtons.OK, MessageBoxIcon.Exclamation); return false; } try { line = new Microsoft.DirectX.Direct3D.Line(device); line.Antialias = true; line.Width = 3.0f; } catch (Exception) { DialogResult r = MessageBox.Show("Failed to Create the Line Object", "ManagedDirect3D::Error", MessageBoxButtons.OK, MessageBoxIcon.Exclamation); return false; } try { fontDescription.FaceName = "arial"; fontDescription.Quality = FontQuality.Default; fontDescription.Weight = FontWeight.Bold; font = new Microsoft.DirectX.Direct3D.Font(device, fontDescription); line.Antialias = true; line.Width = 3.0f; } catch (Exception) { DialogResult r = MessageBox.Show("Failed to Create the font Object", "ManagedDirect3D::Error", MessageBoxButtons.OK, MessageBoxIcon.Exclamation); return false; } return true; }
public AGT_WaypointList(Microsoft.DirectX.Direct3D.Device d) { _line = new Line(d); _line_points = new Vector2[2]; }
/// <summary> /// Initializes the Managed Direct3D Wrapper. /// </summary> /// <param name="renderWindow">Window to render to.</param> /// <param name="screenWidth">Width of the screen in pixels.</param> /// <param name="screenHeight">Height of the screen in pixels.</param> /// <param name="isWindowed">Is the application windowed or not (!!ALWAYS PASS true FOR NOW!!).</param> /// <param name="vsync">Should the renderer wait for a vsync before drawing?</param> /// <returns>true if successful, false otherwise.</returns> public bool InitManagedDirect3D(System.Windows.Forms.Control renderWindow, int screenWidth, int screenHeight, bool isWindowed, bool vsync) { try { // Now setup our D3D present parameters presentParams = new PresentParameters(); presentParams.BackBufferWidth = screenWidth; presentParams.BackBufferHeight = screenHeight; presentParams.BackBufferFormat = (isWindowed) ? Format.Unknown : Format.R5G6B5; presentParams.BackBufferCount = 1; presentParams.MultiSample = MultiSampleType.None; presentParams.MultiSampleQuality = 0; presentParams.SwapEffect = SwapEffect.Copy;// Discard; presentParams.DeviceWindow = renderWindow; presentParams.Windowed = isWindowed; presentParams.EnableAutoDepthStencil = false; presentParams.FullScreenRefreshRateInHz = 0; presentParams.PresentationInterval = (vsync) ? PresentInterval.Default : PresentInterval.Immediate; device = new Device(0, DeviceType.Hardware, renderWindow, CreateFlags.HardwareVertexProcessing, presentParams); } catch (Exception) { DialogResult r = MessageBox.Show("Failed to Create D3D Device", "ManagedDirect3D::Error", MessageBoxButtons.OK, MessageBoxIcon.Exclamation); return(false); } try { sprite = new Microsoft.DirectX.Direct3D.Sprite(device); } catch (Exception) { DialogResult r = MessageBox.Show("Failed to Create the Sprite object", "ManagedDirect3D::Error", MessageBoxButtons.OK, MessageBoxIcon.Exclamation); return(false); } try { line = new Microsoft.DirectX.Direct3D.Line(device); line.Antialias = true; line.Width = 3.0f; } catch (Exception) { DialogResult r = MessageBox.Show("Failed to Create the Line Object", "ManagedDirect3D::Error", MessageBoxButtons.OK, MessageBoxIcon.Exclamation); return(false); } try { fontDescription.FaceName = "arial"; fontDescription.Quality = FontQuality.Default; fontDescription.Weight = FontWeight.Bold; font = new Microsoft.DirectX.Direct3D.Font(device, fontDescription); line.Antialias = true; line.Width = 3.0f; } catch (Exception) { DialogResult r = MessageBox.Show("Failed to Create the font Object", "ManagedDirect3D::Error", MessageBoxButtons.OK, MessageBoxIcon.Exclamation); return(false); } return(true); }
protected void Initialize(Device device) { this.device = device; _d3dLine = new Microsoft.DirectX.Direct3D.Line(this.device); this._inited = true; }