Ignore:
Timestamp:
Aug 17, 1999, 3:28:36 PM (26 years ago)
Author:
phaller
Message:

Add: added ODINWRAP support to OpenGL

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/gdi32/opengl.cpp

    r97 r526  
    1 /* $Id: opengl.cpp,v 1.3 1999-06-10 17:09:04 phaller Exp $ */
     1/* $Id: opengl.cpp,v 1.4 1999-08-17 13:28:36 phaller Exp $ */
    22
    33/*
     
    99 *
    1010 */
     11
     12
     13/****************************************************************************
     14 * Includes                                                                 *
     15 ****************************************************************************/
     16
    1117#include <os2win.h>
    1218#include <stdarg.h>
    1319#include <string.h>
     20#include <odinwrap.h>
    1421#include "misc.h"
    1522#include "unicode.h"
     23
     24
     25ODINDEBUGCHANNEL(GDI32-OPENGL)
     26
     27
     28/****************************************************************************
     29 * Definitions                                                              *
     30 ****************************************************************************/
    1631
    1732typedef int  (* WIN32API CHOOSEPIXELFMT) (HDC, CONST PIXELFORMATDESCRIPTOR *);
     
    1934typedef BOOL (* WIN32API SWAPBUFFERS) (HDC hdc);
    2035
    21 CHOOSEPIXELFMT glChoosePixelFormat = NULL;
    22 SETPIXELFMT    glSetPixelFormat    = NULL;
    23 SWAPBUFFERS    glSwapBuffers       = NULL;
    2436
    25 HINSTANCE hOpenGL = NULL;
     37/****************************************************************************
     38 * Module Global Variables                                                  *
     39 ****************************************************************************/
    2640
    27 //******************************************************************************
    28 //******************************************************************************
    29 int WIN32API ChoosePixelFormat(HDC hdc, CONST PIXELFORMATDESCRIPTOR *pformat)
     41static CHOOSEPIXELFMT glChoosePixelFormat = NULL;
     42static SETPIXELFMT    glSetPixelFormat    = NULL;
     43static SWAPBUFFERS    glSwapBuffers       = NULL;
     44static HINSTANCE      hOpenGL             = NULL;
     45
     46
     47/*****************************************************************************
     48 * Name      : internalOpenGLEnable
     49 * Purpose   : check if loaded, load OpenGL.DLL on demand
     50 * Parameters:
     51 * Variables :
     52 * Result    :
     53 * Remark    :
     54 * Status    :
     55 *
     56 * Author    : Patrick Haller [Fri, 1998/02/27 11:55]
     57 *****************************************************************************/
     58
     59static BOOL internalOpenGLEnable(void)
    3060{
    31  int rc;
     61  if(hOpenGL == NULL)
     62  {
     63     hOpenGL = O32_LoadLibrary("OPENGL32.DLL");
     64     if(hOpenGL == NULL)
     65       return(FALSE);
     66  }
    3267
    33   return(1);
    34   dprintf(("OS2ChoosePixelFormat\n"));
    35   if(hOpenGL == NULL) {
    36         hOpenGL = O32_LoadLibrary("OPENGL32.DLL");
    37         if(hOpenGL == NULL)
    38                 return(0);
    39   }
    4068  if(glChoosePixelFormat == NULL) {
    4169        glChoosePixelFormat = (CHOOSEPIXELFMT)O32_GetProcAddress(hOpenGL, "OS2wglChoosePixelFormat");
     
    4371                return(0);
    4472  }
    45   rc = glChoosePixelFormat(hdc, pformat);
    46   dprintf(("wglChoosePixelFormat returned %d\n", rc));
    47   return(rc);
    48 }
    49 //******************************************************************************
    50 //******************************************************************************
    51 BOOL WIN32API SetPixelFormat(HDC hdc, int whatever, CONST PIXELFORMATDESCRIPTOR * pformat)
    52 {
    53  BOOL rc;
    5473
    55   dprintf(("OS2SetPixelFormat\n"));
    56   if(hOpenGL == NULL) {
    57         hOpenGL = O32_LoadLibrary("OPENGL32.DLL");
    58         if(hOpenGL == NULL)
    59                 return(FALSE);
    60   }
    6174  if(glSetPixelFormat == NULL) {
    6275        glSetPixelFormat = (SETPIXELFMT)O32_GetProcAddress(hOpenGL, "OS2wglSetPixelFormat");
     
    6477                return(FALSE);
    6578  }
    66   rc = glSetPixelFormat(hdc, whatever, pformat);
    67   dprintf(("wglSetPixelFormat returned %d\n", rc));
    68   return(rc);
    69 }
    70 //******************************************************************************
    71 //******************************************************************************
    72 BOOL WIN32API SwapBuffers(HDC hdc)
    73 {
    74  BOOL rc;
    7579
    76   dprintf(("OS2SwapBuffers\n"));
    77   if(hOpenGL == NULL) {
    78         hOpenGL = O32_LoadLibrary("OPENGL32.DLL");
    79         if(hOpenGL == NULL)
    80                 return(FALSE);
    81   }
    8280  if(glSwapBuffers == NULL) {
    8381        glSwapBuffers = (SWAPBUFFERS)O32_GetProcAddress(hOpenGL, "OS2wglSwapBuffers");
     
    8583                return(FALSE);
    8684  }
    87   rc = glSwapBuffers(hdc);
    88   dprintf(("wglSwapBuffers returned %d\n", rc));
    89   return(rc);
     85
     86  return(TRUE); /* OpenGL is initialized and enabled */
    9087}
    91 //******************************************************************************
    92 //******************************************************************************
     88
     89
     90/*****************************************************************************
     91 * Name      :
     92 * Purpose   :
     93 * Parameters:
     94 * Variables :
     95 * Result    :
     96 * Remark    :
     97 * Status    :
     98 *
     99 * Author    : Patrick Haller [Fri, 1998/02/27 11:55]
     100 *****************************************************************************/
     101
     102ODINFUNCTION2(int,ChoosePixelFormat,HDC,                         hdc,
     103                                    CONST PIXELFORMATDESCRIPTOR*,pformat)
     104{
     105  //@@@PH: ?? return(1);
     106
     107  if (glChoosePixelFormat == NULL)
     108    if (internalOpenGLEnable() == FALSE)
     109      return(0);
     110
     111  return(glChoosePixelFormat(hdc, pformat));
     112}
     113
     114
     115/*****************************************************************************
     116 * Name      :
     117 * Purpose   :
     118 * Parameters:
     119 * Variables :
     120 * Result    :
     121 * Remark    :
     122 * Status    :
     123 *
     124 * Author    : Patrick Haller [Fri, 1998/02/27 11:55]
     125 *****************************************************************************/
     126
     127ODINFUNCTION3(BOOL,SetPixelFormat,HDC,                          hdc,
     128                                  int,                          whatever,
     129                                  CONST PIXELFORMATDESCRIPTOR*, pformat)
     130{
     131  if (glSetPixelFormat == NULL)
     132    if (internalOpenGLEnable() == FALSE)
     133      return(0);
     134
     135  return(glSetPixelFormat(hdc, whatever, pformat));
     136}
     137
     138
     139/*****************************************************************************
     140 * Name      :
     141 * Purpose   :
     142 * Parameters:
     143 * Variables :
     144 * Result    :
     145 * Remark    :
     146 * Status    :
     147 *
     148 * Author    : Patrick Haller [Fri, 1998/02/27 11:55]
     149 *****************************************************************************/
     150
     151ODINFUNCTION1(BOOL,SwapBuffers,HDC,hdc)
     152{
     153  if (glSwapBuffers == NULL)
     154    if (internalOpenGLEnable() == FALSE)
     155      return(0);
     156
     157
     158  return(glSwapBuffers(hdc));
     159}
     160
Note: See TracChangeset for help on using the changeset viewer.