                            GLFULLSCREEN.ASM
      ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
      An example of how to use OpenGL in fullscreen (What a surprise!)

By hardCode <http://bizarrecreations.webjump.com>

This example demonstrates how to run OpenGL application at full screen.
There are two general ways to achieve this. Either thru ChangeDisplaySettings 
API or by involving DirectDraw interface. Note that OpenGL itself doesn't 
provide any services for switching to fullscreen mode. Also bear in mind 
that there are several different implementations of OpenGL. E. g. Microsoft 
OpenGL (this one comes with your OS), Silicon Graphics OpenGL for Windows 
(available as SGI's OGL SDK), Mesa OpenGL (for 3Dfx hardware), and maybe 
several more (nothing comes to mind).

There are some major differences between these implementations, one of which 
affects fullscreen operations. Due to the fact that SGI's OpenGL overloads 
certain GDI functions (namely PixelFormat API), it's always able to return 
correct pixel format and, thus, handle rendering operations correctly when 
display mode switching occurs. As opposed to it, MS OpenGL fails to operate 
when you're trying to switch to the bitdepth, different from currently 
selected for your desktop.

! Bear in mind that you must link OpenGL libs before GDI32 in order to let 
  the linker to solve overloaded externals in favor of OpenGL.!

Also note that you don't have to bother with DDraw surfaces, all you need is 
fullscreen exclusive mode.
All above is concerning DirectDraw.
Another issue is that ChangeDisplaySettings apparently always fails to switch 
to bitdepths which differ from currently used. But resolution change is always 
working with this method (at least for us).
As a home task one may try to get rid of the task bar, when changing 
resolution this way :-)

The example program tryes to load ddraw.dll and use its API, and if it fails 
to do so (DirectX not installed) it tryes to use standard Windows API.

If program won't compile, because of undefined constants, try to add the 
following to your windows include file.

;--------------------------- cut here --------------------------------------
DM_LOGPIXELS		EQU     00020000h
DM_BITSPERPEL		EQU	00040000h
DM_PELSWIDTH		EQU	00080000h
DM_PELSHEIGHT		EQU	00100000h
DM_DISPLAYFLAGS		EQU	00200000h
DM_DISPLAYFREQUENCY	EQU	00400000h
DM_PANNINGWIDTH		EQU	00800000h
DM_PANNINGHEIGHT	EQU	01000000h
;---------------------------------------------------------------------------

CDS_* flags are defined in our OpenGL include file.


Also make sure that the DEVMODE structure is defined like this:

DEVMODEA STRUCT DWORD
  dmDeviceName      BYTE   CCHDEVICENAME dup(?)
  dmSpecVersion     WORD      ?
  dmDriverVersion   WORD      ?
  dmSize            WORD      ?
  dmDriverExtra     WORD      ?
  dmFields          DWORD     ?
  dmOrientPosition  POSITION_ORIENTATION <>
  dmScale           WORD      ?
  dmCopies          WORD      ?
  dmDefaultSource   WORD      ?
  dmPrintQuality    WORD      ?
  dmColor           WORD      ?
  dmDuplex          WORD      ?
  dmYResolution     WORD      ?
  dmTTOption        WORD      ?
  dmCollate         WORD      ?
  dmFormName        BYTE CCHFORMNAME dup (?)
  dmLogPixels       WORD      ?
  dmBitsPerPel      DWORD      ?
  dmPelsWidth       DWORD      ?
  dmPelsHeight      DWORD      ?
  dmDisplayFlags    DWORD      ?
  dmDisplayFrequency  DWORD      ?
  dmICMMethod       DWORD ?
  dmICMIntent       DWORD ?
  dmMediaType       DWORD ?
  dmDitherType      DWORD ?
  union
   dmReserved1       DWORD ?
   dmICCManufacturer DWORD ?
  ends
  union
   dmReserved2      DWORD ?
   dmICCModel       DWORD ?
  ends
  dmPanningWidth    DWORD ?
  dmPanningHeight   DWORD ?
DEVMODEA ENDS


DEVMODEW STRUCT DWORD
  dmDeviceName      WCHAR   CCHDEVICENAME dup(?)
  dmSpecVersion     WORD      ?
  dmDriverVersion   WORD      ?
  dmSize            WORD      ?
  dmDriverExtra     WORD      ?
  dmFields          DWORD     ?
  dmOrientPosition  POSITION_ORIENTATION <>
  dmScale           WORD      ?
  dmCopies          WORD      ?
  dmDefaultSource   WORD      ?
  dmPrintQuality    WORD      ?
  dmColor           WORD      ?
  dmDuplex          WORD      ?
  dmYResolution     WORD      ?
  dmTTOption        WORD      ?
  dmCollate         WORD      ?
  dmFormName        WCHAR CCHFORMNAME dup (?)
  dmLogPixels       WORD      ?
  dmBitsPerPel      DWORD      ?
  dmPelsWidth       DWORD      ?
  dmPelsHeight      DWORD      ?
  dmDisplayFlags    DWORD      ?
  dmDisplayFrequency  DWORD      ?
  dmICMMethod       DWORD ?
  dmICMIntent       DWORD ?
  dmMediaType       DWORD ?
  dmDitherType      DWORD ?
  union
   dmReserved1       DWORD ?
   dmICCManufacturer DWORD ?
  ends
  union
   dmReserved2      DWORD ?
   dmICCModel       DWORD ?
  ends
  dmPanningWidth    DWORD ?
  dmPanningHeight   DWORD ?
DEVMODEW ENDS

IFDEF UNICODE
 DEVMODE EQU <DEVMODEW>
ELSE
 DEVMODE EQU <DEVMODEA>
ENDIF

;---------------------------------------------------------------------------
