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

Last change on this file since 526 was 526, checked in by phaller, 26 years ago

Add: added ODINWRAP support to OpenGL

File size: 4.4 KB
Line 
1/* $Id: opengl.cpp,v 1.4 1999-08-17 13:28:36 phaller 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
36
37/****************************************************************************
38 * Module Global Variables *
39 ****************************************************************************/
40
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)
60{
61 if(hOpenGL == NULL)
62 {
63 hOpenGL = O32_LoadLibrary("OPENGL32.DLL");
64 if(hOpenGL == NULL)
65 return(FALSE);
66 }
67
68 if(glChoosePixelFormat == NULL) {
69 glChoosePixelFormat = (CHOOSEPIXELFMT)O32_GetProcAddress(hOpenGL, "OS2wglChoosePixelFormat");
70 if(glChoosePixelFormat == NULL)
71 return(0);
72 }
73
74 if(glSetPixelFormat == NULL) {
75 glSetPixelFormat = (SETPIXELFMT)O32_GetProcAddress(hOpenGL, "OS2wglSetPixelFormat");
76 if(glSetPixelFormat == NULL)
77 return(FALSE);
78 }
79
80 if(glSwapBuffers == NULL) {
81 glSwapBuffers = (SWAPBUFFERS)O32_GetProcAddress(hOpenGL, "OS2wglSwapBuffers");
82 if(glSwapBuffers == NULL)
83 return(FALSE);
84 }
85
86 return(TRUE); /* OpenGL is initialized and enabled */
87}
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 TracBrowser for help on using the repository browser.