protected override void OnPaint(PaintEventArgs e) { if (_updateCounter > 0) { return; } if (_context == null) { base.OnPaint(e); } else if (Monitor.TryEnter(_context)) { try { _context.Capture(); //Set projection if (_projectionChanged) { OnResized(); _projectionChanged = false; } //Set modelview //if (_modelviewChanged) //{ // _modelviewChanged = false; //} if (_camera != null) { fixed(Matrix *p = &_camera._matrix) { _context.glMatrixMode(GLMatrixMode.ModelView); _context.glLoadMatrix((float *)p); } } OnRender(); _context.glFinish(); _context.Swap(); _context.Release(); } finally { Monitor.Exit(_context); } } }