Archived

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

Can I use DirectX using C only?

This topic is 5153 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

Or...do I have to bite the C++ bullet? If I need to learn C++ quickly enough to do Directx, will "Accelerated C++" by Koenig and Moo bring me up to speed? FWIW I have been using C for years, and I know enough Java to do simple games and animation. But now I want to do DirectX! Capt Logic

Share this post


Link to post
Share on other sites
quote:
Original post by Captain Logic
Or...do I have to bite the C++ bullet?

If I need to learn C++ quickly enough to do Directx, will "Accelerated C++" by Koenig and Moo bring me up to speed?

FWIW I have been using C for years, and I know enough Java to do simple games and animation.

But now I want to do DirectX!

Capt Logic




I haven''t learned DirectX yet but Accelerated C++ would be good if it''s necessary for DirectX. I read that after programmming in C for a while.


Share this post


Link to post
Share on other sites
1. The easiest thing to do is write C style code in a CPP file and compile it as C++ - just think of the COM calls as calls to a function pointer (the method) stored in a structure (the interface). Your program doesn''t need to use any classes or be at all object oriented to use DirectX.


2. Read the following part of the SDK docs:
Introducing DirectX 9.0 ->
Using the DirectX SDK ->
Programming DirectX with C/C++ ->
Using COM ->
Using C to Access COM Objects

That tells you how to call the COM objects from C specifying the v-table/this pointer explicitly.


3. Additionally read:

Introducing DirectX 9.0 ->
Using the DirectX SDK ->
Programming DirectX with C/C++ ->
Using COM ->
Using macros to Call DirectX COM Methods

That tells you about the helper macros for use with C which do the v-table stuff for you.


4. The rest of that "Programming DirectX with C/C++" section is probably worth a read too if you''re new to DirectX programming.


5. Older versions of the SDK had a few samples written in C so if you''ve got a reasonable connection it might be worth downloading say the DirectX 7 SDK to look over the samples (still use DX9, just copy the programming "style" from the DX7 samples).

--
Simon O''Connor
3D Game Programmer &
Microsoft DirectX MVP

Share this post


Link to post
Share on other sites