Changeset 526 for trunk/src/gdi32/opengl.cpp
- Timestamp:
- Aug 17, 1999, 3:28:36 PM (26 years ago)
- 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:04phaller Exp $ */1 /* $Id: opengl.cpp,v 1.4 1999-08-17 13:28:36 phaller Exp $ */ 2 2 3 3 /* … … 9 9 * 10 10 */ 11 12 13 /**************************************************************************** 14 * Includes * 15 ****************************************************************************/ 16 11 17 #include <os2win.h> 12 18 #include <stdarg.h> 13 19 #include <string.h> 20 #include <odinwrap.h> 14 21 #include "misc.h" 15 22 #include "unicode.h" 23 24 25 ODINDEBUGCHANNEL(GDI32-OPENGL) 26 27 28 /**************************************************************************** 29 * Definitions * 30 ****************************************************************************/ 16 31 17 32 typedef int (* WIN32API CHOOSEPIXELFMT) (HDC, CONST PIXELFORMATDESCRIPTOR *); … … 19 34 typedef BOOL (* WIN32API SWAPBUFFERS) (HDC hdc); 20 35 21 CHOOSEPIXELFMT glChoosePixelFormat = NULL;22 SETPIXELFMT glSetPixelFormat = NULL;23 SWAPBUFFERS glSwapBuffers = NULL;24 36 25 HINSTANCE hOpenGL = NULL; 37 /**************************************************************************** 38 * Module Global Variables * 39 ****************************************************************************/ 26 40 27 //****************************************************************************** 28 //****************************************************************************** 29 int WIN32API ChoosePixelFormat(HDC hdc, CONST PIXELFORMATDESCRIPTOR *pformat) 41 static CHOOSEPIXELFMT glChoosePixelFormat = NULL; 42 static SETPIXELFMT glSetPixelFormat = NULL; 43 static SWAPBUFFERS glSwapBuffers = NULL; 44 static 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 59 static BOOL internalOpenGLEnable(void) 30 60 { 31 int rc; 61 if(hOpenGL == NULL) 62 { 63 hOpenGL = O32_LoadLibrary("OPENGL32.DLL"); 64 if(hOpenGL == NULL) 65 return(FALSE); 66 } 32 67 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 }40 68 if(glChoosePixelFormat == NULL) { 41 69 glChoosePixelFormat = (CHOOSEPIXELFMT)O32_GetProcAddress(hOpenGL, "OS2wglChoosePixelFormat"); … … 43 71 return(0); 44 72 } 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;54 73 55 dprintf(("OS2SetPixelFormat\n"));56 if(hOpenGL == NULL) {57 hOpenGL = O32_LoadLibrary("OPENGL32.DLL");58 if(hOpenGL == NULL)59 return(FALSE);60 }61 74 if(glSetPixelFormat == NULL) { 62 75 glSetPixelFormat = (SETPIXELFMT)O32_GetProcAddress(hOpenGL, "OS2wglSetPixelFormat"); … … 64 77 return(FALSE); 65 78 } 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;75 79 76 dprintf(("OS2SwapBuffers\n"));77 if(hOpenGL == NULL) {78 hOpenGL = O32_LoadLibrary("OPENGL32.DLL");79 if(hOpenGL == NULL)80 return(FALSE);81 }82 80 if(glSwapBuffers == NULL) { 83 81 glSwapBuffers = (SWAPBUFFERS)O32_GetProcAddress(hOpenGL, "OS2wglSwapBuffers"); … … 85 83 return(FALSE); 86 84 } 87 rc = glSwapBuffers(hdc); 88 dprintf(("wglSwapBuffers returned %d\n", rc)); 89 return(rc); 85 86 return(TRUE); /* OpenGL is initialized and enabled */ 90 87 } 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 102 ODINFUNCTION2(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 127 ODINFUNCTION3(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 151 ODINFUNCTION1(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.