No description
Find a file
Sam Lantinga b7844cd95f 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.

--HG--
extra : convert_revision : svn%3Ac70aab31-4412-0410-b14c-859654838e24/trunk%404226
2009-11-24 04:48:12 +00:00
acinclude A better solution to making the default build optimization -O3 2009-10-11 10:38:38 +00:00
build-scripts Update config.guess and config.sub 2009-10-08 07:08:45 +00:00
include Made the comment actually mean something. :) 2009-11-22 20:00:00 +00:00
src Mason Wheeler to sdl 2009-11-24 04:48:12 +00:00
test More fixes to compile under Visual C++ 2009-11-22 07:00:26 +00:00
VisualC Whoops, need " inside quotes 2009-10-17 23:29:52 +00:00
VisualCE Removed outdated Dreamcast support 2009-09-19 07:21:22 +00:00
Xcode Eric Wing to Sam 2009-10-06 03:33:10 +00:00
Xcode-iPhoneOS Removed the separate static simulator target, all targets create libSDLiPhoneOS.a 2009-11-02 07:57:51 +00:00
.indent.pro SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head. 2006-07-10 21:04:37 +00:00
autogen.sh gcc can't generate dependencies for a file that doesn't exist, so first create SDL_revision.h 2009-10-11 06:42:20 +00:00
Borland.html
Borland.zip
BUGS Merged r2977:2978 from branches/SDL-1.2: BUGS file cutdown. 2007-02-14 10:41:55 +00:00
configure.in Fixed bug #878 2009-11-09 04:13:51 +00:00
COPYING This library is now available under the LGPL 2.1, the major change of which 2006-01-30 14:27:56 +00:00
CREDITS Removed outdated Atari support 2009-09-20 04:15:19 +00:00
docs.html The SDL 1.3 documentation will be primarily online wiki based: 2009-10-07 14:29:59 +00:00
INSTALL
Makefile.ds Initial work on power subsystem for SDL 1.3. 2009-06-07 06:06:35 +00:00
Makefile.in The docs directory doesn't exist anymore 2009-11-11 06:23:19 +00:00
Makefile.minimal Initial work on power subsystem for SDL 1.3. 2009-06-07 06:06:35 +00:00
Makefile.pandora Patch from David Carre: 2009-07-30 14:53:57 +00:00
Makefile.wiz Scott to slouken 2009-11-17 04:53:15 +00:00
NOTES Added notes on the next steps for SDL 1.3 2007-08-16 21:43:19 +00:00
README Removed outdated Atari support 2009-09-20 04:15:19 +00:00
README-SDL.txt
README.BeOS Added a reminder on where to put libSDL.so 2006-02-18 07:21:42 +00:00
README.DirectFB DirectFB cleanups & simple window manager 2009-01-11 23:49:23 +00:00
README.iphoneos This name inconsistency has been bugging me for a while... 2009-09-19 07:32:36 +00:00
README.MacOSX Added information about gcc-fat.sh to README.MacOSX 2006-05-16 07:26:48 +00:00
README.pandora OpenPandora support added by David Carré 2009-05-31 11:53:12 +00:00
README.Porting Added the dummy audio driver to instructions 2006-07-26 03:57:45 +00:00
README.PS3 Merged Martin's code changes from Google Summer of Code 2009 2009-09-07 04:51:29 +00:00
README.QNX Removed references to CD-ROM support from the README files 2009-09-05 09:12:03 +00:00
README.RISCOS Removed references to CD-ROM support from the README files 2009-09-05 09:12:03 +00:00
README.SVN Testing Subversion commit RSS feed. 2008-07-05 18:25:28 +00:00
README.Watcom ------- Comment #5 From Marc Peter 2006-06-25 18:03 [reply] ------- 2006-06-26 01:33:53 +00:00
README.WinCE
sdl-config.in Merged r3002:3003 from branches/SDL-1.2: libdir fix in sdl-config and SDL.spec 2007-04-01 03:28:36 +00:00
sdl.m4 pkg-config replaced sdl-config in these cases. 2009-10-11 07:12:24 +00:00
sdl.pc.in Merged fix for bug #531 from SDL 1.2 revision 3511 2008-01-01 15:26:11 +00:00
SDL.spec.in Merged r3002:3003 from branches/SDL-1.2: libdir fix in sdl-config and SDL.spec 2007-04-01 03:28:36 +00:00
TODO Reminder, add multiple icon sizes! 2009-10-07 04:32:04 +00:00
UNDER_CONSTRUCTION.txt SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head. 2006-07-10 21:04:37 +00:00
VisualC.html Removed newline, to make sure revision control post-commit hook is working. 2008-12-01 09:45:01 +00:00
Watcom-Win32.zip ------- Comment #5 From Marc Peter 2006-06-25 18:03 [reply] ------- 2006-06-26 01:33:53 +00:00
WhatsNew SDL 1.2 is moving to a branch, and SDL 1.3 is becoming the head. 2006-07-10 21:04:37 +00:00

                         Simple DirectMedia Layer

                                  (SDL)

                                Version 1.2

---
http://www.libsdl.org/

This is the Simple DirectMedia Layer, a general API that provides low
level access to audio, keyboard, mouse, joystick, 3D hardware via OpenGL,
and 2D framebuffer across multiple platforms.

The current version supports Linux, Windows, Windows CE, BeOS, MacOS,
Mac OS X, FreeBSD, NetBSD, OpenBSD, BSD/OS, Solaris, IRIX, and QNX.
The code contains support for AIX, OSF/Tru64, RISC OS, and SymbianOS,
but these are not officially supported.

SDL is written in C, but works with C++ natively, and has bindings to
several other languages, including Ada, C#, Eiffel, Erlang, Euphoria,
Guile, Haskell, Java, Lisp, Lua, ML, Objective C, Pascal, Perl, PHP,
Pike, Pliant, Python, Ruby, and Smalltalk.

This library is distributed under GNU LGPL version 2, which can be
found in the file  "COPYING".  This license allows you to use SDL
freely in commercial programs as long as you link with the dynamic
library.

The best way to learn how to use SDL is to check out the header files in
the "include" subdirectory and the programs in the "test" subdirectory.
The header files and test programs are well commented and always up to date.
More documentation is available in HTML format in "docs/index.html", and
a documentation wiki is available online at:
	http://www.libsdl.org/cgi/docwiki.cgi

The test programs in the "test" subdirectory are in the public domain.

Frequently asked questions are answered online:
	http://www.libsdl.org/faq.php

If you need help with the library, or just want to discuss SDL related
issues, you can join the developers mailing list:
	http://www.libsdl.org/mailing-list.php

Enjoy!
	Sam Lantinga				(slouken@libsdl.org)