1 /* Window-specific OpenGL functions implementation.
3 Copyright (c) 1999 Lionel Ulmer
9 #include "debugtools.h"
17 #include "opengl_ext.h"
19 DEFAULT_DEBUG_CHANNEL(opengl)
21 HGLRC WINAPI wglCreateContext(HDC hdc) {
22 DC * dc = DC_GetDCPtr( hdc );
23 X11DRV_PDEVICE *physDev;
27 TRACE("(%08x)\n", hdc);
34 physDev = (X11DRV_PDEVICE *)dc->physDev;
36 /* First, get the visual for the choosen pixel format */
37 vis = physDev->visuals[physDev->current_pf - 1];
40 ERR("NULL visual !!!\n");
41 /* Need to set errors here */
46 ret = glXCreateContext(display, vis, NULL, True);
52 HGLRC WINAPI wglCreateLayerContext(HDC hdc,
54 FIXME("(%08x,%d): stub !\n", hdc, iLayerPlane);
59 BOOL WINAPI wglCopyContext(HGLRC hglrcSrc,
62 FIXME("(%p,%p,%d)\n", hglrcSrc, hglrcDst, mask);
67 BOOL WINAPI wglDeleteContext(HGLRC hglrc) {
68 FIXME("(%p): stub !\n", hglrc);
73 BOOL WINAPI wglDescribeLayerPlane(HDC hdc,
77 LPLAYERPLANEDESCRIPTOR plpd) {
78 FIXME("(%08x,%d,%d,%d,%p)\n", hdc, iPixelFormat, iLayerPlane, nBytes, plpd);
83 HGLRC WINAPI wglGetCurrentContext(void) {
89 ret = glXGetCurrentContext();
92 TRACE(" returning %p\n", ret);
97 HDC WINAPI wglGetCurrentDC(void) {
101 ret = glXGetCurrentContext();
105 TRACE("() no current context -> returning NULL\n");
114 int WINAPI wglGetLayerPaletteEntries(HDC hdc,
118 const COLORREF *pcr) {
119 FIXME("(): stub !\n");
124 static int compar(const void *elt_a, const void *elt_b) {
125 return strcmp(((OpenGL_extension *) elt_a)->name,
126 ((OpenGL_extension *) elt_b)->name);
129 void* WINAPI wglGetProcAddress(LPCSTR lpszProc) {
131 static HMODULE hm = 0;
133 TRACE("(%s)\n", lpszProc);
136 hm = GetModuleHandleA("opengl32");
138 /* First, look if it's not already defined in the 'standard' OpenGL functions */
139 if ((local_func = GetProcAddress(hm, lpszProc)) != NULL) {
140 TRACE("Found function in 'standard' OpenGL functions (%p)\n", local_func);
144 /* After that, look at the extensions defined in the Linux OpenGL library */
145 if ((local_func = glXGetProcAddressARB(lpszProc)) == NULL) {
149 /* Remove the 3 last letters (EXT, ARB, ...).
151 I know that some extensions have more than 3 letters (MESA, NV,
152 INTEL, ...), but this is only a stop-gap measure to fix buggy
153 OpenGL drivers (moreover, it is only useful for old 1.0 apps
154 that query the glBindTextureEXT extension).
156 strncpy(buf, lpszProc, strlen(lpszProc) - 3);
157 buf[strlen(lpszProc) - 3] = '\0';
158 TRACE("Extension not found in the Linux OpenGL library, checking against libGL bug with %s..\n", buf);
160 ret = GetProcAddress(hm, buf);
162 TRACE("Found function in main OpenGL library (%p) !\n", ret);
167 OpenGL_extension ext;
168 OpenGL_extension *ret;
170 ext.name = (char *) lpszProc;
171 ret = (OpenGL_extension *) bsearch(&ext, extension_registry,
172 extension_registry_size, sizeof(OpenGL_extension), compar);
175 TRACE("Returning function (%p)\n", ret->func);
176 *(ret->func_ptr) = local_func;
180 ERR("Extension defined in the OpenGL library but NOT in opengl_ext.c... Please report (lionel.ulmer@free.fr) !\n");
186 BOOL WINAPI wglMakeCurrent(HDC hdc,
188 DC * dc = DC_GetDCPtr( hdc );
189 X11DRV_PDEVICE *physDev;
192 TRACE("(%08x,%p)\n", hdc, hglrc);
195 ERR("Null DC !!!\n");
199 physDev =(X11DRV_PDEVICE *)dc->physDev;
202 ret = glXMakeCurrent(display, physDev->drawable, (GLXContext) hglrc);
208 BOOL WINAPI wglRealizeLayerPalette(HDC hdc,
216 int WINAPI wglSetLayerPaletteEntries(HDC hdc,
220 const COLORREF *pcr) {
221 FIXME("(): stub !\n");
226 BOOL WINAPI wglShareLists(HGLRC hglrc1,
228 FIXME("(): stub !\n");
233 BOOL WINAPI wglSwapLayerBuffers(HDC hdc,
235 FIXME("(): stub !\n");
240 BOOL WINAPI wglUseFontBitmaps(HDC hdc,
244 FIXME("(): stub !\n");
249 BOOL WINAPI wglUseFontOutlines(HDC hdc,
256 LPGLYPHMETRICSFLOAT lpgmf) {
257 FIXME("(): stub !\n");
262 /* This is for brain-dead applications that use OpenGL functions before even
263 creating a rendering context.... */
264 DECL_GLOBAL_CONSTRUCTOR(OpenGL_create_default_context) {
266 XVisualInfo template;
271 template.visualid = XVisualIDFromVisual(visual);
272 vis = XGetVisualInfo(display, VisualIDMask, &template, &num);
273 cx=glXCreateContext(display, vis, 0, GL_TRUE);
274 glXMakeCurrent(display, X11DRV_GetXRootWindow(), cx);