PDA

View Full Version : OpenGL Box for Lazarus



WILL
14-04-2007, 04:21 PM
Kostas "Bad Sector" Michalopoulos has made a rather neat 'control' for Lazarus that creates an OpenGL drawing area in your LCL form.

It works in both Windows and with the required gtk 1.x interface it works in Linux as well. Porting to the gtk 2.x interface is underway, but requires testing.

The control falls under an MIT open source license.


Check it out over at his website: OpenGL Box for Lazarus ('http://www.slashstone.com/more/openglbox/')

JernejL
14-04-2007, 06:41 PM
nice, i'm goint to study this to see how to interact with opengl on linux.

Chebmaster
15-04-2007, 05:56 AM
, i'm goint to study this to see how to interact with opengl on linux.
Except the creating of rendering context and tying it to your window, there's absolutely no difference. Once you got past that point, all your OpenGL code is 100% portable. Except, maybe, that the pbuffer extensions are different for Windows and Linux. For example, my system has GLX_SGIX_pbuffer,
GLX_SGI_swap_control, etc.
I also noticed that the Windows programs running in wine report the absence of pbuffer extensions.

JernejL
15-04-2007, 09:29 AM
i realise, but what i meant is which libraries handle what in linux and how it works under linux.

Chebmaster
15-04-2007, 02:10 PM
Hmm... I created my Win/Lin window manager through pain and sweat, plunging through a lot of unknown, reading good manuals and obscure sources... Maybe I'll be able to help someway.

Most of the functions are gathered in one dynamic library. I use libGL.so.1, it's the analog of Win's opengl32.dll.
The most important is the GLX extension (a replacement of wgl*). AFAIK, FPC should have a "glx" unit, I can't remember exactly because I use my own modification of all the OpenGL header modules.

My code for creating the window and initializing OpenGL could be seen here:
http://host-17-99.imsys.net/cge/_tmpopenglexamplecode/
Of some interest to you may be the cl_winman.inc
ex.:Procedure TCLWindow.SwapBuffers;
begin
{$ifdef unix}
glXSwapBuffers(Display, WindowHandle);
{$else}
wglSwapBuffers(display);
{$endif}
end;
all the *.h and *.inc are included in cl_hub.pp, which uses x , xlib, xutil, dl that are needed by the window manager.

A rough and somewhat incomplete stuff, but it should give you a insight. Because it's a live thing that works.


In short, as I understand it, the aforementioned Lazarus component was created for people to avoid this horror altogether. Probably all you need to work with opengl in linux is attach the opengl unit.

michalis
22-04-2007, 07:37 PM
What's the advantage of this control over the TOpenGLControl that's already included in Lazarus ?

Lazarus control already supports gtk1, win32, carbon (Macs). And Lazarus control has some nice features like display lists sharing. Gtk2 version of this is started but unfinished.

(Uhm, and sorry, I don't want to sound all negative about new Lazarus control; sure it's always good to have alternatives :)