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

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

YD's makefile changes

File size: 5.3 KB
Line 
1/* $Id: opengl.cpp,v 1.5 2000-01-26 23:19:55 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);
35// JVDH MOD STARTS
36typedef int (* WIN32API DESCRIBEPIXELFMT) (HDC, int, UINT, LPPIXELFORMATDESCRIPTOR);
37// JVDH MOD ENDS
38
39
40/****************************************************************************
41 * Module Global Variables *
42 ****************************************************************************/
43
44static CHOOSEPIXELFMT glChoosePixelFormat = NULL;
45static SETPIXELFMT glSetPixelFormat = NULL;
46static SWAPBUFFERS glSwapBuffers = NULL;
47// JVDH MOD STARTS
48static DESCRIBEPIXELFMT glDescribePixelFormat = NULL;
49// JVDH MOD ENDS
50static HINSTANCE hOpenGL = NULL;
51
52
53/*****************************************************************************
54 * Name : internalOpenGLEnable
55 * Purpose : check if loaded, load OpenGL.DLL on demand
56 * Parameters:
57 * Variables :
58 * Result :
59 * Remark :
60 * Status :
61 *
62 * Author : Patrick Haller [Fri, 1998/02/27 11:55]
63 *****************************************************************************/
64
65static BOOL internalOpenGLEnable(void)
66{
67 if(hOpenGL == NULL)
68 {
69 hOpenGL = O32_LoadLibrary("OPENGL32.DLL");
70 if(hOpenGL == NULL)
71 return(FALSE);
72 }
73
74 if(glChoosePixelFormat == NULL) {
75 glChoosePixelFormat = (CHOOSEPIXELFMT)O32_GetProcAddress(hOpenGL, "OS2wglChoosePixelFormat");
76 if(glChoosePixelFormat == NULL)
77 return(0);
78 }
79
80 if(glSetPixelFormat == NULL) {
81 glSetPixelFormat = (SETPIXELFMT)O32_GetProcAddress(hOpenGL, "OS2wglSetPixelFormat");
82 if(glSetPixelFormat == NULL)
83 return(FALSE);
84 }
85
86 if(glSwapBuffers == NULL) {
87 glSwapBuffers = (SWAPBUFFERS)O32_GetProcAddress(hOpenGL, "OS2wglSwapBuffers");
88 if(glSwapBuffers == NULL)
89 return(FALSE);
90 }
91
92// JVDH MOD STARTS
93 if(glDescribePixelFormat == NULL) {
94 glDescribePixelFormat = (DESCRIBEPIXELFMT)O32_GetProcAddress(hOpenGL, "OS2wglDescribePixelFormat");
95 if(glDescribePixelFormat == NULL)
96 return(FALSE);
97 }
98// JVDH MOD ENDS
99
100 return(TRUE); /* OpenGL is initialized and enabled*/
101}
102
103
104/*****************************************************************************
105 * Name :
106 * Purpose :
107 * Parameters:
108 * Variables :
109 * Result :
110 * Remark :
111 * Status :
112 *
113 * Author : Patrick Haller [Fri, 1998/02/27 11:55]
114 *****************************************************************************/
115
116ODINFUNCTION2(int,ChoosePixelFormat,HDC, hdc,
117 CONST PIXELFORMATDESCRIPTOR*,pformat)
118{
119 //@@@PH: ?? return(1);
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
140
141/*****************************************************************************
142 * Name :
143 * Purpose :
144 * Parameters:
145 * Variables :
146 * Result :
147 * Remark :
148 * Status :
149 *
150 * Author : Patrick Haller [Fri, 1998/02/27 11:55]
151 *****************************************************************************/
152
153ODINFUNCTION3(BOOL,SetPixelFormat,HDC, hdc,
154 int, whatever,
155 CONST PIXELFORMATDESCRIPTOR*, pformat)
156{
157 if (glSetPixelFormat == NULL)
158 if (internalOpenGLEnable() == FALSE)
159 return(0);
160
161 return(glSetPixelFormat(hdc, whatever, pformat));
162}
163
164
165/*****************************************************************************
166 * Name :
167 * Purpose :
168 * Parameters:
169 * Variables :
170 * Result :
171 * Remark :
172 * Status :
173 *
174 * Author : Patrick Haller [Fri, 1998/02/27 11:55]
175 *****************************************************************************/
176
177ODINFUNCTION1(BOOL,SwapBuffers,HDC,hdc)
178{
179 if (glSwapBuffers == NULL)
180 if (internalOpenGLEnable() == FALSE)
181 return(0);
182
183
184 return(glSwapBuffers(hdc));
185}
186
Note: See TracBrowser for help on using the repository browser.