PDA

View Full Version : Drawing an image (noob question)



masonwheeler
25-06-2007, 10:24 PM
I'm trying to use Asphyre xtreme to create a tileset engine, and I'm having some trouble getting started. Here's my code so far. I'm trying to load a file, then have it display the entire file to the screen, just to make sure it's working right. I've gotten past all the bugs that keep it from compiling or generate runtime errors, but now all I get is a blank form instead of an image of the picture I loaded

Can anyone tell me what I'm doing wrong?


unit bigmap;

interface

uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms, ExtCtrls, Dialogs, //system libraries
AsphyreImages, AsphyreSubsc, AsphyreDevices, MultiCanvas, AsphyreTimers, AsphyreDef, Asphyre2D, AsphyreCanvas; //Asphyre Xtreme libraries

type
TForm2 = class(TForm)
AsphyreImages1: TAsphyreImages;
dlgOpen: TOpenDialog;
AsphyreDevice1: TAsphyreDevice;
AsphyreTimer1: TAsphyreTimer;
AsphyreCanvas1: TAsphyreCanvas;
procedure AsphyreDevice1Render(Sender: TObject);
procedure FormCreate(Sender: TObject);
procedure FormShow(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
end;

var
Form2: TForm2;

implementation

{$R *.dfm}

procedure TForm2.FormCreate(Sender: TObject);
begin
assert(AsphyreDevice1.Initialize());
end;

procedure TForm2.FormShow(Sender: TObject);
var
ini: TIniFile;
filename: string;

const
tileset: tpoint = (x: 480; y: 256);
tile: tpoint = (x:16; y:16);

begin
if dlgOpen.Execute then
filename := dlgOpen.FileName;
loadChipset(filename, tile, tileset, asphyreimages1); //routine I set up to load the image. It works fine
assert(asphyredevice1.Render(0, false));
assert(asphyredevice1.Flip);

//end if
end;

procedure TForm2.AsphyreDevice1Render(Sender: TObject);
begin
asphyrecanvas1.TexMap(asphyreimages1[0], pBounds4(0, 0, 480, 256), clWhite4, tpattern(0), fxNone);
end;

end.

Mason

masonwheeler
26-06-2007, 06:52 PM
Nevermind. I found the problem. Turns out I need to be continually updating it with the timer. I thought it could just be drawn once and work, but I guess not.

Mason