DDraw, wined3d (d3d8,
d3d9) and OpenGL32 in Mac OSX + stack fudging -- x86 only
Nick Burns
adger44 at hotmail.com
Sun Apr 30 05:40:37 CDT 2006
Here is the patch thus far -- It is not clean or anything... (cvs -q diff -
straight from my tree)
--I think this patch will work and allow you to run specific ogl and d3d
apps (with enough stack fudging see below)
--Here is an example of the stack fudging
--Since this is too hard to add to all entry points... I did not bother
doing it en mass (only for functions that were causing crashes for demos --
waiting for gcc goodness)
void WINAPI SomeApiEntryPoint()
{
//begin stack alignment
asm("pushl 0(%ebp)");//save ebp`
asm("movl %esp, 0(%ebp)");//hope that 0(%ebp) is not used in function
//save esp -- ebp -> esp -> ebp`
asm("subl %ebp, %esp");//calc n
asm("addl %esp, %esp");//n*2
asm("addl %ebp, %esp");//n*2+esp
asm("subl $0x10, %esp");//pad out stack
asm("andl $0xFFFFFFF0, %esp");//align the stack
//end stack alignment
...
//body
...
//begin stack restore
asm("movl 0(%ebp), %esp");//restore esp -- ebp -> esp -> ebp`
asm("popl 0(%ebp)");//restore ebp` + esp
//end stack restore
return;
}
WEEEEEEEEE so fun
- Nick
-------------- next part --------------
cvs -q diff
Index: dlls/ddraw/Makefile.in
===================================================================
RCS file: /home/wine/wine/dlls/ddraw/Makefile.in,v
retrieving revision 1.40
diff -r1.40 Makefile.in
9c9
< EXTRALIBS = -ldxguid -luuid @X_LIBS@ @X_PRE_LIBS@ @XLIB@ @X_EXTRA_LIBS@
---
>EXTRALIBS = -ldxguid -luuid @X_LIBS@ @X_PRE_LIBS@ @XLIB@ @X_EXTRA_LIBS@
>@OPENGL_LIBS@
Index: dlls/ddraw/device_opengl.c
===================================================================
RCS file: /home/wine/wine/dlls/ddraw/device_opengl.c,v
retrieving revision 1.12
diff -r1.12 device_opengl.c
4316c4316
< Drawable drawable = (Drawable) GetPropA(GetDesktopWindow(),
"__wine_x11_whole_window");
---
> Drawable drawable;// = (Drawable) GetPropA(GetDesktopWindow(),
>"__wine_x11_whole_window");
4327a4328,4332
>#ifdef __APPLE__
> FIXME("Root window apple bad!!!\n");
> HWND hwnd = CreateWindowA("BUTTON", "fake", 0, 0, 0, 10, 10, NULL,
>NULL, GetModuleHandleA(NULL), NULL);
> drawable = (Drawable) GetPropA(hwnd, "__wine_x11_whole_window");
>
4333c4338,4350
<
---
>
> /* Get a default rendering context to have the 'caps' function query
>some info from GL */ device_context = GetDC(hwnd);
> display = get_display(device_context);
> ReleaseDC(hwnd, device_context);
>#else
> drawable = (Drawable) GetPropA(GetDesktopWindow(),
>"__wine_x11_whole_window");
> if (!drawable)
> {
> WARN("x11drv not loaded - D3D support disabled!\n");
> return FALSE;
> }
>
4337a4355
>#endif
4371a4390,4392
>#ifdef __APPLE__
> pglXGetProcAddressARB = glXGetProcAddress;
>#else
4372a4394
>#endif
4446a4469,4472
>#ifdef __APPLE__
> FIXME("Root window apple bad!!!\n");
> DestroyWindow(hwnd);
>#endif
Index: dlls/ddraw/main.c
===================================================================
RCS file: /home/wine/wine/dlls/ddraw/main.c,v
retrieving revision 1.57
diff -r1.57 main.c
91a92,99
>#ifdef __APPLE__
>gl_handle=5;
>#define GL_API_FUNCTION(f) p##f=f;
>#include "gl_api.h"
>#undef GL_API_FUNCTION
>return d3ddevice_init_at_startup(gl_handle);
>
>#else
118a127
>#endif
Index: dlls/opengl32/wgl.c
===================================================================
RCS file: /home/wine/wine/dlls/opengl32/wgl.c,v
retrieving revision 1.78
diff -r1.78 wgl.c
49a50,356
>
>#ifdef __APPLE__
>GLXFBConfig* APPLE_glXGetFBConfigs(Display* dpy, int screen, int* ncfgs);
>GLXFBConfig* APPLE_glXChooseFBConfig(Display* dpy, int screen, int*
>attribs, int* ncfgs);
>int APPLE_glXGetFBConfigAttrib(Display* dpy, GLXFBConfig cfg, int attrib,
>int* val);
>XVisualInfo* APPLE_glXGetVisualFromFBConfig(Display* dpy, GLXFBConfig cfg);
>
>typedef struct
>{
> XVisualInfo* info;
> int fbconfig_id;
>}APPLE_GLXFBConfig;
>
>GLXFBConfig* APPLE_glXGetFBConfigs(Display* dpy, int screen, int* ncfgs)
>{
> int attribs[]={None};
> return APPLE_glXChooseFBConfig(dpy,screen,attribs,ncfgs);
>}
>GLXFBConfig* APPLE_glXChooseFBConfig(Display* dpy, int screen, int*
>attribs, int* ncfgs)
>{
>#define add_attrib(val) {_attribs[on_Attrib]=val;on_Attrib++;}
>#define find_attrib(enum_type,found,outval)\
>{\
> found=0;\
> outval=0;\
> for(onattrib=0;attribs[onattrib]!=None;onattrib+=2)\
> {\
>/*printf("(%d)->%d\n",onattrib,attribs[onattrib]);*/\
> if(attribs[onattrib]==enum_type)\
> {\
> found=1;\
> outval=attribs[onattrib+1];\
> }\
> }\
>}\
>
>#if 1
>{
> int onattrib;
> for(onattrib=0;attribs[onattrib]!=None;onattrib+=2)
> {
> switch(attribs[onattrib])
> {
>#if 0
>#define print_case(case_val) case case_val:printf(#case_val " ==
>%d\n",attribs[onattrib+1]);break;
>#else
>#define print_case(case_val) case case_val:break;
>#endif
>#define error_case(case_val) case case_val:printf("unsupported attrib"
>#case_val " == %d\n",attribs[onattrib+1]);break;
> print_case(GLX_FBCONFIG_ID)
> print_case(GLX_BUFFER_SIZE)
> print_case(GLX_DOUBLEBUFFER)
> print_case(GLX_AUX_BUFFERS)
> print_case(GLX_RED_SIZE)
> print_case(GLX_GREEN_SIZE)
> print_case(GLX_BLUE_SIZE)
> print_case(GLX_ALPHA_SIZE)
> print_case(GLX_DEPTH_SIZE)
> print_case(GLX_STENCIL_SIZE)
> print_case(GLX_RENDER_TYPE)
>
> error_case(GLX_LEVEL)
> error_case(GLX_STEREO)
> error_case(GLX_ACCUM_RED_SIZE)
> error_case(GLX_ACCUM_GREEN_SIZE)
> error_case(GLX_ACCUM_BLUE_SIZE)
> error_case(GLX_ACCUM_ALPHA_SIZE)
> error_case(GLX_DRAWABLE_TYPE)
> error_case(GLX_X_RENDERABLE)
> error_case(GLX_X_VISUAL_TYPE)
> error_case(GLX_CONFIG_CAVEAT)
> error_case(GLX_TRANSPARENT_TYPE)
> error_case(GLX_TRANSPARENT_INDEX_VALUE)
> error_case(GLX_TRANSPARENT_RED_VALUE)
> error_case(GLX_TRANSPARENT_GREEN_VALUE)
> error_case(GLX_TRANSPARENT_BLUE_VALUE)
> error_case(GLX_TRANSPARENT_ALPHA_VALUE)
> default: printf("unknown attrib %d ==
>%d\n",attribs[onattrib],attribs[onattrib+1]);break;
> }
> }
>}
>#endif
> *ncfgs=0;
> APPLE_GLXFBConfig** list=NULL;
>
> //loop over big ass set of crap
>//GLX_BUFFER_SIZE 0->32
>//GLX_RGBA
>//GLX_DOUBLEBUFFER
>//GLX_STEREO
>//GLX_AUX_BUFFERS 0->8
>//GLX_RED_SIZE 0->8
>//GLX_GREEN_SIZE 0->8
>//GLX_BLUE_SIZE 0->8
>//GLX_ALPHA_SIZE 0->8
>//GLX_DEPTH_SIZE 0->32
>//GLX_STENCIL_SIZE 0->16
>////GLX_ACCUM_RED_SIZE ////GLX_ACCUM_GREEN_SIZE
>////GLX_ACCUM_BLUE_SIZE
>////GLX_ACCUM_ALPHA_SIZE
> int fbconfig_id=0;
> int rgba[]={None,GLX_RGBA};
> int double_buffer[]={None,GLX_DOUBLEBUFFER};
> //int st[]={None,GLX_STEREO};
> int buff_size[]={0,1,2,4,8,16,32};
> int aux_bufs[]={0,1,2,3,4,5,6,7,8};
> //int color_size[]={0,1,2,3,4,5,6,8};//r,g,b,a
> int color_size[][4]={
> {0, 0, 0, 0},
> {1, 1, 1, 1},
> {2, 3, 2, 0},
> {2, 3, 2, 1},
> {2, 3, 2, 8},
> {3, 3, 2, 0},
> {3, 3, 2, 8},
> {4, 4, 4, 0},
> {4, 4, 4, 1},
> {4, 4, 4, 4},
> {5, 5, 5, 0},
> {5, 5, 5, 1},
> {5, 6, 5, 0},
> {5, 6, 5, 8},
> {8, 8, 8, 0},
> {8, 8, 8, 1},
> {8, 8, 8, 2},
> {8, 8, 8, 4},
> {8, 8, 8, 8},
> {10, 10, 10, 0},
> {10, 10, 10, 1},
> {10, 10, 10, 2}
> };
> int
>rgbas[]={GLX_RED_SIZE,GLX_GREEN_SIZE,GLX_BLUE_SIZE,GLX_ALPHA_SIZE};
> int depth_size[]={0,8,16,24,32};
> int stencil_size[]={0,1,8};
>
>#define foreach(array,block)\
>{\
> int on##array;\
>
>for(on##array=0;on##array<sizeof(array)/sizeof(array[0]);on##array++)\
> {\
> {block}\
> }\
>}\
>
> foreach(color_size,
> {
> foreach(depth_size,
> {
> foreach(stencil_size,
> {
> foreach(buff_size,
> {
> foreach(aux_bufs,
> {
> foreach(rgba,
> {
> foreach(double_buffer,
> {
> int _attribs[256];
> int on_Attrib=0;
> int skip=0;
> int onattrib;
> int found;
> int outval;
>
> if(rgba[onrgba]!=None)
> {
> add_attrib(rgba[onrgba]);
> find_attrib(GLX_RENDER_TYPE,found,outval);
> if(found&&outval!=GLX_RGBA_BIT)
> {
> skip=1;
> }
> }
> else
> {
> find_attrib(GLX_RENDER_TYPE,found,outval);
> if(found&&outval==GLX_RGBA_BIT)
> {
> skip=1;
> }
> }
> if(double_buffer[ondouble_buffer]!=None)
> {
> add_attrib(double_buffer[ondouble_buffer]);
> find_attrib(GLX_DOUBLEBUFFER,found,outval);
> if(found&&outval==False)
> {
> skip=1;
> }
> }
> else
> {
> find_attrib(GLX_DOUBLEBUFFER,found,outval);
> if(found&&outval==True)
> {
> skip=1;
> }
> }
> if(buff_size[onbuff_size]!=0)
> {
> add_attrib(GLX_BUFFER_SIZE);
> add_attrib(buff_size[onbuff_size]);
> find_attrib(GLX_BUFFER_SIZE,found,outval);
> if(found&&outval>buff_size[onbuff_size])
> {
> skip=1;
> }
> }
> foreach(rgbas,
> {
> if(buff_size[onbuff_size]!=0)
> {
> add_attrib(rgbas[onrgbas]);
>
>add_attrib(color_size[oncolor_size][onrgbas]);
> find_attrib(rgbas[onrgbas],found,outval);
>
>if(found&&outval>color_size[oncolor_size][onrgbas])
> {
> skip=1;
> }
> }
> })
> if(depth_size[ondepth_size]!=0)
> {
> add_attrib(GLX_DEPTH_SIZE);
> add_attrib(depth_size[ondepth_size]);
> find_attrib(GLX_DEPTH_SIZE,found,outval);
> if(found&&outval>depth_size[ondepth_size])
> {
> skip=1;
> }
> }
> if(stencil_size[onstencil_size]!=0)
> {
> add_attrib(GLX_STENCIL_SIZE);
> add_attrib(stencil_size[onstencil_size]);
> find_attrib(GLX_STENCIL_SIZE,found,outval);
> if(found&&outval>stencil_size[onstencil_size])
> {
> skip=1;
> }
> }
> if(aux_bufs[onaux_bufs]!=0)
> {
> add_attrib(GLX_AUX_BUFFERS);
> add_attrib(aux_bufs[onaux_bufs]);
> find_attrib(GLX_AUX_BUFFERS,found,outval);
> if(found&&outval>aux_bufs[onaux_bufs])
> {
> skip=1;
> }
> }
>
> add_attrib(None);
>
> find_attrib(GLX_FBCONFIG_ID,found,outval);
> if(found&&outval==fbconfig_id)
> {
> skip=0;
> }
>
> XVisualInfo* info=glXChooseVisual(dpy,screen,_attribs);
> if(info!=NULL)
> {
> if(!skip)
> {
> (*ncfgs)++;
>
>list=(APPLE_GLXFBConfig**)realloc(list,*ncfgs*sizeof(APPLE_GLXFBConfig*));
>
>list[*ncfgs-1]=(APPLE_GLXFBConfig*)malloc(sizeof(APPLE_GLXFBConfig));
> list[*ncfgs-1]->info=info;
> list[*ncfgs-1]->fbconfig_id=fbconfig_id;
> }
> fbconfig_id++;
> }
>//printf("fb: %d ncfgs: %d\n", fbconfig_id, *ncfgs);
> })
> })
> })
> })
> })
> })
> })
>//printf(" ncfgs: %d\n", *ncfgs);
> return (GLXFBConfig*)list;
>}
>int APPLE_glXGetFBConfigAttrib(Display* dpy, GLXFBConfig cfg, int attrib,
>int* val)
>{
> APPLE_GLXFBConfig* _cfg=(APPLE_GLXFBConfig*)cfg;
> if(attrib==GLX_FBCONFIG_ID)
> {
> *val=_cfg->fbconfig_id;
> return 0;
> }
> return glXGetConfig(dpy,_cfg->info,attrib,val);
>}
>XVisualInfo* APPLE_glXGetVisualFromFBConfig(Display* dpy, GLXFBConfig cfg)
>{
> APPLE_GLXFBConfig* _cfg=(APPLE_GLXFBConfig*)cfg;
> return _cfg->info;
>}
>
>
>
>#endif
>
>
93a401
>
534a843,857
>////asm("movl %esp, -0x10(%ebp)");
>////asm("subl $0x10, %esp");
>////asm("andl $0xFFFFFFF0, %esp");
>//asm("pushl 0(%ebp)");//save ebp`
>//asm("movl %esp, 0(%ebp)");//hope that 0(%ebp) is not used in function
>//save esp -- ebp -> esp -> ebp`
>//asm("subl %ebp, %esp");//calc n
>//asm("addl %esp, %esp");//n*2
>//asm("addl %ebp, %esp");//n*2+esp
>//asm("subl $0x10, %esp");//pad out stack
>//asm("andl $0xFFFFFFF0, %esp");//align the stack
>
>//uintptr_t esp;
>//printf("sp(?) = %p\n", (uintptr_t)&esp + sizeof(esp));
>
>
553a877,879
>#ifdef __APPLE__
> FIXME("wglMakeCurrent -- root window apple bad");
>#else
566c892,895
< } else {
---
> }
> else
>#endif
> {
582a912,915
>
>//asm("movl 0(%ebp), %esp");//restore esp -- ebp -> esp -> ebp`
>//asm("popl 0(%ebp)");//restore ebp` + esp
>////asm("movl -0x10(%ebp), %esp");
1208a1542,1548
>#ifdef __APPLE__
>wine_glx.p_glXChooseFBConfig = APPLE_glXChooseFBConfig;
>wine_glx.p_glXGetFBConfigAttrib = APPLE_glXGetFBConfigAttrib;
>wine_glx.p_glXGetVisualFromFBConfig = APPLE_glXGetVisualFromFBConfig;
>wine_glx.p_glXQueryDrawable = NULL;//proc( (const GLubyte *)
>"glXQueryDrawable");
>wine_glx.p_glXGetFBConfigs = APPLE_glXGetFBConfigs;
>#else
1226a1567
>#endif
1265a1607,1609
>#ifdef __APPLE__
> FIXME("If an app starts using ogl before they create a context... --
>its not supported under X11 on Mac OSX UNLESS the user is in rooted mode
>(BUT NO ONE LIKES rooted mode...)");
>#else
1270a1615
>
1280a1626
>
1282a1629
>
1283a1631
>
1284a1633
>
1285a1635
>
1286a1637,1638
>
>#endif
1288a1641,1643
>#ifdef __APPLE__
> p_glXGetProcAddressARB = glXGetProcAddress;
>#else
1296c1651
<
---
>#endif
1304a1660,1662
>#ifdef __APPLE__
> FIXME("No root window default context -- BAD UgLy Root Window\n");
>#else
1308a1667
>#endif
Index: dlls/opengl32/wgl_ext.c
===================================================================
RCS file: /home/wine/wine/dlls/opengl32/wgl_ext.c,v
retrieving revision 1.17
diff -r1.17 wgl_ext.c
41a42,59
>#ifdef __APPLE__
>typedef struct
>{
> XVisualInfo* info;
> int fbconfig_id;
>}APPLE_GLXFBConfig;
>
>GLXFBConfig* APPLE_glXGetFBConfigs(Display* dpy, int screen, int* ncfgs);
>GLXFBConfig* APPLE_glXChooseFBConfig(Display* dpy, int screen, int*
>attribs, int* ncfgs);
>int APPLE_glXGetFBConfigAttrib(Display* dpy, GLXFBConfig cfg, int attrib,
>int* val);
>XVisualInfo* APPLE_glXGetVisualFromFBConfig(Display* dpy, GLXFBConfig cfg);
>
>#define glXGetFBConfigs APPLE_glXGetFBConfigs
>#define glXChooseFBConfig APPLE_glXChooseFBConfig
>#define glXGetFBConfigAttrib APPLE_glXGetFBConfigAttrib
>#define glXGetVisualFromFBConfig APPLE_glXGetVisualFromFBConfig
>
>#endif
Index: dlls/wined3d/device.c
===================================================================
RCS file: /home/wine/wine/dlls/wined3d/device.c,v
retrieving revision 1.192
diff -r1.192 device.c
34a35,46
>#ifdef __APPLE__
>GLXFBConfig* APPLE_glXGetFBConfigs(Display* dpy, int screen, int* ncfgs);
>GLXFBConfig* APPLE_glXChooseFBConfig(Display* dpy, int screen, int*
>attribs, int* ncfgs);
>int APPLE_glXGetFBConfigAttrib(Display* dpy, GLXFBConfig cfg, int attrib,
>int* val);
>XVisualInfo* APPLE_glXGetVisualFromFBConfig(Display* dpy, GLXFBConfig cfg);
>
>#define glXGetFBConfigs APPLE_glXGetFBConfigs
>//#define glXChooseFBConfig APPLE_glXChooseFBConfig
>#define glXGetFBConfigAttrib APPLE_glXGetFBConfigAttrib
>#define glXGetVisualFromFBConfig APPLE_glXGetVisualFromFBConfig
>#endif
>
Index: dlls/wined3d/directx.c
===================================================================
RCS file: /home/wine/wine/dlls/wined3d/directx.c,v
retrieving revision 1.84
diff -r1.84 directx.c
36a37,343
>#ifdef __APPLE__
>GLXFBConfig* APPLE_glXGetFBConfigs(Display* dpy, int screen, int* ncfgs);
>GLXFBConfig* APPLE_glXChooseFBConfig(Display* dpy, int screen, int*
>attribs, int* ncfgs);
>int APPLE_glXGetFBConfigAttrib(Display* dpy, GLXFBConfig cfg, int attrib,
>int* val);
>XVisualInfo* APPLE_glXGetVisualFromFBConfig(Display* dpy, GLXFBConfig cfg);
>
>typedef struct
>{
> XVisualInfo* info;
> int fbconfig_id;
>}APPLE_GLXFBConfig;
>
>GLXFBConfig* APPLE_glXGetFBConfigs(Display* dpy, int screen, int* ncfgs)
>{
> int attribs[]={None};
> return APPLE_glXChooseFBConfig(dpy,screen,attribs,ncfgs);
>}
>GLXFBConfig* APPLE_glXChooseFBConfig(Display* dpy, int screen, int*
>attribs, int* ncfgs)
>{
>#define add_attrib(val) {_attribs[on_Attrib]=val;on_Attrib++;}
>#define find_attrib(enum_type,found,outval)\
>{\
> found=0;\
> outval=0;\
> for(onattrib=0;attribs[onattrib]!=None;onattrib+=2)\
> {\
>/*printf("(%d)->%d\n",onattrib,attribs[onattrib]);*/\
> if(attribs[onattrib]==enum_type)\
> {\
> found=1;\
> outval=attribs[onattrib+1];\
> }\
> }\
>}\
>
>#if 1
>{
> int onattrib;
> for(onattrib=0;attribs[onattrib]!=None;onattrib+=2)
> {
> switch(attribs[onattrib])
> {
>#if 0
>#define print_case(case_val) case case_val:printf(#case_val " ==
>%d\n",attribs[onattrib+1]);break;
>#else
>#define print_case(case_val) case case_val:break;
>#endif
>#define error_case(case_val) case case_val:printf("unsupported attrib"
>#case_val " == %d\n",attribs[onattrib+1]);break;
> print_case(GLX_FBCONFIG_ID)
> print_case(GLX_BUFFER_SIZE)
> print_case(GLX_DOUBLEBUFFER)
> print_case(GLX_AUX_BUFFERS)
> print_case(GLX_RED_SIZE)
> print_case(GLX_GREEN_SIZE)
> print_case(GLX_BLUE_SIZE)
> print_case(GLX_ALPHA_SIZE)
> print_case(GLX_DEPTH_SIZE)
> print_case(GLX_STENCIL_SIZE)
> print_case(GLX_RENDER_TYPE)
>
> error_case(GLX_LEVEL)
> error_case(GLX_STEREO)
> error_case(GLX_ACCUM_RED_SIZE)
> error_case(GLX_ACCUM_GREEN_SIZE)
> error_case(GLX_ACCUM_BLUE_SIZE)
> error_case(GLX_ACCUM_ALPHA_SIZE)
> error_case(GLX_DRAWABLE_TYPE)
> error_case(GLX_X_RENDERABLE)
> error_case(GLX_X_VISUAL_TYPE)
> error_case(GLX_CONFIG_CAVEAT)
> error_case(GLX_TRANSPARENT_TYPE)
> error_case(GLX_TRANSPARENT_INDEX_VALUE)
> error_case(GLX_TRANSPARENT_RED_VALUE)
> error_case(GLX_TRANSPARENT_GREEN_VALUE)
> error_case(GLX_TRANSPARENT_BLUE_VALUE)
> error_case(GLX_TRANSPARENT_ALPHA_VALUE)
> default: printf("unknown attrib %d ==
>%d\n",attribs[onattrib],attribs[onattrib+1]);break;
> }
> }
>}
>#endif
> *ncfgs=0;
> APPLE_GLXFBConfig** list=NULL;
>
> //loop over big ass set of crap
>//GLX_BUFFER_SIZE 0->32
>//GLX_RGBA
>//GLX_DOUBLEBUFFER
>//GLX_STEREO
>//GLX_AUX_BUFFERS 0->8
>//GLX_RED_SIZE 0->8
>//GLX_GREEN_SIZE 0->8
>//GLX_BLUE_SIZE 0->8
>//GLX_ALPHA_SIZE 0->8
>//GLX_DEPTH_SIZE 0->32
>//GLX_STENCIL_SIZE 0->16
>////GLX_ACCUM_RED_SIZE ////GLX_ACCUM_GREEN_SIZE
>////GLX_ACCUM_BLUE_SIZE
>////GLX_ACCUM_ALPHA_SIZE
> int fbconfig_id=0;
> int rgba[]={None,GLX_RGBA};
> int double_buffer[]={None,GLX_DOUBLEBUFFER};
> //int st[]={None,GLX_STEREO};
> int buff_size[]={0,1,2,4,8,16,32};
> int aux_bufs[]={0,1,2,3,4,5,6,7,8};
> //int color_size[]={0,1,2,3,4,5,6,8};//r,g,b,a
> int color_size[][4]={
> {0, 0, 0, 0},
> {1, 1, 1, 1},
> {2, 3, 2, 0},
> {2, 3, 2, 1},
> {2, 3, 2, 8},
> {3, 3, 2, 0},
> {3, 3, 2, 8},
> {4, 4, 4, 0},
> {4, 4, 4, 1},
> {4, 4, 4, 4},
> {5, 5, 5, 0},
> {5, 5, 5, 1},
> {5, 6, 5, 0},
> {5, 6, 5, 8},
> {8, 8, 8, 0},
> {8, 8, 8, 1},
> {8, 8, 8, 2},
> {8, 8, 8, 4},
> {8, 8, 8, 8},
> {10, 10, 10, 0},
> {10, 10, 10, 1},
> {10, 10, 10, 2}
> };
> int
>rgbas[]={GLX_RED_SIZE,GLX_GREEN_SIZE,GLX_BLUE_SIZE,GLX_ALPHA_SIZE};
> int depth_size[]={0,8,16,24,32};
> int stencil_size[]={0,1,8};
>
>#define foreach(array,block)\
>{\
> int on##array;\
>
>for(on##array=0;on##array<sizeof(array)/sizeof(array[0]);on##array++)\
> {\
> {block}\
> }\
>}\
>
> foreach(color_size,
> {
> foreach(depth_size,
> {
> foreach(stencil_size,
> {
> foreach(buff_size,
> {
> foreach(aux_bufs,
> {
> foreach(rgba,
> {
> foreach(double_buffer,
> {
> int _attribs[256];
> int on_Attrib=0;
> int skip=0;
> int onattrib;
> int found;
> int outval;
>
> if(rgba[onrgba]!=None)
> {
> add_attrib(rgba[onrgba]);
> find_attrib(GLX_RENDER_TYPE,found,outval);
> if(found&&outval!=GLX_RGBA_BIT)
> {
> skip=1;
> }
> }
> else
> {
> find_attrib(GLX_RENDER_TYPE,found,outval);
> if(found&&outval==GLX_RGBA_BIT)
> {
> skip=1;
> }
> }
> if(double_buffer[ondouble_buffer]!=None)
> {
> add_attrib(double_buffer[ondouble_buffer]);
> find_attrib(GLX_DOUBLEBUFFER,found,outval);
> if(found&&outval==False)
> {
> skip=1;
> }
> }
> else
> {
> find_attrib(GLX_DOUBLEBUFFER,found,outval);
> if(found&&outval==True)
> {
> skip=1;
> }
> }
> if(buff_size[onbuff_size]!=0)
> {
> add_attrib(GLX_BUFFER_SIZE);
> add_attrib(buff_size[onbuff_size]);
> find_attrib(GLX_BUFFER_SIZE,found,outval);
> if(found&&outval>buff_size[onbuff_size])
> {
> skip=1;
> }
> }
> foreach(rgbas,
> {
> if(buff_size[onbuff_size]!=0)
> {
> add_attrib(rgbas[onrgbas]);
>
>add_attrib(color_size[oncolor_size][onrgbas]);
> find_attrib(rgbas[onrgbas],found,outval);
>
>if(found&&outval>color_size[oncolor_size][onrgbas])
> {
> skip=1;
> }
> }
> })
> if(depth_size[ondepth_size]!=0)
> {
> add_attrib(GLX_DEPTH_SIZE);
> add_attrib(depth_size[ondepth_size]);
> find_attrib(GLX_DEPTH_SIZE,found,outval);
> if(found&&outval>depth_size[ondepth_size])
> {
> skip=1;
> }
> }
> if(stencil_size[onstencil_size]!=0)
> {
> add_attrib(GLX_STENCIL_SIZE);
> add_attrib(stencil_size[onstencil_size]);
> find_attrib(GLX_STENCIL_SIZE,found,outval);
> if(found&&outval>stencil_size[onstencil_size])
> {
> skip=1;
> }
> }
> if(aux_bufs[onaux_bufs]!=0)
> {
> add_attrib(GLX_AUX_BUFFERS);
> add_attrib(aux_bufs[onaux_bufs]);
> find_attrib(GLX_AUX_BUFFERS,found,outval);
> if(found&&outval>aux_bufs[onaux_bufs])
> {
> skip=1;
> }
> }
>
> add_attrib(None);
>
> find_attrib(GLX_FBCONFIG_ID,found,outval);
> if(found&&outval==fbconfig_id)
> {
> skip=0;
> }
>
> XVisualInfo* info=glXChooseVisual(dpy,screen,_attribs);
> if(info!=NULL)
> {
> if(!skip)
> {
> (*ncfgs)++;
>
>list=(APPLE_GLXFBConfig**)realloc(list,*ncfgs*sizeof(APPLE_GLXFBConfig*));
>
>list[*ncfgs-1]=(APPLE_GLXFBConfig*)malloc(sizeof(APPLE_GLXFBConfig));
> list[*ncfgs-1]->info=info;
> list[*ncfgs-1]->fbconfig_id=fbconfig_id;
> }
> fbconfig_id++;
> }
>//printf("fb: %d ncfgs: %d\n", fbconfig_id, *ncfgs);
> })
> })
> })
> })
> })
> })
> })
>//printf(" ncfgs: %d\n", *ncfgs);
> return (GLXFBConfig*)list;
>}
>int APPLE_glXGetFBConfigAttrib(Display* dpy, GLXFBConfig cfg, int attrib,
>int* val)
>{
> APPLE_GLXFBConfig* _cfg=(APPLE_GLXFBConfig*)cfg;
> if(attrib==GLX_FBCONFIG_ID)
> {
> *val=_cfg->fbconfig_id;
> return 0;
> }
> return glXGetConfig(dpy,_cfg->info,attrib,val);
>}
>XVisualInfo* APPLE_glXGetVisualFromFBConfig(Display* dpy, GLXFBConfig cfg)
>{
> APPLE_GLXFBConfig* _cfg=(APPLE_GLXFBConfig*)cfg;
> return _cfg->info;
>}
>
>#define glXGetFBConfigs APPLE_glXGetFBConfigs
>//#define glXChooseFBConfig APPLE_glXChooseFBConfig
>#define glXGetFBConfigAttrib APPLE_glXGetFBConfigAttrib
>#define glXGetVisualFromFBConfig APPLE_glXGetVisualFromFBConfig
>#endif
>
90a398,407
>#ifdef __APPLE__
> FIXME("Root window apple bad!!!\n");
> ctx.hwnd = CreateWindowA("BUTTON", "fake", 0, 0, 0, 10, 10, NULL,
>NULL, GetModuleHandleA(NULL), NULL);
> ctx.drawable = (Drawable) GetPropA(ctx.hwnd,
>"__wine_x11_whole_window");
>
> /* Get the display */
> device_context = GetDC(ctx.hwnd);
> ctx.display = get_display(device_context);
> ReleaseDC(ctx.hwnd, device_context);
>#else
96a414
>#endif
157a476,479
>#ifdef __APPLE__
> FIXME("Root window apple bad!!!\n");
> DestroyWindow(ctx->hwnd);
>#endif
742a1065,1081
>#ifdef __APPLE__
> gl_info->glXCreatePbuffer=glXCreatePbuffer;
> gl_info->glXDestroyPbuffer=glXDestroyPbuffer;
> gl_info->glXCreatePixmap=glXCreatePixmap;
> gl_info->glXDestroyPixmap=glXDestroyPixmap;
> gl_info->glXCreateNewContext=glXCreateNewContext;
> gl_info->glXMakeContextCurrent=glXMakeContextCurrent;
> gl_info->glXChooseFBConfig=APPLE_glXChooseFBConfig;
>
> //glx under mac osx has problems...
> if(gl_info->supported[ATI_SEPARATE_STENCIL])
> {
> FIXME("GL_ATI_separate_stencil not supported in mac X11\n");
> gl_info->supported[ATI_SEPARATE_STENCIL] = FALSE;
> }
>#endif
>
Index: dlls/x11drv/Makefile.in
===================================================================
RCS file: /home/wine/wine/dlls/x11drv/Makefile.in,v
retrieving revision 1.43
diff -r1.43 Makefile.in
8c8
< EXTRALIBS = $(LIBUNICODE) @X_LIBS@ @X_PRE_LIBS@ @XLIB@ @X_EXTRA_LIBS@
---
>EXTRALIBS = $(LIBUNICODE) @X_LIBS@ @X_PRE_LIBS@ @XLIB@ @X_EXTRA_LIBS@
>@OPENGL_LIBS@
Index: dlls/x11drv/opengl.c
===================================================================
RCS file: /home/wine/wine/dlls/x11drv/opengl.c,v
retrieving revision 1.26
diff -r1.26 opengl.c
128a133,134
>
>MAKE_FUNCPTR(glXDestroyGLXPixmap)
130a137,438
>#ifdef __APPLE__
>GLXFBConfig* APPLE_glXGetFBConfigs(Display* dpy, int screen, int* ncfgs);
>GLXFBConfig* APPLE_glXChooseFBConfig(Display* dpy, int screen, int*
>attribs, int* ncfgs);
>int APPLE_glXGetFBConfigAttrib(Display* dpy, GLXFBConfig cfg, int attrib,
>int* val);
>XVisualInfo* APPLE_glXGetVisualFromFBConfig(Display* dpy, GLXFBConfig cfg);
>
>typedef struct
>{
> XVisualInfo* info;
> int fbconfig_id;
>}APPLE_GLXFBConfig;
>
>GLXFBConfig* APPLE_glXGetFBConfigs(Display* dpy, int screen, int* ncfgs)
>{
> int attribs[]={None};
> return APPLE_glXChooseFBConfig(dpy,screen,attribs,ncfgs);
>}
>GLXFBConfig* APPLE_glXChooseFBConfig(Display* dpy, int screen, int*
>attribs, int* ncfgs)
>{
>#define add_attrib(val) {_attribs[on_Attrib]=val;on_Attrib++;}
>#define find_attrib(enum_type,found,outval)\
>{\
> found=0;\
> outval=0;\
> for(onattrib=0;attribs[onattrib]!=None;onattrib+=2)\
> {\
>/*printf("(%d)->%d\n",onattrib,attribs[onattrib]);*/\
> if(attribs[onattrib]==enum_type)\
> {\
> found=1;\
> outval=attribs[onattrib+1];\
> }\
> }\
>}\
>
>#if 1
>{
> int onattrib;
> for(onattrib=0;attribs[onattrib]!=None;onattrib+=2)
> {
> switch(attribs[onattrib])
> {
>#if 0
>#define print_case(case_val) case case_val:printf(#case_val " ==
>%d\n",attribs[onattrib+1]);break;
>#else
>#define print_case(case_val) case case_val:break;
>#endif
>#define error_case(case_val) case case_val:printf("unsupported attrib"
>#case_val " == %d\n",attribs[onattrib+1]);break;
> print_case(GLX_FBCONFIG_ID)
> print_case(GLX_BUFFER_SIZE)
> print_case(GLX_DOUBLEBUFFER)
> print_case(GLX_AUX_BUFFERS)
> print_case(GLX_RED_SIZE)
> print_case(GLX_GREEN_SIZE)
> print_case(GLX_BLUE_SIZE)
> print_case(GLX_ALPHA_SIZE)
> print_case(GLX_DEPTH_SIZE)
> print_case(GLX_STENCIL_SIZE)
> print_case(GLX_RENDER_TYPE)
>
> error_case(GLX_LEVEL)
> error_case(GLX_STEREO)
> error_case(GLX_ACCUM_RED_SIZE)
> error_case(GLX_ACCUM_GREEN_SIZE)
> error_case(GLX_ACCUM_BLUE_SIZE)
> error_case(GLX_ACCUM_ALPHA_SIZE)
> error_case(GLX_DRAWABLE_TYPE)
> error_case(GLX_X_RENDERABLE)
> error_case(GLX_X_VISUAL_TYPE)
> error_case(GLX_CONFIG_CAVEAT)
> error_case(GLX_TRANSPARENT_TYPE)
> error_case(GLX_TRANSPARENT_INDEX_VALUE)
> error_case(GLX_TRANSPARENT_RED_VALUE)
> error_case(GLX_TRANSPARENT_GREEN_VALUE)
> error_case(GLX_TRANSPARENT_BLUE_VALUE)
> error_case(GLX_TRANSPARENT_ALPHA_VALUE)
> default: printf("unknown attrib %d ==
>%d\n",attribs[onattrib],attribs[onattrib+1]);break;
> }
> }
>}
>#endif
> *ncfgs=0;
> APPLE_GLXFBConfig** list=NULL;
>
> //loop over big ass set of crap
>//GLX_BUFFER_SIZE 0->32
>//GLX_RGBA
>//GLX_DOUBLEBUFFER
>//GLX_STEREO
>//GLX_AUX_BUFFERS 0->8
>//GLX_RED_SIZE 0->8
>//GLX_GREEN_SIZE 0->8
>//GLX_BLUE_SIZE 0->8
>//GLX_ALPHA_SIZE 0->8
>//GLX_DEPTH_SIZE 0->32
>//GLX_STENCIL_SIZE 0->16
>////GLX_ACCUM_RED_SIZE ////GLX_ACCUM_GREEN_SIZE
>////GLX_ACCUM_BLUE_SIZE
>////GLX_ACCUM_ALPHA_SIZE
> int fbconfig_id=0;
> int rgba[]={None,GLX_RGBA};
> int double_buffer[]={None,GLX_DOUBLEBUFFER};
> //int st[]={None,GLX_STEREO};
> int buff_size[]={0,1,2,4,8,16,32};
> int aux_bufs[]={0,1,2,3,4,5,6,7,8};
> //int color_size[]={0,1,2,3,4,5,6,8};//r,g,b,a
> int color_size[][4]={
> {0, 0, 0, 0},
> {1, 1, 1, 1},
> {2, 3, 2, 0},
> {2, 3, 2, 1},
> {2, 3, 2, 8},
> {3, 3, 2, 0},
> {3, 3, 2, 8},
> {4, 4, 4, 0},
> {4, 4, 4, 1},
> {4, 4, 4, 4},
> {5, 5, 5, 0},
> {5, 5, 5, 1},
> {5, 6, 5, 0},
> {5, 6, 5, 8},
> {8, 8, 8, 0},
> {8, 8, 8, 1},
> {8, 8, 8, 2},
> {8, 8, 8, 4},
> {8, 8, 8, 8},
> {10, 10, 10, 0},
> {10, 10, 10, 1},
> {10, 10, 10, 2}
> };
> int
>rgbas[]={GLX_RED_SIZE,GLX_GREEN_SIZE,GLX_BLUE_SIZE,GLX_ALPHA_SIZE};
> int depth_size[]={0,8,16,24,32};
> int stencil_size[]={0,1,8};
>
>#define foreach(array,block)\
>{\
> int on##array;\
>
>for(on##array=0;on##array<sizeof(array)/sizeof(array[0]);on##array++)\
> {\
> {block}\
> }\
>}\
>
> foreach(color_size,
> {
> foreach(depth_size,
> {
> foreach(stencil_size,
> {
> foreach(buff_size,
> {
> foreach(aux_bufs,
> {
> foreach(rgba,
> {
> foreach(double_buffer,
> {
> int _attribs[256];
> int on_Attrib=0;
> int skip=0;
> int onattrib;
> int found;
> int outval;
>
> if(rgba[onrgba]!=None)
> {
> add_attrib(rgba[onrgba]);
> find_attrib(GLX_RENDER_TYPE,found,outval);
> if(found&&outval!=GLX_RGBA_BIT)
> {
> skip=1;
> }
> }
> else
> {
> find_attrib(GLX_RENDER_TYPE,found,outval);
> if(found&&outval==GLX_RGBA_BIT)
> {
> skip=1;
> }
> }
> if(double_buffer[ondouble_buffer]!=None)
> {
> add_attrib(double_buffer[ondouble_buffer]);
> find_attrib(GLX_DOUBLEBUFFER,found,outval);
> if(found&&outval==False)
> {
> skip=1;
> }
> }
> else
> {
> find_attrib(GLX_DOUBLEBUFFER,found,outval);
> if(found&&outval==True)
> {
> skip=1;
> }
> }
> if(buff_size[onbuff_size]!=0)
> {
> add_attrib(GLX_BUFFER_SIZE);
> add_attrib(buff_size[onbuff_size]);
> find_attrib(GLX_BUFFER_SIZE,found,outval);
> if(found&&outval>buff_size[onbuff_size])
> {
> skip=1;
> }
> }
> foreach(rgbas,
> {
> if(buff_size[onbuff_size]!=0)
> {
> add_attrib(rgbas[onrgbas]);
>
>add_attrib(color_size[oncolor_size][onrgbas]);
> find_attrib(rgbas[onrgbas],found,outval);
>
>if(found&&outval>color_size[oncolor_size][onrgbas])
> {
> skip=1;
> }
> }
> })
> if(depth_size[ondepth_size]!=0)
> {
> add_attrib(GLX_DEPTH_SIZE);
> add_attrib(depth_size[ondepth_size]);
> find_attrib(GLX_DEPTH_SIZE,found,outval);
> if(found&&outval>depth_size[ondepth_size])
> {
> skip=1;
> }
> }
> if(stencil_size[onstencil_size]!=0)
> {
> add_attrib(GLX_STENCIL_SIZE);
> add_attrib(stencil_size[onstencil_size]);
> find_attrib(GLX_STENCIL_SIZE,found,outval);
> if(found&&outval>stencil_size[onstencil_size])
> {
> skip=1;
> }
> }
> if(aux_bufs[onaux_bufs]!=0)
> {
> add_attrib(GLX_AUX_BUFFERS);
> add_attrib(aux_bufs[onaux_bufs]);
> find_attrib(GLX_AUX_BUFFERS,found,outval);
> if(found&&outval>aux_bufs[onaux_bufs])
> {
> skip=1;
> }
> }
>
> add_attrib(None);
>
> find_attrib(GLX_FBCONFIG_ID,found,outval);
> if(found&&outval==fbconfig_id)
> {
> skip=0;
> }
>
> XVisualInfo* info=glXChooseVisual(dpy,screen,_attribs);
> if(info!=NULL)
> {
> if(!skip)
> {
> (*ncfgs)++;
>
>list=(APPLE_GLXFBConfig**)realloc(list,*ncfgs*sizeof(APPLE_GLXFBConfig*));
>
>list[*ncfgs-1]=(APPLE_GLXFBConfig*)malloc(sizeof(APPLE_GLXFBConfig));
> list[*ncfgs-1]->info=info;
> list[*ncfgs-1]->fbconfig_id=fbconfig_id;
> }
> fbconfig_id++;
> }
>//printf("fb: %d ncfgs: %d\n", fbconfig_id, *ncfgs);
> })
> })
> })
> })
> })
> })
> })
>//printf(" ncfgs: %d\n", *ncfgs);
> return (GLXFBConfig*)list;
>}
>int APPLE_glXGetFBConfigAttrib(Display* dpy, GLXFBConfig cfg, int attrib,
>int* val)
>{
> APPLE_GLXFBConfig* _cfg=(APPLE_GLXFBConfig*)cfg;
> if(attrib==GLX_FBCONFIG_ID)
> {
> *val=_cfg->fbconfig_id;
> return 0;
> }
> return glXGetConfig(dpy,_cfg->info,attrib,val);
>}
>XVisualInfo* APPLE_glXGetVisualFromFBConfig(Display* dpy, GLXFBConfig cfg)
>{
> APPLE_GLXFBConfig* _cfg=(APPLE_GLXFBConfig*)cfg;
> return _cfg->info;
>}
>#endif
>
140a449,451
>#ifdef __APPLE__
> opengl_handle=5;
>#else
141a453
>#endif
143a456,458
>#ifdef __APPLE__
>#define LOAD_FUNCPTR(f) p##f = f;
>#else
144a460
>#endif
150a467,471
>#ifdef __APPLE__
>pglXGetFBConfigs=APPLE_glXGetFBConfigs;
>pglXChooseFBConfig=APPLE_glXChooseFBConfig;
>pglXGetFBConfigAttrib=APPLE_glXGetFBConfigAttrib;
>#else
153a475
>#endif
159c481
< if (pglXQueryExtension(gdi_display, &event_base, &error_base) == True)
{
---
> /*if (pglXQueryExtension(gdi_display, &event_base, &error_base) ==
>True) {
164c486
< }
---
> }*/
Index: include/wine/wined3d_gl.h
===================================================================
RCS file: /home/wine/wine/include/wine/wined3d_gl.h,v
retrieving revision 1.19
diff -r1.19 wined3d_gl.h
1404a1405,1407
>#ifdef __APPLE__
> HWND hwnd;
>#endif
Index: programs/winecfg/audio.c
===================================================================
RCS file: /home/wine/wine/programs/winecfg/audio.c,v
retrieving revision 1.27
diff -r1.27 audio.c
86a87
> {"Mac OSX Core Audio", "coreaudio"},
522c523,530
< loadedAudioDrv = HeapReAlloc(GetProcessHeap(), 0, loadedAudioDrv,
(numFound + 1) * sizeof(AUDIO_DRIVER));
---
> if(numFound)
> {
> loadedAudioDrv = HeapReAlloc(GetProcessHeap(), 0, loadedAudioDrv,
>(numFound + 1) * sizeof(AUDIO_DRIVER));
> }
> else
> {
> loadedAudioDrv = HeapAlloc(GetProcessHeap(), 0,
>sizeof(AUDIO_DRIVER));
> }
More information about the wine-devel
mailing list