void ISupportInitialize.EndInit() { try { int width = this.Width, height = this.Height; if (this.designMode) { //this.assist.Resize(width, height); } else { this.KeyPress += WinSoftGLCanvas_KeyPress; this.MouseDown += WinSoftGLCanvas_MouseDown; this.MouseMove += WinSoftGLCanvas_MouseMove; this.MouseUp += WinSoftGLCanvas_MouseUp; this.MouseWheel += WinSoftGLCanvas_MouseWheel; this.KeyDown += WinSoftGLCanvas_KeyDown; this.KeyUp += WinSoftGLCanvas_KeyUp; } // Create the render context. ContextGenerationParams parameters = null; if (this.designMode) { parameters = new ContextGenerationParams(); parameters.UpdateContextVersion = false; } else { parameters = this.parameters; } var renderContext = new SoftGLRenderContext(width, height, parameters); renderContext.MakeCurrent(); this.renderContext = renderContext; // Set the most basic OpenGL styles. GL.Instance.ShadeModel(GL.GL_SMOOTH); GL.Instance.ClearDepth(1.0f); GL.Instance.Enable(GL.GL_DEPTH_TEST);// depth test is disabled by default. GL.Instance.DepthFunc(GL.GL_LEQUAL); GL.Instance.Hint(GL.GL_PERSPECTIVE_CORRECTION_HINT, GL.GL_NICEST); } catch (Exception) { } }
public override IntPtr GetCurrentContext() { SoftGLRenderContext context = this.currentContext; return(context == null ? IntPtr.Zero : context.Pointer); }