Mes programmes OpenSource
Pour une offre professionnelle, consultez mon site http://www.execute.re.Kylix - Sources Borland Kylix (Linux)
Kylix 1 DirectX MD2 MD2T KCyber OpenGL DCal3D
MD2T MD2 Viewer avec Textures
Téléchargez les sources complets !
Cette nouvelle version supporte les textures; elle n'utilise ni OpenGL ni DirectX, elle est entièrement codée en Pascal à partir de TBitmap.ScanLine.
Du coup c'est complètement compatible Delphi 5 et Kylix BETA 4.
Pour le fun, j'ai ajouté le support de Delphi 2 avec une gestion par API Windows...SetDiBitsToDevice()
Je n'ai malheureusement pas réussit à faire fonctionner la version API XWindow...XPutImage() mais j'ai laissé le code dans le source de "Just3D.pas"
{ Interface de Just3D.PAS }
{ Initialisation de l'environnement 3D }
procedure Init3D(width,height:integer);
{ Chargement et application des Textures }
Function LoadBMP256(FileName:string):integer;
Function SetTexture(index:integer):boolean;
{ Effacer le bitmap offline }
Procedure ClearPixels;
{ Tracé d'un polygon texturé
x,y coordonnées du point à l'écran (en 2D)
z profondeur du point (en 3D)
u,v position du point sur la texture
s niveau d'ombrage (shade) du point
BeginPoly pour le point initial
ScanPoly pour les autres points
EndPoly pour le rendu final }
procedure BeginPoly(x,y:integer; z:float; u,v:integer; s:float);
procedure ScanPoly(x2,y2:integer; iz2:float; iu2,iv2:integer; is2:float);
procedure EndPoly;
{ Dessin du Bitmap offline sur un Canvas }
procedure SetPixels(Canvas:TCanvas);
|
{ Implementation de ClearPixels et SetPixels }
{$IFDEF VER90}{$UNDEF SCANLINE}{$ENDIF} // no Scanline under Delphi 2
{$IFDEF LINUX}{$DEFINE SCANLINE}{$ENDIF} // XPutImage doesn't work yet :((
procedure ClearPixels;
begin
{$ifdef scanline}
with Bitmap.Canvas do begin
Brush.Color:=clBlack;
FillRect(Rect(0,0,maxx,maxy));
end;
{$ifdef linux}Bitmap.FreePixmap;{$endif} // probably a little bug with BETA4
{$else}
FillChar(Pixels^,maxx*maxy*sizeof(integer),0);
{$endif}
end;
procedure SetPixels(Canvas:TCanvas);
begin
{$IFDEF SCANLINE}
Canvas.Draw(0,0,Bitmap);
{$ELSE}
{$ifdef win32}
SetDiBitsToDevice(Canvas.handle,0,0,maxx-1,maxy-1,0,0,0,maxy-1,Pixels,BitmapInfo^,0);
{$else}
XPutImage(Display,Window,Context,Bitmap,0,0,0,0,maxx,maxy);
{$endif}
{$ENDIF}
end;
|
Téléchargez les sources complets !
|
|