Going from DirectX to OpenGL

This is a discussion on Going from DirectX to OpenGL within the Game Programming forums, part of the General Programming Boards category; After reading around on the boards a bit, it seems when people are talking about doing things graphics wise and ...

  1. #1
    pwns nooblars
    Join Date
    Oct 2005
    Location
    Portland, Or
    Posts
    1,094

    Going from DirectX to OpenGL

    After reading around on the boards a bit, it seems when people are talking about doing things graphics wise and just planning out algorithyms they don't mention the API they are using, or planing to use.

    I have 2 books that teach graphical programming right now, Role Playing Game Programming with DirectX (DirectX 8) and Tricks of the 3D Programming Gurus(DirectX9) I bought the RPG one and was givin the other. But DirectX is a windows interface and I am thinking about going to OpenGL interface because it is crossplatform.

    My couple of questions are:
    1. How hard is it to go from DirectX to OpenGL (I haven't learned too much, but have picked up some).
    2. Can I use SDL to handle my input/sound and use OpenGL to handle my graphics?
    3. Is there anything about programming for other platforms than windows that I would need to keep in mind while programming (I know system calls are a no-no but is there anything esle)
    4. I have both VC++ 2005E and Dev-Cpp 4.9.9.2 installed, would there be any reason to use one of these compilers over the other?


    I have searched about a couple of these questions, and I am going to continue searching, but I thought I could post and get the advice of you all with years of experience in graphical programming.

  2. #2
    pwns nooblars
    Join Date
    Oct 2005
    Location
    Portland, Or
    Posts
    1,094
    Seems I will be going GLUT and FMOD since they can work with the input/window stuff, and the sound. So that solves that question .

  3. #3
    Super Moderator VirtualAce's Avatar
    Join Date
    Aug 2001
    Posts
    9,584
    I would not use SDL for sound. Coding your own sound functions using DirectMusic is quite simple.

    DirectX9 Audio Exposed
    http://www.amazon.com/gp/product/155...17424?n=283155

  4. #4
    pwns nooblars
    Join Date
    Oct 2005
    Location
    Portland, Or
    Posts
    1,094
    I am talking about moving away from DirectX and towards OpenGL .

  5. #5
    User
    Join Date
    Jan 2006
    Location
    Canada
    Posts
    498
    I'm just switching from DirectX to OpenGL (however, I was only doing 2D graphics with DirectDraw) and I found that using OpenGL (GLUT) is SO MUCH EASIER THAN DIRECTX. Everything is simplified. Also, your code is completely platform independent. It is definetley a good choice to move to OpenGL.

  6. #6
    Super Moderator VirtualAce's Avatar
    Join Date
    Aug 2001
    Posts
    9,584
    Hey genius....OpenGL is graphics only. So sit down, quiet down, and listen up. You don't dump all of DX just because you don't want to use Direct3D. Calling DirectX a graphics API shows how much you understand about the API. It's a hell of a lot more than graphics.

    Nothing says you can't use DirectMusic, DirectInput, etc, for Win32 programs, or for OpenGL programs. They have designed it in such a way that DX components can function outside of the realm of Direct3D.

    So get the book, get the book, get the book, and read it.

    And you don't dump Direct3D for GL because one is easier than the other. Companies normally support both for all their games and will continue to do so in the future. You code for both to support a wide range of customers. Not because one is easier than the other.

  7. #7
    pwns nooblars
    Join Date
    Oct 2005
    Location
    Portland, Or
    Posts
    1,094
    Hey, nice flame there. Respected you till that post. So sit down, quiet down, and listen up.

    I am trying to move towards platform independance if you would read my post. I am not dumping one for the other because it is easier, I was mearly asking if it is hard to go from one to the other. So calm down and don't jump on people, Mr.F'ing-Know-it-all.

    Next time read the whole post, and the posts afterwards before yelling at me or anyone else. Just because you have been coding a while longer, doesn't make you god, infact I see you asking questions also. Next time you want a power trip, go somewhere else.

  8. #8
    Super Moderator VirtualAce's Avatar
    Join Date
    Aug 2001
    Posts
    9,584
    Give me one good reason as to why cross-platform is even remotely important as it relates to game programming. Cross-platform doesn't mean squat when nearly every game coded only runs on x86 Windows machines. It has been that way, is that way, and always will be that way.

    Unfortunately in it's current state, Linux has no chance of ever changing that. GL is limited in scope due to it's focus on graphics only and go read the boxes of your games. They say they require a DirectX 9.0 compatible sound card meaning that the game either uses Miles library or some form of DirectSound or DirectMusic.

    You are choosing one OR the other and there is no need to. I see nothing in your posts explaining why cross-platform is so important and I doubt you could convice us even if you had some reasons.

    Things are going to change in the near future and it will be interesting to see which APIs survive and which one's don't.
    Most game companies could care less about cross-platform. Statistics show that 80% of PC's run on Windows and as for Mac's, well we all know what they just did so they don't even play a part in it anymore. x86 and Windows is the future. I'm not saying Windows is the best or DirectX is the best, but let's face it - he who has the most resources wins and Microsoft, Intel, and AMD have a hell of a lot of resources. I just don't see Linux doing anything else unless MS really screws up bad. MS could, and probably has, ........ed off half of its customers but they stay lucrative because MS has managed to corner the market in that 90% of software out there only runs on their OS.

    Learn GL if you want but don't dump the power of DirectX components simply for cross-platform. Also the cross-platform barrier between console and PC is becoming less and less distinct as Microsoft gives hints at it's new API which bridges the gap between the two. DirectX 10 will change everything.

    And nowhere in the post did I demean your abilities as a programmer or promote my own. I could care less who is the best because there is always someone who knows more - so it is a moot point. At no point do I think that I'm superior to anyone on this board but I am advising you to re-think your approach to the OpenGL/DirectX debacle. If you want to learn GL then do so and use DirectSound or DirectMusic for sound. If you have to have cross-platform then use FMOD or something else, but I warn you and the million like you. FMOD and SDL will fail you at some point. You MUST learn the underlying structures, architecture, and programming principles for sound, input, networking, and the like if you ever hope to create a game. You absolutely must understand it. Don't avoid that stuff or let someone else's API do it for you.

    Right now it doesn't get any lower than DirectX and you can do your own mixing, etc. Thank God the days of PIC programming and DMA programming are over, but DX still gives you a lot of control over the hardware. Learn it and learn about sound programming in general. You won't regret it. Otherwise, let some other 3rd party API do it for you and just blindly use it.
    Last edited by VirtualAce; 02-23-2006 at 01:33 AM.

  9. #9
    60% Braindead
    Join Date
    Dec 2005
    Posts
    379
    Though its nice to know both languages - it seems useless to understand DirectX if you're coding in linux. However - if you're thinking comercial, you are probably going to need knowledge of both, unless you happen to be hired as a "specialist".

    If you're shooting for a hobby, and just want to be able to run on both platforms, hell try OpenGL. Their are many factors involved, but it shouldent be to hard to switch languages (A bit time consuming, but not difficult).

    Knowing both is always a plus, it gives you much greater flexibility. But dont listen to me - go with your gut :P.
    Code:
    Error W8057 C:\\Life.cpp: Invalid number of arguments in function run(Brain *)

  10. #10
    pwns nooblars
    Join Date
    Oct 2005
    Location
    Portland, Or
    Posts
    1,094
    Commercial programming isn't everything. I don't plan on going commercial with any of the gamming programming I am doing. I develop tools/apps for a living, 90% of the time not even coding in C++ because the deadlines are short and I just need to get it done which means it falls down to Perl usually since I work with a lot of text. Crossplatform is good for me since some of my friends prefer linux and they will be some of the only people to play what ever games I put out there.

    Hey genius....OpenGL is graphics only. So sit down, quiet down, and listen up.
    Right there is where you demeaned my abilities as a programmer or promoted your own. I don't think I or anyone else deserved that.

    The $$ has nothing to do with how or why I am learning my gaming stuff. If/when they release DirectX for linux without having to resort to WineX, then I wont care at all really what API I am using. You never gave reasons to stick with the DirectSound/Music in your first or second post, just said it to use it. I can see why I should continue to learn DirectX, if it allows for access to lower level stuff. Nothing on this board hinted to the fact that DirectSound is as you say it is, so I had no reason to think you were suggesting it like that other than you being a DirectX fanboy.

    I use plenty of modules at work for Perl, each has their on API, for the most part when looking at 2 XML or 2 INI mods, the only difference is syntax and occassionally an extra obscure feature that only the author ever needed on like one occasion. I was assuming that the different APIs for sound/input/graphics were the same, other than one in is crossplatform and the other isn't.

    Thank you for clairfying more.

  11. #11
    Registered User
    Join Date
    Sep 2004
    Posts
    197
    Quote Originally Posted by Bubba
    Give me one good reason as to why cross-platform is even remotely important as it relates to game programming. Cross-platform doesn't mean squat when nearly every game coded only runs on x86 Windows machines. It has been that way, is that way, and always will be that way.
    First, let me give you a nice list
    Quake 4
    Doom 3
    Unreal Tournament 2004
    Unreal Tournament 2003
    Quake 3
    Unreal Tournament
    Quake 2
    Tribes 2

    That's just out of one genre of games that have Linux ports, Never Winter Nights also had a native Linux port. I know most of the titles I mentioned are from 2 major developers (id Software and Epic Games) but you will notice they make a killing just off licensing the engine, which includes Linux for those companies that want it.

    Also, you will find that even FPS games that strictly have a Windows client will have a Linux server binary available due to a large number of hosting providers using it for hosting.

    Don't forget about Mac OS either, the move to Intel I think might just give it a good kick into the gaming market. Blizzard has been targeting the Mac OS platform for years.

    Oh, and should I even mention the reported use of OpenGL by the PlayStaion3?

    Small Edit: forgot to mention, how many CAD/Modeling programs use Direct3D for rendering? Its an OpenGL world there, has been for a long time.

    Oh, and since when has DirectSound been low level? Its an abstraction layer, just like SDL/OpenAL.
    Last edited by Xipher; 02-23-2006 at 09:14 AM.
    If any part of my post is incorrect, please correct me.

    This post is not guarantied to be correct, and is not to be taken as a matter of fact, but of opinion or a guess, unless otherwise noted.

  12. #12
    vae victus! skorman00's Avatar
    Join Date
    Nov 2003
    Posts
    594
    Just to throw my 2 cents out there:
    Being platform independant doesn't just mean it runs on a Linux based machine, it also means it runs on a machine that uses any OS and any processor architecture (provided an implimentation has been made for that architecture). This makes it very easy to port a PC developed game to a Console, or vice versa.

    I would agree with Bubba about using SDL, because SDL requires that you bring in the whole shebang (graphics, input, sound, etc). You will have an SDL window around in the background unless you perform some tricks to get rid of it, but it's not worth it.

  13. #13
    Super Moderator VirtualAce's Avatar
    Join Date
    Aug 2001
    Posts
    9,584
    I can see why I should continue to learn DirectX, if it allows for access to lower level stuff. Nothing on this board hinted to the fact that DirectSound is as you say it is, so I had no reason to think you were suggesting it like that other than you being a DirectX fanboy.
    Click the link and buy the book. DirectSound is very low level. When I can lock the primary buffer, retrieve the write cursor and read cursor for it, lock secondary buffers and directly manipulate and perform algorithmic effects on the data and then remix that into the primary buffer, I'd say that's pretty low level.

    You won't be programming the DMA, DSP or PIC, but who is really going to miss that?

    And as for OpenGL vs Direct3D. There will always be OpenGL and there will always be Direct3D. DirectX is more than Direct3D and it, too, will be around for a very long time.

    DirectX is not hard. Why do people think COM is so hard? COM is brilliant and IMO is a better object oriented design than C++ itself.
    Use one interface to get another to open up more functionality.
    It's like a big toolbox. Direct3D is not hard, OpenGL is not hard.......the APIs are a snap.

    Now using them to accomplish what you want, now that is where it gets hard. Just getting data to the screen and texturing it is about um...5% of the battle.
    Last edited by VirtualAce; 02-23-2006 at 01:12 PM.

  14. #14
    Supermassive black hole cboard_member's Avatar
    Join Date
    Jul 2005
    Posts
    1,709
    Quote Originally Posted by Bubba
    Click the link and buy the book. DirectSound is very low level. When I can lock the primary buffer, retrieve the write cursor and read cursor for it, lock secondary buffers and directly manipulate and perform algorithmic effects on the data and then remix that into the primary buffer, I'd say that's pretty low level.

    You won't be programming the DMA, DSP or PIC, but who is really going to miss that?

    And as for OpenGL vs Direct3D. There will always be OpenGL and there will always be Direct3D. DirectX is more than Direct3D and it, too, will be around for a very long time.

    DirectX is not hard. Why do people think COM is so hard? COM is brilliant and IMO is a better object oriented design than C++ itself.
    Use one interface to get another to open up more functionality.
    It's like a big toolbox. Direct3D is not hard, OpenGL is not hard.......the APIs are a snap.

    Now using them to accomplish what you want, now that is where it gets hard. Just getting data to the screen and texturing it is about um...5% of the battle.
    I agree with your view of COM. I've only recently started to delve into it by looking into DirectX and so far I'm finding it easy to work with.

    I don't like the idea of getting myself into a DirectX vs. OpenGL war, so I'll be going now.

    EDIT: I'm finding the hardest part of game programming is structuring my modules in a way that keeps a strict interface and makes it painless to integrate new features. I really should move away from GLUT because it needs to use callback that I've found impossible to encapsulate thus they're dotted all over my main module in a fashion less that satisfactory. To me.

    Sure drawing can be a pain in the ass. I found it annoying trying to texture quads in OpenGL without skewing the texture, but I think I've got the hang of it now.

    EDIT2: I know structuring isn't specific to game programming, it's just I've never really practiced it to such an extreme before.
    Last edited by cboard_member; 02-23-2006 at 01:24 PM.
    Good class architecture is not like a Swiss Army Knife; it should be more like a well balanced throwing knife.

    - Mike McShaffry

  15. #15
    Registered User
    Join Date
    Sep 2004
    Posts
    197
    Ok, first, I want to say I didn't mean to bad mouth DirectX, but simply the "Gaming is a windows world, keep Linux out of it" mentality.
    Every game I linked to, uses DirectX directly for there Windows version, as they should since its native, and requires less overhead then SDL, which I believe actually uses it on the Windows side IIRC, and adding extra function calls between you and what you need to can just degrade performance. From what I have seen, the Windows and Linux code for every game that supports both, are only partially platform independent, but when it comes down to input handling, networking (not too much different between WinSock and BSD sockets really), and even rendering, they will use platform specific code, simply due to performance reasons. Also, as for audio in Linux, OpenAL could a possible alternative, and is also supported in Windows, but I think it would be better to just use DirectSound instead (Quake 4 using OpenAL in windows, sounds weird, like your in a tin can with a few nukes going off).

    Also, normally when I think low level, I'm thinking direct hardware calls, hence why I didn't understand what you ment by low level, but I understand now.
    Last edited by Xipher; 02-23-2006 at 04:20 PM.
    If any part of my post is incorrect, please correct me.

    This post is not guarantied to be correct, and is not to be taken as a matter of fact, but of opinion or a guess, unless otherwise noted.

Page 1 of 2 12 LastLast
Popular pages Recent additions subscribe to a feed

Similar Threads

  1. DirectX vrs. OpenGL - Witch one is better?
    By Queatrix in forum Windows Programming
    Replies: 5
    Last Post: 02-23-2006, 02:32 PM
  2. Allegro, OpenGL.. or even DirectX?
    By Zeusbwr in forum C++ Programming
    Replies: 1
    Last Post: 11-14-2004, 07:16 AM
  3. Which is better: OpenGL or DirectX
    By Stan100 in forum Game Programming
    Replies: 2
    Last Post: 05-09-2003, 04:43 PM
  4. OpenGL 2 or DirectX ?
    By alex6852 in forum A Brief History of Cprogramming.com
    Replies: 9
    Last Post: 01-02-2003, 01:31 PM
  5. So.. what's the difference between DirectX and OpenGL?
    By QuestionC in forum Game Programming
    Replies: 6
    Last Post: 01-19-2002, 05:18 PM

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21