[D3D 38] Viewports imrpovements
Lionel Ulmer
lionel.ulmer at free.fr
Mon Dec 23 12:24:57 CST 2002
Changelog:
Support viewports the D3D7 way
--
Lionel Ulmer - http://www.bbrox.org/
-------------- next part --------------
--- /home/ulmer/Wine/wine_base//dlls/ddraw/d3ddevice/main.c 2002-12-23 15:30:02.000000000 +0100
+++ /home/ulmer/Wine/wine_work//dlls/ddraw/d3ddevice/main.c 2002-12-23 16:47:22.000000000 +0100
@@ -220,7 +220,19 @@
LPD3DVIEWPORT7 lpData)
{
ICOM_THIS_FROM(IDirect3DDeviceImpl, IDirect3DDevice7, iface);
- FIXME("(%p/%p)->(%p): stub!\n", This, iface, lpData);
+ TRACE("(%p/%p)->(%p)\n", This, iface, lpData);
+
+ if (TRACE_ON(ddraw)) {
+ TRACE(" viewport is : \n");
+ TRACE(" - dwX = %ld dwY = %ld\n",
+ lpData->dwX, lpData->dwY);
+ TRACE(" - dwWidth = %ld dwHeight = %ld\n",
+ lpData->dwWidth, lpData->dwHeight);
+ TRACE(" - dvMinZ = %f dvMaxZ = %f\n",
+ lpData->dvMinZ, lpData->dvMaxZ);
+ }
+ This->active_viewport = *lpData;
+
return DD_OK;
}
@@ -239,7 +251,20 @@
LPD3DVIEWPORT7 lpData)
{
ICOM_THIS_FROM(IDirect3DDeviceImpl, IDirect3DDevice7, iface);
- FIXME("(%p/%p)->(%p): stub!\n", This, iface, lpData);
+ TRACE("(%p/%p)->(%p)\n", This, iface, lpData);
+
+ *lpData = This->active_viewport;
+
+ if (TRACE_ON(ddraw)) {
+ TRACE(" returning viewport : \n");
+ TRACE(" - dwX = %ld dwY = %ld\n",
+ lpData->dwX, lpData->dwY);
+ TRACE(" - dwWidth = %ld dwHeight = %ld\n",
+ lpData->dwWidth, lpData->dwHeight);
+ TRACE(" - dvMinZ = %f dvMaxZ = %f\n",
+ lpData->dvMinZ, lpData->dvMaxZ);
+ }
+
return DD_OK;
}
@@ -703,6 +728,23 @@
This->current_viewport->active_device = This;
This->current_viewport->activate(This->current_viewport);
+ /* And copy the values in the structure used by the device */
+ if (This->current_viewport->use_vp2) {
+ This->active_viewport.dwX = This->current_viewport->viewports.vp2.dwX;
+ This->active_viewport.dwY = This->current_viewport->viewports.vp2.dwY;
+ This->active_viewport.dwHeight = This->current_viewport->viewports.vp2.dwHeight;
+ This->active_viewport.dwWidth = This->current_viewport->viewports.vp2.dwWidth;
+ This->active_viewport.dvMinZ = This->current_viewport->viewports.vp2.dvMinZ;
+ This->active_viewport.dvMaxZ = This->current_viewport->viewports.vp2.dvMaxZ;
+ } else {
+ This->active_viewport.dwX = This->current_viewport->viewports.vp1.dwX;
+ This->active_viewport.dwY = This->current_viewport->viewports.vp1.dwY;
+ This->active_viewport.dwHeight = This->current_viewport->viewports.vp1.dwHeight;
+ This->active_viewport.dwWidth = This->current_viewport->viewports.vp1.dwWidth;
+ This->active_viewport.dvMinZ = This->current_viewport->viewports.vp1.dvMinZ;
+ This->active_viewport.dvMaxZ = This->current_viewport->viewports.vp1.dvMaxZ;
+ }
+
return DD_OK;
}
--- /home/ulmer/Wine/wine_base//dlls/ddraw/d3ddevice/mesa.c 2002-12-23 15:30:02.000000000 +0100
+++ /home/ulmer/Wine/wine_work//dlls/ddraw/d3ddevice/mesa.c 2002-12-23 17:04:07.000000000 +0100
@@ -705,34 +705,21 @@
glMatrixMode(GL_PROJECTION);
glLoadMatrixf((float *) glThis->proj_mat);
} else if ((glThis->last_vertices_transformed == FALSE) && (vertex_transformed == TRUE)) {
- GLdouble height, width, minZ, maxZ;
+ GLdouble height, width, minZ, maxZ, minX, minY;
glMatrixMode(GL_MODELVIEW);
glLoadIdentity();
glMatrixMode(GL_PROJECTION);
glLoadIdentity();
- if (glThis->parent.current_viewport == NULL) {
- ERR("No current viewport !\n");
- /* Using standard values */
- height = 640.0;
- width = 480.0;
- minZ = -10.0;
- maxZ = 10.0;
- } else {
- if (glThis->parent.current_viewport->use_vp2 == 1) {
- height = (GLdouble) glThis->parent.current_viewport->viewports.vp2.dwHeight;
- width = (GLdouble) glThis->parent.current_viewport->viewports.vp2.dwWidth;
- minZ = (GLdouble) glThis->parent.current_viewport->viewports.vp2.dvMinZ;
- maxZ = (GLdouble) glThis->parent.current_viewport->viewports.vp2.dvMaxZ;
- } else {
- height = (GLdouble) glThis->parent.current_viewport->viewports.vp1.dwHeight;
- width = (GLdouble) glThis->parent.current_viewport->viewports.vp1.dwWidth;
- minZ = (GLdouble) glThis->parent.current_viewport->viewports.vp1.dvMinZ;
- maxZ = (GLdouble) glThis->parent.current_viewport->viewports.vp1.dvMaxZ;
- }
- }
- glOrtho(0.0, width, height, 0.0, -minZ, -maxZ);
+ minX = (GLdouble) glThis->parent.active_viewport.dwX;
+ minY = (GLdouble) glThis->parent.active_viewport.dwY;
+ height = (GLdouble) glThis->parent.active_viewport.dwHeight;
+ width = (GLdouble) glThis->parent.active_viewport.dwWidth;
+ minZ = (GLdouble) glThis->parent.active_viewport.dvMinZ;
+ maxZ = (GLdouble) glThis->parent.active_viewport.dvMaxZ;
+
+ glOrtho(minX, width, height, minY, -minZ, -maxZ);
}
if ((glThis->last_vertices_lit == TRUE) && (vertex_lit == FALSE)) {
@@ -941,8 +928,9 @@
inline static void handle_texture(D3DVALUE *coords) {
glTexCoord2fv(coords);
}
-inline static void handle_textures(D3DVALUE *coords, int num_coords) {
-
+inline static void handle_textures(D3DVALUE *coords, int tex_index) {
+ /* For the moment, draw only the first texture.. */
+ if (tex_index == 0) glTexCoord2fv(coords);
}
static void draw_primitive_strided_7(IDirect3DDeviceImpl *This,
@@ -1072,6 +1060,50 @@
(D3DVALUE *) (((char *) lpD3DDrawPrimStrideData->position.lpvData) + i * lpD3DDrawPrimStrideData->position.dwStride);
handle_xyzrhw(position);
}
+
+ if (TRACE_ON(ddraw)) {
+ int tex_index;
+
+ if ((d3dvtVertexType & D3DFVF_POSITION_MASK) == D3DFVF_XYZ) {
+ D3DVALUE *position =
+ (D3DVALUE *) (((char *) lpD3DDrawPrimStrideData->position.lpvData) + i * lpD3DDrawPrimStrideData->position.dwStride);
+ TRACE(" %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(" %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);
+ DPRINTF(" / %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);
+ DPRINTF(" / %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);
+ DPRINTF(" / %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);
+ DPRINTF(" / %f %f", tex_coord[0], tex_coord[1]);
+ }
+ DPRINTF("\n");
+ }
}
} else {
ERR(" matrix weighting not handled yet....\n");
--- /home/ulmer/Wine/wine_base//dlls/ddraw/d3d_private.h 2002-12-22 12:06:18.000000000 +0100
+++ /home/ulmer/Wine/wine_work//dlls/ddraw/d3d_private.h 2002-12-23 16:33:36.000000000 +0100
@@ -170,6 +170,8 @@
IDirect3DViewportImpl *viewport_list;
IDirect3DViewportImpl *current_viewport;
+ D3DVIEWPORT7 active_viewport;
+
IDirectDrawSurfaceImpl *current_texture[MAX_TEXTURES];
void (*set_context)(IDirect3DDeviceImpl*);
--- /home/ulmer/Wine/wine_base//dlls/ddraw/mesa.c 2002-12-22 12:19:13.000000000 +0100
+++ /home/ulmer/Wine/wine_work//dlls/ddraw/mesa.c 2002-12-23 16:24:00.000000000 +0100
@@ -332,7 +332,7 @@
break;
default:
- ERR("Unhandled dwRenderStateType %s !\n", _get_renderstate(dwRenderStateType));
+ ERR("Unhandled dwRenderStateType %s (%08x) !\n", _get_renderstate(dwRenderStateType), dwRenderStateType);
}
LEAVE_GL();
}
More information about the wine-patches
mailing list