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 |
|
---|
25 | ODINDEBUGCHANNEL(GDI32-OPENGL)
|
---|
26 |
|
---|
27 |
|
---|
28 | /****************************************************************************
|
---|
29 | * Definitions *
|
---|
30 | ****************************************************************************/
|
---|
31 |
|
---|
32 | typedef int (* WIN32API CHOOSEPIXELFMT) (HDC, CONST PIXELFORMATDESCRIPTOR *);
|
---|
33 | typedef BOOL (* WIN32API SETPIXELFMT) (HDC, int, CONST PIXELFORMATDESCRIPTOR *);
|
---|
34 | typedef BOOL (* WIN32API SWAPBUFFERS) (HDC hdc);
|
---|
35 | // JVDH MOD STARTS
|
---|
36 | typedef int (* WIN32API DESCRIBEPIXELFMT) (HDC, int, UINT, LPPIXELFORMATDESCRIPTOR);
|
---|
37 | // JVDH MOD ENDS
|
---|
38 |
|
---|
39 |
|
---|
40 | /****************************************************************************
|
---|
41 | * Module Global Variables *
|
---|
42 | ****************************************************************************/
|
---|
43 |
|
---|
44 | static CHOOSEPIXELFMT glChoosePixelFormat = NULL;
|
---|
45 | static SETPIXELFMT glSetPixelFormat = NULL;
|
---|
46 | static SWAPBUFFERS glSwapBuffers = NULL;
|
---|
47 | // JVDH MOD STARTS
|
---|
48 | static DESCRIBEPIXELFMT glDescribePixelFormat = NULL;
|
---|
49 | // JVDH MOD ENDS
|
---|
50 | static 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 |
|
---|
65 | static 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 |
|
---|
116 | ODINFUNCTION2(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 |
|
---|
128 | ODINFUNCTION4(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 |
|
---|
153 | ODINFUNCTION3(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 |
|
---|
177 | ODINFUNCTION1(BOOL,SwapBuffers,HDC,hdc)
|
---|
178 | {
|
---|
179 | if (glSwapBuffers == NULL)
|
---|
180 | if (internalOpenGLEnable() == FALSE)
|
---|
181 | return(0);
|
---|
182 |
|
---|
183 |
|
---|
184 | return(glSwapBuffers(hdc));
|
---|
185 | }
|
---|
186 |
|
---|