Re: [Lazarus] opengl and compiz

2009-08-19 Thread Aleš Katona
Compiz/linux currently is very touchy depending on your card, kernel and distro 
(xorg version).

If you have say Ubuntu 9.04 with kernel .28 and the new xorg and you have intel 
or ati (pre r500, no longer officialy fglrx driver supported) cards you're 
pretty much screwed when it comes to openGL. Compiz itself works, but opengl is 
only up to 1.3 version and has bugged compozing (due to kernel mode setting not 
being in the kernel yet).

All this should change in .30 and .31 kernels and with latest drivers and xorg, 
although I wouldn't hold my breath for openGL 2.0 functionality (on the bright 
side, these changes they are making will be great for all the OSS 3d drivers).

It's one of those big OSS overhauls. So atm. if openGL is fishy and you don't 
have closed source drivers, don't fuss about it much :)

Ales

P.S: for more info, see the phoronix forums and articles

--
___
Lazarus mailing list
Lazarus@lists.lazarus.freepascal.org
http://lists.lazarus.freepascal.org/mailman/listinfo/lazarus


Re: [Lazarus] opengl and compiz

2009-08-18 Thread Andrea Mauri

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. 

Re: [Lazarus] opengl and compiz

2009-08-18 Thread Reimar Grabowski
On Tue, 18 Aug 2009 23:29:54 +0200
Andrea Mauri andrea.mauri...@gmail.com wrote:

 Dear Mattias,
 I think that is related to how lazarus manage opengl.
I cannot really confirm this. My code works fine with or without compiz. But I 
must admit that I see the same resize problems you do when I use a complex 
offscreen framebuffer structure with compiz enabled. I did not have the time to 
trace the origin of the troubles but I don't think it is related to Lazarus 
(although it is possible).
Simple framebuffer setups don't show any problems but I always use the resize 
event to correctly setup projection matrix and viewport.

 I tried another example with TOpenGLControl and I get the same behaviour.
I have just tested your code and it looks like there is a problem with the 
OnClick event of the control. Lots of clicks are 'lost' if compiz is enabled. 
But it does not seem to be a problem with the minimizing else my code should 
show the problem, too, and I can get your code the show the cube even after 
minimizing and restoring the window. If I find some time I will try to look a 
little bit deeper.

 Any ideas?
Perhaps your driver/card don't play nicely with compiz. Compiz sometimes shows 
problems with all kind of stuff (mostly task bars and window decorations). So I 
advise you to disable it while developing or using windowed OpenGL programs 
(btw fusion-icon makes this window manager switching easy).
It may be a problem with GLScene but the 'lost' OnClick events look like there 
is some trouble with Lazarus, too.

hih

Reimar

P.S.: And while we are talking about compiz issues. I have observed that my 
framerate increases if I have the mouse pointer over the OpenGLControl (which I 
think is really strange behaviour). Do you see the same effect?
-- 
A: Because it messes up the order in which people normally read text.
Q: Why is top-posting such a bad thing?
A: Top-posting.
Q: What is the most annoying thing in e-mail?

--
___
Lazarus mailing list
Lazarus@lists.lazarus.freepascal.org
http://lists.lazarus.freepascal.org/mailman/listinfo/lazarus