gdi32: Support OpenGL in bitmaps through libOSMesa.

This commit is contained in:
Alexandre Julliard 2012-07-26 20:47:31 +02:00
parent cbf9589ba3
commit 35eef16ba7
8 changed files with 464 additions and 6 deletions

72
configure vendored
View File

@ -822,6 +822,7 @@ with_openal
with_opencl with_opencl
with_opengl with_opengl
with_openssl with_openssl
with_osmesa
with_oss with_oss
with_png with_png
with_pthread with_pthread
@ -1510,6 +1511,7 @@ Optional Packages:
--without-opencl do not use OpenCL --without-opencl do not use OpenCL
--without-opengl do not use OpenGL --without-opengl do not use OpenGL
--without-openssl do not use OpenSSL --without-openssl do not use OpenSSL
--without-osmesa do not use the OSMesa library
--without-oss do not use the OSS sound support --without-oss do not use the OSS sound support
--without-png do not use PNG --without-png do not use PNG
--without-pthread do not use the pthread library --without-pthread do not use the pthread library
@ -2679,6 +2681,12 @@ if test "${with_openssl+set}" = set; then :
fi fi
# Check whether --with-osmesa was given.
if test "${with_osmesa+set}" = set; then :
withval=$with_osmesa; if test "x$withval" = "xno"; then ac_cv_header_GL_osmesa_h=no; fi
fi
# Check whether --with-oss was given. # Check whether --with-oss was given.
if test "${with_oss+set}" = set; then : if test "${with_oss+set}" = set; then :
withval=$with_oss; withval=$with_oss;
@ -8806,7 +8814,7 @@ fi
opengl_msg="" opengl_msg=""
if test "x$with_opengl" != "xno" if test "x$with_opengl" != "xno"
then then
for ac_header in GL/gl.h GL/glx.h GL/glu.h for ac_header in GL/gl.h GL/glx.h GL/glu.h GL/osmesa.h
do : do :
as_ac_Header=`$as_echo "ac_cv_header_$ac_header" | $as_tr_sh` as_ac_Header=`$as_echo "ac_cv_header_$ac_header" | $as_tr_sh`
ac_fn_c_check_header_compile "$LINENO" "$ac_header" "$as_ac_Header" "#ifdef HAVE_GL_GLX_H ac_fn_c_check_header_compile "$LINENO" "$ac_header" "$as_ac_Header" "#ifdef HAVE_GL_GLX_H
@ -9023,6 +9031,68 @@ fi
*) as_fn_error $? "libGLU ${notice_platform}development files not found, GLU won't be supported. *) as_fn_error $? "libGLU ${notice_platform}development files not found, GLU won't be supported.
This is an error since --with-glu was requested." "$LINENO" 5 ;; This is an error since --with-glu was requested." "$LINENO" 5 ;;
esac esac
fi
if test "$ac_cv_header_GL_osmesa_h" = "yes"
then
{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for -lOSMesa" >&5
$as_echo_n "checking for -lOSMesa... " >&6; }
if ${ac_cv_lib_soname_OSMesa+:} false; then :
$as_echo_n "(cached) " >&6
else
ac_check_soname_save_LIBS=$LIBS
LIBS="-lOSMesa $X_LIBS $X_PRE_LIBS $XLIB -lm $X_EXTRA_LIBS $LIBS"
cat confdefs.h - <<_ACEOF >conftest.$ac_ext
/* end confdefs.h. */
/* Override any GCC internal prototype to avoid an error.
Use char because int might match the return type of a GCC
builtin and then its argument prototype would still apply. */
#ifdef __cplusplus
extern "C"
#endif
char glAccum ();
int
main ()
{
return glAccum ();
;
return 0;
}
_ACEOF
if ac_fn_c_try_link "$LINENO"; then :
case "$LIBEXT" in
dll) ac_cv_lib_soname_OSMesa=`$ac_cv_path_LDD conftest.exe | grep "OSMesa" | sed -e "s/dll.*/dll/"';2,$d'` ;;
dylib) ac_cv_lib_soname_OSMesa=`otool -L conftest$ac_exeext | grep "libOSMesa\\.[0-9A-Za-z.]*dylib" | sed -e "s/^.*\/\(libOSMesa\.[0-9A-Za-z.]*dylib\).*$/\1/"';2,$d'` ;;
*) ac_cv_lib_soname_OSMesa=`$ac_cv_path_LDD conftest$ac_exeext | grep "libOSMesa\\.$LIBEXT" | sed -e "s/^.*\(libOSMesa\.$LIBEXT[^ ]*\).*$/\1/"';2,$d'` ;;
esac
fi
rm -f core conftest.err conftest.$ac_objext \
conftest$ac_exeext conftest.$ac_ext
LIBS=$ac_check_soname_save_LIBS
fi
if test "x$ac_cv_lib_soname_OSMesa" = "x"; then :
{ $as_echo "$as_me:${as_lineno-$LINENO}: result: not found" >&5
$as_echo "not found" >&6; }
else
{ $as_echo "$as_me:${as_lineno-$LINENO}: result: $ac_cv_lib_soname_OSMesa" >&5
$as_echo "$ac_cv_lib_soname_OSMesa" >&6; }
cat >>confdefs.h <<_ACEOF
#define SONAME_LIBOSMESA "$ac_cv_lib_soname_OSMesa"
_ACEOF
fi
fi
if test "x$ac_cv_lib_soname_OSMesa" = "x"; then :
case "x$with_osmesa" in
x) as_fn_append wine_notices "|libOSMesa ${notice_platform}development files not found (or too old), OpenGL rendering in bitmaps won't be supported." ;;
xno) ;;
*) as_fn_error $? "libOSMesa ${notice_platform}development files not found (or too old), OpenGL rendering in bitmaps won't be supported.
This is an error since --with-osmesa was requested." "$LINENO" 5 ;;
esac
fi fi
else else
opengl_msg="Old Mesa headers detected. Consider upgrading your Mesa libraries." opengl_msg="Old Mesa headers detected. Consider upgrading your Mesa libraries."

View File

@ -69,6 +69,8 @@ AC_ARG_WITH(opencl, AS_HELP_STRING([--without-opencl],[do not use OpenCL]),
AC_ARG_WITH(opengl, AS_HELP_STRING([--without-opengl],[do not use OpenGL])) AC_ARG_WITH(opengl, AS_HELP_STRING([--without-opengl],[do not use OpenGL]))
AC_ARG_WITH(openssl, AS_HELP_STRING([--without-openssl],[do not use OpenSSL]), AC_ARG_WITH(openssl, AS_HELP_STRING([--without-openssl],[do not use OpenSSL]),
[if test "x$withval" = "xno"; then ac_cv_header_openssl_err_h=no; ac_cv_header_openssl_ssl_h=no; fi]) [if test "x$withval" = "xno"; then ac_cv_header_openssl_err_h=no; ac_cv_header_openssl_ssl_h=no; fi])
AC_ARG_WITH(osmesa, AS_HELP_STRING([--without-osmesa],[do not use the OSMesa library]),
[if test "x$withval" = "xno"; then ac_cv_header_GL_osmesa_h=no; fi])
AC_ARG_WITH(oss, AS_HELP_STRING([--without-oss],[do not use the OSS sound support])) AC_ARG_WITH(oss, AS_HELP_STRING([--without-oss],[do not use the OSS sound support]))
AC_ARG_WITH(png, AS_HELP_STRING([--without-png],[do not use PNG]), AC_ARG_WITH(png, AS_HELP_STRING([--without-png],[do not use PNG]),
[if test "x$withval" = "xno"; then ac_cv_header_png_h=no; fi]) [if test "x$withval" = "xno"; then ac_cv_header_png_h=no; fi])
@ -1091,7 +1093,7 @@ then
opengl_msg="" opengl_msg=""
if test "x$with_opengl" != "xno" if test "x$with_opengl" != "xno"
then then
AC_CHECK_HEADERS(GL/gl.h GL/glx.h GL/glu.h,,, AC_CHECK_HEADERS(GL/gl.h GL/glx.h GL/glu.h GL/osmesa.h,,,
[#ifdef HAVE_GL_GLX_H [#ifdef HAVE_GL_GLX_H
# include <GL/glx.h> # include <GL/glx.h>
#endif]) #endif])
@ -1127,6 +1129,13 @@ This probably prevents linking to OpenGL. Try deleting the file and restarting c
fi fi
WINE_NOTICE_WITH(glu,[test "x$ac_cv_lib_soname_GLU" = "x"], WINE_NOTICE_WITH(glu,[test "x$ac_cv_lib_soname_GLU" = "x"],
[libGLU ${notice_platform}development files not found, GLU won't be supported.]) [libGLU ${notice_platform}development files not found, GLU won't be supported.])
if test "$ac_cv_header_GL_osmesa_h" = "yes"
then
WINE_CHECK_SONAME(OSMesa,glAccum,,,[$X_LIBS $X_PRE_LIBS $XLIB -lm $X_EXTRA_LIBS])
fi
WINE_NOTICE_WITH(osmesa,[test "x$ac_cv_lib_soname_OSMesa" = "x"],
[libOSMesa ${notice_platform}development files not found (or too old), OpenGL rendering in bitmaps won't be supported.])
else else
opengl_msg="Old Mesa headers detected. Consider upgrading your Mesa libraries." opengl_msg="Old Mesa headers detected. Consider upgrading your Mesa libraries."
fi fi

View File

@ -2,7 +2,7 @@ EXTRADEFS = -D_GDI32_
MODULE = gdi32.dll MODULE = gdi32.dll
IMPORTLIB = gdi32 IMPORTLIB = gdi32
IMPORTS = advapi32 IMPORTS = advapi32
EXTRAINCL = @FREETYPEINCL@ @FONTCONFIGINCL@ EXTRAINCL = @FREETYPEINCL@ @FONTCONFIGINCL@ @X_CFLAGS@
EXTRALIBS = @CARBONLIB@ EXTRALIBS = @CARBONLIB@
DELAYIMPORTS = usp10 DELAYIMPORTS = usp10
@ -18,6 +18,7 @@ C_SRCS = \
dibdrv/dc.c \ dibdrv/dc.c \
dibdrv/graphics.c \ dibdrv/graphics.c \
dibdrv/objects.c \ dibdrv/objects.c \
dibdrv/opengl.c \
dibdrv/primitives.c \ dibdrv/primitives.c \
driver.c \ driver.c \
enhmetafile.c \ enhmetafile.c \

View File

@ -409,7 +409,7 @@ const struct gdi_dc_funcs dib_driver =
dibdrv_CreateDC, /* pCreateDC */ dibdrv_CreateDC, /* pCreateDC */
dibdrv_DeleteDC, /* pDeleteDC */ dibdrv_DeleteDC, /* pDeleteDC */
NULL, /* pDeleteObject */ NULL, /* pDeleteObject */
NULL, /* pDescribePixelFormat */ dibdrv_DescribePixelFormat, /* pDescribePixelFormat */
NULL, /* pDeviceCapabilities */ NULL, /* pDeviceCapabilities */
dibdrv_Ellipse, /* pEllipse */ dibdrv_Ellipse, /* pEllipse */
NULL, /* pEndDoc */ NULL, /* pEndDoc */
@ -501,7 +501,7 @@ const struct gdi_dc_funcs dib_driver =
NULL, /* pSetMapMode */ NULL, /* pSetMapMode */
NULL, /* pSetMapperFlags */ NULL, /* pSetMapperFlags */
dibdrv_SetPixel, /* pSetPixel */ dibdrv_SetPixel, /* pSetPixel */
NULL, /* pSetPixelFormat */ dibdrv_SetPixelFormat, /* pSetPixelFormat */
NULL, /* pSetPolyFillMode */ NULL, /* pSetPolyFillMode */
NULL, /* pSetROP2 */ NULL, /* pSetROP2 */
NULL, /* pSetRelAbs */ NULL, /* pSetRelAbs */
@ -524,6 +524,6 @@ const struct gdi_dc_funcs dib_driver =
NULL, /* pSwapBuffers */ NULL, /* pSwapBuffers */
NULL, /* pUnrealizePalette */ NULL, /* pUnrealizePalette */
NULL, /* pWidenPath */ NULL, /* pWidenPath */
NULL, /* wine_get_wgl_driver */ dibdrv_wine_get_wgl_driver, /* wine_get_wgl_driver */
GDI_PRIORITY_DIB_DRV /* priority */ GDI_PRIORITY_DIB_DRV /* priority */
}; };

View File

@ -114,6 +114,7 @@ extern DWORD dibdrv_BlendImage( PHYSDEV dev, BITMAPINFO *info, const struct g
struct bitblt_coords *src, struct bitblt_coords *dst, BLENDFUNCTION func ) DECLSPEC_HIDDEN; struct bitblt_coords *src, struct bitblt_coords *dst, BLENDFUNCTION func ) DECLSPEC_HIDDEN;
extern BOOL dibdrv_Chord( PHYSDEV dev, INT left, INT top, INT right, INT bottom, extern BOOL dibdrv_Chord( PHYSDEV dev, INT left, INT top, INT right, INT bottom,
INT start_x, INT start_y, INT end_x, INT end_y ) DECLSPEC_HIDDEN; INT start_x, INT start_y, INT end_x, INT end_y ) DECLSPEC_HIDDEN;
extern int dibdrv_DescribePixelFormat( PHYSDEV dev, int fmt, UINT size, PIXELFORMATDESCRIPTOR *descr ) DECLSPEC_HIDDEN;
extern BOOL dibdrv_Ellipse( PHYSDEV dev, INT left, INT top, INT right, INT bottom ) DECLSPEC_HIDDEN; extern BOOL dibdrv_Ellipse( PHYSDEV dev, INT left, INT top, INT right, INT bottom ) DECLSPEC_HIDDEN;
extern BOOL dibdrv_ExtFloodFill( PHYSDEV dev, INT x, INT y, COLORREF color, UINT type ) DECLSPEC_HIDDEN; extern BOOL dibdrv_ExtFloodFill( PHYSDEV dev, INT x, INT y, COLORREF color, UINT type ) DECLSPEC_HIDDEN;
extern BOOL dibdrv_ExtTextOut( PHYSDEV dev, INT x, INT y, UINT flags, extern BOOL dibdrv_ExtTextOut( PHYSDEV dev, INT x, INT y, UINT flags,
@ -145,8 +146,10 @@ extern HPEN dibdrv_SelectPen( PHYSDEV dev, HPEN hpen, const struct brush_pat
extern COLORREF dibdrv_SetDCBrushColor( PHYSDEV dev, COLORREF color ) DECLSPEC_HIDDEN; extern COLORREF dibdrv_SetDCBrushColor( PHYSDEV dev, COLORREF color ) DECLSPEC_HIDDEN;
extern COLORREF dibdrv_SetDCPenColor( PHYSDEV dev, COLORREF color ) DECLSPEC_HIDDEN; extern COLORREF dibdrv_SetDCPenColor( PHYSDEV dev, COLORREF color ) DECLSPEC_HIDDEN;
extern COLORREF dibdrv_SetPixel( PHYSDEV dev, INT x, INT y, COLORREF color ) DECLSPEC_HIDDEN; extern COLORREF dibdrv_SetPixel( PHYSDEV dev, INT x, INT y, COLORREF color ) DECLSPEC_HIDDEN;
extern BOOL dibdrv_SetPixelFormat( PHYSDEV dev, int fmt, const PIXELFORMATDESCRIPTOR *descr ) DECLSPEC_HIDDEN;
extern BOOL dibdrv_StretchBlt( PHYSDEV dst_dev, struct bitblt_coords *dst, extern BOOL dibdrv_StretchBlt( PHYSDEV dst_dev, struct bitblt_coords *dst,
PHYSDEV src_dev, struct bitblt_coords *src, DWORD rop ) DECLSPEC_HIDDEN; PHYSDEV src_dev, struct bitblt_coords *src, DWORD rop ) DECLSPEC_HIDDEN;
extern struct opengl_funcs *dibdrv_wine_get_wgl_driver( PHYSDEV dev, UINT version ) DECLSPEC_HIDDEN;
static inline dibdrv_physdev *get_dibdrv_pdev( PHYSDEV dev ) static inline dibdrv_physdev *get_dibdrv_pdev( PHYSDEV dev )
{ {

368
dlls/gdi32/dibdrv/opengl.c Normal file
View File

@ -0,0 +1,368 @@
/*
* DIB driver OpenGL support
*
* Copyright 2012 Alexandre Julliard
*
* 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
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
*/
#include "config.h"
#include "wine/port.h"
#ifdef HAVE_GL_OSMESA_H
#include <GL/osmesa.h>
#undef APIENTRY
#undef GLAPI
#undef WINGDIAPI
#endif
#include "gdi_private.h"
#include "dibdrv.h"
#include "wine/library.h"
#include "wine/debug.h"
WINE_DEFAULT_DEBUG_CHANNEL(dib);
#ifdef SONAME_LIBOSMESA
#include "wine/wgl_driver.h"
struct wgl_context
{
OSMesaContext context;
int format;
};
static struct opengl_funcs opengl_funcs;
#define USE_GL_FUNC(name) #name,
static const char *opengl_func_names[] = { ALL_WGL_FUNCS };
#undef USE_GL_FUNC
#define MAKE_FUNCPTR(f) static typeof(f) * p##f;
MAKE_FUNCPTR(OSMesaCreateContextExt)
MAKE_FUNCPTR(OSMesaDestroyContext)
MAKE_FUNCPTR(OSMesaGetProcAddress)
MAKE_FUNCPTR(OSMesaMakeCurrent)
MAKE_FUNCPTR(OSMesaPixelStore)
#undef MAKE_FUNCPTR
static const struct
{
UINT mesa;
BYTE color_bits;
BYTE red_bits, red_shift;
BYTE green_bits, green_shift;
BYTE blue_bits, blue_shift;
BYTE alpha_bits, alpha_shift;
BYTE accum_bits;
BYTE depth_bits;
BYTE stencil_bits;
} pixel_formats[] =
{
{ OSMESA_BGRA, 32, 8, 16, 8, 8, 8, 0, 8, 24, 16, 32, 8 },
{ OSMESA_BGRA, 32, 8, 16, 8, 8, 8, 0, 8, 24, 16, 16, 8 },
{ OSMESA_RGBA, 32, 8, 0, 8, 8, 8, 16, 8, 24, 16, 32, 8 },
{ OSMESA_RGBA, 32, 8, 0, 8, 8, 8, 16, 8, 24, 16, 16, 8 },
{ OSMESA_ARGB, 32, 8, 8, 8, 16, 8, 24, 8, 0, 16, 32, 8 },
{ OSMESA_ARGB, 32, 8, 8, 8, 16, 8, 24, 8, 0, 16, 16, 8 },
{ OSMESA_RGB, 24, 8, 0, 8, 8, 8, 16, 0, 0, 16, 32, 8 },
{ OSMESA_RGB, 24, 8, 0, 8, 8, 8, 16, 0, 0, 16, 16, 8 },
{ OSMESA_BGR, 24, 8, 16, 8, 8, 8, 0, 0, 0, 16, 32, 8 },
{ OSMESA_BGR, 24, 8, 16, 8, 8, 8, 0, 0, 0, 16, 16, 8 },
{ OSMESA_RGB_565, 16, 5, 0, 6, 5, 5, 11, 0, 0, 16, 32, 8 },
{ OSMESA_RGB_565, 16, 5, 0, 6, 5, 5, 11, 0, 0, 16, 16, 8 },
};
static const int nb_formats = sizeof(pixel_formats) / sizeof(pixel_formats[0]);
static BOOL init_opengl(void)
{
static int init_done;
static void *osmesa_handle;
char buffer[200];
unsigned int i;
if (init_done) return (osmesa_handle != NULL);
init_done = 1;
osmesa_handle = wine_dlopen( SONAME_LIBOSMESA, RTLD_NOW, buffer, sizeof(buffer) );
if (osmesa_handle == NULL)
{
ERR( "Failed to load OSMesa: %s\n", buffer );
return FALSE;
}
for (i = 0; i < sizeof(opengl_func_names)/sizeof(opengl_func_names[0]); i++)
{
if (!(((void **)&opengl_funcs.gl)[i] = wine_dlsym( osmesa_handle, opengl_func_names[i], NULL, 0 )))
{
ERR( "%s not found in %s, disabling.\n", opengl_func_names[i], SONAME_LIBOSMESA );
goto failed;
}
}
#define LOAD_FUNCPTR(f) do if (!(p##f = (void *)wine_dlsym( osmesa_handle, #f, NULL, 0 ))) \
{ \
ERR( "%s not found in %s, disabling.\n", #f, SONAME_LIBOSMESA ); \
goto failed; \
} while(0)
LOAD_FUNCPTR(OSMesaCreateContextExt);
LOAD_FUNCPTR(OSMesaDestroyContext);
LOAD_FUNCPTR(OSMesaGetProcAddress);
LOAD_FUNCPTR(OSMesaMakeCurrent);
LOAD_FUNCPTR(OSMesaPixelStore);
#undef LOAD_FUNCPTR
return TRUE;
failed:
wine_dlclose( osmesa_handle, NULL, 0 );
osmesa_handle = NULL;
return FALSE;
}
/**********************************************************************
* dibdrv_DescribePixelFormat
*/
int dibdrv_DescribePixelFormat( PHYSDEV dev, int fmt, UINT size, PIXELFORMATDESCRIPTOR *descr )
{
int ret = sizeof(pixel_formats) / sizeof(pixel_formats[0]);
if (fmt <= 0 || fmt > ret) return ret;
if (size < sizeof(*descr)) return 0;
memset( descr, 0, sizeof(*descr) );
descr->nSize = sizeof(*descr);
descr->nVersion = 1;
descr->dwFlags = PFD_SUPPORT_GDI | PFD_SUPPORT_OPENGL | PFD_DRAW_TO_BITMAP | PFD_GENERIC_FORMAT;
descr->iPixelType = PFD_TYPE_RGBA;
descr->cColorBits = pixel_formats[fmt - 1].color_bits;
descr->cRedBits = pixel_formats[fmt - 1].red_bits;
descr->cRedShift = pixel_formats[fmt - 1].red_shift;
descr->cGreenBits = pixel_formats[fmt - 1].green_bits;
descr->cGreenShift = pixel_formats[fmt - 1].green_shift;
descr->cBlueBits = pixel_formats[fmt - 1].blue_bits;
descr->cBlueShift = pixel_formats[fmt - 1].blue_shift;
descr->cAlphaBits = pixel_formats[fmt - 1].alpha_bits;
descr->cAlphaShift = pixel_formats[fmt - 1].alpha_shift;
descr->cAccumBits = pixel_formats[fmt - 1].accum_bits;
descr->cAccumRedBits = pixel_formats[fmt - 1].accum_bits / 4;
descr->cAccumGreenBits = pixel_formats[fmt - 1].accum_bits / 4;
descr->cAccumBlueBits = pixel_formats[fmt - 1].accum_bits / 4;
descr->cAccumAlphaBits = pixel_formats[fmt - 1].accum_bits / 4;
descr->cDepthBits = pixel_formats[fmt - 1].depth_bits;
descr->cStencilBits = pixel_formats[fmt - 1].stencil_bits;
descr->cAuxBuffers = 0;
descr->iLayerType = PFD_MAIN_PLANE;
return ret;
}
/**********************************************************************
* dibdrv_SetPixelFormat
*/
BOOL dibdrv_SetPixelFormat( PHYSDEV dev, int fmt, const PIXELFORMATDESCRIPTOR *descr )
{
DC *dc;
BOOL ret = TRUE;
if (fmt <= 0 || fmt > nb_formats) return FALSE;
dc = get_dc_ptr( dev->hdc );
if (!dc->pixel_format) dc->pixel_format = fmt;
else ret = (dc->pixel_format == fmt);
release_dc_ptr( dc );
return ret;
}
/***********************************************************************
* dibdrv_wglCopyContext
*/
static BOOL dibdrv_wglCopyContext( struct wgl_context *src, struct wgl_context *dst, UINT mask )
{
FIXME( "not supported yet\n" );
return FALSE;
}
/***********************************************************************
* dibdrv_wglCreateContext
*/
static struct wgl_context *dibdrv_wglCreateContext( HDC hdc )
{
struct wgl_context *context;
if (!(context = HeapAlloc( GetProcessHeap(), 0, sizeof( *context )))) return NULL;
context->format = GetPixelFormat( hdc );
if (!context->format || context->format > nb_formats) context->format = 1;
if (!(context->context = pOSMesaCreateContextExt( pixel_formats[context->format - 1].mesa,
pixel_formats[context->format - 1].depth_bits,
pixel_formats[context->format - 1].stencil_bits,
pixel_formats[context->format - 1].accum_bits, 0 )))
{
HeapFree( GetProcessHeap(), 0, context );
return NULL;
}
return context;
}
/***********************************************************************
* dibdrv_wglDeleteContext
*/
static void dibdrv_wglDeleteContext( struct wgl_context *context )
{
pOSMesaDestroyContext( context->context );
HeapFree( GetProcessHeap(), 0, context );
}
/***********************************************************************
* dibdrv_wglGetPixelFormat
*/
static int dibdrv_wglGetPixelFormat( HDC hdc )
{
DC *dc = get_dc_ptr( hdc );
int ret = 0;
if (dc)
{
ret = dc->pixel_format;
release_dc_ptr( dc );
}
return ret;
}
/***********************************************************************
* dibdrv_wglGetProcAddress
*/
static PROC dibdrv_wglGetProcAddress( const char *proc )
{
if (!strncmp( proc, "wgl", 3 )) return NULL;
return (PROC)pOSMesaGetProcAddress( proc );
}
/***********************************************************************
* dibdrv_wglMakeCurrent
*/
static BOOL dibdrv_wglMakeCurrent( HDC hdc, struct wgl_context *context )
{
HBITMAP bitmap;
BITMAPOBJ *bmp;
dib_info dib;
BOOL ret = FALSE;
if (!context)
{
pOSMesaMakeCurrent( NULL, NULL, GL_UNSIGNED_BYTE, 0, 0 );
return TRUE;
}
if (GetPixelFormat( hdc ) != context->format)
FIXME( "mismatched pixel formats %u/%u not supported yet\n",
GetPixelFormat( hdc ), context->format );
bitmap = GetCurrentObject( hdc, OBJ_BITMAP );
bmp = GDI_GetObjPtr( bitmap, OBJ_BITMAP );
if (!bmp) return FALSE;
if (init_dib_info_from_bitmapobj( &dib, bmp ))
{
char *bits;
int width = dib.rect.right - dib.rect.left;
int height = dib.rect.bottom - dib.rect.top;
if (dib.stride < 0)
bits = (char *)dib.bits.ptr + (dib.rect.bottom - 1) * dib.stride;
else
bits = (char *)dib.bits.ptr + dib.rect.top * dib.stride;
bits += dib.rect.left * dib.bit_count / 8;
TRACE( "context %p bits %p size %ux%u\n", context, bits, width, height );
ret = pOSMesaMakeCurrent( context->context, bits, GL_UNSIGNED_BYTE, width, height );
if (ret)
{
pOSMesaPixelStore( OSMESA_ROW_LENGTH, abs( dib.stride ) * 8 / dib.bit_count );
pOSMesaPixelStore( OSMESA_Y_UP, 1 ); /* Windows seems to assume bottom-up */
}
}
GDI_ReleaseObj( bitmap );
return ret;
}
/***********************************************************************
* dibdrv_wglShareLists
*/
static BOOL dibdrv_wglShareLists( struct wgl_context *org, struct wgl_context *dest )
{
FIXME( "not supported yet\n" );
return FALSE;
}
static struct opengl_funcs opengl_funcs =
{
{
dibdrv_wglCopyContext, /* p_wglCopyContext */
dibdrv_wglCreateContext, /* p_wglCreateContext */
dibdrv_wglDeleteContext, /* p_wglDeleteContext */
dibdrv_wglGetPixelFormat, /* p_wglGetPixelFormat */
dibdrv_wglGetProcAddress, /* p_wglGetProcAddress */
dibdrv_wglMakeCurrent, /* p_wglMakeCurrent */
dibdrv_wglShareLists, /* p_wglShareLists */
}
};
/**********************************************************************
* dibdrv_wine_get_wgl_driver
*/
struct opengl_funcs *dibdrv_wine_get_wgl_driver( PHYSDEV dev, UINT version )
{
if (version != WINE_WGL_DRIVER_VERSION)
{
ERR( "version mismatch, opengl32 wants %u but dibdrv has %u\n", version, WINE_WGL_DRIVER_VERSION );
return NULL;
}
if (!init_opengl()) return (void *)-1;
return &opengl_funcs;
}
#else /* SONAME_LIBOSMESA */
/**********************************************************************
* dibdrv_DescribePixelFormat
*/
int dibdrv_DescribePixelFormat( PHYSDEV dev, int fmt, UINT size, PIXELFORMATDESCRIPTOR *descr )
{
return 0;
}
/**********************************************************************
* dibdrv_SetPixelFormat
*/
BOOL dibdrv_SetPixelFormat( PHYSDEV dev, int fmt, const PIXELFORMATDESCRIPTOR *descr )
{
return FALSE;
}
/**********************************************************************
* dibdrv_wine_get_wgl_driver
*/
struct opengl_funcs *dibdrv_wine_get_wgl_driver( PHYSDEV dev, UINT version )
{
ERR( "OSMesa not compiled in, no OpenGL bitmap support\n" );
return (void *)-1;
}
#endif /* SONAME_LIBOSMESA */

View File

@ -104,6 +104,7 @@ typedef struct tagDC
SIZE virtual_size; /* Initially HORZSIZE,VERTSIZE. Changed by SetVirtualResolution */ SIZE virtual_size; /* Initially HORZSIZE,VERTSIZE. Changed by SetVirtualResolution */
RECT vis_rect; /* visible rectangle in screen coords */ RECT vis_rect; /* visible rectangle in screen coords */
RECT device_rect; /* rectangle for the whole device */ RECT device_rect; /* rectangle for the whole device */
int pixel_format; /* pixel format (for memory DCs) */
FLOAT miterLimit; FLOAT miterLimit;
int flags; int flags;

View File

@ -239,6 +239,9 @@
/* Define to 1 if you have the <GL/gl.h> header file. */ /* Define to 1 if you have the <GL/gl.h> header file. */
#undef HAVE_GL_GL_H #undef HAVE_GL_GL_H
/* Define to 1 if you have the <GL/osmesa.h> header file. */
#undef HAVE_GL_OSMESA_H
/* Define if we have libgphoto2 development environment */ /* Define if we have libgphoto2 development environment */
#undef HAVE_GPHOTO2 #undef HAVE_GPHOTO2
@ -1256,6 +1259,9 @@
/* Define to the soname of the libopenal library. */ /* Define to the soname of the libopenal library. */
#undef SONAME_LIBOPENAL #undef SONAME_LIBOPENAL
/* Define to the soname of the libOSMesa library. */
#undef SONAME_LIBOSMESA
/* Define to the soname of the libpng library. */ /* Define to the soname of the libpng library. */
#undef SONAME_LIBPNG #undef SONAME_LIBPNG