67 SupportNPOTT: Boolean = false; |
67 SupportNPOTT: Boolean = false; |
68 |
68 |
69 implementation |
69 implementation |
70 uses uMisc, uConsole, uLand, uLocale, uWorld; |
70 uses uMisc, uConsole, uLand, uLocale, uWorld; |
71 |
71 |
|
72 type TGPUVendor = (gvUnknown, gvNVIDIA, gvATI, gvIntel); |
|
73 |
72 var |
74 var |
73 HHTexture: PTexture; |
75 HHTexture: PTexture; |
74 MaxTextureSize: Integer; |
76 MaxTextureSize: Integer; |
|
77 cGPUVendor: TGPUVendor; |
75 |
78 |
76 procedure StoreInit; |
79 procedure StoreInit; |
77 begin |
80 begin |
78 |
81 cGPUVendor:= gvUnknown; |
79 end; |
82 end; |
80 |
83 |
81 procedure DrawRoundRect(rect: PSDL_Rect; BorderColor, FillColor: Longword; Surface: PSDL_Surface; Clear: boolean); |
84 procedure DrawRoundRect(rect: PSDL_Rect; BorderColor, FillColor: Longword; Surface: PSDL_Surface; Clear: boolean); |
82 var r: TSDL_Rect; |
85 var r: TSDL_Rect; |
83 begin |
86 begin |
975 function glLoadExtension(extension : string) : boolean; |
978 function glLoadExtension(extension : string) : boolean; |
976 begin |
979 begin |
977 {$IFNDEF IPHONEOS} |
980 {$IFNDEF IPHONEOS} |
978 glLoadExtension:= glext_LoadExtension(extension); |
981 glLoadExtension:= glext_LoadExtension(extension); |
979 {$ELSE} |
982 {$ELSE} |
980 glLoadExtension:= false; |
983 glLoadExtension:= false; |
981 {$ENDIF} |
984 {$ENDIF} |
|
985 {$IFDEF DEBUGFILE} |
982 if not glLoadExtension then |
986 if not glLoadExtension then |
983 WriteLnToConsole('OpenGL: "' + extension + '" failed to load') |
987 AddFileLog('OpenGL: "' + extension + '" failed to load') |
984 else |
988 else |
985 WriteLnToConsole('OpenGL: "' + extension + '" loaded'); |
989 AddFileLog('OpenGL: "' + extension + '" loaded'); |
|
990 {$ENDIF} |
986 end; |
991 end; |
987 |
992 |
988 procedure SetupOpenGL; |
993 procedure SetupOpenGL; |
|
994 var vendor: shortstring; |
989 begin |
995 begin |
990 glGetIntegerv(GL_MAX_TEXTURE_SIZE, @MaxTextureSize); |
996 glGetIntegerv(GL_MAX_TEXTURE_SIZE, @MaxTextureSize); |
991 |
997 |
992 //workaround for wan the previous call fails |
|
993 if MaxTextureSize = 0 then MaxTextureSize:= 1024; |
|
994 |
|
995 {$IFDEF DEBUGFILE} |
998 {$IFDEF DEBUGFILE} |
996 AddFileLog('GL_MAX_TEXTURE_SIZE: ' + inttostr(MaxTextureSize)); |
999 AddFileLog('OpenGL: Renderer: ' + glGetString(GL_RENDERER)); |
|
1000 AddFileLog('OpenGL: Vendor: ' + glGetString(GL_VENDOR)); |
|
1001 AddFileLog('OpenGL: Version: ' + glGetString(GL_VERSION)); |
|
1002 AddFileLog('OpenGL: GL_MAX_TEXTURE_SIZE: ' + inttostr(MaxTextureSize)); |
997 {$ENDIF} |
1003 {$ENDIF} |
998 |
1004 |
|
1005 if MaxTextureSize = 0 then |
|
1006 begin |
|
1007 MaxTextureSize:= 1024; |
|
1008 {$IFDEF DEBUGFILE} |
|
1009 AddFileLog('OpenGL: Warning - driver didn''t provide any valid max texture size; assuming 1024'); |
|
1010 {$ENDIF} |
|
1011 end; |
|
1012 |
|
1013 vendor:= LowerCase(glGetString(GL_VENDOR)); |
|
1014 if StrPos(Str2PChar(vendor), Str2PChar('nvidia')) <> nil then |
|
1015 cGPUVendor:= gvNVIDIA |
|
1016 else if StrPos(Str2PChar(vendor), Str2PChar('intel')) <> nil then |
|
1017 cGPUVendor:= gvATI |
|
1018 else if StrPos(Str2PChar(vendor), Str2PChar('ati')) <> nil then |
|
1019 cGPUVendor:= gvIntel; |
|
1020 |
|
1021 |
|
1022 |
999 {$IFNDEF IPHONEOS} |
1023 {$IFNDEF IPHONEOS} |
1000 SupportNPOTT:= glLoadExtension('GL_ARB_texture_non_power_of_two'); |
1024 // since ATI seems to be unable to provide proper texture filtering/quality, |
|
1025 // don't even try to load the extension on ATI cards |
|
1026 if cGPUVendor <> gvATI then |
|
1027 SupportNPOTT:= glLoadExtension('GL_ARB_texture_non_power_of_two') |
|
1028 {$IFDEF DEBUGFILE} |
|
1029 else |
|
1030 AddFileLog('OpenGL: Skipped extension GL_ARB_texture_non_power_of_two due to ATI card') |
|
1031 {$ENDIF} |
|
1032 ; // don't touch this line! :) |
1001 {$ENDIF} |
1033 {$ENDIF} |
1002 |
1034 |
1003 // set view port to whole window |
1035 // set view port to whole window |
1004 glViewport(0, 0, cScreenWidth, cScreenHeight); |
1036 glViewport(0, 0, cScreenWidth, cScreenHeight); |
1005 |
1037 |