hedgewars/uStore.pas
branchexperimental3D
changeset 4347 0ddb100fea61
parent 4343 19cbea33e4d2
child 4812 f924be23ffb4
equal deleted inserted replaced
4345:2c93d6a10869 4347:0ddb100fea61
   885         SpritesData[ii].Surface:= nil;
   885         SpritesData[ii].Surface:= nil;
   886     end;
   886     end;
   887     SDL_FreeSurface(MissionIcons);
   887     SDL_FreeSurface(MissionIcons);
   888     FreeTexture(ropeIconTex);
   888     FreeTexture(ropeIconTex);
   889     FreeTexture(HHTexture);
   889     FreeTexture(HHTexture);
       
   890 {$IFNDEF S3D_DISABLED}
   890     if (cStereoMode = smHorizontal) or (cStereoMode = smVertical) or (cStereoMode = smAFR) then
   891     if (cStereoMode = smHorizontal) or (cStereoMode = smVertical) or (cStereoMode = smAFR) then
   891     begin
   892     begin
   892         glDeleteTextures(1, @texl);
   893         glDeleteTextures(1, @texl);
   893         glDeleteRenderbuffersEXT(1, @depthl);
   894         glDeleteRenderbuffersEXT(1, @depthl);
   894         glDeleteFramebuffersEXT(1, @framel);
   895         glDeleteFramebuffersEXT(1, @framel);
   895         glDeleteTextures(1, @texr);
   896         glDeleteTextures(1, @texr);
   896         glDeleteRenderbuffersEXT(1, @depthr);
   897         glDeleteRenderbuffersEXT(1, @depthr);
   897         glDeleteFramebuffersEXT(1, @framer)
   898         glDeleteFramebuffersEXT(1, @framer)
   898     end
   899     end
       
   900 {$ENDIF}
   899 end;
   901 end;
   900 
   902 
   901 
   903 
   902 function CheckCJKFont(s: ansistring; font: THWFont): THWFont;
   904 function CheckCJKFont(s: ansistring; font: THWFont): THWFont;
   903 var l, i : LongInt;
   905 var l, i : LongInt;
  1191     AddFileLog('OpenGL - "' + extension + '" skipped')
  1193     AddFileLog('OpenGL - "' + extension + '" skipped')
  1192 {$ENDIF}
  1194 {$ENDIF}
  1193 {$ELSE}
  1195 {$ELSE}
  1194     glLoadExtension:= glext_LoadExtension(extension);
  1196     glLoadExtension:= glext_LoadExtension(extension);
  1195 {$IFDEF DEBUGFILE}
  1197 {$IFDEF DEBUGFILE}
  1196     if not glLoadExtension then
  1198     if glLoadExtension then
  1197         AddFileLog('OpenGL - "' + extension + '" failed to load')
  1199         AddFileLog('OpenGL - "' + extension + '" loaded')
  1198     else
  1200     else
  1199         AddFileLog('OpenGL - "' + extension + '" loaded');
  1201         AddFileLog('OpenGL - "' + extension + '" failed to load');
  1200 {$ENDIF}
  1202 {$ENDIF}
  1201 {$ENDIF}
  1203 {$ENDIF}
  1202 end;
  1204 end;
  1203 
  1205 
  1204 procedure SetupOpenGL;
  1206 procedure SetupOpenGL;
  1261         cGPUVendor:= gvNVIDIA
  1263         cGPUVendor:= gvNVIDIA
  1262     else if StrPos(Str2PChar(vendor), Str2PChar('intel')) <> nil then
  1264     else if StrPos(Str2PChar(vendor), Str2PChar('intel')) <> nil then
  1263         cGPUVendor:= gvATI
  1265         cGPUVendor:= gvATI
  1264     else if StrPos(Str2PChar(vendor), Str2PChar('ati')) <> nil then
  1266     else if StrPos(Str2PChar(vendor), Str2PChar('ati')) <> nil then
  1265         cGPUVendor:= gvIntel;
  1267         cGPUVendor:= gvIntel;
       
  1268 {$ENDIF}
  1266 //SupportNPOTT:= glLoadExtension('GL_ARB_texture_non_power_of_two');
  1269 //SupportNPOTT:= glLoadExtension('GL_ARB_texture_non_power_of_two');
  1267 
  1270 {$IFNDEF S3D_DISABLED}
  1268     if (cStereoMode = smHorizontal) or (cStereoMode = smVertical) or (cStereoMode = smAFR) then
  1271     if (cStereoMode = smHorizontal) or (cStereoMode = smVertical) or (cStereoMode = smAFR) then
  1269     begin
  1272     begin
  1270         // prepare left and right frame buffers and associated textures
  1273         // prepare left and right frame buffers and associated textures
  1271         glLoadExtension('GL_EXT_framebuffer_object');
  1274         if glLoadExtension('GL_EXT_framebuffer_object') then
  1272 
  1275         begin
  1273         // left
  1276             // left
  1274         glGenFramebuffersEXT(1, @framel);
  1277             glGenFramebuffersEXT(1, @framel);
  1275         glBindFramebufferEXT(GL_FRAMEBUFFER_EXT, framel);
  1278             glBindFramebufferEXT(GL_FRAMEBUFFER_EXT, framel);
  1276         glGenRenderbuffersEXT(1, @depthl);
  1279             glGenRenderbuffersEXT(1, @depthl);
  1277         glBindRenderbufferEXT(GL_RENDERBUFFER_EXT, depthl);
  1280             glBindRenderbufferEXT(GL_RENDERBUFFER_EXT, depthl);
  1278         glRenderbufferStorageEXT(GL_RENDERBUFFER_EXT, GL_DEPTH_COMPONENT, cScreenWidth, cScreenHeight);
  1281             glRenderbufferStorageEXT(GL_RENDERBUFFER_EXT, GL_DEPTH_COMPONENT, cScreenWidth, cScreenHeight);
  1279         glFramebufferRenderbufferEXT(GL_FRAMEBUFFER_EXT, GL_DEPTH_ATTACHMENT_EXT, GL_RENDERBUFFER_EXT, depthl);
  1282             glFramebufferRenderbufferEXT(GL_FRAMEBUFFER_EXT, GL_DEPTH_ATTACHMENT_EXT, GL_RENDERBUFFER_EXT, depthl);
  1280         glGenTextures(1, @texl);
  1283             glGenTextures(1, @texl);
  1281         glBindTexture(GL_TEXTURE_2D, texl);
  1284             glBindTexture(GL_TEXTURE_2D, texl);
  1282         glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA8,  cScreenWidth, cScreenHeight, 0, GL_RGBA, GL_UNSIGNED_BYTE, nil);
  1285             glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA8,  cScreenWidth, cScreenHeight, 0, GL_RGBA, GL_UNSIGNED_BYTE, nil);
  1283         glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
  1286             glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
  1284         glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR);
  1287             glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR);
  1285         glFramebufferTexture2DEXT(GL_FRAMEBUFFER_EXT, GL_COLOR_ATTACHMENT0_EXT, GL_TEXTURE_2D, texl, 0);
  1288             glFramebufferTexture2DEXT(GL_FRAMEBUFFER_EXT, GL_COLOR_ATTACHMENT0_EXT, GL_TEXTURE_2D, texl, 0);
  1286 
  1289 
  1287         // right
  1290             // right
  1288         glGenFramebuffersEXT(1, @framer);
  1291             glGenFramebuffersEXT(1, @framer);
  1289         glBindFramebufferEXT(GL_FRAMEBUFFER_EXT, framer);
  1292             glBindFramebufferEXT(GL_FRAMEBUFFER_EXT, framer);
  1290         glGenRenderbuffersEXT(1, @depthr);
  1293             glGenRenderbuffersEXT(1, @depthr);
  1291         glBindRenderbufferEXT(GL_RENDERBUFFER_EXT, depthr);
  1294             glBindRenderbufferEXT(GL_RENDERBUFFER_EXT, depthr);
  1292         glRenderbufferStorageEXT(GL_RENDERBUFFER_EXT, GL_DEPTH_COMPONENT, cScreenWidth, cScreenHeight);
  1295             glRenderbufferStorageEXT(GL_RENDERBUFFER_EXT, GL_DEPTH_COMPONENT, cScreenWidth, cScreenHeight);
  1293         glFramebufferRenderbufferEXT(GL_FRAMEBUFFER_EXT, GL_DEPTH_ATTACHMENT_EXT, GL_RENDERBUFFER_EXT, depthr);
  1296             glFramebufferRenderbufferEXT(GL_FRAMEBUFFER_EXT, GL_DEPTH_ATTACHMENT_EXT, GL_RENDERBUFFER_EXT, depthr);
  1294         glGenTextures(1, @texr);
  1297             glGenTextures(1, @texr);
  1295         glBindTexture(GL_TEXTURE_2D, texr);
  1298             glBindTexture(GL_TEXTURE_2D, texr);
  1296         glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA8,  cScreenWidth, cScreenHeight, 0, GL_RGBA, GL_UNSIGNED_BYTE, nil);
  1299             glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA8,  cScreenWidth, cScreenHeight, 0, GL_RGBA, GL_UNSIGNED_BYTE, nil);
  1297         glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
  1300             glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
  1298         glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR);
  1301             glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR);
  1299         glFramebufferTexture2DEXT(GL_FRAMEBUFFER_EXT, GL_COLOR_ATTACHMENT0_EXT, GL_TEXTURE_2D, texr, 0);
  1302             glFramebufferTexture2DEXT(GL_FRAMEBUFFER_EXT, GL_COLOR_ATTACHMENT0_EXT, GL_TEXTURE_2D, texr, 0);
  1300 
  1303 
  1301         // reset
  1304             // reset
  1302         glBindFramebufferEXT(GL_FRAMEBUFFER_EXT, 0)
  1305             glBindFramebufferEXT(GL_FRAMEBUFFER_EXT, 0)
       
  1306         end
       
  1307         else
       
  1308             cStereoMode:= smNone;
  1303     end;
  1309     end;
  1304 {$ENDIF}
  1310 {$ENDIF}
  1305 
  1311 
  1306 {$IFDEF DEBUGFILE}
  1312 {$IFDEF DEBUGFILE}
  1307     if cGPUVendor = gvUnknown then
  1313     if cGPUVendor = gvUnknown then