[Lazarus] How to query vertical scrollbar width?

Graeme Geldenhuys graemeg at opensoft.homeip.net
Wed Aug 19 10:37:29 CEST 2009


Dear Mattias,
I think that is related to how lazarus manage opengl. I tried another 
example with TOpenGLControl and I get the same behaviour.
I put a TOpenGLControl on a form then I just copied a piece of code 
(from the example on TOpenGLControl in Components/Examples) in order to 
draw a cube after a click on the TOpenGLControl.
When I click on the OpenGLControl1 the cube is correctly painted both 
with and without compiz.
With compiz disabled if I minimize the form and then restore it the 
OpenGLControl1 is not visible but if I click on it the OpenGLControl1 
appears again and the cube too.
With Compiz enabled if I minimize the form and then restore it the 
OpenGLControl1 is not visible neither if I click on it the 
OpenGLControl1 again. Oviously the cube is not visible.
Any ideas?
andrea

Here the code I used.

unit Unit1;

{$mode objfpc}{$H+}

interface

uses
  Classes, SysUtils, FileUtil, LResources, Forms, Controls, Graphics, 
Dialogs,
  OpenGLContext, GL, GLU;

type

  { TForm1 }

  TForm1 = class(TForm)
    OpenGLControl1: TOpenGLControl;
    procedure OpenGLControl1Click(Sender: TObject);
  private
    { private declarations }
  public
    { public declarations }
    cube_rotationx: GLFloat;
    cube_rotationy: GLFloat;
    cube_rotationz: GLFloat;

  end;

var
  Form1: TForm1;

implementation

{ TForm1 }

procedure TForm1.OpenGLControl1Click(Sender: TObject);
var
  Speed: Double;
begin
  if Sender=nil then ;

  glClearColor(1.0, 1.0, 1.0, 1.0);
  glClear(GL_COLOR_BUFFER_BIT or GL_DEPTH_BUFFER_BIT);
  glEnable(GL_DEPTH_TEST);

  glMatrixMode(GL_PROJECTION);
  glLoadIdentity();
  gluPerspective(45.0, double(width) / height, 0.1, 100.0);
  glMatrixMode(GL_MODELVIEW);
  glLoadIdentity();

  glTranslatef(0.0, 0.0,-6.0);
  glRotatef(cube_rotationx, cube_rotationy, cube_rotationz, 0.0);

  glBegin(GL_QUADS);
          glColor3f(0.0,1.0,0.0);                              // Set 
The Color To Green
          glVertex3f( 1.0, 1.0,-1.0);                  // Top Right Of 
The Quad (Top)
          glVertex3f(-1.0, 1.0,-1.0);                  // Top Left Of 
The Quad (Top)
          glVertex3f(-1.0, 1.0, 1.0);                  // Bottom Left Of 
The Quad (Top)
          glVertex3f( 1.0, 1.0, 1.0);                  // Bottom Right 
Of The Quad (Top)
  glEnd();
  glBegin(GL_QUADS);
          glColor3f(1.0,0.5,0.0);                              // Set 
The Color To Orange
          glVertex3f( 1.0,-1.0, 1.0);                  // Top Right Of 
The Quad (Bottom)
          glVertex3f(-1.0,-1.0, 1.0);                  // Top Left Of 
The Quad (Bottom)
          glVertex3f(-1.0,-1.0,-1.0);                  // Bottom Left Of 
The Quad (Bottom)
          glVertex3f( 1.0,-1.0,-1.0);                  // Bottom Right 
Of The Quad (Bottom)
  glEnd();
  glBegin(GL_QUADS);
          glColor3f(1.0,0.0,0.0);                              // Set 
The Color To Red
          glVertex3f( 1.0, 1.0, 1.0);                  // Top Right Of 
The Quad (Front)
          glVertex3f(-1.0, 1.0, 1.0);                  // Top Left Of 
The Quad (Front)
          glVertex3f(-1.0,-1.0, 1.0);                  // Bottom Left Of 
The Quad (Front)
          glVertex3f( 1.0,-1.0, 1.0);                  // Bottom Right 
Of The Quad (Front)
  glEnd();
  glBegin(GL_QUADS);
          glColor3f(1.0,1.0,0.0);                              // Set 
The Color To Yellow
          glVertex3f( 1.0,-1.0,-1.0);                  // Bottom Left Of 
The Quad (Back)
          glVertex3f(-1.0,-1.0,-1.0);                  // Bottom Right 
Of The Quad (Back)
          glVertex3f(-1.0, 1.0,-1.0);                  // Top Right Of 
The Quad (Back)
          glVertex3f( 1.0, 1.0,-1.0);                  // Top Left Of 
The Quad (Back)
  glEnd();
  glBegin(GL_QUADS);
          glColor3f(0.0,0.0,1.0);                              // Set 
The Color To Blue
          glVertex3f(-1.0, 1.0, 1.0);                  // Top Right Of 
The Quad (Left)
          glVertex3f(-1.0, 1.0,-1.0);                  // Top Left Of 
The Quad (Left)
          glVertex3f(-1.0,-1.0,-1.0);                  // Bottom Left Of 
The Quad (Left)
          glVertex3f(-1.0,-1.0, 1.0);                  // Bottom Right 
Of The Quad (Left)
  glEnd();
  glBegin(GL_QUADS);
          glColor3f(1.0,0.0,1.0);                              // Set 
The Color To Violet
          glVertex3f( 1.0, 1.0,-1.0);                  // Top Right Of 
The Quad (Right)
          glVertex3f( 1.0, 1.0, 1.0);                  // Top Left Of 
The Quad (Right)
          glVertex3f( 1.0,-1.0, 1.0);                  // Bottom Left Of 
The Quad (Right)
          glVertex3f( 1.0,-1.0,-1.0);                  // Bottom Right 
Of The Quad (Right)
  glEnd();

  Speed := double(OpenGLControl1.FrameDiffTimeInMSecs)/10;

  cube_rotationx += 5.15 * Speed;
  cube_rotationy += 5.15 * Speed;
  cube_rotationz += 20.0 * Speed;

  OpenGLControl1.SwapBuffers;
end;

initialization
  {$I unit1.lrs}

end.                                                                                        

> I doubt that this is related. The bug was too many queries.
> This seems more as if an size event is ignored.
> Have you asked the glscene developers?
>
> Mattias
>
> --
> _______________________________________________
> Lazarus mailing list
> Lazarus at lists.lazarus.freepascal.org
> http://lists.lazarus.freepascal.org/mailman/listinfo/lazarus
>
>   

-- 
Dr. Andrea Mauri, PhD
Milano Chemometrics and QSAR Research Group
Department of Environmental Sciences
University of Milano-Bicocca 
P.zza della Scienza, 1
20126 Milano - Italy

Tel: ++39 02 64482801
mailto:andrea.mauri.75 at gmail.com
http://michem.disat.unimib.it/chm/ 





More information about the Lazarus mailing list