private void OnVisibleChanged(object sender, EventArgs e) { if (glControl.Visible) { glControl.Focus(); } }
public void OpenGL_MouseEnter(object sender, EventArgs e) { if (Form.ActiveForm == Program.frmMainInstance) { OpenGLControl.Focus(); } DrawViewLater(); }
private void Form1_Load(object sender, EventArgs e) { findResults = new List <KeyValuePair <Forge.FileEntry, EntryTreeNode> >(); // hide the progress bar toolStripProgressBar.Visible = false; // load the games' directories into the tree view LoadGamesIntoTreeView(); // set up the zoom dropdown in the Image viewer foreach (double z in zoomLevels) { ToolStripMenuItem item = new ToolStripMenuItem(); item.Text = $"{z * 100}%"; item.Click += new EventHandler(delegate(object s, EventArgs a) { ChangeZoom(z); }); zoomDropDownButton.DropDownItems.Add(item); } // create a GLControl and a GLViewer GLControl glControl = new GLControl(new GraphicsMode(32, 24, 0, 4), 3, 0, GraphicsContextFlags.ForwardCompatible); glControl.Dock = DockStyle.Fill; tabPage1.Controls.Add(glControl); gl = new GLViewer(glControl); gl.BackgroundColor = Properties.Settings.Default.threeBG; gl.Init(); // load the Utah teapot OBJMesh teapot = OBJMesh.LoadFromFile(Application.ExecutablePath + "\\..\\Shaders\\teapot.obj"); gl.Meshes.Add(teapot); Console.WriteLine(teapot.GetVertices().Length); // create a timer to constantly render the 3D Viewer Timer t = new Timer(); t.Interval = (int)(1 / 70f * 1000); // 60 FPS t.Tick += new EventHandler(delegate(object s, EventArgs a) { gl.Render(); }); t.Start(); glControl.Focus(); // load settings LoadSettings(); }
private void Fake_InitializeComponent() { glc = new GLControl(GraphicsMode.Default, 3, 3, GraphicsContextFlags.Default); func_panel = new FuncPanel(); timer = new Timer(); timer.Tick += (o, e) => glc.Invalidate(); timer.Interval = 16; timer.Start(); glc.Name = "glc"; glc.VSync = true; glc.Paint += glc_Paint; glc.MouseMove += glc_MouseMove; glc.MouseMove += (o, e) => glc.Focus(); glc.MouseUp += glc_MouseUp; glc.MouseDown += glc_MouseDown; glc.MouseWheel += glc_MouseWheel; glc.KeyDown += ModifierKeyDown; glc.KeyUp += ModifierKeyUp; glc.TabIndex = 0; func_panel.MouseMove += (o, e) => func_panel.Focus(); func_panel.ParentWindow = this; func_panel.KeyDown += ModifierKeyDown; func_panel.KeyUp += ModifierKeyUp; Text = "CubeSharp"; Name = "CubeSharp"; Size = new Size(800, 600); Font = new Font("sans", 10); this.Load += CubeSharp_Load; this.Resize += CubeSharp_Resize; Controls.Add(glc); Controls.Add(func_panel); }
private void ProcessInput() { Rectangle r = Control.RectangleToScreen(Control.ClientRectangle); if (GetForegroundWindow() == Control.ParentForm.Handle) { if (r.Contains(Cursor.Position)) { Control.Focus(); if (Keyboard.GetState().IsKeyDown(Key.W)) { Camera.Move(0, movement, 0); } if (Keyboard.GetState().IsKeyDown(Key.S)) { Camera.Move(0, -movement, 0); } if (Keyboard.GetState().IsKeyDown(Key.A)) { Camera.Move(-movement, 0, 0); } if (Keyboard.GetState().IsKeyDown(Key.D)) { Camera.Move(movement, 0, 0); } if (Keyboard.GetState().IsKeyDown(Key.Q)) { Camera.Move(0, 0, movement); } if (Keyboard.GetState().IsKeyDown(Key.E)) { Camera.Move(0, 0, -movement); } if (Keyboard.GetState().IsKeyDown(Key.R)) { ResetCamera(); } if (Keyboard.GetState().IsKeyDown(Key.Left)) { Camera.AddRotation(rotation, 0); } if (Keyboard.GetState().IsKeyDown(Key.Right)) { Camera.AddRotation(-rotation, 0); } if (Keyboard.GetState().IsKeyDown(Key.Up)) { Camera.AddRotation(0, rotation); } if (Keyboard.GetState().IsKeyDown(Key.Down)) { Camera.AddRotation(0, -rotation); } /*if (Mouse.GetState().IsButtonDown(0)) * { * Cursor.Clip = Control.ParentForm.RectangleToScreen(Control.ParentForm.ClientRectangle); * //Cursor.Position = Control.PointToScreen(new Point(Control.Width / 2, Control.Height / 2)); * //Cursor.Hide(); * Control.Capture = true; * Point p = Control.PointToScreen(Cursor.Position); * Camera.AddRotation(p.X * mouseSensitivity, p.Y * mouseSensitivity); * }*/ } /*else * { * Cursor.Clip = Rectangle.Empty; * //Cursor.Show(); * Control.Capture = false; * }*/ } }
/// <summary> /// Handler for m_control's MouseMove event. /// </summary> /// <param name="sender"></param> /// <param name="e"></param> void m_control_MouseMove(object sender, System.Windows.Forms.MouseEventArgs e) { m_control.Focus(); }