wgl: Replace the GLXFBConfigIDs in the pixelformat list with real GLXFBConfigs.
This commit is contained in:
parent
cfd81827ac
commit
4a96be5a72
|
@ -128,10 +128,10 @@ struct WineGLInfo {
|
||||||
};
|
};
|
||||||
|
|
||||||
typedef struct wine_glpixelformat {
|
typedef struct wine_glpixelformat {
|
||||||
int iPixelFormat;
|
int iPixelFormat;
|
||||||
int fbconfig;
|
GLXFBConfig fbconfig;
|
||||||
int fmt_index;
|
int fmt_id;
|
||||||
BOOL offscreenOnly;
|
BOOL offscreenOnly;
|
||||||
} WineGLPixelFormat;
|
} WineGLPixelFormat;
|
||||||
|
|
||||||
static Wine_GLContext *context_list;
|
static Wine_GLContext *context_list;
|
||||||
|
@ -817,7 +817,7 @@ static int ConvertAttribWGLtoGLX(const int* iWGLAttr, int* oGLXAttr, Wine_GLPBuf
|
||||||
return nAttribs;
|
return nAttribs;
|
||||||
}
|
}
|
||||||
|
|
||||||
static BOOL get_fbconfig_from_visualid(Display *display, Visual *visual, int *fmt_id, int *fmt_index)
|
static BOOL get_fbconfig_from_visualid(Display *display, Visual *visual, GLXFBConfig *fbconfig, int *fmt_id)
|
||||||
{
|
{
|
||||||
GLXFBConfig* cfgs = NULL;
|
GLXFBConfig* cfgs = NULL;
|
||||||
int i;
|
int i;
|
||||||
|
@ -848,9 +848,9 @@ static BOOL get_fbconfig_from_visualid(Display *display, Visual *visual, int *fm
|
||||||
/* We are looking up the GLX index of our main visual and have found it :) */
|
/* We are looking up the GLX index of our main visual and have found it :) */
|
||||||
if(visualid == tmp_vis_id) {
|
if(visualid == tmp_vis_id) {
|
||||||
TRACE("Found FBCONFIG_ID 0x%x at index %d for VISUAL_ID 0x%x\n", tmp_fmt_id, i, tmp_vis_id);
|
TRACE("Found FBCONFIG_ID 0x%x at index %d for VISUAL_ID 0x%x\n", tmp_fmt_id, i, tmp_vis_id);
|
||||||
XFree(cfgs);
|
*fbconfig = cfgs[i];
|
||||||
*fmt_id = tmp_fmt_id;
|
*fmt_id = tmp_fmt_id;
|
||||||
*fmt_index = i;
|
XFree(cfgs);
|
||||||
return TRUE;
|
return TRUE;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -862,13 +862,13 @@ static BOOL get_fbconfig_from_visualid(Display *display, Visual *visual, int *fm
|
||||||
|
|
||||||
static BOOL init_formats(Display *display, int screen, Visual *visual)
|
static BOOL init_formats(Display *display, int screen, Visual *visual)
|
||||||
{
|
{
|
||||||
int fmt_id, fmt_index;
|
int fmt_id, tmp_vis_id, tmp_fmt_id, nCfgs, i;
|
||||||
int tmp_vis_id, tmp_fmt_id, nCfgs, i;
|
GLXFBConfig* cfgs;
|
||||||
GLXFBConfig* cfgs = NULL;
|
GLXFBConfig fbconfig;
|
||||||
int nOffscreenFormats = 0;
|
int nOffscreenFormats = 0;
|
||||||
|
|
||||||
/* Locate the fbconfig correspondig to our main visual */
|
/* Locate the fbconfig correspondig to our main visual */
|
||||||
if(!get_fbconfig_from_visualid(display, visual, &fmt_id, &fmt_index)) {
|
if(!get_fbconfig_from_visualid(display, visual, &fbconfig, &fmt_id)) {
|
||||||
ERR("Can't get the FBCONFIG_ID for the main visual, expect problems!\n");
|
ERR("Can't get the FBCONFIG_ID for the main visual, expect problems!\n");
|
||||||
return FALSE;
|
return FALSE;
|
||||||
}
|
}
|
||||||
|
@ -885,8 +885,8 @@ static BOOL init_formats(Display *display, int screen, Visual *visual)
|
||||||
/* We only have the single format of Wine's main visual */
|
/* We only have the single format of Wine's main visual */
|
||||||
WineGLPixelFormatList = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(WineGLPixelFormat));
|
WineGLPixelFormatList = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, sizeof(WineGLPixelFormat));
|
||||||
WineGLPixelFormatList[0].iPixelFormat = 1;
|
WineGLPixelFormatList[0].iPixelFormat = 1;
|
||||||
WineGLPixelFormatList[0].fbconfig = fmt_id;
|
WineGLPixelFormatList[0].fbconfig = fbconfig;
|
||||||
WineGLPixelFormatList[0].fmt_index = fmt_index;
|
WineGLPixelFormatList[0].fmt_id = fmt_id;
|
||||||
WineGLPixelFormatList[0].offscreenOnly = FALSE;
|
WineGLPixelFormatList[0].offscreenOnly = FALSE;
|
||||||
WineGLPixelFormatListSize = 1;
|
WineGLPixelFormatListSize = 1;
|
||||||
}
|
}
|
||||||
|
@ -905,8 +905,8 @@ static BOOL init_formats(Display *display, int screen, Visual *visual)
|
||||||
/* Allocate memory for all the offscreen pixelformats and the format of Wine's main visual */
|
/* Allocate memory for all the offscreen pixelformats and the format of Wine's main visual */
|
||||||
WineGLPixelFormatList = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, (1+nOffscreenFormats)*sizeof(WineGLPixelFormat));
|
WineGLPixelFormatList = HeapAlloc(GetProcessHeap(), HEAP_ZERO_MEMORY, (1+nOffscreenFormats)*sizeof(WineGLPixelFormat));
|
||||||
WineGLPixelFormatList[0].iPixelFormat = 1;
|
WineGLPixelFormatList[0].iPixelFormat = 1;
|
||||||
WineGLPixelFormatList[0].fbconfig = fmt_id;
|
WineGLPixelFormatList[0].fbconfig = fbconfig;
|
||||||
WineGLPixelFormatList[0].fmt_index = fmt_index;
|
WineGLPixelFormatList[0].fmt_id = fmt_id;
|
||||||
WineGLPixelFormatList[0].offscreenOnly = FALSE;
|
WineGLPixelFormatList[0].offscreenOnly = FALSE;
|
||||||
WineGLPixelFormatListSize = 1;
|
WineGLPixelFormatListSize = 1;
|
||||||
|
|
||||||
|
@ -919,9 +919,9 @@ static BOOL init_formats(Display *display, int screen, Visual *visual)
|
||||||
if(tmp_vis_id == 0) {
|
if(tmp_vis_id == 0) {
|
||||||
TRACE("Found offscreen format FBCONFIG_ID 0x%x corresponding to iPixelFormat %d at GLX index %d\n", tmp_fmt_id, WineGLPixelFormatListSize, i);
|
TRACE("Found offscreen format FBCONFIG_ID 0x%x corresponding to iPixelFormat %d at GLX index %d\n", tmp_fmt_id, WineGLPixelFormatListSize, i);
|
||||||
WineGLPixelFormatList[WineGLPixelFormatListSize].iPixelFormat = WineGLPixelFormatListSize;
|
WineGLPixelFormatList[WineGLPixelFormatListSize].iPixelFormat = WineGLPixelFormatListSize;
|
||||||
WineGLPixelFormatList[WineGLPixelFormatListSize].fbconfig = tmp_fmt_id;
|
WineGLPixelFormatList[WineGLPixelFormatListSize].fbconfig = cfgs[i];
|
||||||
WineGLPixelFormatList[WineGLPixelFormatListSize].fmt_index = i;
|
WineGLPixelFormatList[WineGLPixelFormatListSize].fmt_id = tmp_fmt_id;
|
||||||
WineGLPixelFormatList[0].offscreenOnly = TRUE;
|
WineGLPixelFormatList[WineGLPixelFormatListSize].offscreenOnly = TRUE;
|
||||||
WineGLPixelFormatListSize++;
|
WineGLPixelFormatListSize++;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -935,45 +935,44 @@ static BOOL init_formats(Display *display, int screen, Visual *visual)
|
||||||
/* GLX can advertise dozens of different pixelformats including offscreen and onscreen ones.
|
/* GLX can advertise dozens of different pixelformats including offscreen and onscreen ones.
|
||||||
* In our WGL implementation we only support a subset of these formats namely the format of
|
* In our WGL implementation we only support a subset of these formats namely the format of
|
||||||
* Wine's main visual and offscreen formats (if they are available).
|
* Wine's main visual and offscreen formats (if they are available).
|
||||||
* This function converts a WGL format to its corresponding GLX one. It returns the index (zero-based)
|
* This function converts a WGL format to its corresponding GLX one. It returns a WineGLPixelFormat
|
||||||
* into the GLX FB config table and it returns the number of supported WGL formats in fmt_count.
|
* and it returns the number of supported WGL formats in fmt_count.
|
||||||
*/
|
*/
|
||||||
static BOOL ConvertPixelFormatWGLtoGLX(Display *display, int iPixelFormat, BOOL AllowOffscreen, int *fmt_index, int *fmt_count)
|
static WineGLPixelFormat* ConvertPixelFormatWGLtoGLX(Display *display, int iPixelFormat, BOOL AllowOffscreen, int *fmt_count)
|
||||||
{
|
{
|
||||||
int ret = FALSE;
|
WineGLPixelFormat *res = NULL;
|
||||||
|
|
||||||
/* Init the list of pixel formats when we need it */
|
/* Init the list of pixel formats when we need it */
|
||||||
if(!WineGLPixelFormatListSize)
|
if(!WineGLPixelFormatListSize)
|
||||||
init_formats(display, DefaultScreen(display), visual);
|
init_formats(display, DefaultScreen(display), visual);
|
||||||
|
|
||||||
|
/* Check if the pixelformat is valid. Note that it is legal to pass an invalid
|
||||||
|
* iPixelFormat in case of probing the number of pixelformats.
|
||||||
|
*/
|
||||||
if((iPixelFormat <= 0) || (iPixelFormat > WineGLPixelFormatListSize)) {
|
if((iPixelFormat <= 0) || (iPixelFormat > WineGLPixelFormatListSize)) {
|
||||||
ERR("invalid iPixelFormat %d\n", iPixelFormat);
|
ERR("invalid iPixelFormat %d\n", iPixelFormat);
|
||||||
ret = FALSE;
|
|
||||||
*fmt_index = -1;
|
|
||||||
|
|
||||||
if(AllowOffscreen)
|
if(AllowOffscreen)
|
||||||
*fmt_count = WineGLPixelFormatListSize;
|
*fmt_count = WineGLPixelFormatListSize;
|
||||||
else
|
else
|
||||||
*fmt_count = 1; /* Only show the format of our main visual */
|
*fmt_count = 1; /* Only show the format of our main visual */
|
||||||
}
|
}
|
||||||
else if(iPixelFormat == 1) {
|
else if(iPixelFormat == 1) {
|
||||||
ret = TRUE;
|
res = &WineGLPixelFormatList[0];
|
||||||
*fmt_index = WineGLPixelFormatList[0].fmt_index;
|
|
||||||
*fmt_count = 1; /* Only show the format of our main visual */
|
*fmt_count = 1; /* Only show the format of our main visual */
|
||||||
}
|
}
|
||||||
/* Limit the use of offscreen formats to WGL extension calls which pass AllowOffscreen = TRUE */
|
|
||||||
else if((WineGLPixelFormatList[iPixelFormat-1].offscreenOnly == TRUE) && AllowOffscreen) {
|
else if((WineGLPixelFormatList[iPixelFormat-1].offscreenOnly == TRUE) && AllowOffscreen) {
|
||||||
ret = TRUE;
|
res = &WineGLPixelFormatList[iPixelFormat-1];
|
||||||
*fmt_count = WineGLPixelFormatListSize;
|
*fmt_count = WineGLPixelFormatListSize;
|
||||||
TRACE("Returning FBConfig_ID=%x for iPixelFormat=%d\n", WineGLPixelFormatList[iPixelFormat-1].fbconfig, iPixelFormat);
|
TRACE("Returning FBConfig=%p for iPixelFormat=%d\n", res->fbconfig, iPixelFormat);
|
||||||
}
|
}
|
||||||
|
|
||||||
TRACE("Number of returned pixelformats=%d\n", *fmt_count);
|
TRACE("Number of returned pixelformats=%d\n", *fmt_count);
|
||||||
return ret;
|
|
||||||
|
return res;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Search our internal pixelformat list for the WGL format corresponding to the given fbconfig */
|
/* Search our internal pixelformat list for the WGL format corresponding to the given fbconfig */
|
||||||
static int ConvertPixelFormatGLXtoWGL(Display *display, int fbconfig)
|
static int ConvertPixelFormatGLXtoWGL(Display *display, int fmt_id)
|
||||||
{
|
{
|
||||||
int i;
|
int i;
|
||||||
|
|
||||||
|
@ -982,12 +981,12 @@ static int ConvertPixelFormatGLXtoWGL(Display *display, int fbconfig)
|
||||||
init_formats(display, DefaultScreen(display), visual);
|
init_formats(display, DefaultScreen(display), visual);
|
||||||
|
|
||||||
for(i=0; i<WineGLPixelFormatListSize; i++) {
|
for(i=0; i<WineGLPixelFormatListSize; i++) {
|
||||||
if(WineGLPixelFormatList[i].fbconfig == fbconfig) {
|
if(WineGLPixelFormatList[i].fmt_id == fmt_id) {
|
||||||
TRACE("Returning iPixelFormat %d for fbconfig 0x%x\n", WineGLPixelFormatList[i].iPixelFormat, fbconfig);
|
TRACE("Returning iPixelFormat %d for fmt_id 0x%x\n", WineGLPixelFormatList[i].iPixelFormat, fmt_id);
|
||||||
return WineGLPixelFormatList[i].iPixelFormat;
|
return WineGLPixelFormatList[i].iPixelFormat;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
TRACE("No compatible format found for FBCONFIG_ID=0x%x\n", fbconfig);
|
TRACE("No compatible format found for fmt_id 0x%x\n", fmt_id);
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -998,11 +997,9 @@ static int ConvertPixelFormatGLXtoWGL(Display *display, int fbconfig)
|
||||||
*/
|
*/
|
||||||
int X11DRV_ChoosePixelFormat(X11DRV_PDEVICE *physDev,
|
int X11DRV_ChoosePixelFormat(X11DRV_PDEVICE *physDev,
|
||||||
const PIXELFORMATDESCRIPTOR *ppfd) {
|
const PIXELFORMATDESCRIPTOR *ppfd) {
|
||||||
GLXFBConfig* cfgs = NULL;
|
WineGLPixelFormat *fmt;
|
||||||
int ret = 0;
|
int ret = 0;
|
||||||
int nCfgs = 0;
|
|
||||||
int value = 0;
|
int value = 0;
|
||||||
int fmt_index = 0;
|
|
||||||
|
|
||||||
if (!has_opengl()) {
|
if (!has_opengl()) {
|
||||||
ERR("No libGL on this box - disabling OpenGL support !\n");
|
ERR("No libGL on this box - disabling OpenGL support !\n");
|
||||||
|
@ -1021,15 +1018,9 @@ int X11DRV_ChoosePixelFormat(X11DRV_PDEVICE *physDev,
|
||||||
goto choose_exit;
|
goto choose_exit;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Get a list containing all supported FB configurations */
|
fmt = ConvertPixelFormatWGLtoGLX(gdi_display, 1 /* main visual */, FALSE /* offscreen */, &value);
|
||||||
cfgs = pglXGetFBConfigs(gdi_display, DefaultScreen(gdi_display), &nCfgs);
|
|
||||||
if (NULL == cfgs || 0 == nCfgs) {
|
|
||||||
ERR("glXGetFBConfigs returns NULL (glError: %d)\n", pglGetError());
|
|
||||||
goto choose_exit;
|
|
||||||
}
|
|
||||||
|
|
||||||
/* In case an fbconfig was found, check if it matches to the requirements of the ppfd */
|
/* In case an fbconfig was found, check if it matches to the requirements of the ppfd */
|
||||||
if(!ConvertPixelFormatWGLtoGLX(gdi_display, 1 /* main visual */, FALSE /* offscreen */, &fmt_index, &value)) {
|
if(!fmt) {
|
||||||
ERR("Can't find a matching FBCONFIG_ID for VISUAL_ID 0x%lx!\n", visual->visualid);
|
ERR("Can't find a matching FBCONFIG_ID for VISUAL_ID 0x%lx!\n", visual->visualid);
|
||||||
} else {
|
} else {
|
||||||
int dwFlags = 0;
|
int dwFlags = 0;
|
||||||
|
@ -1037,7 +1028,7 @@ int X11DRV_ChoosePixelFormat(X11DRV_PDEVICE *physDev,
|
||||||
int value = 0;
|
int value = 0;
|
||||||
|
|
||||||
/* Pixel type */
|
/* Pixel type */
|
||||||
pglXGetFBConfigAttrib(gdi_display, cfgs[fmt_index], GLX_RENDER_TYPE, &value);
|
pglXGetFBConfigAttrib(gdi_display, fmt->fbconfig, GLX_RENDER_TYPE, &value);
|
||||||
if (value & GLX_RGBA_BIT)
|
if (value & GLX_RGBA_BIT)
|
||||||
iPixelType = PFD_TYPE_RGBA;
|
iPixelType = PFD_TYPE_RGBA;
|
||||||
else
|
else
|
||||||
|
@ -1049,7 +1040,7 @@ int X11DRV_ChoosePixelFormat(X11DRV_PDEVICE *physDev,
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Doublebuffer */
|
/* Doublebuffer */
|
||||||
pglXGetFBConfigAttrib(gdi_display, cfgs[fmt_index], GLX_DOUBLEBUFFER, &value); if (value) dwFlags |= PFD_DOUBLEBUFFER;
|
pglXGetFBConfigAttrib(gdi_display, fmt->fbconfig, GLX_DOUBLEBUFFER, &value); if (value) dwFlags |= PFD_DOUBLEBUFFER;
|
||||||
if (!(ppfd->dwFlags & PFD_DOUBLEBUFFER_DONTCARE) && (ppfd->dwFlags & PFD_DOUBLEBUFFER)) {
|
if (!(ppfd->dwFlags & PFD_DOUBLEBUFFER_DONTCARE) && (ppfd->dwFlags & PFD_DOUBLEBUFFER)) {
|
||||||
if (!(dwFlags & PFD_DOUBLEBUFFER)) {
|
if (!(dwFlags & PFD_DOUBLEBUFFER)) {
|
||||||
TRACE("dbl buffer mismatch\n");
|
TRACE("dbl buffer mismatch\n");
|
||||||
|
@ -1058,7 +1049,7 @@ int X11DRV_ChoosePixelFormat(X11DRV_PDEVICE *physDev,
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Stereo */
|
/* Stereo */
|
||||||
pglXGetFBConfigAttrib(gdi_display, cfgs[fmt_index], GLX_STEREO, &value); if (value) dwFlags |= PFD_STEREO;
|
pglXGetFBConfigAttrib(gdi_display, fmt->fbconfig, GLX_STEREO, &value); if (value) dwFlags |= PFD_STEREO;
|
||||||
if (!(ppfd->dwFlags & PFD_STEREO_DONTCARE) && (ppfd->dwFlags & PFD_STEREO)) {
|
if (!(ppfd->dwFlags & PFD_STEREO_DONTCARE) && (ppfd->dwFlags & PFD_STEREO)) {
|
||||||
if (!(dwFlags & PFD_STEREO)) {
|
if (!(dwFlags & PFD_STEREO)) {
|
||||||
TRACE("stereo mismatch\n");
|
TRACE("stereo mismatch\n");
|
||||||
|
@ -1067,28 +1058,28 @@ int X11DRV_ChoosePixelFormat(X11DRV_PDEVICE *physDev,
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Alpha bits */
|
/* Alpha bits */
|
||||||
pglXGetFBConfigAttrib(gdi_display, cfgs[fmt_index], GLX_ALPHA_SIZE, &value);
|
pglXGetFBConfigAttrib(gdi_display, fmt->fbconfig, GLX_ALPHA_SIZE, &value);
|
||||||
if (ppfd->iPixelType==PFD_TYPE_RGBA && ppfd->cAlphaBits && !value) {
|
if (ppfd->iPixelType==PFD_TYPE_RGBA && ppfd->cAlphaBits && !value) {
|
||||||
TRACE("alpha mismatch\n");
|
TRACE("alpha mismatch\n");
|
||||||
goto choose_exit;
|
goto choose_exit;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Depth bits */
|
/* Depth bits */
|
||||||
pglXGetFBConfigAttrib(gdi_display, cfgs[fmt_index], GLX_DEPTH_SIZE, &value);
|
pglXGetFBConfigAttrib(gdi_display, fmt->fbconfig, GLX_DEPTH_SIZE, &value);
|
||||||
if (ppfd->cDepthBits && !value) {
|
if (ppfd->cDepthBits && !value) {
|
||||||
TRACE("depth mismatch\n");
|
TRACE("depth mismatch\n");
|
||||||
goto choose_exit;
|
goto choose_exit;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Stencil bits */
|
/* Stencil bits */
|
||||||
pglXGetFBConfigAttrib(gdi_display, cfgs[fmt_index], GLX_STENCIL_SIZE, &value);
|
pglXGetFBConfigAttrib(gdi_display, fmt->fbconfig, GLX_STENCIL_SIZE, &value);
|
||||||
if (ppfd->cStencilBits && !value) {
|
if (ppfd->cStencilBits && !value) {
|
||||||
TRACE("stencil mismatch\n");
|
TRACE("stencil mismatch\n");
|
||||||
goto choose_exit;
|
goto choose_exit;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Aux buffers */
|
/* Aux buffers */
|
||||||
pglXGetFBConfigAttrib(gdi_display, cfgs[fmt_index], GLX_AUX_BUFFERS, &value);
|
pglXGetFBConfigAttrib(gdi_display, fmt->fbconfig, GLX_AUX_BUFFERS, &value);
|
||||||
if (ppfd->cAuxBuffers && !value) {
|
if (ppfd->cAuxBuffers && !value) {
|
||||||
TRACE("aux mismatch\n");
|
TRACE("aux mismatch\n");
|
||||||
goto choose_exit;
|
goto choose_exit;
|
||||||
|
@ -1103,7 +1094,6 @@ choose_exit:
|
||||||
if(!ret)
|
if(!ret)
|
||||||
TRACE("No matching mode was found returning 0\n");
|
TRACE("No matching mode was found returning 0\n");
|
||||||
|
|
||||||
if (NULL != cfgs) XFree(cfgs);
|
|
||||||
wine_tsx11_unlock();
|
wine_tsx11_unlock();
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
@ -1120,14 +1110,9 @@ int X11DRV_DescribePixelFormat(X11DRV_PDEVICE *physDev,
|
||||||
/*XVisualInfo *vis;*/
|
/*XVisualInfo *vis;*/
|
||||||
int value;
|
int value;
|
||||||
int rb,gb,bb,ab;
|
int rb,gb,bb,ab;
|
||||||
|
WineGLPixelFormat *fmt;
|
||||||
GLXFBConfig* cfgs = NULL;
|
|
||||||
GLXFBConfig cur;
|
|
||||||
int nCfgs = 0;
|
|
||||||
int ret = 0;
|
int ret = 0;
|
||||||
int fmt_count = 0;
|
int fmt_count = 0;
|
||||||
int fmt_index = 0;
|
|
||||||
BOOL res = FALSE;
|
|
||||||
|
|
||||||
if (!has_opengl()) {
|
if (!has_opengl()) {
|
||||||
ERR("No libGL on this box - disabling OpenGL support !\n");
|
ERR("No libGL on this box - disabling OpenGL support !\n");
|
||||||
|
@ -1136,29 +1121,13 @@ int X11DRV_DescribePixelFormat(X11DRV_PDEVICE *physDev,
|
||||||
|
|
||||||
TRACE("(%p,%d,%d,%p)\n", physDev, iPixelFormat, nBytes, ppfd);
|
TRACE("(%p,%d,%d,%p)\n", physDev, iPixelFormat, nBytes, ppfd);
|
||||||
|
|
||||||
wine_tsx11_lock();
|
|
||||||
cfgs = pglXGetFBConfigs(gdi_display, DefaultScreen(gdi_display), &nCfgs);
|
|
||||||
wine_tsx11_unlock();
|
|
||||||
|
|
||||||
if (NULL == cfgs || 0 == nCfgs) {
|
|
||||||
ERR("unexpected iPixelFormat(%d), returns NULL\n", iPixelFormat);
|
|
||||||
return 0; /* unespected error */
|
|
||||||
}
|
|
||||||
|
|
||||||
/* Look for the iPixelFormat in our list of supported formats. If it is supported we get the index in the FBConfig table and the number of supported formats back */
|
/* Look for the iPixelFormat in our list of supported formats. If it is supported we get the index in the FBConfig table and the number of supported formats back */
|
||||||
res = ConvertPixelFormatWGLtoGLX(gdi_display, iPixelFormat, FALSE /* Offscreen */, &fmt_index, &fmt_count);
|
fmt = ConvertPixelFormatWGLtoGLX(gdi_display, iPixelFormat, FALSE /* Offscreen */, &fmt_count);
|
||||||
|
|
||||||
if (ppfd == NULL) {
|
if (ppfd == NULL) {
|
||||||
/* The application is only querying the number of visuals */
|
/* The application is only querying the number of pixelformats */
|
||||||
wine_tsx11_lock();
|
|
||||||
if (NULL != cfgs) XFree(cfgs);
|
|
||||||
wine_tsx11_unlock();
|
|
||||||
return fmt_count;
|
return fmt_count;
|
||||||
} else if(res == FALSE) {
|
} else if(fmt == NULL) {
|
||||||
WARN("unexpected iPixelFormat(%d): not >=1 and <=nFormats(%d), returning NULL!\n", iPixelFormat, fmt_count);
|
WARN("unexpected iPixelFormat(%d): not >=1 and <=nFormats(%d), returning NULL!\n", iPixelFormat, fmt_count);
|
||||||
wine_tsx11_lock();
|
|
||||||
if (NULL != cfgs) XFree(cfgs);
|
|
||||||
wine_tsx11_unlock();
|
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1169,7 +1138,6 @@ int X11DRV_DescribePixelFormat(X11DRV_PDEVICE *physDev,
|
||||||
}
|
}
|
||||||
|
|
||||||
ret = fmt_count;
|
ret = fmt_count;
|
||||||
cur = cfgs[fmt_index];
|
|
||||||
|
|
||||||
memset(ppfd, 0, sizeof(PIXELFORMATDESCRIPTOR));
|
memset(ppfd, 0, sizeof(PIXELFORMATDESCRIPTOR));
|
||||||
ppfd->nSize = sizeof(PIXELFORMATDESCRIPTOR);
|
ppfd->nSize = sizeof(PIXELFORMATDESCRIPTOR);
|
||||||
|
@ -1181,30 +1149,30 @@ int X11DRV_DescribePixelFormat(X11DRV_PDEVICE *physDev,
|
||||||
|
|
||||||
wine_tsx11_lock();
|
wine_tsx11_lock();
|
||||||
|
|
||||||
pglXGetFBConfigAttrib(gdi_display, cur, GLX_CONFIG_CAVEAT, &value);
|
pglXGetFBConfigAttrib(gdi_display, fmt->fbconfig, GLX_CONFIG_CAVEAT, &value);
|
||||||
if(value == GLX_SLOW_CONFIG)
|
if(value == GLX_SLOW_CONFIG)
|
||||||
ppfd->dwFlags |= PFD_GENERIC_ACCELERATED;
|
ppfd->dwFlags |= PFD_GENERIC_ACCELERATED;
|
||||||
|
|
||||||
pglXGetFBConfigAttrib(gdi_display, cur, GLX_DOUBLEBUFFER, &value); if (value) ppfd->dwFlags |= PFD_DOUBLEBUFFER;
|
pglXGetFBConfigAttrib(gdi_display, fmt->fbconfig, GLX_DOUBLEBUFFER, &value); if (value) ppfd->dwFlags |= PFD_DOUBLEBUFFER;
|
||||||
pglXGetFBConfigAttrib(gdi_display, cur, GLX_STEREO, &value); if (value) ppfd->dwFlags |= PFD_STEREO;
|
pglXGetFBConfigAttrib(gdi_display, fmt->fbconfig, GLX_STEREO, &value); if (value) ppfd->dwFlags |= PFD_STEREO;
|
||||||
|
|
||||||
/* Pixel type */
|
/* Pixel type */
|
||||||
pglXGetFBConfigAttrib(gdi_display, cur, GLX_RENDER_TYPE, &value);
|
pglXGetFBConfigAttrib(gdi_display, fmt->fbconfig, GLX_RENDER_TYPE, &value);
|
||||||
if (value & GLX_RGBA_BIT)
|
if (value & GLX_RGBA_BIT)
|
||||||
ppfd->iPixelType = PFD_TYPE_RGBA;
|
ppfd->iPixelType = PFD_TYPE_RGBA;
|
||||||
else
|
else
|
||||||
ppfd->iPixelType = PFD_TYPE_COLORINDEX;
|
ppfd->iPixelType = PFD_TYPE_COLORINDEX;
|
||||||
|
|
||||||
/* Color bits */
|
/* Color bits */
|
||||||
pglXGetFBConfigAttrib(gdi_display, cur, GLX_BUFFER_SIZE, &value);
|
pglXGetFBConfigAttrib(gdi_display, fmt->fbconfig, GLX_BUFFER_SIZE, &value);
|
||||||
ppfd->cColorBits = value;
|
ppfd->cColorBits = value;
|
||||||
|
|
||||||
/* Red, green, blue and alpha bits / shifts */
|
/* Red, green, blue and alpha bits / shifts */
|
||||||
if (ppfd->iPixelType == PFD_TYPE_RGBA) {
|
if (ppfd->iPixelType == PFD_TYPE_RGBA) {
|
||||||
pglXGetFBConfigAttrib(gdi_display, cur, GLX_RED_SIZE, &rb);
|
pglXGetFBConfigAttrib(gdi_display, fmt->fbconfig, GLX_RED_SIZE, &rb);
|
||||||
pglXGetFBConfigAttrib(gdi_display, cur, GLX_GREEN_SIZE, &gb);
|
pglXGetFBConfigAttrib(gdi_display, fmt->fbconfig, GLX_GREEN_SIZE, &gb);
|
||||||
pglXGetFBConfigAttrib(gdi_display, cur, GLX_BLUE_SIZE, &bb);
|
pglXGetFBConfigAttrib(gdi_display, fmt->fbconfig, GLX_BLUE_SIZE, &bb);
|
||||||
pglXGetFBConfigAttrib(gdi_display, cur, GLX_ALPHA_SIZE, &ab);
|
pglXGetFBConfigAttrib(gdi_display, fmt->fbconfig, GLX_ALPHA_SIZE, &ab);
|
||||||
|
|
||||||
ppfd->cRedBits = rb;
|
ppfd->cRedBits = rb;
|
||||||
ppfd->cRedShift = gb + bb + ab;
|
ppfd->cRedShift = gb + bb + ab;
|
||||||
|
@ -1227,11 +1195,11 @@ int X11DRV_DescribePixelFormat(X11DRV_PDEVICE *physDev,
|
||||||
/* Accums : to do ... */
|
/* Accums : to do ... */
|
||||||
|
|
||||||
/* Depth bits */
|
/* Depth bits */
|
||||||
pglXGetFBConfigAttrib(gdi_display, cur, GLX_DEPTH_SIZE, &value);
|
pglXGetFBConfigAttrib(gdi_display, fmt->fbconfig, GLX_DEPTH_SIZE, &value);
|
||||||
ppfd->cDepthBits = value;
|
ppfd->cDepthBits = value;
|
||||||
|
|
||||||
/* stencil bits */
|
/* stencil bits */
|
||||||
pglXGetFBConfigAttrib(gdi_display, cur, GLX_STENCIL_SIZE, &value);
|
pglXGetFBConfigAttrib(gdi_display, fmt->fbconfig, GLX_STENCIL_SIZE, &value);
|
||||||
ppfd->cStencilBits = value;
|
ppfd->cStencilBits = value;
|
||||||
|
|
||||||
wine_tsx11_unlock();
|
wine_tsx11_unlock();
|
||||||
|
@ -1244,10 +1212,6 @@ int X11DRV_DescribePixelFormat(X11DRV_PDEVICE *physDev,
|
||||||
dump_PIXELFORMATDESCRIPTOR(ppfd);
|
dump_PIXELFORMATDESCRIPTOR(ppfd);
|
||||||
}
|
}
|
||||||
|
|
||||||
wine_tsx11_lock();
|
|
||||||
if (NULL != cfgs) XFree(cfgs);
|
|
||||||
wine_tsx11_unlock();
|
|
||||||
|
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1270,7 +1234,7 @@ int X11DRV_GetPixelFormat(X11DRV_PDEVICE *physDev) {
|
||||||
BOOL X11DRV_SetPixelFormat(X11DRV_PDEVICE *physDev,
|
BOOL X11DRV_SetPixelFormat(X11DRV_PDEVICE *physDev,
|
||||||
int iPixelFormat,
|
int iPixelFormat,
|
||||||
const PIXELFORMATDESCRIPTOR *ppfd) {
|
const PIXELFORMATDESCRIPTOR *ppfd) {
|
||||||
int fmt_index = 0;
|
WineGLPixelFormat *fmt;
|
||||||
int value;
|
int value;
|
||||||
|
|
||||||
TRACE("(%p,%d,%p)\n", physDev, iPixelFormat, ppfd);
|
TRACE("(%p,%d,%p)\n", physDev, iPixelFormat, ppfd);
|
||||||
|
@ -1281,7 +1245,8 @@ BOOL X11DRV_SetPixelFormat(X11DRV_PDEVICE *physDev,
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Check if iPixelFormat is in our list of supported formats to see if it is supported. */
|
/* Check if iPixelFormat is in our list of supported formats to see if it is supported. */
|
||||||
if(!ConvertPixelFormatWGLtoGLX(gdi_display, iPixelFormat, FALSE /* Offscreen */, &fmt_index, &value)) {
|
fmt = ConvertPixelFormatWGLtoGLX(gdi_display, iPixelFormat, FALSE /* Offscreen */, &value);
|
||||||
|
if(!fmt) {
|
||||||
ERR("Invalid iPixelFormat: %d\n", iPixelFormat);
|
ERR("Invalid iPixelFormat: %d\n", iPixelFormat);
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
@ -1289,9 +1254,6 @@ BOOL X11DRV_SetPixelFormat(X11DRV_PDEVICE *physDev,
|
||||||
physDev->current_pf = iPixelFormat;
|
physDev->current_pf = iPixelFormat;
|
||||||
|
|
||||||
if (TRACE_ON(opengl)) {
|
if (TRACE_ON(opengl)) {
|
||||||
int nCfgs_fmt = 0;
|
|
||||||
GLXFBConfig* cfgs_fmt = NULL;
|
|
||||||
GLXFBConfig cur_cfg;
|
|
||||||
int gl_test = 0;
|
int gl_test = 0;
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
@ -1310,20 +1272,17 @@ BOOL X11DRV_SetPixelFormat(X11DRV_PDEVICE *physDev,
|
||||||
pglXQueryDrawable(gdi_display, drawable, GLX_HEIGHT, (unsigned int*) &value);
|
pglXQueryDrawable(gdi_display, drawable, GLX_HEIGHT, (unsigned int*) &value);
|
||||||
TRACE(" - HEIGHT as %d\n", tmp);
|
TRACE(" - HEIGHT as %d\n", tmp);
|
||||||
*/
|
*/
|
||||||
cfgs_fmt = pglXGetFBConfigs(gdi_display, DefaultScreen(gdi_display), &nCfgs_fmt);
|
gl_test = pglXGetFBConfigAttrib(gdi_display, fmt->fbconfig, GLX_FBCONFIG_ID, &value);
|
||||||
cur_cfg = cfgs_fmt[fmt_index];
|
|
||||||
gl_test = pglXGetFBConfigAttrib(gdi_display, cur_cfg, GLX_FBCONFIG_ID, &value);
|
|
||||||
if (gl_test) {
|
if (gl_test) {
|
||||||
ERR("Failed to retrieve FBCONFIG_ID from GLXFBConfig, expect problems.\n");
|
ERR("Failed to retrieve FBCONFIG_ID from GLXFBConfig, expect problems.\n");
|
||||||
} else {
|
} else {
|
||||||
TRACE(" FBConfig have :\n");
|
TRACE(" FBConfig have :\n");
|
||||||
TRACE(" - FBCONFIG_ID 0x%x\n", value);
|
TRACE(" - FBCONFIG_ID 0x%x\n", value);
|
||||||
pglXGetFBConfigAttrib(gdi_display, cur_cfg, GLX_VISUAL_ID, &value);
|
pglXGetFBConfigAttrib(gdi_display, fmt->fbconfig, GLX_VISUAL_ID, &value);
|
||||||
TRACE(" - VISUAL_ID 0x%x\n", value);
|
TRACE(" - VISUAL_ID 0x%x\n", value);
|
||||||
pglXGetFBConfigAttrib(gdi_display, cur_cfg, GLX_DRAWABLE_TYPE, &value);
|
pglXGetFBConfigAttrib(gdi_display, fmt->fbconfig, GLX_DRAWABLE_TYPE, &value);
|
||||||
TRACE(" - DRAWABLE_TYPE 0x%x\n", value);
|
TRACE(" - DRAWABLE_TYPE 0x%x\n", value);
|
||||||
}
|
}
|
||||||
XFree(cfgs_fmt);
|
|
||||||
}
|
}
|
||||||
return TRUE;
|
return TRUE;
|
||||||
}
|
}
|
||||||
|
@ -1336,12 +1295,9 @@ BOOL X11DRV_SetPixelFormat(X11DRV_PDEVICE *physDev,
|
||||||
HGLRC X11DRV_wglCreateContext(X11DRV_PDEVICE *physDev)
|
HGLRC X11DRV_wglCreateContext(X11DRV_PDEVICE *physDev)
|
||||||
{
|
{
|
||||||
Wine_GLContext *ret;
|
Wine_GLContext *ret;
|
||||||
GLXFBConfig* cfgs_fmt = NULL;
|
WineGLPixelFormat *fmt;
|
||||||
GLXFBConfig cur_cfg;
|
|
||||||
int hdcPF = physDev->current_pf;
|
int hdcPF = physDev->current_pf;
|
||||||
int fmt_count = 0;
|
int fmt_count = 0;
|
||||||
int fmt_index = 0;
|
|
||||||
int nCfgs_fmt = 0;
|
|
||||||
int value = 0;
|
int value = 0;
|
||||||
int gl_test = 0;
|
int gl_test = 0;
|
||||||
HDC hdc = physDev->hdc;
|
HDC hdc = physDev->hdc;
|
||||||
|
@ -1356,35 +1312,27 @@ HGLRC X11DRV_wglCreateContext(X11DRV_PDEVICE *physDev)
|
||||||
/* First, get the visual in use by the X11DRV */
|
/* First, get the visual in use by the X11DRV */
|
||||||
if (!gdi_display) return 0;
|
if (!gdi_display) return 0;
|
||||||
|
|
||||||
|
fmt = ConvertPixelFormatWGLtoGLX(gdi_display, hdcPF, FALSE /* Offscreen */, &fmt_count);
|
||||||
/* We can only render using the iPixelFormat (1) of Wine's Main visual, we need to get the corresponding GLX format.
|
/* We can only render using the iPixelFormat (1) of Wine's Main visual, we need to get the corresponding GLX format.
|
||||||
* If this fails something is very wrong on the system. */
|
* If this fails something is very wrong on the system. */
|
||||||
if(!ConvertPixelFormatWGLtoGLX(gdi_display, hdcPF, FALSE /* Offscreen */, &fmt_index, &fmt_count)) {
|
if(!fmt) {
|
||||||
ERR("Cannot get FB Config for main iPixelFormat 1, expect problems!\n");
|
ERR("Cannot get FB Config for main iPixelFormat 1, expect problems!\n");
|
||||||
SetLastError(ERROR_INVALID_PIXEL_FORMAT);
|
SetLastError(ERROR_INVALID_PIXEL_FORMAT);
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
cfgs_fmt = pglXGetFBConfigs(gdi_display, DefaultScreen(gdi_display), &nCfgs_fmt);
|
|
||||||
if (NULL == cfgs_fmt || 0 == nCfgs_fmt) {
|
|
||||||
ERR("Cannot get FB Configs, expect problems.\n");
|
|
||||||
SetLastError(ERROR_INVALID_PIXEL_FORMAT);
|
|
||||||
return NULL;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (fmt_count < hdcPF) {
|
if (fmt_count < hdcPF) {
|
||||||
ERR("(%p): unexpected pixelFormat(%d) > nFormats(%d), returns NULL\n", hdc, hdcPF, fmt_count);
|
ERR("(%p): unexpected pixelFormat(%d) > nFormats(%d), returns NULL\n", hdc, hdcPF, fmt_count);
|
||||||
SetLastError(ERROR_INVALID_PIXEL_FORMAT);
|
SetLastError(ERROR_INVALID_PIXEL_FORMAT);
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
cur_cfg = cfgs_fmt[fmt_index];
|
gl_test = pglXGetFBConfigAttrib(gdi_display, fmt->fbconfig, GLX_FBCONFIG_ID, &value);
|
||||||
gl_test = pglXGetFBConfigAttrib(gdi_display, cur_cfg, GLX_FBCONFIG_ID, &value);
|
|
||||||
if (gl_test) {
|
if (gl_test) {
|
||||||
ERR("Failed to retrieve FBCONFIG_ID from GLXFBConfig, expect problems.\n");
|
ERR("Failed to retrieve FBCONFIG_ID from GLXFBConfig, expect problems.\n");
|
||||||
SetLastError(ERROR_INVALID_PIXEL_FORMAT);
|
SetLastError(ERROR_INVALID_PIXEL_FORMAT);
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
XFree(cfgs_fmt);
|
|
||||||
|
|
||||||
/* The context will be allocated in the wglMakeCurrent call */
|
/* The context will be allocated in the wglMakeCurrent call */
|
||||||
wine_tsx11_lock();
|
wine_tsx11_lock();
|
||||||
|
@ -1392,9 +1340,9 @@ HGLRC X11DRV_wglCreateContext(X11DRV_PDEVICE *physDev)
|
||||||
wine_tsx11_unlock();
|
wine_tsx11_unlock();
|
||||||
ret->hdc = hdc;
|
ret->hdc = hdc;
|
||||||
ret->physDev = physDev;
|
ret->physDev = physDev;
|
||||||
ret->fb_conf = cur_cfg;
|
ret->fb_conf = fmt->fbconfig;
|
||||||
/*ret->vis = vis;*/
|
/*ret->vis = vis;*/
|
||||||
ret->vis = pglXGetVisualFromFBConfig(gdi_display, cur_cfg);
|
ret->vis = pglXGetVisualFromFBConfig(gdi_display, fmt->fbconfig);
|
||||||
|
|
||||||
TRACE(" creating context %p (GL context creation delayed)\n", ret);
|
TRACE(" creating context %p (GL context creation delayed)\n", ret);
|
||||||
return (HGLRC) ret;
|
return (HGLRC) ret;
|
||||||
|
@ -1991,11 +1939,10 @@ static const char * WINAPI X11DRV_wglGetExtensionsStringARB(HDC hdc) {
|
||||||
static HPBUFFERARB WINAPI X11DRV_wglCreatePbufferARB(HDC hdc, int iPixelFormat, int iWidth, int iHeight, const int *piAttribList)
|
static HPBUFFERARB WINAPI X11DRV_wglCreatePbufferARB(HDC hdc, int iPixelFormat, int iWidth, int iHeight, const int *piAttribList)
|
||||||
{
|
{
|
||||||
Wine_GLPBuffer* object = NULL;
|
Wine_GLPBuffer* object = NULL;
|
||||||
GLXFBConfig* cfgs = NULL;
|
WineGLPixelFormat *fmt = NULL;
|
||||||
int nCfgs = 0;
|
int nCfgs = 0;
|
||||||
int attribs[256];
|
int attribs[256];
|
||||||
int nAttribs = 0;
|
int nAttribs = 0;
|
||||||
int fmt_index = 0;
|
|
||||||
|
|
||||||
TRACE("(%p, %d, %d, %d, %p)\n", hdc, iPixelFormat, iWidth, iHeight, piAttribList);
|
TRACE("(%p, %d, %d, %d, %p)\n", hdc, iPixelFormat, iWidth, iHeight, piAttribList);
|
||||||
|
|
||||||
|
@ -2005,16 +1952,9 @@ static HPBUFFERARB WINAPI X11DRV_wglCreatePbufferARB(HDC hdc, int iPixelFormat,
|
||||||
return NULL; /* unexpected error */
|
return NULL; /* unexpected error */
|
||||||
}
|
}
|
||||||
|
|
||||||
cfgs = pglXGetFBConfigs(gdi_display, DefaultScreen(gdi_display), &nCfgs);
|
|
||||||
|
|
||||||
if (NULL == cfgs || 0 == nCfgs) {
|
|
||||||
ERR("(%p): Cannot get FB Configs for iPixelFormat(%d), returns NULL\n", hdc, iPixelFormat);
|
|
||||||
SetLastError(ERROR_INVALID_PIXEL_FORMAT);
|
|
||||||
return NULL; /* unexpected error */
|
|
||||||
}
|
|
||||||
|
|
||||||
/* Convert the WGL pixelformat to a GLX format, if it fails then the format is invalid */
|
/* Convert the WGL pixelformat to a GLX format, if it fails then the format is invalid */
|
||||||
if(!ConvertPixelFormatWGLtoGLX(gdi_display, iPixelFormat, FALSE /* Offscreen */, &fmt_index, &nCfgs)) {
|
fmt = ConvertPixelFormatWGLtoGLX(gdi_display, iPixelFormat, FALSE /* Offscreen */, &nCfgs);
|
||||||
|
if(!fmt) {
|
||||||
ERR("(%p): unexpected iPixelFormat(%d) > nFormats(%d), returns NULL\n", hdc, iPixelFormat, nCfgs);
|
ERR("(%p): unexpected iPixelFormat(%d) > nFormats(%d), returns NULL\n", hdc, iPixelFormat, nCfgs);
|
||||||
SetLastError(ERROR_INVALID_PIXEL_FORMAT);
|
SetLastError(ERROR_INVALID_PIXEL_FORMAT);
|
||||||
goto create_failed; /* unexpected error */
|
goto create_failed; /* unexpected error */
|
||||||
|
@ -2157,20 +2097,16 @@ static HPBUFFERARB WINAPI X11DRV_wglCreatePbufferARB(HDC hdc, int iPixelFormat,
|
||||||
}
|
}
|
||||||
|
|
||||||
PUSH1(attribs, None);
|
PUSH1(attribs, None);
|
||||||
object->drawable = pglXCreatePbuffer(gdi_display, cfgs[fmt_index], attribs);
|
object->drawable = pglXCreatePbuffer(gdi_display, fmt->fbconfig, attribs);
|
||||||
TRACE("new Pbuffer drawable as %p\n", (void*) object->drawable);
|
TRACE("new Pbuffer drawable as %p\n", (void*) object->drawable);
|
||||||
if (!object->drawable) {
|
if (!object->drawable) {
|
||||||
SetLastError(ERROR_NO_SYSTEM_RESOURCES);
|
SetLastError(ERROR_NO_SYSTEM_RESOURCES);
|
||||||
goto create_failed; /* unexpected error */
|
goto create_failed; /* unexpected error */
|
||||||
}
|
}
|
||||||
TRACE("->(%p)\n", object);
|
TRACE("->(%p)\n", object);
|
||||||
|
|
||||||
/** free list */
|
|
||||||
XFree(cfgs);
|
|
||||||
return (HPBUFFERARB) object;
|
return (HPBUFFERARB) object;
|
||||||
|
|
||||||
create_failed:
|
create_failed:
|
||||||
if (NULL != cfgs) XFree(cfgs);
|
|
||||||
HeapFree(GetProcessHeap(), 0, object);
|
HeapFree(GetProcessHeap(), 0, object);
|
||||||
TRACE("->(FAILED)\n");
|
TRACE("->(FAILED)\n");
|
||||||
return (HPBUFFERARB) NULL;
|
return (HPBUFFERARB) NULL;
|
||||||
|
@ -2443,14 +2379,11 @@ static GLboolean WINAPI X11DRV_wglChoosePixelFormatARB(HDC hdc, const int *piAtt
|
||||||
static GLboolean WINAPI X11DRV_wglGetPixelFormatAttribivARB(HDC hdc, int iPixelFormat, int iLayerPlane, UINT nAttributes, const int *piAttributes, int *piValues)
|
static GLboolean WINAPI X11DRV_wglGetPixelFormatAttribivARB(HDC hdc, int iPixelFormat, int iLayerPlane, UINT nAttributes, const int *piAttributes, int *piValues)
|
||||||
{
|
{
|
||||||
UINT i;
|
UINT i;
|
||||||
GLXFBConfig* cfgs = NULL;
|
WineGLPixelFormat *fmt = NULL;
|
||||||
GLXFBConfig curCfg = NULL;
|
|
||||||
int nCfgs = 0;
|
|
||||||
int hTest;
|
int hTest;
|
||||||
int tmp;
|
int tmp;
|
||||||
int curGLXAttr = 0;
|
int curGLXAttr = 0;
|
||||||
int nWGLFormats = 0;
|
int nWGLFormats = 0;
|
||||||
int fmt_index = 0;
|
|
||||||
|
|
||||||
TRACE("(%p, %d, %d, %d, %p, %p)\n", hdc, iPixelFormat, iLayerPlane, nAttributes, piAttributes, piValues);
|
TRACE("(%p, %d, %d, %d, %p, %p)\n", hdc, iPixelFormat, iLayerPlane, nAttributes, piAttributes, piValues);
|
||||||
|
|
||||||
|
@ -2459,16 +2392,11 @@ static GLboolean WINAPI X11DRV_wglGetPixelFormatAttribivARB(HDC hdc, int iPixelF
|
||||||
return GL_FALSE;
|
return GL_FALSE;
|
||||||
}
|
}
|
||||||
|
|
||||||
cfgs = pglXGetFBConfigs(gdi_display, DefaultScreen(gdi_display), &nCfgs);
|
|
||||||
if (NULL == cfgs) {
|
|
||||||
ERR("no FB Configs found for display(%p)\n", gdi_display);
|
|
||||||
return GL_FALSE;
|
|
||||||
}
|
|
||||||
|
|
||||||
/* Convert the WGL pixelformat to a GLX one, if this fails then most likely the iPixelFormat isn't supoprted.
|
/* Convert the WGL pixelformat to a GLX one, if this fails then most likely the iPixelFormat isn't supoprted.
|
||||||
* We don't have to fail yet as a program can specify an invaled iPixelFormat (lets say 0) if it wants to query
|
* We don't have to fail yet as a program can specify an invaled iPixelFormat (lets say 0) if it wants to query
|
||||||
* the number of supported WGL formats. Whether the iPixelFormat is valid is handled in the for-loop below. */
|
* the number of supported WGL formats. Whether the iPixelFormat is valid is handled in the for-loop below. */
|
||||||
if(!ConvertPixelFormatWGLtoGLX(gdi_display, iPixelFormat, FALSE /* Offscreen */, &fmt_index, &nWGLFormats)) {
|
fmt = ConvertPixelFormatWGLtoGLX(gdi_display, iPixelFormat, FALSE /* Offscreen */, &nWGLFormats);
|
||||||
|
if(!fmt) {
|
||||||
WARN("Unable to convert iPixelFormat %d to a GLX one!\n", iPixelFormat);
|
WARN("Unable to convert iPixelFormat %d to a GLX one!\n", iPixelFormat);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -2487,11 +2415,8 @@ static GLboolean WINAPI X11DRV_wglGetPixelFormatAttribivARB(HDC hdc, int iPixelF
|
||||||
|
|
||||||
case WGL_ACCELERATION_ARB:
|
case WGL_ACCELERATION_ARB:
|
||||||
curGLXAttr = GLX_CONFIG_CAVEAT;
|
curGLXAttr = GLX_CONFIG_CAVEAT;
|
||||||
|
if (!fmt) goto pix_error;
|
||||||
if (nCfgs < iPixelFormat || 0 >= iPixelFormat) goto pix_error;
|
hTest = pglXGetFBConfigAttrib(gdi_display, fmt->fbconfig, curGLXAttr, &tmp);
|
||||||
curCfg = cfgs[iPixelFormat - 1];
|
|
||||||
|
|
||||||
hTest = pglXGetFBConfigAttrib(gdi_display, curCfg, curGLXAttr, &tmp);
|
|
||||||
if (hTest) goto get_error;
|
if (hTest) goto get_error;
|
||||||
switch (tmp) {
|
switch (tmp) {
|
||||||
case GLX_NONE: piValues[i] = WGL_FULL_ACCELERATION_ARB; break;
|
case GLX_NONE: piValues[i] = WGL_FULL_ACCELERATION_ARB; break;
|
||||||
|
@ -2505,11 +2430,8 @@ static GLboolean WINAPI X11DRV_wglGetPixelFormatAttribivARB(HDC hdc, int iPixelF
|
||||||
|
|
||||||
case WGL_TRANSPARENT_ARB:
|
case WGL_TRANSPARENT_ARB:
|
||||||
curGLXAttr = GLX_TRANSPARENT_TYPE;
|
curGLXAttr = GLX_TRANSPARENT_TYPE;
|
||||||
/* Check if the format is supported by checking if iPixelFormat isn't larger than the max number of
|
if (!fmt) goto pix_error;
|
||||||
* supported WGLFormats and also check if the GLX fmt_index is valid. */
|
hTest = pglXGetFBConfigAttrib(gdi_display, fmt->fbconfig, curGLXAttr, &tmp);
|
||||||
if((iPixelFormat > nWGLFormats) || (fmt_index > nCfgs)) goto pix_error;
|
|
||||||
curCfg = cfgs[fmt_index];
|
|
||||||
hTest = pglXGetFBConfigAttrib(gdi_display, curCfg, curGLXAttr, &tmp);
|
|
||||||
if (hTest) goto get_error;
|
if (hTest) goto get_error;
|
||||||
piValues[i] = GL_FALSE;
|
piValues[i] = GL_FALSE;
|
||||||
if (GLX_NONE != tmp) piValues[i] = GL_TRUE;
|
if (GLX_NONE != tmp) piValues[i] = GL_TRUE;
|
||||||
|
@ -2517,11 +2439,8 @@ static GLboolean WINAPI X11DRV_wglGetPixelFormatAttribivARB(HDC hdc, int iPixelF
|
||||||
|
|
||||||
case WGL_PIXEL_TYPE_ARB:
|
case WGL_PIXEL_TYPE_ARB:
|
||||||
curGLXAttr = GLX_RENDER_TYPE;
|
curGLXAttr = GLX_RENDER_TYPE;
|
||||||
/* Check if the format is supported by checking if iPixelFormat isn't larger than the max number of
|
if (!fmt) goto pix_error;
|
||||||
* supported WGLFormats and also check if the GLX fmt_index is valid. */
|
hTest = pglXGetFBConfigAttrib(gdi_display, fmt->fbconfig, curGLXAttr, &tmp);
|
||||||
if((iPixelFormat > nWGLFormats) || (fmt_index > nCfgs)) goto pix_error;
|
|
||||||
curCfg = cfgs[fmt_index];
|
|
||||||
hTest = pglXGetFBConfigAttrib(gdi_display, curCfg, curGLXAttr, &tmp);
|
|
||||||
if (hTest) goto get_error;
|
if (hTest) goto get_error;
|
||||||
TRACE("WGL_PIXEL_TYPE_ARB: GLX_RENDER_TYPE = 0x%x\n", tmp);
|
TRACE("WGL_PIXEL_TYPE_ARB: GLX_RENDER_TYPE = 0x%x\n", tmp);
|
||||||
if (tmp & GLX_RGBA_BIT) { piValues[i] = WGL_TYPE_RGBA_ARB; }
|
if (tmp & GLX_RGBA_BIT) { piValues[i] = WGL_TYPE_RGBA_ARB; }
|
||||||
|
@ -2536,14 +2455,11 @@ static GLboolean WINAPI X11DRV_wglGetPixelFormatAttribivARB(HDC hdc, int iPixelF
|
||||||
|
|
||||||
case WGL_COLOR_BITS_ARB:
|
case WGL_COLOR_BITS_ARB:
|
||||||
/** see ConvertAttribWGLtoGLX for explain */
|
/** see ConvertAttribWGLtoGLX for explain */
|
||||||
/* Check if the format is supported by checking if iPixelFormat isn't larger than the max number of
|
if (!fmt) goto pix_error;
|
||||||
* supported WGLFormats and also check if the GLX fmt_index is valid. */
|
hTest = pglXGetFBConfigAttrib(gdi_display, fmt->fbconfig, GLX_BUFFER_SIZE, piValues + i);
|
||||||
if((iPixelFormat > nWGLFormats) || (fmt_index > nCfgs)) goto pix_error;
|
|
||||||
curCfg = cfgs[fmt_index];
|
|
||||||
hTest = pglXGetFBConfigAttrib(gdi_display, curCfg, GLX_BUFFER_SIZE, piValues + i);
|
|
||||||
if (hTest) goto get_error;
|
if (hTest) goto get_error;
|
||||||
TRACE("WGL_COLOR_BITS_ARB: GLX_BUFFER_SIZE = %d\n", piValues[i]);
|
TRACE("WGL_COLOR_BITS_ARB: GLX_BUFFER_SIZE = %d\n", piValues[i]);
|
||||||
hTest = pglXGetFBConfigAttrib(gdi_display, curCfg, GLX_ALPHA_SIZE, &tmp);
|
hTest = pglXGetFBConfigAttrib(gdi_display, fmt->fbconfig, GLX_ALPHA_SIZE, &tmp);
|
||||||
if (hTest) goto get_error;
|
if (hTest) goto get_error;
|
||||||
TRACE("WGL_COLOR_BITS_ARB: GLX_ALPHA_SIZE = %d\n", tmp);
|
TRACE("WGL_COLOR_BITS_ARB: GLX_ALPHA_SIZE = %d\n", tmp);
|
||||||
piValues[i] = piValues[i] - tmp;
|
piValues[i] = piValues[i] - tmp;
|
||||||
|
@ -2564,17 +2480,14 @@ static GLboolean WINAPI X11DRV_wglGetPixelFormatAttribivARB(HDC hdc, int iPixelF
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
curGLXAttr = GLX_RENDER_TYPE;
|
curGLXAttr = GLX_RENDER_TYPE;
|
||||||
/* Check if the format is supported by checking if iPixelFormat isn't larger than the max number of
|
if (!fmt) goto pix_error;
|
||||||
* supported WGLFormats and also check if the GLX fmt_index is valid. */
|
hTest = pglXGetFBConfigAttrib(gdi_display, fmt->fbconfig, curGLXAttr, &tmp);
|
||||||
if((iPixelFormat > nWGLFormats) || (fmt_index > nCfgs)) goto pix_error;
|
|
||||||
curCfg = cfgs[fmt_index];
|
|
||||||
hTest = pglXGetFBConfigAttrib(gdi_display, curCfg, curGLXAttr, &tmp);
|
|
||||||
if (hTest) goto get_error;
|
if (hTest) goto get_error;
|
||||||
if (GLX_COLOR_INDEX_BIT == tmp) {
|
if (GLX_COLOR_INDEX_BIT == tmp) {
|
||||||
piValues[i] = GL_FALSE;
|
piValues[i] = GL_FALSE;
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
hTest = pglXGetFBConfigAttrib(gdi_display, curCfg, GLX_DRAWABLE_TYPE, &tmp);
|
hTest = pglXGetFBConfigAttrib(gdi_display, fmt->fbconfig, GLX_DRAWABLE_TYPE, &tmp);
|
||||||
if (hTest) goto get_error;
|
if (hTest) goto get_error;
|
||||||
piValues[i] = (tmp & GLX_PBUFFER_BIT) ? GL_TRUE : GL_FALSE;
|
piValues[i] = (tmp & GLX_PBUFFER_BIT) ? GL_TRUE : GL_FALSE;
|
||||||
continue;
|
continue;
|
||||||
|
@ -2613,7 +2526,7 @@ static GLboolean WINAPI X11DRV_wglGetPixelFormatAttribivARB(HDC hdc, int iPixelF
|
||||||
piValues[i] = GL_TRUE;
|
piValues[i] = GL_TRUE;
|
||||||
continue;
|
continue;
|
||||||
case WGL_DRAW_TO_PBUFFER_ARB:
|
case WGL_DRAW_TO_PBUFFER_ARB:
|
||||||
hTest = pglXGetFBConfigAttrib(gdi_display, curCfg, GLX_DRAWABLE_TYPE, &tmp);
|
hTest = pglXGetFBConfigAttrib(gdi_display, fmt->fbconfig, GLX_DRAWABLE_TYPE, &tmp);
|
||||||
if (hTest) goto get_error;
|
if (hTest) goto get_error;
|
||||||
piValues[i] = (tmp & GLX_PBUFFER_BIT) ? GL_TRUE : GL_FALSE;
|
piValues[i] = (tmp & GLX_PBUFFER_BIT) ? GL_TRUE : GL_FALSE;
|
||||||
continue;
|
continue;
|
||||||
|
@ -2644,11 +2557,8 @@ static GLboolean WINAPI X11DRV_wglGetPixelFormatAttribivARB(HDC hdc, int iPixelF
|
||||||
* mean that the behavior could differ between different vendors (ATI, Nvidia, ..).
|
* mean that the behavior could differ between different vendors (ATI, Nvidia, ..).
|
||||||
*/
|
*/
|
||||||
if (0 != curGLXAttr && iPixelFormat != 0) {
|
if (0 != curGLXAttr && iPixelFormat != 0) {
|
||||||
/* Check if the format is supported by checking if iPixelFormat isn't larger than the max number of
|
if (!fmt) goto pix_error;
|
||||||
* supported WGLFormats and also check if the GLX fmt_index is valid. */
|
hTest = pglXGetFBConfigAttrib(gdi_display, fmt->fbconfig, curGLXAttr, piValues + i);
|
||||||
if((iPixelFormat > 0) && ((iPixelFormat > nWGLFormats) || (fmt_index > nCfgs))) goto pix_error;
|
|
||||||
curCfg = cfgs[fmt_index];
|
|
||||||
hTest = pglXGetFBConfigAttrib(gdi_display, curCfg, curGLXAttr, piValues + i);
|
|
||||||
if (hTest) goto get_error;
|
if (hTest) goto get_error;
|
||||||
curGLXAttr = 0;
|
curGLXAttr = 0;
|
||||||
} else {
|
} else {
|
||||||
|
@ -2659,12 +2569,10 @@ static GLboolean WINAPI X11DRV_wglGetPixelFormatAttribivARB(HDC hdc, int iPixelF
|
||||||
|
|
||||||
get_error:
|
get_error:
|
||||||
ERR("(%p): unexpected failure on GetFBConfigAttrib(%x) returns FALSE\n", hdc, curGLXAttr);
|
ERR("(%p): unexpected failure on GetFBConfigAttrib(%x) returns FALSE\n", hdc, curGLXAttr);
|
||||||
XFree(cfgs);
|
|
||||||
return GL_FALSE;
|
return GL_FALSE;
|
||||||
|
|
||||||
pix_error:
|
pix_error:
|
||||||
ERR("(%p): unexpected iPixelFormat(%d) vs nFormats(%d), returns FALSE\n", hdc, iPixelFormat, nCfgs);
|
ERR("(%p): unexpected iPixelFormat(%d) vs nFormats(%d), returns FALSE\n", hdc, iPixelFormat, nWGLFormats);
|
||||||
XFree(cfgs);
|
|
||||||
return GL_FALSE;
|
return GL_FALSE;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue