View Full Version : DirectX and Turbo Delphi for .NET

24-09-2007, 02:30 PM
I downloaded Turbo Delphi for .NET and would like to try creating some basic 3D application with DirectX 10... The question is, how do I start? Should I create a VCL Forms application, or console? Which units should I add to uses? And are there any examples on how to initialize the device? Thanks for all your help. I'll Google at the same time, and try to find some answers myself.


24-09-2007, 04:20 PM
There are DX10 pascal headers avaliable ?

24-09-2007, 04:30 PM
I don't know. Is Delphi able to use .NET libraries? Since it is using an intermediate language, I suppose it might be possible somehow...

24-09-2007, 04:56 PM
Clootie has ported the DirectX 10 headers to pascal.. isn't it? :D



They should work fine, just as the DX9 headers did. Just include them in your library path. :)

24-09-2007, 05:02 PM
I think Delphi.Net have full suport calling functions from dlls, so you will have no problems :)

24-09-2007, 05:09 PM
Heh, thanks I'll try Clootie's headers.

Another question is: to deploy Delphi .NET applications for DX10, which packages do I have to pack with the .exe?

24-09-2007, 06:34 PM
Sorry i dont know about .NET. In fact, i know so little about what .Net is and how it works, that i cannot tell whether clooties headers will work with .NET :?

You should give it a try :)

25-09-2007, 04:42 PM
If you are using Turbo Delphi for .NET then you need to look at Managed DirectX examples. Clootie provide headers for UNmanaged DirectX development, so they will/should NOT work with .NET.

The Managed DirectX Assemblies ship with DirectX 9 and 10 SDK and also as part of the latest Runtime available from

A recap of What Managed Direct X is can be summarised as follows:

# A functionally equivalent wrapper around the normal DirectX API for .NET

# Providing very good performance while offering the productivity gain of coding in .NET

# On its way to becoming a prime game development platform, with the recent XNA
announcement and the general Microsoft push toward .NET

There are also some Managed DirectX 9 Demos that I ported to Delphi.NET back in 2004 over @ http://tech.groups.yahoo.com/group/JEDI-DirectXExamples/files/DirectX9.zip
that were never publicly released. There are 34 demos so far, including a slightly fixed PointSprites demo and added Voice over IP demo ( untested ).

If I could find another 2 hours in the day I would port these to work with Highlander.

25-09-2007, 05:03 PM
Thanks savage. But if I can't use Clootie's headers in Delphi .NET, which units can I use from the .NET framework. I mean, in the uses clause, which unit names do I place?

Are those examples available somewhere else, it seems I have to create an account at Yahoo to get them.

Finally, what is "Highlander", some immortal of the Delphi clan? :)


25-09-2007, 06:09 PM
For .NET there is no concept of headers. That is the beauty of it. You just add the assembly to your .NET project, regardless of .NET language ) and you can use all the methods, functions types etc straight away.

Highlander is the next version of Delphi, which has just been released ( or is about to be released ).

25-09-2007, 06:14 PM
Does the assembly come with the SDK?

25-09-2007, 06:46 PM
It comes with both the SDK and the Runtime, as I mentioned earlier.
If you have the latest SDK installed you should find a sub-directory named Managed, which contains all the C# DirectX examples.

25-09-2007, 07:32 PM
Oh, very good :D And, is the assembly installed the same way components are installed in Delphi, or is there a specific option in the IDE to add them?


25-09-2007, 08:40 PM
When you have the project open, in the project manager you will see a folder called "References", right click on it and you should see an option called "Add Reference..." this should open up a dialog box that lists all the assemblies installed on your system. It may take a while to load them into the dialog. If you scroll down you should find quite a few there named "Microsoft.DirectX.*". Select the ones you want to refer to an in your code add the respective namespace to your unit and you are ready to go.

To save you some time, I've managed to get the 6 Managed Tutorials working again. Download them from http://chrome.pascalgamedevelopment.com/files/DirectX9.zip

Hopefully the project files should open in Turbo, if not open the .dpr file and it should create a Turbo compatible project. Have a look through the code and see how it all hangs together. If only the other 28 demos were as easy to get working it would show off stuff like particle systems and even Voice Over IP.

25-09-2007, 09:03 PM
Wow, thanks! I'll try it at home.


25-09-2007, 11:03 PM
You are in luck. Through the use of black magic and jiggery pokery most the samples now compile. The main exception being DirectInput and DirectPlay examples which seemed to be cause by the compiler and not my code ( honest :-) ).

It's midnight here so I will try and zip them up and upload them tomorrow night.

26-09-2007, 03:09 PM
Hey that's great news! :D

Yesterday I ran the examples, and they work great. I was very excited, I thought I would have to learn C# to make managed DX applications.

I see the syntax in Delphi for .NET haven't changed a lot (I'm using Delphi 7). Now there are some questions:

1. What's the benefit of DX in Delphi .NET? Apart from being managed, which I understand as a memory safe execution, is it possible to make a Delphi .NET application run in the XBox?

2. I tried to compile some of my classes, and got an error like "Language feature not available: 'destructor' ". But in the help they explain classes, and there appear the constructor and destructor! I'm confused about that. I understand .NET will release any object when it loses all it's references, but what can I do in the case I want to restore a given state after an object has been released?

3. I see the Pointer type now is unsecure. There are several cases where I need to pass memory locations, and do type conversions. What's the best way to translate this code? Should I keep using Pointer and wrap it inside {$UNSAFECODE xxx} directives? Or should I use as many typed-pointers as possible?

Also I plan to update my units for the .NET platform using conditional compilation, so I don't have to create two versions of the whole engine I'm building. Is the Turbo Delphi for .NET the only compiler with VER140 ? Or is Turbo Delphi (Win32) using that value too?


26-09-2007, 11:04 PM
I've just uploaded a new zip which overwrite the previous version. This one contains 17 demos :
Player - Plays movies
Texture - Plays movies on a texture


Tutorial 1-6

Tutorial 1


As it turns out, DirectSound also causes problems with the .NET compiler. So that leaves 16 demos that don't currently work.

To answer your questions

1. The Managed DirectX API is much much simpler than the normal one and the XNA one is even better! You need XNA to write games for the XBox 360 and you also need .NET 2.0 compliant compiler, which I think the Turbo versions are not yet. Highlander is .NET 2.0 compliant, but it is a real pain to use with XNA. Using Chrome is much easier and has been tested on Xbox 360. The down side of Managed code is that it is slightly slower than native code, but with multi-core system getting more and more cores, this won't matter much in the very near future.

2. .NET is a different way to of writing your code/classes. If I were you I would read up on the difference between .NET and managed out and how it differs from Native coding. If an object has been released, typically you would re-create, but as long as you keep a reference to the object it will stick around in memory.

3. Managed code hates pointer. That does not mean you can't use it, but it's considered unsafe and is therefore not recommended. Again I would suggest you read up on the difference between native and managed coding.

4. I'm not sure how the Turbo versions are versioned :), the best thing I can suggest is looking here - http://delphi.wikia.com/wiki/Borland_Compiler_Conditional_Defines or posting on a CodeGear forum.

Let me know if you have any problems with the demo.

27-09-2007, 02:56 PM
Downloaded the new demos, I'll try them at home.

Thanks for the recommendations, I'm following some guides to make my code safe. At the moment I haven't had many problem to convert my code, but there are two things that I don't know how to translate:

1. What's the best way to replace an "absolute"?

2. What's the best way to replace a string[1]? For example in: Move(data^, mystring[1], n);