Tue, 24 Nov 2009 04:59:50 +0000Fixed bug #891
Sam Lantinga [Tue, 24 Nov 2009 04:59:50 +0000] rev 3486
Fixed bug #891

Mason Wheeler 2009-11-23 06:59:48 PST

There's code in SDL_RecreateWindow specifically to handle SDL_WINDOW_FOREIGN,
but it appears to have been overlooked in the allowed_flags constant. This
causes the line

window->flags = (flags & allowed_flags);

to strip SDL_WINDOW_FOREIGN from the window's flags, which breaks some code in
WIN_WindowProc in SDL_win32Events.c that treats foreign windows differently.
This can be trivially fixed by defining allowed_flags as

const Uint32 allowed_flags = (SDL_WINDOW_FULLSCREEN |
SDL_WINDOW_OPENGL |
SDL_WINDOW_BORDERLESS |
SDL_WINDOW_RESIZABLE |
SDL_WINDOW_INPUT_GRABBED |
SDL_WINDOW_FOREIGN);

Tue, 24 Nov 2009 04:48:12 +0000Mason Wheeler to sdl
Sam Lantinga [Tue, 24 Nov 2009 04:48:12 +0000] rev 3485
Mason Wheeler to sdl

I updated SDL, and suddenly my SDL frames stopped working. They'd "initialize" full of gibberish, and I couldn't render anything to them. After a bit of digging, I found a problem: the renderer initialization routine in my SDL frame code wasn't getting called anymore.

procedure TSdlFrame.Paint;
begin
if SDL_SelectRenderer(FWindowID) = -1 then
CreateRenderer;
SDL_RenderPresent;
end;

function TSdlFrame.CreateRenderer: boolean;
const
pf: tagPIXELFORMATDESCRIPTOR = (nSize: sizeof(pf); nVersion: 1;
dwFlags: PFD_DRAW_TO_WINDOW or PFD_SUPPORT_OPENGL or PFD_DOUBLEBUFFER;
iPixelType: PFD_TYPE_RGBA; cColorBits: 24; cAlphaBits: 8;
iLayerType: PFD_MAIN_PLANE);

RENDERERS: array[TRendererType] of AnsiString = ('software', 'gdi', 'opengl', 'd3d');
var
pFormat: integer;
begin
if (SDL_SelectRenderer(FWindowID) = 0) then
begin
result := true;
Exit;
end;
if FRendererType = rtOpenGL then
begin
pFormat := ChoosePixelFormat(canvas.Handle, @pf);
if not SetPixelFormat(canvas.Handle, pFormat, @pf) then
outputDebugString(PChar(SysErrorMessage(GetLastError)));
if wglCreateContext(canvas.Handle) = 0 then
outputDebugString(PChar(SysErrorMessage(GetLastError)));
end;
if (SDL_CreateRenderer(FWindowID, SDL_RendererIndex(RENDERERS[FRendererType]), [sdlrPresentFlip3, sdlrAccelerated]) = 0) then
begin
SDL_ShowWindow(FWindowID);
assert(SDL_SetRenderDrawColor(0, 0, 0, 255) = 0);
FFlags := SDL_GetWindowFlags(FWindowID);
if assigned(FOnAvailable) then
FOnAvailable(self);
end
else outputDebugString(pChar(format('SDL_CreateRenderer failed: %s', [sdl_GetError])));
result := SDL_SelectRenderer(FWindowID) = 0;
end;

This is a critical issue. The Paint method gets called when the control receives a WM_PAINT message from Windows. I can't create the renderer before then, or it will fail and cause trouble. And when I do create it, it needs to be created with certain parameters. So imagine my surprise when I started debugging into the DLL and found that SDL_SelectRenderer was trying to be "helpful" by creating the renderer for me if it didn't already exist! Now not only does my initialization code not get called, I end up with the wrong renderer and so things don't render as expected when I try to use the window.

Sun, 22 Nov 2009 20:53:53 +0000Set the error so someone can get more information
Sam Lantinga [Sun, 22 Nov 2009 20:53:53 +0000] rev 3484
Set the error so someone can get more information

Sun, 22 Nov 2009 20:00:00 +0000Made the comment actually mean something. :)
Sam Lantinga [Sun, 22 Nov 2009 20:00:00 +0000] rev 3483
Made the comment actually mean something. :)

Sun, 22 Nov 2009 07:00:26 +0000More fixes to compile under Visual C++
Sam Lantinga [Sun, 22 Nov 2009 07:00:26 +0000] rev 3482
More fixes to compile under Visual C++

Sun, 22 Nov 2009 06:42:58 +0000Fixed include paths for Visual C++
Sam Lantinga [Sun, 22 Nov 2009 06:42:58 +0000] rev 3481
Fixed include paths for Visual C++

Sun, 22 Nov 2009 06:37:43 +0000The Direct3D Read/Write pixels interface is in progress.
Sam Lantinga [Sun, 22 Nov 2009 06:37:43 +0000] rev 3480
The Direct3D Read/Write pixels interface is in progress.

Sun, 22 Nov 2009 06:34:45 +0000Whoops, actually set the SDL error, don't just print the error.
Sam Lantinga [Sun, 22 Nov 2009 06:34:45 +0000] rev 3479
Whoops, actually set the SDL error, don't just print the error.

Sat, 21 Nov 2009 08:42:42 +0000Added support for QNX default font. Backspace and Return keys now handled.
Mike Gorchak [Sat, 21 Nov 2009 08:42:42 +0000] rev 3478
Added support for QNX default font. Backspace and Return keys now handled.

Sat, 21 Nov 2009 07:59:19 +0000We want to be strict on software renderer tests and opaque tests, but give a decent margin for blending inaccuracy for the blended tests.
Sam Lantinga [Sat, 21 Nov 2009 07:59:19 +0000] rev 3477
We want to be strict on software renderer tests and opaque tests, but give a decent margin for blending inaccuracy for the blended tests.