使用LCL制作SDL视口

时间:2015-06-17 20:32:27

标签: sdl lazarus

我在Lazarus中使用SDL来创建opengl上下文以及查询输入。这非常好,但现在我想制作一个应该是跨平台的LCL组件。在我使用SDL_CreateWindow之前,它为我创建一个窗口并且在没有LCL的情况下工作。

编辑:问题已部分解决,请参阅下面的评论!

现在进行第一次测试我尝试使用SDL使用SDL_CreateWindowFrom来使用带有SDL的TForm。它需要某种窗口句柄作为参数。但是,以下源代码只会导致程序在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;

我创建窗口的第二行只是一个测试,因为第一行不起作用。 然而,这似乎是在Windows下使用Delphi执行此操作的常规方法: http://ffmpeg-delphi.googlecode.com/svn/trunk/+Player/Unit1.pas

在Lazarus中,TWinControl.Handle似乎与Delphi的TWinControl.Handle不同,因为它需要跨平台。 例如:http://wiki.lazarus.freepascal.org/LCL_Interface_Redesign_Idea 但我不明白如何为所有平台获得SDL兼容句柄。

0 个答案:

没有答案