OpenGLControl in ScrollBox with ScrollBar.Tracking lazarus / 70-OpenGL ---------------------------------------------------------------------- creaothceann · 2017-03-07 00:04 I'm using an OpenGLControl for displaying OpenGL graphics. The Control is in a ScrollBox whose Horz/VertScrollBar.Tracking properties are enabled. This means that the OpenGLControl moves while the scroll bar is moved, and not only when the mouse button is released. Unfortunately this creates a strange "corruption" effect. (Maybe it's related to this problem?) Setting the form, the ScrollBox and the OpenGLControl's DoubleBuffered properties doesn't help. I know I could probably simulate the ScrollBox with separate scrollbars, but maybe there is an easier way? Code: Pascal  [Select][+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i unit U_Form_Main;  interfaceuses Classes, Controls, Forms, GL, Graphics, OpenGLContext, SysUtils;  type {TForm_Main} TForm_Main = class(TForm)        procedure GUI_Form_OnCreate        (Sender : TObject);        procedure GUI_OpenGLControl_OnClick(Sender : TObject);        procedure GUI_OpenGLControl_OnPaint(Sender : TObject);        private        _OpenGLControl : TOpenGLControl;        _ScrollBox     : TScrollBox;        end;  var Form_Main : TForm_Main;  implementation  {$R *.lfm}  {TForm_Main}  procedure TForm_Main.GUI_Form_OnCreate(Sender : TObject);beginCaption := '0';DoubleBuffered := True;_ScrollBox     := TScrollBox.Create(Self);with _ScrollBox do begin        Parent       := Self;        Align          := alClient;        Color          := clAppWorkspace;        DoubleBuffered := True;end;_OpenGLControl := TOpenGLControl.Create(_ScrollBox);with _OpenGLControl do begin        AutoResizeViewport := True;        DoubleBuffered     := True;        Parent             := _ScrollBox;        Left               := 0;      Top                := 0;        Width              := Screen.Width;        Height             := Screen.Height;        MultiSampling      := 4;        OnClick            := @GUI_OpenGLControl_OnClick;      OnPaint            := @GUI_OpenGLControl_OnPaint;        Invalidate;end;end;  procedure TForm_Main.GUI_OpenGLControl_OnClick(Sender : TObject);beginwith _ScrollBox do begin        Tag := Tag XOR 1;        Self.Caption := IntToStr(Tag);        HorzScrollBar.Tracking := ByteBool(Tag);        VertScrollBar.Tracking := HorzScrollBar.Tracking;end;end;  procedure TForm_Main.GUI_OpenGLControl_OnPaint(Sender : TObject);beginglClearColor(0.27, 0.53, 0.71, 1.0);glClear(GL_COLOR_BUFFER_BIT OR GL_DEPTH_BUFFER_BIT);glLoadIdentity;glBegin(GL_TRIANGLE_STRIP);      glColor3F(0, 0, 1);  glVertex3F(-1.0,  1.0, -1.0);        glColor3F(1, 0, 0);  glVertex3F(-1.0, -1.0, -1.0);        glColor3F(0, 1, 1);  glVertex3F( 1.0,  1.0,  1.0);        glColor3F(1, 1, 0);  glVertex3F( 1.0, -1.0,  1.0);glEnd;_OpenGLControl.SwapBuffers;end;  end. (This version of the code dynamically allocates the ScrollBox and the OpenGLControl so that it's clear what settings are used.) Click on the OpenGLControl to enable the ScrollBar.Tracking.