Making an SDL Viewport with LCL

576 views Asked by At

i'm using SDL in Lazarus for creating an opengl context and also for querying the input. This works quite good but now I want to make an LCL Component which should be cross platform. Before I was using SDL_CreateWindow which creates a window for me and works without LCL.

Edit: The problem is partly solved, see comment below!

Now for a first test I tried to use a TForm with SDL using SDL_CreateWindowFrom. It requires some sort of window handle as a parameter. However the following source code just results in the program exiting without any error under Linux (Lazarus 1.4.0 - FPC 2.6.4 - SDL 2.0.3).

procedure TForm1.FormClick(Sender: TObject);
var
  DC: HDC;
  H: HWND;
  WND: PSDL_Window;
begin
  SDL_Init( SDL_INIT_VIDEO );
  H:= Handle;
  DC:= GetDC( Form1.Handle );
  WND:= SDL_CreateWindowFrom( Pointer( H )); //Either of these lines ...
  WND:= SDL_CreateWindowFrom( Pointer( DC )); //causes the program to just crash 
  Caption:= SDL_GetError(); // This point is never reached
end;

The second line where I create a window was just a test because the first was not working. However this seems to be the normal way of doing it with Delphi under Windows: http://ffmpeg-delphi.googlecode.com/svn/trunk/+Player/Unit1.pas

In Lazarus the TWinControl.Handle seems to be different from Delphi's TWinControl.Handle because it needs to be cross platform. For example: http://wiki.lazarus.freepascal.org/LCL_Interface_Redesign_Idea But I don't understand how to get an SDL compatible handle for all platforms.

1

There are 1 answers

1
jmanndeveloper On

im finding this a lot w sdl,including pushing 1.13+ on people ,to drop os9 support ,which is wrong . sorry,the solution is to patch sdl,or at least the jedi headers.

the mods reference "sdl2 early days" using aa textures and gl,not used until version two . sdl is a slopheap of issues like these.

sorry i have been away from lazgfx for so long. the rv had priority ,then bandwidth to stabilize linux- low speed inet really takes a toll,running ubuntu.

I have a complete alternative to this- because I can get a gl context window in Lazarus, I'm having the backwards problem . I believe another developer helped me solve it. "2d window" handles -via x11 accellerated rendering and trying to get lcl,sdl to handshake with them.

I think it's five of us working on the same problem and we all need to coordinate. I'm on code Forge not GitHub.