Delphi-PRAXiS
Seite 23 von 26   « Erste     13212223 2425     Letzte »    

Delphi-PRAXiS (https://www.delphipraxis.net/forum.php)
-   Software-Projekte der Mitglieder (https://www.delphipraxis.net/26-software-projekte-der-mitglieder/)
-   -   Andorra 2D [Ver. 0.4.5.1, 31.12.08] (https://www.delphipraxis.net/81314-andorra-2d-%5Bver-0-4-5-1-31-12-08%5D.html)

inherited 2. Jan 2009 12:09

Re: Andorra 2D [Ver. 0.4.5.1, 31.12.08]
 
Die Surface-Demo läuft hier wunderbar (Linux, Lazarus, OpenGL)

Florian H 2. Jan 2009 13:17

Re: Andorra 2D [Ver. 0.4.5.1, 31.12.08]
 
Hm.
Wenn ich nach dem Create noch ein
Delphi-Quellcode:
adTextureSF.Texture.Clear;
einfüge, funktioniert es zumindest insofern, dass ich das gezeichnete übertragen kann. Allerdings wird der Inhalt des TextureSurfaces dann nicht gespeichert, sondern ist im nächsten Zeichenschritt wieder verloren (-> Grafikmüll oder gar nichts).
Sprich, ich muss jedesmal neu auf das TextureSurface zeichnen, was aber ja nicht Sinn der Sache ist.

Mich wundert's halt, dass es in OpenGL prima funktioniert... habe auch nochmal die AndorraDX93D.dll neu compiliert, damit wurde sie zwar ~30kb kleiner, hat aber ansonsten nichts gebracht.

xZise 2. Jan 2009 14:16

Re: Andorra 2D [Ver. 0.4.5.1, 31.12.08]
 
Zitat:

Zitat von igel457
Deinen Sourcecode baue ich bei Gelegenheit ein.[...]

Naja ist ja nicht so die große Sache. Ich kam nur auf die Idee das so umzusetzen, weil ich eine TFixelList habe die von TSpriteList abgeleitet wurde.

Zitat:

Zitat von igel457
[...]AdBitmap.SaveToFile schreibt die Daten (wie im zweiten Tutorial beschrieben) in ein Andorra internes Format. Zu den eigentlichen Bilddaten kommen Informationen über das Texturobjekt (Breite, Höhe, Bittiefe) hinzu.[...]

Ah mist, aber ich wollte jetzt nicht alle Tutorials durchsuchen um möglicherweise was zu finden ;)

Zitat:

Zitat von igel457
[...]Die Dokumentation habe ich jetzt endlich erfolgreich über SSH entpackt.[...]

Okay ich gucke es mir mal an.
Zitat:

Zitat von igel457
[...]Wenn du ein Andorra-Bild in ein anderes Grafikobjekt speichern willst, kannst du die Funktion "SaveToGraphic" verwenden.

Nein ich will nur gucken, ob ein Inhalt eines AdImages wirklich komplett schwarz ist. Und ein SaveToGraphic nützt da nichts, weil davon weiß ich schon was rauskommt.
Und ich habe jetzt das AdImage einfach mal drauf gezeichnet und das Ergebnis ist dass unter Delphi 2009 SaveToGraphic nicht funktioniert.

MfG
xZise

igel457 2. Jan 2009 16:10

Re: Andorra 2D [Ver. 0.4.5.1, 31.12.08]
 
Wenn du wissen möchtest, ob ein TAdImage komplett Schwarz ist, dann speichere es doch in ein TAdBitmap und greife einfach über Scanline darauf zu:
Delphi-Quellcode:
var
  adbmp: TAdBitmap;
  pc: PCardinal;
begin
  adbmp := TAdBitmap.Create;
  AdImage.Texture.SaveToGraphic(adbmp);
  pc := adbmp.Scanline;
  for i := 0 to (adbmp.Size div 4) - 1 do
  begin
    if (pc^ and $FFFFFF00) <> 0 then Nicht Schwarz //and $FFFFFF00 ist um den Alphakanal zu ignorieren
    inc(pc);
  end;
  adbmp.Free;
end;

xZise 2. Jan 2009 17:19

Re: Andorra 2D [Ver. 0.4.5.1, 31.12.08]
 
Zitat:

Zitat von igel457
Wenn du wissen möchtest, ob ein TAdImage komplett Schwarz ist, dann speichere es doch in ein TAdBitmap und greife einfach über Scanline darauf zu:
Delphi-Quellcode:
var
  adbmp: TAdBitmap;
  pc: PCardinal;
begin
  adbmp := TAdBitmap.Create;
  AdImage.Texture.SaveToGraphic(adbmp);
  pc := adbmp.Scanline;
  for i := 0 to (adbmp.Size div 4) - 1 do
  begin
    if (pc^ and $FFFFFF00) <> 0 then Nicht Schwarz //and $FFFFFF00 ist um den Alphakanal zu ignorieren
    inc(pc);
  end;
  adbmp.Free;
end;

Hmmm also damit funktioniert es, aber mit diesem Code nicht:
Delphi-Quellcode:
bmp := TBitmap.Create;
try
  AImgBuf.Texture.SaveToGraphic(bmp);
  bmp.SaveToFile(ExtractFilePath(ParamStr(0)) + 'Neuer Ordner\' + AName + '-a.bmp');
finally
  bmp.Free;
end;
MfG
xZise

igel457 2. Jan 2009 17:38

Re: Andorra 2D [Ver. 0.4.5.1, 31.12.08]
 
Debugge das "SaveToFile" doch mal durch. Dann erkennst du doch vermutlich wo es scheitert.

xZise 2. Jan 2009 18:30

Re: Andorra 2D [Ver. 0.4.5.1, 31.12.08]
 
Ehm warum das denn? Also erstens nehme ich an dass der VCL Code soweit i.O. ist und zweitens könnte ich dieses Bitmap auch mit einem TImage verknüpfen und würde nur eine Schwarze Fläche sehen.

MfG
xZise

[edit=0]Ich meine natürlich nicht den VLC media player sondern die Visual Component Library[/edit]

igel457 2. Jan 2009 20:05

Re: Andorra 2D [Ver. 0.4.5.1, 31.12.08]
 
Ich meinte natürlich SaveToGraphic :oops:

xZise 2. Jan 2009 20:09

Re: Andorra 2D [Ver. 0.4.5.1, 31.12.08]
 
Achso ;)

Naja ich habe es vermutlich auf das Kopieren der Daten (AssignTo der Klasse TAdVCLFormat^^) eingegrenzt. Aber so richtig weiß ich nicht, was ich da testen könnte.

Was sein könnte, dass er irgendwie die Hintergrundfarbe nicht richtig setzt, weil da wo Transparenz ist, sieht man schwarz (durchscheinen).

Trace von SaveToGrapic
  1. AImgBuf.SaveToGraphic -> procedure TAdTexture.SaveToGraphic(AGraphic: TObject);
  2. AImgBuf.Texture.SaveToBitmap -> ?????
  3. bmp (TAdBitmap).AssignTo -> procedure TAdBitmap.AssignTo(AGraphic: TObject);
  4. tmp (TAdGraphicFormat).AssignTo -> function TAdVCLFormat.AssignTo(ABitmap: TAdBitmap; AGraphic: TObject): boolean;

Delphi-Quellcode:
function TAdVCLFormat.AssignTo(ABitmap: TAdBitmap;
  AGraphic: TObject): boolean;
var
  bmp: TBitmap;
  y: integer;
begin
  result := true;
 
  bmp := TBitmap.Create;
  try
    bmp.PixelFormat := pf32Bit;
    bmp.Width := ABitmap.Width;
    bmp.Height := ABitmap.Height;

    for y := 0 to bmp.Height - 1 do
      Move(ABitmap.ScanLine(y)^, bmp.ScanLine[y]^, ABitmap.Width * 4);

    TGraphic(AGraphic).Assign(bmp);
  finally
    bmp.Free;
  end;
end;
Wenn ich da das bmp speichere habe ich schon den Big. Das heißt ich vermute es liegt irgendwie an den Move. Wobei ich natürlich da vorher das ABitmap getestet habe und wenn ich vor der for-Schleife das Bitmap teste läuft alles wunderbar:

Delphi-Quellcode:
function TAdVCLFormat.AssignTo(ABitmap: TAdBitmap;
  AGraphic: TObject): boolean;
var
  bmp: TBitmap;
  y: integer;

  i : Integer;
  pc: PCardinal;
begin
  result := true;
 
  bmp := TBitmap.Create;
  try
    bmp.PixelFormat := pf32Bit;
    bmp.Width := ABitmap.Width;
    bmp.Height := ABitmap.Height;

    pc := ABitmap.Scanline;
    for i := 0 to (ABitmap.Size div 4) - 1 do
    begin
      if (pc^ and $FFFFFF00) <> 0 then Beep;
      inc(pc);
    end;

    for y := 0 to bmp.Height - 1 do
      Move(ABitmap.ScanLine(y)^, bmp.ScanLine[y]^, ABitmap.Width * 4);
    bmp.SaveToFile(ExtractFilePath(ParamStr(0)) + 'Neuer Ordner\' + IntToStr(Random(MaxInt - 1)) + '-a.bmp');
    TGraphic(AGraphic).Assign(bmp);
  finally
    bmp.Free;
  end;
end;
MfG
xZise

igel457 2. Jan 2009 20:40

Re: Andorra 2D [Ver. 0.4.5.1, 31.12.08]
 
Ersetzte die MoveTo Zeilen mal Schritt für Schritt durch die folgenden Codeschnipsel und schildere was passiert:

1.
Delphi-Quellcode:
var
  pc1, pc2: PCardinal;
  x, y: integer;
begin
  for y := 0 to bmp.Height - 1 do
  begin  
    pc1 := bmp.Scanline[y];  
    pc2 := ABitmap.Scanline(y);
    for x := 0 to bmp.Width - 1 do
    begin
      pc1^ := $FF0000FF; //Blaues Bitmap, Alpha $FF
      inc(pc1);
      inc(pc2);
    end;
  end;  
end;
2.
Delphi-Quellcode:
var
  pc1, pc2: PCardinal;
  x, y: integer;
begin
  for y := 0 to bmp.Height - 1 do
  begin  
    pc1 := bmp.Scanline[y];  
    pc2 := ABitmap.Scanline(y);
    for x := 0 to bmp.Width - 1 do
    begin
      pc1^ := $FFFFFFFF; //Weißes Bitmap, Alpha $FF
      inc(pc1);
      inc(pc2);
    end;
  end;  
end;
3.
Delphi-Quellcode:
var
  pc1, pc2: PCardinal;
  x, y: integer;
begin
  for y := 0 to bmp.Height - 1 do
  begin  
    pc1 := bmp.Scanline[y];  
    pc2 := ABitmap.Scanline(y);
    for x := 0 to bmp.Width - 1 do
    begin
      pc1^ := pc2^ or $000000FF; //Inhalt ABitmap, Alpha $FF
      inc(pc1);
      inc(pc2);
    end;
  end;  
end;

4.
Delphi-Quellcode:
var
  pc1, pc2: PCardinal;
  x, y: integer;
begin
  for y := 0 to bmp.Height - 1 do
  begin  
    pc1 := bmp.Scanline[y];  
    pc2 := ABitmap.Scanline(y);
    for x := 0 to bmp.Width - 1 do
    begin
      pc1^ := pc2^; //Inhalt ABitmap, Alpha $FF
      inc(pc1);
      inc(pc2);
    end;
  end;  
end;

xZise 2. Jan 2009 21:54

Re: Andorra 2D [Ver. 0.4.5.1, 31.12.08]
 
Hmmm also ich habe jetzt die "alte" Methode entfernt und sie neu deklariert:
Delphi-Quellcode:
function TAdVCLFormat.AssignTo(ABitmap: TAdBitmap;
  AGraphic: TObject): boolean;
var
  pc1, pc2: PCardinal;
  x, y: integer;
  bmp: TBitmap;
begin
  bmp := TBitmap.Create;
  try
    bmp.PixelFormat := pf32Bit;
    bmp.Width := ABitmap.Width;
    bmp.Height := ABitmap.Height;
// Ab hier habe ich das aus deinen Codesniplseln kopiert
    for y := 0 to bmp.Height - 1 do
    begin
      pc1 := bmp.Scanline[y];
      pc2 := ABitmap.Scanline(y);
      for x := 0 to bmp.Width - 1 do
      begin
        pc1^ := pc2^; //Inhalt ABitmap, Alpha $FF
        inc(pc1);
        inc(pc2);
      end;
    end;
// Bis hier
  finally
    bmp.free;
  end;
end;
Ergebnis war jedes mal eine weiße Fläche. Ich müsste auch bmp der Grafik zuweisen. Jetzt bekomme ich vernünftige Ergebnisse:
  1. Blaues Bitmap durchgehend (ohne Transparenzen)
  2. Weißes Bitmap (ohne Transprenzen wahrscheinlich (Hg war weiß))
  3. Inhalt der Grafik, Bläulich, "Hintergrund" ist schwarz
  4. Inhalt der Grafik, "Hintergrund" ist schwarz

Hier ist mein Workaround für weiße Hintergrundflächen:
Delphi-Quellcode:
function TAdVCLFormat.AssignTo(ABitmap: TAdBitmap;
  AGraphic: TObject): boolean;
var
  bmp: TBitmap;
  y, x: integer;            var i : Integer;

  LineIn, LineOut : PCardinal;
  LineInRec : LongRec;
begin
  result := true;

  bmp := TBitmap.Create;
  try
    bmp.PixelFormat := pf32Bit;
    bmp.Width := ABitmap.Width;
    bmp.Height := ABitmap.Height;

    for y := 0 to bmp.Height - 1 do
    begin
      LineIn := ABitmap.ScanLine(y);
      LineOut := bmp.ScanLine[y];
      for x := 0 to bmp.Width - 1 do
      begin
        LineInRec.Bytes[0] := 255 - LineIn^ shr 24;
        LineInRec.Bytes[1] := (LineIn^ shr 16) and $00FF;
        LineInRec.Bytes[2] := (LineIn^ shr 8) and $0000FF;
        LineInRec.Bytes[3] := LineIn^ and $000000FF;

        for i := 1 to 3 do
        begin
          if LineInRec.Bytes[0] < 255 - LineInRec.Bytes[i] then
            LineInRec.Bytes[i] := LineInRec.Bytes[0] + LineInRec.Bytes[i]
          else
            LineInRec.Bytes[i] := $FF;
        end;

        LineOut^ := $FF000000 or (LineInRec.Bytes[1] shl 16) or (LineInRec.Bytes[2] shl 8) or (LineInRec.Bytes[3]);

        Inc(LineIn);
        Inc(LineOut);
      end;
    end;

    TGraphic(AGraphic).Assign(bmp);
  finally
    bmp.Free;
  end;
end;
Wie man sieht längst nicht so performat wie dein Code, aber damit bekomme ich immerhin Transparenz.

Übrigens gibt es eine Möglichkeit bei deinem Canvas auch Kreis/Rechtecksringe zu zeichnen? Und wie sieht es mit abgerundeten Rechtecken aus?

Btw, wenn du möchtest könntest du noch folgende Funktionen implementieren (Dürfte es alle nicht geben):
Delphi-Quellcode:
function AdPoint(const APoint : TPoint) : TAdPoint; overload;
begin
  Result := AdPoint(APoint.X, APoint.Y);
end;

function AdRect(ACorner1, ACorner2 : TAdPoint; const APreventFlipOver : Boolean = true) : TAdRect; overload;
var
  CornerBuffer : TAdPoint;
begin
  if APreventFlipOver then
  begin
    if (ACorner1.X > ACorner2.X) or (ACorner1.Y > ACorner2.Y) then
    begin
      CornerBuffer := ACorner1;
      ACorner1 := ACorner2;
      ACorner2 := CornerBuffer;
    end;
  end;
  Result := AdRect(ACorner1.X, ACorner1.Y, ACorner2.X, ACorner2.Y);
end;

function AdRect(ACorner1, ACorner2 : TPoint; const APreventFlipOver : Boolean = true) : TAdRect; overload;
begin
  Result := AdRect(AdPoint(ACorner1), AdPoint(ACorner2), APreventFlipOver)
end;
MfG
xZise

xZise 5. Jan 2009 17:18

Re: Andorra 2D [Ver. 0.4.5.1, 31.12.08]
 
Was ist los :) Ist so still geworden, aber auch mit Workaround sieht die Transparenz schrecklich aus.

MfG
xZise

igel457 5. Jan 2009 17:48

Re: Andorra 2D [Ver. 0.4.5.1, 31.12.08]
 
Hallo,

ich habe deinen letzten Post ohne das Edit nur gelesen, deshalb wurde ich nicht darauf aufmerksam. Deinen "Workaround" muss ich mir mal genauer anschauen.

Deine AdPoint-Funktion lässt sich auch viel effizienter ohne Funktion schreiben (übrigens geht das genauso mit TAdRect):
Delphi-Quellcode:
var
  p1: TAdPoint;
  p2: TPoint;
begin
  p1 := PAdPoint(@p2)^;
end;
Mit der Transparenz schaue ich mal - wenn mich nicht alles täuscht, habe ich die Transparenzbehandlung ausgebaut: In den älteren Versionen habe ich das in das gegebene Bitmap übergeblendet. Ich dachte damals (als ich es ausgebaut habe) so was wie: "Wenn die VCL schon pf32Bit anbietet, dann verwende ich dass doch auch - da bekommt der Benutzer seine Daten auch so, wie sie sein sollen und nicht verfälscht." - Was auch stimmt, denn schließlich stehen die Daten 1 zu 1, so wie sie sein sollen im Speicher des Bitmaps. Ich denke hier sollte eher die VCL und nicht Andorra 2D gefixt werden. Du kannst ja mal Borland Inprise CodeGear Emba-irgendwas deswegen fragen ;-).

Das mit dem APreventFlip over baue ich lieber direkt ins Canvas ein. Wenn du Code für abgerundete Ecken schreibst, übernehme ich den auch gerne. Schau dir mal die Unit TAdCanvas an - du musst einfach nur eine Klasse von TAdCanvasObject ableiten und 3 oder 4 Funktionen implementieren. Aber achte darauf, dass die Texturkoordinaten, Farbverläufe und Normalen richtig gesetzt werden und du nirgendst Speicherüberläufe einbaust. Und dann musst du nur noch eine Funktion zu TAdCanvas hinzufügen, die dein Objekt erzeugt und auf die aktuelle DisplayList pusht. Also ganz einfach... :-)

Danke für die Vorschläge,
Andreas

3_of_8 5. Jan 2009 18:29

Re: Andorra 2D [Ver. 0.4.5.1, 31.12.08]
 
Tja, aber wie wir wissen können Bugfixes von größeren Softwareunternehmen eine Zeit dauern. Embarcadero heißen die Jungs übrigens momentan, aber wenn mans genau wissen will, sollte man das jeden Tag überprüfen, so oft wie sich das ändert. :mrgreen:

xZise 5. Jan 2009 18:41

Re: Andorra 2D [Ver. 0.4.5.1, 31.12.08]
 
Zitat:

Zitat von igel457
ich habe deinen letzten Post ohne das Edit nur gelesen, deshalb wurde ich nicht darauf aufmerksam. Deinen "Workaround" muss ich mir mal genauer anschauen.

Naja das ist das Problem mit den Edits ;)

Zitat:

Zitat von igel457
Deine AdPoint-Funktion lässt sich auch viel effizienter ohne Funktion schreiben (übrigens geht das genauso mit TAdRect):
Delphi-Quellcode:
var
  p1: TAdPoint;
  p2: TPoint;
begin
  p1 := PAdPoint(@p2)^;
end;

Okay stimmt das sollte gehen ;)

Zitat:

Zitat von igel457
Mit der Transparenz schaue ich mal - wenn mich nicht alles täuscht, habe ich die Transparenzbehandlung ausgebaut: In den älteren Versionen habe ich das in das gegebene Bitmap übergeblendet. Ich dachte damals (als ich es ausgebaut habe) so was wie: "Wenn die VCL schon pf32Bit anbietet, dann verwende ich dass doch auch - da bekommt der Benutzer seine Daten auch so, wie sie sein sollen und nicht verfälscht." - Was auch stimmt, denn schließlich stehen die Daten 1 zu 1, so wie sie sein sollen im Speicher des Bitmaps. Ich denke hier sollte eher die VCL und nicht Andorra 2D gefixt werden. Du kannst ja mal Borland Inprise CodeGear Emba-irgendwas deswegen fragen ;-).

Tja das nervt mich auch, dass die Transparenzbehandlung nicht die beste ist. Wobei ich jetzt nicht weiß, wie das mit Delphi 2009 aussieht. Das soll ja endlich png-Dateien unterstützen.

Zitat:

Zitat von igel457
Das mit dem APreventFlip over baue ich lieber direkt ins Canvas ein.

Könntest du auch machen ;) und so schlecht ist die Idee gar nicht ;)
Zitat:

Zitat von igel457
Wenn du Code für abgerundete Ecken schreibst, übernehme ich den auch gerne. Schau dir mal die Unit TAdCanvas an - du musst einfach nur eine Klasse von TAdCanvasObject ableiten und 3 oder 4 Funktionen implementieren. Aber achte darauf, dass die Texturkoordinaten, Farbverläufe und Normalen richtig gesetzt werden und du nirgendst Speicherüberläufe einbaust. Und dann musst du nur noch eine Funktion zu TAdCanvas hinzufügen, die dein Objekt erzeugt und auf die aktuelle DisplayList pusht. Also ganz einfach... :-)

:stupid: Ich habs mir auch angeschaut aber das ist noch etwas "unverständlich", aber ich kann natürlich mal genauer nach gucken :)

Btw: Du wolltest doch mal wissen, was alles Andorra 2D verwendet? Da könntest du auch den DrawBall Editor drauf setzen!

Und eine andere Frage: Ist es möglich ein "Screenshot" davon zu erstellen?

MfG
xZise

Florian H 6. Jan 2009 16:44

Re: Andorra 2D [Ver. 0.4.5.1, 31.12.08]
 
Grade gesehen: Könntest du bitte bei der Beschreibung von DrawBall auf der Andorra-HP ( http://andorra.sourceforge.net/index...ction=projects ) das "your balls" irgendwie ändern?
Durch das "your" ist das eigentlich schon ziemlich eindeutig als 'deine Eier' zu verstehen :mrgreen:

igel457 6. Jan 2009 16:48

Re: Andorra 2D [Ver. 0.4.5.1, 31.12.08]
 
Uuups :oops:

Ok, jetzt sind es "Murmeln", ohne "your"... Aber vorher war es doch auch ganz lustig. ;-)

3_of_8 6. Jan 2009 23:10

Re: Andorra 2D [Ver. 0.4.5.1, 31.12.08]
 
Here ye go, mate!

(Jemand mit einem englischen Lazarus könnte vielleicht noch mal überprüfen, ob die Menüpunkte so stimmen - wahrscheinlich nicht ganz, ich hab die einfach übersetzt und habe kein Lazarus, um es nachzuprüfen)

Zitat:

Andorra 2D - Compiling with Lazarus

Every beginning is difficult
To compile Andorra 2D with Lazarus, some particular issues have to be attended. Once those are taken care of, nothing stands in the way to use Andorra 2D even in Linux. This tutorial requires a working version of Lazarus as well as some knowledge in using it. Therefore, if any problems should occur with Lazarus that are not directly related to Andorra 2D (such as "Lazarus complains that 'Unit Interfaces could not be found', what should I do?"), please do not address them to me. Honest as I am, I have to admit I have not been working with Lazarus a lot myself, so if you have any more errors or suggestions for improvements, do not hesitate to inform me of them.


Compiling the plugin
The first difficulty to overcome is the fact that plugin DLLs compiled with Delphi are not compatible with Lazarus, which is quite logical as the internal Delphi compiler and the Free Pascal Compiler (which is used by Lazarus) are two different programmes, which were developed independently from one another. As a consequence of this, the class structure created by Free Pascal has become incompatible to Delphi's, but Andorra 2D exchanges objects between the library and the host application, which inevitably results in access violations.
We avoid this problem simply by recompiling the plugin library with Lazarus. For this, we open the file "AndorraOGL.lpi" in the directory "src/dll/opengl/" with Lazarus. However, before we can simply compile this file, we have to set up the search paths and the output directories accordingly.
To do this, we enter the path to the OpenGL header and the path to the Andorra 2D surce files via "Project->Compiler settings->Paths->Other unit files->...". If there should be any problems with unit files that cannot be found, just adding the "path templates" can help. Especially in Linux Andorra 2D only wanted to compile with those.
http://andorra.sourceforge.net/tutots/lazarus/img1.png
Apart from this, "../../dcu/" should be entered in "unit output path" in the paths dialogue and "../../../bin/" in "Project->Project settings->Target file name". Now we can compile the library with a click on "Start->Recompile all". If you are lucky enough to get the message "Project 'AndorraOGLLaz' built successfully. ;)", you should also make sure that the plugin was really recompiled. FOr this, take a look at the target directory and check the change date of "AndorraOGLLaz.dll".
As you may have noticed, the file name of the Lazarus DLL differs from that of the Delphi DLL to avoid confusion.
If everything went well until now, there is not much in the way of taking a trip to the world of Andorra 2D with the help of Lazarus now.


Our Lazarus Andorra 2D project
Now we want to create a simple Andorra 2D project with Lazarus. For that, we create a new "Application" project with "File->New" and add the Andorra 2D search path just like we did when compiling the OpenGL plugin. Also, it might be necessary to add the package "LazOpenGLContext" to your project when using another widget set than "Win32/Win64". (in Linux, for example)
http://andorra.sourceforge.net/tutots/lazarus/img2.png


About windows systems and device contexts
This necessity has the following background: When using the normal Windows widget set, Andorra 2D can also forward a handle (the inventory number of our window, in a manner of speaking) to the plugin library. After that, the plugin handles creating the according device context itself. (Which is done with a few lines in Windows) This is the area our graphics card or the used window graphics system can draw on. However, the device context has to be managed by the window system in use. In Linux, a multitude of window systems exists. (some of which can be selected as a widget set in Lazarus) Now the plugin would need to have a context creation routine for each of these systems, which would of course be an enormous effort. Luckily, the busy developers of Lazarus have thought of something for that, too: The component "TOpenGLControl", which creates a device context adapted to our selected window system and operating system for our application, which the plugin can draw on directly. Alternative windows frameworks, such as the GLFW framework work the same way. There is more information about this in the tutorial "About the Andorra 2D window frameworks".


Some code...
Now we just need some code to test Andorra 2D with Lazarus:
Delphi-Quellcode:
procedure TForm1.FormCreate(Sender: TObject);
begin
  AdDraw := TAdDraw.Create(self);
  AdDraw.DllName := 'AndorraOGLLaz.dll';
  Application.OnIdle := @Idle;
  AdDraw.Initialize;
end;

procedure TForm1.FormDestroy(Sender: TObject);
begin
  AdDraw.Free;
end;

procedure TForm1.Idle(Sender: TObject; var Done:boolean);
begin
  AdDraw.ClearSurface(0);
  AdDraw.BeginScene;
  with AdDraw.Canvas do
  begin
    Font := AdDraw.Fonts.GenerateFont('Arial', 24, []);
    TextOut(0,0,'Andorra 2D...');
    Font := AdDraw.Fonts.GenerateFont('Arial', 10, []);
    TextOut(0,30,'...works with Lazarus too');
  end;
  AdDraw.EndScene;
  AdDraw.Flip;
end;
To prevent problems, it has proven useful to replace the line
Delphi-Quellcode:
{$mode objfpc}{$H+}
at the beginning of the unit with this one:
Delphi-Quellcode:
{$MODE DELPHI}
http://andorra.sourceforge.net/tutots/lazarus/img3.png

Copyright and licence
(c) by Andreas Stöckel, February 2008

The content of this tutorial subjects to the GNU Licence for Free Documentation.

xZise 7. Jan 2009 00:48

Re: Andorra 2D [Ver. 0.4.5.1, 31.12.08]
 
Wow .... Mal eben ein abgerundetes Rechteck zu zeichnen ist nicht ohne, wenn ich mir den Code des Rechtecks anschaue. Also ein Großteil habe ich verstanden, wobei ich bei procedure TAdCanvasQuadObject.Generate; noch nicht so den Durchblick habe :D

By the way:
Zitat:

Zitat von igel457
[...]du nirgendst Speicherüberläufe einbaust.[...]

Kreis ohne Füllung -> IntegerÜberlauf :stupid:

Und eine Frage bei dem Kreis:
Die Anzahl der Schritte sind ja: 2 * PI * r * (0,1/(0,01 * r))
Wenn mich nicht alles täuscht lässt sich das vereinfachen:
2 * PI * r * ((1/10)/(1/100)) * (1/r) | Mit dem Kerwert malnehmen
2 * PI * r * (100/10) * (1/r)
2 * PI * r/r * 10
2 * PI * 10
20 * PI

Siehe TAdCanvasEllipseObject.Generate:
Delphi-Quellcode:
steps := round(Pi * 2 * ar * (0.1/(ar*0.01)));
Wozu so kompliziert :) Abgesehen davon wird der Kreis bei größerem Radius immer schlechter, da es immer 63 Ecken sind.

Übrigens wie kann es sein, dass ein Kreis mit der SimpleDemo gezeichnet kein IntegerÜberlauf verursacht, während er in meinem Editor (komischerweise seit kurzem) einen solchen verursacht?

Ich habe mein WorkAround verbessert, da vorher es zu Integerüberläufen kam.

MfG
xZise

Codewalker 11. Jan 2009 12:45

Re: Andorra 2D [Ver. 0.4.5.1, 31.12.08]
 
Warum ist das Property Name einer TAdImageList noch ein AnsiString, während alles andere ein String ist. Das könnte unter Delphi 2009 doch ein Problem geben, oder irre ich mich?

igel457 11. Jan 2009 17:15

Re: Andorra 2D [Ver. 0.4.5.1, 31.12.08]
 
Weil ich den Namen der Images direkt in eine Datei Speichere/daraus Lade - dort eben mit 8 Bit pro Char.

xZise 11. Jan 2009 22:14

Re: Andorra 2D [Ver. 0.4.5.1, 31.12.08]
 
Zitat:

Zitat von Codewalker
Warum ist das Property Name einer TAdImageList noch ein AnsiString, während alles andere ein String ist. Das könnte unter Delphi 2009 doch ein Problem geben, oder irre ich mich?

Naja, weil wahrscheinlich intern in die Datei auch ein AnsiString gespeichert wird. Könnte unschön sein.

Aber was anderes: Wäre es möglich dem TSprite eine Eigenschaft "DefaultDraw" zu verpassen? Weil, ich würde den Cursor bei mir nämlich selber zeichnen (nachdem alles andere gezeichnet wurde). Aber wenn ich einmal "SpriteEngine.Draw" und "Cursor.Draw" mache habe ich es ja doppelt. Deshalb dachte ich, wenn "DefaulDraw" auf "false" steht, zeichnet er es nur, beim expliziten Aufruf von ".Draw" ansonsten auch, wenn die "Mutterklasse" ".Draw" aufruft.

Btw, kann ich jetzt "Rechtecksringe" zeichnen (Kreisringe halt in rechtecksform) und auch abgerundete Rechtecke (wenn auch nicht vollständiger Support).

MfG
xZise

3_of_8 12. Jan 2009 12:10

Re: Andorra 2D [Ver. 0.4.5.1, 31.12.08]
 
Was ist denn ein "Kreisring in Rechtecksform"? Meinst du eine Ellipse? :gruebel:

stefan2005 12. Jan 2009 14:58

Re: Andorra 2D [Ver. 0.4.5.1, 31.12.08]
 
Zitat:

Zitat von 3_of_8
Was ist denn ein "Kreisring in Rechtecksform"? Meinst du eine Ellipse? :gruebel:

Warscheinlich meint er diese Rechtecke mit abgerundeten Ecken :)
(in Paint gibt es auch so eine Form namens "Gerundetes Rechteck")

xZise 12. Jan 2009 16:14

Re: Andorra 2D [Ver. 0.4.5.1, 31.12.08]
 
Nein ^^ Einfach ein Kreisring in rechtecker Form ...
Code:
________
| ____ |
| |  | |
| |__| |
|______|
Mehr nicht :)

MfG
xZise

3_of_8 12. Jan 2009 17:24

Re: Andorra 2D [Ver. 0.4.5.1, 31.12.08]
 
Dann würde ich es aber nicht "Kreisring" nennen, weil das überhaupt nichts mit einem Kreis zu tun hat. ;)

xZise 12. Jan 2009 17:31

Re: Andorra 2D [Ver. 0.4.5.1, 31.12.08]
 
KreisRING ist ein Kreis wo in der Mitte ein Kreis fehlt. Und ein Rechteckiger Kreisring ist ein Rechteck ohne Rechteck in der Mitte ;)

MfG
xZise

3_of_8 16. Jan 2009 16:45

Re: Andorra 2D [Ver. 0.4.5.1, 31.12.08]
 
Eine weitere Übersetzung - inherited bestand drauf. :mrgreen:

Zitat:

The FreeImage library in Linux

As there have been and still are problems using the FreeImage library with Andorra in Linux, I decided to write this small tutorial, which describes the basic process of compiling, installing and using this free graphics library and avoids possible sources of trouble.

-1. What is FreeImage?
FreeImage is an open source and free of charge graphics library with which many different graphics formats can be loaded and displayed. A complete list of the supported formats can be found at http://freeimage.sourceforge.net/features.html.

0. Determining whether FreeImage is in the packages
In some Linux distributions it is possible that the library is already in the package sources. This renders the manual compiling unnecessary and saves a lot of time.
However, I am quite sure that it does not exist neither in Debian and Ubuntu nor in SUSE Linux or Arch Linux as a precompiled package. Should it exist in your distribution nevertheless, you can skip the following steps until "Using FreeImage in Andorra"

1. Downloading FreeImage
Go to http://freeimage.sourceforge.net/download.html and download the source package (source distribution). A ZIP file named "FreeImage3100.zip" is created. The 3100 here is the version. At the moment of writing this document, 3.10.0 was the most recent version. Even if there is a more recent version available, the process described here should be applicable without further ado, only the commands containing the version number have to be adjusted.

2. Unpacking the archive
Unpack the archive either with a graphical decompressor or via command line using:
Delphi-Quellcode:
$ unzip FreeImage3100.zip
and browse to the created directory "FreeImage".
Delphi-Quellcode:
$ cd FreeImage
3. Compiling FreeImage
Because FreeImage does not require any configuration, it should be possible to compile it directly. To do that, just call "make" in the command line in the directory "FreeImage":
$ make
Now it's time for a small coffee break while the library is being translated. Normally you should get an output similar to the following after a few minutes showing that compiling has been completed successfully:
Delphi-Quellcode:
cp *.a Dist
cp *.so Dist
cp Source/FreeImage.h Dist
make[1]: Leaving directory `/some/directory/FreeImage'
Should an error message be displayed instead, something went wrong. This can have several, often possibly highly diverse, reasons. In this case, try to get information about the problem from the internet or write directly to the Free Image developing team. You can also write an e-mail to me. You can find the address at the end of the tutorial.

4. Installing FreeImage
If everything went well until now, you can install the library by calling
Delphi-Quellcode:
$ make install
in the FreeImage directory with root privileges. After that, a file named "libfreeimage.so" should have been created in /usr/lib.

5. Using FreeImage in Andorra
Now we get to the most exciting part of the tutorial: Including the library in Andorra. Thanks to modular interface system, this is very simple, a corresponding wrapper is also available already. All you have to do is to include the unit "AdFreeImage.pas" in your main unit. From now on, it is tried to load graphics files you load, with an image list, for instance, with the FreeImage library.


6. Troubleshooting

Unfortunately, errors occur, which is why I try to address the most common errors here.

"Wenn I try to load a graphics file with FreeImage, my programme crashes with the error 'SIGSEGV'."
This error is often an indication of a wrong call convention. Unfortunately, there are obviously differences between the FreeImage versions, and as a consequence of that, both the names of the supplied functions and the call conventions are partially different. Because I don't know the reasons for this yet, some compiler switches have been added to the wrapper to change the call convention as easily as possible. This switch is located in the unit "FreeImage.pas" in the subdirectory "lib" in the Andorra directory, it is called "FIcdecl" and is active in non-Windows systems by default. When it is activated with {$define Ficdecl}, the convention "cdecl" is used instead of "stdcall". Should the same error still occur, please do not hesitate and send me an e-mail.

"Wenn I try to compile the project, I get the error 'undefined reference to 'FreeImage_Initialise@4' or something like that."
This error also has to do something with the library's different versions mentioned above. Try to activate or deactivate the compiler switch "FINoPrefix" in the unit "FreeImage.pas". Should that not help, please send me an e-mail.

"When compiling, I get the error 'Fatal: Can't find unit AdPNGUtils used by AdFreeImage'"
This is apparently a bug of Lazarus or FreePascal that only occurred in my case. Should the same error happen in your case, try deleting the entry "AdPngUtils" in the "uses" clause of the "AdFreeImage" unit and adding it again and pay attention to the capitalisation. After that, it should compile.

7. If there are any more open questions...
do not hesitate and send me an e-mail to nwyderka at stud.informatik.uni-goettingen.de or take a look into the Delphi-PRAXiS at www.delphipraxis.net. We're happy to help you.

Und eine deutsche Version des englischen Tutorials über Andorra auf i386/amd64-Linux:
Zitat:

Der Sourceforge-Benutzer Nyrel hatte Probleme, als er Andorra 2D auf seinem Linux-System verwenden wollte. Er hat eine Anleitung geschrieben, um allen anderen Andorra 2D-Benutzern zu helfen, die versuchen, das selbe zu tun.

Andorra 2D 0.4.5.1 auf Linux i386 und amd64 zum Laufen bekommen
Ich habe diese Anleitung auf meinem ThinkPad-Notebook (i386, kubuntu 8.10, fpc 2.2.2, lazarus 0.9.26) und auf meinem PC (amd64, kubuntu 8.04 64bit, fpc 2.2.2, lazarus 0.9.27 SVN-Version etwa vom 1.1.2009) überprüft.

Voraussetzungen:
Eine funktionierende Installation von FPC und Lazarus.

Ich habe mich dazu entschieden, diese Anleitung Schritt für Schritt zu machen und alle dazwischenliegenden Fehlermeldungen zu zeigen, die man erhalten kann, bis alles richtig installiert ist. Dies kann vielleicht anderen helfen, diesen Thread zu finden, wenn sie nach ihren Fehlermeldungen suchen.

Es ist zu beachten, dass die gleichen Fehlermeldungen, die man erhält, aufgrund von Unterschieden in der Systemkonfiguration etwas anders sein können. Zögern Sie nicht, neue Fehlermeldungen und (hoffentlich) Lösungen zu diesem Thread hinzuzufügen.

Andorra 2D installieren
Laden Sie Andorra 2D herunter und entpacken Sie es in das Verzeichnis, in das sie es installieren wollen. Ich werde das folgende verwenden:
~/program/andorra


Erzeugen eines Testprojekts - Teil 1
Öffen Sie das SimpleNonVCL-Projekt in Lazarus. Dieses finden Sie hier:
~/program/andorra/demos/Simple/SimpleNonVCL/NoVCL.lpi

Drücken Sie F9 um zu versuchen, es zu kompilieren und auszuführen. Sie werden jedoch nicht weit kommen, weil es einige Dinge gibt, die sie ändern müssen:

Fehler 1:
Main.pas(50,31) Error: Identifier not found "ReportMemoryLeaksOnShutdown"
(Main.pas(50,31) Fehler: Bezeichner nicht gefunden: "ReportMemoryLeaksOnShutdown")

Lösung 1:
Einfach auskommentieren

Fehler 2:
/usr/bin/ld: cannot find -lfreeimage
/usr/bin/ld: -lfreeimage kann nicht gefunden werden

Lösung 2:
Die FreeImage-Bibliothek muss installiert werden. Starten Sie den Paketmanager für Ihre Linuxdistribution, (adept, synaptic, rpmdrake, etc.) suchen Sie nach FreeImage und installieren Sie es. Bei meinem System hieß das Paket "libfreeimage3".

Fehler 3 (noch einmal):
/usr/bin/ld: cannot find -lfreeimage
/usr/bin/ld: -lfreeimage kann nicht gefunden werden

Lösung 3:
Die FreeImage-Bibliothek kann nicht gefunden werden, weil die Bibliotheksdatei /usr/lib/libfreeimageplus.so.3 statt /usr/lib/libfreeimageplus.so heißt. Erzeugen sie eine symbolische Verknüpfung, um dies zu korrigieren:

sudo ln -s /usr/lib/libfreeimage.so.3 /usr/lib/libfreeimage.so

Mehr Informationen über das Problem mit FreeImage können in dem FreeImage-Tutorial-Tutorial nachgelesen werden. Sie müssen FreeImage nicht mit Andorra 2D verwenden. Die FreeImage-Bibliothek wird nur in dieser Demo dazu verwendet, PNG-Bilder zu laden. Sie können auch die Units "AdPNG" und "AdDevIL" statt "AdFreeImage" ausprobieren.

Fehler 4:
/usr/bin/ld: -lGL kann nicht gefunden werden

Lösung 4:
Wieder der falsche Name für die Bibliotheksdatei. Erzeugen Sie eine symbolische Verknüpfung:
sudo ln -s /usr/lib/libGL.so.1 /usr/lib/libGL.so


Ab hier kompiliert das Projekt erfolgreich auf meinem System. Aber es stürzt ab, wenn es ausgeführt wird.


Fehler 5:
Exception while creating process: Executable not found: "xterm"
(Exception beim Erzeugen des Prozesses: Ausführbare Datei "xterm" nicht gefunden)

Lösung 5:
Installieren Sie xterm mit ihrem Paketmanager. Normalerweise ist es bereits installiert, aber das war auf einer fast neuen kubuntu 8.10-Installation.

Fehler 6:
Exception: No compatible Andorra 2D plugin library found.
(Exception: Keine kompatible Andorra 2D-Pluginbibliothek gefunden)

Diese Exception tritt beim folgenden Befhler auf:
Main.pas, 65: AdDraw.DllName := DefaultPlugin
Dieser Fehler ist absolut in Ordnung zu diesem Zeitpunkt, da wir noch keine Plugins kompiliert haben. Lassen Sie uns zum nächsten Teil kommen.


Erzeugen der Andorra-Pluginbibliothek - Teil 1
Öffnen Sie das andorraOGL-Projekt:
~/program/andorra/src/dll/opengl/andorraOGL.lpi

Gehen Sie zu Projekt->Projektoptionen und ändern Sie den Namen des erzeugten Kompilats von:
../../../bin/AndorraOGLLaz.dll

nach:
../../../bin/libAndorraOGLLaz.so

Versuchen Sie, das Projekt mit Strg-F9 zu erzeugen.

An dieser Stelle sollte das Projekt erfolgreich kompilieren, wenn Sie einen i386 verwenden und Sie können mit "Erzeugen eines Testprojekts - Teil 2" fortfahren.

Wenn Sie ein 64 Bit-System verwenden, gibt es noch ein paar Probleme zu lösen.


Fehler 7:
/usr/bin/ld: ~/program/andorra/src/dcu/AdClasses.o: relocation R_X86_64_32S against _$ADCLASSES$_Ld1' can not be used when making a share object; recompile with -fPIC
(/usr/bin/ld: ~/program/andorra/src/dcu/AdClasses.o: Relokation R_X86_64_32S gegen _$ADCLASSES$_Ld1' kann nicht verwendet werden, wenn ein gemeinsam genutztes Objekt erzeugt wird; Kompilieren Sie noch einmal mit -fPIC.)

Lösung 7:
Ich weiß nicht genau, worum es da geht, aber lassen Sie uns einfach dem Rat folgen und mit "-fPIC" neu kompilieren. Gehen Sie zu Projekt->Compilereinstellungen->Andere und schreiben Sie -fPic in das Feld für benutzerdefinierte Optionen.

Jetzt sollte das Projekt richtig kompilieren, aber es müssen immer noch einige Probleme gelöst werden, bevor es wirklich funktioniert. Wir kommen gleich dazu!


Erzeugen eines Testprojekts - Teil 2
Also Sie das AndorraOGL-Projekt oben erzeugt haben, hat es eine Pluginbibliotheksdatei in Andorras bin-Verzeichnis (~/program/andorra/bin) erstellt. Wir brauchen diese Datei, um das Testprojekt zum Laufen zu bekommen, also kopieren Sie die Bibliotheksdatei in Ihr Projektverzeichnis:

cp ~/program/andorra/bin/libAndorraOGLLaz.so ~/program/andorra/demos/Simple/SimpleNonVCL/

Öffnen Sie erneut das das SimpleNonVCL-Projekt in Lazarus und drücken Sie F9 um zu versuchen, es auszuführen.

Wenn Sie einen i386 verwenden, sollte dieses mal alles funktionieren und sie sollten ein schwarzes Fenster mit einem Andorra-Logo und einem Text, der den Mauszeiger verfolgt, sehen.

Wenn Sie immer noch eine Exception bei der Zuweisung von DllName erhalten, können Sie versuchen, diese Zeile von:
Delphi-Quellcode:
AdDraw.DllName := DefaultPlugin
nach:
Delphi-Quellcode:
AdDraw.DllName := './libAndorraOGLLaz.so'
zu ändern. Wenn Sie jedoch einen amd64 verwenden, werden Sie eine Exception bei der Initialisierung von OpenGL erhalten.

Fehler 8:
Main.pas: AdDraw.Initialize ->
AdDraws.pas, 1453: AdAppl.Initialize(FWnd) ->
OGLMain.pas, 249: InitOpenGL ->
dglOpenGL, 8848: glXGetProcAddress := glProcedure('glXGetProcAddress');
dglOpenGL, 8809: Result := GetProcAddress(LibHandle, ProcName);
dglOpenGL, 8702: Result := dlsym(Pointer(LibHandle), ProcName);


Der Fehler tritt in der Funktion LoadLibrary auf, in der der Rückgabewert von dlopen auf ein THandle gecastet wird. Das Problem ist, dass THandle als 32 Bit groß definiert ist, aber der Rückgabewert 64 Bit groß ist.

Delphi-Quellcode:
function LoadLibrary(Name: PChar): THandle;
begin
  Result := THandle(dlopen(Name, RTLD_LAZY));
end;
Also müssen wir das in der Pluginbibliothek ändern.

Erzeugen der Andorra-Pluginbibliothek - Teil 2
Öffnen Sie das andorraOGL-Projekt noch einmal.

Lösung 8:
Die Lösung ist, eine neue Typendefinition von THandle überall hinzuzufügen, wo es auftaucht:

~/program/andorra/src/dll/opengl/OGLShader.pas:
118: function TOGLShaderSystem.LoadShaderPlugin(AID: TAdVeryShortString): boolean;
119: type // Added
120: THandle = Int64; // Neu


~/program/andorra/lib/dglOpenGL.pas:
225: type
226: THandle = Int64; // Neu


Dieser Fehler sollte bei neuen Versionen von Andorra 2D (neuer als 0.4.5.1) behoben sein.

Nun sollten Sie in der Lage sein, das Projekt erfolgreich zu kompilieren und eine gültige 64 Bit-Pluginbibliothek zu kompilieren. Mit der neuen Version von libAndorraOGLLaz.so sollte es auch möglich sein, das Testprojekt erfolgreich zu kompilieren und auszuführen!

Ich habe mich durch die Tutorials auf der Andorra-Webseite gearbeitet und bist jetzt habe ich das Sprite-Engine-Tutorial ohne (größere) Probleme abgeschlossen.

Hinweis: THandle wird auch in einigen anderen Dateien verwendet. (suchen Sie einfach danach) Es ist wahrscheinlich eine gute Idee, seine Neudefnition auch zu ihnen hinzuzufügen, aber die Änderungen oben sind genug, um alles erstmalig zum Laufen zu bekommen.

Im Übrigen fehlt bei beiden Originaltutorials der Hinweis auf den Autor und die Lizenz ganz unten, und daher auch hier in den Übersetzungen. Im englischen Original des zweiten Tutorials kann der Hinweis darauf, dass es das FreeImage-Tutorial nur auf Deutsch gibt, nun entfernt werden.

igel457 17. Jan 2009 21:16

Re: Andorra 2D [Ver. 0.4.5.1, 31.12.08]
 
Hallo 3_of_8,

erstmal Entschuldigung, dass ich erst so spät antworte - ich hatte (habe) in letzter Zeit einiges zu tun und habe deinen Post irgendwie verdrängt.

Auf jeden Fall vielen Dank für die Übersetzungen, ich habe die Tutorials hochgeladen. :thumb:

Andreas

Florian H 18. Jan 2009 01:44

Re: Andorra 2D [Ver. 0.4.5.1, 31.12.08]
 
Zitat:

Zitat von igel457
erstmal Entschuldigung, dass ich erst so spät antworte - ich hatte (habe) in letzter Zeit einiges zu tun und habe deinen Post irgendwie verdrängt.

Hast du den Post auch verdrängt? :stupid:
http://www.delphipraxis.net/internal...=984564#984564
:)

3_of_8 18. Jan 2009 10:59

Re: Andorra 2D [Ver. 0.4.5.1, 31.12.08]
 
Kein Problem. Jetzt sind eh nur noch drei übrig, mal schauen, wann ich die angreife.

Romi 18. Jan 2009 21:14

Re: Andorra 2D [Ver. 0.4.5.1, 31.12.08]
 
Zitat:

Zitat von 3_of_8
Kein Problem. Jetzt sind eh nur noch drei übrig, mal schauen, wann ich die angreife.

Ich hatte die letzten Wochen viel zu tun, deshalb dauerts etwas, aber Particle ist bei mir halb fertig. Nur das du damit nicht anfängst ;)

Codewalker 21. Jan 2009 14:36

Re: Andorra 2D [Ver. 0.4.5.1, 31.12.08]
 
Ich hätte noch eine Anregung/Bitte: Könnte man jedem Item in der TAdImageList noch ein String-Feld hinzufügen, dass man zur freien Verwendung nutzen kann und per AdImgEdit auch mit Text belegen kann? Hintergrund: Ich würde gerne Bilder in der Liste mit Tags/Kategorien versehen. Wäre so etwas möglich oder habt ihr eine alternative Idee? (Der Name des Bildes kommt nicht in Frage, soll schon ein anderes Feld sein)

xZise 21. Jan 2009 15:42

Re: Andorra 2D [Ver. 0.4.5.1, 31.12.08]
 
Naja du könnest gucken, ob du vielleicht an den Bilddaten noch Informationen dranhängen kannst?

MfG
xZise

Florian H 23. Jan 2009 16:55

Re: Andorra 2D [Ver. 0.4.5.1, 31.12.08]
 
Gibts eigentlich irgendwo eine Demo oder ein Tut bezüglich "Lights"?
Würde mir das gerne mal anschauen, aber das ganze rein über die Doku zu machen ist sehr anstrengend und oft von Misserfolg gekrönt ...

igel457 23. Jan 2009 17:12

Re: Andorra 2D [Ver. 0.4.5.1, 31.12.08]
 
Hallo,

"Lights" sind eigentlich nur am besten für 3D-Modelle geeignet. Schau dir mal die "Simple3D"-Demo an, dort verwende ich ein Lichtobjekt.

Für reine 2D-Anwendungen würde ich (wie in der Bounce-Demo) einen Lichtkreis additiv auf die Szene zeichnen.

Edit:
@Codewalker: Ich habe vor irgendwann das ImageList-Dateiformat auf etwas dynamischeres Abzuändern, ich hatte da an etwas XML-Basiertes mit Binärdatenteil gedacht. Aber vorerst möchte ich noch nichts daran ändern.

@FlorianH: Wegen deinem Problem mit den Surfaces: Eine (suboptimale) Lösung ist, den Hintergrund nicht in der GPU zu rendern, sondern das ganze in die CPU auszulagern. "TAdBitmap"s kannst du mit TAdBitmap.DrawBitmap aufeinanderzeichnen. Dabei musst du ja nur die veränderten Farbkleckse zeichnen. Woran das Problem mit dem DirectX-FBO liegt, habe ich bis jetzt noch keine Ahnung - bei mir (Radeon 9800/ HD 4650) funktioniert es ja.

igel457 28. Jan 2009 21:16

Re: Andorra 2D [Ver. 0.4.5.1, 31.12.08]
 
Hallo,

gerade habe ich in Andorra 2D die Möglichkeit zum Laden von 3D-Modellen eingebaut. Wie alles andere auch, findet das Laden in modularer Weise statt. So können Loader für die verschiedenen Modelformate einfach durch hinzufügen zur Uses-Klausel eingebunden werden (so mache ich das ja auch schon bei den Bildformaten.)

Momentan arbeite ich an einem Loader für 3DS (Danke hierbei an Noeska, dessen Bibliothek "glModel" ich hierbei teilweise als Referenz für das 3DS Dateiformat missbrauche). Die entsprechende Unit gibt es hier zum Anschauen: http://andorra.cvs.sourceforge.net/v...as?view=markup

Aktuell lade ich weder Texturen/-koordinaten noch Materialien aus der 3DS-Datei, doch das kommt in den nächsten Tagen noch.

Weitere Formate, die ich unterstützen möchte sind .X und .OBJ

Außerdem habe ich einen "Maskottchen Wettbewerb" gestartet, bei dem ich ein 3D-Maskottchen für die Verwendung in den 3D-Demos von Andorra 2D suche.
Siehe: http://www.delphipraxis.net/internal...t.php?t=151171

Kommentare sind wie immer erwünscht, ;-)
Andreas

Codewalker 29. Jan 2009 09:54

Re: Andorra 2D [Ver. 0.4.5.1, 31.12.08]
 
Supi, dann kann ich in meinem Spiel vielleicht das Würfeln tatsächlich mit fallenden Würfeln darstellen (wobei man ja dann noch die Newton-Physics für Modelle oder Boxen bräuchte. Planst du das zufällig auch?).

Wann gibt es denn von dir den nächsten zusammengepackten Release?

3_of_8 29. Jan 2009 14:46

Re: Andorra 2D [Ver. 0.4.5.1, 31.12.08]
 
Es gibt ein altes Projekt von mir, in dem Loader für MD2 und MS3D sowie Anbindungen an Newton enthalten sind - wenn ich mal viel Zeit habe, kann ich schauen, in wie weit ich das in Andorra integrieren kann.

3_of_8 27. Mär 2009 21:27

Re: Andorra 2D [Ver. 0.4.5.1, 31.12.08]
 
Another wee translation for ye. ;)

(Es heißt im Übrigen "das Partikel", nicht "der Partikel". "die Partikel (sing.)" gibt es auch, aber damit ist ein Wort gemeint, das nicht gebeugt wird)

Zitat:

Andorra 2D tutorials
Particle systems


What are particle systems?
You want to use graphical effects such as explosions or magic spells many times in your game.
To do this, so-called "particle systems" are often used. As the name suggests, particle systems consist of single "particles", which in turn are mostly rather unspectacularly looking images that move in a certain direction and disappear again after some time:
http://andorra.sourceforge.net/tutots/particle.png
If you have several of these particles, you get this effect:
http://andorra.sourceforge.net/tutots/part1.png
The particle system manages the particles and their movements.

Particle systems Andorra 2D

Loading particles
In Andorra 2D, there is the class "TAdParticleSystem" in the unit "AdParticles".
The class expects a parameter of the type "TAdDraw" in its constructor specifying the surface which the output should be displayed on.
To create particles, you have to assign the particle's image first.
This is done by the following code:
Delphi-Quellcode:
//Creating the particle system
partsys := TAdParticleSystem.Create(AdDraw);
//Assigning the image
partsys.Texture := AdImageList.Items[0].Texture;
To achieve the best effect, make sure the particle has an alpha channel. Use this image, for example. (Note that in order to load PNG images you have to include the AdPNG unit and the library PNGDelphi has to be in the search path, if needed).

Now we're already done. Add the following line to your rendering routine:
Delphi-Quellcode:
partsys.Emit(1, 0, 0);
This line adds a new particle to the particle system at the position 0,0. The particle system has its own coordinate system in which the particles move. We create our new particle at the origin of ordinates.

Now we have to tell the particle systems to move its particles and draw them. This is done by the following lines:
Delphi-Quellcode:
PartSys.Move(AdPerCounter.TimeGap / 1000);
partsys.Draw(bmAdd, AdDraw.DisplayRect.Right / 2, AdDraw.DisplayRect.Bottom / 2);
The coordinate system's point of origin is temporarily moved to the centre point of the screen, so that new particles also appear there.
Do not forget to also free the particle system in the end and execute the programme:
http://andorra.sourceforge.net/tutots/part3.png

If you want to have the source code, take a look at the demo "demos\Particles\Simple\simplepart". Or take a look at this: http://andorra.cvs.sourceforge.net/a...iew=markup#l_1

The behaviour of particles
As you have seen, the particles have a default behaviour. But where does it come from?
To find that out, we take a look at how the "emit" function of the particle system works in detail:
http://andorra.sourceforge.net/tutots/creation.png
In the beginning, the specified amount of particles is created, which inherit their properties from the particle system's "default particle". Then the fuction "SetupMovement" of each particle is called, in which a movement vector is generated.
To change the overall appearance of the particle system, you only have to adjust the properties of the default particle. To adjust the life time of the particles, for example, write the following:
Delphi-Quellcode:
PartSys.DefaultParticle.LifeTime := 2; //Specified in seconds
You can adjust the particles' properties with the comfortable particle editor (parted.exe). Just play around with it a bit. You can also write the particles into a file with it and load them again with:
Delphi-Quellcode:
PartSys.DefaultParticle.LoadFromFile('particle.apf');
Note that the image you have loaded into the particle editor is not saved into the file.

That was virtually everything there is to say about particles.

Custom particle classes
If you want to create particles with a chaotic movement pattern, you can derive your own particle class, which you can pass on to the particle system by assigning the default particle. Take a look at the source code of TAdStdParticle or TAdBillboardParticle respectively. It's the easiest way to derive your own particle class from those.

Particles in the sprite engine
The class "TParticleSprite" exists to use particle systems in the sprite engine. It has its own particle system. You can also tell it how many particles to create per second. This, however, is a chapter on its own and will be covered separately in the sprite engine tutorials.

Copyright and licence
(c) by Andreas Stöckel February 2007
Translation by 3_of_8 (Manuel Eberl)

The content of this tutorial is subject to the GNU Licence for Free Documentation.


Alle Zeitangaben in WEZ +1. Es ist jetzt 06:34 Uhr.
Seite 23 von 26   « Erste     13212223 2425     Letzte »    

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
LinkBacks Enabled by vBSEO © 2011, Crawlability, Inc.
Delphi-PRAXiS (c) 2002 - 2023 by Daniel R. Wolf, 2024-2025 by Thomas Breitkreuz