Archived

This topic is now archived and is closed to further replies.

Muhagl

Code a Dll with Powerdraw

Recommended Posts

I have to Code a Dll with Power Draw so i can Skript my Game with VB. But i can always Init PowerDraw and Clear the Screen. Timer, Font and VDTb doesnt work... On Init PowerFont or VDTb ive got the ErrorString: "The Method was Called with invalide parameters or in inapropriate situation" ??? Is this come from the DLL Coding or i beeing too Stupid for PowerDraw... Plz Help!! Hmmm... i have to go bach to DelphiX O_O [edited by - Muhagl on March 18, 2003 4:10:23 PM]

Share this post


Link to post
Share on other sites
Ok, thats the Init Code for PDraw but i think that works (Screen get Clear with the right Color)



Function RPGDX9_Init: Integer;
begin
FM_Engine.Draw := TPowerDraw.Create(FM_Engine);

FM_Engine.Draw.Initialize;
FM_Engine.Draw.InitDevice;
PDrawExDllName := ''C:\tmp\'' + PDrawExDllName;
RPGDX9_Switch := true;
FM_Engine.Draw.Clear($FF00FF00);
FM_Engine.Draw.Present;
end;



And thats the Font loading Code:



Function RPGE4_LoadSystemFont(FontFile: PChar): Integer;
var FontFileStr: String;
Res: Integer;
begin
RPGE4_LoadSystemFont := 0;
{Convert Null Termided String in Pascal String}
FontFileStr := StrPas(FontFile);
{Check File}
if FileExists(FontFileStr)
then begin
{Load Font}

Res := FM_Engine.DXF_System.LoadFromFile(FontFileStr, D3DFMT_A4R4G4B4 );
if Res <> 0 then ShowMessage(ErrorString(res)); // Here is the Error! ******


FM_Engine.DXF_System.InvertGraphics;

FM_Engine.DXF_System.Scale := 256;
FM_Engine.Draw.Clear($FF000000);
FM_Engine.Draw.BeginScene;

FM_Engine.DXF_System.TextOut(''testing'',4,4,$00FF00);

FM_Engine.Draw.EndScene;
FM_Engine.Draw.Present;
end else begin
ShowMessage(''Fine not found'');
RPGE4_LoadSystemFont := 1;
end;
end;




Hope you can help me...

Share this post


Link to post
Share on other sites
Error code -1 with the message "The method was called in inapropriate situation" happends when you try to load font or graphics when PowerDraw hasn''t been initialized. Since in your code you never checked the resulting value of Initialize and InitDevice, the error pumped out of font loading routine.

Share this post


Link to post
Share on other sites
Sry 4 Doppelpost...

Ive got no Error Messages on Init...



Function RPGDX9_Init: Integer;
var res: Integer;
begin
FM_Engine.Draw := TPowerDraw.Create(FM_Engine);

res := FM_Engine.Draw.Initialize;
if (res <> 0) then
ShowMessage(Errorstring(res));
res := FM_Engine.Draw.InitDevice;
if (res <> 0) then
ShowMessage(Errorstring(res));

PDrawExDllName := ''C:\tmp\'' + PDrawExDllName;
RPGDX9_Switch := true;
FM_Engine.Draw.Clear($FF00FF00);
FM_Engine.Draw.Present;
end;



Now i`m really think i''m to Stupid for uning PDraw :D

Hmmm... Im using the PDraw Dx9 Version... Can this be the Answer? Delphi Ver7

Share this post


Link to post
Share on other sites
Few suggestions - you''d assign path before you initialize PowerDraw; don''t compare resulting code to 0, it might be bigger than 0 (which isn''t an error), compare it like "if (Res < errNone)"; also, check the order of initialization process and loading routine... I think the problem is somewhere in your code since PowerDraw routines check for Initialized flag each time and return errInvalidCall if the component is not initialized.
!!! Also, keep in mind to assign PowerDraw to Font, i.e. Font.PowerDraw:= PowerDraw... same applies to imagelists, etc.

Share this post


Link to post
Share on other sites
Oh my God! It Works! Very Special Thanks to you! Thats Great!!! *sing*

Ehem... it was the Font.PowerDraw := Form.PowerDraw;

*sing*

[edited by - Muhagl on March 20, 2003 3:15:10 PM]

Share this post


Link to post
Share on other sites