hedgewars/uStore.pas
changeset 4900 8ad0e23e6d63
parent 4894 efcea232bbf6
child 4901 d1e2d82d9ccc
equal deleted inserted replaced
4899:8163c9aaad0c 4900:8ad0e23e6d63
   454 end;
   454 end;
   455 
   455 
   456 function glLoadExtension(extension : shortstring) : boolean;
   456 function glLoadExtension(extension : shortstring) : boolean;
   457 begin
   457 begin
   458 {$IF GLunit = gles11}
   458 {$IF GLunit = gles11}
   459     // FreePascal doesn't come with OpenGL ES 1.1 Extension headers
   459     // FreePascal doesnt come with OpenGL ES 1.1 Extension headers
   460     extension:= extension; // avoid hint
   460     extension:= extension; // avoid hint
   461     glLoadExtension:= false;
   461     glLoadExtension:= false;
   462 {$IFDEF DEBUGFILE}
       
   463     AddFileLog('OpenGL - "' + extension + '" skipped')
   462     AddFileLog('OpenGL - "' + extension + '" skipped')
   464 {$ENDIF}
       
   465 {$ELSE}
   463 {$ELSE}
   466     glLoadExtension:= glext_LoadExtension(extension);
   464     glLoadExtension:= glext_LoadExtension(extension);
   467 {$IFDEF DEBUGFILE}
       
   468     if glLoadExtension then
   465     if glLoadExtension then
   469         AddFileLog('OpenGL - "' + extension + '" loaded')
   466         AddFileLog('OpenGL - "' + extension + '" loaded')
   470     else
   467     else
   471         AddFileLog('OpenGL - "' + extension + '" failed to load');
   468         AddFileLog('OpenGL - "' + extension + '" failed to load');
   472 {$ENDIF}
       
   473 {$ENDIF}
   469 {$ENDIF}
   474 end;
   470 end;
   475 
   471 
   476 procedure SetupOpenGL;
   472 procedure SetupOpenGL;
   477 {$IFNDEF IPHONEOS}
   473 {$IFNDEF IPHONEOS}
   509     SDL_GL_SetAttribute(SDL_GL_BUFFER_SIZE, 16); // buffer has to be 16 bit only
   505     SDL_GL_SetAttribute(SDL_GL_BUFFER_SIZE, 16); // buffer has to be 16 bit only
   510     SDL_GL_SetAttribute(SDL_GL_ACCELERATED_VISUAL, 1); // try to prefer hardware rendering
   506     SDL_GL_SetAttribute(SDL_GL_ACCELERATED_VISUAL, 1); // try to prefer hardware rendering
   511 
   507 
   512     glGetIntegerv(GL_MAX_TEXTURE_SIZE, @MaxTextureSize);
   508     glGetIntegerv(GL_MAX_TEXTURE_SIZE, @MaxTextureSize);
   513 
   509 
   514 {$IFDEF DEBUGFILE}
       
   515     AddFileLog('OpenGL-- Renderer: ' + shortstring(pchar(glGetString(GL_RENDERER))));
   510     AddFileLog('OpenGL-- Renderer: ' + shortstring(pchar(glGetString(GL_RENDERER))));
   516     AddFileLog('  |----- Vendor: ' + shortstring(pchar(glGetString(GL_VENDOR))));
   511     AddFileLog('  |----- Vendor: ' + shortstring(pchar(glGetString(GL_VENDOR))));
   517     AddFileLog('  |----- Version: ' + shortstring(pchar(glGetString(GL_VERSION))));
   512     AddFileLog('  |----- Version: ' + shortstring(pchar(glGetString(GL_VERSION))));
   518     AddFileLog('  \----- GL_MAX_TEXTURE_SIZE: ' + inttostr(MaxTextureSize));
   513     AddFileLog('  \----- GL_MAX_TEXTURE_SIZE: ' + inttostr(MaxTextureSize));
   519 {$ENDIF}
       
   520 
   514 
   521     if MaxTextureSize <= 0 then
   515     if MaxTextureSize <= 0 then
   522     begin
   516     begin
   523         MaxTextureSize:= 1024;
   517         MaxTextureSize:= 1024;
   524 {$IFDEF DEBUGFILE}
       
   525         AddFileLog('OpenGL Warning - driver didn''t provide any valid max texture size; assuming 1024');
   518         AddFileLog('OpenGL Warning - driver didn''t provide any valid max texture size; assuming 1024');
   526 {$ENDIF}
       
   527     end;
   519     end;
   528 
   520 
   529 {$IFDEF IPHONEOS}
   521 {$IFDEF IPHONEOS}
   530     cGPUVendor:= gvApple;
   522     cGPUVendor:= gvApple;
   531 {$ELSE}
   523 {$ELSE}
   577         else
   569         else
   578             cStereoMode:= smNone;
   570             cStereoMode:= smNone;
   579     end;
   571     end;
   580 {$ENDIF}
   572 {$ENDIF}
   581 
   573 
   582 {$IFDEF DEBUGFILE}
       
   583     if cGPUVendor = gvUnknown then
   574     if cGPUVendor = gvUnknown then
   584         AddFileLog('OpenGL Warning - unknown hardware vendor; please report');
   575         AddFileLog('OpenGL Warning - unknown hardware vendor; please report');
   585 {$ELSE}
       
   586     // just avoid 'never used' compiler warning for now
       
   587     if cGPUVendor = gvUnknown then cGPUVendor:= gvUnknown;
       
   588 {$ENDIF}
       
   589 
   576 
   590     // set view port to whole window
   577     // set view port to whole window
   591     if (rotationQt = 0) or (rotationQt = 180) then
   578     if (rotationQt = 0) or (rotationQt = 180) then
   592         glViewport(0, 0, cScreenWidth, cScreenHeight)
   579         glViewport(0, 0, cScreenWidth, cScreenHeight)
   593     else
   580     else
   854 end;
   841 end;
   855 
   842 
   856 procedure chFullScr(var s: shortstring);
   843 procedure chFullScr(var s: shortstring);
   857 var flags: Longword = 0;
   844 var flags: Longword = 0;
   858     ico: PSDL_Surface;
   845     ico: PSDL_Surface;
   859 {$IFDEF DEBUGFILE}
       
   860     buf: array[byte] of char;
   846     buf: array[byte] of char;
   861 {$ENDIF}
       
   862 begin
   847 begin
   863     s:= s; // avoid compiler hint
   848     s:= s; // avoid compiler hint
   864     if Length(s) = 0 then cFullScreen:= not cFullScreen
   849     if Length(s) = 0 then cFullScreen:= not cFullScreen
   865     else cFullScreen:= s = '1';
   850     else cFullScreen:= s = '1';
   866 
   851 
   867 {$IFDEF DEBUGFILE}
       
   868     buf[0]:= char(0); // avoid compiler hint
   852     buf[0]:= char(0); // avoid compiler hint
   869     AddFileLog('Prepare to change video parameters...');
   853     AddFileLog('Prepare to change video parameters...');
   870 {$ENDIF}
       
   871 
   854 
   872     flags:= SDL_OPENGL;// or SDL_RESIZABLE;
   855     flags:= SDL_OPENGL;// or SDL_RESIZABLE;
   873 
   856 
   874     if cFullScreen then
   857     if cFullScreen then
   875         flags:= flags or SDL_FULLSCREEN;
   858         flags:= flags or SDL_FULLSCREEN;
   894     // set window caption
   877     // set window caption
   895     SDL_WM_SetCaption('Hedgewars', nil);
   878     SDL_WM_SetCaption('Hedgewars', nil);
   896 
   879 
   897     if SDLPrimSurface <> nil then
   880     if SDLPrimSurface <> nil then
   898     begin
   881     begin
   899 {$IFDEF DEBUGFILE}
       
   900         AddFileLog('Freeing old primary surface...');
   882         AddFileLog('Freeing old primary surface...');
   901 {$ENDIF}
       
   902         SDL_FreeSurface(SDLPrimSurface);
   883         SDL_FreeSurface(SDLPrimSurface);
   903         SDLPrimSurface:= nil;
   884         SDLPrimSurface:= nil;
   904     end;
   885     end;
   905 
   886 
   906 {$IFDEF SDL13}
   887 {$IFDEF SDL13}
   919     SDLPrimSurface:= SDL_SetVideoMode(cScreenWidth, cScreenHeight, cBits, flags);
   900     SDLPrimSurface:= SDL_SetVideoMode(cScreenWidth, cScreenHeight, cBits, flags);
   920     SDLTry(SDLPrimSurface <> nil, true);
   901     SDLTry(SDLPrimSurface <> nil, true);
   921     PixelFormat:= SDLPrimSurface^.format;
   902     PixelFormat:= SDLPrimSurface^.format;
   922 {$ENDIF}
   903 {$ENDIF}
   923 
   904 
   924 {$IFDEF DEBUGFILE}
   905     AddFileLog('Setting up OpenGL (using driver: ' + shortstring(SDL_VideoDriverName(buf, sizeof(buf))) + ')');
   925     AddFileLog('Setting up OpenGL...');
       
   926     AddFileLog('SDL video driver: ' + shortstring(SDL_VideoDriverName(buf, sizeof(buf))));
       
   927 {$ENDIF}
       
   928     SetupOpenGL();
   906     SetupOpenGL();
   929 end;
   907 end;
   930 
   908 
   931 procedure initModule;
   909 procedure initModule;
   932 begin
   910 begin