public void Invalidate() { if (glview != null) { glview.Invalidate(); } }
private void FillOutCurrentPanel(int id, int val) { switch (id) { case 0: if (datafile.replacedRobots.Count != 0) { UpdateRobotPanel(val); } else { statusBar1.Text = "No robot elements in HXM"; } break; case 1: if (datafile.replacedModels.Count != 0) { UpdateModelPanel(val); glControl1.Invalidate(); ReplacedElementComboBox.SelectedIndex = datafile.replacedModels[val].replacementID; } else { statusBar1.Text = "no model elements in HXM!"; } break; } }
public static void HandleResize(GLControl glCtrl, double viewdistance) { GL.Viewport(0, 0, glCtrl.ClientSize.Width, glCtrl.ClientSize.Height); GL.MatrixMode(MatrixMode.Projection); GL.LoadIdentity(); Glu.Perspective(45, (double)glCtrl.Width / glCtrl.Height, 0.5, viewdistance); glCtrl.Invalidate(); GL.MatrixMode(MatrixMode.Modelview); }
internal static void Resize(ref ModernGLControl glControl1) { viewport_changed = true; renderView = glControl1; viewportWidth = renderView.Width; viewportHeight = renderView.Height; renderView.Invalidate(); }
public void Initialize(Language language) { // tools DodgeBurnOptions = new DodgeBurnOptions(); DarkenLightenOptions = new DarkenLightenOptions(); PencilOptions = new PencilOptions(); FloodFillOptions = new FloodFillOptions(); NoiseOptions = new NoiseOptions(); EraserOptions = new EraserOptions(); StampOptions = new StampOptions(); _tools.Add(new ToolIndex(new CameraTool(), null, "T_TOOL_CAMERA", Resources.eye__1_, Keys.C)); _tools.Add(new ToolIndex(new PencilTool(), PencilOptions, "T_TOOL_PENCIL", Resources.pen, Keys.P)); _tools.Add(new ToolIndex(new EraserTool(), EraserOptions, "T_TOOL_ERASER", Resources.erase, Keys.E)); _tools.Add(new ToolIndex(new DropperTool(), null, "T_TOOL_DROPPER", Resources.pipette, Keys.D)); _tools.Add(new ToolIndex(new DodgeBurnTool(), DodgeBurnOptions, "T_TOOL_DODGEBURN", Resources.dodge, Keys.B)); _tools.Add(new ToolIndex(new DarkenLightenTool(), DarkenLightenOptions, "T_TOOL_DARKENLIGHTEN", Resources.darkenlighten, Keys.L)); _tools.Add(new ToolIndex(new FloodFillTool(), FloodFillOptions, "T_TOOL_BUCKET", Resources.fill_bucket, Keys.F)); _tools.Add(new ToolIndex(new NoiseTool(), NoiseOptions, "T_TOOL_NOISE", Resources.noise, Keys.N)); _tools.Add(new ToolIndex(new StampTool(), StampOptions, "T_TOOL_STAMP", Resources.stamp_pattern, Keys.M)); for (int i = _tools.Count - 1; i >= 0; --i) { toolToolStripMenuItem.DropDownItems.Insert(0, _tools[i].MenuItem); _tools[i].MenuItem.Click += ToolMenuItemClicked; toolStrip1.Items.Insert(toolStrip1.Items.IndexOf(toolStripSeparator1) + 1, _tools[i].Button); _tools[i].Button.Click += ToolMenuItemClicked; languageProvider1.SetPropertyNames(_tools[i].MenuItem, "Text"); languageProvider1.SetPropertyNames(_tools[i].Button, "Text"); } // Shortcuts InitShortcuts(); LoadShortcutKeys(GlobalSettings.ShortcutKeys); _shortcutEditor.ShortcutExists += _shortcutEditor_ShortcutExists; Editor.CurrentLanguage = language; SetSelectedTool(_tools[0]); Brushes.LoadBrushes(); foreach (string x in GlobalSettings.SkinDirectories) Directory.CreateDirectory(MacroHandler.ReplaceMacros(x)); // set up the GL control var mode = new GraphicsMode(); reset: Renderer = new GLControl(new GraphicsMode(mode.ColorFormat, mode.Depth, mode.Stencil, GlobalSettings.Multisamples)); if (Renderer.Context == null) { mode = new GraphicsMode(); goto reset; } Renderer.BackColor = Color.Black; Renderer.Dock = DockStyle.Fill; Renderer.Location = new Point(0, 25); Renderer.Name = "rendererControl"; Renderer.Size = new Size(641, 580); Renderer.TabIndex = 4; splitContainer4.Panel2.Controls.Add(Renderer); Renderer.BringToFront(); GLVendor = GL.GetString(StringName.Vendor); GLVersion = GL.GetString(StringName.Version); GLRenderer = GL.GetString(StringName.Renderer); GLExtensions = GL.GetString(StringName.Extensions); InitGL(); Renderer.Paint += rendererControl_Paint; Renderer.MouseDown += rendererControl_MouseDown; Renderer.MouseMove += rendererControl_MouseMove; Renderer.MouseUp += rendererControl_MouseUp; Renderer.MouseLeave += rendererControl_MouseLeave; Renderer.Resize += rendererControl_Resize; Renderer.MouseWheel += rendererControl_MouseWheel; Renderer.MouseEnter += rendererControl_MouseEnter; #if NO if (!GlobalSettings.Loaded) MessageBox.Show(this, GetLanguageString("C_SETTINGSFAILED")); #endif _undoListBox = new UndoRedoPanel(); _undoListBox.ActionString = "L_UNDOACTIONS"; languageProvider1.SetPropertyNames(_undoListBox, "ActionString"); _undoListBox.ListBox.MouseClick += UndoListBox_MouseClick; undoToolStripButton.DropDown = new Popup(_undoListBox); undoToolStripButton.DropDownOpening += undoToolStripButton_DropDownOpening; _redoListBox = new UndoRedoPanel(); _redoListBox.ActionString = "L_REDOACTIONS"; languageProvider1.SetPropertyNames(_redoListBox, "ActionString"); _redoListBox.ListBox.MouseClick += RedoListBox_MouseClick; redoToolStripButton.DropDown = new Popup(_redoListBox); redoToolStripButton.DropDownOpening += redoToolStripButton_DropDownOpening; undoToolStripButton.DropDown.AutoClose = redoToolStripButton.DropDown.AutoClose = true; CreatePartList(); Renderer.Invalidate(); }
public void InvalidateAll() { gl3DView.Invalidate(); }
private void trackBar1_Scroll(object sender, EventArgs e) { SetupViewport(); glControl1.Invalidate(); }
/// <summary> /// Defines the control that renders the game and initializes /// all video related objects. /// </summary> /// <param name="ctrl">A reference to the GLControl renderer.</param> public static void LoadROM(ref byte[] romBuffer, ref GLControl ctrl) { _control = ctrl; IsColorGameBoy = GBCEmulator.IsColorGameBoy; _vram = new byte[8192]; _oam = new byte[160]; Buffer.BlockCopy(romBuffer, 0x8000, _vram, 0, 8192); Buffer.BlockCopy(romBuffer, 0xFE00, _oam, 0, 160); STAT = 0; ModeFlag = (byte)ModeFlags.OAM; LYC = 0; SCX = 0; SCY = 0; WX = 0; WY = 0; // Graphics initialization _pixelBuffer = new byte[160,144,3]; ctrl.MakeCurrent(); // Make it current for OpenGL GL.ClearColor(Color.White); ctrl.Invalidate(); }
public RenderTab(Mesh mesh, string filename) { tabPage = new TabPage(Path.GetFileNameWithoutExtension(filename)); tabPage.AllowDrop = true; tabPage.ToolTipText = Path.GetFullPath(filename); glControl = new GLControl(); glControl.Parent = tabPage; glControl.Dock = DockStyle.Fill; glControl.VSync = false; glControl.TabStop = false; // doesn't work at the moment... (OpenTK bug) glControl.Load += Load; glControl.Resize += Resize; glControl.Paint += Paint; inputHandler = new InputHandler(glControl); inputHandler.mouseDownListeners.Add(MouseButtons.Left, (x, y) => mouseLeftDown = true); inputHandler.mouseDownListeners.Add(MouseButtons.Right, (x, y) => mouseRightDown = true); inputHandler.mouseDownListeners.Add(MouseButtons.Middle, (x, y) => mouseMiddleDown = true); inputHandler.mouseUpListeners.Add(MouseButtons.Left, (x, y) => mouseLeftDown = false); inputHandler.mouseUpListeners.Add(MouseButtons.Right, (x, y) => mouseRightDown = false); inputHandler.mouseUpListeners.Add(MouseButtons.Middle, (x, y) => mouseMiddleDown = false); inputHandler.mouseMoved += (int x, int y) => { if (mouseLastX != -1 && mouseLastY != -1) { if (mouseLeftDown) { int moveX = x - mouseLastX; int moveY = y - mouseLastY; float mag = (float)Math.Sqrt(moveX * moveX + moveY * moveY) / 2f; // vector (x, y) perpendicular to another vector is (y, x) rotations.Add(new Rotation(-mag, -moveY, -moveX, 0)); glControl.Invalidate(); } } mouseLastX = x; mouseLastY = y; }; inputHandler.mouseWheelMoved += (int delta) => { scale += delta / SystemInformation.MouseWheelScrollDelta * 0.1f; // keep scale between 0.1 - 10 scale = Math.Min(10f, Math.Max(0.1f, scale)); glControl.Invalidate(); }; this.mesh = mesh; rotations = new List<Rotation>(); }