hedgewars/uMisc.pas
changeset 753 40fc0deb388f
parent 626 a30171dbcd19
child 754 94ac14829085
equal deleted inserted replaced
752:69f1dc50a1fa 753:40fc0deb388f
    16  * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
    16  * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
    17  *)
    17  *)
    18 
    18 
    19 unit uMisc;
    19 unit uMisc;
    20 interface
    20 interface
    21 uses uConsts, SDLh, uFloat;
    21 uses uConsts, SDLh, uFloat, GL;
    22 {$INCLUDE options.inc}
    22 {$INCLUDE options.inc}
    23 var isCursorVisible : boolean = false;
    23 var isCursorVisible : boolean = false;
    24     isTerminated    : boolean = false;
    24     isTerminated    : boolean = false;
    25     isInLag         : boolean = false;
    25     isInLag         : boolean = false;
    26     isPaused        : boolean = false;
    26     isPaused        : boolean = false;
   113 {$ENDIF}
   113 {$ENDIF}
   114 procedure SetKB(n: Longword);
   114 procedure SetKB(n: Longword);
   115 procedure SendKB;
   115 procedure SendKB;
   116 procedure SetLittle(var r: hwFloat);
   116 procedure SetLittle(var r: hwFloat);
   117 procedure SendStat(sit: TStatInfoType; s: shortstring);
   117 procedure SendStat(sit: TStatInfoType; s: shortstring);
   118 function Str2PChar(const s: shortstring): PChar;
   118 function  Str2PChar(const s: shortstring): PChar;
       
   119 function  Surface2Tex(surf: PSDL_Surface): GLuint;
   119 
   120 
   120 var CursorPoint: TPoint;
   121 var CursorPoint: TPoint;
   121     TargetPoint: TPoint = (X: NoPointX; Y: 0);
   122     TargetPoint: TPoint = (X: NoPointX; Y: 0);
   122 
   123 
   123 implementation
   124 implementation
   249 end;
   250 end;
   250 
   251 
   251 function RectToStr(Rect: TSDL_Rect): shortstring;
   252 function RectToStr(Rect: TSDL_Rect): shortstring;
   252 begin
   253 begin
   253 RectToStr:= '(x: ' + inttostr(rect.x) + '; y: ' + inttostr(rect.y) + '; w: ' + inttostr(rect.w) + '; h: ' + inttostr(rect.h) + ')'
   254 RectToStr:= '(x: ' + inttostr(rect.x) + '; y: ' + inttostr(rect.y) + '; w: ' + inttostr(rect.w) + '; h: ' + inttostr(rect.h) + ')'
       
   255 end;
       
   256 
       
   257 function Surface2Tex(surf: PSDL_Surface): GLuint;
       
   258 var mode: LongInt;
       
   259     texId: GLuint;
       
   260 begin
       
   261 if (surf^.format^.BytesPerPixel = 3) then mode:= GL_RGB else
       
   262 if (surf^.format^.BytesPerPixel = 4) then mode:= GL_RGBA else
       
   263    begin
       
   264    TryDo(false, 'Surface2Tex: BytePerPixel not in [3, 4]', true);
       
   265    Surface2Tex:= 0;
       
   266    exit
       
   267    end;
       
   268 
       
   269 glGenTextures(1, @texId);
       
   270 
       
   271 glBindTexture(GL_TEXTURE_2D, texId);
       
   272 
       
   273 glTexImage2D(GL_TEXTURE_2D, 0, mode, surf^.w, surf^.h, 0, mode, GL_UNSIGNED_BYTE, surf^.pixels);
       
   274 
       
   275 glTexParameteri(GL_TEXTURE_2D,GL_TEXTURE_MIN_FILTER,GL_NEAREST);
       
   276 glTexParameteri(GL_TEXTURE_2D,GL_TEXTURE_MAG_FILTER,GL_LINEAR);
       
   277 
       
   278 Surface2Tex:= texId
   254 end;
   279 end;
   255 
   280 
   256 
   281 
   257 var i: LongInt;
   282 var i: LongInt;
   258 {$ENDIF}
   283 {$ENDIF}