# HG changeset patch # User unc0rr # Date 1244735871 0 # Node ID e41fdfaa8edd6941b9e2a6ab4c6285c16aec807d # Parent a2811690da1b4c57305a622c82cdce74f4f43fa4 Patch by Smaxx: - Check texture size against GL_MAX_TEXTURE_SIZE diff -r a2811690da1b -r e41fdfaa8edd hedgewars/uConsts.pas --- a/hedgewars/uConsts.pas Thu Jun 11 15:22:02 2009 +0000 +++ b/hedgewars/uConsts.pas Thu Jun 11 15:57:51 2009 +0000 @@ -153,6 +153,7 @@ msgLoading = 'Loading '; msgOK = 'ok'; msgFailed = 'failed'; + msgFailedSize = 'failed due to size'; msgGettingConfig = 'Getting game config...'; const diff -r a2811690da1b -r e41fdfaa8edd hedgewars/uStore.pas --- a/hedgewars/uStore.pas Thu Jun 11 15:22:02 2009 +0000 +++ b/hedgewars/uStore.pas Thu Jun 11 15:57:51 2009 +0000 @@ -66,6 +66,7 @@ var HHTexture: PTexture; + MaxTextureSize: Integer; procedure StoreInit; begin @@ -886,18 +887,25 @@ end; if tmpsurf = nil then - if critical then OutError(msgFailed, true) - else begin - WriteLnToConsole(msgFailed); - exit(nil) - end; + begin + OutError(msgFailed, critical); + exit(nil) + end; + +if (tmpsurf^.w > MaxTextureSize) or (tmpsurf^.h > MaxTextureSize) then + begin + SDL_FreeSurface(tmpsurf); + OutError(msgFailedSize, critical); + exit(SDL_CreateRGBSurface(SDL_SWSURFACE, 32, 32, 32, RMask, GMask, BMask, AMask)) + end; if setTransparent then TryDo(SDL_SetColorKey(tmpsurf, SDL_SRCCOLORKEY, 0) = 0, errmsgTransparentSet, true); //if hasAlpha then Result:= SDL_DisplayFormatAlpha(tmpsurf) // else Result:= SDL_DisplayFormat(tmpsurf); -{$IFDEF DEBUGFILE}WriteLnToConsole('(' + inttostr(tmpsurf^.w) + ',' + inttostr(tmpsurf^.h) + ') ');{$ENDIF} +WriteLnToConsole('(' + inttostr(tmpsurf^.w) + ',' + inttostr(tmpsurf^.h) + ') '); WriteLnToConsole(msgOK); -LoadImage:= tmpsurf//Result + +LoadImage:= tmpsurf //Result end; procedure SetupOpenGL; @@ -907,7 +915,12 @@ glScalef(2.0 / cScreenWidth, -2.0 / cScreenHeight, 1.0); glTranslatef(-cScreenWidth / 2, -cScreenHeight / 2, 0); glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA); -glMatrixMode(GL_MODELVIEW) +glMatrixMode(GL_MODELVIEW); + +glGetIntegerv(GL_MAX_TEXTURE_SIZE, @MaxTextureSize); +{$IFDEF DEBUGFILE} +AddFileLog('GL_MAX_TEXTURE_SIZE: ' + inttostr(MaxTextureSize)); +{$ENDIF} end; ////////////////////////////////////////////////////////////////////////////////