============
Device Guide
============

This document lists various notes, capabilities, and limitations about each |HPSNOW| driver interface. These should be taken into consideration when programming your application as not every driver interface is as capable as the others. Some have external software dependencies, and some are not compatible with |HPSNOW| (due to bugs in the vendor drivers or other limitations). See the `graphics card information page <http://developer.techsoft3d.com/hoops/hoops-visualize/graphics-cards/>`_ for more details.

In addition to conventional on-screen rendering, all driver interfaces additionally support hardware-accelerated rendering to a memory buffer. For information on how to set up an offscreen rendering context, see the :doc:`offscreen rendering </prog_guide/0702_offscreen_rendering>` section of the Programming Guide.

All |HPSNOW| windows are double-buffered.

------------------------

.. _dx11:

DirectX11
=========

The DirectX11 driver is supported on Windows platforms.

In your code, the DirectX11 interface can be selected :ref:` on this page <prog_guide/0101_database>` under the "Connecting |HPSNOW| to a Window" using the ``Window::Driver::DirectX11`` enum value.

Use of this driver allows the developer to query and select which GPU to use when running on a system that has multiple GPUs. A common example would be running on a laptop which has both an integrated GPU and a discrete graphics card, which often yield significant differences in performance and power consumption.

Users can query GPUs using ``HPS::Database::ShowAvailableGPUs()``.

Users can select which GPU to use with the new function ``SetPreferredGPU()``, which is available in the following classes:

* ``HPS::StandAloneWindowOptionsKit::SetPreferredGPU``
* ``HPS::OffScreenWindowOptionsKit::SetPreferredGPU``
* ``HPS::ApplicationWindowOptionsKit::SetPreferredGPU``


Runtime Requirements
--------------------

In order to use the DirectX11 driver, the *d3dcompiler* DLL must be made available in the execution environment of the target machine. We distribute this file with the |HPSNOW| package. 

------------------------

OpenGL2
=======

OpenGL2 is a shader-based driver interface that requires the host platform to have OpenGL 3.2+ or OpenGL ES 3.2+.


Limitations
-----------

* Post process effects (bloom, fast silhouettes, ambient occlusion, and depth of field) are not currently supported on iOS or Android due to GPU limitations on current devices.

In your code, the OpenGL2 interface can be selected :ref:`on this page<prog_guide/0101_database>` under the "Connecting |HPSNOW| to a Window" section, using the ``Window::Driver::OpenGL2`` enum value.
	
	
---------------------------

OpenGL2Mesa
===========

The OpenGL2Mesa driver is a software driver interface. This driver is functionally equivalent to our other shader drivers, however, its performance is reduced since it doesn't make use of the GPU. It's meant to provide a fallback driver on a system where no other hardware driver is available.

Please note that on Windows 10 systems, Microsoft provides a DirectX11 software fallback in case there is no GPU available in the execution environment, so this driver is normally only useful for other operating systems. On Linux, for example, it would be useful if the user doesn't have a GPU and is unable to install a Mesa driver on the system.

The OpenGL2Mesa driver is provided as a separate library, and is supported on Windows and Linux systems only. We also include a 32-bit Mesa driver binary for Windows (but not for Linux). The relevant files are named as follows:

.. csv-table::
	:header: "OS", "Driver filename"
	
	"Windows", "*hps_opengl2_mesa.dll*"
	"Linux", "*libhps_opengl2_mesa.so*"

In addition to the driver file itself, there's another dependency you must include. This is named *libHGL.so* on Linux and *hopengl32.dll* on Windows. To use the Mesa driver, both of these files need to be in the application's path (or ``LD_LIBRARY_PATH``) at runtime.
