Recent

Author Topic: [SOLVED] error when compiling unit bgrabitmap on mac osx.  (Read 7285 times)

mapolat

  • New Member
  • *
  • Posts: 18
[SOLVED] error when compiling unit bgrabitmap on mac osx.
« on: July 27, 2012, 10:47:58 pm »
First, sorry for my bad english.

I use mac osx (snow leopard) and Lazarus 1.1. Now I've downloaded BGRABitMap and want to use it as a package for my developments.

Unfortunately, I get the following error message again and again, when I try to compile it (see ScreenShot1):

"/../BGRABitMap/bgracolorint.pas(55,23) Fatal: There were 1 errors compiling module stopping."

A change in the line and commenting out does not help (see ScreenShot2).

This error message comes in versions BGRABitMap 5.7.1, 5.7.2, 5.8

I can not identify where the fault lies? can anyone help me?
 
« Last Edit: July 28, 2012, 05:06:16 pm by mapolat »

circular

  • Hero Member
  • *****
  • Posts: 3070
    • Personal webpage
Re: error when compiling unit bgrabitmap
« Reply #1 on: July 28, 2012, 11:54:52 am »
This problem has already been raised. You are right, it does not compile. And I don't know either what would be the problem in the code. I think that the problem comes from the compiler.
Conscience is the debugger of the mind

circular

  • Hero Member
  • *****
  • Posts: 3070
    • Personal webpage
Re: error when compiling unit bgrabitmap
« Reply #2 on: July 28, 2012, 12:01:10 pm »
Here is a test program for this unit. Does it compile on MacOS?
Conscience is the debugger of the mind

mapolat

  • New Member
  • *
  • Posts: 18
Re: error when compiling unit bgrabitmap
« Reply #3 on: July 28, 2012, 12:39:05 pm »
Hi Circular,

Thank's for your feedback.

I tried your test program to compile. Result is the same (see ScreenShot 20120728_12_18_30.jpg).

I've searched the forum. User Shebuka has written in another thread (http://www.lazarus.freepascal.org/index.php/topic,16584.0.html):
"You need to get rev. 387 from svn, it's the last working on mac."

I've downloaded build 387 and tested. And actually can compile the build 387. SVN build 388 and higher can not compile anymore.


mapolat

  • New Member
  • *
  • Posts: 18
Re: error when compiling unit bgrabitmap
« Reply #4 on: July 28, 2012, 01:16:36 pm »
Hi Circular,

I have now removed the only assemler codes from BGRAColorInt.pas. And now can I compile the test program.

I did not have enough knowledge of assembler. It seems to me, that the assembler code in BGRAColorInt.pas is not appropriate for mac.

Code: [Select]
unit BGRAColorInt;

{$mode objfpc}{$H+}

interface

uses
  BGRATypes;

type
  TColorInt65536 = packed record
    r,g,b,a: integer;
  end;

function ColorInt65536(r,g,b,a: integer): TColorInt65536; inline; overload;
function ColorInt65536(r,g,b: integer): TColorInt65536; inline; overload;
function ColorFToColorInt65536(colorF: TColorF): TColorInt65536; inline;
function ColorInt65536ToColorF(color: TColorInt65536): TColorF;
operator +(const color1,color2: TColorInt65536): TColorInt65536; inline;
operator *(const color1,color2: TColorInt65536): TColorInt65536;
operator *(const color1: TColorInt65536; factor65536: integer): TColorInt65536;
function ColorIntToBGRA(const AColor: TColorInt65536): TBGRAPixel;
function BGRAToColorInt(const AColor: TBGRAPixel): TColorInt65536;
function BGRAToColorIntMultiply(const color1: TBGRAPixel; const color2: TColorInt65536): TColorInt65536;

implementation

function ColorInt65536(r, g, b, a: integer): TColorInt65536;
begin
  result.r := r;
  result.g := g;
  result.b := b;
  result.a := a;
end;

function ColorInt65536(r, g, b: integer): TColorInt65536;
begin
  result.r := r;
  result.g := g;
  result.b := b;
  result.a := 65536;
end;

function ColorFToColorInt65536(colorF: TColorF): TColorInt65536;
begin
  result.r := round(colorF[1]*65536);
  result.g := round(colorF[2]*65536);
  result.b := round(colorF[3]*65536);
  result.a := round(colorF[4]*65536);
end;

function ColorInt65536ToColorF(color: TColorInt65536): TColorF;
const oneOver65536 = 1/65536;
begin
  result[1] := color.r*oneOver65536;
  result[2] := color.g*oneOver65536;
  result[3] := color.b*oneOver65536;
  result[4] := color.a*oneOver65536;
end;

operator+(const color1, color2: TColorInt65536): TColorInt65536;
begin
  result.r := color1.r+color2.r;
  result.g := color1.g+color2.g;
  result.b := color1.b+color2.b;
  result.a := color1.a+color2.a;
end;

operator*(const color1, color2: TColorInt65536): TColorInt65536;
begin
  result.r := int64(color1.r)*color2.r shr 16;
  result.g := int64(color1.g)*color2.g shr 16;
  result.b := int64(color1.b)*color2.b shr 16;
  result.a := int64(color1.a)*color2.a shr 16;
end;

operator*(const color1: TColorInt65536; factor65536: integer): TColorInt65536;
begin
  result.r := int64(color1.r)*factor65536 shr 16;
  result.g := int64(color1.g)*factor65536 shr 16;
  result.b := int64(color1.b)*factor65536 shr 16;
  result.a := int64(color1.a)*factor65536 shr 16;
end;

function BGRAToColorInt(const AColor: TBGRAPixel): TColorInt65536;
begin
  result.r := AColor.red shl 8 + AColor.red + (AColor.red shr 7);
  result.g := AColor.green shl 8 + AColor.green + (AColor.green shr 7);
  result.b := AColor.blue shl 8 + AColor.blue + (AColor.blue shr 7);
  result.a := AColor.alpha shl 8 + AColor.alpha+ (AColor.alpha shr 7);
end;

function BGRAToColorIntMultiply(const color1: TBGRAPixel;
  const color2: TColorInt65536): TColorInt65536;
begin
  result.r := int64(color2.r)*(color1.red shr 7+color1.red) shr 8;
  result.g := int64(color2.g)*(color1.green shr 7+color1.green) shr 8;
  result.b := int64(color2.b)*(color1.blue shr 7+color1.blue) shr 8;
  result.a := int64(color2.a)*(color1.alpha shr 7+color1.alpha) shr 8;
end;

function ColorIntToBGRA(const AColor: TColorInt65536): TBGRAPixel;
var maxValue,invMaxValue,r,g,b: integer;
begin
  if AColor.a <= 0 then
    result.alpha := 0;
  if AColor.a >= 65536 then
    result.alpha := 255
  else
    result.alpha := AColor.a shr 8 - (AColor.a shr 15);

  maxValue := AColor.r;
  if AColor.g > maxValue then maxValue := AColor.g;
  if AColor.b > maxValue then maxValue := AColor.b;

  if maxValue <= 0 then
  begin
    result.red := 0;
    result.green := 0;
    result.blue := 0;
    exit;
  end;

  if maxValue <= 65535 then
  begin
    if AColor.r <= 0 then result.red := 0 else
      result.red := AColor.r shr 8 - (AColor.r shr 15);

    if AColor.g <= 0 then result.green := 0 else
      result.green := AColor.g shr 8 - (AColor.g shr 15);

    if AColor.b <= 0 then result.blue := 0 else
      result.blue := AColor.b shr 8 - (AColor.b shr 15);
    exit;
  end;

  invMaxValue := (1073741824+maxValue-1) div maxValue;
  maxValue := (maxValue-65535) shr 9;
  if AColor.r < 0 then r := 0 else
    r := AColor.r*invMaxValue shr 22 + maxValue;
  if AColor.g < 0 then g := 0 else
    g := AColor.g*invMaxValue shr 22 + maxValue;
  if AColor.b < 0 then b := 0 else
    b := AColor.b*invMaxValue shr 22 + maxValue;

  if r >= 255 then result.red := 255 else
    result.red := r;
  if g >= 255 then result.green := 255 else
      result.green := g;
  if b >= 255 then result.blue := 255 else
    result.blue := b;
end;


end.

circular

  • Hero Member
  • *****
  • Posts: 3070
    • Personal webpage
Re: error when compiling unit bgrabitmap
« Reply #5 on: July 28, 2012, 03:26:44 pm »
I see.

Can you try to remove the "packed" keyword in the definition of TColorF (in BGRATypes) while keeping assembler. Does this fix the problem ?

Otherwise, this version of BGRAColorInt would avoid using asm with MacOS :
Code: [Select]
unit BGRAColorInt;

{$mode objfpc}{$H+}
{$ifdef CPUI386}
  {$define BGRACOLORINT_USEASM}
{$endif}
{$ifdef DARWIN}
  {$undef BGRACOLORINT_USEASM}
{$endif}

interface

uses
  BGRATypes;

type
  TColorInt65536 = packed record
    r,g,b,a: integer;
  end;

function ColorInt65536(r,g,b,a: integer): TColorInt65536; inline; overload;
function ColorInt65536(r,g,b: integer): TColorInt65536; inline; overload;
function ColorFToColorInt65536(colorF: TColorF): TColorInt65536; inline;
function ColorInt65536ToColorF(color: TColorInt65536): TColorF;
operator +(const color1,color2: TColorInt65536): TColorInt65536; inline;
operator *(const color1,color2: TColorInt65536): TColorInt65536;
operator *(const color1: TColorInt65536; factor65536: integer): TColorInt65536;
function ColorIntToBGRA(const AColor: TColorInt65536): TBGRAPixel;
function BGRAToColorInt(const AColor: TBGRAPixel): TColorInt65536;
function BGRAToColorIntMultiply(const color1: TBGRAPixel; const color2: TColorInt65536): TColorInt65536;

implementation

function ColorInt65536(r, g, b, a: integer): TColorInt65536;
begin
  result.r := r;
  result.g := g;
  result.b := b;
  result.a := a;
end;

function ColorInt65536(r, g, b: integer): TColorInt65536;
begin
  result.r := r;
  result.g := g;
  result.b := b;
  result.a := 65536;
end;

function ColorFToColorInt65536(colorF: TColorF): TColorInt65536;
begin
  result.r := round(colorF[1]*65536);
  result.g := round(colorF[2]*65536);
  result.b := round(colorF[3]*65536);
  result.a := round(colorF[4]*65536);
end;

function ColorInt65536ToColorF(color: TColorInt65536): TColorF;
const oneOver65536 = 1/65536;
begin
  result[1] := color.r*oneOver65536;
  result[2] := color.g*oneOver65536;
  result[3] := color.b*oneOver65536;
  result[4] := color.a*oneOver65536;
end;

operator+(const color1, color2: TColorInt65536): TColorInt65536;
begin
  result.r := color1.r+color2.r;
  result.g := color1.g+color2.g;
  result.b := color1.b+color2.b;
  result.a := color1.a+color2.a;
end;

operator*(const color1, color2: TColorInt65536): TColorInt65536;
{$ifdef BGRACOLORINT_USEASM} {$asmmode intel} assembler;
  asm
    push edx
    push ebx
    push esi
    mov ebx, Color1
    mov esi, Color2
    //ecx = @result

    mov eax, [ebx] //r
    imul [esi]
    shl edx, 16
    shr eax, 16
    or edx, eax
    mov [ecx], edx

    mov eax, [ebx+4] //g
    imul [esi+4]
    shl edx, 16
    shr eax, 16
    or edx, eax
    mov [ecx+4], edx

    mov eax, [ebx+8] //b
    imul [esi+8]
    shl edx, 16
    shr eax, 16
    or edx, eax
    mov [ecx+8], edx

    mov eax, [ebx+12] //a
    imul [esi+12]
    shl edx, 16
    shr eax, 16
    or edx, eax
    mov [ecx+12], edx

    pop esi
    pop ebx
    pop edx
  end;
{$ELSE}
begin
  result.r := int64(color1.r)*color2.r shr 16;
  result.g := int64(color1.g)*color2.g shr 16;
  result.b := int64(color1.b)*color2.b shr 16;
  result.a := int64(color1.a)*color2.a shr 16;
end;
{$ENDIF}

operator*(const color1: TColorInt65536; factor65536: integer): TColorInt65536;
{$ifdef BGRACOLORINT_USEASM} {$asmmode intel} assembler;
  asm
    push edx
    push ebx
    push esi
    mov ebx, Color1
    mov esi, factor65536
    //ecx = @result

    mov eax, [ebx] //r
    imul esi
    shl edx, 16
    shr eax, 16
    or edx, eax
    mov [ecx], edx

    mov eax, [ebx+4] //g
    imul esi
    shl edx, 16
    shr eax, 16
    or edx, eax
    mov [ecx+4], edx

    mov eax, [ebx+8] //b
    imul esi
    shl edx, 16
    shr eax, 16
    or edx, eax
    mov [ecx+8], edx

    mov eax, [ebx+12] //a
    imul esi
    shl edx, 16
    shr eax, 16
    or edx, eax
    mov [ecx+12], edx

    pop esi
    pop ebx
    pop edx
  end;
{$else}
begin
  result.r := int64(color1.r)*factor65536 shr 16;
  result.g := int64(color1.g)*factor65536 shr 16;
  result.b := int64(color1.b)*factor65536 shr 16;
  result.a := int64(color1.a)*factor65536 shr 16;
end;
{$endif}

function BGRAToColorInt(const AColor: TBGRAPixel): TColorInt65536;
begin
  result.r := AColor.red shl 8 + AColor.red + (AColor.red shr 7);
  result.g := AColor.green shl 8 + AColor.green + (AColor.green shr 7);
  result.b := AColor.blue shl 8 + AColor.blue + (AColor.blue shr 7);
  result.a := AColor.alpha shl 8 + AColor.alpha+ (AColor.alpha shr 7);
end;

function BGRAToColorIntMultiply(const color1: TBGRAPixel;
  const color2: TColorInt65536): TColorInt65536;
{$ifdef BGRACOLORINT_USEASM} {$asmmode intel} assembler;
  asm
    push ebx
    push esi

    mov esi, Color2
    mov ebx, result
    mov ecx, [Color1]

    movzx eax, cl //b
    mov edx, eax
    shr edx, 7
    add eax, edx
    imul [esi+8]
    shl edx, 24
    shr eax, 8
    or edx, eax
    mov [ebx+8], edx
    shr ecx, 8

    movzx eax, cl //g
    mov edx, eax
    shr edx, 7
    add eax, edx
    imul [esi+4]
    shl edx, 24
    shr eax, 8
    or edx, eax
    mov [ebx+4], edx
    shr ecx, 8

    movzx eax, cl //r
    mov edx, eax
    shr edx, 7
    add eax, edx
    imul [esi]
    shl edx, 24
    shr eax, 8
    or edx, eax
    mov [ebx], edx
    shr ecx, 8

    movzx eax, cl //a
    mov edx, eax
    shr edx, 7
    add eax, edx
    imul [esi+12]
    shl edx, 24
    shr eax, 8
    or edx, eax
    mov [ebx+12], edx

    pop esi
    pop ebx
  end;
{$ELSE}
begin
  result.r := int64(color2.r)*(color1.red shr 7+color1.red) shr 8;
  result.g := int64(color2.g)*(color1.green shr 7+color1.green) shr 8;
  result.b := int64(color2.b)*(color1.blue shr 7+color1.blue) shr 8;
  result.a := int64(color2.a)*(color1.alpha shr 7+color1.alpha) shr 8;
end;
{$ENDIF}

function ColorIntToBGRA(const AColor: TColorInt65536): TBGRAPixel;
var maxValue,invMaxValue,r,g,b: integer;
begin
  if AColor.a <= 0 then
    result.alpha := 0;
  if AColor.a >= 65536 then
    result.alpha := 255
  else
    result.alpha := AColor.a shr 8 - (AColor.a shr 15);

  maxValue := AColor.r;
  if AColor.g > maxValue then maxValue := AColor.g;
  if AColor.b > maxValue then maxValue := AColor.b;

  if maxValue <= 0 then
  begin
    result.red := 0;
    result.green := 0;
    result.blue := 0;
    exit;
  end;

  if maxValue <= 65535 then
  begin
    if AColor.r <= 0 then result.red := 0 else
      result.red := AColor.r shr 8 - (AColor.r shr 15);

    if AColor.g <= 0 then result.green := 0 else
      result.green := AColor.g shr 8 - (AColor.g shr 15);

    if AColor.b <= 0 then result.blue := 0 else
      result.blue := AColor.b shr 8 - (AColor.b shr 15);
    exit;
  end;

  invMaxValue := (1073741824+maxValue-1) div maxValue;
  maxValue := (maxValue-65535) shr 9;
  if AColor.r < 0 then r := 0 else
    r := AColor.r*invMaxValue shr 22 + maxValue;
  if AColor.g < 0 then g := 0 else
    g := AColor.g*invMaxValue shr 22 + maxValue;
  if AColor.b < 0 then b := 0 else
    b := AColor.b*invMaxValue shr 22 + maxValue;

  if r >= 255 then result.red := 255 else
    result.red := r;
  if g >= 255 then result.green := 255 else
      result.green := g;
  if b >= 255 then result.blue := 255 else
    result.blue := b;
end;


end.
Conscience is the debugger of the mind

mapolat

  • New Member
  • *
  • Posts: 18
Re: error when compiling unit bgrabitmap
« Reply #6 on: July 28, 2012, 03:46:26 pm »
I had already tried to convert the packed arrays and packed record in arrays and records. The error went away not so. So it is not because of the keyword "packed".

It really seems to be due to assembler code.

If I, as you suggested, assembler code with

{$mode objfpc}{$H+}
{$ifdef CPUI386}
  {$define BGRACOLORINT_USEASM}
{$endif}
{$ifdef DARWIN}
  {$undef BGRACOLORINT_USEASM}
{$endif}

 turn off, can I compile the unit.

mapolat

  • New Member
  • *
  • Posts: 18
Re: error when compiling unit bgrabitmap
« Reply #7 on: July 28, 2012, 04:22:20 pm »
Hi Circular,

Now, I can compile your test-program successfully.

As a next step I would like to customize the package BGRABitMap 5.8 (build 422) and compile it.

now I get another error message (see ScreenShot_20120728_160757.jpg).:

"Error: Generating PIC, but reference is not safe-PIC."

I had read that you had this problem fixed. What was the solution?

circular

  • Hero Member
  • *****
  • Posts: 3070
    • Personal webpage
Re: error when compiling unit bgrabitmap
« Reply #8 on: July 28, 2012, 04:29:15 pm »
Try with this code for BGRAMatrix3D (replacing "cmp UseSSE3" by "if UseSSE3"):
Code: [Select]
unit BGRAMatrix3D;

{$mode objfpc}{$H+}

{$ifdef CPUI386}
  {$asmmode intel}
{$endif}

interface

uses
  BGRABitmapTypes, BGRASSE;

type
  TMatrix3D = packed array[1..3,1..4] of single;

operator*(const A: TMatrix3D; const M: TPoint3D): TPoint3D;
operator*(const A: TMatrix3D; var M: TPoint3D_128): TPoint3D_128;
operator*(A,B: TMatrix3D): TMatrix3D;

function Matrix3D(m11,m12,m13,m14, m21,m22,m23,m24, m31,m32,m33,m34: single): TMatrix3D; overload;
function Matrix3D(vx,vy,vz,ofs: TPoint3D): TMatrix3D; overload;
function Matrix3D(vx,vy,vz,ofs: TPoint3D_128): TMatrix3D; overload;
function MatrixIdentity3D: TMatrix3D;
function MatrixInverse3D(A: TMatrix3D): TMatrix3D;
function MatrixTranslation3D(ofs: TPoint3D): TMatrix3D;
function MatrixScale3D(size: TPoint3D): TMatrix3D;
function MatrixRotateX(angle: single): TMatrix3D;
function MatrixRotateY(angle: single): TMatrix3D;
function MatrixRotateZ(angle: single): TMatrix3D;

{$IFDEF CPUI386}
procedure Matrix3D_SSE_Load(const A: TMatrix3D);
procedure MatrixMultiplyVect3D_SSE_Aligned(var M: TPoint3D_128; out N: TPoint3D_128);
procedure MatrixMultiplyVect3D_SSE3_Aligned(var M: TPoint3D_128; out N: TPoint3D_128);
{$ENDIF}

implementation

procedure multiplyVectInline(const A : TMatrix3D; const vx,vy,vz,vt: single; out outx,outy,outz: single);
begin
  outx := vx * A[1,1] + vy * A[1,2] + vz * A[1,3] + vt * A[1,4];
  outy := vx * A[2,1] + vy * A[2,2] + vz * A[2,3] + vt * A[2,4];
  outz := vx * A[3,1] + vy * A[3,2] + vz * A[3,3] + vt * A[3,4];
end;

operator*(const A: TMatrix3D; const M: TPoint3D): TPoint3D;
begin
  result.x := M.x * A[1,1] + M.y * A[1,2] + M.z * A[1,3] + A[1,4];
  result.y := M.x * A[2,1] + M.y * A[2,2] + M.z * A[2,3] + A[2,4];
  result.z := M.x * A[3,1] + M.y * A[3,2] + M.z * A[3,3] + A[3,4];
end;

var SingleConst1 : single = 1;

{$IFDEF CPUI386}
procedure Matrix3D_SSE_Load(const A: TMatrix3D);
begin
  asm
    mov eax, A
    movups xmm5, [eax]
    movups xmm6, [eax+16]
    movups xmm7, [eax+32]
  end;
end;

procedure MatrixMultiplyVect3D_SSE_Aligned(var M: TPoint3D_128; out N: TPoint3D_128);
var oldMt: single;
begin
  oldMt := M.t;
  M.t := SingleConst1;
  asm
    mov eax, M
    movaps xmm0, [eax]

    mov eax, N

    movaps xmm2,xmm0
    mulps xmm2,xmm5
    //mix1
    movaps xmm3, xmm2
    shufps xmm3, xmm3, $4e
    addps xmm2, xmm3
    //mix2
    movaps xmm3, xmm2
    shufps xmm3, xmm3, $11
    addps xmm2, xmm3

    movss [eax], xmm2

    movaps xmm2,xmm0
    mulps xmm2,xmm6
    //mix1
    movaps xmm3, xmm2
    shufps xmm3, xmm3, $4e
    addps xmm2, xmm3
    //mix2
    movaps xmm3, xmm2
    shufps xmm3, xmm3, $11
    addps xmm2, xmm3

    movss [eax+4], xmm2

    mulps xmm0,xmm7
    //mix1
    movaps xmm3, xmm0
    shufps xmm3, xmm3, $4e
    addps xmm0, xmm3
    //mix2
    movaps xmm3, xmm0
    shufps xmm3, xmm3, $11
    addps xmm0, xmm3

    movss [eax+8], xmm0
  end;
  M.t := oldMt;
  N.t := 0;
end;

procedure MatrixMultiplyVect3D_SSE3_Aligned(var M: TPoint3D_128; out N: TPoint3D_128);
var oldMt: single;
begin
  oldMt := M.t;
  M.t := SingleConst1;
  asm
    mov eax, M
    movaps xmm0, [eax]

    mov eax, N

    movaps xmm2,xmm0
    mulps xmm2,xmm5
    haddps xmm2,xmm2
    haddps xmm2,xmm2
    movss [eax], xmm2

    movaps xmm2,xmm0
    mulps xmm2,xmm6
    haddps xmm2,xmm2
    haddps xmm2,xmm2
    movss [eax+4], xmm2

    mulps xmm0,xmm7
    haddps xmm0,xmm0
    haddps xmm0,xmm0
    movss [eax+8], xmm0
  end;
  M.t := oldMt;
end;
{$ENDIF}

operator*(const A: TMatrix3D; var M: TPoint3D_128): TPoint3D_128;
{$IFDEF CPUI386}var oldMt: single; {$ENDIF}
begin
  {$IFDEF CPUI386}
  if UseSSE then
  begin
    oldMt := M.t;
    M.t := SingleConst1;
    if UseSSE3 then
    asm
      mov eax, A
      movups xmm5, [eax]
      movups xmm6, [eax+16]
      movups xmm7, [eax+32]

      mov eax, M
      movups xmm0, [eax]

      mov eax, result

      movaps xmm4,xmm0
      mulps xmm4,xmm5
      haddps xmm4,xmm4
      haddps xmm4,xmm4
      movss [eax], xmm4

      movaps xmm4,xmm0
      mulps xmm4,xmm6
      haddps xmm4,xmm4
      haddps xmm4,xmm4
      movss [eax+4], xmm4

      mulps xmm0,xmm7
      haddps xmm0,xmm0
      haddps xmm0,xmm0
      movss [eax+8], xmm0
    end else
    asm
      mov eax, A
      movups xmm5, [eax]
      movups xmm6, [eax+16]
      movups xmm7, [eax+32]

      mov eax, M
      movups xmm0, [eax]

      mov eax, result

      movaps xmm4,xmm0
      mulps xmm4,xmm5
      //mix1
      movaps xmm3, xmm4
      shufps xmm3, xmm3, $4e
      addps xmm4, xmm3
      //mix2
      movaps xmm3, xmm4
      shufps xmm3, xmm3, $11
      addps xmm4, xmm3

      movss [eax], xmm4

      movaps xmm4,xmm0
      mulps xmm4,xmm6
      //mix1
      movaps xmm3, xmm4
      shufps xmm3, xmm3, $4e
      addps xmm4, xmm3
      //mix2
      movaps xmm3, xmm4
      shufps xmm3, xmm3, $11
      addps xmm4, xmm3

      movss [eax+4], xmm4

      mulps xmm0,xmm7
      //mix1
      movaps xmm3, xmm0
      shufps xmm3, xmm3, $4e
      addps xmm0, xmm3
      //mix2
      movaps xmm3, xmm0
      shufps xmm3, xmm3, $11
      addps xmm0, xmm3

      movss [eax+8], xmm0
    end;
    M.t := oldMt;
    result.t := 0;
  end else
  {$ENDIF}
  begin
    result.x := M.x * A[1,1] + M.y * A[1,2] + M.z * A[1,3] + A[1,4];
    result.y := M.x * A[2,1] + M.y * A[2,2] + M.z * A[2,3] + A[2,4];
    result.z := M.x * A[3,1] + M.y * A[3,2] + M.z * A[3,3] + A[3,4];
    result.t := 0;
  end;
end;

operator*(A,B: TMatrix3D): TMatrix3D;
begin
  multiplyVectInline(A, B[1,1],B[2,1],B[3,1],0, result[1,1],result[2,1],result[3,1]);
  multiplyVectInline(A, B[1,2],B[2,2],B[3,2],0, result[1,2],result[2,2],result[3,2]);
  multiplyVectInline(A, B[1,3],B[2,3],B[3,3],0, result[1,3],result[2,3],result[3,3]);
  multiplyVectInline(A, B[1,4],B[2,4],B[3,4],1, result[1,4],result[2,4],result[3,4]);
end;

function MatrixIdentity3D: TMatrix3D;
begin
  result := Matrix3D( 1,0,0,0,
                      0,1,0,0,
                      0,0,1,0);
end;

function Matrix3D(m11, m12, m13, m14, m21, m22, m23, m24, m31, m32, m33,
  m34: single): TMatrix3D;
begin
  result[1,1] := m11;
  result[1,2] := m12;
  result[1,3] := m13;
  result[1,4] := m14;

  result[2,1] := m21;
  result[2,2] := m22;
  result[2,3] := m23;
  result[2,4] := m24;

  result[3,1] := m31;
  result[3,2] := m32;
  result[3,3] := m33;
  result[3,4] := m34;
end;

function MatrixInverse3D(A: TMatrix3D): TMatrix3D;
var ofs: TPoint3D;
begin
  ofs := Point3D(A[1,4],A[2,4],A[3,4]);

  result[1,1] := A[1,1];
  result[1,2] := A[2,1];
  result[1,3] := A[3,1];
  result[1,4] := 0;

  result[2,1] := A[1,2];
  result[2,2] := A[2,2];
  result[2,3] := A[3,2];
  result[2,4] := 0;

  result[3,1] := A[1,3];
  result[3,2] := A[2,3];
  result[3,3] := A[3,3];
  result[3,4] := 0;

  result := result*MatrixTranslation3D(-ofs);
end;

function Matrix3D(vx, vy, vz, ofs: TPoint3D): TMatrix3D;
begin
  result := Matrix3D(vx.x, vy.x, vz.x, ofs.x,
                     vx.y, vy.y, vz.y, ofs.y,
                     vx.z, vy.z, vz.z, ofs.z);
end;

function Matrix3D(vx, vy, vz, ofs: TPoint3D_128): TMatrix3D;
begin
  result := Matrix3D(vx.x, vy.x, vz.x, ofs.x,
                     vx.y, vy.y, vz.y, ofs.y,
                     vx.z, vy.z, vz.z, ofs.z);
end;

function MatrixTranslation3D(ofs: TPoint3D): TMatrix3D;
begin
  result := Matrix3D(1,0,0,ofs.x,
                     0,1,0,ofs.Y,
                     0,0,1,ofs.z);
end;

function MatrixScale3D(size: TPoint3D): TMatrix3D;
begin
  result := Matrix3D(size.x,0,0,0,
                     0,size.y,0,0,
                     0,0,size.z,0);
end;

function MatrixRotateX(angle: single): TMatrix3D;
begin
  result := Matrix3D( 1,       0,           0,       0,
                      0,   cos(angle), sin(angle),   0,
                      0,  -sin(angle), cos(angle),   0);
end;

function MatrixRotateY(angle: single): TMatrix3D;
begin
  result := Matrix3D(  cos(angle), 0, -sin(angle),  0,
                           0,      1,      0,       0,
                       sin(angle), 0,  cos(angle),  0);
end;

function MatrixRotateZ(angle: single): TMatrix3D;
begin
  result := Matrix3D(  cos(angle), sin(angle),   0,    0,
                      -sin(angle), cos(angle),   0,    0,
                          0,            0,       1,    0);
end;

end.
« Last Edit: July 28, 2012, 04:31:49 pm by circular »
Conscience is the debugger of the mind

mapolat

  • New Member
  • *
  • Posts: 18
Re: error when compiling unit bgrabitmap
« Reply #9 on: July 28, 2012, 04:55:22 pm »
You're the greatest!

Now, the error are fixed and I can compile BGRABitMap 5.8 and integrate it into my projects.

Many thanks for the emergency aid.

circular

  • Hero Member
  • *****
  • Posts: 3070
    • Personal webpage
Re: solved : error when compiling unit bgrabitmap on mac osx.
« Reply #10 on: July 28, 2012, 05:05:02 pm »
Well thank you for helping me solving this problem.

Now I can publish a new version of BGRABitmap that will work again on MacOS.
Conscience is the debugger of the mind

circular

  • Hero Member
  • *****
  • Posts: 3070
    • Personal webpage
Re: [SOLVED] error when compiling unit bgrabitmap on mac osx.
« Reply #11 on: July 28, 2012, 05:18:26 pm »
Here is a new zip of BGRABitmap (v5.9) :
http://sourceforge.net/projects/lazpaint/files/src/

According to the modifications we've made, it should work on MacOS.
Conscience is the debugger of the mind

mapolat

  • New Member
  • *
  • Posts: 18
Re: [SOLVED] error when compiling unit bgrabitmap on mac osx.
« Reply #12 on: July 28, 2012, 05:36:45 pm »
Super ...

I have tested BGRABitMap v5.9. It works on MAC OSX with no errors.

Thank you.

circular

  • Hero Member
  • *****
  • Posts: 3070
    • Personal webpage
Re: [SOLVED] error when compiling unit bgrabitmap on mac osx.
« Reply #13 on: July 28, 2012, 05:44:17 pm »
Thanks for testing.  :)
Conscience is the debugger of the mind

Shebuka

  • Sr. Member
  • ****
  • Posts: 422
Re: [SOLVED] error when compiling unit bgrabitmap on mac osx.
« Reply #14 on: July 30, 2012, 10:20:28 am »
Good news, now my svn is up to date and running cool :)