afaik there is no easy solution to the problem. see also
here. Basically, if you get things working then you have to 'fix' the double event loop and things get ugly pretty fast.
edit: But, to answer your question:
unit Unit1;
{$mode objfpc}{$H+}
interface
uses
Classes, SysUtils, FileUtil, Forms, Controls, Graphics, Dialogs, ExtCtrls,
StdCtrls;
type
{ TForm1 }
TForm1 = class(TForm)
Button1: TButton;
Memo1: TMemo;
Panel1: TPanel;
procedure Button1Click(Sender: TObject);
procedure FormCreate(Sender: TObject);
procedure FormDestroy(Sender: TObject);
private
{ private declarations }
public
{ public declarations }
procedure WriteM(S: String);
end;
var
Form1: TForm1;
implementation
{$R *.lfm}
uses
SDL;
var
SDLScreen: PSDL_Surface;
{ TForm1 }
procedure TForm1.FormCreate(Sender: TObject);
begin
SDL_putenv(PChar('SDL_WINDOWID=' + IntToStr(Panel1.handle)));
end;
procedure TForm1.Button1Click(Sender: TObject);
var
ARect: TSDL_Rect;
begin
if (SDL_Init(SDL_INIT_VIDEO) = 0) then
begin
WriteM('SDL_Init succeeded');
SDLScreen := SDL_SetVideoMode(Panel1.WIdth, Panel1.Height, 32, SDL_SWSURFACE or SDL_DOUBLEBUF);
if assigned(SDLScreen) then
begin
WriteM('SDL_SetVideoMode returned a valid SDL surface');
ARect.h := 50;
ARect.w := 50;
ARect.x := 50;
ARect.h := 50;
SDL_FillRect(SDLScreen, @ARect, SDL_MapRGB(SDLScreen^.format, 0, 255, 0));
SDL_FLIP(SDLScreen);
end
else WriteM('Unable to Create SDL screen');
end
else WriteM('Unable to Initialize SDL');
end;
procedure TForm1.FormDestroy(Sender: TObject);
begin
SDL_QUIT;
end;
procedure TForm1.WriteM(S: String);
begin
memo1.Append(S);
end;
end.
Try and see if that works for you.