source: trunk/src/gdi32/opengl.cpp@ 2527

Last change on this file since 2527 was 2527, checked in by sandervl, 26 years ago

JvdH's opengl changes

File size: 5.6 KB
Line 
1/* $Id: opengl.cpp,v 1.6 2000-01-26 23:48:03 sandervl Exp $ */
2
3/*
4 * GDI32 OpenGl stubs
5 *
6 * Copyright 1998 Sander van Leeuwen (sandervl@xs4all.nl)
7 *
8 * Project Odin Software License can be found in LICENSE.TXT
9 *
10 */
11
12
13/****************************************************************************
14 * Includes *
15 ****************************************************************************/
16
17#include <os2win.h>
18#include <stdarg.h>
19#include <string.h>
20#include <odinwrap.h>
21#include "misc.h"
22#include "unicode.h"
23
24
25ODINDEBUGCHANNEL(GDI32-OPENGL)
26
27
28/****************************************************************************
29 * Definitions *
30 ****************************************************************************/
31
32typedef int (* WIN32API CHOOSEPIXELFMT) (HDC, CONST PIXELFORMATDESCRIPTOR *);
33typedef BOOL (* WIN32API SETPIXELFMT) (HDC, int, CONST PIXELFORMATDESCRIPTOR *);
34typedef BOOL (* WIN32API SWAPBUFFERS) (HDC hdc);
35typedef int (* WIN32API DESCRIBEPIXELFMT) (HDC, int, UINT, LPPIXELFORMATDESCRIPTOR);
36typedef int (* WIN32API GETPIXELFMT) (HDC);
37
38
39/****************************************************************************
40 * Module Global Variables *
41 ****************************************************************************/
42
43static CHOOSEPIXELFMT glChoosePixelFormat = NULL;
44static SETPIXELFMT glSetPixelFormat = NULL;
45static SWAPBUFFERS glSwapBuffers = NULL;
46static DESCRIBEPIXELFMT glDescribePixelFormat = NULL;
47static GETPIXELFMT glGetPixelFormat = NULL;
48static HINSTANCE hOpenGL = NULL;
49
50
51/*****************************************************************************
52 * Name : internalOpenGLEnable
53 * Purpose : check if loaded, load OpenGL.DLL on demand
54 * Parameters:
55 * Variables :
56 * Result :
57 * Remark :
58 * Status :
59 *
60 * Author : Patrick Haller [Fri, 1998/02/27 11:55]
61 *****************************************************************************/
62
63static BOOL internalOpenGLEnable(void)
64{
65 if(hOpenGL == NULL)
66 {
67 hOpenGL = O32_LoadLibrary("OPENGL32.DLL");
68 if(hOpenGL == NULL)
69 return(FALSE);
70 }
71
72 if(glChoosePixelFormat == NULL) {
73 glChoosePixelFormat = (CHOOSEPIXELFMT)O32_GetProcAddress(hOpenGL, "OS2wglChoosePixelFormat");
74 if(glChoosePixelFormat == NULL)
75 return(0);
76 }
77
78 if(glSetPixelFormat == NULL) {
79 glSetPixelFormat = (SETPIXELFMT)O32_GetProcAddress(hOpenGL, "OS2wglSetPixelFormat");
80 if(glSetPixelFormat == NULL)
81 return(FALSE);
82 }
83
84 if(glSwapBuffers == NULL) {
85 glSwapBuffers = (SWAPBUFFERS)O32_GetProcAddress(hOpenGL, "OS2wglSwapBuffers");
86 if(glSwapBuffers == NULL)
87 return(FALSE);
88 }
89
90 if(glDescribePixelFormat == NULL) {
91 glDescribePixelFormat = (DESCRIBEPIXELFMT)O32_GetProcAddress(hOpenGL, "OS2wglDescribePixelFormat");
92 if(glDescribePixelFormat == NULL)
93 return(FALSE);
94 }
95
96 if(glGetPixelFormat == NULL) {
97 glGetPixelFormat = (GETPIXELFMT)O32_GetProcAddress(hOpenGL, "OS2wglGetPixelFormat");
98 if(glGetPixelFormat == NULL)
99 return(FALSE);
100 }
101
102 return(TRUE); /* OpenGL is initialized and enabled*/
103}
104
105
106/*****************************************************************************
107 * Name :
108 * Purpose :
109 * Parameters:
110 * Variables :
111 * Result :
112 * Remark :
113 * Status :
114 *
115 * Author : Patrick Haller [Fri, 1998/02/27 11:55]
116 *****************************************************************************/
117
118ODINFUNCTION2(int,ChoosePixelFormat,HDC, hdc,
119 CONST PIXELFORMATDESCRIPTOR*,pformat)
120{
121 if (glChoosePixelFormat == NULL)
122 if (internalOpenGLEnable() == FALSE)
123 return(0);
124
125 return(glChoosePixelFormat(hdc, pformat));
126}
127
128ODINFUNCTION4(int,DescribePixelFormat,HDC,hdc,
129 int,iFormat,
130 UINT,nBytes,
131 LPPIXELFORMATDESCRIPTOR,pformat)
132{
133 if (glDescribePixelFormat == NULL)
134 if (internalOpenGLEnable() == FALSE)
135 return(0);
136
137 return(glDescribePixelFormat(hdc, iFormat, nBytes, pformat));
138}
139
140ODINFUNCTION1(int,GetPixelFormat,HDC,hdc)
141{
142 if (glGetPixelFormat == NULL)
143 if (internalOpenGLEnable() == FALSE)
144 return(0);
145
146 return(glGetPixelFormat(hdc));
147}
148
149/*****************************************************************************
150 * Name :
151 * Purpose :
152 * Parameters:
153 * Variables :
154 * Result :
155 * Remark :
156 * Status :
157 *
158 * Author : Patrick Haller [Fri, 1998/02/27 11:55]
159 *****************************************************************************/
160
161ODINFUNCTION3(BOOL,SetPixelFormat,HDC, hdc,
162 int, whatever,
163 CONST PIXELFORMATDESCRIPTOR*, pformat)
164{
165 if (glSetPixelFormat == NULL)
166 if (internalOpenGLEnable() == FALSE)
167 return(0);
168
169 return(glSetPixelFormat(hdc, whatever, pformat));
170}
171
172
173/*****************************************************************************
174 * Name :
175 * Purpose :
176 * Parameters:
177 * Variables :
178 * Result :
179 * Remark :
180 * Status :
181 *
182 * Author : Patrick Haller [Fri, 1998/02/27 11:55]
183 *****************************************************************************/
184
185ODINFUNCTION1(BOOL,SwapBuffers,HDC,hdc)
186{
187 if (glSwapBuffers == NULL)
188 if (internalOpenGLEnable() == FALSE)
189 return(0);
190
191
192 return(glSwapBuffers(hdc));
193}
194
Note: See TracBrowser for help on using the repository browser.