2000-05-12 22:18:14 +02:00
|
|
|
/* Window-specific OpenGL functions implementation.
|
|
|
|
|
|
|
|
Copyright (c) 1999 Lionel Ulmer
|
|
|
|
*/
|
|
|
|
|
2001-10-14 18:18:52 +02:00
|
|
|
#include "config.h"
|
|
|
|
|
2000-05-12 22:18:14 +02:00
|
|
|
#include <stdlib.h>
|
2001-01-22 03:17:29 +01:00
|
|
|
#include <string.h>
|
2000-05-12 22:18:14 +02:00
|
|
|
|
2000-05-23 23:15:06 +02:00
|
|
|
#include "wine/exception.h"
|
|
|
|
|
2000-05-12 22:18:14 +02:00
|
|
|
#include "debugtools.h"
|
|
|
|
#include "gdi.h"
|
|
|
|
#include "windef.h"
|
2000-05-23 23:15:06 +02:00
|
|
|
#include "winerror.h"
|
2000-05-12 22:18:14 +02:00
|
|
|
#include "wine_gl.h"
|
|
|
|
#include "x11drv.h"
|
2000-05-23 03:20:08 +02:00
|
|
|
#include "x11font.h"
|
2000-05-12 22:18:14 +02:00
|
|
|
|
|
|
|
#include "wgl.h"
|
|
|
|
#include "opengl_ext.h"
|
|
|
|
|
2000-05-18 02:07:53 +02:00
|
|
|
DEFAULT_DEBUG_CHANNEL(opengl);
|
2000-05-12 22:18:14 +02:00
|
|
|
|
2000-06-12 23:53:46 +02:00
|
|
|
static GLXContext default_cx = NULL;
|
|
|
|
|
2000-05-30 22:04:21 +02:00
|
|
|
typedef struct wine_glcontext {
|
|
|
|
HDC hdc;
|
|
|
|
GLXContext ctx;
|
|
|
|
XVisualInfo *vis;
|
|
|
|
struct wine_glcontext *next;
|
|
|
|
struct wine_glcontext *prev;
|
|
|
|
} Wine_GLContext;
|
|
|
|
static Wine_GLContext *context_array;
|
|
|
|
|
|
|
|
static inline Wine_GLContext *get_context_from_GLXContext(GLXContext ctx) {
|
|
|
|
Wine_GLContext *ret = context_array;
|
|
|
|
while (ret != NULL) if (ctx == ret->ctx) break; else ret = ret->next;
|
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
|
|
|
|
static inline void free_context(Wine_GLContext *context) {
|
|
|
|
if (context->next != NULL) context->next->prev = context->prev;
|
|
|
|
if (context->prev != NULL) context->prev->next = context->next;
|
|
|
|
else context_array = context->next;
|
|
|
|
|
|
|
|
HeapFree(GetProcessHeap(), 0, context);
|
|
|
|
}
|
|
|
|
|
|
|
|
static inline Wine_GLContext *alloc_context(void) {
|
|
|
|
Wine_GLContext *ret;
|
|
|
|
|
|
|
|
ret = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(Wine_GLContext));
|
|
|
|
ret->next = context_array;
|
|
|
|
if (context_array != NULL) context_array->prev = ret;
|
|
|
|
else context_array = ret;
|
|
|
|
|
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2000-05-23 23:15:06 +02:00
|
|
|
static int XGLErrorFlag = 0;
|
|
|
|
static int XGLErrorHandler(Display *dpy, XErrorEvent *event) {
|
|
|
|
XGLErrorFlag = 1;
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
/* filter for page-fault exceptions */
|
|
|
|
static WINE_EXCEPTION_FILTER(page_fault)
|
|
|
|
{
|
|
|
|
return EXCEPTION_EXECUTE_HANDLER;
|
|
|
|
}
|
|
|
|
|
2000-05-18 02:07:53 +02:00
|
|
|
/***********************************************************************
|
2001-06-19 20:20:47 +02:00
|
|
|
* wglCreateContext (OPENGL32.@)
|
2000-05-18 02:07:53 +02:00
|
|
|
*/
|
2001-04-25 01:17:53 +02:00
|
|
|
HGLRC WINAPI wglCreateContext(HDC hdc)
|
|
|
|
{
|
2000-05-12 22:18:14 +02:00
|
|
|
XVisualInfo *vis;
|
2000-05-30 22:04:21 +02:00
|
|
|
Wine_GLContext *ret;
|
2001-03-28 03:45:08 +02:00
|
|
|
int num;
|
|
|
|
XVisualInfo template;
|
2000-05-12 22:18:14 +02:00
|
|
|
|
|
|
|
TRACE("(%08x)\n", hdc);
|
|
|
|
|
2001-03-28 03:45:08 +02:00
|
|
|
/* First, get the visual in use by the X11DRV */
|
2001-06-26 23:10:11 +02:00
|
|
|
template.visualid = GetPropA( GetDesktopWindow(), "__wine_x11_visual_id" );
|
2001-05-11 02:17:47 +02:00
|
|
|
vis = XGetVisualInfo(gdi_display, VisualIDMask, &template, &num);
|
2000-05-12 22:18:14 +02:00
|
|
|
|
|
|
|
if (vis == NULL) {
|
|
|
|
ERR("NULL visual !!!\n");
|
|
|
|
/* Need to set errors here */
|
|
|
|
return NULL;
|
|
|
|
}
|
2000-05-30 22:04:21 +02:00
|
|
|
|
|
|
|
/* The context will be allocated in the wglMakeCurrent call */
|
2000-05-12 22:18:14 +02:00
|
|
|
ENTER_GL();
|
2000-05-30 22:04:21 +02:00
|
|
|
ret = alloc_context();
|
2000-05-12 22:18:14 +02:00
|
|
|
LEAVE_GL();
|
2000-05-30 22:04:21 +02:00
|
|
|
ret->hdc = hdc;
|
|
|
|
ret->vis = vis;
|
2000-05-12 22:18:14 +02:00
|
|
|
|
2000-05-30 22:04:21 +02:00
|
|
|
TRACE(" creating context %p (GL context creation delayed)\n", ret);
|
2000-05-12 22:18:14 +02:00
|
|
|
return (HGLRC) ret;
|
|
|
|
}
|
|
|
|
|
2000-05-18 02:07:53 +02:00
|
|
|
/***********************************************************************
|
2001-06-19 20:20:47 +02:00
|
|
|
* wglCreateLayerContext (OPENGL32.@)
|
2000-05-18 02:07:53 +02:00
|
|
|
*/
|
2000-05-12 22:18:14 +02:00
|
|
|
HGLRC WINAPI wglCreateLayerContext(HDC hdc,
|
|
|
|
int iLayerPlane) {
|
|
|
|
FIXME("(%08x,%d): stub !\n", hdc, iLayerPlane);
|
|
|
|
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
|
2000-05-18 02:07:53 +02:00
|
|
|
/***********************************************************************
|
2001-06-19 20:20:47 +02:00
|
|
|
* wglCopyContext (OPENGL32.@)
|
2000-05-18 02:07:53 +02:00
|
|
|
*/
|
2000-05-12 22:18:14 +02:00
|
|
|
BOOL WINAPI wglCopyContext(HGLRC hglrcSrc,
|
|
|
|
HGLRC hglrcDst,
|
|
|
|
UINT mask) {
|
|
|
|
FIXME("(%p,%p,%d)\n", hglrcSrc, hglrcDst, mask);
|
|
|
|
|
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
|
2000-05-18 02:07:53 +02:00
|
|
|
/***********************************************************************
|
2001-06-19 20:20:47 +02:00
|
|
|
* wglDeleteContext (OPENGL32.@)
|
2000-05-18 02:07:53 +02:00
|
|
|
*/
|
2000-05-12 22:18:14 +02:00
|
|
|
BOOL WINAPI wglDeleteContext(HGLRC hglrc) {
|
2000-05-23 23:15:06 +02:00
|
|
|
int (*WineXHandler)(Display *, XErrorEvent *);
|
2000-05-30 22:04:21 +02:00
|
|
|
Wine_GLContext *ctx = (Wine_GLContext *) hglrc;
|
|
|
|
BOOL ret;
|
2000-05-23 23:15:06 +02:00
|
|
|
|
2000-05-23 03:20:08 +02:00
|
|
|
TRACE("(%p)\n", hglrc);
|
2000-05-23 23:15:06 +02:00
|
|
|
|
2000-05-23 03:20:08 +02:00
|
|
|
ENTER_GL();
|
2000-05-23 23:15:06 +02:00
|
|
|
/* A game (Half Life not to name it) deletes twice the same context. To prevent
|
|
|
|
crashes, run with our own error function enabled */
|
2001-05-11 02:17:47 +02:00
|
|
|
XSync(gdi_display, False);
|
2000-05-23 23:15:06 +02:00
|
|
|
XGLErrorFlag = 0;
|
|
|
|
WineXHandler = XSetErrorHandler(XGLErrorHandler);
|
|
|
|
__TRY {
|
2001-05-11 02:17:47 +02:00
|
|
|
glXDestroyContext(gdi_display, ctx->ctx);
|
|
|
|
XSync(gdi_display, False);
|
|
|
|
XFlush(gdi_display);
|
2000-05-30 22:04:21 +02:00
|
|
|
|
|
|
|
if (XGLErrorHandler == 0) free_context(ctx);
|
2000-05-23 23:15:06 +02:00
|
|
|
}
|
|
|
|
__EXCEPT(page_fault) {
|
|
|
|
XGLErrorFlag = 1;
|
|
|
|
}
|
|
|
|
__ENDTRY
|
|
|
|
|
2000-05-30 22:04:21 +02:00
|
|
|
ret = TRUE;
|
2000-05-23 23:15:06 +02:00
|
|
|
XSetErrorHandler(WineXHandler);
|
|
|
|
if (XGLErrorFlag) {
|
2000-05-30 22:04:21 +02:00
|
|
|
WARN("Error deleting context !\n");
|
2000-05-23 23:15:06 +02:00
|
|
|
SetLastError(ERROR_INVALID_HANDLE);
|
|
|
|
ret = FALSE;
|
|
|
|
}
|
2000-05-23 03:20:08 +02:00
|
|
|
LEAVE_GL();
|
|
|
|
|
2000-05-23 23:15:06 +02:00
|
|
|
return ret;
|
2000-05-12 22:18:14 +02:00
|
|
|
}
|
|
|
|
|
2000-05-18 02:07:53 +02:00
|
|
|
/***********************************************************************
|
2001-06-19 20:20:47 +02:00
|
|
|
* wglDescribeLayerPlane (OPENGL32.@)
|
2000-05-18 02:07:53 +02:00
|
|
|
*/
|
2000-05-12 22:18:14 +02:00
|
|
|
BOOL WINAPI wglDescribeLayerPlane(HDC hdc,
|
|
|
|
int iPixelFormat,
|
|
|
|
int iLayerPlane,
|
|
|
|
UINT nBytes,
|
|
|
|
LPLAYERPLANEDESCRIPTOR plpd) {
|
|
|
|
FIXME("(%08x,%d,%d,%d,%p)\n", hdc, iPixelFormat, iLayerPlane, nBytes, plpd);
|
|
|
|
|
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
|
2000-05-18 02:07:53 +02:00
|
|
|
/***********************************************************************
|
2001-06-19 20:20:47 +02:00
|
|
|
* wglGetCurrentContext (OPENGL32.@)
|
2000-05-18 02:07:53 +02:00
|
|
|
*/
|
2000-05-12 22:18:14 +02:00
|
|
|
HGLRC WINAPI wglGetCurrentContext(void) {
|
2000-05-30 22:04:21 +02:00
|
|
|
GLXContext gl_ctx;
|
|
|
|
Wine_GLContext *ret;
|
2000-05-12 22:18:14 +02:00
|
|
|
|
|
|
|
TRACE("()\n");
|
|
|
|
|
|
|
|
ENTER_GL();
|
2000-05-30 22:04:21 +02:00
|
|
|
gl_ctx = glXGetCurrentContext();
|
|
|
|
ret = get_context_from_GLXContext(gl_ctx);
|
2000-05-12 22:18:14 +02:00
|
|
|
LEAVE_GL();
|
|
|
|
|
2000-05-30 22:04:21 +02:00
|
|
|
TRACE(" returning %p (GL context %p)\n", ret, gl_ctx);
|
2000-05-12 22:18:14 +02:00
|
|
|
|
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
|
2000-05-18 02:07:53 +02:00
|
|
|
/***********************************************************************
|
2001-06-19 20:20:47 +02:00
|
|
|
* wglGetCurrentDC (OPENGL32.@)
|
2000-05-18 02:07:53 +02:00
|
|
|
*/
|
2000-05-12 22:18:14 +02:00
|
|
|
HDC WINAPI wglGetCurrentDC(void) {
|
2000-05-30 22:04:21 +02:00
|
|
|
GLXContext gl_ctx;
|
|
|
|
Wine_GLContext *ret;
|
2000-05-12 22:18:14 +02:00
|
|
|
|
2000-05-30 22:04:21 +02:00
|
|
|
TRACE("()\n");
|
|
|
|
|
2000-05-12 22:18:14 +02:00
|
|
|
ENTER_GL();
|
2000-05-30 22:04:21 +02:00
|
|
|
gl_ctx = glXGetCurrentContext();
|
|
|
|
ret = get_context_from_GLXContext(gl_ctx);
|
2000-05-12 22:18:14 +02:00
|
|
|
LEAVE_GL();
|
|
|
|
|
2000-05-30 22:04:21 +02:00
|
|
|
if (ret) {
|
|
|
|
TRACE(" returning %08x (GL context %p - Wine context %p)\n", ret->hdc, gl_ctx, ret);
|
|
|
|
return ret->hdc;
|
2000-05-12 22:18:14 +02:00
|
|
|
} else {
|
2000-05-30 22:04:21 +02:00
|
|
|
TRACE(" no Wine context found for GLX context %p\n", gl_ctx);
|
2000-05-12 22:18:14 +02:00
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2000-05-18 02:07:53 +02:00
|
|
|
/***********************************************************************
|
2001-06-19 20:20:47 +02:00
|
|
|
* wglGetLayerPaletteEntries (OPENGL32.@)
|
2000-05-18 02:07:53 +02:00
|
|
|
*/
|
2000-05-12 22:18:14 +02:00
|
|
|
int WINAPI wglGetLayerPaletteEntries(HDC hdc,
|
|
|
|
int iLayerPlane,
|
|
|
|
int iStart,
|
|
|
|
int cEntries,
|
|
|
|
const COLORREF *pcr) {
|
|
|
|
FIXME("(): stub !\n");
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
static int compar(const void *elt_a, const void *elt_b) {
|
|
|
|
return strcmp(((OpenGL_extension *) elt_a)->name,
|
|
|
|
((OpenGL_extension *) elt_b)->name);
|
|
|
|
}
|
|
|
|
|
2000-05-18 02:07:53 +02:00
|
|
|
/***********************************************************************
|
2001-06-19 20:20:47 +02:00
|
|
|
* wglGetProcAddress (OPENGL32.@)
|
2000-05-18 02:07:53 +02:00
|
|
|
*/
|
2000-05-12 22:18:14 +02:00
|
|
|
void* WINAPI wglGetProcAddress(LPCSTR lpszProc) {
|
|
|
|
void *local_func;
|
|
|
|
static HMODULE hm = 0;
|
|
|
|
|
|
|
|
TRACE("(%s)\n", lpszProc);
|
|
|
|
|
|
|
|
if (hm == 0)
|
|
|
|
hm = GetModuleHandleA("opengl32");
|
|
|
|
|
|
|
|
/* First, look if it's not already defined in the 'standard' OpenGL functions */
|
|
|
|
if ((local_func = GetProcAddress(hm, lpszProc)) != NULL) {
|
2000-05-30 22:04:21 +02:00
|
|
|
TRACE(" found function in 'standard' OpenGL functions (%p)\n", local_func);
|
2000-05-12 22:18:14 +02:00
|
|
|
return local_func;
|
|
|
|
}
|
|
|
|
|
|
|
|
/* After that, look at the extensions defined in the Linux OpenGL library */
|
|
|
|
if ((local_func = glXGetProcAddressARB(lpszProc)) == NULL) {
|
|
|
|
char buf[256];
|
|
|
|
void *ret = NULL;
|
|
|
|
|
|
|
|
/* Remove the 3 last letters (EXT, ARB, ...).
|
|
|
|
|
|
|
|
I know that some extensions have more than 3 letters (MESA, NV,
|
|
|
|
INTEL, ...), but this is only a stop-gap measure to fix buggy
|
|
|
|
OpenGL drivers (moreover, it is only useful for old 1.0 apps
|
|
|
|
that query the glBindTextureEXT extension).
|
|
|
|
*/
|
|
|
|
strncpy(buf, lpszProc, strlen(lpszProc) - 3);
|
|
|
|
buf[strlen(lpszProc) - 3] = '\0';
|
2000-05-30 22:04:21 +02:00
|
|
|
TRACE(" extension not found in the Linux OpenGL library, checking against libGL bug with %s..\n", buf);
|
2000-05-12 22:18:14 +02:00
|
|
|
|
|
|
|
ret = GetProcAddress(hm, buf);
|
|
|
|
if (ret != NULL) {
|
2000-05-30 22:04:21 +02:00
|
|
|
TRACE(" found function in main OpenGL library (%p) !\n", ret);
|
2000-05-12 22:18:14 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
return ret;
|
|
|
|
} else {
|
|
|
|
OpenGL_extension ext;
|
|
|
|
OpenGL_extension *ret;
|
|
|
|
|
|
|
|
ext.name = (char *) lpszProc;
|
|
|
|
ret = (OpenGL_extension *) bsearch(&ext, extension_registry,
|
|
|
|
extension_registry_size, sizeof(OpenGL_extension), compar);
|
|
|
|
|
|
|
|
if (ret != NULL) {
|
2000-05-30 22:04:21 +02:00
|
|
|
TRACE(" returning function (%p)\n", ret->func);
|
2000-05-12 22:18:14 +02:00
|
|
|
*(ret->func_ptr) = local_func;
|
|
|
|
|
|
|
|
return ret->func;
|
|
|
|
} else {
|
2001-03-28 03:45:08 +02:00
|
|
|
ERR("Extension %s defined in the OpenGL library but NOT in opengl_ext.c... Please report (lionel.ulmer@free.fr) !\n", lpszProc);
|
2000-05-12 22:18:14 +02:00
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2000-05-18 02:07:53 +02:00
|
|
|
/***********************************************************************
|
2001-06-19 20:20:47 +02:00
|
|
|
* wglMakeCurrent (OPENGL32.@)
|
2000-05-18 02:07:53 +02:00
|
|
|
*/
|
2000-05-12 22:18:14 +02:00
|
|
|
BOOL WINAPI wglMakeCurrent(HDC hdc,
|
|
|
|
HGLRC hglrc) {
|
|
|
|
BOOL ret;
|
|
|
|
|
|
|
|
TRACE("(%08x,%p)\n", hdc, hglrc);
|
|
|
|
|
2000-05-23 23:15:06 +02:00
|
|
|
if (hglrc == NULL) {
|
|
|
|
ENTER_GL();
|
2001-05-11 02:17:47 +02:00
|
|
|
ret = glXMakeCurrent(gdi_display,
|
2000-05-23 23:15:06 +02:00
|
|
|
None,
|
|
|
|
NULL);
|
|
|
|
LEAVE_GL();
|
|
|
|
} else {
|
|
|
|
DC * dc = DC_GetDCPtr( hdc );
|
|
|
|
|
|
|
|
if (dc == NULL) {
|
|
|
|
ERR("Null DC !!!\n");
|
|
|
|
ret = FALSE;
|
|
|
|
} else {
|
|
|
|
X11DRV_PDEVICE *physDev;
|
2000-05-30 22:04:21 +02:00
|
|
|
Wine_GLContext *ctx = (Wine_GLContext *) hglrc;
|
2000-05-23 23:15:06 +02:00
|
|
|
|
|
|
|
physDev =(X11DRV_PDEVICE *)dc->physDev;
|
2000-05-30 22:04:21 +02:00
|
|
|
|
|
|
|
if (ctx->ctx == NULL) {
|
|
|
|
ENTER_GL();
|
2001-05-11 02:17:47 +02:00
|
|
|
ctx->ctx = glXCreateContext(gdi_display, ctx->vis, NULL, True);
|
2000-05-30 22:04:21 +02:00
|
|
|
LEAVE_GL();
|
|
|
|
TRACE(" created a delayed OpenGL context (%p)\n", ctx->ctx);
|
|
|
|
}
|
2000-05-23 23:15:06 +02:00
|
|
|
|
|
|
|
ENTER_GL();
|
2001-05-11 02:17:47 +02:00
|
|
|
ret = glXMakeCurrent(gdi_display,
|
2000-05-23 23:15:06 +02:00
|
|
|
physDev->drawable,
|
2000-05-30 22:04:21 +02:00
|
|
|
ctx->ctx);
|
2000-05-23 23:15:06 +02:00
|
|
|
LEAVE_GL();
|
2000-08-19 23:38:55 +02:00
|
|
|
GDI_ReleaseObj( hdc );
|
2000-05-23 23:15:06 +02:00
|
|
|
}
|
|
|
|
}
|
2000-05-30 22:04:21 +02:00
|
|
|
TRACE(" returning %s\n", (ret ? "True" : "False"));
|
2000-05-12 22:18:14 +02:00
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
|
2000-05-18 02:07:53 +02:00
|
|
|
/***********************************************************************
|
2001-06-19 20:20:47 +02:00
|
|
|
* wglRealizeLayerPalette (OPENGL32.@)
|
2000-05-18 02:07:53 +02:00
|
|
|
*/
|
2000-05-12 22:18:14 +02:00
|
|
|
BOOL WINAPI wglRealizeLayerPalette(HDC hdc,
|
|
|
|
int iLayerPlane,
|
|
|
|
BOOL bRealize) {
|
|
|
|
FIXME("()\n");
|
|
|
|
|
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
|
2000-05-18 02:07:53 +02:00
|
|
|
/***********************************************************************
|
2001-06-19 20:20:47 +02:00
|
|
|
* wglSetLayerPaletteEntries (OPENGL32.@)
|
2000-05-18 02:07:53 +02:00
|
|
|
*/
|
2000-05-12 22:18:14 +02:00
|
|
|
int WINAPI wglSetLayerPaletteEntries(HDC hdc,
|
|
|
|
int iLayerPlane,
|
|
|
|
int iStart,
|
|
|
|
int cEntries,
|
|
|
|
const COLORREF *pcr) {
|
|
|
|
FIXME("(): stub !\n");
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2000-05-18 02:07:53 +02:00
|
|
|
/***********************************************************************
|
2001-06-19 20:20:47 +02:00
|
|
|
* wglShareLists (OPENGL32.@)
|
2000-05-18 02:07:53 +02:00
|
|
|
*/
|
2000-05-12 22:18:14 +02:00
|
|
|
BOOL WINAPI wglShareLists(HGLRC hglrc1,
|
|
|
|
HGLRC hglrc2) {
|
2000-05-30 22:04:21 +02:00
|
|
|
Wine_GLContext *org = (Wine_GLContext *) hglrc1;
|
|
|
|
Wine_GLContext *dest = (Wine_GLContext *) hglrc2;
|
|
|
|
|
|
|
|
TRACE("(%p, %p)\n", org, dest);
|
2000-05-12 22:18:14 +02:00
|
|
|
|
2000-05-30 22:04:21 +02:00
|
|
|
if (dest->ctx != NULL) {
|
|
|
|
ERR("Could not share display lists, context already created !\n");
|
|
|
|
return FALSE;
|
|
|
|
} else {
|
|
|
|
if (org->ctx == NULL) {
|
|
|
|
ENTER_GL();
|
2001-05-11 02:17:47 +02:00
|
|
|
org->ctx = glXCreateContext(gdi_display, org->vis, NULL, True);
|
2000-05-30 22:04:21 +02:00
|
|
|
LEAVE_GL();
|
|
|
|
TRACE(" created a delayed OpenGL context (%p) for Wine context %p\n", org->ctx, org);
|
|
|
|
}
|
|
|
|
|
|
|
|
ENTER_GL();
|
|
|
|
/* Create the destination context with display lists shared */
|
2001-05-11 02:17:47 +02:00
|
|
|
dest->ctx = glXCreateContext(gdi_display, dest->vis, org->ctx, True);
|
2000-05-30 22:04:21 +02:00
|
|
|
LEAVE_GL();
|
|
|
|
TRACE(" created a delayed OpenGL context (%p) for Wine context %p sharing lists with OpenGL ctx %p\n", dest->ctx, dest, org->ctx);
|
|
|
|
}
|
|
|
|
|
|
|
|
return TRUE;
|
2000-05-12 22:18:14 +02:00
|
|
|
}
|
|
|
|
|
2000-05-18 02:07:53 +02:00
|
|
|
/***********************************************************************
|
2001-06-19 20:20:47 +02:00
|
|
|
* wglSwapLayerBuffers (OPENGL32.@)
|
2000-05-18 02:07:53 +02:00
|
|
|
*/
|
2000-05-12 22:18:14 +02:00
|
|
|
BOOL WINAPI wglSwapLayerBuffers(HDC hdc,
|
|
|
|
UINT fuPlanes) {
|
|
|
|
FIXME("(): stub !\n");
|
|
|
|
|
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
|
2000-05-18 02:07:53 +02:00
|
|
|
/***********************************************************************
|
2001-06-19 20:20:47 +02:00
|
|
|
* wglUseFontBitmapsA (OPENGL32.@)
|
2000-05-18 02:07:53 +02:00
|
|
|
*/
|
2000-05-23 03:20:08 +02:00
|
|
|
BOOL WINAPI wglUseFontBitmapsA(HDC hdc,
|
|
|
|
DWORD first,
|
|
|
|
DWORD count,
|
|
|
|
DWORD listBase) {
|
|
|
|
DC * dc = DC_GetDCPtr( hdc );
|
|
|
|
X11DRV_PDEVICE *physDev = (X11DRV_PDEVICE *)dc->physDev;
|
|
|
|
fontObject* pfo = XFONT_GetFontObject( physDev->font );
|
|
|
|
Font fid = pfo->fs->fid;
|
2000-05-12 22:18:14 +02:00
|
|
|
|
2000-05-23 03:20:08 +02:00
|
|
|
TRACE("(%08x, %ld, %ld, %ld)\n", hdc, first, count, listBase);
|
|
|
|
|
|
|
|
ENTER_GL();
|
|
|
|
/* I assume that the glyphs are at the same position for X and for Windows */
|
|
|
|
glXUseXFont(fid, first, count, listBase);
|
|
|
|
LEAVE_GL();
|
2000-08-19 23:38:55 +02:00
|
|
|
GDI_ReleaseObj( hdc );
|
2000-05-23 03:20:08 +02:00
|
|
|
return TRUE;
|
2000-05-12 22:18:14 +02:00
|
|
|
}
|
|
|
|
|
2000-05-18 02:07:53 +02:00
|
|
|
/***********************************************************************
|
2001-06-19 20:20:47 +02:00
|
|
|
* wglUseFontOutlinesA (OPENGL32.@)
|
2000-05-18 02:07:53 +02:00
|
|
|
*/
|
2000-05-23 03:20:08 +02:00
|
|
|
BOOL WINAPI wglUseFontOutlinesA(HDC hdc,
|
|
|
|
DWORD first,
|
|
|
|
DWORD count,
|
|
|
|
DWORD listBase,
|
|
|
|
FLOAT deviation,
|
|
|
|
FLOAT extrusion,
|
|
|
|
int format,
|
|
|
|
LPGLYPHMETRICSFLOAT lpgmf) {
|
2000-05-12 22:18:14 +02:00
|
|
|
FIXME("(): stub !\n");
|
|
|
|
|
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
|
2000-06-12 23:53:46 +02:00
|
|
|
|
2000-05-12 22:18:14 +02:00
|
|
|
/* This is for brain-dead applications that use OpenGL functions before even
|
|
|
|
creating a rendering context.... */
|
2000-06-12 23:53:46 +02:00
|
|
|
static void process_attach(void) {
|
2001-03-28 03:45:08 +02:00
|
|
|
XWindowAttributes win_attr;
|
|
|
|
Visual *rootVisual;
|
2000-05-12 22:18:14 +02:00
|
|
|
int num;
|
|
|
|
XVisualInfo template;
|
2000-06-12 23:53:46 +02:00
|
|
|
XVisualInfo *vis = NULL;
|
2001-06-26 23:10:11 +02:00
|
|
|
Window root = (Window)GetPropA( GetDesktopWindow(), "__wine_x11_whole_window" );
|
2000-05-12 22:18:14 +02:00
|
|
|
|
2001-06-26 23:10:11 +02:00
|
|
|
if (!root)
|
|
|
|
{
|
|
|
|
ERR("X11DRV not loaded. Cannot create default context.\n");
|
|
|
|
return;
|
2000-06-12 23:53:46 +02:00
|
|
|
}
|
2001-06-26 23:10:11 +02:00
|
|
|
|
2000-05-12 22:18:14 +02:00
|
|
|
ENTER_GL();
|
2001-03-28 03:45:08 +02:00
|
|
|
|
|
|
|
/* Try to get the visual from the Root Window. We can't use the standard (presumably
|
|
|
|
double buffered) X11DRV visual with the Root Window, since we don't know if the Root
|
|
|
|
Window was created using the standard X11DRV visual, and glXMakeCurrent can't deal
|
|
|
|
with mismatched visuals. Note that the Root Window visual may not be double
|
|
|
|
buffered, so apps actually attempting to render this way may flicker */
|
2001-06-26 23:10:11 +02:00
|
|
|
if (XGetWindowAttributes( gdi_display, root, &win_attr ))
|
2001-03-28 03:45:08 +02:00
|
|
|
{
|
|
|
|
rootVisual = win_attr.visual;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
/* Get the default visual, since we can't seem to get the attributes from the
|
|
|
|
Root Window. Let's hope that the Root Window Visual matches the DefaultVisual */
|
2001-05-11 02:17:47 +02:00
|
|
|
rootVisual = DefaultVisual( gdi_display, DefaultScreen(gdi_display) );
|
2001-03-28 03:45:08 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
template.visualid = XVisualIDFromVisual(rootVisual);
|
2001-05-11 02:17:47 +02:00
|
|
|
vis = XGetVisualInfo(gdi_display, VisualIDMask, &template, &num);
|
|
|
|
if (vis != NULL) default_cx = glXCreateContext(gdi_display, vis, 0, GL_TRUE);
|
2001-06-26 23:10:11 +02:00
|
|
|
if (default_cx != NULL) glXMakeCurrent(gdi_display, root, default_cx);
|
2000-06-12 23:53:46 +02:00
|
|
|
XFree(vis);
|
2000-05-12 22:18:14 +02:00
|
|
|
LEAVE_GL();
|
2000-05-30 22:04:21 +02:00
|
|
|
|
2000-06-12 23:53:46 +02:00
|
|
|
if (default_cx == NULL) {
|
|
|
|
ERR("Could not create default context.\n");
|
|
|
|
}
|
|
|
|
|
2000-05-30 22:04:21 +02:00
|
|
|
context_array = NULL;
|
2000-05-12 22:18:14 +02:00
|
|
|
}
|
2000-06-12 23:53:46 +02:00
|
|
|
|
|
|
|
static void process_detach(void) {
|
2001-05-11 02:17:47 +02:00
|
|
|
glXDestroyContext(gdi_display, default_cx);
|
2000-06-12 23:53:46 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
/***********************************************************************
|
|
|
|
* OpenGL initialisation routine
|
|
|
|
*/
|
|
|
|
BOOL WINAPI OpenGL32_Init( HINSTANCE hinst, DWORD reason, LPVOID reserved )
|
|
|
|
{
|
|
|
|
switch(reason) {
|
|
|
|
case DLL_PROCESS_ATTACH:
|
2001-01-17 23:03:18 +01:00
|
|
|
process_attach();
|
2000-06-12 23:53:46 +02:00
|
|
|
break;
|
|
|
|
case DLL_PROCESS_DETACH:
|
2001-01-17 23:03:18 +01:00
|
|
|
process_detach();
|
2000-06-12 23:53:46 +02:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
return TRUE;
|
|
|
|
}
|