hedgewars/uMisc.pas
changeset 1180 e56317fdf78d
parent 1128 9b3f42bf4eef
child 1295 27bec661581c
equal deleted inserted replaced
1179:bdf8b68b1dd1 1180:e56317fdf78d
   118 procedure SetKB(n: Longword);
   118 procedure SetKB(n: Longword);
   119 procedure SendKB;
   119 procedure SendKB;
   120 procedure SetLittle(var r: hwFloat);
   120 procedure SetLittle(var r: hwFloat);
   121 procedure SendStat(sit: TStatInfoType; s: shortstring);
   121 procedure SendStat(sit: TStatInfoType; s: shortstring);
   122 function  Str2PChar(const s: shortstring): PChar;
   122 function  Str2PChar(const s: shortstring): PChar;
       
   123 function NewTexture(width, height: Longword; buf: Pointer): PTexture;
   123 function  Surface2Tex(surf: PSDL_Surface): PTexture;
   124 function  Surface2Tex(surf: PSDL_Surface): PTexture;
   124 procedure FreeTexture(tex: PTexture);
   125 procedure FreeTexture(tex: PTexture);
   125 function  toPowerOf2(i: Longword): Longword;
   126 function  toPowerOf2(i: Longword): Longword;
   126 function DecodeBase64(s: shortstring): shortstring;
   127 function DecodeBase64(s: shortstring): shortstring;
   127 procedure MakeScreenshot(s: shortstring);
   128 procedure MakeScreenshot(s: shortstring);
   263 
   264 
   264 function toPowerOf2(i: Longword): Longword;
   265 function toPowerOf2(i: Longword): Longword;
   265 begin
   266 begin
   266 toPowerOf2:= 1;
   267 toPowerOf2:= 1;
   267 while (toPowerOf2 < i) do toPowerOf2:= toPowerOf2 shl 1
   268 while (toPowerOf2 < i) do toPowerOf2:= toPowerOf2 shl 1
       
   269 end;
       
   270 
       
   271 function NewTexture(width, height: Longword; buf: Pointer): PTexture;
       
   272 begin
       
   273 new(NewTexture);
       
   274 NewTexture^.w:= width;
       
   275 NewTexture^.h:= height;
       
   276 
       
   277 glGenTextures(1, @NewTexture^.id);
       
   278 
       
   279 glBindTexture(GL_TEXTURE_2D, NewTexture^.id);
       
   280 
       
   281 glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, width, height, 0, GL_RGBA, GL_UNSIGNED_BYTE, buf);
       
   282 
       
   283 glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR);
       
   284 glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR)
   268 end;
   285 end;
   269 
   286 
   270 function Surface2Tex(surf: PSDL_Surface): PTexture;
   287 function Surface2Tex(surf: PSDL_Surface): PTexture;
   271 var mode: LongInt;
   288 var mode: LongInt;
   272     tw, th: Longword;
   289     tw, th: Longword;