- Fixed typo in TGLArrow (RealWidth <> RealHeight)

- Fixed TGLArrow.HitTest
This commit is contained in:
Andreas Schneider 2009-12-09 21:25:29 +01:00
parent 3bd5add656
commit 80412fa867
1 changed files with 12 additions and 6 deletions

View File

@ -30,8 +30,8 @@ unit UOverlayUI;
interface interface
uses uses
Classes, SysUtils, Gl, GLU, ImagingTypes, ImagingClasses, ImagingOpenGL, Classes, SysUtils, Gl, GLU, Imaging, ImagingTypes, ImagingClasses,
OpenGLContext, ImagingUtility; ImagingOpenGL, OpenGLContext, ImagingUtility;
type type
@ -93,7 +93,7 @@ begin
GetGLTextureCaps(caps); GetGLTextureCaps(caps);
if caps.NonPowerOfTwo then if caps.NonPowerOfTwo then
begin begin
FWidth := FRealHeight; FWidth := FRealWidth;
FHeight := FRealHeight; FHeight := FRealHeight;
end else end else
begin begin
@ -127,10 +127,13 @@ begin
end; end;
function TGLArrow.HitTest(AX, AY: Integer): Boolean; function TGLArrow.HitTest(AX, AY: Integer): Boolean;
var
pixel: TColor32Rec;
begin begin
if (AX > -1) and (AX < FRealWidth) and (AY > -1) and (AY < FRealHeight) then if (AX > -1) and (AX < FRealWidth) and (AY > -1) and (AY < FRealHeight) then
begin begin
Result := (FGraphic <> nil) and (Cardinal(PIntegerArray(FGraphic.Bits)^[AY * FWidth + AX] and $FF000000) > 0); pixel := GetPixel32(FGraphic.ImageDataPointer^, AX, AY);
Result := pixel.A > 0;
end else end else
Result := False; Result := False;
end; end;
@ -178,14 +181,17 @@ begin
for i := 0 to 3 do for i := 0 to 3 do
begin begin
FArrows[2*i] := TGLArrow.Create(arrow); FArrows[2*i] := TGLArrow.Create(arrow);
arrow.Rotate(-90); if i < 3 then
arrow.Rotate(-90);
end; end;
arrow.Free; arrow.Free;
arrow := TSingleImage.CreateFromStream(ResourceManager.GetResource(1)); arrow := TSingleImage.CreateFromStream(ResourceManager.GetResource(1));
for i := 0 to 3 do for i := 0 to 3 do
begin begin
FArrows[2*i+1] := TGLArrow.Create(arrow); FArrows[2*i+1] := TGLArrow.Create(arrow);
arrow.Rotate(-90); if i < 3 then
arrow.Rotate(-90);
end; end;
arrow.Free; arrow.Free;
end; end;