hedgewars/uMisc.pas
changeset 2248 26e11cb27c61
parent 2242 2e8251933b71
child 2249 ac8a762ccb4e
equal deleted inserted replaced
2247:10a5c05e09c9 2248:26e11cb27c61
   332 ResetVertexArrays(NewTexture);
   332 ResetVertexArrays(NewTexture);
   333 
   333 
   334 glGenTextures(1, @NewTexture^.id);
   334 glGenTextures(1, @NewTexture^.id);
   335 
   335 
   336 glBindTexture(GL_TEXTURE_2D, NewTexture^.id);
   336 glBindTexture(GL_TEXTURE_2D, NewTexture^.id);
   337 {$IFDEF IPHONEOS}
       
   338 glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, width, height, 0, GL_BGRA, GL_UNSIGNED_BYTE, buf);
       
   339 {$ELSE}
       
   340 glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, width, height, 0, GL_RGBA, GL_UNSIGNED_BYTE, buf);
   337 glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, width, height, 0, GL_RGBA, GL_UNSIGNED_BYTE, buf);
   341 {$ENDIF}
       
   342 
   338 
   343 //glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP);
   339 //glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP);
   344 //glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP);
   340 //glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP);
   345 glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR);
   341 glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR);
   346 glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR)
   342 glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR)
   359 Surface2Tex^.h:= surf^.h;
   355 Surface2Tex^.h:= surf^.h;
   360 
   356 
   361 if (surf^.format^.BytesPerPixel = 3) then 
   357 if (surf^.format^.BytesPerPixel = 3) then 
   362 	begin
   358 	begin
   363 		modeIntFormat:= GL_RGB;
   359 		modeIntFormat:= GL_RGB;
   364 		{$IFDEF IPHONEOS}
       
   365 		modeFormat:= GL_BGR;
       
   366 		{$ELSE}
       
   367 		modeFormat:= modeIntFormat;
   360 		modeFormat:= modeIntFormat;
   368 		{$ENDIF}
       
   369 	end
   361 	end
   370 else
   362 else
   371 if (surf^.format^.BytesPerPixel = 4) then
   363 if (surf^.format^.BytesPerPixel = 4) then
   372 	begin
   364 	begin
   373 		modeIntFormat:= GL_RGBA;
   365 		modeIntFormat:= GL_RGBA;
   374 		{$IFDEF IPHONEOS}
       
   375 		modeFormat:= GL_BGRA;
       
   376 		{$ELSE}
       
   377 		modeFormat:= modeIntFormat;
   366 		modeFormat:= modeIntFormat;
   378 		{$ENDIF}
       
   379 	end
   367 	end
   380 else
   368 else
   381    begin
   369    begin
   382    TryDo(false, 'Surface2Tex: BytesPerPixel not in [3, 4]', true);
   370    TryDo(false, 'Surface2Tex: BytesPerPixel not in [3, 4]', true);
   383    Surface2Tex^.id:= 0;
   371    Surface2Tex^.id:= 0;