hedgewars/uMisc.pas
changeset 2447 08d623a494e6
parent 2428 6800f8aa0184
child 2460 ac0c497fb842
equal deleted inserted replaced
2446:cbb3af76bcc0 2447:08d623a494e6
   245 function FloatToStr(n: hwFloat): shortstring;
   245 function FloatToStr(n: hwFloat): shortstring;
   246 begin
   246 begin
   247 FloatToStr:= cstr(n) + '_' + inttostr(Lo(n.QWordValue))
   247 FloatToStr:= cstr(n) + '_' + inttostr(Lo(n.QWordValue))
   248 end;
   248 end;
   249 
   249 
       
   250 procedure SetTextureParameters(enableClamp: Boolean);
       
   251 begin
       
   252 if enableClamp and not cReducedQuality then
       
   253     begin
       
   254     glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE);
       
   255     glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE)
       
   256     end;
       
   257 glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR);
       
   258 glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR)
       
   259 end;
       
   260 
   250 function DxDy2Angle(const _dY, _dX: hwFloat): GLfloat;
   261 function DxDy2Angle(const _dY, _dX: hwFloat): GLfloat;
   251 var dY, dX: Extended;
   262 var dY, dX: Extended;
   252 begin
   263 begin
   253 dY:= _dY.QWordValue / $100000000;
   264 dY:= _dY.QWordValue / $100000000;
   254 if _dY.isNegative then dY:= - dY;
   265 if _dY.isNegative then dY:= - dY;
   365 glGenTextures(1, @NewTexture^.id);
   376 glGenTextures(1, @NewTexture^.id);
   366 
   377 
   367 glBindTexture(GL_TEXTURE_2D, NewTexture^.id);
   378 glBindTexture(GL_TEXTURE_2D, NewTexture^.id);
   368 glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, width, height, 0, GL_RGBA, GL_UNSIGNED_BYTE, buf);
   379 glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, width, height, 0, GL_RGBA, GL_UNSIGNED_BYTE, buf);
   369 
   380 
   370 if not cReducedQuality then
   381 SetTextureParameters(true);
   371     begin
       
   372     glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE);
       
   373     glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE)
       
   374     end;
       
   375 glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR);
       
   376 glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR)
       
   377 end;
   382 end;
   378 
   383 
   379 function Surface2Tex(surf: PSDL_Surface; enableClamp: boolean): PTexture;
   384 function Surface2Tex(surf: PSDL_Surface; enableClamp: boolean): PTexture;
   380 var modeIntFormat: LongInt;
   385 var modeIntFormat: LongInt;
   381     modeFormat: LongInt;
   386     modeFormat: LongInt;
   496 ResetVertexArrays(Surface2Tex);
   501 ResetVertexArrays(Surface2Tex);
   497 
   502 
   498 if SDL_MustLock(surf) then
   503 if SDL_MustLock(surf) then
   499 	SDL_UnlockSurface(surf);
   504 	SDL_UnlockSurface(surf);
   500 
   505 
   501 if enableClamp and not cReducedQuality then
   506 SetTextureParameters(enableClamp);
   502     begin
       
   503     glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE);
       
   504     glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE)
       
   505     end;
       
   506 glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR);
       
   507 glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR)
       
   508 end;
   507 end;
   509 
   508 
   510 procedure FreeTexture(tex: PTexture);
   509 procedure FreeTexture(tex: PTexture);
   511 begin
   510 begin
   512 if tex <> nil then
   511 if tex <> nil then