Home
Products
Community
Manuals
Contact
Login or Signup

Various methods to detect opengl?

BlitzMax Forums/BlitzMax OpenGL Programming/Various methods to detect opengl?

Robert Cummings(Posted 1+ years ago) #1
Hi,

What are actually the various methods to detect the presence of opengl?

I'd like to be able to return if opengl is in hardware of software mode.

Apologies if you have read a similar post, but I felt this forum more approporite for this kind of question.

I can't benchmark it as it is very unreliable on some cpus. For example the cpu may be the slow factor.


ImaginaryHuman(Posted 1+ years ago) #2
I really don't think that OpenGL has any intention of reporting to you that it is or it not hardware accelerated. They make a point of being cross-platform and hardware/implementation independent. OpenGL itself probably doesn't know how its driver is implemented. It is unaware of whether it runs on hardware or software, or should be.
It is the o/s or the graphics card's driver that you probably have to talk to to find out if there is hardware acceleration active. OpenGL is supposed to be independent of its implementation, that why it is an interface to the graphics card and not the graphics card itself.

If you use SetGraphicsDriver() GLGraphicsDriver() you should know that you at least have OpenGL .. but no idea on the hardware support. DrawPixmap is *about* the same speed on a software mode as it for DrawImage because they both keep the backbuffer in main memory (possibly). That's about all I can think of.

Maybe someone else has some ideas?


skidracer(Posted 1+ years ago) #3
There are some methods outlined in the windows section of the OpenGL FAQ you may want to look into.


Robert Cummings(Posted 1+ years ago) #4
Thanks Simon. Following your advice I googled to the homepage and found:

http://www.opengl.org/resources/faq/technical/mswindows.htm#0020

To force software rendering from your application, choose a pixel format that is not hardware accelerated. To do this, you can not use ChoosePixelFormat(), which always selects a hardware accelerated pixel format when one is available. Instead, use DescribePixelFormat() to iterate through the list of available pixel formats. Any format with the PFD_GENERIC_FORMAT attribute bit set will not be hardware accelerated.


Now... how to do this in Blitzmax?


Robert Cummings(Posted 1+ years ago) #5
Actually: 5.040 How do I know my program is using hardware acceleration on a Wintel card?




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".)

You can also gather performance data by rendering into the back buffer and comparing the results against known performance statistics for your device. This method is particularly useful for devices that revert to software rendering for some state combinations or OpenGL features. See the section on performance for more information.



This is better information but still confused how to do this in Blitzmax...


Robert Cummings(Posted 1+ years ago) #6
Ok after a discussion on IRC about it with noel, this transpired:

SuperStrict
Framework Pub.OpenGL
Import Brl.StandardIO
Import Brl.GLGraphics
Try
GLGraphics( 320, 240, 0 )
Print String.FromCString(glGetString( GL_RENDERER ))
Print String.FromCString(glGetString( GL_VENDOR ))
Print String.FromCString(glGetString( GL_VERSION ))
Print String.FromCString(glGetString( GL_EXTENSIONS ))
Catch o:Object
Print o.ToString( )
End Try
End


Problem is, we have to open an opengl window, but if that fails there is always try and catch.

What I need to know next is: what strings to look out for? What will happen on 95, 98, Me and windows NT machines?


Robert Cummings(Posted 1+ years ago) #7
I am more interested in doing this:

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.


Because sometimes the GL_RENDERER field is blank for machines WITH and WITHOUT opengl Hardware acceleration!

Any ideas?