Hi guys
I send a reply to the list a couple of days ago, but I attached my exe file
and it seems it was blocked but hotmail...
First, thanks a lot for all your replies... Jesse, I've made the changes
proposed in those patches, but it didn't work :-(
After further inspection, it seems the problem is when I call wglMakeCurrent
for a context which shares display lists with another context. I've attached
the program and the source code, so you can try it.
This is the output of the trace+opengl:
trace:opengl:has_opengl GLX is up and running error_base = 77
trace:opengl:X11DRV_setup_opengl_visual Visual ID 21 Chosen
trace:opengl:X11DRV_ChoosePixelFormat (0x403a28a8,0x406afdac)
trace:opengl:dump_PIXELFORMATDESCRIPTOR - size / version : 40 / 1
trace:opengl:dump_PIXELFORMATDESCRIPTOR - dwFlags : PFD_DOUBLEBUFFER
PFD_DRAW_TO_WINDOW PFD_SUPPORT_OPENGL
trace:opengl:dump_PIXELFORMATDESCRIPTOR - iPixelType : PFD_TYPE_RGBA
trace:opengl:dump_PIXELFORMATDESCRIPTOR - Color : 24
trace:opengl:dump_PIXELFORMATDESCRIPTOR - Red : 8
trace:opengl:dump_PIXELFORMATDESCRIPTOR - Green : 8
trace:opengl:dump_PIXELFORMATDESCRIPTOR - Blue : 8
trace:opengl:dump_PIXELFORMATDESCRIPTOR - Alpha : 8
trace:opengl:dump_PIXELFORMATDESCRIPTOR - Accum : 0
trace:opengl:dump_PIXELFORMATDESCRIPTOR - Depth : 24
trace:opengl:dump_PIXELFORMATDESCRIPTOR - Stencil : 0
trace:opengl:dump_PIXELFORMATDESCRIPTOR - Aux : 0
trace:opengl:dump_PIXELFORMATDESCRIPTOR - iLayerType : PFD_MAIN_PLANE
trace:opengl:X11DRV_SetPixelFormat (0x403a28a8,3,0x406afdac)
trace:opengl:X11DRV_SetPixelFormat FBConfig have :
trace:opengl:X11DRV_SetPixelFormat - FBCONFIG_ID 0x73
trace:opengl:X11DRV_SetPixelFormat - VISUAL_ID 0x23
trace:opengl:X11DRV_SetPixelFormat - DRAWABLE_TYPE 0x7
trace:opengl:X11DRV_GetPixelFormat (0x403a28a8): returns 3
trace:opengl:wglCreateContext (0x1cc)->(PF:3)
trace:opengl:wglCreateContext creating context 0x403a2a40 (GL context
creation delayed)
trace:opengl:X11DRV_ChoosePixelFormat (0x403a2cc0,0x406afdac)
trace:opengl:dump_PIXELFORMATDESCRIPTOR - size / version : 40 / 1
trace:opengl:dump_PIXELFORMATDESCRIPTOR - dwFlags : PFD_DOUBLEBUFFER
PFD_DRAW_TO_WINDOW PFD_SUPPORT_OPENGL
trace:opengl:dump_PIXELFORMATDESCRIPTOR - iPixelType : PFD_TYPE_RGBA
trace:opengl:dump_PIXELFORMATDESCRIPTOR - Color : 24
trace:opengl:dump_PIXELFORMATDESCRIPTOR - Red : 8
trace:opengl:dump_PIXELFORMATDESCRIPTOR - Green : 8
trace:opengl:dump_PIXELFORMATDESCRIPTOR - Blue : 8
trace:opengl:dump_PIXELFORMATDESCRIPTOR - Alpha : 8
trace:opengl:dump_PIXELFORMATDESCRIPTOR - Accum : 0
trace:opengl:dump_PIXELFORMATDESCRIPTOR - Depth : 24
trace:opengl:dump_PIXELFORMATDESCRIPTOR - Stencil : 0
trace:opengl:dump_PIXELFORMATDESCRIPTOR - Aux : 0
trace:opengl:dump_PIXELFORMATDESCRIPTOR - iLayerType : PFD_MAIN_PLANE
trace:opengl:X11DRV_SetPixelFormat (0x403a2cc0,3,0x406afdac)
trace:opengl:X11DRV_SetPixelFormat FBConfig have :
trace:opengl:X11DRV_SetPixelFormat - FBCONFIG_ID 0x73
trace:opengl:X11DRV_SetPixelFormat - VISUAL_ID 0x23
trace:opengl:X11DRV_SetPixelFormat - DRAWABLE_TYPE 0x7
trace:opengl:X11DRV_GetPixelFormat (0x403a2cc0): returns 3
trace:opengl:wglCreateContext (0x1dc)->(PF:3)
trace:opengl:wglCreateContext creating context 0x403a2e58 (GL context
creation delayed)
trace:opengl:wglShareLists (0x403a2a40, 0x403a2e58)
trace:opengl:describeContext Context 0x403a2a40 have (vis:0x7c1782d0):
trace:opengl:describeContext - FBCONFIG_ID 0x73
trace:opengl:describeContext - VISUAL_ID 0x23
trace:opengl:wglShareLists created a delayed OpenGL context (0x7c190318)
for Wine context 0x403a2a40
trace:opengl:describeContext Context 0x403a2e58 have (vis:0x7c18a4d0):
trace:opengl:describeContext - FBCONFIG_ID 0x73
trace:opengl:describeContext - VISUAL_ID 0x23
trace:opengl:wglShareLists created a delayed OpenGL context (0x7c1b1590)
for Wine context 0x403a2e58 sharing lists with OpenGL ctx 0x7c190318
trace:opengl:wglGetCurrentDC ()
trace:opengl:wglGetCurrentDC no Wine context found for GLX context
0x7c096448
trace:opengl:wglGetCurrentContext ()
trace:opengl:wglGetCurrentContext returning (nil) (GL context 0x7c096448)
trace:opengl:wglMakeCurrent (0x1dc,0x403a2e58)
trace:opengl:wglMakeCurrent make current for dis 0x7c0657f0, drawable
0x3800002, ctx 0x7c1b1590
X Error of failed request: BadMatch (invalid parameter attributes)
Major opcode of failed request: 144 (GLX)
Minor opcode of failed request: 5 (X_GLXMakeCurrent)
Serial number of failed request: 120
Current serial number in output stream: 120
My guess is that when we call wglMakeCurrent for the context with the shared
lists, it has a VISUAL_ID of 0x23, but X11DRV_setup_opengl_visual chosed a
Visual ID of 0x21, and hence the BadMatch error.
As I said, this program works just fine in Windows, so we must be doing
something differente in wine
Any ideas/hints?
Thanks
_________________________________________________________________
Don't just Search. Find! http://search.sympatico.msn.ca/default.aspx The new
MSN Search! Check it out!
#include <windows.h>
#include <gl/gl.h>
#include <gl/glu.h>
#include <stdio.h>
char *DummyWindowClassName = NULL;
HINSTANCE g_hInstance = NULL;
static LRESULT CALLBACK DummyGLWindowProc(HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam)
{
return DefWindowProc(hWnd, uMsg, wParam, lParam);
}
class GLContext
{
public:
HDC hDC, OldDC;
HGLRC hRC, OldRC;
HWND hWnd; // Zero size dummy window
public:
static bool Init();
static void Shutdown();
GLContext();
~GLContext() { Free(); }
bool Create(int width = 0, int height = 0, bool sharelists = true);
void Free();
bool Obtain();
void Release(bool restore = true);
};
GLContext SharedContext, Context;
bool GLContext::Init()
{
if (DummyWindowClassName == NULL)
{
DummyWindowClassName = "DummyWindowClassName";
WNDCLASS wc;
wc.style = CS_OWNDC;
wc.lpfnWndProc = (WNDPROC)DummyGLWindowProc;
wc.cbClsExtra = 0;
wc.cbWndExtra = 0;
wc.hInstance = g_hInstance;
wc.hIcon = NULL;
wc.hCursor = NULL;
wc.hbrBackground = NULL;
wc.lpszMenuName = NULL;
wc.lpszClassName = DummyWindowClassName;
if (!RegisterClass(&wc))
{
DummyWindowClassName = NULL;
return false;
}
}
return true;
}
void GLContext::Shutdown()
{
if (DummyWindowClassName)
{
UnregisterClass(DummyWindowClassName, g_hInstance);
DummyWindowClassName = NULL;
}
}
GLContext::GLContext()
{
hDC = NULL;
OldDC = NULL;
hRC = NULL;
OldRC = NULL;
hWnd = NULL;
}
void GLContext::Free()
{
if (hRC)
{
wglDeleteContext(hRC);
hRC = NULL;
}
if (hDC)
{
ReleaseDC(hWnd, hDC);
hDC = 0;
}
if (hWnd)
{
DestroyWindow(hWnd);
hWnd = 0;
}
}
bool GLContext::Create(int width, int height, bool sharelists)
{
if (!(hWnd = CreateWindow(DummyWindowClassName, "", WS_POPUP, 0, 0, width, height, NULL, NULL, g_hInstance, NULL)))
{
Free();
return false;
}
if (!(hDC = GetDC(hWnd)))
{
Free();
return false;
}
PIXELFORMATDESCRIPTOR pfd =
{
sizeof(PIXELFORMATDESCRIPTOR),
1, // Version Number
PFD_DRAW_TO_WINDOW | PFD_SUPPORT_OPENGL | PFD_DOUBLEBUFFER,
PFD_TYPE_RGBA,
24, // Color Depth
8, 0, 8, 0, 8, 0, // 8 bit rgb
8, // 8 bit alpha buffer
0, // No Alpha shift Bit
0, // No Accumulation Buffer
0, 0, 0, 0, // No Accumulation Bits
24, // Z-Buffer
0, // No Stencil Buffer
0, // No Auxiliary Buffer
PFD_MAIN_PLANE, // Main Drawing Layer
0, // Reserved
0, 0, 0 // Layer Masks Ignored
};
unsigned int PixelFormat;
if (!(PixelFormat = ChoosePixelFormat(hDC, &pfd)))
{
Free();
return false;
}
if (!SetPixelFormat(hDC, PixelFormat, &pfd))
{
Free();
return false;
}
if (!(hRC = wglCreateContext(hDC)))
{
Free();
return false;
}
if (sharelists)
{
if (!wglShareLists(SharedContext.hRC, hRC))
{
Free();
return false;
}
}
return true;
}
bool GLContext::Obtain()
{
OldDC = wglGetCurrentDC();
OldRC = wglGetCurrentContext();
int ret = wglMakeCurrent(hDC, hRC);
if (ret != TRUE)
wglMakeCurrent(OldDC, OldRC);
return ret == TRUE;
}
void GLContext::Release(bool restore)
{
wglMakeCurrent(NULL, NULL);
if (restore && OldRC && OldDC)
{
LONG ret = wglMakeCurrent(OldDC, OldRC);
if (ret == FALSE)
printf("GLContext::Release() - failed\n");
}
}
//----------------------------------------------------------------------------------------------
int WINAPI WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpCmdLine, int nCmdShow)
{
g_hInstance = hInstance;
if (!GLContext::Init())
return false;
// the context we will share later
if (!SharedContext.Create(0, 0, false))
return false;
// the main context
if (!Context.Create(0, 0, true))
return false;
if (!Context.Obtain())
return false;
// do something in OpenGL
GLint stackDepth;
glGetIntegerv(GL_MAX_MODELVIEW_STACK_DEPTH, &stackDepth);
printf("WinMain - ModelView stack depth is %i\n", stackDepth);
GLenum e = glGetError();
if (e != GL_NO_ERROR)
{
const char *errstring = (const char*)gluErrorString(e);
printf("WinMain - OpenGL error: %s\n", errstring);
}
Context.Release();
Context.Free();
SharedContext.Free();
GLContext::Shutdown();
return 0;
}