Pages: [1] 2 3
  Print  
Author Topic: DirectX 9 Implemented and Working! <Functions Can Now Be Written>  (Read 8554 times)
Offline (Male) Goombert
Posted on: July 28, 2013, 05:33:28 PM

Contributor
Location: Cappuccino, CA
Joined: Jan 2013
Posts: 2983

View Profile
After trying this several times with DirectX 10 and failing, I decided to give DX one more chance to be a part of our game engine, and it finally worked with DX9. The headers and libraries are distributed with MingW for DX9 so no need to install the Windows or DirectX SDK, if you are on Windows you will simply be able to switch it under API settings and use it. Now of course not all functions have been implemented, the implementation status is listed below. This will increase the compatibility of ENIGMA on native Windows platforms and for those people Micro$hit likes to screw over with bad OpenGL support.

So we are now looking particularly for Windows users to help implement the graphics functions for DirectX. There's a lot of functions to be done, varying in difficulty so people from all skill-levels should be able to help. I am going to be writing a ton of the code as well, your help is going to be appreciated.

Currently Implemented:
 Sprites: Full support
 Backgrounds: Full support
 Models: Full support
 Primitives: Full support
 Tiles: No Support
 Fog: Experimental Support
 Transformations: Almost full support
 Projections: Full support
 Views: Experimental Support
 Curves: No support
 Standard Draw: Almost full support
 Lighting: Experimental Support
 Shaders: Limited or Buggy support
 Text and Font: Full support
 Particle Effects: No support
 Surfaces: Almost full support
 Texture: Limited or Buggy support
 Blend Modes and Color: Full support
 Vertex Formats: No support
« Last Edit: November 29, 2013, 06:46:36 PM by Robert B Colton » Logged
Offline (Unknown gender) fervi
Reply #1 Posted on: July 29, 2013, 03:21:00 PM
Member
Joined: Feb 2013
Posts: 75

View Profile Email
Yay

Now we need DX6, because I want to create games for Windows 98

Maximum trolling

Fervi
Logged
Offline (Unknown gender) forthevin
Reply #2 Posted on: July 29, 2013, 05:03:00 PM

Contributor
Joined: Jun 2012
Posts: 171

View Profile
Very nice, having DirectX set up and working will make further development on it much easier. While it in principle ought to be enough to be able to use OpenGL, that may not be the best solution on Windows for a given game, and supporting DirectX will give them the choice of which graphics system to use. While it may be an extra burden, it can be expanded upon bit by bit, and with a future test suite over the graphics, all the tests that we write for the OpenGL graphics systems can be reused for DirectX, and vice versa, given that the interface for using the graphics system is the same between implementations.
Logged
Offline (Male) Goombert
Reply #3 Posted on: July 29, 2013, 06:57:27 PM

Contributor
Location: Cappuccino, CA
Joined: Jan 2013
Posts: 2983

View Profile
Well not only that forthevin but we have already had people here whose hardware supports DirectX10 and 11 but not OpenGL 1, you know how Micro$hit likes to be. This will definitely increase the compatibility of our engine, its just a matter of hardware is all. And though you can forget about the likely possibility of Xbox port, this does make ENIGMA much more portable if we were to do so for various Windows platforms, including Windows Phone. There is also a difference between the API's let us not forget Game Maker was designed with Direct3D for most of its rendering, and OpenGL has been causing visual anomalies in some games just due to the difference in their function specifications. Also with DirectX you can switch between software and vertex processing at runtime, there is no such thing as an immediate mode in DX which makes the code much more durable.

Anyway, I have implemented some projection, color, lighting, fog, and transform functions, please merge.
https://github.com/enigma-dev/enigma-dev/pull/278
My primary focus is to get sprites, backgrounds, and models/primitives working and hopefully we can set it as the default Graphics System for Win32. When this occurs I will set up a Direct3D 10 and 11 graphics system, most of the code should just be copy and paste work.
« Last Edit: July 29, 2013, 07:07:36 PM by Robert B Colton » Logged
Offline (Male) Josh @ Dreamland
Reply #4 Posted on: July 30, 2013, 05:44:42 AM

Prince of all Goldfish
Developer
Location: Ohio, United States
Joined: Feb 2008
Posts: 2925

View Profile Email
The intention is to keep the interfaces all but identical, forthevin. I believe it's in our best interest to encourage DirectX on Windows and OpenGL on Mac/Linux. The differences in behavior should be minimized, if not eliminated, to prevent any incidents with porting.

This will be necessary, anyway, for when we start "officially" supporting embedded systems.

Personally, though, I think DX9 Is a step in the wrong direction. Nothing written for it will be compatible with DX10 or 11.

DirectX11 would be my personal choice in target. It works on newer Windows service packs, and on the XBox One, which if anyone actually purchases, promises to support homebrew natively.
Moreover, DirectX11 has this. It's an XNA-like layer over DirectX11. As far as I know, it's .NET free. So you could use its SpriteBatch class for a quick, efficient solution.

Note: All ENIGMA games which use DirectXTK will have to be closed-source due to intentional licensing conflicts by Microsoft.
« Last Edit: July 30, 2013, 05:49:53 AM by Josh @ Dreamland » Logged
"That is the single most cryptic piece of code I have ever seen." -Master PobbleWobble
"I disapprove of what you say, but I will defend to the death your right to say it." -Evelyn Beatrice Hall, Friends of Voltaire
Offline (Male) Goombert
Reply #5 Posted on: July 30, 2013, 06:27:28 AM

Contributor
Location: Cappuccino, CA
Joined: Jan 2013
Posts: 2983

View Profile
Quote
Personally, though, I think DX9 Is a step in the wrong direction.
Completely disagree, one good thing about ENIGMA is its compatibility, we can run in virtual machines where Stupido is not capable of doing so. Microsoft likes to be bastards with OpenGL support, and once I get the hang of DX it won't take long and I'll be working on DX10 and 11.
Logged
Offline (Unknown gender) TheExDeus
Reply #6 Posted on: July 30, 2013, 06:58:36 AM

Developer
Joined: Apr 2008
Posts: 1886

View Profile
Well one reason why Rober chose DX9 is because MinGW already has it. I personally also don't want a requirement to install a 10GB sdk or something. Of course if the installation would be painless, then the problem wouldn't be that big.
Also, at least for now, we don't support anything that could use the new features. I personally don't have any use for DX anyway. OGL support is clearly good enough to even support FBO's on Intel Cards, so I don't have any problems with it. I would more gladly create an android port.
Logged
Offline (Male) Josh @ Dreamland
Reply #7 Posted on: July 30, 2013, 07:06:48 AM

Prince of all Goldfish
Developer
Location: Ohio, United States
Joined: Feb 2008
Posts: 2925

View Profile Email
Supposedly, thanks to the WINE team, it comes with DX10, too. There was just some difficulty using it, which isn't surprising.

Either way, if he's comfortable writing these functions for all of them, that's fine; the ones which are most used will naturally be the most maintained. I fear DX10 will basically never be used, but, que sera, sera.
Logged
"That is the single most cryptic piece of code I have ever seen." -Master PobbleWobble
"I disapprove of what you say, but I will defend to the death your right to say it." -Evelyn Beatrice Hall, Friends of Voltaire
Offline (Unknown gender) TheExDeus
Reply #8 Posted on: July 30, 2013, 11:12:44 AM

Developer
Joined: Apr 2008
Posts: 1886

View Profile
DX10 isn't really used in games either. It's always DX9 or DX11, never DX10. Probably because it didn't give that much useful features to substantiate the changes necessary to any big engine.
Logged
Offline (Male) Goombert
Reply #9 Posted on: July 30, 2013, 04:09:36 PM

Contributor
Location: Cappuccino, CA
Joined: Jan 2013
Posts: 2983

View Profile
I don't care about all that, I care about the people who come here and don't have OGL support, that's great if it works good for all of us, but it doesn't help us if we just ignore those people, and DX9 is just a stepping stone in DX10 and DX11 for me, I am going to write them all. We already have GLES for other embedded systems, it's dumb that we ignore the operating system that controls 90% of the market, which is not going to favor in our interest.

Anyway, I disagree that its not going to be used either, look Game Maker's 3D functions were designed around Direct3D, we've had to do screwy shit to get things to work exactly like they do in Game Maker because of the differences in OGL vs DX, not that we shouldn't get our OGL system as close as possible, I am just saying using a D3D graphics system would make those anomalies a lot less possible. Not to mention the code is much easier to work with, the code I've written so far has been a lot less bloated than OGL, and its not as convoluted with all the extensions and querying. Because you are targeting a specific version, you already know what and what you can not work with, not to mention there is no "immediate mode" so you can switch between hardware/software vertex processing at runtime, this has always been an important thing with DirectX when new technology comes out because it allows people to choose to try and emulate it if they don't have proper graphics hardware.
Logged
Offline (Male) Goombert
Reply #10 Posted on: July 31, 2013, 02:08:41 AM

Contributor
Location: Cappuccino, CA
Joined: Jan 2013
Posts: 2983

View Profile
Guys, hey I got the #1 reason we are going to use DX now, look at the updated screen shot, that is 50,000 draw_sprite calls at 30fps, OpenGL can't handle 15,000 on my pc at more than 12fps. That is utilizing DX's internal sprite batching class, please proceed with the DirectX vs. OpenGL debates. :P

Please merge pull request....
https://github.com/enigma-dev/enigma-dev/pull/283

Also to prove my point, this is the d3d blend modes and their OpenGL and Direct3D equivalents.
Code: [Select]
  bm_zero             =  1,  // GL_ZERO                  D3DBLEND_ZERO
  bm_one              =  2,  // GL_ONE                   D3DBLEND_ONE
  bm_src_color        =  3,  // GL_SRC_COLOR             D3DBLEND_SRCCOLOR    //only for dest
  bm_inv_src_color    =  4,  // GL_ONE_MINUS_SRC_COLOR   D3DBLEND_INVSRCCOLOR //only for dest
  bm_src_alpha        =  5,  // GL_SRC_ALPHA             D3DBLEND_SRCALPHA
  bm_inv_src_alpha    =  6,  // GL_ONE_MINUS_SRC_ALPHA   D3DBLEND_INVSRCALPHA
  bm_dest_alpha       =  7,  // GL_DST_ALPHA             D3DBLEND_DESTALPHA
  bm_inv_dest_alpha   =  8,  // GL_ONE_MINUS_DST_ALPHA   D3DBLEND_INVDESTALPHA
  bm_dest_color       =  9,  // GL_DST_COLOR             D3DBLEND_DESTCOLOR     //only for src
  bm_inv_dest_color   = 10,  // GL_ONE_MINUS_DST_COLOR   D3DBLEND_INVDESTCOLOR  //only for src
  bm_src_alpha_sat    = 11   // GL_SRC_ALPHA_SATURATE    D3DBLEND_SRCALPHASAT   //only for src

So like I said the graphics portion of Game Maker was designed around D3D, obviously because of the function naming as well, so this definitely will cut down on visual anomalies in games. I've also noticed the transform functions have the same behavior as one would expect in Game Maker.
« Last Edit: July 31, 2013, 03:17:17 AM by Robert B Colton » Logged
Offline (Unknown gender) TheExDeus
Reply #11 Posted on: July 31, 2013, 04:14:01 AM

Developer
Joined: Apr 2008
Posts: 1886

View Profile
Quote
Guys, hey I got the #1 reason we are going to use DX now, look at the updated screen shot, that is 50,000 draw_sprite calls at 30fps, OpenGL can't handle 15,000 on my pc at more than 12fps. That is utilizing DX's internal sprite batching class, please proceed with the DirectX vs. OpenGL debates. :P
That is because we don't use any batching at all. But I do have a proposition for it here: http://enigma-dev.org/forums/index.php?topic=1380.0 (which no one seems to read). In managed to get 30FPS with 100k sprites. But it will probably be slower (or the same, maybe even faster, wtfk) in the final implementation. So I doubt that in proper implementation one is any faster than the other.

Quote
Also to prove my point, this is the d3d blend modes and their OpenGL and Direct3D equivalents.
No one ever doubted that GM was based on D3D.... because everyone know it's based on D3D.... even D3D functions have a prefix.. wait for it... D3D.

Quote
We already have GLES for other embedded systems
Sadly we don't. I would really want an android port, but the framework it requires (together with a shit ton of configuration for SDK/NDK) makes it all hard to do. Maybe I'll just try making GLES run on Windows (if that is even possible) and then try to make it work on another device.
« Last Edit: July 31, 2013, 04:16:07 AM by TheExDeus » Logged
Offline (Male) Goombert
Reply #12 Posted on: July 31, 2013, 04:18:36 AM

Contributor
Location: Cappuccino, CA
Joined: Jan 2013
Posts: 2983

View Profile
Quote
Sadly we don't. I would really want an android port, but the framework it requires (together with a shit ton of configuration for SDK/NDK) makes it all hard to do. Maybe I'll just try making GLES run on Windows (if that is even possible) and then try to make it work on another device.
Nonsense Harri, I have faith in you  :)

Edit: We can also add the display_reset for AA it's just a flag in the D3D present parameters. And now I get my full 8 levels of MSAA and Morphological anti-aliasing provided by my ATI Radeon graphics card, so I still say the fuck with OpenGL. The Direct3D code is much more abstract but yet so much more compact and easier to read and write.

Edit 2:

Text rendering and fonts on the way!!!
« Last Edit: July 31, 2013, 06:31:59 AM by Robert B Colton » Logged
Offline (Male) Josh @ Dreamland
Reply #13 Posted on: July 31, 2013, 06:32:07 AM

Prince of all Goldfish
Developer
Location: Ohio, United States
Joined: Feb 2008
Posts: 2925

View Profile Email
If you're getting 50,000 sprite draws at 30 fps, my guess is that you have the batching on at full power. What I mean is, try drawing an arm sprite, then drawing a torso sprite over that, then drawing another arm sprite over that. You'll probably be disappointed.
« Last Edit: July 31, 2013, 07:31:54 AM by Josh @ Dreamland » Logged
"That is the single most cryptic piece of code I have ever seen." -Master PobbleWobble
"I disapprove of what you say, but I will defend to the death your right to say it." -Evelyn Beatrice Hall, Friends of Voltaire
Offline (Male) Goombert
Reply #14 Posted on: July 31, 2013, 07:22:40 AM

Contributor
Location: Cappuccino, CA
Joined: Jan 2013
Posts: 2983

View Profile
Me and Josh did a few test cases and the sprite batch does properly organize depths, and in fact transformations can be applied to the sprites/backgrounds/text to turn them into 3D billboards like many people do in Game Maker.
Logged
Pages: [1] 2 3
  Print