2000-05-12 22:18:14 +02:00
|
|
|
/* Window-specific OpenGL functions implementation.
|
2002-03-10 00:29:33 +01:00
|
|
|
*
|
|
|
|
* Copyright (c) 1999 Lionel Ulmer
|
2005-04-28 20:31:15 +02:00
|
|
|
* Copyright (c) 2005 Raphael Junqueira
|
2002-03-10 00:29:33 +01:00
|
|
|
*
|
|
|
|
* This library is free software; you can redistribute it and/or
|
|
|
|
* modify it under the terms of the GNU Lesser General Public
|
|
|
|
* License as published by the Free Software Foundation; either
|
|
|
|
* version 2.1 of the License, or (at your option) any later version.
|
|
|
|
*
|
|
|
|
* This library is distributed in the hope that it will be useful,
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
|
|
|
* Lesser General Public License for more details.
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU Lesser General Public
|
|
|
|
* License along with this library; if not, write to the Free Software
|
2006-05-18 14:49:52 +02:00
|
|
|
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
|
2002-03-10 00:29:33 +01:00
|
|
|
*/
|
2000-05-12 22:18:14 +02:00
|
|
|
|
2001-10-14 18:18:52 +02:00
|
|
|
#include "config.h"
|
2004-01-20 23:48:57 +01:00
|
|
|
#include "wine/port.h"
|
2001-10-14 18:18:52 +02:00
|
|
|
|
2003-09-06 01:08:26 +02:00
|
|
|
#include <stdarg.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
|
|
|
|
|
|
|
#include "windef.h"
|
2002-03-23 22:43:56 +01:00
|
|
|
#include "winbase.h"
|
|
|
|
#include "winuser.h"
|
2000-05-23 23:15:06 +02:00
|
|
|
#include "winerror.h"
|
2005-04-28 20:31:15 +02:00
|
|
|
#include "winreg.h"
|
2005-12-03 18:01:51 +01:00
|
|
|
#include "wingdi.h"
|
2006-03-20 17:55:06 +01:00
|
|
|
#include "winternl.h"
|
|
|
|
#include "winnt.h"
|
2000-05-12 22:18:14 +02:00
|
|
|
|
2004-02-07 02:29:33 +01:00
|
|
|
#include "wgl_ext.h"
|
2000-05-12 22:18:14 +02:00
|
|
|
#include "opengl_ext.h"
|
2006-03-07 14:55:35 +01:00
|
|
|
#ifdef HAVE_GL_GLU_H
|
|
|
|
#undef far
|
|
|
|
#undef near
|
|
|
|
#include <GL/glu.h>
|
|
|
|
#endif
|
2004-01-20 23:48:57 +01:00
|
|
|
#include "wine/library.h"
|
2002-03-23 22:43:56 +01:00
|
|
|
#include "wine/debug.h"
|
2000-05-12 22:18:14 +02:00
|
|
|
|
2006-03-25 13:07:23 +01:00
|
|
|
WINE_DEFAULT_DEBUG_CHANNEL(wgl);
|
|
|
|
WINE_DECLARE_DEBUG_CHANNEL(opengl);
|
2000-05-12 22:18:14 +02:00
|
|
|
|
2005-12-22 13:54:01 +01:00
|
|
|
/** global glx object */
|
|
|
|
wine_glx_t wine_glx;
|
|
|
|
|
2003-04-22 06:05:08 +02:00
|
|
|
/* x11drv GDI escapes */
|
|
|
|
#define X11DRV_ESCAPE 6789
|
|
|
|
enum x11drv_escape_codes
|
|
|
|
{
|
2005-12-19 17:45:13 +01:00
|
|
|
X11DRV_GET_DISPLAY, /* get X11 display for a DC */
|
|
|
|
X11DRV_GET_DRAWABLE, /* get current drawable for a DC */
|
|
|
|
X11DRV_GET_FONT, /* get current X font for a DC */
|
|
|
|
X11DRV_SET_DRAWABLE, /* set current drawable for a DC */
|
|
|
|
X11DRV_START_EXPOSURES, /* start graphics exposures */
|
|
|
|
X11DRV_END_EXPOSURES, /* end graphics exposures */
|
|
|
|
X11DRV_GET_DCE, /* get the DCE pointer */
|
|
|
|
X11DRV_SET_DCE, /* set the DCE pointer */
|
2006-02-02 13:23:55 +01:00
|
|
|
X11DRV_GET_GLX_DRAWABLE, /* get current glx drawable for a DC */
|
|
|
|
X11DRV_SYNC_PIXMAP /* sync the dibsection to its pixmap */
|
2003-04-22 06:05:08 +02:00
|
|
|
};
|
|
|
|
|
2002-09-25 02:29:56 +02:00
|
|
|
void (*wine_tsx11_lock_ptr)(void) = NULL;
|
|
|
|
void (*wine_tsx11_unlock_ptr)(void) = NULL;
|
|
|
|
|
2000-06-12 23:53:46 +02:00
|
|
|
static GLXContext default_cx = NULL;
|
2002-03-23 22:43:56 +01:00
|
|
|
static Display *default_display; /* display to use for default context */
|
2000-06-12 23:53:46 +02:00
|
|
|
|
2004-02-12 01:35:01 +01:00
|
|
|
static HMODULE opengl32_handle;
|
|
|
|
|
2005-03-10 12:13:33 +01:00
|
|
|
static glXGetProcAddressARB_t p_glXGetProcAddressARB = NULL;
|
2003-07-11 05:50:19 +02:00
|
|
|
|
2005-04-28 20:31:15 +02:00
|
|
|
static char internal_gl_disabled_extensions[512];
|
|
|
|
static char* internal_gl_extensions = NULL;
|
|
|
|
|
2000-05-30 22:04:21 +02:00
|
|
|
typedef struct wine_glcontext {
|
|
|
|
HDC hdc;
|
2002-03-23 22:43:56 +01:00
|
|
|
Display *display;
|
2000-05-30 22:04:21 +02:00
|
|
|
XVisualInfo *vis;
|
2005-11-11 11:52:14 +01:00
|
|
|
GLXFBConfig fb_conf;
|
|
|
|
GLXContext ctx;
|
2006-03-20 17:55:06 +01:00
|
|
|
BOOL do_escape;
|
2000-05-30 22:04:21 +02:00
|
|
|
struct wine_glcontext *next;
|
|
|
|
struct wine_glcontext *prev;
|
|
|
|
} Wine_GLContext;
|
2002-03-23 22:43:56 +01:00
|
|
|
static Wine_GLContext *context_list;
|
2000-05-30 22:04:21 +02:00
|
|
|
|
2002-03-23 22:43:56 +01:00
|
|
|
static inline Wine_GLContext *get_context_from_GLXContext(GLXContext ctx)
|
|
|
|
{
|
|
|
|
Wine_GLContext *ret;
|
2006-06-22 21:18:01 +02:00
|
|
|
if (!ctx) return NULL;
|
2002-03-23 22:43:56 +01:00
|
|
|
for (ret = context_list; ret; ret = ret->next) if (ctx == ret->ctx) break;
|
|
|
|
return ret;
|
2000-05-30 22:04:21 +02:00
|
|
|
}
|
2002-03-23 22:43:56 +01:00
|
|
|
|
2006-02-02 13:23:55 +01:00
|
|
|
void enter_gl(void)
|
|
|
|
{
|
2006-03-20 17:55:06 +01:00
|
|
|
Wine_GLContext *curctx = (Wine_GLContext *) NtCurrentTeb()->glContext;
|
|
|
|
|
|
|
|
if (curctx && curctx->do_escape)
|
|
|
|
{
|
|
|
|
enum x11drv_escape_codes escape = X11DRV_SYNC_PIXMAP;
|
|
|
|
ExtEscape(curctx->hdc, X11DRV_ESCAPE, sizeof(escape), (LPCSTR)&escape, 0, NULL);
|
|
|
|
}
|
2006-02-02 13:23:55 +01:00
|
|
|
|
|
|
|
wine_tsx11_lock_ptr();
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2002-03-23 22:43:56 +01:00
|
|
|
static inline void free_context(Wine_GLContext *context)
|
|
|
|
{
|
2000-05-30 22:04:21 +02:00
|
|
|
if (context->next != NULL) context->next->prev = context->prev;
|
|
|
|
if (context->prev != NULL) context->prev->next = context->next;
|
2002-03-23 22:43:56 +01:00
|
|
|
else context_list = context->next;
|
2000-05-30 22:04:21 +02:00
|
|
|
|
|
|
|
HeapFree(GetProcessHeap(), 0, context);
|
|
|
|
}
|
|
|
|
|
2002-03-23 22:43:56 +01:00
|
|
|
static inline Wine_GLContext *alloc_context(void)
|
|
|
|
{
|
2000-05-30 22:04:21 +02:00
|
|
|
Wine_GLContext *ret;
|
|
|
|
|
2002-03-23 22:43:56 +01:00
|
|
|
if ((ret = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(Wine_GLContext))))
|
|
|
|
{
|
|
|
|
ret->next = context_list;
|
|
|
|
if (context_list) context_list->prev = ret;
|
|
|
|
context_list = ret;
|
|
|
|
}
|
2000-05-30 22:04:21 +02:00
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
|
2002-03-23 22:43:56 +01:00
|
|
|
inline static BOOL is_valid_context( Wine_GLContext *ctx )
|
|
|
|
{
|
|
|
|
Wine_GLContext *ptr;
|
|
|
|
for (ptr = context_list; ptr; ptr = ptr->next) if (ptr == ctx) break;
|
|
|
|
return (ptr != NULL);
|
|
|
|
}
|
2000-05-30 22:04:21 +02:00
|
|
|
|
2002-03-23 22:43:56 +01:00
|
|
|
/* retrieve the X display to use on a given DC */
|
|
|
|
inline static Display *get_display( HDC hdc )
|
|
|
|
{
|
|
|
|
Display *display;
|
|
|
|
enum x11drv_escape_codes escape = X11DRV_GET_DISPLAY;
|
|
|
|
|
|
|
|
if (!ExtEscape( hdc, X11DRV_ESCAPE, sizeof(escape), (LPCSTR)&escape,
|
|
|
|
sizeof(display), (LPSTR)&display )) display = NULL;
|
|
|
|
return display;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2005-12-19 17:45:13 +01:00
|
|
|
/* retrieve the GLX drawable to use on a given DC */
|
2002-03-23 22:43:56 +01:00
|
|
|
inline static Drawable get_drawable( HDC hdc )
|
|
|
|
{
|
2005-12-19 17:45:13 +01:00
|
|
|
GLXDrawable drawable;
|
|
|
|
enum x11drv_escape_codes escape = X11DRV_GET_GLX_DRAWABLE;
|
2002-03-23 22:43:56 +01:00
|
|
|
|
|
|
|
if (!ExtEscape( hdc, X11DRV_ESCAPE, sizeof(escape), (LPCSTR)&escape,
|
|
|
|
sizeof(drawable), (LPSTR)&drawable )) drawable = 0;
|
|
|
|
return drawable;
|
2000-05-23 23:15:06 +02:00
|
|
|
}
|
2002-03-23 22:43:56 +01:00
|
|
|
|
2005-04-28 20:31:15 +02:00
|
|
|
/** for use of wglGetCurrentReadDCARB */
|
|
|
|
inline static HDC get_hdc_from_Drawable(GLXDrawable d)
|
|
|
|
{
|
|
|
|
Wine_GLContext *ret;
|
|
|
|
for (ret = context_list; ret; ret = ret->next) {
|
|
|
|
if (d == get_drawable( ret->hdc )) {
|
|
|
|
return ret->hdc;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return NULL;
|
|
|
|
}
|
2002-03-23 22:43:56 +01:00
|
|
|
|
2005-12-19 17:45:13 +01:00
|
|
|
/* retrieve the X font to use on a given DC */
|
2002-03-23 22:43:56 +01:00
|
|
|
inline static Font get_font( HDC hdc )
|
2000-05-23 23:15:06 +02:00
|
|
|
{
|
2002-03-23 22:43:56 +01:00
|
|
|
Font font;
|
|
|
|
enum x11drv_escape_codes escape = X11DRV_GET_FONT;
|
|
|
|
|
|
|
|
if (!ExtEscape( hdc, X11DRV_ESCAPE, sizeof(escape), (LPCSTR)&escape,
|
|
|
|
sizeof(font), (LPSTR)&font )) font = 0;
|
|
|
|
return font;
|
2000-05-23 23:15:06 +02:00
|
|
|
}
|
|
|
|
|
2002-03-23 22:43:56 +01:00
|
|
|
|
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-30 22:04:21 +02:00
|
|
|
Wine_GLContext *ret;
|
2001-03-28 03:45:08 +02:00
|
|
|
int num;
|
|
|
|
XVisualInfo template;
|
2005-12-08 12:45:07 +01:00
|
|
|
XVisualInfo *vis = NULL;
|
2002-03-23 22:43:56 +01:00
|
|
|
Display *display = get_display( hdc );
|
2005-11-30 18:26:16 +01:00
|
|
|
int hdcPF = GetPixelFormat(hdc);
|
|
|
|
GLXFBConfig cur_cfg;
|
2000-05-12 22:18:14 +02:00
|
|
|
|
2005-12-08 12:45:07 +01:00
|
|
|
TRACE("(%p)->(PF:%d)\n", hdc, hdcPF);
|
2000-05-12 22:18:14 +02:00
|
|
|
|
2001-03-28 03:45:08 +02:00
|
|
|
/* First, get the visual in use by the X11DRV */
|
2002-03-23 22:43:56 +01:00
|
|
|
if (!display) return 0;
|
2002-10-19 01:48:57 +02:00
|
|
|
template.visualid = (VisualID)GetPropA( GetDesktopWindow(), "__wine_x11_visual_id" );
|
2002-03-23 22:43:56 +01:00
|
|
|
vis = XGetVisualInfo(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;
|
|
|
|
}
|
2005-11-30 18:26:16 +01:00
|
|
|
if (0 >= hdcPF) {
|
|
|
|
SetLastError(ERROR_INVALID_PIXEL_FORMAT);
|
|
|
|
return NULL;
|
|
|
|
}
|
2000-05-12 22:18:14 +02:00
|
|
|
|
2005-11-11 11:52:14 +01:00
|
|
|
{
|
|
|
|
int nCfgs_fmt = 0;
|
|
|
|
GLXFBConfig* cfgs_fmt = NULL;
|
|
|
|
int value;
|
|
|
|
int gl_test = 0;
|
2005-12-22 13:54:01 +01:00
|
|
|
cfgs_fmt = wine_glx.p_glXGetFBConfigs(display, DefaultScreen(display), &nCfgs_fmt);
|
2005-11-11 11:52:14 +01:00
|
|
|
if (NULL == cfgs_fmt || 0 == nCfgs_fmt) {
|
|
|
|
ERR("Cannot get FB Configs, expect problems.\n");
|
2005-11-30 18:26:16 +01:00
|
|
|
SetLastError(ERROR_INVALID_PIXEL_FORMAT);
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
if (nCfgs_fmt < hdcPF) {
|
|
|
|
ERR("(%p): unexpected pixelFormat(%d) > nFormats(%d), returns NULL\n", hdc, hdcPF, nCfgs_fmt);
|
|
|
|
SetLastError(ERROR_INVALID_PIXEL_FORMAT);
|
2005-11-11 11:52:14 +01:00
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
cur_cfg = cfgs_fmt[hdcPF - 1];
|
2005-12-22 13:54:01 +01:00
|
|
|
gl_test = wine_glx.p_glXGetFBConfigAttrib(display, cur_cfg, GLX_FBCONFIG_ID, &value);
|
2005-11-11 11:52:14 +01:00
|
|
|
if (gl_test) {
|
|
|
|
ERR("Failed to retrieve FBCONFIG_ID from GLXFBConfig, expect problems.\n");
|
2005-11-30 18:26:16 +01:00
|
|
|
SetLastError(ERROR_INVALID_PIXEL_FORMAT);
|
2005-11-11 11:52:14 +01:00
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
XFree(cfgs_fmt);
|
|
|
|
}
|
|
|
|
|
2005-11-30 18:26:16 +01:00
|
|
|
/* The context will be allocated in the wglMakeCurrent call */
|
|
|
|
ENTER_GL();
|
|
|
|
ret = alloc_context();
|
|
|
|
LEAVE_GL();
|
|
|
|
ret->hdc = hdc;
|
|
|
|
ret->display = display;
|
|
|
|
ret->fb_conf = cur_cfg;
|
2005-12-08 12:45:07 +01:00
|
|
|
/*ret->vis = vis;*/
|
2005-12-22 13:54:01 +01:00
|
|
|
ret->vis = wine_glx.p_glXGetVisualFromFBConfig(display, cur_cfg);
|
2005-11-30 18:26:16 +01: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) {
|
2002-11-30 02:55:59 +01:00
|
|
|
TRACE("(%p,%d)\n", hdc, iLayerPlane);
|
|
|
|
|
|
|
|
if (iLayerPlane == 0) {
|
|
|
|
return wglCreateContext(hdc);
|
|
|
|
}
|
|
|
|
FIXME(" no handler for layer %d\n", iLayerPlane);
|
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
|
|
|
* 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
|
|
|
*/
|
2002-03-23 22:43:56 +01:00
|
|
|
BOOL WINAPI wglDeleteContext(HGLRC hglrc)
|
|
|
|
{
|
2000-05-30 22:04:21 +02:00
|
|
|
Wine_GLContext *ctx = (Wine_GLContext *) hglrc;
|
2002-03-23 22:43:56 +01:00
|
|
|
BOOL ret = TRUE;
|
|
|
|
|
2000-05-23 03:20:08 +02:00
|
|
|
TRACE("(%p)\n", hglrc);
|
2002-06-01 01:06:46 +02:00
|
|
|
|
2000-05-23 03:20:08 +02:00
|
|
|
ENTER_GL();
|
2002-03-23 22:43:56 +01:00
|
|
|
/* A game (Half Life not to name it) deletes twice the same context,
|
|
|
|
* so make sure it is valid first */
|
|
|
|
if (is_valid_context( ctx ))
|
|
|
|
{
|
|
|
|
if (ctx->ctx) glXDestroyContext(ctx->display, ctx->ctx);
|
|
|
|
free_context(ctx);
|
2000-05-23 23:15:06 +02:00
|
|
|
}
|
2002-03-23 22:43:56 +01:00
|
|
|
else
|
|
|
|
{
|
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();
|
2002-06-01 01:06:46 +02:00
|
|
|
|
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) {
|
2002-10-19 01:48:57 +02:00
|
|
|
FIXME("(%p,%d,%d,%d,%p)\n", hdc, iPixelFormat, iLayerPlane, nBytes, plpd);
|
2000-05-12 22:18:14 +02:00
|
|
|
|
|
|
|
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);
|
2002-06-01 01:06:46 +02:00
|
|
|
|
2004-08-16 22:07:06 +02:00
|
|
|
return (HGLRC)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
|
|
|
* 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");
|
2002-06-01 01:06:46 +02:00
|
|
|
|
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) {
|
2002-10-19 01:48:57 +02:00
|
|
|
TRACE(" returning %p (GL context %p - Wine context %p)\n", ret->hdc, gl_ctx, ret);
|
2000-05-30 22:04:21 +02:00
|
|
|
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;
|
|
|
|
}
|
|
|
|
|
2002-01-02 22:43:19 +01:00
|
|
|
/***********************************************************************
|
|
|
|
* wglGetProcAddress (OPENGL32.@)
|
|
|
|
*/
|
2000-05-12 22:18:14 +02:00
|
|
|
static int compar(const void *elt_a, const void *elt_b) {
|
2004-11-30 22:38:57 +01:00
|
|
|
return strcmp(((const OpenGL_extension *) elt_a)->name,
|
|
|
|
((const OpenGL_extension *) elt_b)->name);
|
2000-05-12 22:18:14 +02:00
|
|
|
}
|
|
|
|
|
2004-02-07 02:29:33 +01:00
|
|
|
static int wgl_compar(const void *elt_a, const void *elt_b) {
|
2004-11-30 22:38:57 +01:00
|
|
|
return strcmp(((const WGL_extension *) elt_a)->func_name,
|
|
|
|
((const WGL_extension *) elt_b)->func_name);
|
2004-02-07 02:29:33 +01:00
|
|
|
}
|
|
|
|
|
2005-12-03 18:01:51 +01:00
|
|
|
PROC WINAPI wglGetProcAddress(LPCSTR lpszProc) {
|
2000-05-12 22:18:14 +02:00
|
|
|
void *local_func;
|
2002-01-02 22:43:19 +01:00
|
|
|
OpenGL_extension ext;
|
2006-06-09 18:13:09 +02:00
|
|
|
const OpenGL_extension *ext_ret;
|
2002-01-02 22:43:19 +01:00
|
|
|
|
2000-05-12 22:18:14 +02:00
|
|
|
TRACE("(%s)\n", lpszProc);
|
|
|
|
|
|
|
|
/* First, look if it's not already defined in the 'standard' OpenGL functions */
|
2004-02-12 01:35:01 +01:00
|
|
|
if ((local_func = GetProcAddress(opengl32_handle, 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;
|
|
|
|
}
|
|
|
|
|
2003-07-11 05:50:19 +02:00
|
|
|
if (p_glXGetProcAddressARB == NULL) {
|
2003-09-17 22:04:25 +02:00
|
|
|
ERR("Warning : dynamic GL extension loading not supported by native GL library.\n");
|
2003-07-11 05:50:19 +02:00
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
|
2002-01-02 22:43:19 +01:00
|
|
|
/* After that, search in the thunks to find the real name of the extension */
|
2006-06-09 18:13:09 +02:00
|
|
|
ext.name = lpszProc;
|
|
|
|
ext_ret = (const OpenGL_extension *) bsearch(&ext, extension_registry,
|
2002-01-02 22:43:19 +01:00
|
|
|
extension_registry_size, sizeof(OpenGL_extension), compar);
|
|
|
|
|
|
|
|
if (ext_ret == NULL) {
|
2004-02-07 02:29:33 +01:00
|
|
|
WGL_extension wgl_ext, *wgl_ext_ret;
|
|
|
|
|
|
|
|
/* Try to find the function in the WGL extensions ... */
|
|
|
|
wgl_ext.func_name = (char *) lpszProc;
|
|
|
|
wgl_ext_ret = (WGL_extension *) bsearch(&wgl_ext, wgl_extension_registry,
|
|
|
|
wgl_extension_registry_size, sizeof(WGL_extension), wgl_compar);
|
|
|
|
|
|
|
|
if (wgl_ext_ret == NULL) {
|
|
|
|
/* Some sanity checks :-) */
|
|
|
|
ENTER_GL();
|
2005-08-10 11:48:58 +02:00
|
|
|
local_func = p_glXGetProcAddressARB( (const GLubyte *) lpszProc);
|
2004-02-07 02:29:33 +01:00
|
|
|
LEAVE_GL();
|
|
|
|
if (local_func != NULL) {
|
2004-09-02 00:46:40 +02:00
|
|
|
WARN("Extension %s defined in the OpenGL library but NOT in opengl_ext.c...\n", lpszProc);
|
2004-02-07 02:29:33 +01:00
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
|
|
|
|
WARN("Did not find extension %s in either Wine or your OpenGL library.\n", lpszProc);
|
2002-01-02 22:43:19 +01:00
|
|
|
return NULL;
|
2004-02-07 02:29:33 +01:00
|
|
|
} else {
|
|
|
|
void *ret = NULL;
|
|
|
|
|
|
|
|
if (wgl_ext_ret->func_init != NULL) {
|
|
|
|
const char *err_msg;
|
|
|
|
if ((err_msg = wgl_ext_ret->func_init(p_glXGetProcAddressARB,
|
|
|
|
wgl_ext_ret->context)) == NULL) {
|
|
|
|
ret = wgl_ext_ret->func_address;
|
|
|
|
} else {
|
|
|
|
WARN("Error when getting WGL extension '%s' : %s.\n", debugstr_a(lpszProc), err_msg);
|
|
|
|
return NULL;
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
ret = wgl_ext_ret->func_address;
|
|
|
|
}
|
2000-05-12 22:18:14 +02:00
|
|
|
|
2004-02-07 02:29:33 +01:00
|
|
|
if (ret)
|
|
|
|
TRACE(" returning WGL function (%p)\n", ret);
|
|
|
|
return ret;
|
|
|
|
}
|
2000-05-12 22:18:14 +02:00
|
|
|
} else {
|
2006-06-09 16:26:44 +02:00
|
|
|
const char *glx_name = ext_ret->glx_name ? ext_ret->glx_name : ext_ret->name;
|
2003-07-11 05:50:19 +02:00
|
|
|
ENTER_GL();
|
2006-06-09 16:26:44 +02:00
|
|
|
local_func = p_glXGetProcAddressARB( (const GLubyte*)glx_name);
|
2003-07-11 05:50:19 +02:00
|
|
|
LEAVE_GL();
|
|
|
|
|
2002-01-02 22:43:19 +01:00
|
|
|
/* After that, look at the extensions defined in the Linux OpenGL library */
|
2003-07-11 05:50:19 +02:00
|
|
|
if (local_func == NULL) {
|
2002-01-02 22:43:19 +01:00
|
|
|
char buf[256];
|
|
|
|
void *ret = NULL;
|
2002-06-01 01:06:46 +02:00
|
|
|
|
2002-01-02 22:43:19 +01:00
|
|
|
/* Remove the 3 last letters (EXT, ARB, ...).
|
2002-06-01 01:06:46 +02:00
|
|
|
|
2002-01-02 22:43:19 +01:00
|
|
|
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).
|
|
|
|
*/
|
2006-06-09 16:26:44 +02:00
|
|
|
memcpy(buf, glx_name, strlen(glx_name) - 3);
|
|
|
|
buf[strlen(glx_name) - 3] = '\0';
|
2002-01-02 22:43:19 +01:00
|
|
|
TRACE(" extension not found in the Linux OpenGL library, checking against libGL bug with %s..\n", buf);
|
2002-06-01 01:06:46 +02:00
|
|
|
|
2004-02-12 01:35:01 +01:00
|
|
|
ret = GetProcAddress(opengl32_handle, buf);
|
2002-01-02 22:43:19 +01:00
|
|
|
if (ret != NULL) {
|
|
|
|
TRACE(" found function in main OpenGL library (%p) !\n", ret);
|
|
|
|
} else {
|
2006-06-09 16:26:44 +02:00
|
|
|
WARN("Did not find function %s (%s) in your OpenGL library !\n", lpszProc, glx_name);
|
2002-06-01 01:06:46 +02:00
|
|
|
}
|
|
|
|
|
2002-01-02 22:43:19 +01:00
|
|
|
return ret;
|
2000-05-12 22:18:14 +02:00
|
|
|
} else {
|
2002-01-02 22:43:19 +01:00
|
|
|
TRACE(" returning function (%p)\n", ext_ret->func);
|
2006-06-09 18:13:09 +02:00
|
|
|
extension_funcs[ext_ret - extension_registry] = local_func;
|
2002-06-01 01:06:46 +02:00
|
|
|
|
2002-01-02 22:43:19 +01:00
|
|
|
return ext_ret->func;
|
2000-05-12 22:18:14 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2005-12-22 13:54:01 +01:00
|
|
|
static int describeContext(Wine_GLContext* ctx) {
|
|
|
|
int tmp;
|
|
|
|
int ctx_vis_id;
|
|
|
|
TRACE(" Context %p have (vis:%p):\n", ctx, ctx->vis);
|
|
|
|
wine_glx.p_glXGetFBConfigAttrib(ctx->display, ctx->fb_conf, GLX_FBCONFIG_ID, &tmp);
|
|
|
|
TRACE(" - FBCONFIG_ID 0x%x\n", tmp);
|
|
|
|
wine_glx.p_glXGetFBConfigAttrib(ctx->display, ctx->fb_conf, GLX_VISUAL_ID, &tmp);
|
|
|
|
TRACE(" - VISUAL_ID 0x%x\n", tmp);
|
|
|
|
ctx_vis_id = tmp;
|
|
|
|
return ctx_vis_id;
|
|
|
|
}
|
|
|
|
|
|
|
|
static int describeDrawable(Wine_GLContext* ctx, Drawable drawable) {
|
|
|
|
int tmp;
|
2006-05-09 00:38:00 +02:00
|
|
|
int nElements;
|
|
|
|
int attribList[3] = { GLX_FBCONFIG_ID, 0, None };
|
|
|
|
GLXFBConfig *fbCfgs;
|
|
|
|
|
2005-12-22 13:54:01 +01:00
|
|
|
if (3 > wine_glx.version || NULL == wine_glx.p_glXQueryDrawable) {
|
|
|
|
/** glXQueryDrawable not available so returns not supported */
|
|
|
|
return -1;
|
|
|
|
}
|
2006-05-09 00:38:00 +02:00
|
|
|
|
2005-12-22 13:54:01 +01:00
|
|
|
TRACE(" Drawable %p have :\n", (void*) drawable);
|
|
|
|
wine_glx.p_glXQueryDrawable(ctx->display, drawable, GLX_WIDTH, (unsigned int*) &tmp);
|
|
|
|
TRACE(" - WIDTH as %d\n", tmp);
|
|
|
|
wine_glx.p_glXQueryDrawable(ctx->display, drawable, GLX_HEIGHT, (unsigned int*) &tmp);
|
|
|
|
TRACE(" - HEIGHT as %d\n", tmp);
|
2006-05-09 00:38:00 +02:00
|
|
|
wine_glx.p_glXQueryDrawable(ctx->display, drawable, GLX_FBCONFIG_ID, (unsigned int*) &tmp);
|
|
|
|
TRACE(" - FBCONFIG_ID as 0x%x\n", tmp);
|
|
|
|
|
|
|
|
attribList[1] = tmp;
|
|
|
|
fbCfgs = wine_glx.p_glXChooseFBConfig(ctx->display, DefaultScreen(ctx->display), attribList, &nElements);
|
|
|
|
if (fbCfgs == NULL) {
|
|
|
|
return -1;
|
|
|
|
}
|
|
|
|
|
|
|
|
wine_glx.p_glXGetFBConfigAttrib(ctx->display, fbCfgs[0], GLX_VISUAL_ID, &tmp);
|
|
|
|
TRACE(" - VISUAL_ID as 0x%x\n", tmp);
|
|
|
|
|
|
|
|
XFree(fbCfgs);
|
|
|
|
|
|
|
|
return tmp;
|
2005-12-22 13:54:01 +01:00
|
|
|
}
|
|
|
|
|
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;
|
2005-12-19 17:45:13 +01:00
|
|
|
DWORD type = GetObjectType(hdc);
|
2000-05-12 22:18:14 +02:00
|
|
|
|
2002-10-19 01:48:57 +02:00
|
|
|
TRACE("(%p,%p)\n", hdc, hglrc);
|
2002-06-01 01:06:46 +02:00
|
|
|
|
2002-03-23 22:43:56 +01:00
|
|
|
ENTER_GL();
|
2000-05-23 23:15:06 +02:00
|
|
|
if (hglrc == NULL) {
|
2002-03-23 22:43:56 +01:00
|
|
|
ret = glXMakeCurrent(default_display, None, NULL);
|
2006-03-20 17:55:06 +01:00
|
|
|
NtCurrentTeb()->glContext = NULL;
|
2000-05-23 23:15:06 +02:00
|
|
|
} else {
|
2000-05-30 22:04:21 +02:00
|
|
|
Wine_GLContext *ctx = (Wine_GLContext *) hglrc;
|
2002-03-23 22:43:56 +01:00
|
|
|
Drawable drawable = get_drawable( hdc );
|
2000-05-30 22:04:21 +02:00
|
|
|
if (ctx->ctx == NULL) {
|
2005-12-08 12:45:07 +01:00
|
|
|
int draw_vis_id, ctx_vis_id;
|
|
|
|
VisualID visualid = (VisualID)GetPropA( GetDesktopWindow(), "__wine_x11_visual_id" );
|
2005-12-22 13:54:01 +01:00
|
|
|
TRACE(" Wine desktop VISUAL_ID is 0x%x\n", (unsigned int) visualid);
|
|
|
|
draw_vis_id = describeDrawable(ctx, drawable);
|
|
|
|
ctx_vis_id = describeContext(ctx);
|
2005-12-08 12:45:07 +01:00
|
|
|
|
2005-12-22 13:54:01 +01:00
|
|
|
if (-1 == draw_vis_id || (draw_vis_id == visualid && draw_vis_id != ctx_vis_id)) {
|
2005-12-08 12:45:07 +01:00
|
|
|
/**
|
|
|
|
* Inherits from root window so reuse desktop visual
|
|
|
|
*/
|
|
|
|
XVisualInfo template;
|
|
|
|
XVisualInfo *vis;
|
|
|
|
int num;
|
|
|
|
template.visualid = visualid;
|
|
|
|
vis = XGetVisualInfo(ctx->display, VisualIDMask, &template, &num);
|
|
|
|
|
|
|
|
TRACE(" Creating GLX Context\n");
|
2006-01-11 12:10:04 +01:00
|
|
|
ctx->ctx = glXCreateContext(ctx->display, vis, NULL, type == OBJ_MEMDC ? False : True);
|
2005-12-08 12:45:07 +01:00
|
|
|
} else {
|
|
|
|
TRACE(" Creating GLX Context\n");
|
2006-01-11 12:10:04 +01:00
|
|
|
ctx->ctx = glXCreateContext(ctx->display, ctx->vis, NULL, type == OBJ_MEMDC ? False : True);
|
2005-12-08 12:45:07 +01:00
|
|
|
}
|
|
|
|
TRACE(" created a delayed OpenGL context (%p)\n", ctx->ctx);
|
2000-05-30 22:04:21 +02:00
|
|
|
}
|
2005-05-12 11:55:44 +02:00
|
|
|
TRACE(" make current for dis %p, drawable %p, ctx %p\n", ctx->display, (void*) drawable, ctx->ctx);
|
2002-03-23 22:43:56 +01:00
|
|
|
ret = glXMakeCurrent(ctx->display, drawable, ctx->ctx);
|
2006-03-20 17:55:06 +01:00
|
|
|
NtCurrentTeb()->glContext = ctx;
|
2005-12-19 17:45:13 +01:00
|
|
|
if(ret && type == OBJ_MEMDC)
|
2006-03-20 17:55:06 +01:00
|
|
|
{
|
|
|
|
ctx->do_escape = TRUE;
|
2005-12-19 17:45:13 +01:00
|
|
|
glDrawBuffer(GL_FRONT_LEFT);
|
2006-03-20 17:55:06 +01:00
|
|
|
}
|
2000-05-23 23:15:06 +02:00
|
|
|
}
|
2002-03-23 22:43:56 +01:00
|
|
|
LEAVE_GL();
|
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;
|
|
|
|
}
|
|
|
|
|
2005-04-28 20:31:15 +02:00
|
|
|
/***********************************************************************
|
|
|
|
* wglMakeContextCurrentARB (OPENGL32.@)
|
|
|
|
*/
|
|
|
|
BOOL WINAPI wglMakeContextCurrentARB(HDC hDrawDC, HDC hReadDC, HGLRC hglrc)
|
|
|
|
{
|
|
|
|
BOOL ret;
|
|
|
|
TRACE("(%p,%p,%p)\n", hDrawDC, hReadDC, hglrc);
|
|
|
|
|
|
|
|
ENTER_GL();
|
|
|
|
if (hglrc == NULL) {
|
2005-12-22 13:54:01 +01:00
|
|
|
ret = glXMakeCurrent(default_display, None, NULL);
|
2005-04-28 20:31:15 +02:00
|
|
|
} else {
|
2005-12-22 13:54:01 +01:00
|
|
|
if (NULL == wine_glx.p_glXMakeContextCurrent) {
|
|
|
|
ret = FALSE;
|
|
|
|
} else {
|
|
|
|
Wine_GLContext *ctx = (Wine_GLContext *) hglrc;
|
|
|
|
Drawable d_draw = get_drawable( hDrawDC );
|
|
|
|
Drawable d_read = get_drawable( hReadDC );
|
|
|
|
|
|
|
|
if (ctx->ctx == NULL) {
|
2006-01-11 12:10:04 +01:00
|
|
|
ctx->ctx = glXCreateContext(ctx->display, ctx->vis, NULL, GetObjectType(hDrawDC) == OBJ_MEMDC ? False : True);
|
|
|
|
TRACE(" created a delayed OpenGL context (%p)\n", ctx->ctx);
|
2005-12-22 13:54:01 +01:00
|
|
|
}
|
|
|
|
ret = wine_glx.p_glXMakeContextCurrent(ctx->display, d_draw, d_read, ctx->ctx);
|
2005-04-28 20:31:15 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
LEAVE_GL();
|
|
|
|
|
|
|
|
TRACE(" returning %s\n", (ret ? "True" : "False"));
|
|
|
|
return ret;
|
|
|
|
}
|
|
|
|
|
|
|
|
/***********************************************************************
|
|
|
|
* wglGetCurrentReadDCARB (OPENGL32.@)
|
|
|
|
*/
|
|
|
|
HDC WINAPI wglGetCurrentReadDCARB(void)
|
|
|
|
{
|
|
|
|
GLXDrawable gl_d;
|
|
|
|
HDC ret;
|
|
|
|
|
|
|
|
TRACE("()\n");
|
|
|
|
|
|
|
|
ENTER_GL();
|
|
|
|
gl_d = glXGetCurrentReadDrawable();
|
|
|
|
ret = get_hdc_from_Drawable(gl_d);
|
|
|
|
LEAVE_GL();
|
|
|
|
|
|
|
|
TRACE(" returning %p (GL drawable %lu)\n", ret, gl_d);
|
|
|
|
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;
|
2002-06-01 01:06:46 +02:00
|
|
|
|
2000-05-30 22:04:21 +02:00
|
|
|
TRACE("(%p, %p)\n", org, dest);
|
2000-05-12 22:18:14 +02:00
|
|
|
|
2005-11-29 10:43:38 +01:00
|
|
|
if (NULL != dest && dest->ctx != NULL) {
|
2000-05-30 22:04:21 +02:00
|
|
|
ERR("Could not share display lists, context already created !\n");
|
|
|
|
return FALSE;
|
|
|
|
} else {
|
|
|
|
if (org->ctx == NULL) {
|
|
|
|
ENTER_GL();
|
2005-12-22 13:54:01 +01:00
|
|
|
describeContext(org);
|
2006-01-11 12:10:04 +01:00
|
|
|
org->ctx = glXCreateContext(org->display, org->vis, NULL, GetObjectType(org->hdc) == OBJ_MEMDC ? False : 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);
|
|
|
|
}
|
2005-11-29 10:43:38 +01:00
|
|
|
if (NULL != dest) {
|
|
|
|
ENTER_GL();
|
2005-12-22 13:54:01 +01:00
|
|
|
describeContext(dest);
|
2005-11-29 10:43:38 +01:00
|
|
|
/* Create the destination context with display lists shared */
|
2006-01-11 12:10:04 +01:00
|
|
|
dest->ctx = glXCreateContext(org->display, dest->vis, org->ctx, GetObjectType(org->hdc) == OBJ_MEMDC ? False : True);
|
2005-11-29 10:43:38 +01: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-30 22:04:21 +02:00
|
|
|
}
|
2005-11-29 10:43:38 +01:00
|
|
|
return FALSE;
|
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) {
|
2006-03-25 13:07:23 +01:00
|
|
|
TRACE_(opengl)("(%p, %08x)\n", hdc, fuPlanes);
|
2000-05-12 22:18:14 +02:00
|
|
|
|
2002-06-10 04:28:42 +02:00
|
|
|
if (fuPlanes & WGL_SWAP_MAIN_PLANE) {
|
|
|
|
if (!SwapBuffers(hdc)) return FALSE;
|
|
|
|
fuPlanes &= ~WGL_SWAP_MAIN_PLANE;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (fuPlanes) {
|
|
|
|
WARN("Following layers unhandled : %08x\n", fuPlanes);
|
|
|
|
}
|
2002-07-03 03:16:45 +02:00
|
|
|
|
2002-06-10 04:28:42 +02:00
|
|
|
return TRUE;
|
2000-05-12 22:18:14 +02:00
|
|
|
}
|
|
|
|
|
2004-01-06 01:36:13 +01:00
|
|
|
static BOOL internal_wglUseFontBitmaps(HDC hdc,
|
|
|
|
DWORD first,
|
|
|
|
DWORD count,
|
|
|
|
DWORD listBase,
|
2005-11-02 21:51:41 +01:00
|
|
|
DWORD (WINAPI *GetGlyphOutline_ptr)(HDC,UINT,UINT,LPGLYPHMETRICS,DWORD,LPVOID,const MAT2*))
|
2002-03-23 22:43:56 +01:00
|
|
|
{
|
2002-07-08 21:34:26 +02:00
|
|
|
/* We are running using client-side rendering fonts... */
|
|
|
|
GLYPHMETRICS gm;
|
2004-09-22 04:46:38 +02:00
|
|
|
unsigned int glyph;
|
2002-07-08 21:34:26 +02:00
|
|
|
int size = 0;
|
|
|
|
void *bitmap = NULL, *gl_bitmap = NULL;
|
|
|
|
int org_alignment;
|
|
|
|
|
|
|
|
ENTER_GL();
|
|
|
|
glGetIntegerv(GL_UNPACK_ALIGNMENT, &org_alignment);
|
|
|
|
glPixelStorei(GL_UNPACK_ALIGNMENT, 4);
|
|
|
|
LEAVE_GL();
|
|
|
|
|
|
|
|
for (glyph = first; glyph < first + count; glyph++) {
|
2004-09-22 04:46:38 +02:00
|
|
|
unsigned int needed_size = GetGlyphOutline_ptr(hdc, glyph, GGO_BITMAP, &gm, 0, NULL, NULL);
|
2004-01-06 01:36:13 +01:00
|
|
|
int height, width_int;
|
2004-02-24 01:58:39 +01:00
|
|
|
|
2004-02-24 02:21:43 +01:00
|
|
|
TRACE("Glyph : %3d / List : %ld\n", glyph, listBase);
|
2004-02-24 01:58:39 +01:00
|
|
|
if (needed_size == GDI_ERROR) {
|
|
|
|
TRACE(" - needed size : %d (GDI_ERROR)\n", needed_size);
|
|
|
|
goto error;
|
|
|
|
} else {
|
|
|
|
TRACE(" - needed size : %d\n", needed_size);
|
|
|
|
}
|
|
|
|
|
2004-01-06 01:36:13 +01:00
|
|
|
if (needed_size > size) {
|
|
|
|
size = needed_size;
|
2004-12-23 18:06:43 +01:00
|
|
|
HeapFree(GetProcessHeap(), 0, bitmap);
|
|
|
|
HeapFree(GetProcessHeap(), 0, gl_bitmap);
|
2004-01-06 01:36:13 +01:00
|
|
|
bitmap = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, size);
|
|
|
|
gl_bitmap = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, size);
|
|
|
|
}
|
2004-02-24 01:58:39 +01:00
|
|
|
if (GetGlyphOutline_ptr(hdc, glyph, GGO_BITMAP, &gm, size, bitmap, NULL) == GDI_ERROR) goto error;
|
2004-01-06 01:36:13 +01:00
|
|
|
if (TRACE_ON(opengl)) {
|
|
|
|
unsigned int height, width, bitmask;
|
|
|
|
unsigned char *bitmap_ = (unsigned char *) bitmap;
|
|
|
|
|
2004-02-24 02:21:43 +01:00
|
|
|
TRACE(" - bbox : %d x %d\n", gm.gmBlackBoxX, gm.gmBlackBoxY);
|
|
|
|
TRACE(" - origin : (%ld , %ld)\n", gm.gmptGlyphOrigin.x, gm.gmptGlyphOrigin.y);
|
|
|
|
TRACE(" - increment : %d - %d\n", gm.gmCellIncX, gm.gmCellIncY);
|
|
|
|
if (needed_size != 0) {
|
2005-11-10 13:14:56 +01:00
|
|
|
TRACE(" - bitmap :\n");
|
2004-02-24 02:21:43 +01:00
|
|
|
for (height = 0; height < gm.gmBlackBoxY; height++) {
|
|
|
|
TRACE(" ");
|
|
|
|
for (width = 0, bitmask = 0x80; width < gm.gmBlackBoxX; width++, bitmask >>= 1) {
|
|
|
|
if (bitmask == 0) {
|
|
|
|
bitmap_ += 1;
|
|
|
|
bitmask = 0x80;
|
|
|
|
}
|
|
|
|
if (*bitmap_ & bitmask)
|
2005-09-25 17:23:21 +02:00
|
|
|
TRACE("*");
|
2004-02-24 02:21:43 +01:00
|
|
|
else
|
2005-09-25 17:23:21 +02:00
|
|
|
TRACE(" ");
|
2004-01-06 01:36:13 +01:00
|
|
|
}
|
2005-09-12 17:14:06 +02:00
|
|
|
bitmap_ += (4 - ((UINT_PTR)bitmap_ & 0x03));
|
2005-09-25 17:23:21 +02:00
|
|
|
TRACE("\n");
|
2004-01-06 01:36:13 +01:00
|
|
|
}
|
2002-07-08 21:34:26 +02:00
|
|
|
}
|
|
|
|
}
|
2004-01-06 01:36:13 +01:00
|
|
|
|
2004-02-24 02:21:43 +01:00
|
|
|
/* In OpenGL, the bitmap is drawn from the bottom to the top... So we need to invert the
|
|
|
|
* glyph for it to be drawn properly.
|
|
|
|
*/
|
|
|
|
if (needed_size != 0) {
|
|
|
|
width_int = (gm.gmBlackBoxX + 31) / 32;
|
|
|
|
for (height = 0; height < gm.gmBlackBoxY; height++) {
|
|
|
|
int width;
|
|
|
|
for (width = 0; width < width_int; width++) {
|
|
|
|
((int *) gl_bitmap)[(gm.gmBlackBoxY - height - 1) * width_int + width] =
|
|
|
|
((int *) bitmap)[height * width_int + width];
|
|
|
|
}
|
2004-01-06 01:36:13 +01:00
|
|
|
}
|
2002-07-08 21:34:26 +02:00
|
|
|
}
|
2004-01-06 01:36:13 +01:00
|
|
|
|
|
|
|
ENTER_GL();
|
|
|
|
glNewList(listBase++, GL_COMPILE);
|
2004-02-24 02:21:43 +01:00
|
|
|
if (needed_size != 0) {
|
|
|
|
glBitmap(gm.gmBlackBoxX, gm.gmBlackBoxY,
|
2004-02-25 02:25:49 +01:00
|
|
|
0 - (int) gm.gmptGlyphOrigin.x, (int) gm.gmBlackBoxY - (int) gm.gmptGlyphOrigin.y,
|
2004-02-24 02:21:43 +01:00
|
|
|
gm.gmCellIncX, gm.gmCellIncY,
|
|
|
|
gl_bitmap);
|
|
|
|
} else {
|
|
|
|
/* This is the case of 'empty' glyphs like the space character */
|
|
|
|
glBitmap(0, 0, 0, 0, gm.gmCellIncX, gm.gmCellIncY, NULL);
|
|
|
|
}
|
2004-01-06 01:36:13 +01:00
|
|
|
glEndList();
|
|
|
|
LEAVE_GL();
|
2002-07-08 21:34:26 +02:00
|
|
|
}
|
2004-01-06 01:36:13 +01:00
|
|
|
|
2002-07-08 21:34:26 +02:00
|
|
|
ENTER_GL();
|
|
|
|
glPixelStorei(GL_UNPACK_ALIGNMENT, org_alignment);
|
|
|
|
LEAVE_GL();
|
2004-01-06 01:36:13 +01:00
|
|
|
|
2004-12-23 18:06:43 +01:00
|
|
|
HeapFree(GetProcessHeap(), 0, bitmap);
|
|
|
|
HeapFree(GetProcessHeap(), 0, gl_bitmap);
|
2002-07-08 21:34:26 +02:00
|
|
|
return TRUE;
|
|
|
|
|
|
|
|
error:
|
|
|
|
ENTER_GL();
|
|
|
|
glPixelStorei(GL_UNPACK_ALIGNMENT, org_alignment);
|
|
|
|
LEAVE_GL();
|
|
|
|
|
2004-12-23 18:06:43 +01:00
|
|
|
HeapFree(GetProcessHeap(), 0, bitmap);
|
|
|
|
HeapFree(GetProcessHeap(), 0, gl_bitmap);
|
2004-01-06 01:36:13 +01:00
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
|
|
|
|
/***********************************************************************
|
|
|
|
* wglUseFontBitmapsA (OPENGL32.@)
|
|
|
|
*/
|
|
|
|
BOOL WINAPI wglUseFontBitmapsA(HDC hdc,
|
|
|
|
DWORD first,
|
|
|
|
DWORD count,
|
|
|
|
DWORD listBase)
|
|
|
|
{
|
|
|
|
Font fid = get_font( hdc );
|
|
|
|
|
|
|
|
TRACE("(%p, %ld, %ld, %ld) using font %ld\n", hdc, first, count, listBase, fid);
|
|
|
|
|
|
|
|
if (fid == 0) {
|
|
|
|
return internal_wglUseFontBitmaps(hdc, first, count, listBase, GetGlyphOutlineA);
|
|
|
|
}
|
|
|
|
|
|
|
|
ENTER_GL();
|
|
|
|
/* I assume that the glyphs are at the same position for X and for Windows */
|
|
|
|
glXUseXFont(fid, first, count, listBase);
|
|
|
|
LEAVE_GL();
|
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
|
|
|
|
/***********************************************************************
|
|
|
|
* wglUseFontBitmapsW (OPENGL32.@)
|
|
|
|
*/
|
|
|
|
BOOL WINAPI wglUseFontBitmapsW(HDC hdc,
|
|
|
|
DWORD first,
|
|
|
|
DWORD count,
|
|
|
|
DWORD listBase)
|
|
|
|
{
|
|
|
|
Font fid = get_font( hdc );
|
|
|
|
|
|
|
|
TRACE("(%p, %ld, %ld, %ld) using font %ld\n", hdc, first, count, listBase, fid);
|
|
|
|
|
|
|
|
if (fid == 0) {
|
|
|
|
return internal_wglUseFontBitmaps(hdc, first, count, listBase, GetGlyphOutlineW);
|
2002-07-08 21:34:26 +02:00
|
|
|
}
|
2000-05-23 03:20:08 +02:00
|
|
|
|
2004-01-06 01:36:13 +01:00
|
|
|
WARN("Using the glX API for the WCHAR variant - some characters may come out incorrectly !\n");
|
|
|
|
|
2000-05-23 03:20:08 +02:00
|
|
|
ENTER_GL();
|
|
|
|
/* I assume that the glyphs are at the same position for X and for Windows */
|
|
|
|
glXUseXFont(fid, first, count, listBase);
|
|
|
|
LEAVE_GL();
|
|
|
|
return TRUE;
|
2000-05-12 22:18:14 +02:00
|
|
|
}
|
2002-06-01 01:06:46 +02:00
|
|
|
|
2006-03-07 14:55:35 +01:00
|
|
|
#ifdef HAVE_GL_GLU_H
|
|
|
|
|
|
|
|
static void fixed_to_double(POINTFX fixed, UINT em_size, GLdouble vertex[3])
|
|
|
|
{
|
|
|
|
vertex[0] = (fixed.x.value + (GLdouble)fixed.x.fract / (1 << 16)) / em_size;
|
|
|
|
vertex[1] = (fixed.y.value + (GLdouble)fixed.y.fract / (1 << 16)) / em_size;
|
|
|
|
vertex[2] = 0.0;
|
|
|
|
}
|
|
|
|
|
|
|
|
static void tess_callback_vertex(GLvoid *vertex)
|
|
|
|
{
|
|
|
|
GLdouble *dbl = vertex;
|
|
|
|
TRACE("%f, %f, %f\n", dbl[0], dbl[1], dbl[2]);
|
|
|
|
glVertex3dv(vertex);
|
|
|
|
}
|
|
|
|
|
|
|
|
static void tess_callback_begin(GLenum which)
|
|
|
|
{
|
|
|
|
TRACE("%d\n", which);
|
|
|
|
glBegin(which);
|
|
|
|
}
|
|
|
|
|
|
|
|
static void tess_callback_end(void)
|
|
|
|
{
|
|
|
|
TRACE("\n");
|
|
|
|
glEnd();
|
|
|
|
}
|
|
|
|
|
|
|
|
/***********************************************************************
|
|
|
|
* wglUseFontOutlines_common
|
|
|
|
*/
|
|
|
|
BOOL WINAPI wglUseFontOutlines_common(HDC hdc,
|
|
|
|
DWORD first,
|
|
|
|
DWORD count,
|
|
|
|
DWORD listBase,
|
|
|
|
FLOAT deviation,
|
|
|
|
FLOAT extrusion,
|
|
|
|
int format,
|
|
|
|
LPGLYPHMETRICSFLOAT lpgmf,
|
|
|
|
BOOL unicode)
|
|
|
|
{
|
|
|
|
UINT glyph;
|
|
|
|
const MAT2 identity = {{0,1},{0,0},{0,0},{0,1}};
|
|
|
|
GLUtesselator *tess;
|
|
|
|
LOGFONTW lf;
|
|
|
|
HFONT old_font, unscaled_font;
|
|
|
|
UINT em_size = 1024;
|
|
|
|
RECT rc;
|
|
|
|
|
|
|
|
TRACE("(%p, %ld, %ld, %ld, %f, %f, %d, %p, %s)\n", hdc, first, count,
|
|
|
|
listBase, deviation, extrusion, format, lpgmf, unicode ? "W" : "A");
|
|
|
|
|
|
|
|
|
|
|
|
ENTER_GL();
|
|
|
|
tess = gluNewTess();
|
|
|
|
if(tess)
|
|
|
|
{
|
|
|
|
gluTessCallback(tess, GLU_TESS_VERTEX, (_GLUfuncptr)tess_callback_vertex);
|
|
|
|
gluTessCallback(tess, GLU_TESS_BEGIN, (_GLUfuncptr)tess_callback_begin);
|
|
|
|
gluTessCallback(tess, GLU_TESS_END, tess_callback_end);
|
|
|
|
}
|
|
|
|
LEAVE_GL();
|
|
|
|
|
|
|
|
if(!tess) return FALSE;
|
|
|
|
|
|
|
|
GetObjectW(GetCurrentObject(hdc, OBJ_FONT), sizeof(lf), &lf);
|
|
|
|
rc.left = rc.right = rc.bottom = 0;
|
|
|
|
rc.top = em_size;
|
|
|
|
DPtoLP(hdc, (POINT*)&rc, 2);
|
|
|
|
lf.lfHeight = -abs(rc.top - rc.bottom);
|
|
|
|
lf.lfOrientation = lf.lfEscapement = 0;
|
|
|
|
unscaled_font = CreateFontIndirectW(&lf);
|
|
|
|
old_font = SelectObject(hdc, unscaled_font);
|
|
|
|
|
|
|
|
for (glyph = first; glyph < first + count; glyph++)
|
|
|
|
{
|
|
|
|
DWORD needed;
|
|
|
|
GLYPHMETRICS gm;
|
|
|
|
BYTE *buf;
|
|
|
|
TTPOLYGONHEADER *pph;
|
|
|
|
TTPOLYCURVE *ppc;
|
|
|
|
GLdouble *vertices;
|
|
|
|
|
|
|
|
if(unicode)
|
|
|
|
needed = GetGlyphOutlineW(hdc, glyph, GGO_NATIVE, &gm, 0, NULL, &identity);
|
|
|
|
else
|
|
|
|
needed = GetGlyphOutlineA(hdc, glyph, GGO_NATIVE, &gm, 0, NULL, &identity);
|
|
|
|
|
|
|
|
if(needed == GDI_ERROR)
|
|
|
|
goto error;
|
|
|
|
|
|
|
|
buf = HeapAlloc(GetProcessHeap(), 0, needed);
|
|
|
|
vertices = HeapAlloc(GetProcessHeap(), 0, needed / sizeof(POINTFX) * 3 * sizeof(GLdouble));
|
|
|
|
|
|
|
|
if(unicode)
|
|
|
|
GetGlyphOutlineW(hdc, glyph, GGO_NATIVE, &gm, needed, buf, &identity);
|
|
|
|
else
|
|
|
|
GetGlyphOutlineA(hdc, glyph, GGO_NATIVE, &gm, needed, buf, &identity);
|
|
|
|
|
|
|
|
TRACE("glyph %d\n", glyph);
|
|
|
|
|
|
|
|
if(lpgmf)
|
|
|
|
{
|
2006-06-26 13:12:54 +02:00
|
|
|
lpgmf->gmfBlackBoxX = (float)gm.gmBlackBoxX / em_size;
|
|
|
|
lpgmf->gmfBlackBoxY = (float)gm.gmBlackBoxY / em_size;
|
|
|
|
lpgmf->gmfptGlyphOrigin.x = (float)gm.gmptGlyphOrigin.x / em_size;
|
|
|
|
lpgmf->gmfptGlyphOrigin.y = (float)gm.gmptGlyphOrigin.y / em_size;
|
|
|
|
lpgmf->gmfCellIncX = (float)gm.gmCellIncX / em_size;
|
|
|
|
lpgmf->gmfCellIncY = (float)gm.gmCellIncY / em_size;
|
|
|
|
|
2006-03-07 14:55:35 +01:00
|
|
|
TRACE("%fx%f at %f,%f inc %f,%f\n", lpgmf->gmfBlackBoxX, lpgmf->gmfBlackBoxY,
|
|
|
|
lpgmf->gmfptGlyphOrigin.x, lpgmf->gmfptGlyphOrigin.y, lpgmf->gmfCellIncX, lpgmf->gmfCellIncY);
|
|
|
|
lpgmf++;
|
|
|
|
}
|
|
|
|
|
|
|
|
ENTER_GL();
|
|
|
|
glNewList(listBase++, GL_COMPILE);
|
|
|
|
gluTessBeginPolygon(tess, NULL);
|
|
|
|
|
|
|
|
pph = (TTPOLYGONHEADER*)buf;
|
|
|
|
while((BYTE*)pph < buf + needed)
|
|
|
|
{
|
|
|
|
TRACE("\tstart %d, %d\n", pph->pfxStart.x.value, pph->pfxStart.y.value);
|
|
|
|
|
|
|
|
gluTessBeginContour(tess);
|
|
|
|
|
|
|
|
fixed_to_double(pph->pfxStart, em_size, vertices);
|
|
|
|
gluTessVertex(tess, vertices, vertices);
|
|
|
|
vertices += 3;
|
|
|
|
|
|
|
|
ppc = (TTPOLYCURVE*)((char*)pph + sizeof(*pph));
|
|
|
|
while((char*)ppc < (char*)pph + pph->cb)
|
|
|
|
{
|
|
|
|
int i;
|
|
|
|
|
|
|
|
switch(ppc->wType) {
|
|
|
|
case TT_PRIM_LINE:
|
|
|
|
for(i = 0; i < ppc->cpfx; i++)
|
|
|
|
{
|
|
|
|
TRACE("\t\tline to %d, %d\n", ppc->apfx[i].x.value, ppc->apfx[i].y.value);
|
|
|
|
fixed_to_double(ppc->apfx[i], em_size, vertices);
|
|
|
|
gluTessVertex(tess, vertices, vertices);
|
|
|
|
vertices += 3;
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
|
|
|
|
case TT_PRIM_QSPLINE:
|
|
|
|
for(i = 0; i < ppc->cpfx/2; i++)
|
|
|
|
{
|
|
|
|
/* FIXME just connecting the control points for now */
|
|
|
|
TRACE("\t\tcurve %d,%d %d,%d\n",
|
|
|
|
ppc->apfx[i * 2].x.value, ppc->apfx[i * 3].y.value,
|
|
|
|
ppc->apfx[i * 2 + 1].x.value, ppc->apfx[i * 3 + 1].y.value);
|
|
|
|
fixed_to_double(ppc->apfx[i * 2], em_size, vertices);
|
|
|
|
gluTessVertex(tess, vertices, vertices);
|
|
|
|
vertices += 3;
|
|
|
|
fixed_to_double(ppc->apfx[i * 2 + 1], em_size, vertices);
|
|
|
|
gluTessVertex(tess, vertices, vertices);
|
|
|
|
vertices += 3;
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
ERR("\t\tcurve type = %d\n", ppc->wType);
|
|
|
|
gluTessEndContour(tess);
|
|
|
|
goto error_in_list;
|
|
|
|
}
|
|
|
|
|
|
|
|
ppc = (TTPOLYCURVE*)((char*)ppc + sizeof(*ppc) +
|
|
|
|
(ppc->cpfx - 1) * sizeof(POINTFX));
|
|
|
|
}
|
|
|
|
gluTessEndContour(tess);
|
|
|
|
pph = (TTPOLYGONHEADER*)((char*)pph + pph->cb);
|
|
|
|
}
|
|
|
|
|
|
|
|
error_in_list:
|
|
|
|
gluTessEndPolygon(tess);
|
2006-06-26 13:12:54 +02:00
|
|
|
glTranslated((GLdouble)gm.gmCellIncX / em_size, (GLdouble)gm.gmCellIncY / em_size, 0.0);
|
2006-03-07 14:55:35 +01:00
|
|
|
glEndList();
|
|
|
|
LEAVE_GL();
|
|
|
|
HeapFree(GetProcessHeap(), 0, buf);
|
|
|
|
HeapFree(GetProcessHeap(), 0, vertices);
|
|
|
|
}
|
|
|
|
|
|
|
|
error:
|
|
|
|
DeleteObject(SelectObject(hdc, old_font));
|
|
|
|
gluDeleteTess(tess);
|
|
|
|
return TRUE;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
#else /* HAVE_GL_GLU_H */
|
|
|
|
|
|
|
|
BOOL WINAPI wglUseFontOutlines_common(HDC hdc,
|
|
|
|
DWORD first,
|
|
|
|
DWORD count,
|
|
|
|
DWORD listBase,
|
|
|
|
FLOAT deviation,
|
|
|
|
FLOAT extrusion,
|
|
|
|
int format,
|
|
|
|
LPGLYPHMETRICSFLOAT lpgmf,
|
|
|
|
BOOL unicode)
|
|
|
|
{
|
|
|
|
FIXME("Unable to compile in wglUseFontOutlines support without GL/glu.h\n");
|
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
|
|
|
|
#endif /* HAVE_GL_GLU_H */
|
|
|
|
|
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,
|
2006-03-07 14:55:35 +01:00
|
|
|
LPGLYPHMETRICSFLOAT lpgmf)
|
|
|
|
{
|
|
|
|
return wglUseFontOutlines_common(hdc, first, count, listBase, deviation, extrusion, format, lpgmf, FALSE);
|
|
|
|
}
|
2000-05-12 22:18:14 +02:00
|
|
|
|
2006-03-07 14:55:35 +01:00
|
|
|
/***********************************************************************
|
|
|
|
* wglUseFontOutlinesW (OPENGL32.@)
|
|
|
|
*/
|
|
|
|
BOOL WINAPI wglUseFontOutlinesW(HDC hdc,
|
|
|
|
DWORD first,
|
|
|
|
DWORD count,
|
|
|
|
DWORD listBase,
|
|
|
|
FLOAT deviation,
|
|
|
|
FLOAT extrusion,
|
|
|
|
int format,
|
|
|
|
LPGLYPHMETRICSFLOAT lpgmf)
|
|
|
|
{
|
|
|
|
return wglUseFontOutlines_common(hdc, first, count, listBase, deviation, extrusion, format, lpgmf, TRUE);
|
2000-05-12 22:18:14 +02:00
|
|
|
}
|
|
|
|
|
2005-04-28 20:31:15 +02:00
|
|
|
const GLubyte * internal_glGetString(GLenum name) {
|
|
|
|
const char* GL_Extensions = NULL;
|
|
|
|
|
|
|
|
if (GL_EXTENSIONS != name) {
|
|
|
|
return glGetString(name);
|
|
|
|
}
|
|
|
|
|
|
|
|
if (NULL == internal_gl_extensions) {
|
2005-08-10 11:48:58 +02:00
|
|
|
GL_Extensions = (const char *) glGetString(GL_EXTENSIONS);
|
2005-04-28 20:31:15 +02:00
|
|
|
|
|
|
|
TRACE("GL_EXTENSIONS reported:\n");
|
|
|
|
if (NULL == GL_Extensions) {
|
|
|
|
ERR("GL_EXTENSIONS returns NULL\n");
|
|
|
|
return NULL;
|
|
|
|
} else {
|
|
|
|
size_t len = strlen(GL_Extensions);
|
2005-05-10 15:15:12 +02:00
|
|
|
internal_gl_extensions = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, len + 2);
|
2005-04-28 20:31:15 +02:00
|
|
|
|
|
|
|
while (*GL_Extensions != 0x00) {
|
|
|
|
const char* Start = GL_Extensions;
|
|
|
|
char ThisExtn[256];
|
|
|
|
|
|
|
|
memset(ThisExtn, 0x00, sizeof(ThisExtn));
|
|
|
|
while (*GL_Extensions != ' ' && *GL_Extensions != 0x00) {
|
|
|
|
GL_Extensions++;
|
|
|
|
}
|
|
|
|
memcpy(ThisExtn, Start, (GL_Extensions - Start));
|
|
|
|
TRACE("- %s:", ThisExtn);
|
|
|
|
|
|
|
|
/* test if supported API is disabled by config */
|
|
|
|
if (NULL == strstr(internal_gl_disabled_extensions, ThisExtn)) {
|
|
|
|
strcat(internal_gl_extensions, " ");
|
2005-05-10 15:15:12 +02:00
|
|
|
strcat(internal_gl_extensions, ThisExtn);
|
2005-04-28 20:31:15 +02:00
|
|
|
TRACE(" active\n");
|
|
|
|
} else {
|
|
|
|
TRACE(" deactived (by config)\n");
|
|
|
|
}
|
|
|
|
|
|
|
|
if (*GL_Extensions == ' ') GL_Extensions++;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2005-08-10 11:48:58 +02:00
|
|
|
return (const GLubyte *) internal_gl_extensions;
|
2005-04-28 20:31:15 +02:00
|
|
|
}
|
|
|
|
|
2005-11-11 11:52:14 +01:00
|
|
|
void internal_glGetIntegerv(GLenum pname, GLint* params) {
|
2005-12-22 13:54:01 +01:00
|
|
|
glGetIntegerv(pname, params);
|
|
|
|
if (pname == GL_DEPTH_BITS) {
|
|
|
|
GLXContext gl_ctx = glXGetCurrentContext();
|
|
|
|
Wine_GLContext* ret = get_context_from_GLXContext(gl_ctx);
|
|
|
|
/*TRACE("returns Wine Ctx as %p\n", ret);*/
|
|
|
|
/**
|
|
|
|
* if we cannot find a Wine Context
|
|
|
|
* we only have the default wine desktop context,
|
|
|
|
* so if we have only a 24 depth say we have 32
|
|
|
|
*/
|
|
|
|
if (NULL == ret && 24 == *params) {
|
|
|
|
*params = 32;
|
|
|
|
}
|
|
|
|
TRACE("returns GL_DEPTH_BITS as '%d'\n", *params);
|
|
|
|
}
|
2005-11-11 11:52:14 +01:00
|
|
|
if (pname == GL_ALPHA_BITS) {
|
|
|
|
GLint tmp;
|
|
|
|
GLXContext gl_ctx = glXGetCurrentContext();
|
|
|
|
Wine_GLContext* ret = get_context_from_GLXContext(gl_ctx);
|
|
|
|
glXGetFBConfigAttrib(ret->display, ret->fb_conf, GLX_ALPHA_SIZE, &tmp);
|
|
|
|
TRACE("returns GL_ALPHA_BITS as '%d'\n", tmp);
|
|
|
|
*params = tmp;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2005-04-28 20:31:15 +02:00
|
|
|
|
2003-07-11 05:50:19 +02:00
|
|
|
/* No need to load any other libraries as according to the ABI, libGL should be self-sufficient and
|
|
|
|
include all dependencies
|
|
|
|
*/
|
|
|
|
#ifndef SONAME_LIBGL
|
|
|
|
#define SONAME_LIBGL "libGL.so"
|
|
|
|
#endif
|
2000-06-12 23:53:46 +02:00
|
|
|
|
2005-12-22 13:54:01 +01:00
|
|
|
static void wgl_initialize_glx(Display *display, int screen, glXGetProcAddressARB_t proc)
|
|
|
|
{
|
|
|
|
const char *server_glx_version = glXQueryServerString(display, screen, GLX_VERSION);
|
|
|
|
const char *server_glx_extensions = glXQueryServerString(display, screen, GLX_EXTENSIONS);
|
|
|
|
/*
|
|
|
|
const char *client_glx_version = glXGetClientString(display, GLX_VERSION);
|
|
|
|
const char *client_glx_extensions = glXGetClientString(display, GLX_EXTENSIONS);
|
|
|
|
const char *glx_extensions = glXQueryExtensionsString(display, screen);
|
|
|
|
*/
|
|
|
|
|
|
|
|
memset(&wine_glx, 0, sizeof(wine_glx));
|
|
|
|
|
|
|
|
if (!strcmp("1.2", server_glx_version)) {
|
|
|
|
wine_glx.version = 2;
|
|
|
|
} else {
|
|
|
|
wine_glx.version = 3;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (2 < wine_glx.version) {
|
|
|
|
wine_glx.p_glXChooseFBConfig = proc( (const GLubyte *) "glXChooseFBConfig");
|
|
|
|
wine_glx.p_glXGetFBConfigAttrib = proc( (const GLubyte *) "glXGetFBConfigAttrib");
|
|
|
|
wine_glx.p_glXGetVisualFromFBConfig = proc( (const GLubyte *) "glXGetVisualFromFBConfig");
|
|
|
|
|
|
|
|
/*wine_glx.p_glXGetFBConfigs = proc( (const GLubyte *) "glXGetFBConfigs");*/
|
|
|
|
wine_glx.p_glXQueryDrawable = proc( (const GLubyte *) "glXQueryDrawable");
|
|
|
|
} else {
|
|
|
|
if (NULL != strstr(server_glx_extensions, "GLX_SGIX_fbconfig")) {
|
|
|
|
wine_glx.p_glXChooseFBConfig = proc( (const GLubyte *) "glXChooseFBConfigSGIX");
|
|
|
|
wine_glx.p_glXGetFBConfigAttrib = proc( (const GLubyte *) "glXGetFBConfigAttribSGIX");
|
|
|
|
wine_glx.p_glXGetVisualFromFBConfig = proc( (const GLubyte *) "glXGetVisualFromFBConfigSGIX");
|
|
|
|
} else {
|
|
|
|
ERR(" glx_version as %s and GLX_SGIX_fbconfig extension is unsupported. Expect problems.\n", server_glx_version);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
/** try anyway to retrieve that calls, maybe they works using glx client tricks */
|
|
|
|
wine_glx.p_glXGetFBConfigs = proc( (const GLubyte *) "glXGetFBConfigs");
|
|
|
|
wine_glx.p_glXMakeContextCurrent = proc( (const GLubyte *) "glXMakeContextCurrent");
|
|
|
|
}
|
|
|
|
|
2000-05-12 22:18:14 +02:00
|
|
|
/* This is for brain-dead applications that use OpenGL functions before even
|
|
|
|
creating a rendering context.... */
|
2002-03-23 22:43:56 +01:00
|
|
|
static BOOL 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;
|
2002-03-23 22:43:56 +01:00
|
|
|
HDC hdc;
|
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" );
|
2005-05-06 21:38:50 +02:00
|
|
|
HMODULE mod = GetModuleHandleA( "winex11.drv" );
|
2003-07-11 05:50:19 +02:00
|
|
|
void *opengl_handle;
|
2005-04-28 20:31:15 +02:00
|
|
|
DWORD size = sizeof(internal_gl_disabled_extensions);
|
|
|
|
HKEY hkey = 0;
|
2003-12-05 05:43:20 +01:00
|
|
|
|
2002-09-25 02:29:56 +02:00
|
|
|
if (!root || !mod)
|
2001-06-26 23:10:11 +02:00
|
|
|
{
|
|
|
|
ERR("X11DRV not loaded. Cannot create default context.\n");
|
2002-03-23 22:43:56 +01:00
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
|
2002-09-25 02:29:56 +02:00
|
|
|
wine_tsx11_lock_ptr = (void *)GetProcAddress( mod, "wine_tsx11_lock" );
|
|
|
|
wine_tsx11_unlock_ptr = (void *)GetProcAddress( mod, "wine_tsx11_unlock" );
|
|
|
|
|
2002-03-23 22:43:56 +01:00
|
|
|
hdc = GetDC(0);
|
|
|
|
default_display = get_display( hdc );
|
|
|
|
ReleaseDC( 0, hdc );
|
|
|
|
if (!default_display)
|
|
|
|
{
|
|
|
|
ERR("X11DRV not loaded. Cannot get display for screen DC.\n");
|
|
|
|
return FALSE;
|
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
|
2002-06-01 01:06:46 +02:00
|
|
|
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
|
2001-03-28 03:45:08 +02:00
|
|
|
buffered, so apps actually attempting to render this way may flicker */
|
2002-03-23 22:43:56 +01:00
|
|
|
if (XGetWindowAttributes( default_display, root, &win_attr ))
|
2001-03-28 03:45:08 +02:00
|
|
|
{
|
2002-06-01 01:06:46 +02:00
|
|
|
rootVisual = win_attr.visual;
|
2001-03-28 03:45:08 +02:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2002-06-01 01:06:46 +02:00
|
|
|
/* Get the default visual, since we can't seem to get the attributes from the
|
2001-03-28 03:45:08 +02:00
|
|
|
Root Window. Let's hope that the Root Window Visual matches the DefaultVisual */
|
2002-03-23 22:43:56 +01:00
|
|
|
rootVisual = DefaultVisual( default_display, DefaultScreen(default_display) );
|
2001-03-28 03:45:08 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
template.visualid = XVisualIDFromVisual(rootVisual);
|
2002-03-23 22:43:56 +01:00
|
|
|
vis = XGetVisualInfo(default_display, VisualIDMask, &template, &num);
|
|
|
|
if (vis != NULL) default_cx = glXCreateContext(default_display, vis, 0, GL_TRUE);
|
|
|
|
if (default_cx != NULL) glXMakeCurrent(default_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
|
|
|
|
2003-12-02 06:27:00 +01:00
|
|
|
opengl_handle = wine_dlopen(SONAME_LIBGL, RTLD_NOW|RTLD_GLOBAL, NULL, 0);
|
|
|
|
if (opengl_handle != NULL) {
|
|
|
|
p_glXGetProcAddressARB = wine_dlsym(opengl_handle, "glXGetProcAddressARB", NULL, 0);
|
|
|
|
wine_dlclose(opengl_handle, NULL, 0);
|
|
|
|
if (p_glXGetProcAddressARB == NULL)
|
|
|
|
TRACE("could not find glXGetProcAddressARB in libGL.\n");
|
2003-07-11 05:50:19 +02:00
|
|
|
}
|
2004-02-07 02:29:33 +01:00
|
|
|
|
2005-04-28 20:31:15 +02:00
|
|
|
internal_gl_disabled_extensions[0] = 0;
|
|
|
|
if (!RegOpenKeyA( HKEY_LOCAL_MACHINE, "Software\\Wine\\OpenGL", &hkey)) {
|
2005-07-06 21:08:05 +02:00
|
|
|
if (!RegQueryValueExA( hkey, "DisabledExtensions", 0, NULL, (LPBYTE)internal_gl_disabled_extensions, &size)) {
|
2005-04-28 20:31:15 +02:00
|
|
|
TRACE("found DisabledExtensions=\"%s\"\n", internal_gl_disabled_extensions);
|
|
|
|
}
|
|
|
|
RegCloseKey(hkey);
|
|
|
|
}
|
|
|
|
|
2000-06-12 23:53:46 +02:00
|
|
|
if (default_cx == NULL) {
|
|
|
|
ERR("Could not create default context.\n");
|
|
|
|
}
|
2005-06-21 22:03:18 +02:00
|
|
|
else
|
|
|
|
{
|
|
|
|
/* After context initialize also the list of supported WGL extensions. */
|
2005-12-22 13:54:01 +01:00
|
|
|
wgl_initialize_glx(default_display, DefaultScreen(default_display), p_glXGetProcAddressARB);
|
2005-06-21 22:03:18 +02:00
|
|
|
wgl_ext_initialize_extensions(default_display, DefaultScreen(default_display), p_glXGetProcAddressARB, internal_gl_disabled_extensions);
|
|
|
|
}
|
2002-03-23 22:43:56 +01:00
|
|
|
return TRUE;
|
2000-05-12 22:18:14 +02:00
|
|
|
}
|
2000-06-12 23:53:46 +02:00
|
|
|
|
2003-03-06 23:48:54 +01:00
|
|
|
|
2003-08-08 23:07:23 +02:00
|
|
|
/**********************************************************************/
|
|
|
|
|
2002-03-23 22:43:56 +01:00
|
|
|
static void process_detach(void)
|
|
|
|
{
|
|
|
|
glXDestroyContext(default_display, default_cx);
|
2000-06-12 23:53:46 +02:00
|
|
|
|
2004-02-07 02:29:33 +01:00
|
|
|
/* Do not leak memory... */
|
|
|
|
wgl_ext_finalize_extensions();
|
2006-05-10 00:33:53 +02:00
|
|
|
HeapFree(GetProcessHeap(), 0, internal_gl_extensions);
|
2003-05-07 05:18:51 +02:00
|
|
|
}
|
|
|
|
|
2000-06-12 23:53:46 +02:00
|
|
|
/***********************************************************************
|
|
|
|
* OpenGL initialisation routine
|
|
|
|
*/
|
2002-11-05 00:53:41 +01:00
|
|
|
BOOL WINAPI DllMain( HINSTANCE hinst, DWORD reason, LPVOID reserved )
|
2000-06-12 23:53:46 +02:00
|
|
|
{
|
2002-03-23 22:43:56 +01:00
|
|
|
switch(reason)
|
|
|
|
{
|
|
|
|
case DLL_PROCESS_ATTACH:
|
2004-02-12 01:35:01 +01:00
|
|
|
opengl32_handle = hinst;
|
2003-06-30 22:53:48 +02:00
|
|
|
DisableThreadLibraryCalls(hinst);
|
2002-03-23 22:43:56 +01:00
|
|
|
return process_attach();
|
|
|
|
case DLL_PROCESS_DETACH:
|
|
|
|
process_detach();
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
return TRUE;
|
2000-06-12 23:53:46 +02:00
|
|
|
}
|