Need some help (c++, c#, opengl, dx)

lazzygee

Newcomer
I just started learning programming recently and picked up a few books about C++. Not to say that i'm already a programmer but I'm learning really quick. I already have some ideas of how programming "works" and how programmers think. As a newbie I have no intentions programming for other platforms than Windows or using some other IDE than MS VS.NET. I was always interested into graphics and how (real-time) 3D stuff works so I started reading a lot about OpenGL and DX and eventually decided to use DX as it seems (from reading what others say about both) easier to me :\ Correct me here if I'm wrong but if for example I want to use a specifis effect which uses pixel shaders i must write (opengl) seperate extientions for each vendor? This (and the fact that I have no intention coding for non Win platforms) is what I based my desicion upon which is a better API for me. The way I see it right now is that you "only write everything once" in DX while you must rewrite some stuff in OpenGL specific for each vendor? Any info on this, or if there is an article discussing how DX programming is different from OpenGL would be very usefull.
note: don't think that I already _know_ how real-time 3D stuff works. I'm still in the process of making a spinning cube :)

Now to my other question :)
As I said C++ seems quite straight forward to me. I can already look at some code and to some degree understand what it does, or if I put it better - understand why it's there. After some reading about C# I am tempted that it might be a better language for my purpose. And I don't want to learn both languages because then I'll just fail in both because my mind would be messed up :) I try to keep it simple untill i have enough knowledge.
I am more looking for info about if there are any developers (engine coders) out there that actually use C# or have said about it something.
If I understand correctly C# is very similar to C++ but a lot simple. Simple is always good but I don't want it to not allow me any serious stuff. After all I am looking for a language that I will stick with for many years.


Sorry if this is in the wrong forum or I don't make much sense, but my mind is kind of puzzled right now.

not really a question, but something that keeps bugging me: is Tim Sweeney writing for OpenGL or DX? Their games run in both so I don't know.

Thanks!
 
opengl

I am in no way an expert on OpenGL, as I'm just starting to learn it myself (Just got the red book in the mail today!), but I believe the OpenGL extension for the shader language is a general extension and not a vendor specific one. So you can write your shaders and they will work for all OpenGL compliant hardware. But there are vendor specific extensions you can use. I believe OpenGL 2.0, the shader language is no longer an extension, but is included as part of the core of OpenGL.

I also don't know much about DirectX, but I do know something about VS .NET. Managed C++ seems pretty crappy in it's current incarnation. So, I think right now, the only real option for VS .NET games programming is C#, but I honestly don't know how great that is. Now, if you wanna go the C++ route, it's better to use unmanaged and do things the old way(Windows API, MFC), outside of the .NET environment. More difficult to code, but much faster for games ... I could be totally wrong though.
 
C# with DirectX9 is awesome.

Try it out, you will not regret it.
It's very easy to set up and you can knock up a simple program in lightning speed.

I am a little pissed off that there is no default OpenGL library with VS.NET 2003 which can be used under C#.

I use Java LWJGL to write GL programs which are multi platform.

MFC is going the way of the Dodo. In Longhorn it is completely eliminated.
 
I mean some extensions. Like Carmack had to use different render path's for different cards that's something you're not doing under DirectX if I'm right?
 
lazzygee said:
I mean some extensions. Like Carmack had to use different render path's for different cards that's something you're not doing under DirectX if I'm right?
If he had used DX instead of GL he would probably still have written a fixed function path, a ps1.1 path, a ps1.4 path and a ps2.0 path. But anyway, if you're just going to use Windows and you're not interested in experimenting with custom vendor specific stuff then there is no reason to not go with DX9.
 
I already have some ideas of how programming "works" and how programmers think.

Yes, they usually think about why their programming doesn't work :)

Correct me here if I'm wrong but if for example I want to use a specifis effect which uses pixel shaders i must write (opengl) seperate extientions for each vendor?

That depends on what hardware you're targeting. There is a generic ARB extension for shaders (called vertex programs and fragment programs in OpenGL), but it only supports SM2.0-level hardware. The 1.x-generation is ignored altogether by OpenGL, so if you want to target that, you need vendor-specific paths.

I personally prefer Direct3D... some of the reasons for my choice are no longer valid, because OpenGL has caught up in those areas, but you could think about practical reasons aswell, rather than purely technical ones. Such as the quality of the driver support from various vendors. I don't think that is going to change anytime soon.

I try to keep it simple untill i have enough knowledge.

I suppose in that case C# seems like the best language to start with. It is generally simpler than C++. Once you're familiar with C#, the step to C++ is not all that large, and .NET allows you to use DLLs written in (native) C++ from .NET applications (so also C#), so if you want, you can combine the two. If you do managed C++, it's even easier, since then both languages are .NET.

not really a question, but something that keeps bugging me: is Tim Sweeney writing for OpenGL or DX? Their games run in both so I don't know.

Tim Sweeney... That was Epic -> Unreal, if I'm not mistaken. In which case I believe they are doing Direct3D only these days.
 
I mean some extensions. Like Carmack had to use different render path's for different cards that's something you're not doing under DirectX if I'm right?

DirectX doesn't have extensions, but that still doesn't mean that all cards can run the exact same code. DirectX offers an interface which allows you to check the caps of the current hardware, and select a suitable rendering path for it.
The difference between that and OpenGL extensions is not that large in practice.
The annoying thing about OpenGL is that sometimes the same feature is exposed through different extensions on different hardware, so you'd have to code the same stuff for both extensions. This is something that doesn't happen in DirectX.

Apart from that, DirectX is generally more up-to-date than OpenGL's non-vendor specific support. For example, the GF3 came out at about the same time as DirectX 8, which enabled pretty much all functionality of the GF3 and similar hardware. Then it was extended to 8.1 for the Radeon 8500.
The Radeon 9700 was released at almost the same time as DirectX 9, and OpenGL 2.0 is only just now catching up.
So you get to use the new features almost right away, with a generic, non-vendor specific API. OpenGL extensions will expose the new features even sooner, but they will not work on other hardware. Sometimes extensions are even removed from a driver in later versions, which will break the code even on hardware that used to support it.
So DirectX code will be more future-proof and compatible in general.
Those are things that I find important. Apparently even some OpenGL programmers find them important, because JC replaced all vendor-specific code with ARB-extensions when they became available. Ofcourse the difference is that he had to code all the vendor-specific stuff first, and then the ARB-stuff too. With DirectX he'd be done on the first take.
 
Back
Top