PDA

View Full Version : irrPascal :: Irrlicht for Pascal



Srki_82
14-04-2007, 10:47 PM
I'm currently writting Pascal wrapper for Irrlicht engine. It's not much right now, but, you can at least create Irrlicht device, use logger and cursor controll :)

I want to finish events, video driver and scene manager first, and then the rest. I think I could write wrapper so you can use ALL Irrlicht functionality.

Download archive contains C++ wrapper dynamic loading library, Pascal units, test program (Delphi and Lazarus project files) . Windows binary and source codes are included. To compile C++ wrapper you will need Irrlicht source code.

http://www.geocities.com/srki_82/irrPascal.zip

Joshas
15-04-2007, 05:46 AM
Finally, the dream come true - Irrlicht & Pascal. Good luck!

Edit: couldn't get it to work, all I get is "The application failed to initialize properly (0x0150002)." error message.

Galfar
15-04-2007, 09:38 AM
Works for me. I'm really looking forward to seeing Irrlicht in Pascal.

Srki_82
15-04-2007, 09:52 AM
Edit: couldn't get it to work, all I get is "The application failed to initialize properly (0x0150002)." error message.

It would be great if you could debug test application and tell me where does this error ocure. I tried it on several computers and it worked. Only problem is exiting fullscreen. I get access violation when I run program from Lazarus, but no error when I run binary file outside Lazarus.

savage
15-04-2007, 10:30 AM
Finally, the dream come true - Irrlicht & Pascal.

If you want to use Delphi.NET and Irrlicht, I posted some examples of this a couple of years ago on the Irrlicht wiki.

Joshas
15-04-2007, 11:22 AM
I've tried to run it just after unpacking, also compile from Delphi 7 PE IDE - results are the same. Delphi stops right after IrrDevice declaration. No luck with Lazarus either (debugger error, because process is not running). Maybe I'm missing some dll files or have overlooked something very obvious?
Haven't tried .NET yet, I prefer plain old Objet Pascal :).

UPDATE:
Here's what I got form Dependency Walker:

Error: The Side-by-Side configuration information for "d:\temp\irrpascal\irrlicht\IRRPASCAL.DLL" contains errors. This application has failed to start because the application configuration is incorrect. Reinstalling the application may fix this problem (14001).
Error: At least one required implicit or forwarded dependency was not found.
Warning: At least one module has an unresolved import due to a missing export function in a delay-load dependent module.

It also shows that I'm missing a MSVCR80.DLL, but after downloading it and putting in the same folder as irrpascal.dll problem still exists.

UPDATE2 - Workaround:
I've imported IrrPascal VC Studio project to CodeBlocks and compiled with GCC, then just replaced Irrlicht.dll with GCC one and everything is working. Downside might be bigger size of GCC compiled dll files.

Srki_82
15-04-2007, 01:11 PM
UPDATE2 - Workaround:
I've imported IrrPascal VC Studio project to CodeBlocks and compiled with GCC, then just replaced Irrlicht.dll with GCC one and everything is working. Downside might be bigger size of GCC compiled dll files.
I compiled both Irrlicht.dll and IrrPascal.dll with Visual C++ Express and that seams to be the problem. GCC compiler is probably better choice because there is no dependecise to msvcxxxx.dll

File size can be reduced using upx :)

Srki_82
16-04-2007, 11:06 AM
I'm opening irr-pascal project on sourceforge. When they activate project, all sources will be hosted there.

I worked little on wrapper dll and it now fully supports irrlicht device, cursor control, event reciver, logger, os operator and video mode list. Limited support is there for file system (IXMLxxxx classes are not yet supported), video driver and scene manager.

Nodes, meshes, cameras, lights and others are not yet supported.

As soon as I complete Pascal units you will have new sources to download.

Srki_82
16-04-2007, 09:28 PM
irrPascal is now on sourceforge.net: http://sourceforge.net/projects/irr-pascal

You can use SVN to get the latest sources. First package for download will be available when Irrlicht HelloWorld is compiled in Pascal :)

Joshas
17-04-2007, 12:42 PM
I've downloaded (or should I say "checked out") the SVN version<STRIKE>, but while compiling IrrTest I've got some Access Violations somewhere in CreateDevice function, so I think I'll wait for working HelloWorld example</STRIKE>.
Sorry, false alarm. It seems that someone forgot to update IrrTest Delphi project with new source code ;). Everything works neatly on Lazarus.
And it seems that to make it work on Delphi copy-paste approach is not enough - window doesn't paint in blue color, it is just "see-through". I wonder, what difference between Delphi and Free Pascal (Lazarus) makes this happen?

Srki_82
17-04-2007, 08:00 PM
I made some modifications to Pascal units and wrapper and now test project forks with Lazarus and Delphi.

Also... instead of using records to hold position, dimension, vectors, etc... I'll use original Irrlicht classes. Position and dimension already works (cursor controller use new position class).

Joshas
18-04-2007, 05:15 PM
I still get an empty window with Delphi 7 PE and have not a slight idea what might be wrong. Compiling as console application shows that input works correctly - characters and mouse position are echoed in console window. It might be something wrong with device creation function in Delphi, but this is just my guess, because when I change driver type in Lazarus to EDT_NULL- only console window pops up, but when I try to do same thing in Delphi - device window is created, and it even handles input (shows mouse position in console). Maybe it's a sign that I should move on to Lazarus permanently? But I just can't drop Delphi and its unbelievably fast compile times.

Srki_82
18-04-2007, 07:04 PM
I updated code a little and Delphi problem still exists... the weirdest thing is that when you use just wrapper functions (no classes or something else... just device_xxxxx, video_xxxxx from Irrlicht.pas every thing is working fine on Delphi.

I'll try debugging IrrPascal.dll and maybe I'll see what exactly is passed to it by Delphi and Lazarus.

For now... Lazarus is only FPC/Lazarus is only choice.

Srki_82
18-04-2007, 07:49 PM
It seams that Delphi instead of EDT_XXXXX enums sends something else to IrrPascal.dll

Something that I don't understand... if I write code like this

constructor TIrrDevice.Create&#40;driverType&#58; VIDEO_DRIVER_TYPE; Width&#58; Integer;
Height&#58; Integer; bits&#58; Integer; fullscreen&#58; Boolean; stencilbuffer&#58; Boolean;
vsync&#58; Boolean; reciver&#58; IIrrEventReceiver&#41;;
begin
inherited Create&#40;device_createDevice&#40;EDT_OPENGL, Width, Height, bits,
fullscreen, stencilbuffer, vsync&#41;, False, False&#41;;

if GetIrrObject = nil then
raise Exception.Create&#40;'Error creating Irrlicht Device'&#41;;

EventReceiver &#58;= reciver;
FResizeAble &#58;= False;
FWindowCaption &#58;= '';
end;notice that EDT_OPENGL is set as the first parameter to device_createDevice function, everything is working just right but if I write driverType wrong value is passed to IrrPascal.dll

I really don't know what to do. Does Delphi requires some special way of sending and receiving enums to and from dlls with cdecl calling convention?

Galfar
18-04-2007, 08:10 PM
There is a problem with enum type sizes. Just put {$MINENUMSIZE 4} to irlicht.inc and it will work (tested in Delphi 2007).

Srki_82
18-04-2007, 09:56 PM
Thanks Galfar, that was IT :)

Now I can continue working on wrapper :)

Joshas
19-04-2007, 09:47 AM
Great, finally it works on Delphi 7.

Srki_82
23-04-2007, 09:49 PM
Everything is going smoothly :)

Change of plan... first things that we will see on irrlicht device will be gui elements. Wrapper dll already (SVN revision 15) contains functions for creating gui elements, code for modifying gui elements is not yet there.

I'll try to finish IImage, ITexture, IGUISkin and IGUIFont and to complete IGUIEnviroment. Next things are gui elements.

BTW when finished, could this wrapper be used in competitions?

savage
23-04-2007, 10:12 PM
BTW when finished, could this wrapper be used in competitions?

I would say yes as long as the main game code is in Pascal.

WILL
23-04-2007, 10:51 PM
Yeah, it's just like .NET or any other API really...

Srki_82
07-05-2007, 05:39 PM
There is something strange in Pascal :)

I finished almost all basic functions and then testing started but... everything is working nice when wrapper functions are called from C++, but Pascal code generates division by zero runtime error whenever some mesh is added to scene. I guess there is something wrong with parameter types (size of types are different in Pascal and C++ or something like that) or with precision (Set8087CW...)?

I uploaded mini version of wrapper and C++ and Pascal program that uses it. I can't figure what is wrong... maybe someone else can?

Download: http://www.geocities.com/srki_82/Mini.zip

Srki_82
07-05-2007, 08:10 PM
Never mind... I found solution... Set8087CW($133f) fixed everything.

Srki_82
07-05-2007, 10:13 PM
Pascal has compiled Irrlicht HelloWorld tutorial :D

For now all calls are made directly to wrapper, but basic classes will be completed soon so HelloWorld will look like original one written in C++ (no need for temp. vars, using classes for calls,...).

Setharian
08-05-2007, 07:47 AM
why you actually need a wrapper dll? I thought irrlicht exports functions using interfaces, does it not? if that's the case I see no reason for a wrapper dll, you just need correct interface declarations and use those.....if I'm wrong please correct me....

Srki_82
08-05-2007, 08:19 AM
Well... classes like vector3d<T>, SColor, SMaterial, etc. are not interfaces so I have to write wrapper dll to create and use that classes.

If there is solution that doesn't require wrapper dll, I will be happy to hear how to do that.

I tried to use exported abstract classes for device, video driver and scene manager but I never get them working in Pascal.

Setharian
08-05-2007, 10:14 AM
look at the .NET wrapper for irrlicht, that's all I can say:)

EDIT:
so no, it's not as cool as I thought :) marshalling is required for these non-interface types...

Srki_82
08-05-2007, 10:52 AM
For now, we need this wrapper dll. Flatten version of Irrlicht classes in this wrapper can be used in almost any compiler that supports dynamic loading libraries... it would be useful for Pascal, VB, GameMaker, C and many ther programmers :)

BTW this article helped me in the begging: http://www.rvelthuis.de/articles/articles-cppobjs.html

Joshas
08-05-2007, 12:28 PM
I'm having trouble compiling latest version with GCC, here's what errors I get when I try to build irrPascal wrapper in CodeBlocks:
IrrAttributes.cpp:710: error: 'class irr::io::IAttributes' has no member named 'addUserPointer'
IrrAttributes.cpp:722: error: 'class irr::io::IAttributes' has no member named 'getAttributeAsUserPointer'
IrrAttributes.cpp:728: error: 'class irr::io::IAttributes' has no member named 'getAttributeAsUserPointer'

Srki_82
08-05-2007, 12:47 PM
I used the latest Irrlich sources for building IrrPascal. Download the latest version from SVN or simply remove functions that do not exists in your header files.

Srki_82
10-05-2007, 05:26 PM
Classes are updated so HelloWorld tutorial is almost identical to C++ version.

BTW FPC/Laz make difference between PChar and Pointer so I can overload functions with that types, but to Delphi PChar is the same as Pointer and it cann't overload functions like:

function A&#40;a&#58; PChar&#41;&#58; Boolean; overload;
function B&#40;b&#58; Pointer&#41;&#58; Boolean; overload;
Is there some switch to disable that?

Srki_82
27-05-2007, 03:22 PM
It is now possible to write event receiver code in class instead of top level function. Hopefully creating of Irrlicht arrays will be finished soon and creating of custom scene nodes will follow.

Srki_82
12-06-2007, 11:26 PM
I dropped support for latest SVN version of Irrlicht. From now on only stable versions of Irrlicht will be supported (currently 1.3).

BTW CustomSceneNode is almost complete :)

Srki_82
16-06-2007, 01:08 PM
Call for help :)

IrrPascal is working fine under Windows, but I don't know how to compile and setup shared library in Linux?

Can anyone create makefile and all that is necessary for libIrrPascal.so to compile?

GendoIkari
25-06-2007, 07:13 PM
Hi, i'm Gendo Ikari from Italy.
Do you need some help for windows version? I'm really interested in your project, and if it will be finished i'll be glad.
I'm not bvery pro with c++ but i know both c++ and object pascal.

Srki_82
25-06-2007, 07:32 PM
Help is always appreciated :)

This project doesn't require advanced c++ knowledge. I'm currently trying to compile IrrPascal and IrrTest on Linux but I just can't do it.

You can download SVN version from sourceforge and start adding support for GUI classes or something other if you want.

alexione
14-09-2007, 09:49 AM
GCC compiler is probably better choice because there is no dependecise to msvcxxxx.dll

Check on Project Options / C++ / Code Generation if you are using DLL version of runtime. It shouldn't depend on msvcxxx.dll if you link c++ runtime staticly.

Almindor
16-09-2007, 11:08 AM
Call for help :)

IrrPascal is working fine under Windows, but I don't know how to compile and setup shared library in Linux?

Can anyone create makefile and all that is necessary for libIrrPascal.so to compile?

I can help you with linux stuff at least. It would be VERY nice if you could join us at #pgd so we can discuss stuff realtime? I really hate developing over mail or forums :)

I have compiled the .so successfully and your demo works with it. You can get the makefile with all requirements at http://members.chello.sk/ales/irrpas.tar.gz

Just extract and put the contents to your IrrPascal sources dir, overriding files. It contains all irrlicht .h files as well as the libIrrlicht.so itself (1.3.1 compiled on my machine). You can replace the lib in the "lib" subdir easily if you wish. There's also a sample compiled pascal test binary (linux).

I had to fix 3 cpp files. 2 were "API mistakes" (one typo, one change) and 1 is beyond me. Triangle3d has some oddities.
1. You used a private method, I removed that one (just made it return false)
2. There's a very odd error on IsFrontSide method regarding & operator inside the irrlicht triangle.h file. Can't figure out what's wrong so I made it return false as well.

With these changes your example worked on linux.

Reiter
07-10-2007, 08:29 AM
Is this project already dead? :(

I don't hope so. Well, when I tried to run the latest version of the files I noticed you don't provide a pre-compiled .DLL. Since I don't have VC++ I tried to compile one with MingW system (g++) but didn't work for me. Maybe in next releases you could provide some pre-compiled files.

Furthermore I wonder why you don't use the original .DLL and just provide the units for translation (like e.g. in JEDI-SDL project) but try to rewrite the IrrPascal.DLL/IrrPascal.so?

alexione
10-10-2007, 09:35 AM
There are several problems for this approach to be possible:

1. Irrlicht DLL exports only two function, and they are both used to create Irrlicht device.

2. Irrlicht is heavily based on C++ templates. So, one would need to rewrite all template classes in Pascal (arrays, maps, strings, ...) or to write DLL wrapper which would export functions with clean C interface.

3. Pascal compilers (FPC & Delphi) still don't support direct linking to C++ code which uses templates.

Also, I think that Srki still tried to link directly to Irrlicht DLL, but without success :(

Srki_82
10-10-2007, 03:45 PM
Hi!

I didn't touch IrrPascal wrapper for a long time. I moved to another country and because of my new job there is no time for me to develop IrrPascal for now. I'll continue as soon as have more free time :)

New Irrlicht introtuced new template classes... that means even more code will be duplicated :) Copy, Paste, Replace... Copy, Paste, Replace :) In the end IrrPascal wrapper will be bigger than Irrlicht :)

pstudio
13-02-2008, 11:26 AM
I've recently developed an interest in Irrlicht and was wondering if this project is still on or if I'll have to do the units myself (or using c++)?

Srki_82
15-02-2008, 08:49 PM
I have stop working on Irrlicht wrapper. I don't have enought free time to work on it. For now, Irrlicht for .Net and Delphi .Net do job for me.

pstudio
18-02-2008, 03:14 PM
Ok - it's a shame but I know how it is not to have enough free time. Perhaps I'll look into the .Net version.