Mercurial > sdl-ios-xcode
view Xcode-iPhoneOS/Template/SDL Application/___PROJECTNAME___.xcodeproj/hfutrell.pbxuser @ 3485:e77a69aae239
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.
author | Sam Lantinga <slouken@libsdl.org> |
---|---|
date | Tue, 24 Nov 2009 04:48:12 +0000 |
parents | 20326ba2bda2 |
children |
line wrap: on
line source
// !$*UTF8*$! { 1D6058900D05DD3D006BFB54 /* ___PROJECTNAME___ */ = { activeExec = 0; executables = ( FD92E3970E15A188001244C8 /* ___PROJECTNAME___ */, ); }; 29B97313FDCFA39411CA2CEA /* Project object */ = { activeBuildConfigurationName = Debug; activeExecutable = FD92E3970E15A188001244C8 /* ___PROJECTNAME___ */; activeTarget = 1D6058900D05DD3D006BFB54 /* ___PROJECTNAME___ */; addToTargets = ( 1D6058900D05DD3D006BFB54 /* ___PROJECTNAME___ */, ); codeSenseManager = FD92E3A60E15A18E001244C8 /* Code sense */; executables = ( FD92E3970E15A188001244C8 /* ___PROJECTNAME___ */, ); perUserDictionary = { PBXConfiguration.PBXFileTableDataSource3.PBXFileTableDataSource = { PBXFileTableDataSourceColumnSortingDirectionKey = "-1"; PBXFileTableDataSourceColumnSortingKey = PBXFileDataSource_Filename_ColumnID; PBXFileTableDataSourceColumnWidthsKey = ( 20, 455, 20, 48, 43, 43, 20, ); PBXFileTableDataSourceColumnsKey = ( PBXFileDataSource_FiletypeID, PBXFileDataSource_Filename_ColumnID, PBXFileDataSource_Built_ColumnID, PBXFileDataSource_ObjectSize_ColumnID, PBXFileDataSource_Errors_ColumnID, PBXFileDataSource_Warnings_ColumnID, PBXFileDataSource_Target_ColumnID, ); }; PBXConfiguration.PBXTargetDataSource.PBXTargetDataSource = { PBXFileTableDataSourceColumnSortingDirectionKey = "-1"; PBXFileTableDataSourceColumnSortingKey = PBXFileDataSource_Filename_ColumnID; PBXFileTableDataSourceColumnWidthsKey = ( 20, 415, 60, 20, 48, 43, 43, ); PBXFileTableDataSourceColumnsKey = ( PBXFileDataSource_FiletypeID, PBXFileDataSource_Filename_ColumnID, PBXTargetDataSource_PrimaryAttribute, PBXFileDataSource_Built_ColumnID, PBXFileDataSource_ObjectSize_ColumnID, PBXFileDataSource_Errors_ColumnID, PBXFileDataSource_Warnings_ColumnID, ); }; PBXPerProjectTemplateStateSaveDate = 240783190; PBXWorkspaceStateSaveDate = 240783190; }; perUserProjectItems = { FD779EEC0E26BA5E00F39101 /* PlistBookmark */ = FD779EEC0E26BA5E00F39101 /* PlistBookmark */; FD779EEE0E26BA5E00F39101 /* PlistBookmark */ = FD779EEE0E26BA5E00F39101 /* PlistBookmark */; FD77A0870E26BDCE00F39101 /* PBXBookmark */ = FD77A0870E26BDCE00F39101 /* PBXBookmark */; FD77A0880E26BDCE00F39101 /* PBXBookmark */ = FD77A0880E26BDCE00F39101 /* PBXBookmark */; FD77A08B0E26BDCE00F39101 /* PBXBookmark */ = FD77A08B0E26BDCE00F39101 /* PBXBookmark */; FD77A08C0E26BDCE00F39101 /* PBXBookmark */ = FD77A08C0E26BDCE00F39101 /* PBXBookmark */; FD77A0A00E26BE0800F39101 /* PBXTextBookmark */ = FD77A0A00E26BE0800F39101 /* PBXTextBookmark */; FDB8BFF00E5A0F6F00980157 /* PBXTextBookmark */ = FDB8BFF00E5A0F6F00980157 /* PBXTextBookmark */; }; sourceControlManager = FD92E3A50E15A18E001244C8 /* Source Control */; userBuildSettings = { }; }; FD779EEC0E26BA5E00F39101 /* PlistBookmark */ = { isa = PlistBookmark; fRef = 8D1107310486CEB800E47090 /* Info.plist */; fallbackIsa = PBXBookmark; isK = 0; kPath = ( CFBundleSignature, ); name = /Users/hfutrell/iPhoneSource/gsoc2008_iphone/XCodeiPhoneOS/SDLiPhoneOS/template/SDLApplicationTemplate/Info.plist; rLen = 0; rLoc = 2147483647; }; FD779EEE0E26BA5E00F39101 /* PlistBookmark */ = { isa = PlistBookmark; fRef = 8D1107310486CEB800E47090 /* Info.plist */; fallbackIsa = PBXBookmark; isK = 0; kPath = ( CFBundleSignature, ); name = /Users/hfutrell/iPhoneSource/gsoc2008_iphone/XCodeiPhoneOS/SDLiPhoneOS/template/SDLApplicationTemplate/Info.plist; rLen = 0; rLoc = 2147483647; }; FD77A0870E26BDCE00F39101 /* PBXBookmark */ = { isa = PBXBookmark; fRef = FD77A07C0E26BD8C00F39101 /* Icon.png */; }; FD77A0880E26BDCE00F39101 /* PBXBookmark */ = { isa = PBXBookmark; fRef = FD77A07E0E26BDA900F39101 /* Default.png */; }; FD77A08B0E26BDCE00F39101 /* PBXBookmark */ = { isa = PBXBookmark; fRef = FD77A07C0E26BD8C00F39101 /* Icon.png */; }; FD77A08C0E26BDCE00F39101 /* PBXBookmark */ = { isa = PBXBookmark; fRef = FD77A07E0E26BDA900F39101 /* Default.png */; }; FD77A09C0E26BDE500F39101 /* main.c */ = { uiCtxt = { sepNavIntBoundsRect = "{{0, 0}, {633, 1148}}"; sepNavSelRange = "{240, 0}"; sepNavVisRange = "{0, 587}"; }; }; FD77A0A00E26BE0800F39101 /* PBXTextBookmark */ = { isa = PBXTextBookmark; fRef = FD77A09C0E26BDE500F39101 /* main.c */; name = "main.c: 15"; rLen = 0; rLoc = 240; rType = 0; vrLen = 587; vrLoc = 0; }; FD92E3970E15A188001244C8 /* ___PROJECTNAME___ */ = { isa = PBXExecutable; activeArgIndices = ( ); argumentStrings = ( ); autoAttachOnCrash = 1; breakpointsEnabled = 0; configStateDict = { }; customDataFormattersEnabled = 1; debuggerPlugin = GDBDebugging; disassemblyDisplayState = 0; dylibVariantSuffix = ""; enableDebugStr = 1; environmentEntries = ( ); executableSystemSymbolLevel = 0; executableUserSymbolLevel = 0; libgmallocEnabled = 0; name = "___PROJECTNAME___"; savedGlobals = { }; sourceDirectories = ( ); }; FD92E3A50E15A18E001244C8 /* Source Control */ = { isa = PBXSourceControlManager; fallbackIsa = XCSourceControlManager; isSCMEnabled = 0; scmConfiguration = { }; }; FD92E3A60E15A18E001244C8 /* Code sense */ = { isa = PBXCodeSenseManager; indexTemplatePath = ""; }; FDB8BFF00E5A0F6F00980157 /* PBXTextBookmark */ = { isa = PBXTextBookmark; fRef = FD77A09C0E26BDE500F39101 /* main.c */; name = "main.c: 15"; rLen = 0; rLoc = 240; rType = 0; vrLen = 587; vrLoc = 0; }; }