Board index » delphi » Hardware acceleration with OpenGL and detecting type of OpenGL driver ICD, etc...

Hardware acceleration with OpenGL and detecting type of OpenGL driver ICD, etc...

Hi all, I have a procedure below that detects what type of OpenGL driver is
being used on the computer and for example it reports the 'hardware accelerated
(ICD)' one on my computer at home.  My home computer does support OpenGL1.2 and
DirectX, but with example OpenGL programs I have I don't seem to get hardware
acceleration at all...

a)    does the procedure below work correctly?
b)    how can I utilise hardware OpenGL acceleration with my card (GeForce II-MX
400 64Mb of ram)?

PS I have Jon Q Jacobs' OpenGL book...

procedure TForm1.DetectOpenGLDriver;
const
  DRIVER_MASK = PFD_GENERIC_FORMAT or PFD_GENERIC_ACCELERATED;
var
  I,
  AccumShift: Integer;
  PFD: TPixelFormatDescriptor;
  DC: HDC;
  IDOfPixelFormat: Integer;
begin
  FillChar(PFD, SizeOf(PFD), #0);
  DescribePixelFormat(DC, IDOfPixelFormat, SizeOf(PFD), PFD);
  with PFD do
  begin
    if (DRIVER_MASK and dwFlags) = 0 then
    begin
      AccelLabel.Caption := 'hardware accelerated (ICD)';
      AccelLabel.Font.Color := clGreen;
    end
    else
    if (DRIVER_MASK and dwFlags) = DRIVER_MASK then
    begin
      AccelLabel.Caption := 'partially hardware accelerated (MCD)';
      AccelLabel.Font.Color := clOlive;
    end
    else
    if (DRIVER_MASK and dwFlags) = PFD_GENERIC_FORMAT then
    begin
      AccelLabel.Caption := 'unaccelerated (software only)';
      AccelLabel.Font.Color := clRed;
    end
    else
    begin
      AccelLabel.Caption := 'no information available';
      AccelLabel.Font.Color := clGray;
    end;
  end;
end;

Thanks,
Paul Nicholls (Delphi 5 Professional)
"If time is water, computer games are a sponge" - Paul Nicholls

HomePage: www.southcom.com.au/~phantom
Email: paul_f_nicho...@hotmail.com

 

Re:Hardware acceleration with OpenGL and detecting type of OpenGL driver ICD, etc...


Quote
Paul Nicholls wrote:
> Hi all, I have a procedure below that detects what type of OpenGL driver is
> being used on the computer and for example it reports the 'hardware accelerated
> (ICD)' one on my computer at home.  My home computer does support OpenGL1.2 and
> DirectX, but with example OpenGL programs I have I don't seem to get hardware
> acceleration at all...

> a)    does the procedure below work correctly?

You forgot the error checking. You should write
  Win32Check(DescribePixelFormat(...) <> 0);

And you will get random results because you don't initialize IDOfPixelFormat.

Quote
> b)    how can I utilise hardware OpenGL acceleration with my card?

If you call ChoosePixelFormat, Windows will choose the 'best' pixel format
available. It's unlikely that a program could make a better selection.

If a program is slow, it uses rendering commands which aren't supported by
the hardware. An ICD will emulate those calls in software, but as long as
Windows is concerned, it's done by the driver, so it must be 'accelerated'.

Many example programs on the net have been written for SGI systems and
use capabilities which are not support by 'game' cards, e.g. alpha bits,
large depth/accumulation/stencil buffers, many aux buffers, many lights.
You have to look at the specs of your card to determine what you can
use safely (=without software emulation).

If you are really curious, you can download SPECglperf from
<http://www.specbench.org/gpc/opc.static/glperf.htm> to see which calls
are accelerated under which circumstances.

HTH
Clemens

Re:Hardware acceleration with OpenGL and detecting type of OpenGL driver ICD, etc...


There's lots of reasons for slow performance other than the driver but
an easy way to see if the HW driver is beging used is the following
calls:

Memo1.Lines.Add ( 'Driver Vendor:   ' + glGetString ( GL_VENDOR ) ) ;
Memo1.Lines.Add ( 'Driver Renderer: ' + glGetString ( GL_RENDERER ) ) ;
Memo1.Lines.Add ( 'Driver Version:  ' + glGetString ( GL_VERSION ) ) ;

If the vendor is MS then its using the SW driver. Some cards, such as my
Matrox G400, require certain desktop color settings before the HW driver
can be used and it doesn't always seem logical. My Matrox only supports
GL in 16 and 32 bit mode, not 24 bit. Of course your card may be
different.

Mitch Wolberg,
RockWare, Inc.

Quote
Paul Nicholls wrote:

> Hi all, I have a procedure below that detects what type of OpenGL driver is
> being used on the computer and for example it reports the 'hardware accelerated
> (ICD)' one on my computer at home.  My home computer does support OpenGL1.2 and
> DirectX, but with example OpenGL programs I have I don't seem to get hardware
> acceleration at all...

> a)    does the procedure below work correctly?
> b)    how can I utilise hardware OpenGL acceleration with my card (GeForce II-MX
> 400 64Mb of ram)?

> PS I have Jon Q Jacobs' OpenGL book...

> procedure TForm1.DetectOpenGLDriver;
> const
>   DRIVER_MASK = PFD_GENERIC_FORMAT or PFD_GENERIC_ACCELERATED;
> var
>   I,
>   AccumShift: Integer;
>   PFD: TPixelFormatDescriptor;
>   DC: HDC;
>   IDOfPixelFormat: Integer;
> begin
>   FillChar(PFD, SizeOf(PFD), #0);
>   DescribePixelFormat(DC, IDOfPixelFormat, SizeOf(PFD), PFD);
>   with PFD do
>   begin
>     if (DRIVER_MASK and dwFlags) = 0 then
>     begin
>       AccelLabel.Caption := 'hardware accelerated (ICD)';
>       AccelLabel.Font.Color := clGreen;
>     end
>     else
>     if (DRIVER_MASK and dwFlags) = DRIVER_MASK then
>     begin
>       AccelLabel.Caption := 'partially hardware accelerated (MCD)';
>       AccelLabel.Font.Color := clOlive;
>     end
>     else
>     if (DRIVER_MASK and dwFlags) = PFD_GENERIC_FORMAT then
>     begin
>       AccelLabel.Caption := 'unaccelerated (software only)';
>       AccelLabel.Font.Color := clRed;
>     end
>     else
>     begin
>       AccelLabel.Caption := 'no information available';
>       AccelLabel.Font.Color := clGray;
>     end;
>   end;
> end;

> Thanks,
> Paul Nicholls (Delphi 5 Professional)
> "If time is water, computer games are a sponge" - Paul Nicholls

> HomePage: www.southcom.com.au/~phantom
> Email: paul_f_nicho...@hotmail.com

Other Threads