Commit 6a3aa4eb authored by Alexandre Julliard's avatar Alexandre Julliard

opengl32: Use proper handles for PBuffers instead of raw pointers.

parent 98bd066c
......@@ -205,8 +205,8 @@ sub ConvertType($)
"HGLRC" => "struct wgl_context *",
"GLDEBUGPROCARB" => "void *",
"GLDEBUGPROCAMD" => "void *",
"HPBUFFERARB" => "HANDLE",
"HPBUFFEREXT" => "HANDLE",
"HPBUFFERARB" => "struct wgl_pbuffer *",
"HPBUFFEREXT" => "struct wgl_pbuffer *",
);
foreach my $org (reverse sort keys %hash) {
......@@ -777,7 +777,8 @@ print HEADER "#endif\n\n";
printf HEADER "#define WINE_WGL_DRIVER_VERSION %u\n\n", $wgl_version + 1;
print HEADER "struct wgl_context;\n\n";
print HEADER "struct wgl_context;\n";
print HEADER "struct wgl_pbuffer;\n\n";
print HEADER "struct opengl_funcs\n{\n";
print HEADER " struct\n {\n";
......
......@@ -208,7 +208,7 @@ static void test_pbuffers(HDC hdc)
trace("iPixelFormat returned by GetPixelFormat: %d\n", res);
trace("PixelFormat from wglChoosePixelFormatARB: %d\n", iPixelFormat);
pwglReleasePbufferDCARB(pbuffer, hdc);
pwglReleasePbufferDCARB(pbuffer, pbuffer_hdc);
}
else skip("Pbuffer test for onscreen pixelformat skipped as no onscreen format with pbuffer capabilities have been found\n");
......
......@@ -81,6 +81,7 @@ extern BOOL WINAPI GdiSwapBuffers( HDC hdc );
enum wgl_handle_type
{
HANDLE_CONTEXT = 0 << 12,
HANDLE_PBUFFER = 1 << 12,
HANDLE_TYPE_MASK = 15 << 12
};
......@@ -92,6 +93,7 @@ struct wgl_handle
union
{
struct wgl_context *context; /* for HANDLE_CONTEXT */
struct wgl_pbuffer *pbuffer; /* for HANDLE_PBUFFER */
struct wgl_handle *next; /* for free handles */
} u;
};
......@@ -849,11 +851,13 @@ void WINAPI wglFreeMemoryNV( void *pointer )
*/
BOOL WINAPI wglBindTexImageARB( HPBUFFERARB handle, int buffer )
{
/* FIXME: get functions from pbuffer handle */
const struct opengl_funcs *funcs = NtCurrentTeb()->glTable;
struct wgl_handle *ptr = get_handle_ptr( handle, HANDLE_PBUFFER );
BOOL ret;
if (!funcs->ext.p_wglBindTexImageARB) return FALSE;
return funcs->ext.p_wglBindTexImageARB( handle, buffer );
if (!ptr) return FALSE;
ret = ptr->funcs->ext.p_wglBindTexImageARB( ptr->u.pbuffer, buffer );
release_handle_ptr( ptr );
return ret;
}
/***********************************************************************
......@@ -863,11 +867,13 @@ BOOL WINAPI wglBindTexImageARB( HPBUFFERARB handle, int buffer )
*/
BOOL WINAPI wglReleaseTexImageARB( HPBUFFERARB handle, int buffer )
{
/* FIXME: get functions from pbuffer handle */
const struct opengl_funcs *funcs = NtCurrentTeb()->glTable;
struct wgl_handle *ptr = get_handle_ptr( handle, HANDLE_PBUFFER );
BOOL ret;
if (!funcs->ext.p_wglReleaseTexImageARB) return FALSE;
return funcs->ext.p_wglReleaseTexImageARB( handle, buffer );
if (!ptr) return FALSE;
ret = ptr->funcs->ext.p_wglReleaseTexImageARB( ptr->u.pbuffer, buffer );
release_handle_ptr( ptr );
return ret;
}
/***********************************************************************
......@@ -877,11 +883,13 @@ BOOL WINAPI wglReleaseTexImageARB( HPBUFFERARB handle, int buffer )
*/
BOOL WINAPI wglSetPbufferAttribARB( HPBUFFERARB handle, const int *attribs )
{
/* FIXME: get functions from pbuffer handle */
const struct opengl_funcs *funcs = NtCurrentTeb()->glTable;
struct wgl_handle *ptr = get_handle_ptr( handle, HANDLE_PBUFFER );
BOOL ret;
if (!funcs->ext.p_wglSetPbufferAttribARB) return FALSE;
return funcs->ext.p_wglSetPbufferAttribARB( handle, attribs );
if (!ptr) return FALSE;
ret = ptr->funcs->ext.p_wglSetPbufferAttribARB( ptr->u.pbuffer, attribs );
release_handle_ptr( ptr );
return ret;
}
/***********************************************************************
......@@ -933,10 +941,15 @@ BOOL WINAPI wglGetPixelFormatAttribfvARB( HDC hdc, int format, int layer, UINT c
*/
HPBUFFERARB WINAPI wglCreatePbufferARB( HDC hdc, int format, int width, int height, const int *attribs )
{
const struct opengl_funcs *funcs = get_dc_funcs( hdc );
HPBUFFERARB ret = 0;
struct wgl_pbuffer *pbuffer;
struct opengl_funcs *funcs = get_dc_funcs( hdc );
if (!funcs || !funcs->ext.p_wglCreatePbufferARB) return 0;
return funcs->ext.p_wglCreatePbufferARB( hdc, format, width, height, attribs );
if (!(pbuffer = funcs->ext.p_wglCreatePbufferARB( hdc, format, width, height, attribs ))) return 0;
ret = alloc_handle( HANDLE_PBUFFER, funcs, pbuffer );
if (!ret) funcs->ext.p_wglDestroyPbufferARB( pbuffer );
return ret;
}
/***********************************************************************
......@@ -946,11 +959,13 @@ HPBUFFERARB WINAPI wglCreatePbufferARB( HDC hdc, int format, int width, int heig
*/
HDC WINAPI wglGetPbufferDCARB( HPBUFFERARB handle )
{
/* FIXME: get functions from pbuffer handle */
const struct opengl_funcs *funcs = NtCurrentTeb()->glTable;
struct wgl_handle *ptr = get_handle_ptr( handle, HANDLE_PBUFFER );
HDC ret;
if (!funcs->ext.p_wglGetPbufferDCARB) return 0;
return funcs->ext.p_wglGetPbufferDCARB( handle );
if (!ptr) return 0;
ret = ptr->funcs->ext.p_wglGetPbufferDCARB( ptr->u.pbuffer );
release_handle_ptr( ptr );
return ret;
}
/***********************************************************************
......@@ -960,11 +975,13 @@ HDC WINAPI wglGetPbufferDCARB( HPBUFFERARB handle )
*/
int WINAPI wglReleasePbufferDCARB( HPBUFFERARB handle, HDC hdc )
{
/* FIXME: get functions from pbuffer handle */
const struct opengl_funcs *funcs = get_dc_funcs( hdc );
struct wgl_handle *ptr = get_handle_ptr( handle, HANDLE_PBUFFER );
BOOL ret;
if (!funcs || !funcs->ext.p_wglReleasePbufferDCARB) return 0;
return funcs->ext.p_wglReleasePbufferDCARB( handle, hdc );
if (!ptr) return FALSE;
ret = ptr->funcs->ext.p_wglReleasePbufferDCARB( ptr->u.pbuffer, hdc );
release_handle_ptr( ptr );
return ret;
}
/***********************************************************************
......@@ -974,11 +991,12 @@ int WINAPI wglReleasePbufferDCARB( HPBUFFERARB handle, HDC hdc )
*/
BOOL WINAPI wglDestroyPbufferARB( HPBUFFERARB handle )
{
/* FIXME: get functions from pbuffer handle */
const struct opengl_funcs *funcs = NtCurrentTeb()->glTable;
struct wgl_handle *ptr = get_handle_ptr( handle, HANDLE_PBUFFER );
if (!funcs->ext.p_wglDestroyPbufferARB) return FALSE;
return funcs->ext.p_wglDestroyPbufferARB( handle );
if (!ptr) return FALSE;
ptr->funcs->ext.p_wglDestroyPbufferARB( ptr->u.pbuffer );
free_handle_ptr( ptr );
return TRUE;
}
/***********************************************************************
......@@ -988,11 +1006,13 @@ BOOL WINAPI wglDestroyPbufferARB( HPBUFFERARB handle )
*/
BOOL WINAPI wglQueryPbufferARB( HPBUFFERARB handle, int attrib, int *value )
{
/* FIXME: get functions from pbuffer handle */
const struct opengl_funcs *funcs = NtCurrentTeb()->glTable;
struct wgl_handle *ptr = get_handle_ptr( handle, HANDLE_PBUFFER );
BOOL ret;
if (!funcs->ext.p_wglQueryPbufferARB) return FALSE;
return funcs->ext.p_wglQueryPbufferARB( handle, attrib, value );
if (!ptr) return FALSE;
ret = ptr->funcs->ext.p_wglQueryPbufferARB( ptr->u.pbuffer, attrib, value );
release_handle_ptr( ptr );
return ret;
}
/***********************************************************************
......
......@@ -160,7 +160,8 @@ struct wgl_context
struct list entry;
};
typedef struct wine_glpbuffer {
struct wgl_pbuffer
{
Drawable drawable;
Display* display;
WineGLPixelFormat* fmt;
......@@ -177,7 +178,7 @@ typedef struct wine_glpbuffer {
GLenum texture_type;
GLuint texture;
int texture_level;
} Wine_GLPBuffer;
};
struct glx_physdev
{
......@@ -647,7 +648,7 @@ static int describeContext( struct wgl_context *ctx ) {
return ctx_vis_id;
}
static int ConvertAttribWGLtoGLX(const int* iWGLAttr, int* oGLXAttr, Wine_GLPBuffer* pbuf) {
static int ConvertAttribWGLtoGLX(const int* iWGLAttr, int* oGLXAttr, struct wgl_pbuffer* pbuf) {
int nAttribs = 0;
unsigned cur = 0;
int pop;
......@@ -1956,10 +1957,10 @@ static const GLubyte *X11DRV_wglGetExtensionsStringARB(HDC hdc)
*
* WGL_ARB_pbuffer: wglCreatePbufferARB
*/
static HANDLE X11DRV_wglCreatePbufferARB( HDC hdc, int iPixelFormat, int iWidth, int iHeight,
static struct wgl_pbuffer *X11DRV_wglCreatePbufferARB( HDC hdc, int iPixelFormat, int iWidth, int iHeight,
const int *piAttribList )
{
Wine_GLPBuffer* object = NULL;
struct wgl_pbuffer* object = NULL;
WineGLPixelFormat *fmt = NULL;
int nCfgs = 0;
int attribs[256];
......@@ -1978,13 +1979,13 @@ static HANDLE X11DRV_wglCreatePbufferARB( HDC hdc, int iPixelFormat, int iWidth,
if(!fmt) {
ERR("(%p): unexpected iPixelFormat(%d) > nFormats(%d), returns NULL\n", hdc, iPixelFormat, nCfgs);
SetLastError(ERROR_INVALID_PIXEL_FORMAT);
goto create_failed; /* unexpected error */
return NULL;
}
object = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(Wine_GLPBuffer));
object = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(*object));
if (NULL == object) {
SetLastError(ERROR_NO_SYSTEM_RESOURCES);
goto create_failed; /* unexpected error */
return NULL;
}
object->hdc = hdc;
object->display = gdi_display;
......@@ -2137,7 +2138,7 @@ static HANDLE X11DRV_wglCreatePbufferARB( HDC hdc, int iPixelFormat, int iWidth,
goto create_failed; /* unexpected error */
}
TRACE("->(%p)\n", object);
return (HPBUFFERARB)object;
return object;
create_failed:
HeapFree(GetProcessHeap(), 0, object);
......@@ -2150,14 +2151,10 @@ create_failed:
*
* WGL_ARB_pbuffer: wglDestroyPbufferARB
*/
static BOOL X11DRV_wglDestroyPbufferARB(HANDLE hPbuffer)
static BOOL X11DRV_wglDestroyPbufferARB( struct wgl_pbuffer *object )
{
Wine_GLPBuffer* object = (Wine_GLPBuffer *)hPbuffer;
TRACE("(%p)\n", hPbuffer);
if (NULL == object) {
SetLastError(ERROR_INVALID_HANDLE);
return GL_FALSE;
}
TRACE("(%p)\n", object);
wine_tsx11_lock();
pglXDestroyPbuffer(object->display, object->drawable);
wine_tsx11_unlock();
......@@ -2170,17 +2167,11 @@ static BOOL X11DRV_wglDestroyPbufferARB(HANDLE hPbuffer)
*
* WGL_ARB_pbuffer: wglGetPbufferDCARB
*/
static HDC X11DRV_wglGetPbufferDCARB(HANDLE hPbuffer)
static HDC X11DRV_wglGetPbufferDCARB( struct wgl_pbuffer *object )
{
struct x11drv_escape_set_drawable escape;
Wine_GLPBuffer* object = (Wine_GLPBuffer *)hPbuffer;
HDC hdc;
if (NULL == object) {
SetLastError(ERROR_INVALID_HANDLE);
return NULL;
}
hdc = CreateDCA( "DISPLAY", NULL, NULL, NULL );
if (!hdc) return 0;
......@@ -2194,7 +2185,7 @@ static HDC X11DRV_wglGetPbufferDCARB(HANDLE hPbuffer)
escape.gl_type = DC_GL_PBUFFER;
ExtEscape( hdc, X11DRV_ESCAPE, sizeof(escape), (LPSTR)&escape, 0, NULL );
TRACE( "(%p)->(%p)\n", hPbuffer, hdc );
TRACE( "(%p)->(%p)\n", object, hdc );
return hdc;
}
......@@ -2203,14 +2194,10 @@ static HDC X11DRV_wglGetPbufferDCARB(HANDLE hPbuffer)
*
* WGL_ARB_pbuffer: wglQueryPbufferARB
*/
static BOOL X11DRV_wglQueryPbufferARB(HANDLE hPbuffer, int iAttribute, int *piValue)
static BOOL X11DRV_wglQueryPbufferARB( struct wgl_pbuffer *object, int iAttribute, int *piValue )
{
Wine_GLPBuffer* object = (Wine_GLPBuffer *)hPbuffer;
TRACE("(%p, 0x%x, %p)\n", hPbuffer, iAttribute, piValue);
if (NULL == object) {
SetLastError(ERROR_INVALID_HANDLE);
return GL_FALSE;
}
TRACE("(%p, 0x%x, %p)\n", object, iAttribute, piValue);
switch (iAttribute) {
case WGL_PBUFFER_WIDTH_ARB:
wine_tsx11_lock();
......@@ -2300,9 +2287,9 @@ static BOOL X11DRV_wglQueryPbufferARB(HANDLE hPbuffer, int iAttribute, int *piVa
*
* WGL_ARB_pbuffer: wglReleasePbufferDCARB
*/
static int X11DRV_wglReleasePbufferDCARB(HANDLE hPbuffer, HDC hdc)
static int X11DRV_wglReleasePbufferDCARB( struct wgl_pbuffer *object, HDC hdc )
{
TRACE("(%p, %p)\n", hPbuffer, hdc);
TRACE("(%p, %p)\n", object, hdc);
return DeleteDC(hdc);
}
......@@ -2311,16 +2298,12 @@ static int X11DRV_wglReleasePbufferDCARB(HANDLE hPbuffer, HDC hdc)
*
* WGL_ARB_pbuffer: wglSetPbufferAttribARB
*/
static BOOL X11DRV_wglSetPbufferAttribARB( HANDLE hPbuffer, const int *piAttribList )
static BOOL X11DRV_wglSetPbufferAttribARB( struct wgl_pbuffer *object, const int *piAttribList )
{
Wine_GLPBuffer* object = (Wine_GLPBuffer *)hPbuffer;
GLboolean ret = GL_FALSE;
WARN("(%p, %p): alpha-testing, report any problem\n", hPbuffer, piAttribList);
if (NULL == object) {
SetLastError(ERROR_INVALID_HANDLE);
return GL_FALSE;
}
WARN("(%p, %p): alpha-testing, report any problem\n", object, piAttribList);
if (!object->use_render_texture) {
SetLastError(ERROR_INVALID_HANDLE);
return GL_FALSE;
......@@ -2729,16 +2712,12 @@ static BOOL X11DRV_wglGetPixelFormatAttribfvARB( HDC hdc, int iPixelFormat, int
*
* WGL_ARB_render_texture: wglBindTexImageARB
*/
static BOOL X11DRV_wglBindTexImageARB(HANDLE hPbuffer, int iBuffer)
static BOOL X11DRV_wglBindTexImageARB( struct wgl_pbuffer *object, int iBuffer )
{
Wine_GLPBuffer* object = (Wine_GLPBuffer *)hPbuffer;
GLboolean ret = GL_FALSE;
TRACE("(%p, %d)\n", hPbuffer, iBuffer);
if (NULL == object) {
SetLastError(ERROR_INVALID_HANDLE);
return GL_FALSE;
}
TRACE("(%p, %d)\n", object, iBuffer);
if (!object->use_render_texture) {
SetLastError(ERROR_INVALID_HANDLE);
return GL_FALSE;
......@@ -2792,16 +2771,12 @@ static BOOL X11DRV_wglBindTexImageARB(HANDLE hPbuffer, int iBuffer)
*
* WGL_ARB_render_texture: wglReleaseTexImageARB
*/
static BOOL X11DRV_wglReleaseTexImageARB(HANDLE hPbuffer, int iBuffer)
static BOOL X11DRV_wglReleaseTexImageARB( struct wgl_pbuffer *object, int iBuffer )
{
Wine_GLPBuffer* object = (Wine_GLPBuffer *)hPbuffer;
GLboolean ret = GL_FALSE;
TRACE("(%p, %d)\n", hPbuffer, iBuffer);
if (NULL == object) {
SetLastError(ERROR_INVALID_HANDLE);
return GL_FALSE;
}
TRACE("(%p, %d)\n", object, iBuffer);
if (!object->use_render_texture) {
SetLastError(ERROR_INVALID_HANDLE);
return GL_FALSE;
......
......@@ -7,9 +7,10 @@
#define WINE_GLAPI
#endif
#define WINE_WGL_DRIVER_VERSION 3
#define WINE_WGL_DRIVER_VERSION 4
struct wgl_context;
struct wgl_pbuffer;
struct opengl_funcs
{
......@@ -2432,24 +2433,24 @@ struct opengl_funcs
void (WINE_GLAPI *p_glWindowPos4svMESA)(const GLshort*);
void (WINE_GLAPI *p_glWriteMaskEXT)(GLuint,GLuint,GLenum,GLenum,GLenum,GLenum);
GLvoid* (WINE_GLAPI *p_wglAllocateMemoryNV)(GLsizei,GLfloat,GLfloat,GLfloat);
BOOL (WINE_GLAPI *p_wglBindTexImageARB)(HANDLE,int);
BOOL (WINE_GLAPI *p_wglBindTexImageARB)(struct wgl_pbuffer *,int);
BOOL (WINE_GLAPI *p_wglChoosePixelFormatARB)(HDC,const int*,const FLOAT*,UINT,int*,UINT*);
struct wgl_context * (WINE_GLAPI *p_wglCreateContextAttribsARB)(HDC,struct wgl_context *,const int*);
HANDLE (WINE_GLAPI *p_wglCreatePbufferARB)(HDC,int,int,int,const int*);
BOOL (WINE_GLAPI *p_wglDestroyPbufferARB)(HANDLE);
struct wgl_pbuffer * (WINE_GLAPI *p_wglCreatePbufferARB)(HDC,int,int,int,const int*);
BOOL (WINE_GLAPI *p_wglDestroyPbufferARB)(struct wgl_pbuffer *);
void (WINE_GLAPI *p_wglFreeMemoryNV)(void*);
HDC (WINE_GLAPI *p_wglGetCurrentReadDCARB)(void);
const GLubyte * (WINE_GLAPI *p_wglGetExtensionsStringARB)(HDC);
const GLubyte * (WINE_GLAPI *p_wglGetExtensionsStringEXT)(void);
HDC (WINE_GLAPI *p_wglGetPbufferDCARB)(HANDLE);
HDC (WINE_GLAPI *p_wglGetPbufferDCARB)(struct wgl_pbuffer *);
BOOL (WINE_GLAPI *p_wglGetPixelFormatAttribfvARB)(HDC,int,int,UINT,const int*,FLOAT*);
BOOL (WINE_GLAPI *p_wglGetPixelFormatAttribivARB)(HDC,int,int,UINT,const int*,int*);
int (WINE_GLAPI *p_wglGetSwapIntervalEXT)(void);
BOOL (WINE_GLAPI *p_wglMakeContextCurrentARB)(HDC,HDC,struct wgl_context *);
BOOL (WINE_GLAPI *p_wglQueryPbufferARB)(HANDLE,int,int*);
int (WINE_GLAPI *p_wglReleasePbufferDCARB)(HANDLE,HDC);
BOOL (WINE_GLAPI *p_wglReleaseTexImageARB)(HANDLE,int);
BOOL (WINE_GLAPI *p_wglSetPbufferAttribARB)(HANDLE,const int*);
BOOL (WINE_GLAPI *p_wglQueryPbufferARB)(struct wgl_pbuffer *,int,int*);
int (WINE_GLAPI *p_wglReleasePbufferDCARB)(struct wgl_pbuffer *,HDC);
BOOL (WINE_GLAPI *p_wglReleaseTexImageARB)(struct wgl_pbuffer *,int);
BOOL (WINE_GLAPI *p_wglSetPbufferAttribARB)(struct wgl_pbuffer *,const int*);
BOOL (WINE_GLAPI *p_wglSetPixelFormatWINE)(HDC,int);
BOOL (WINE_GLAPI *p_wglSwapIntervalEXT)(int);
} ext;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment