public AddressSpaceRenderer_OGL(AddressSpace parent, RenderManager_OGL renderManager) { Parent = parent; RenderManager = renderManager; glControl = new GLControl(); glControl.Parent = parent; glControl.Dock = DockStyle.Fill; glControl.Load += glControl_Load; glControl.Resize += glControl_Resize; glControl.MouseDown += new MouseEventHandler(Parent.AddressSpace_MouseDown); glControl.MouseUp += new MouseEventHandler(Parent.AddressSpace_MouseUp); glControl.MouseMove += new MouseEventHandler(Parent.AddressSpace_MouseMove); glControl.MouseWheel += new MouseEventHandler(Parent.AddressSpace_MouseWheel); glControl.MouseLeave += new EventHandler(Parent.AddressSpace_MouseLeave); }
public AddressSpaceScroller_OGL(History history, RenderManager_OGL renderManager, int parentWidth) : base(parentWidth) { History = history; RenderManager = renderManager; glControl = new GLControl(); glControl.Parent = this; glControl.Dock = DockStyle.Fill; glControl.Load += glControl_Load; glControl.Resize += glControl_Resize; glControl.MouseDown += new MouseEventHandler(AddressSpaceScroller_MouseDown); glControl.MouseUp += new MouseEventHandler(AddressSpaceScroller_MouseUp); glControl.MouseMove += new MouseEventHandler(AddressSpaceScroller_MouseMove); this.Controls.Add(glControl); }
void OnRender(object sender, RenderManager_OGL.RenderEventArgs e) { try { if (!GlControlLoaded) { return; } if (e.IsPreRender) { Monitor.Enter(glControl); if (glControl.Context == null) { Monitor.Exit(glControl); return; } if (!glControl.Context.IsCurrent) { glControl.MakeCurrent(); } GL.Clear(ClearBufferMask.ColorBufferBit | ClearBufferMask.DepthBufferBit); GL.MatrixMode(MatrixMode.Modelview); GL.PushMatrix(); GL.Translate(Offset.X, Offset.Y, 0); GL.Scale(Scale, Scale, Scale); } else { // TODO: These should modify the VBO instead of using immediate mode MemoryBlock selectedBlock = SelectedBlock; if (selectedBlock != null) { GL.Begin(BeginMode.Triangles); GL.Color3(Color.FromArgb(40, 40, 40)); foreach (Triangle triangle in selectedBlock.Triangles) { foreach (Vector vertex in triangle.Vertices) { GL.Vertex3(vertex.X * Width, vertex.Y, 1); } } GL.End(); } MemoryBlock hoverBlock = HoverBlock; if (hoverBlock != null) { GL.Begin(BeginMode.Triangles); GL.Color3(Color.FromArgb(40, 40, 40)); foreach (Triangle triangle in hoverBlock.Triangles) { foreach (Vector vertex in triangle.Vertices) { GL.Vertex3(vertex.X * Width, vertex.Y, 1); } } GL.End(); } GL.PopMatrix(); glControl.SwapBuffers(); glControl.Context.MakeCurrent(null); Monitor.Exit(glControl); } } catch (ObjectDisposedException) { } catch (InvalidOperationException) { } }
void OnRender(object sender, RenderManager_OGL.RenderEventArgs e) { try { if (e.IsPreRender) { Monitor.Enter(glControl); if (glControl.Context == null) { Monitor.Exit(glControl); return; } if (!glControl.Context.IsCurrent) { glControl.MakeCurrent(); } Rectangle bounds = Bounds; UInt64 maxWidth = (UInt64)ParentWidth; UInt64 maxHeight = (UInt64)bounds.Bottom; float scaleX = (float)Width / (float)maxWidth; float scaleY = (float)Height / (float)maxHeight; GL.Clear(ClearBufferMask.ColorBufferBit | ClearBufferMask.DepthBufferBit); GL.MatrixMode(MatrixMode.Modelview); GL.PushMatrix(); GL.Scale(scaleX, scaleY, 1); } else { GL.PopMatrix(); glControl.SwapBuffers(); glControl.Context.MakeCurrent(null); Monitor.Exit(glControl); } } catch (ObjectDisposedException) { } catch (InvalidOperationException) { } }