mesa.c

来自「Wine-20031016」· C语言 代码 · 共 1,666 行 · 第 1/5 页

C
1,666
字号
    d1->dwSize  = sizeof(*d1);    d1->dwFlags = D3DDD_COLORMODEL | D3DDD_DEVCAPS | D3DDD_TRANSFORMCAPS | D3DDD_BCLIPPING | D3DDD_LIGHTINGCAPS |	D3DDD_LINECAPS | D3DDD_TRICAPS | D3DDD_DEVICERENDERBITDEPTH | D3DDD_DEVICEZBUFFERBITDEPTH |	D3DDD_MAXBUFFERSIZE | D3DDD_MAXVERTEXCOUNT;    d1->dcmColorModel = D3DCOLOR_RGB;    d1->dwDevCaps = opengl_device_caps.dwDevCaps;    d1->dtcTransformCaps.dwSize = sizeof(D3DTRANSFORMCAPS);    d1->dtcTransformCaps.dwCaps = D3DTRANSFORMCAPS_CLIP;    d1->bClipping = TRUE;    d1->dlcLightingCaps.dwSize = sizeof(D3DLIGHTINGCAPS);    d1->dlcLightingCaps.dwCaps = D3DLIGHTCAPS_DIRECTIONAL | D3DLIGHTCAPS_PARALLELPOINT | D3DLIGHTCAPS_POINT | D3DLIGHTCAPS_SPOT;    d1->dlcLightingCaps.dwLightingModel = D3DLIGHTINGMODEL_RGB;    d1->dlcLightingCaps.dwNumLights = opengl_device_caps.dwMaxActiveLights;    d1->dpcLineCaps = opengl_device_caps.dpcLineCaps;    d1->dpcTriCaps = opengl_device_caps.dpcTriCaps;    d1->dwDeviceRenderBitDepth  = opengl_device_caps.dwDeviceRenderBitDepth;    d1->dwDeviceZBufferBitDepth = opengl_device_caps.dwDeviceZBufferBitDepth;    d1->dwMaxBufferSize = 0;    d1->dwMaxVertexCount = 65536;    d1->dwMinTextureWidth  = opengl_device_caps.dwMinTextureWidth;    d1->dwMinTextureHeight = opengl_device_caps.dwMinTextureHeight;    d1->dwMaxTextureWidth  = opengl_device_caps.dwMaxTextureWidth;    d1->dwMaxTextureHeight = opengl_device_caps.dwMaxTextureHeight;    d1->dwMinStippleWidth  = 1;    d1->dwMinStippleHeight = 1;    d1->dwMaxStippleWidth  = 32;    d1->dwMaxStippleHeight = 32;    d1->dwMaxTextureRepeat = opengl_device_caps.dwMaxTextureRepeat;    d1->dwMaxTextureAspectRatio = opengl_device_caps.dwMaxTextureAspectRatio;    d1->dwMaxAnisotropy = opengl_device_caps.dwMaxAnisotropy;    d1->dvGuardBandLeft = opengl_device_caps.dvGuardBandLeft;    d1->dvGuardBandRight = opengl_device_caps.dvGuardBandRight;    d1->dvGuardBandTop = opengl_device_caps.dvGuardBandTop;    d1->dvGuardBandBottom = opengl_device_caps.dvGuardBandBottom;    d1->dvExtentsAdjust = opengl_device_caps.dvExtentsAdjust;    d1->dwStencilCaps = opengl_device_caps.dwStencilCaps;    d1->dwFVFCaps = opengl_device_caps.dwFVFCaps;    d1->dwTextureOpCaps = opengl_device_caps.dwTextureOpCaps;    d1->wMaxTextureBlendStages = opengl_device_caps.wMaxTextureBlendStages;    d1->wMaxSimultaneousTextures = opengl_device_caps.wMaxSimultaneousTextures;}static void fill_opengl_caps_7(D3DDEVICEDESC7 *d){    *d = opengl_device_caps;}HRESULT d3ddevice_enumerate(LPD3DENUMDEVICESCALLBACK cb, LPVOID context, DWORD version){    D3DDEVICEDESC dref, d1, d2;    HRESULT ret_value;    /* Some games (Motoracer 2 demo) have the bad idea to modify the device name string.       Let's put the string in a sufficiently sized array in writable memory. */    char device_name[50];    strcpy(device_name,"direct3d");    fill_opengl_caps(&dref);    if (version > 1) {        /* It seems that enumerating the reference IID on Direct3D 1 games (AvP / Motoracer2) breaks them */	char interface_name[] = "WINE Reference Direct3DX using OpenGL";        TRACE(" enumerating OpenGL D3DDevice interface using reference IID (IID %s).\n", debugstr_guid(&IID_IDirect3DRefDevice));	d1 = dref;	d2 = dref;	ret_value = cb((LPIID) &IID_IDirect3DRefDevice, interface_name, device_name, &d1, &d2, context);	if (ret_value != D3DENUMRET_OK)	    return ret_value;    }    {	char interface_name[] = "WINE Direct3DX using OpenGL";	TRACE(" enumerating OpenGL D3DDevice interface (IID %s).\n", debugstr_guid(&IID_D3DDEVICE_OpenGL));	d1 = dref;	d2 = dref;	ret_value = cb((LPIID) &IID_D3DDEVICE_OpenGL, interface_name, device_name, &d1, &d2, context);	if (ret_value != D3DENUMRET_OK)	    return ret_value;    }    return D3DENUMRET_OK;}HRESULT d3ddevice_enumerate7(LPD3DENUMDEVICESCALLBACK7 cb, LPVOID context){    D3DDEVICEDESC7 ddesc;    char interface_name[] = "WINE Direct3D7 using OpenGL";    char device_name[] = "Wine D3D7 device";    fill_opengl_caps_7(&ddesc);        TRACE(" enumerating OpenGL D3DDevice7 interface.\n");        return cb(interface_name, device_name, &ddesc, context);}ULONG WINAPIGL_IDirect3DDeviceImpl_7_3T_2T_1T_Release(LPDIRECT3DDEVICE7 iface){    ICOM_THIS_FROM(IDirect3DDeviceImpl, IDirect3DDevice7, iface);    IDirect3DDeviceGLImpl *glThis = (IDirect3DDeviceGLImpl *) This;        TRACE("(%p/%p)->() decrementing from %lu.\n", This, iface, This->ref);    if (!--(This->ref)) {        int i;	IDirectDrawSurfaceImpl *surface = This->surface, *surf;		/* Release texture associated with the device */ 	for (i = 0; i < MAX_TEXTURES; i++) {	    if (This->current_texture[i] != NULL)	        IDirectDrawSurface7_Release(ICOM_INTERFACE(This->current_texture[i], IDirectDrawSurface7));	    HeapFree(GetProcessHeap(), 0, This->tex_mat[i]);	}	/* Look for the front buffer and override its surface's Flip method (if in double buffering) */	for (surf = surface; surf != NULL; surf = surf->surface_owner) {	    if ((surf->surface_desc.ddsCaps.dwCaps&(DDSCAPS_FLIP|DDSCAPS_FRONTBUFFER)) == (DDSCAPS_FLIP|DDSCAPS_FRONTBUFFER)) {	        surf->aux_ctx  = NULL;		surf->aux_data = NULL;		surf->aux_flip = NULL;		break;	    }	}	for (surf = surface; surf != NULL; surf = surf->surface_owner) {	    IDirectDrawSurfaceImpl *surf2;	    for (surf2 = surf; surf2->prev_attached != NULL; surf2 = surf2->prev_attached) ;	    for (; surf2 != NULL; surf2 = surf2->next_attached) {	        if (((surf2->surface_desc.ddsCaps.dwCaps & (DDSCAPS_3DDEVICE)) == (DDSCAPS_3DDEVICE)) &&		    ((surf2->surface_desc.ddsCaps.dwCaps & (DDSCAPS_ZBUFFER)) != (DDSCAPS_ZBUFFER))) {		    /* Override the Lock / Unlock function for all these surfaces */		    surf2->lock_update = surf2->lock_update_prev;		    surf2->unlock_update = surf2->unlock_update_prev;		    /* And install also the blt / bltfast overrides */		    surf2->aux_blt = NULL;		    surf2->aux_bltfast = NULL;		}		surf2->d3ddevice = NULL;	    }	}		/* And warn the D3D object that this device is no longer active... */	This->d3d->d3d_removed_device(This->d3d, This);	HeapFree(GetProcessHeap(), 0, This->world_mat);	HeapFree(GetProcessHeap(), 0, This->view_mat);	HeapFree(GetProcessHeap(), 0, This->proj_mat);	if (glThis->surface_ptr)	    HeapFree(GetProcessHeap(), 0, glThis->surface_ptr);	DeleteCriticalSection(&(This->crit));		ENTER_GL();	if (glThis->unlock_tex)	    glDeleteTextures(1, &(glThis->unlock_tex));	glXDestroyContext(glThis->display, glThis->gl_context);	LEAVE_GL();	HeapFree(GetProcessHeap(), 0, This->clipping_planes);	HeapFree(GetProcessHeap(), 0, This);	return 0;    }    return This->ref;}HRESULT WINAPIGL_IDirect3DDeviceImpl_3_2T_1T_GetCaps(LPDIRECT3DDEVICE3 iface,				       LPD3DDEVICEDESC lpD3DHWDevDesc,				       LPD3DDEVICEDESC lpD3DHELDevDesc){    ICOM_THIS_FROM(IDirect3DDeviceImpl, IDirect3DDevice3, iface);    D3DDEVICEDESC desc;    DWORD dwSize;    TRACE("(%p/%p)->(%p,%p)\n", This, iface, lpD3DHWDevDesc, lpD3DHELDevDesc);    fill_opengl_caps(&desc);    dwSize = lpD3DHWDevDesc->dwSize;    memset(lpD3DHWDevDesc, 0, dwSize);    memcpy(lpD3DHWDevDesc, &desc, (dwSize <= desc.dwSize ? dwSize : desc.dwSize));    dwSize = lpD3DHELDevDesc->dwSize;    memset(lpD3DHELDevDesc, 0, dwSize);    memcpy(lpD3DHELDevDesc, &desc, (dwSize <= desc.dwSize ? dwSize : desc.dwSize));    TRACE(" returning caps : (no dump function yet)\n");    return DD_OK;}static HRESULT enum_texture_format_OpenGL(LPD3DENUMTEXTUREFORMATSCALLBACK cb_1,					  LPD3DENUMPIXELFORMATSCALLBACK cb_2,					  LPVOID context){    DDSURFACEDESC sdesc;    LPDDPIXELFORMAT pformat;    /* Do the texture enumeration */    sdesc.dwSize = sizeof(DDSURFACEDESC);    sdesc.dwFlags = DDSD_PIXELFORMAT | DDSD_CAPS;    sdesc.ddsCaps.dwCaps = DDSCAPS_TEXTURE;    pformat = &(sdesc.ddpfPixelFormat);    pformat->dwSize = sizeof(DDPIXELFORMAT);    pformat->dwFourCC = 0;    TRACE("Enumerating GL_RGBA unpacked (32)\n");    pformat->dwFlags = DDPF_RGB | DDPF_ALPHAPIXELS;    pformat->u1.dwRGBBitCount = 32;    pformat->u2.dwRBitMask =        0x00FF0000;    pformat->u3.dwGBitMask =        0x0000FF00;    pformat->u4.dwBBitMask =        0x000000FF;    pformat->u5.dwRGBAlphaBitMask = 0xFF000000;    if (cb_1) if (cb_1(&sdesc , context) == 0) return DD_OK;    if (cb_2) if (cb_2(pformat, context) == 0) return DD_OK;    TRACE("Enumerating GL_RGB unpacked (32)\n");    pformat->dwFlags = DDPF_RGB;    pformat->u1.dwRGBBitCount = 32;    pformat->u2.dwRBitMask =        0x00FF0000;    pformat->u3.dwGBitMask =        0x0000FF00;    pformat->u4.dwBBitMask =        0x000000FF;    pformat->u5.dwRGBAlphaBitMask = 0x00000000;    if (cb_1) if (cb_1(&sdesc , context) == 0) return DD_OK;    if (cb_2) if (cb_2(pformat, context) == 0) return DD_OK;        TRACE("Enumerating GL_RGB unpacked (24)\n");    pformat->dwFlags = DDPF_RGB;    pformat->u1.dwRGBBitCount = 24;    pformat->u2.dwRBitMask = 0x00FF0000;    pformat->u3.dwGBitMask = 0x0000FF00;    pformat->u4.dwBBitMask = 0x000000FF;    pformat->u5.dwRGBAlphaBitMask = 0x00000000;    if (cb_1) if (cb_1(&sdesc , context) == 0) return DD_OK;    if (cb_2) if (cb_2(pformat, context) == 0) return DD_OK;    /* Note : even if this is an 'emulated' texture format, it needs to be first              as some dumb applications seem to rely on that. */    TRACE("Enumerating GL_RGBA packed GL_UNSIGNED_SHORT_1_5_5_5 (ARGB) (16)\n");    pformat->dwFlags = DDPF_RGB | DDPF_ALPHAPIXELS;    pformat->u1.dwRGBBitCount = 16;    pformat->u2.dwRBitMask =        0x00007C00;    pformat->u3.dwGBitMask =        0x000003E0;    pformat->u4.dwBBitMask =        0x0000001F;    pformat->u5.dwRGBAlphaBitMask = 0x00008000;    if (cb_1) if (cb_1(&sdesc , context) == 0) return DD_OK;    if (cb_2) if (cb_2(pformat, context) == 0) return DD_OK;    TRACE("Enumerating GL_RGBA packed GL_UNSIGNED_SHORT_4_4_4_4 (ARGB) (16)\n");    pformat->dwFlags = DDPF_RGB | DDPF_ALPHAPIXELS;    pformat->u1.dwRGBBitCount = 16;    pformat->u2.dwRBitMask =        0x00000F00;    pformat->u3.dwGBitMask =        0x000000F0;    pformat->u4.dwBBitMask =        0x0000000F;    pformat->u5.dwRGBAlphaBitMask = 0x0000F000;    if (cb_1) if (cb_1(&sdesc , context) == 0) return DD_OK;    if (cb_2) if (cb_2(pformat, context) == 0) return DD_OK;    TRACE("Enumerating GL_RGB packed GL_UNSIGNED_SHORT_5_6_5 (16)\n");    pformat->dwFlags = DDPF_RGB;    pformat->u1.dwRGBBitCount = 16;    pformat->u2.dwRBitMask = 0x0000F800;    pformat->u3.dwGBitMask = 0x000007E0;    pformat->u4.dwBBitMask = 0x0000001F;    pformat->u5.dwRGBAlphaBitMask = 0x00000000;    if (cb_1) if (cb_1(&sdesc , context) == 0) return DD_OK;    if (cb_2) if (cb_2(pformat, context) == 0) return DD_OK;    TRACE("Enumerating GL_RGB packed GL_UNSIGNED_SHORT_5_5_5 (16)\n");    pformat->dwFlags = DDPF_RGB;    pformat->u1.dwRGBBitCount = 16;    pformat->u2.dwRBitMask = 0x00007C00;    pformat->u3.dwGBitMask = 0x000003E0;    pformat->u4.dwBBitMask = 0x0000001F;    pformat->u5.dwRGBAlphaBitMask = 0x00000000;    if (cb_1) if (cb_1(&sdesc , context) == 0) return DD_OK;    if (cb_2) if (cb_2(pformat, context) == 0) return DD_OK;    #if 0    /* This is a compromise : some games choose the first 16 bit texture format with alpha they       find enumerated, others the last one. And both want to have the ARGB one.              So basically, forget our OpenGL roots and do not even enumerate our RGBA ones.    */    /* See argument about the RGBA format for 'packed' texture formats */    TRACE("Enumerating GL_RGBA unpacked (32)\n");    pformat->dwFlags = DDPF_RGB | DDPF_ALPHAPIXELS;    pformat->u1.dwRGBBitCount = 32;    pformat->u2.dwRBitMask =        0xFF000000;    pformat->u3.dwGBitMask =        0x00FF0000;    pformat->u4.dwBBitMask =        0x0000FF00;    pformat->u5.dwRGBAlphaBitMask = 0x000000FF;    if (cb_1) if (cb_1(&sdesc , context) == 0) return DD_OK;    if (cb_2) if (cb_2(pformat, context) == 0) return DD_OK;        TRACE("Enumerating GL_RGBA packed GL_UNSIGNED_SHORT_4_4_4_4 (16)\n");    pformat->dwFlags = DDPF_RGB | DDPF_ALPHAPIXELS;    pformat->u1.dwRGBBitCount = 16;    pformat->u2.dwRBitMask =        0x0000F000;    pformat->u3.dwGBitMask =        0x00000F00;    pformat->u4.dwBBitMask =        0x000000F0;    pformat->u5.dwRGBAlphaBitMask = 0x0000000F;    if (cb_1) if (cb_1(&sdesc , context) == 0) return DD_OK;    if (cb_2) if (cb_2(pformat, context) == 0) return DD_OK;    TRACE("Enumerating GL_RGBA packed GL_UNSIGNED_SHORT_5_5_5_1 (16)\n");    pformat->dwFlags = DDPF_RGB | DDPF_ALPHAPIXELS;    pformat->u1.dwRGBBitCount = 16;    pformat->u2.dwRBitMask =        0x0000F800;    pformat->u3.dwGBitMask =        0x000007C0;    pformat->u4.dwBBitMask =        0x0000003E;    pformat->u5.dwRGBAlphaBitMask = 0x00000001;    if (cb_1) if (cb_1(&sdesc , context) == 0) return DD_OK;    if (cb_2) if (cb_2(pformat, context) == 0) return DD_OK;#endif    TRACE("Enumerating GL_RGB packed GL_UNSIGNED_BYTE_3_3_2 (8)\n");    pformat->dwFlags = DDPF_RGB;    pformat->u1.dwRGBBitCount = 8;    pformat->u2.dwRBitMask =        0x000000E0;    pformat->u3.dwGBitMask =        0x0000001C;    pformat->u4.dwBBitMask =        0x00000003;    pformat->u5.dwRGBAlphaBitMask = 0x00000000;    if (cb_1) if (cb_1(&sdesc , context) == 0) return DD_OK;    if (cb_2) if (cb_2(pformat, context) == 0) return DD_OK;    TRACE("Enumerating Paletted (8)\n");    pformat->dwFlags = DDPF_PALETTEINDEXED8;    pformat->u1.dwRGBBitCount = 8;    pformat->u2.dwRBitMask =        0x00000000;    pformat->u3.dwGBitMask =        0x00000000;    pformat->u4.dwBBitMask =        0x00000000;    pformat->u5.dwRGBAlphaBitMask = 0x00000000;    if (cb_1) if (cb_1(&sdesc , context) == 0) return DD_OK;    if (cb_2) if (cb_2(pformat, context) == 0) return DD_OK;

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?