Jump to content
  • Advertisement
Sign in to follow this  
chigga102

C with Directx

This topic is 4553 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

Is it possible to use Directx with C (not C++ C) i was just wondering and can u tell me which version of directx has compatabity with C

Share this post


Link to post
Share on other sites
Advertisement
Short answer: yes, it is possible to use DirectX from C and every version of DirectX is "C compatible".
There was a thread on the topic a few days ago (I couldn't find it right now, sorry). Basically, since DirectX is build using COM, you can access its functionality by using a slightly different syntax than the C++ one, i.e. d3dDevice->Clear(...) becomes IDirect3DDevice_Clear( d3dDevice, ... ).

HTH,
Pat.

Share this post


Link to post
Share on other sites
Thanks and please dont ask why C i read i few things and they said avoid OOP until u r proficient in Procedual and i'm doing just that even though i'm learn C# but i just wanted to know. Can anyone point me to some resources on C with directx.

Share this post


Link to post
Share on other sites
If you are not sufficiently proficient with procedural programming to learn object-orientated programming, you have no chance of successfully grappling with the C interface to DirectX. Harsh, I know, but realistic.

[EDIT] Hang on. That sounded a bit nasty. What I mean is this: It is probably reasonable advice to learn procedural programming before learning object-orientated programming. I did and I can't imagine any other way. However, I was already pretty well versed in OO before I started trying to use DirectX. I have briefly glimpsed the C-style equivalents to the "normal" C++ ways of accessing the DirectX interfaces and I am fairly sure that if you have not yet moved on from procedural C to C++, you will not make a lot of headway with DirectX.

Was that more fair?

Share this post


Link to post
Share on other sites
I just finished writing a game in 99% C (C++ for the tools) just for the hell of it because I love C. I find that it's easier NOT to use the macros because Visual Assist or MSDev's built in intellisense shows the arguments of the macro as single characters.

d3dDevice->BeginScene();

becomes

d3dDevice->lpVtbl->BeginScene(d3dDevice); //I prefer this if using C

or

IDirect3DDevice9_BeginScene(d3dDevice); //I think, I don't use the macros

But since you have to include the pointer to itself as the first argument, it makes the argument names shifted over by one, but you get used to it. You'll see what I mean.

You could always use C++ and procedural code if the macro or Vtable accessing is that horrific.

Share this post


Link to post
Share on other sites
DirectDraw (7.0 on down) seems to work very well with C. Direct3D (8.1 and up) on the other hand would be easier on you syntax-wise if you use C++.

Share this post


Link to post
Share on other sites
I'm Just actually learning C# (i'm little over a noob) then i aim for C then for C++ and i wanna start coding as quick as possible but i didnt learn C first because they told me basically "You learn some bad habbits" and the reason i didnt learn C++ was cause Functions the whole passing ARGS so i decided to go to C#. the i go for C but thanks for the reply.
//I just finished writing a game in 99% C (C++ for the tools) just for the hell of it because I love C.//
dx elliot was it hard writing the game ? what type of game how large is it. sry for questions

but thanks.

Share this post


Link to post
Share on other sites
Quote:
Original post by chigga102
//I just finished writing a game in 99% C (C++ for the tools) just for the hell of it because I love C.//
dx elliot was it hard writing the game ? what type of game how large is it. sry for questions

but thanks.


It's called GrimSim in my profile under "portfolio", all the info is there (click sig). It was a complete flop so I never posted it in the announcements forum.

All the topics on C with DirectX always make it sound really painful, but it most definitely is NOT. There was a little problem with initializing DirectInput due to a clear difference in syntax, but that was about it. Writing GrimSim in OOP would have probably taken me twice as much time because I've always used procedural code, but I'm trying to move into the OOP realm now.

Share this post


Link to post
Share on other sites
Do you think the VTC C by Mark Virtue videos are any good thanks.
also how does opengl with c compare with directx and c and in you opinion which
api should i use with c thanks.

[Edited by - chigga102 on July 3, 2006 6:40:08 AM]

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

GameDev.net is your game development community. Create an account for your GameDev Portfolio and participate in the largest developer community in the games industry.

Sign me up!