SDL_CreateWindowFrom creates do-nothing window

I went and wrote up a simple Delphi component that uses SDL_CreateWindowFrom to create a SDL rendering window you can place on a Delphi form. Only problem is, it doesn’t do anything. I’d expect the code below to produce a black rectangle. Instead, nothing gets drawn.

The CreateWnd method is an override of a virtual method that’s called when a window handle is needed. The “inherited” call creates a valid HWND handle and does a bit of housekeeping. DestroyWnd is its counterpart for when the handle needs to be cleared. All the code runs properly and the assertions all pass. After calling CreateWnd, the value of FWindowID is 1, and FFlags is 2060 (0x080C, or SDL_WINDOW_FOREIGN || SDL_WINDOW_BORDERLESS || SDL_WINDOW_SHOWN), which is just what I’d expect. But nothing shows up on my form.

{ TSdlFrame }

procedure TSdlFrame.CreateWnd;
begin
inherited;
if SDL_WasInit(SDL_INIT_VIDEO) <> SDL_INIT_VIDEO then
SDL_InitSubSystem(SDL_INIT_VIDEO);
FWindowID := SDL_CreateWindowFrom(self.Handle);
assert(SDL_SelectRenderer(FWindowID) = -1);
assert(SDL_CreateRenderer(FWindowID, 1, [sdlrAccelerated]) = 0);
SDL_ShowWindow(FWindowID);
assert(SDL_SetRenderDrawColor(0, 0, 0, 0) = 0);
assert(SDL_RenderFill(nil) = 0);
FFlags := SDL_GetWindowFlags(FWindowID);
end;

procedure TSdlFrame.DestroyWnd;
begin
SDL_DestroyWindow(FWindowID);
FWindowID := 0;
inherited;
end;

Hiyya, Sdl is c/c++ but there is an adaption with sdl remade in delphi form http://sourceforge.net/forum/forum.php?forum_id=202136 JEDI-SDL v.05
A Delphi community should be able to help with that easier than here. Dunno. Anybody?---------------------------------------------------------------

---- Mason Wheeler wrote:

=============

I went and wrote up a simple Delphi component that uses SDL_CreateWindowFrom to create a SDL rendering window you can place on a Delphi form. Only problem is, it doesn’t do anything. I’d expect the code below to produce a black rectangle. Instead, nothing gets drawn.

The CreateWnd method is an override of a virtual method that’s called when a window handle is needed. The “inherited” call creates a valid HWND handle and does a bit of housekeeping. DestroyWnd is its counterpart for when the handle needs to be cleared. All the code runs properly and the assertions all pass. After calling CreateWnd, the value of FWindowID is 1, and FFlags is 2060 (0x080C, or SDL_WINDOW_FOREIGN || SDL_WINDOW_BORDERLESS || SDL_WINDOW_SHOWN), which is just what I’d expect. But nothing shows up on my form.

{ TSdlFrame }

procedure TSdlFrame.CreateWnd;
begin
inherited;
if SDL_WasInit(SDL_INIT_VIDEO) <> SDL_INIT_VIDEO then
SDL_InitSubSystem(SDL_INIT_VIDEO);
FWindowID := SDL_CreateWindowFrom(self.Handle);
assert(SDL_SelectRenderer(FWindowID) = -1);
assert(SDL_CreateRenderer(FWindowID, 1, [sdlrAccelerated]) = 0);
SDL_ShowWindow(FWindowID);
assert(SDL_SetRenderDrawColor(0, 0, 0, 0) = 0);
assert(SDL_RenderFill(nil) = 0);
FFlags := SDL_GetWindowFlags(FWindowID);
end;

procedure TSdlFrame.DestroyWnd;
begin
SDL_DestroyWindow(FWindowID);
FWindowID := 0;
inherited;
end;


SDL mailing list
SDL at lists.libsdl.org
http://lists.libsdl.org/listinfo.cgi/sdl-libsdl.org

I’m using the JEDI_SDL headers already. But this appears to be an
error on the SDL side of things, and Sam has already expressed interest
in this control, most likely because it would generate feedback about
this bit of functionality that he wouldn’t have gotten otherwise.>----- Original Message ----

From: “necronology at cox.net
Sent: Monday, March 9, 2009 1:05:00 PM
Subject: Re: [SDL] SDL_CreateWindowFrom creates do-nothing window.

Hiyya, Sdl is c/c++ but there is an adaption with sdl remade in delphi form http://sourceforge.net/forum/forum.php?forum_id=202136 JEDI-SDL v.05
A Delphi community should be able to help with that easier than here. Dunno. Anyb

I went and wrote up a simple Delphi component that uses SDL_CreateWindowFrom to create a SDL rendering window you can place on a Delphi form. Only problem is, it doesn’t do anything. I’d expect the code below to produce a black rectangle. Instead, nothing gets drawn.

I don’t know if this will fix it, but you probably need to call SDL_RenderPresent().

See ya!
-Sam Lantinga, Founder and President, Galaxy Gameworks LLC

I went and wrote up a simple Delphi component that uses SDL_CreateWindowFrom to create a SDL rendering
window you can place on a Delphi form. Only problem is, it doesn’t do anything. I’d expect the code below to
produce a black rectangle. Instead, nothing gets drawn.

I don’t know if this will fix it, but you probably need to call SDL_RenderPresent().

facepalm Yep. That was it. It’s working now. Thanks.>----- Original Message ----

From: Sam Lantinga
Subject: Re: [SDL] SDL_CreateWindowFrom creates do-nothing window.

facepalm Yep. That was it. It’s working now. Thanks.

You’re welcome!

-Sam Lantinga, Founder and President, Galaxy Gameworks LLC