Add GLXFBConfig on Wine_GLContext (we should remove XVisualInfo

references on code).
Hook glGetIntegerv on GL_ALPHA_BITS to query on GLXFBConfig instead of
glGetInteger (as it returns bad value).
This commit is contained in:
Raphael Junqueira 2005-11-11 10:52:14 +00:00 committed by Alexandre Julliard
parent 0edbaf7e80
commit 7ed830b8e1
6 changed files with 75 additions and 10 deletions

View File

@ -261,6 +261,9 @@ sub GenerateThunk($$$$)
if ( $func_ref->[0] eq "glGetString" ) {
$wine_func_ref_name = "internal_glGetString";
}
if ( $func_ref->[0] eq "glGetIntegerv" ) {
$wine_func_ref_name = "internal_glGetIntegerv";
}
$ret = "$ret$prefix$wine_func_ref_name( $call_arg);\n";
if ($thread_safe) {
$ret = "$ret LEAVE_GL();\n";

View File

@ -73,5 +73,6 @@ extern OpenGL_extension extension_registry[];
extern int extension_registry_size;
const GLubyte* internal_glGetString(GLenum name);
void internal_glGetIntegerv(GLenum pname, GLint* params);
#endif /* __DLLS_OPENGL32_OPENGL_EXT_H */

View File

@ -1329,7 +1329,7 @@ void WINAPI wine_glGetHistogramParameteriv( GLenum target, GLenum pname, GLint*
void WINAPI wine_glGetIntegerv( GLenum pname, GLint* params ) {
TRACE("(%d, %p)\n", pname, params );
ENTER_GL();
glGetIntegerv( pname, params );
internal_glGetIntegerv( pname, params );
LEAVE_GL();
}

View File

@ -64,8 +64,9 @@ static char* internal_gl_extensions = NULL;
typedef struct wine_glcontext {
HDC hdc;
Display *display;
GLXContext ctx;
XVisualInfo *vis;
GLXFBConfig fb_conf;
GLXContext ctx;
struct wine_glcontext *next;
struct wine_glcontext *prev;
} Wine_GLContext;
@ -186,6 +187,28 @@ HGLRC WINAPI wglCreateContext(HDC hdc)
ret->display = display;
ret->vis = vis;
{
int hdcPF = GetPixelFormat(hdc);
int nCfgs_fmt = 0;
GLXFBConfig* cfgs_fmt = NULL;
GLXFBConfig cur_cfg;
int value;
int gl_test = 0;
cfgs_fmt = glXGetFBConfigs(display, DefaultScreen(display), &nCfgs_fmt);
if (NULL == cfgs_fmt || 0 == nCfgs_fmt) {
ERR("Cannot get FB Configs, expect problems.\n");
return NULL;
}
cur_cfg = cfgs_fmt[hdcPF - 1];
gl_test = glXGetFBConfigAttrib(display, cur_cfg, GLX_FBCONFIG_ID, &value);
if (gl_test) {
ERR("Failed to retrieve FBCONFIG_ID from GLXFBConfig, expect problems.\n");
return NULL;
}
ret->fb_conf = cur_cfg;
XFree(cfgs_fmt);
}
TRACE(" creating context %p (GL context creation delayed)\n", ret);
return (HGLRC) ret;
}
@ -442,7 +465,6 @@ BOOL WINAPI wglMakeCurrent(HDC hdc,
} else {
Wine_GLContext *ctx = (Wine_GLContext *) hglrc;
Drawable drawable = get_drawable( hdc );
if (ctx->ctx == NULL) {
ctx->ctx = glXCreateContext(ctx->display, ctx->vis, NULL, True);
TRACE(" created a delayed OpenGL context (%p) for %p\n", ctx->ctx, ctx->vis);
@ -799,6 +821,18 @@ const GLubyte * internal_glGetString(GLenum name) {
return (const GLubyte *) internal_gl_extensions;
}
void internal_glGetIntegerv(GLenum pname, GLint* params) {
glGetIntegerv(pname, params);
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;
}
}
/* No need to load any other libraries as according to the ABI, libGL should be self-sufficient and
include all dependencies

View File

@ -357,23 +357,23 @@ static unsigned ConvertAttribWGLtoGLX(const int* iWGLAttr, int* oGLXAttr, Wine_G
break;
case WGL_RED_BITS_ARB:
pop = iWGLAttr[++cur];
TRACE("pAttr[%d] = GLX_RED_SIZE: %d\n", cur, pop);
PUSH2(oGLXAttr, GLX_RED_SIZE, pop);
TRACE("pAttr[%d] = GLX_RED_SIZE: %d\n", cur, pop);
break;
case WGL_GREEN_BITS_ARB:
pop = iWGLAttr[++cur];
TRACE("pAttr[%d] = GLX_GREEN_SIZE: %d\n", cur, pop);
PUSH2(oGLXAttr, GLX_GREEN_SIZE, pop);
TRACE("pAttr[%d] = GLX_GREEN_SIZE: %d\n", cur, pop);
break;
case WGL_ALPHA_BITS_ARB:
pop = iWGLAttr[++cur];
TRACE("pAttr[%d] = GLX_ALPHA_SIZE: %d\n", cur, pop);
PUSH2(oGLXAttr, GLX_ALPHA_SIZE, pop);
TRACE("pAttr[%d] = GLX_ALPHA_SIZE: %d\n", cur, pop);
break;
case WGL_DEPTH_BITS_ARB:
pop = iWGLAttr[++cur];
TRACE("pAttr[%d] = GLX_DEPTH_SIZE: %d\n", cur, pop);
PUSH2(oGLXAttr, GLX_DEPTH_SIZE, pop);
TRACE("pAttr[%d] = GLX_DEPTH_SIZE: %d\n", cur, pop);
break;
case WGL_STENCIL_BITS_ARB:
pop = iWGLAttr[++cur];
@ -689,8 +689,11 @@ GLboolean WINAPI wglChoosePixelFormatARB(HDC hdc, const int *piAttribIList, cons
continue ;
}
if (fmt_id == tmp_fmt_id) {
int tmp;
piFormats[pfmt_it] = it_fmt + 1;
++pfmt_it;
glXGetFBConfigAttrib(display, cfgs_fmt[it_fmt], GLX_ALPHA_SIZE, &tmp);
TRACE("for FBCONFIG_ID(%d/%d) found '%d'\n", it_fmt + 1, nCfgs_fmt, tmp);
break ;
}
}

View File

@ -212,7 +212,6 @@ int X11DRV_ChoosePixelFormat(X11DRV_PDEVICE *physDev,
}
if (ppfd->iPixelType == PFD_TYPE_RGBA) {
ADD2(GLX_RENDER_TYPE, GLX_RGBA_BIT);
ADD2(GLX_BUFFER_SIZE, ppfd->cColorBits);
if (32 == ppfd->cDepthBits) {
/**
* for 32 bpp depth buffers force to use 24.
@ -222,7 +221,15 @@ int X11DRV_ChoosePixelFormat(X11DRV_PDEVICE *physDev,
} else {
TEST_AND_ADD2(ppfd->cDepthBits, GLX_DEPTH_SIZE, ppfd->cDepthBits);
}
TEST_AND_ADD2(ppfd->cAlphaBits, GLX_ALPHA_SIZE, ppfd->cAlphaBits);
if (32 == ppfd->cColorBits) {
ADD2(GLX_RED_SIZE, 8);
ADD2(GLX_GREEN_SIZE, 8);
ADD2(GLX_BLUE_SIZE, 8);
ADD2(GLX_ALPHA_SIZE, 8);
} else {
ADD2(GLX_BUFFER_SIZE, ppfd->cColorBits);
TEST_AND_ADD2(ppfd->cAlphaBits, GLX_ALPHA_SIZE, ppfd->cAlphaBits);
}
}
TEST_AND_ADD2(ppfd->cStencilBits, GLX_STENCIL_SIZE, ppfd->cStencilBits);
TEST_AND_ADD2(ppfd->cAuxBuffers, GLX_AUX_BUFFERS, ppfd->cAuxBuffers);
@ -444,7 +451,24 @@ BOOL X11DRV_SetPixelFormat(X11DRV_PDEVICE *physDev,
TRACE("(%p,%d,%p)\n", physDev, iPixelFormat, ppfd);
physDev->current_pf = iPixelFormat;
if (TRACE_ON(opengl)) {
int nCfgs_fmt = 0;
GLXFBConfig* cfgs_fmt = NULL;
GLXFBConfig cur_cfg;
int value;
int gl_test = 0;
cfgs_fmt = pglXGetFBConfigs(gdi_display, DefaultScreen(gdi_display), &nCfgs_fmt);
cur_cfg = cfgs_fmt[iPixelFormat - 1];
gl_test = pglXGetFBConfigAttrib(gdi_display, cur_cfg, GLX_FBCONFIG_ID, &value);
if (gl_test) {
ERR("Failed to retrieve FBCONFIG_ID from GLXFBConfig, expect problems.\n");
} else {
FIXME("have FBCONFIG_ID %x\n", value);
}
XFree(cfgs_fmt);
}
return TRUE;
}