Allegro.cc - Online Community

Allegro.cc Forums » Programming Questions » Query GFX_* driver at runtime.

Credits go to Kitty Cat and Thomas Fjellstrom for helping out!
This thread is locked; no one can reply to it. rss feed Print
Query GFX_* driver at runtime.
brigham toskin
Member #2,213
April 2002

I'm trying to query which driver is loaded by allegro when you use a magic card like GFX_AUTODETECT_FULLSCREEN. I've been searching the the manual, the forums and google to no avail for a couple days now, so I guess you could call that due dilligence before asking here.

The only way I can figure to do it is search the sources and try to access whatever internal structure allegro stores such information in, but my friend assures me that there's a nicer way to do this--he just doesn't remember what it is.

It seems like this must be a very common thing. I mean, the ability to tailor your graphics effects to the card you have seems braindead-obvious. I mean, I know how to query certain capabilities of the driver, but not exactly whih one it is.

Anyone got this one?

---
I now submit to your flogging.

Thomas Fjellstrom
Member #476
June 2000
avatar

While its not recomended that you use internal structures and especially the member variables of allegro types, you can access the driver id, ex: gfx_driver->id.

First three items in the GFX_DRIVER struct are:

   int  id;
   AL_CONST char *name;
   AL_CONST char *desc;
   AL_CONST char *ascii_name;

--
Thomas Fjellstrom - [website] - [email] - [Allegro Wiki] - [Allegro TODO]
"If you can't think of a better solution, don't try to make a better solution." -- weapon_S
"The less evidence we have for what we believe is certain, the more violently we defend beliefs against those who don't agree" -- https://twitter.com/neiltyson/status/592870205409353730

kazzmir
Member #1,786
December 2001
avatar

Quote:

I mean, I know how to query certain capabilities of the driver, but not exactly whih one it is.

Do you really want to know what the underlying graphics driver is or do you mean asking Allegro what extra capabilities it supports such as hardware accelerated blitting? If the latter case you can use gfx_capabilities to determine this.

if ( gfx_capabilities & GFX_HW_VRAM_BLIT ){
  ...
}

If the former what would you do with that information anyway? Do you really want to optimize your program for a certain OS?

brigham toskin
Member #2,213
April 2002

I want to be able to know exactly which graphic driver its using because this is actually going to be part of the logged output for a quick n dirty benchmark rig I whipped up. I'm trying to get an idea of how well various rendering methods perform on different machines, and the performance numbers are less meaningful if I don't know the graphics driver.

---
I now submit to your flogging.

Kitty Cat
Member #2,815
October 2002
avatar

After setting the graphics mode, use gfx_driver->name to tell which driver was selected. gfx_driver->desc could be useful, too.

--
"Do not meddle in the affairs of cats, for they are subtle and will pee on your computer." -- Bruce Graham

Evert
Member #794
November 2000
avatar

Quote:

I'm trying to query which driver is loaded by allegro when you use a magic card like GFX_AUTODETECT_FULLSCREEN.

You typically shouldn't care and don't need to know. If for some reason you do need to know, others have already posted the information.
In either caes don't use that information to decide what your code does.

That said, you can normally assume the following:
Windows: *_AUTODETECT gives you a DirectX hardware accelerated driver, GFX_SAFE gives you GDI.
X11: *_AUTODETECT and GFX_SAFE both gives you X11, though you might be able to get DGA2 if you have root privileges.
MacOS X: Quartz, I think it's called. Doesn't matter, since there is really only one driver.
I'm not sure about Linux console, but I suspect it's the normal FB (Frame Buffer) driver.

brigham toskin
Member #2,213
April 2002

I mostly just need to know so I can give some context to the results I receive from the graphical tests I'm running, e.g. how well does rotate_sprite() perform with the test data using ddraw_accel vs. gdi on an older machine?

---
I now submit to your flogging.

Tobias Dammers
Member #2,604
August 2002
avatar

If you want to compare gfx driver performance, then why not set the desired drivers explicitly? You can always skip the test for drivers that fail.
Remember, set_gfx_mode(GFX_DIRECTX, ...) is perfectly valid. Just that it won't compile on anything but windows, and it will fail if the directx driver is not available or doesn't support the desired resolution.

---
Me make music: Triofobie
---
"We need Tobias and his awesome trombone, too." - Johan Halmén

Go to: