DirectX?

BlitzMax Forums/BlitzMax Module Tweaks/DirectX?

xlsior(Posted 2005) [#1]
First of all, I've been playing around with the BlitzMax win32 beta, and overall I'm pretty happy with what it is capable of.

That said: While OpenGL was the obvious choice for a cross-platform compiler, I am finding that unfortunately support on windows systems somewhat... lacking.

While the OpenGL stuff is blazingly fast on my Athlon 2800+ / Radeon 9600Pro, it is excruciatingly slow on many of the older systems I have tried it on. And I'm not just talking 'a little sluggish' here.

Some very basic 2D stuff that ran -very- fast and smoothly in the original BlitzBasic on my old 600MHz laptop, runs several orders of magnitude slower when I do the same in BlitzMax. (Compaq Armada E500, ATI Rage Pro Mobility AGPx2)

All I'm talking about here is a gameloop during which a 640x480 pixel background image gets drawn, with a single 64x64 movable sprite on top. That's it.

With the original BlitzBasic, it would crank out several hundred frames a second, with a bunch of extra funtionality like a* pathfinder routines and such being used as well.
With blitzMax, just the one movable sprite (with no other features etc.) runs at a whopping 5 frames per second for me on the same laptop. I was using the standard driver that Windows 2000 provided on its own when detecting the video adapter upon installerion.
I tried downloading the 'latest and greatest' driver from Compaq's support website, but this made matters dramatically worse: the framerate decreased to may one frame per five seconds.

Yes. One frame per five seconds.

(More than likely, the updated compaq drivers did not use the hardware openGL functionality of the video adapter at all, even though the card is capable of it)

Note that I did not limit the framerate using the 'herz' parameter or something -- this is identical code, running very easily at the default 60fps on the Athlon, at a stand-still on the 600Mhz P3.

Making your programs portable to Mac & Linux is great - but I have a feeling that I'll be losing a significantly larger section of the windows market than that I would gain in the Mac/Linux area...

There are many 'older' systems that can provide pretty decent speeds with directX that don't want anything to do with OpenGL. Like it or not, DirectX is the defacto video standard on Win32.

Now, I don't know much about what is involved at a compiler level, and what the actual modules are responsible for -- but... would it be conceivable that we'll see a DirectX module for BlitzMax at some point, to reclaim compatiblity with older/slower machines that are currently left behind?

Realistically, a large number of the people that make up the puzzle / shareware market aren't exactly on the cutting edge of technology, and are likely to have lower end machines (vs. the hardcode Doom3 / unreal overclocker crowd who's machines can handle anything openGL can throw at it)

If not by blitz research themselves, what is the likelyhood that someone else could/would make such a directX module? (I'm not talking whiz-bang Direct3D functionality, but just plain vanilla DirectDraw 2D stuff.)

While openGL does give blitzmax some rather nice features, it could be -immensely- useful if you had the ability to compile both an OpenGL and DirectX version of 2D games, making minimal changes...

Anyway, with the current situation it looks like it either means losing a sizable chunk of the Win32 market, or a lot of extra work by back-porting anything you make to the old flavours of BB... Lots of work, considering the many very advanced features that BlitzMax offers, like the OOP support.

Of course, I realize that the current Win32 is still in Beta and all that, and anything is subject to change. But I don't think one could expect any graphical performance increases on the scale that would be required to make the programs usable on many mid-range systems...

Any thoughts?


Bot Builder(Posted 2005) [#2]
Yes, it is most likely that you are in fact running Micro5|-|17 software emulations of opengl, originally ptoduced to disclaim ogl as a competitor against dx.... <insert ramblings on how ogl is better but through devious business moves DX came out on top>

Anyway, true, ogl is slow on some computers but there are drivers for most cards that make ogl apps as fast if not faster than dx.


teamonkey(Posted 2005) [#3]
There's full access to the Win32 API so there's no reason that a DirectX Max2D driver couldn't be written (in fact, it looks as though Max2D was designed so that other APIs could be easily added while making it compatible)

ATI Rage Pro Mobility

My old Rage Pro Turbo only had OpenGL comptibility under NT (or 2000, I guess) and even then the acceleration wasn't fully hardware-accelerated. My old G3 PowerBook has a Rage card and has to do OpenGL in software too. Some of the older, cheaper S3 cards don't have OpenGL support either. It's a small handful of cards.

Making your programs portable to Mac & Linux is great - but I have a feeling that I'll be losing a significantly larger section of the windows market than that I would gain in the Mac/Linux area...

Indie publisher GarageGames.com won't publish games without a Mac port because the Mac market account for 65% of their sales (7% for Linux, leaving only 28% of sales for Windows). http://www.garagegames.com/index.php?sec=mg&mod=resource&page=category&qid=124#5507


xlsior(Posted 2005) [#4]
Anyway, true, ogl is slow on some computers but there are drivers for most cards that make ogl apps as fast if not faster than dx.


Well, I didn't have much look hunting down any better drivers, and I dare say that I should have better luck in that area than the 'typical' windows user who doesn't even know what a driver *is*, let alone why he would need one and where to find one.

Face it, if you make a game that runs at absolute unplayable speeds on Joe User's PC, he won't spend a lot of time trying to 'fix' it.
It's not 'oh, I'm dropping a frame every once in a while', it's I'm running a hundred times too slow.

One of two things will happen:
1) He downloaded a freebie or demo of your game, and will likely delete is 10 seconds later, never to look back at it.
2) He actually paid money to order a game, finds it runs like crap, and either you end up spending a lot of time supporting a zillion different driver issues, he will demand a refund, or both.

The average person barely reads system requirements. All they know is that they have "one of those big grey intel cases that makes the internet go faster"
OpenGL doesn't mean anything to them. No matter how big you state that you need to have a hardware OpenGL videocard with good drivers, that will just cause people's eyes to glaze over, and think "doom 2 runs just fine, how different could a simple puzzle game be?"

If nothing else, DirectX would allow you to work around a lot of problems simply because the vast majority of windows games us it, and videocard/PC makers can't really get away skimping on DirectX support like they do on OpenGL... DirectX is a big deal on Windows.

Time will tell -- But I do predict that this will become a big issue when people start releasing software to the public.


Mark Tiffany(Posted 2005) [#5]
there's no reason that a DirectX Max2D driver couldn't be written (in fact, it looks as though Max2D was designed so that other APIs could be easily added while making it compatible)

I think that was exactly the theory behind how the Max2D module was written. Max2D actually uses the glBlitz2d driver module, so there's no reason why a dx7Blitz2d driver module or softwareBlitz2D driver module couldn't be written, possibly from the BlitzPlus codebase, or even by a bright spark in the community.


BeChris(Posted 2005) [#6]
Good morning everybody.
I had the same problem all of you describe in this topic : very poor performances when running a BlitzMax app with a crappy gfx card (Sis 305).
I found it very problematic if we must have the last 3D accelerated gfx card in order to run only a 2D game.

That's why I tried to write an alternative module to Blitz2D.
After having looking for several 2D libs (portable on Linux, Win and Mac) I found both SDL and Allegro.

I was surprised how Allegro *seems* to perform better than SDL (maybe because its older).

So, I wrote a simple modules which provide a few graphics commands : Graphics, Plot, Line, DrawText, Flip ...

You can contact me if you want the source (until I find how to include link in a post) at cgouiran@...

For the moment, I only tried it under windows.

You'll need to have a working mingw/msys system (as for compiling any modules) and you'll need to install allegro before using my module.

I'm using allegro 4.1.17 (WIP).

But be warned : I was disappointed how my module didn't beform better than Max2D as I expected (even with a non accelerated 3D gfx card).

I made some very simple benchmark (drawing a spinning line on the screen) and I got the same FPS.

I must admit I have not a good skill at using Allegro but maybe someone else ...

Let me know if you're interrested in upgrading/improvind/trying this module.


ImaginaryHuman(Posted 2005) [#7]
On a G3 300Mhz ibook here, the OpenGL is fairly slow and is all in software. Just doing a screen flip by itself with no rendering or even a clearscreen doesn't run any faster than 30fps, and barely that. That's before doing any rendering or any other processing of any kind. I can add maybe a few 128x128 objects and have them move around at maybe between 16 and 25fps but that's all. That's in 32-bit color. It's not really much different in 16-bit.

We also have a 1GHz G4 iMac which has hardware accelerated OpenGL. Now, on the ibook, since it's all in software, pixmaps are the same speed (or even slightly faster) than Images. On the iMac, it can render about 10 times as many pixmaps (like 100). But using images, it can render like 100 times as much - well over 1000 images at 25fps. So the iMac is about 100 times faster. The likelihood is that the graphics card has a great deal to do with it. I don't exactly know my graphics cards but I don't think the Radeon 4MX is top of the line, probably mid-of-the-line or something.

So basically yes, if I wanted to create a game on the ibook with software OpenGL, I'm not going to get it to render very much in any quick time. It's probably sufficient for some kind of puzzle game or not-much-graphics-moving game.

In comparison, on the same ibook, there is a game called Magellan which has three full-screen layers of parallax scrolling and lots of objects flying around all over the place at 25fps. A 300Mhz G3 isn't top of the line but it's got enough juice to do quite a lot of rendering, compared to say my old Amiga. So it's not that the computer doesn't have the throughput, it's more that OpenGL is a sophisticated library that provides so much flexibility that it tends to work a lot more slowly, in software, than some customized blitting routine that knows what screenmode to expect and just wants to do simple image copies. Also everything in openGl is pretty much floating point, which must surely add greatly to the speed decrease. Drawing a pixel isn't just a matter of copying a byte, it's a matter of converting 32-bit color information into floating point values and storing it, per pixel.

So yes, on an unaccelerated system, OpenGL is going to be slower than an old-school graphics routine, but if you have a decentish graphics card it is more than capable of producing astounding amounts of output.

I like the idea that BlitzMax might have more than one graphics driver at some point. If it could allow you to use an oldschool 2D driver, as an option, for slower systems, bypassing OpenGL altogether, that would be useful. Then again, you have to think to the future. Games consoles have powerful graphics chips, lots of computers have them now too, it's going to only become much more commonplace to have a reasonably quick graphics card in your system. What used to be a luxury is fast becoming mainstream. So look to the future.


Shagwana(Posted 2005) [#8]
Allegro
I thought Allegro was a software based 2d lib (and also .sdl)
(until I find how to include link in a post
You can just copy the url to the post, like http://www.google.com


BeChris(Posted 2005) [#9]
Allegro is a 2D lib but with some parts (blitting among others) that use gfx card capabilities to be hardware accelerated.


Hotcakes(Posted 2005) [#10]
but... would it be conceivable that we'll see a DirectX module for BlitzMax at some point, to reclaim compatiblity with older/slower machines that are currently left behind?

Absolutely. Probably not as an official BRL module, but somebody round here is bound to work on something. 2D support is a good question, though. If anybody starts work on a DX8 or 9 module then you're likely to suffer similar problems on that anyway.


flying willy(Posted 2005) [#11]
I wonder why the existing blitz3d dll isn't ported and sold by BR?


BeChris(Posted 2005) [#12]
The question I'm wondering now : are people from BRL interrested to see someone providing a true 2D module (based on DirectX for Windows, for Max and Linux we will see later) ?

I'd like to have Mark and Simon point of view on this topic.

To know if it's worth the effort to do it : will they support anyone which may begin a 2D DirectX backend (maybe they could provide B+ existing backend to avoid reinventing the wheel) ?

Is it foreseen, at BRL, to write in a near future such a module ?


Hotcakes(Posted 2005) [#13]
Obviously I'm not BRL, but I highly doubt you'll be seeing a real 2D module from BRL anytime soon (or anytime late)... They've done their 2d module, the 3d module will require a -lot- of work (and if it's to be kept as a next gen engine, it will have to be at least semi-constantly updated) and DX obviously isn't portable. I highly doubt you'll ever see a module from BRL that isn't cross platform. They can't be seen as favouring one platform over the other, really, when they're trying to sell 3 identical products.

If someone were to announce (and actually intend to finish) a real 2D module written using DirectX, I would really hope BRL takes your suggestion on board, I would love to see a BlitzPlus 2D module for BlitzMax.