This topic is now archived and is closed to further replies.


graphics choosing

Recommended Posts

hello_there    122
is there a test function or something that runs a test that lists all the graphics cards availiable? because my programe will only work on computers with 3dfx. i want to be able to select which card to use so it''s compatible.

Share this post

Link to post
Share on other sites
Obelix    122
You can get information about the hardware like in one of the NeHe tutorials. What does "i want to be able to select which card to use" mean? If you are talking about computers with multiple cards do I not think that you can do it. The programmer should only have to worry about OpenGL and let it take care of the low level stuff.

Share this post

Link to post
Share on other sites
Guest Anonymous Poster   
Guest Anonymous Poster
I dont know if this helps but I found this example function on an FAQ a while back. I don''t recall the address or author to give proper credit - sorry. It doesn''t directly address the problem you are having but if I was going to solve it, I would go in this direction. Hope this helps ->

-- snip --

Note: many consumer graphics cards cannot accelerate when the display is 24bpp, and many cannot accelerate when
the desktop is at 32bpp in high-resolution. I always change to 800x600 x16bpp for my full-screen games. That
ensures that the graphics card will have enough memory.

Normally, you call ChoosePixelFormat to choose a pixel format. But it''s hard to know whether this will give you
an accelerated pixel format. For us gamers, acceleration is the most important thing: we''d be happy to settle
for a 16bpp accelerated surface, rather than a 32bpp unaccelerated surface.

The following code uses a gamer''s heuristics to choose a suitable pixel format. Call it like this:

int bpp=-1; // don''t care. (or a positive integer)
int depth=-1; // don''t care. (or a positive integer)
int dbl=1; // we want double-buffering. (or -1 for ''don''t care'', or 0 for ''none'')
int acc=1; // we want acceleration. (or -1 or 0)
int pf=ChoosePixelFormatEx(hdc,&bpp,&depth,&dbl,&acc);

The function will return, in those variables, the pixel format that it choose.

int ChoosePixelFormatEx(HDC hdc,int *p_bpp,int *p_depth,int *p_dbl,int *p_acc)
{ int wbpp; if (p_bpp==NULL) wbpp=-1; else wbpp=*p_bpp;
int wdepth; if (p_depth==NULL) wdepth=16; else wdepth=*p_depth;
int wdbl; if (p_dbl==NULL) wdbl=-1; else wdbl=*p_dbl;
int wacc; if (p_acc==NULL) wacc=1; else wacc=*p_acc;
PIXELFORMATDESCRIPTOR pfd; ZeroMemory(&pfd,sizeof(pfd)); pfd.nSize=sizeof(pfd); pfd.nVersion=1;
int num=DescribePixelFormat(hdc,1,sizeof(pfd),&pfd);
if (num==0) return 0;
unsigned int maxqual=0; int maxindex=0;
int max_bpp, max_depth, max_dbl, max_acc;
for (int i=1; i<=num; i++)
{ ZeroMemory(&pfd,sizeof(pfd)); pfd.nSize=sizeof(pfd); pfd.nVersion=1;
int bpp=pfd.cColorBits;
int depth=pfd.cDepthBits;
bool pal=(pfd.iPixelType==PFD_TYPE_COLORINDEX);
bool mcd=((pfd.dwFlags & PFD_GENERIC_FORMAT) && (pfd.dwFlags & PFD_GENERIC_ACCELERATED));
bool soft=((pfd.dwFlags & PFD_GENERIC_FORMAT) && !(pfd.dwFlags & PFD_GENERIC_ACCELERATED));
bool icd=(!(pfd.dwFlags & PFD_GENERIC_FORMAT) && !(pfd.dwFlags & PFD_GENERIC_ACCELERATED));
bool opengl=(pfd.dwFlags & PFD_SUPPORT_OPENGL);
bool window=(pfd.dwFlags & PFD_DRAW_TO_WINDOW);
bool bitmap=(pfd.dwFlags & PFD_DRAW_TO_BITMAP);
bool dbuff=(pfd.dwFlags & PFD_DOUBLEBUFFER);
unsigned int q=0;
if (opengl && window) q=q+0x8000;
if (wdepth==-1 || (wdepth>0 && depth>0)) q=q+0x4000;
if (wdbl==-1 || (wdbl==0 && !dbuff) || (wdbl==1 && dbuff)) q=q+0x2000;
if (wacc==-1 || (wacc==0 && soft) || (wacc==1 && (mcd || icd))) q=q+0x1000;
if (mcd || icd) q=q+0x0040; if (icd) q=q+0x0002;
if (wbpp==-1 || (wbpp==bpp)) q=q+0x0800;
if (bpp>=16) q=q+0x0020; if (bpp==16) q=q+0x0008;
if (wdepth==-1 || (wdepth==depth)) q=q+0x0400;
if (depth>=16) q=q+0x0010; if (depth==16) q=q+0x0004;
if (!pal) q=q+0x0080;
if (bitmap) q=q+0x0001;
if (q>maxqual) {maxqual=q; maxindex=i;max_bpp=bpp; max_depth=depth; max_dbl=dbuff?1:0; max_acc=soft?0:1;}
if (maxindex==0) return maxindex;
if (p_bpp!=NULL) *p_bpp=max_bpp;
if (p_depth!=NULL) *p_depth=max_depth;
if (p_dbl!=NULL) *p_dbl=max_dbl;
if (p_acc!=NULL) *p_acc=max_acc;
return maxindex;

OpenGL doesn''t provide a direct query to determine hardware acceleration usage. However, this can usually be
inferred by using indirect methods.

If you are using the Win32 interface (as opposed to GLUT), call DescribePixelFormat() and check the returned
dwFlags bitfield. If PFD_GENERIC_ACCELERATED is clear and PFD_GENERIC_FORMAT is set, then the pixel format is
only supported by the generic implementation. Hardware acceleration is not possible for this format. For
hardware acceleration, you need to choose a different format.

If glGetString(GL_VENDOR) returns something other than "Microsoft Corporation", it means you''re using the
board''s ICD. If it returns "Microsoft Corporation", this implies you chose a pixel format that your device
can''t accelerate. However, glGetString(GL_VENDOR) also returns this if your device has an MCD instead of
an ICD, which means you might still be hardware accelerated in this case.

Another way to check for hardware acceleration is to temporarily remove or rename the ICD, so it can''t be
loaded. If performance drops, it means you were hardware accelerated before. Don''t forget to restore the
ICD to its original location or name. (To find your ICD file name, run the regedit utility and search for a
key named "OpenGLdrivers".)

Share this post

Link to post
Share on other sites