Support viewports the D3D7 way.
This commit is contained in:
parent
c40b756021
commit
5f78568b53
|
@ -170,6 +170,8 @@ struct IDirect3DDeviceImpl
|
||||||
|
|
||||||
IDirect3DViewportImpl *viewport_list;
|
IDirect3DViewportImpl *viewport_list;
|
||||||
IDirect3DViewportImpl *current_viewport;
|
IDirect3DViewportImpl *current_viewport;
|
||||||
|
D3DVIEWPORT7 active_viewport;
|
||||||
|
|
||||||
IDirectDrawSurfaceImpl *current_texture[MAX_TEXTURES];
|
IDirectDrawSurfaceImpl *current_texture[MAX_TEXTURES];
|
||||||
|
|
||||||
void (*set_context)(IDirect3DDeviceImpl*);
|
void (*set_context)(IDirect3DDeviceImpl*);
|
||||||
|
|
|
@ -220,7 +220,19 @@ Main_IDirect3DDeviceImpl_7_SetViewport(LPDIRECT3DDEVICE7 iface,
|
||||||
LPD3DVIEWPORT7 lpData)
|
LPD3DVIEWPORT7 lpData)
|
||||||
{
|
{
|
||||||
ICOM_THIS_FROM(IDirect3DDeviceImpl, IDirect3DDevice7, iface);
|
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;
|
return DD_OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -239,7 +251,20 @@ Main_IDirect3DDeviceImpl_7_GetViewport(LPDIRECT3DDEVICE7 iface,
|
||||||
LPD3DVIEWPORT7 lpData)
|
LPD3DVIEWPORT7 lpData)
|
||||||
{
|
{
|
||||||
ICOM_THIS_FROM(IDirect3DDeviceImpl, IDirect3DDevice7, iface);
|
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;
|
return DD_OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -703,6 +728,23 @@ Main_IDirect3DDeviceImpl_3_2T_SetCurrentViewport(LPDIRECT3DDEVICE3 iface,
|
||||||
This->current_viewport->active_device = This;
|
This->current_viewport->active_device = This;
|
||||||
This->current_viewport->activate(This->current_viewport);
|
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;
|
return DD_OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -705,34 +705,21 @@ static void draw_primitive_handle_GL_state(IDirect3DDeviceGLImpl *glThis,
|
||||||
glMatrixMode(GL_PROJECTION);
|
glMatrixMode(GL_PROJECTION);
|
||||||
glLoadMatrixf((float *) glThis->proj_mat);
|
glLoadMatrixf((float *) glThis->proj_mat);
|
||||||
} else if ((glThis->last_vertices_transformed == FALSE) && (vertex_transformed == TRUE)) {
|
} 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);
|
glMatrixMode(GL_MODELVIEW);
|
||||||
glLoadIdentity();
|
glLoadIdentity();
|
||||||
glMatrixMode(GL_PROJECTION);
|
glMatrixMode(GL_PROJECTION);
|
||||||
glLoadIdentity();
|
glLoadIdentity();
|
||||||
|
|
||||||
if (glThis->parent.current_viewport == NULL) {
|
minX = (GLdouble) glThis->parent.active_viewport.dwX;
|
||||||
ERR("No current viewport !\n");
|
minY = (GLdouble) glThis->parent.active_viewport.dwY;
|
||||||
/* Using standard values */
|
height = (GLdouble) glThis->parent.active_viewport.dwHeight;
|
||||||
height = 640.0;
|
width = (GLdouble) glThis->parent.active_viewport.dwWidth;
|
||||||
width = 480.0;
|
minZ = (GLdouble) glThis->parent.active_viewport.dvMinZ;
|
||||||
minZ = -10.0;
|
maxZ = (GLdouble) glThis->parent.active_viewport.dvMaxZ;
|
||||||
maxZ = 10.0;
|
|
||||||
} else {
|
glOrtho(minX, width, height, minY, -minZ, -maxZ);
|
||||||
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);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if ((glThis->last_vertices_lit == TRUE) && (vertex_lit == FALSE)) {
|
if ((glThis->last_vertices_lit == TRUE) && (vertex_lit == FALSE)) {
|
||||||
|
@ -941,8 +928,9 @@ inline static void handle_diffuse_and_specular(DWORD *color_d, DWORD *color_s) {
|
||||||
inline static void handle_texture(D3DVALUE *coords) {
|
inline static void handle_texture(D3DVALUE *coords) {
|
||||||
glTexCoord2fv(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,
|
static void draw_primitive_strided_7(IDirect3DDeviceImpl *This,
|
||||||
|
@ -1072,6 +1060,50 @@ static void draw_primitive_strided_7(IDirect3DDeviceImpl *This,
|
||||||
(D3DVALUE *) (((char *) lpD3DDrawPrimStrideData->position.lpvData) + i * lpD3DDrawPrimStrideData->position.dwStride);
|
(D3DVALUE *) (((char *) lpD3DDrawPrimStrideData->position.lpvData) + i * lpD3DDrawPrimStrideData->position.dwStride);
|
||||||
handle_xyzrhw(position);
|
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 {
|
} else {
|
||||||
ERR(" matrix weighting not handled yet....\n");
|
ERR(" matrix weighting not handled yet....\n");
|
||||||
|
|
|
@ -332,7 +332,7 @@ void set_render_state(D3DRENDERSTATETYPE dwRenderStateType,
|
||||||
break;
|
break;
|
||||||
|
|
||||||
default:
|
default:
|
||||||
ERR("Unhandled dwRenderStateType %s !\n", _get_renderstate(dwRenderStateType));
|
ERR("Unhandled dwRenderStateType %s (%08x) !\n", _get_renderstate(dwRenderStateType), dwRenderStateType);
|
||||||
}
|
}
|
||||||
LEAVE_GL();
|
LEAVE_GL();
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue