Why you should use OpenGL and not DirectX

0 favourites
From the Asset Store
2D fighting template based in the game that defined the fighting games genre.
  • Found this linked from the TIGS forum, and I thought it to be an interesting read:

    http://blog.wolfire.com/2010/01/Why-you ... ot-DirectX

    I know, there's a lot of ARGH MICRO$$$OFT! in the article, but it really does make some good points.

    And a question for the devs: I know it's too late for C1, but what are your thoughts on OpenGL for C2, either as the sole renderer or an addition to a DX renderer? I know a lot of people who would be much more interested in Construct if it were cross-platform. Plus the open nature of the library just sort of sits better with the open-sourceness of Construct and all.

  • Try Construct 3

    Develop games in your browser. Powerful, performant & highly capable.

    Try Now Construct 3 users don't see these ads
  • However, there's one big problem: they don't work on Windows XP![/code:3scp2ru6]
    Um yeah, lets limit Construct users that can use it.
    Also i think that Developers should switch to Assembler from C++, so Construct can be more optimized.
  • OpenGL with DirectX so you could decide which one to use would be the perfect solution and who said u cant use something with XP?

  • However, there's one big problem: they don't work on Windows XP![/code:3cizza59]
    
    

    Let's correct this:

    Microsoft has worked hard on DirectX 10 and 11(...). However, there's one big problem: they don't work on Windows XP![/code:3cizza59]
    Can you see? OpenGL (up to newest) WORKS on Windows XP, but DirectX 10 and 11 doesn't work!
  • Can you see? OpenGL (up to newest) WORKS on Windows XP, but DirectX 10 and 11 doesn't work!

    And probably never will.

  • i suddenly feel like an openGL warrior.

    But yeah cross platformness is awesome, could be possible for C2 if ash is up for it

  • Also i think that Developers should switch to Assembler from C++, so Construct can be more optimized.

    are you being sarcastic or serious I cant tell....

  • > Also i think that Developers should switch to Assembler from C++, so Construct can be more optimized.

    >

    are you being sarcastic or serious I cant tell....

    Think he must be.

    OpenGl would be cool though. I still know people who don't have direct X on their PCs

  • > Also i think that Developers should switch to Assembler from C++, so Construct can be more optimized.

    >

    are you being sarcastic or serious I cant tell....

    Yes im being sarcastic, because yes OpenGL is more powerfull and you can get more Frames from it but its harder to code, so its like saying "switch from C++ to Assembler".

  • I'm not a programmer and even I know that's quite an exaggeration.

  • I don't think OpenGL is that difficult to code... it is just a misconception spread by Microsoft.

  • Construct 2 will definitely be OpenGL rendered, and there will be no DirectX renderer, at least not at first.

    DirectX 10 and 11 are not at all an option since so many people are still on XP (roughly two-thirds of all computers still use it). That leaves the choice between DirectX 9 and OpenGL. Features and performance are pretty much equivalent, so that's not part of the choice (although OpenGL can bring DX10 and DX11 features to Windows XP!).

    Cross platform is an important point, allowing the opportunity for games to run on OS X, Linux, PS3 etc without rewriting the renderer. But there are two things which make it a far better choice for Construct! OpenGL games are much easier to redistribute - OpenGL 1.1 comes preinstalled on Windows XP, so there's no need to update DirectX or install those damn "optional" updates that are actually required. So more often than not you send someone a game and it will just run, like it should.

    OpenGL is also MUCH easier to program for! I also don't know where the idea DirectX is easier came from. It is far, far more complicated, and also dumps some extremely tough problems on the developer (like lost devices). If I had a blog this would definitely make for a rant. Let me briefly cover it here anyway.

    Lost devices are when something happens to the fullscreen display, eg. something else goes fullscreen (like previewing a fullscreen game in Construct), or the computer going to sleep mode, or a fullscreen application being alt-tabbed away and restoring to the desktop. A similar problem happens if you want to resize the window. In DirectX, the application gets sent a message that says "boom, lost device, everything your program has done in DirectX has now been reverted". You now have to completely re-load the application's textures, effects, fonts, states... everything. In the editor where people preview fullscreen games, this happens regularly, and is extremely complicated to handle, not to mention the runtime also has to handle it.

    OpenGL has no notion of lost devices and handles it all for you.

    Ordinary drawing in DirectX also involves a number of steps. First you have to specify a vertex format, and define in the program a correspondingly formatted structure. Drawing a quad (a rectangular shape, eg. a sprite) involves sending to the graphics card four vertices (the corners of the box). So to do this first you create a vertex buffer, with room for four vertices allocated. You lock it, copy in four of your structs that define the four corners, and unlock it. For maximum efficiency you must also create an index buffer, with six indices, to define two triangles that draw the quad. However, for maximum efficiency, both index and vertex buffers must be as large as possible, ie. contain data for as much drawing as possible when sending them off. Because in Construct draw calls can come from all over the place (lots of different plugins render stuff), this means implementing a batching system that collects as many rendering calls as possible, generates two very large vertex and index buffers, then sends these to the GPU with a clever batch executor that runs through the saved rendering commands executing them on their associated vertices and indices. For maximum efficiency (again) you'd need to write a custom allocator (and Construct does in fact implement one), because you don't know how many rendering commands there will be, so there are thousands of small allocations every tick, so the allocation must be as optimal as possible. The code for this optimal DirectX renderer is extremely complicated and runs in to pages and pages of code with many past bugs associated with them.

    Here's how you draw a quad in OpenGL:

    glBegin(GL_QUADS);
    glVertex3f(0,0,0); // top left corner
    glVertex3f(1,0,0); // top right corner
    glVertex3f(1,1,0); // bottom right corner
    glVertex3f(0,1,0); // bottom left corner
    glEnd();[/code:2q69wpxs]
    
    You might also notice this essentially naturally is a batching system.  Just don't call glEnd(), unless the next drawn thing isn't a quad.  It's [i]trivial[/i], especially compared to the monolithic system required for DirectX.
    
    Why should end users care about how easy it is to program though?  Well, it saves hours of developer time, allowing us to work on other features and fix other bugs instead, and results in fewer bugs, because the program is simpler.
    
    Having coded a bit for OpenGL recently I have to say:  I genuinely have no idea how DirectX rose to prominence.  Any developer who tried both would simply use OpenGL because it is so much easier and has lots of benefits like multiplatform (one of those platforms being XP!).  I guess the situation the world over is like myself, using DirectX just to go with the flow since lots of big games also use it.  I guess it's testament to the genius of the Microsoft marketing department that they managed to make a complicated API which poses you with nasty problems the world's most popular graphics API.  </rant>
  • So... what exactly is good about DirectX? Is there anything worth using it for over OpenGL? Why don't all companies and software use OpenGL? I'm just curious to what you programmers have to say about it, It's interesting.

  • Daaayumm, Ash... I think they heard you all the way in Redmond

    I guess that settles that.

  • The other great thing about OpenGL is its usually emulated excellently on things like Wine. So even if we only programmed Construct for Windows XP, Linux and OSX would probably be able to run it with wine and whatever the other one is. But microsoft release so many updates to Direct X 9 that the emulators cant support all of them because theres so many and each update is incompatible with older versions.

    Btw does anyone know if Construct works on Windows 7? One of my friends has windows 7, and I sent her a Construct christmas card I made and it told her she needed to update her direct x which she couldn't be bothered doing....which took me by surprise because I thought Windows 7 would include all the versions of Direct X since its like several gigabytes big.

Jump to:
Active Users
There are 1 visitors browsing this topic (0 users and 1 guests)