hedgewars/uStore.pas
changeset 3691 34fe2149f75d
parent 3689 e2be39ee19f0
parent 3688 fd8c22a358de
child 3695 c11abf387a7d
equal deleted inserted replaced
3689:e2be39ee19f0 3691:34fe2149f75d
    37     MissionIcons: PSDL_Surface;
    37     MissionIcons: PSDL_Surface;
    38     ropeIconTex: PTexture;
    38     ropeIconTex: PTexture;
    39     rotationQt: GLfloat;
    39     rotationQt: GLfloat;
    40     wScreen: LongInt;
    40     wScreen: LongInt;
    41     hScreen: LongInt;
    41     hScreen: LongInt;
    42     
    42     framel, framer, depthl, depthr: GLuint;
       
    43     texl, texr: GLuint;
       
    44 
    43 procedure initModule;
    45 procedure initModule;
    44 procedure freeModule;
    46 procedure freeModule;
    45 
    47 
    46 procedure StoreLoad;
    48 procedure StoreLoad;
    47 procedure StoreRelease;
    49 procedure StoreRelease;
   800         SpritesData[ii].Surface:= nil;
   802         SpritesData[ii].Surface:= nil;
   801     end;
   803     end;
   802     SDL_FreeSurface(MissionIcons);
   804     SDL_FreeSurface(MissionIcons);
   803     FreeTexture(ropeIconTex);
   805     FreeTexture(ropeIconTex);
   804     FreeTexture(HHTexture);
   806     FreeTexture(HHTexture);
       
   807     if isStereoEnabled then
       
   808     begin
       
   809         glDeleteTextures(1, @texl);
       
   810         glDeleteRenderbuffersEXT(1, @depthl);
       
   811         glDeleteFramebuffersEXT(1, @framel);
       
   812         glDeleteTextures(1, @texr);
       
   813         glDeleteRenderbuffersEXT(1, @depthr);
       
   814         glDeleteFramebuffersEXT(1, @framer)
       
   815     end
   805 end;
   816 end;
   806 
   817 
   807 
   818 
   808 function CheckCJKFont(s: ansistring; font: THWFont): THWFont;
   819 function CheckCJKFont(s: ansistring; font: THWFont): THWFont;
   809 var l, i : LongInt;
   820 var l, i : LongInt;
  1169 {$IFDEF DEBUGFILE}
  1180 {$IFDEF DEBUGFILE}
  1170         AddFileLog('OpenGL Warning - driver didn''t provide any valid max texture size; assuming 1024');
  1181         AddFileLog('OpenGL Warning - driver didn''t provide any valid max texture size; assuming 1024');
  1171 {$ENDIF}
  1182 {$ENDIF}
  1172     end;
  1183     end;
  1173 
  1184 
  1174 {$IFNDEF IPHONEOS}
  1185 {$IFDEF IPHONEOS}
       
  1186     cGPUVendor:= gvApple;
       
  1187 {$ELSE}
  1175     if StrPos(Str2PChar(vendor), Str2PChar('nvidia')) <> nil then
  1188     if StrPos(Str2PChar(vendor), Str2PChar('nvidia')) <> nil then
  1176         cGPUVendor:= gvNVIDIA
  1189         cGPUVendor:= gvNVIDIA
  1177     else if StrPos(Str2PChar(vendor), Str2PChar('intel')) <> nil then
  1190     else if StrPos(Str2PChar(vendor), Str2PChar('intel')) <> nil then
  1178         cGPUVendor:= gvATI
  1191         cGPUVendor:= gvATI
  1179     else if StrPos(Str2PChar(vendor), Str2PChar('ati')) <> nil then
  1192     else if StrPos(Str2PChar(vendor), Str2PChar('ati')) <> nil then
  1180         cGPUVendor:= gvIntel;
  1193         cGPUVendor:= gvIntel;
  1181 //SupportNPOTT:= glLoadExtension('GL_ARB_texture_non_power_of_two');
  1194 //SupportNPOTT:= glLoadExtension('GL_ARB_texture_non_power_of_two');
  1182 {$ELSE}
  1195 
  1183     cGPUVendor:= gvApple;
  1196     if isStereoEnabled then
       
  1197     begin
       
  1198         // prepare left and right frame buffers and associated textures
       
  1199         glLoadExtension('GL_EXT_framebuffer_object');
       
  1200 
       
  1201         // left
       
  1202         glGenFramebuffersEXT(1, @framel);
       
  1203         glBindFramebufferEXT(GL_FRAMEBUFFER_EXT, framel);
       
  1204         glGenRenderbuffersEXT(1, @depthl);
       
  1205         glBindRenderbufferEXT(GL_RENDERBUFFER_EXT, depthl);
       
  1206         glRenderbufferStorageEXT(GL_RENDERBUFFER_EXT, GL_DEPTH_COMPONENT, cScreenWidth, cScreenHeight);
       
  1207         glFramebufferRenderbufferEXT(GL_FRAMEBUFFER_EXT, GL_DEPTH_ATTACHMENT_EXT, GL_RENDERBUFFER_EXT, depthl);
       
  1208         glGenTextures(1, @texl);
       
  1209         glBindTexture(GL_TEXTURE_2D, texl);
       
  1210         glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA8,  cScreenWidth, cScreenHeight, 0, GL_RGBA, GL_UNSIGNED_BYTE, nil);
       
  1211         glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
       
  1212         glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR);
       
  1213         glFramebufferTexture2DEXT(GL_FRAMEBUFFER_EXT, GL_COLOR_ATTACHMENT0_EXT, GL_TEXTURE_2D, texl, 0);
       
  1214 
       
  1215         // right
       
  1216         glGenFramebuffersEXT(1, @framer);
       
  1217         glBindFramebufferEXT(GL_FRAMEBUFFER_EXT, framer);
       
  1218         glGenRenderbuffersEXT(1, @depthr);
       
  1219         glBindRenderbufferEXT(GL_RENDERBUFFER_EXT, depthr);
       
  1220         glRenderbufferStorageEXT(GL_RENDERBUFFER_EXT, GL_DEPTH_COMPONENT, cScreenWidth, cScreenHeight);
       
  1221         glFramebufferRenderbufferEXT(GL_FRAMEBUFFER_EXT, GL_DEPTH_ATTACHMENT_EXT, GL_RENDERBUFFER_EXT, depthr);
       
  1222         glGenTextures(1, @texr);
       
  1223         glBindTexture(GL_TEXTURE_2D, texr);
       
  1224         glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA8,  cScreenWidth, cScreenHeight, 0, GL_RGBA, GL_UNSIGNED_BYTE, nil);
       
  1225         glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
       
  1226         glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR);
       
  1227         glFramebufferTexture2DEXT(GL_FRAMEBUFFER_EXT, GL_COLOR_ATTACHMENT0_EXT, GL_TEXTURE_2D, texr, 0);
       
  1228 
       
  1229         // reset
       
  1230         glBindFramebufferEXT(GL_FRAMEBUFFER_EXT, 0)
       
  1231     end;
  1184 {$ENDIF}
  1232 {$ENDIF}
  1185 
  1233 
  1186 {$IFDEF DEBUGFILE}
  1234 {$IFDEF DEBUGFILE}
  1187     if cGPUVendor = gvUnknown then
  1235     if cGPUVendor = gvUnknown then
  1188         AddFileLog('OpenGL Warning - unknown hardware vendor; please report');
  1236         AddFileLog('OpenGL Warning - unknown hardware vendor; please report');