mesa.c

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

C
1,666 行
字号
    if (glThis->current_active_tex_unit != GL_TEXTURE0_WINE) {	GL_extensions.glActiveTexture(GL_TEXTURE0_WINE);	glThis->current_active_tex_unit = GL_TEXTURE0_WINE;    }    draw_primitive_handle_GL_state(This,				   (d3dvtVertexType & D3DFVF_POSITION_MASK) != D3DFVF_XYZ,				   vertex_lighted);    draw_primitive_start_GL(d3dptPrimitiveType);    /* Some fast paths first before the generic case.... */    if ((d3dvtVertexType == D3DFVF_VERTEX) && (num_active_stages <= 1)) {	int index;		for (index = 0; index < dwIndexCount; index++) {	    int i = (dwIndices == NULL) ? index : dwIndices[index];	    D3DVALUE *normal = 	      (D3DVALUE *) (((char *) lpD3DDrawPrimStrideData->normal.lpvData) + i * lpD3DDrawPrimStrideData->normal.dwStride);	    D3DVALUE *tex_coord =	      (D3DVALUE *) (((char *) lpD3DDrawPrimStrideData->textureCoords[0].lpvData) + i * lpD3DDrawPrimStrideData->textureCoords[0].dwStride);	    D3DVALUE *position =	      (D3DVALUE *) (((char *) lpD3DDrawPrimStrideData->position.lpvData) + i * lpD3DDrawPrimStrideData->position.dwStride);	    	    handle_normal(normal);	    handle_texture(tex_coord);	    handle_xyz(position);	    	    TRACE_(ddraw_geom)(" %f %f %f / %f %f %f (%f %f)\n",			       position[0], position[1], position[2],			       normal[0], normal[1], normal[2],			       tex_coord[0], tex_coord[1]);	}    } else if ((d3dvtVertexType == D3DFVF_TLVERTEX) && (num_active_stages <= 1)) {	int index;		for (index = 0; index < dwIndexCount; index++) {	    int i = (dwIndices == NULL) ? index : dwIndices[index];	    DWORD *color_d = 	      (DWORD *) (((char *) lpD3DDrawPrimStrideData->diffuse.lpvData) + i * lpD3DDrawPrimStrideData->diffuse.dwStride);	    DWORD *color_s = 	      (DWORD *) (((char *) lpD3DDrawPrimStrideData->specular.lpvData) + i * lpD3DDrawPrimStrideData->specular.dwStride);	    D3DVALUE *tex_coord =	      (D3DVALUE *) (((char *) lpD3DDrawPrimStrideData->textureCoords[0].lpvData) + i * lpD3DDrawPrimStrideData->textureCoords[0].dwStride);	    D3DVALUE *position =	      (D3DVALUE *) (((char *) lpD3DDrawPrimStrideData->position.lpvData) + i * lpD3DDrawPrimStrideData->position.dwStride);	    handle_diffuse_and_specular(&(This->state_block), glThis->fog_table, color_d, color_s, TRUE);	    handle_texture(tex_coord);	    handle_xyzrhw(position);	    TRACE_(ddraw_geom)(" %f %f %f %f / %02lx %02lx %02lx %02lx - %02lx %02lx %02lx %02lx (%f %f)\n",			       position[0], position[1], position[2], position[3], 			       (*color_d >> 16) & 0xFF,			       (*color_d >>  8) & 0xFF,			       (*color_d >>  0) & 0xFF,			       (*color_d >> 24) & 0xFF,			       (*color_s >> 16) & 0xFF,			       (*color_s >>  8) & 0xFF,			       (*color_s >>  0) & 0xFF,			       (*color_s >> 24) & 0xFF,			       tex_coord[0], tex_coord[1]);	}     } else if (((d3dvtVertexType & D3DFVF_POSITION_MASK) == D3DFVF_XYZ) ||	       ((d3dvtVertexType & D3DFVF_POSITION_MASK) == D3DFVF_XYZRHW)) {        /* This is the 'slow path' but that should support all possible vertex formats out there...	   Note that people should write a fast path for all vertex formats out there...	*/  	int index;	int num_tex_index = ((d3dvtVertexType & D3DFVF_TEXCOUNT_MASK) >> D3DFVF_TEXCOUNT_SHIFT);	static const D3DVALUE no_index[] = { 0.0, 0.0, 0.0, 0.0 };	  	for (index = 0; index < dwIndexCount; index++) {	    int i = (dwIndices == NULL) ? index : dwIndices[index];	    int tex_stage;	    if (d3dvtVertexType & D3DFVF_NORMAL) { 	        D3DVALUE *normal = 		  (D3DVALUE *) (((char *) lpD3DDrawPrimStrideData->normal.lpvData) + i * lpD3DDrawPrimStrideData->normal.dwStride);	    		handle_normal(normal);	    }	    if ((d3dvtVertexType & (D3DFVF_DIFFUSE|D3DFVF_SPECULAR)) == (D3DFVF_DIFFUSE|D3DFVF_SPECULAR)) {	        DWORD *color_d = 		  (DWORD *) (((char *) lpD3DDrawPrimStrideData->diffuse.lpvData) + i * lpD3DDrawPrimStrideData->diffuse.dwStride);		DWORD *color_s = 		  (DWORD *) (((char *) lpD3DDrawPrimStrideData->specular.lpvData) + i * lpD3DDrawPrimStrideData->specular.dwStride);		handle_diffuse_and_specular(&(This->state_block), glThis->fog_table, color_d, color_s, vertex_lighted);	    } else {	        if (d3dvtVertexType & D3DFVF_SPECULAR) { 		    DWORD *color_s = 		      (DWORD *) (((char *) lpD3DDrawPrimStrideData->specular.lpvData) + i * lpD3DDrawPrimStrideData->specular.dwStride);		    handle_specular(&(This->state_block), color_s, vertex_lighted);		} else if (d3dvtVertexType & D3DFVF_DIFFUSE) {		    DWORD *color_d = 		      (DWORD *) (((char *) lpD3DDrawPrimStrideData->diffuse.lpvData) + i * lpD3DDrawPrimStrideData->diffuse.dwStride);		    handle_diffuse(&(This->state_block), color_d, vertex_lighted);		}	    }	    for (tex_stage = 0; tex_stage < num_active_stages; tex_stage++) {	        int tex_index = This->state_block.texture_stage_state[tex_stage][D3DTSS_TEXCOORDINDEX - 1] & 0x0000FFFF;		if (tex_index >= num_tex_index) {		    handle_textures((D3DVALUE *) no_index, tex_stage);		 } else {		     D3DVALUE *tex_coord =		       (D3DVALUE *) (((char *) lpD3DDrawPrimStrideData->textureCoords[tex_index].lpvData) + 				     i * lpD3DDrawPrimStrideData->textureCoords[tex_index].dwStride);		     handle_textures(tex_coord, tex_stage);		}	    }	    	    if ((d3dvtVertexType & D3DFVF_POSITION_MASK) == D3DFVF_XYZ) {	        D3DVALUE *position =		  (D3DVALUE *) (((char *) lpD3DDrawPrimStrideData->position.lpvData) + i * lpD3DDrawPrimStrideData->position.dwStride);		handle_xyz(position);	    } else if ((d3dvtVertexType & D3DFVF_POSITION_MASK) == D3DFVF_XYZRHW) {	        D3DVALUE *position =		  (D3DVALUE *) (((char *) lpD3DDrawPrimStrideData->position.lpvData) + i * lpD3DDrawPrimStrideData->position.dwStride);		handle_xyzrhw(position);	    }	    if (TRACE_ON(ddraw_geom)) {	        int tex_index;		if ((d3dvtVertexType & D3DFVF_POSITION_MASK) == D3DFVF_XYZ) {		    D3DVALUE *position =		      (D3DVALUE *) (((char *) lpD3DDrawPrimStrideData->position.lpvData) + i * lpD3DDrawPrimStrideData->position.dwStride);		    TRACE_(ddraw_geom)(" %f %f %f", position[0], position[1], position[2]);		} else if ((d3dvtVertexType & D3DFVF_POSITION_MASK) == D3DFVF_XYZRHW) {		    D3DVALUE *position =		      (D3DVALUE *) (((char *) lpD3DDrawPrimStrideData->position.lpvData) + i * lpD3DDrawPrimStrideData->position.dwStride);		    TRACE_(ddraw_geom)(" %f %f %f %f", position[0], position[1], position[2], position[3]);		}	        if (d3dvtVertexType & D3DFVF_NORMAL) { 		    D3DVALUE *normal = 		      (D3DVALUE *) (((char *) lpD3DDrawPrimStrideData->normal.lpvData) + i * lpD3DDrawPrimStrideData->normal.dwStride);	    		    TRACE_(ddraw_geom)(" / %f %f %f", normal[0], normal[1], normal[2]);		}		if (d3dvtVertexType & D3DFVF_DIFFUSE) {		    DWORD *color_d = 		      (DWORD *) (((char *) lpD3DDrawPrimStrideData->diffuse.lpvData) + i * lpD3DDrawPrimStrideData->diffuse.dwStride);		    TRACE_(ddraw_geom)(" / %02lx %02lx %02lx %02lx",				       (*color_d >> 16) & 0xFF,				       (*color_d >>  8) & 0xFF,				       (*color_d >>  0) & 0xFF,				       (*color_d >> 24) & 0xFF);		}	        if (d3dvtVertexType & D3DFVF_SPECULAR) { 		    DWORD *color_s = 		      (DWORD *) (((char *) lpD3DDrawPrimStrideData->specular.lpvData) + i * lpD3DDrawPrimStrideData->specular.dwStride);		    TRACE_(ddraw_geom)(" / %02lx %02lx %02lx %02lx",				       (*color_s >> 16) & 0xFF,				       (*color_s >>  8) & 0xFF,				       (*color_s >>  0) & 0xFF,				       (*color_s >> 24) & 0xFF);		}		for (tex_index = 0; tex_index < ((d3dvtVertexType & D3DFVF_TEXCOUNT_MASK) >> D3DFVF_TEXCOUNT_SHIFT); tex_index++) {                    D3DVALUE *tex_coord =		      (D3DVALUE *) (((char *) lpD3DDrawPrimStrideData->textureCoords[tex_index].lpvData) + 				    i * lpD3DDrawPrimStrideData->textureCoords[tex_index].dwStride);		    TRACE_(ddraw_geom)(" / %f %f", tex_coord[0], tex_coord[1]);		}		TRACE_(ddraw_geom)("\n");	    }	}    } else {        ERR(" matrix weighting not handled yet....\n");    }        glEnd();    /* Whatever the case, disable the color material stuff */    glDisable(GL_COLOR_MATERIAL);    LEAVE_GL();    TRACE("End\n");        LeaveCriticalSection(&(This->crit));}HRESULT WINAPIGL_IDirect3DDeviceImpl_7_3T_DrawPrimitive(LPDIRECT3DDEVICE7 iface,					  D3DPRIMITIVETYPE d3dptPrimitiveType,					  DWORD d3dvtVertexType,					  LPVOID lpvVertices,					  DWORD dwVertexCount,					  DWORD dwFlags){    ICOM_THIS_FROM(IDirect3DDeviceImpl, IDirect3DDevice7, iface);    D3DDRAWPRIMITIVESTRIDEDDATA strided;    TRACE("(%p/%p)->(%08x,%08lx,%p,%08lx,%08lx)\n", This, iface, d3dptPrimitiveType, d3dvtVertexType, lpvVertices, dwVertexCount, dwFlags);    if (TRACE_ON(ddraw)) {        TRACE(" - flags : "); dump_DPFLAGS(dwFlags);    }    convert_FVF_to_strided_data(d3dvtVertexType, lpvVertices, &strided, 0);    draw_primitive_strided(This, d3dptPrimitiveType, d3dvtVertexType, &strided, dwVertexCount, NULL, dwVertexCount, dwFlags);        return DD_OK;}HRESULT WINAPIGL_IDirect3DDeviceImpl_7_3T_DrawIndexedPrimitive(LPDIRECT3DDEVICE7 iface,						 D3DPRIMITIVETYPE d3dptPrimitiveType,						 DWORD d3dvtVertexType,						 LPVOID lpvVertices,						 DWORD dwVertexCount,						 LPWORD dwIndices,						 DWORD dwIndexCount,						 DWORD dwFlags){    ICOM_THIS_FROM(IDirect3DDeviceImpl, IDirect3DDevice7, iface);    D3DDRAWPRIMITIVESTRIDEDDATA strided;    TRACE("(%p/%p)->(%08x,%08lx,%p,%08lx,%p,%08lx,%08lx)\n", This, iface, d3dptPrimitiveType, d3dvtVertexType, lpvVertices, dwVertexCount, dwIndices, dwIndexCount, dwFlags);    if (TRACE_ON(ddraw)) {        TRACE(" - flags : "); dump_DPFLAGS(dwFlags);    }    convert_FVF_to_strided_data(d3dvtVertexType, lpvVertices, &strided, 0);    draw_primitive_strided(This, d3dptPrimitiveType, d3dvtVertexType, &strided, dwVertexCount, dwIndices, dwIndexCount, dwFlags);        return DD_OK;}HRESULT WINAPIGL_IDirect3DDeviceImpl_7_3T_DrawPrimitiveStrided(LPDIRECT3DDEVICE7 iface,                                                   D3DPRIMITIVETYPE d3dptPrimitiveType,                                                   DWORD dwVertexType,                                                   LPD3DDRAWPRIMITIVESTRIDEDDATA lpD3DDrawPrimStrideData,                                                   DWORD dwVertexCount,                                                   DWORD dwFlags){    ICOM_THIS_FROM(IDirect3DDeviceImpl, IDirect3DDevice7, iface);    TRACE("(%p/%p)->(%08x,%08lx,%p,%08lx,%08lx)\n", This, iface, d3dptPrimitiveType, dwVertexType, lpD3DDrawPrimStrideData, dwVertexCount, dwFlags);    if (TRACE_ON(ddraw)) {        TRACE(" - flags : "); dump_DPFLAGS(dwFlags);    }    draw_primitive_strided(This, d3dptPrimitiveType, dwVertexType, lpD3DDrawPrimStrideData, dwVertexCount, NULL, dwVertexCount, dwFlags);    return DD_OK;}HRESULT WINAPIGL_IDirect3DDeviceImpl_7_3T_DrawIndexedPrimitiveStrided(LPDIRECT3DDEVICE7 iface,                                                          D3DPRIMITIVETYPE d3dptPrimitiveType,                                                          DWORD dwVertexType,                                                          LPD3DDRAWPRIMITIVESTRIDEDDATA lpD3DDrawPrimStrideData,                                                          DWORD dwVertexCount,                                                          LPWORD lpIndex,                                                          DWORD dwIndexCount,                                                          DWORD dwFlags){    ICOM_THIS_FROM(IDirect3DDeviceImpl, IDirect3DDevice7, iface);    TRACE("(%p/%p)->(%08x,%08lx,%p,%08lx,%p,%08lx,%08lx)\n", This, iface, d3dptPrimitiveType, dwVertexType, lpD3DDrawPrimStrideData, dwVertexCount, lpIndex, dwIndexCount, dwFlags);    if (TRACE_ON(ddraw)) {        TRACE(" - flags : "); dump_DPFLAGS(dwFlags);    }    draw_primitive_strided(This, d3dptPrimitiveType, dwVertexType, lpD3DDrawPrimStrideData, dwVertexCount, lpIndex, dwIndexCount, dwFlags);    return DD_OK;}HRESULT WINAPIGL_IDirect3DDeviceImpl_7_3T_DrawPrimitiveVB(LPDIRECT3DDEVICE7 iface,					    D3DPRIMITIVETYPE d3dptPrimitiveType,					    LPDIRECT3DVERTEXBUFFER7 lpD3DVertexBuf,					    DWORD dwStartVertex,					    DWORD dwNumVertices,					    DWORD dwFlags){    ICOM_THIS_FROM(IDirect3DDeviceImpl, IDirect3DDevice7, iface);    IDirect3DVertexBufferImpl *vb_impl = ICOM_OBJECT(IDirect3DVertexBufferImpl, IDirect3DVertexBuffer7, lpD3DVertexBuf);    D3DDRAWPRIMITIVESTRIDEDDATA strided;    TRACE("(%p/%p)->(%08x,%p,%08lx,%08lx,%08lx)\n", This, iface, d3dptPrimitiveType, lpD3DVertexBuf, dwStartVertex, dwNumVertices, dwFlags);    if (TRACE_ON(ddraw)) {        TRACE(" - flags : "); dump_DPFLAGS(dwFlags);    }    if (vb_impl->processed == TRUE) {        IDirect3DVertexBufferGLImpl *vb_glimp = (IDirect3DVertexBufferGLImpl *) vb_impl;	IDirect3DDeviceGLImpl *glThis = (IDirect3DDeviceGLImpl *) This;	glThis->transform_state = GL_TRANSFORM_VERTEXBUFFER;	This->set_matrices(This, VIEWMAT_CHANGED|WORLDMAT_CHANGED|PROJMAT_CHANGED,			   &(vb_glimp->world_mat), &(vb_glimp->view_mat), &(vb_glimp->proj_mat));	convert_FVF_to_strided_data(vb_glimp->dwVertexTypeDesc, vb_glimp->vertices, &strided, dwStartVertex);	draw_primitive_strided(This, d3dptPrimitiveType, vb_glimp->dwVertexTypeDesc, &strided, dwNumVertices, NULL, dwNumVertices, dwFlags);    } else {        convert_FVF_to_strided_data(vb_impl->desc.dwFVF, vb_impl->vertices, &strided, dwStartVertex);	draw_primitive_strided(This, d3dptPrimitiveType, vb_impl->desc.dwFVF, &strided, dwNumVertices, NULL, dwNumVertices, dwFlags);    }    return DD_OK;}HRESULT WINAPIGL_IDirect3DDeviceImpl_7_3T_DrawIndexedPrimitiveVB(LPDIRECT3DDEVICE7 iface,						   D3DPRIMITIVETYPE d3dptPrimitiveType,						   LPDIRECT3DVERTEXBUFFER7 lpD3DVertexBuf,						   DWORD dwStartVertex,						   DWORD dwNumVertices,						   LPWORD lpwIndices,						   DWORD dwIndexCount,						   DWORD dwFlags){    ICOM_THIS_FROM(IDirect3DDeviceImpl, IDirect3DDevice7, iface);    IDirect3DVertexBufferImpl *vb_impl = ICOM_OBJECT(IDirect3DVertexBufferImpl, IDirect3DVertexBuffer7, lpD3DVertexBuf);    D3DDRAWPRIMITIVESTRIDEDDATA strided;        TRACE("(%p/%p)->(%08x,%p,%08lx,%08lx,%p,%08lx,%08lx)\n", This, iface, d3dptPrimitiveType, lpD3DVertexBuf, dwStartVertex, dwNumVertices, lpwIndices, dwIndexCount, dwFlags);    if (TRACE_ON(ddraw)) {        TRACE(" - flags : "); dump_DPFLAGS(dwFlags);    }    if (vb_impl->processed == TRUE) {        IDirect3DVertexBufferGLImpl *vb_glimp = (IDirect3DVertexBufferGLImpl *) vb_impl;	IDirect3DDeviceGLImpl *glThis = (IDirect3DDeviceGLImpl *) This;	glThis->transform_state = GL_TRANSFORM_VERTEXBUFFER;	This->set_matrices(This, VIEWMAT_CHANGED|WORLDMAT_CHANGED|PROJMAT_CHANGED,			   &(vb_glimp->world_mat), &(vb_glimp->view_mat), &(vb_glimp->proj_mat));	convert_FVF_to_strided_data(vb_glimp->dwVertexTypeDesc, vb_glimp->vertices, &strided, dwStartV

⌨️ 快捷键说明

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