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