Index: ddraw/glDirect3DDevice.cpp |
— | — | @@ -575,10 +575,29 @@ |
576 | 576 | }
|
577 | 577 | HRESULT WINAPI glDirect3DDevice7::Clear(DWORD dwCount, LPD3DRECT lpRects, DWORD dwFlags, DWORD dwColor, D3DVALUE dvZ, DWORD dwStencil)
|
578 | 578 | {
|
| 579 | + ClearCommand cmd;
|
579 | 580 | TRACE_ENTER(7,14,this,8,dwCount,14,lpRects,9,dwFlags,9,dwColor,19,&dvZ,9,dwStencil);
|
580 | 581 | if(!this) TRACE_RET(HRESULT,23,DDERR_INVALIDOBJECT);
|
581 | 582 | if(dwCount && !lpRects) TRACE_RET(HRESULT,23,DDERR_INVALIDPARAMS);
|
582 | | - TRACE_RET(HRESULT,23,glRenderer_Clear(renderer,glDDS7,dwCount,lpRects,dwFlags,dwColor,dvZ,dwStencil));
|
| 583 | + cmd.dwCount = dwCount;
|
| 584 | + cmd.lpRects = lpRects;
|
| 585 | + cmd.dwFlags = dwFlags;
|
| 586 | + cmd.dwColor = dwColor;
|
| 587 | + cmd.dvZ = dvZ;
|
| 588 | + cmd.dwStencil = dwStencil;
|
| 589 | + cmd.target = glDDS7->texture;
|
| 590 | + cmd.targetlevel = glDDS7->miplevel;
|
| 591 | + if (glDDS7->zbuffer)
|
| 592 | + {
|
| 593 | + cmd.zbuffer = glDDS7->zbuffer->texture;
|
| 594 | + cmd.zlevel = glDDS7->zbuffer->miplevel;
|
| 595 | + }
|
| 596 | + else
|
| 597 | + {
|
| 598 | + cmd.zbuffer = NULL;
|
| 599 | + cmd.zlevel = 0;
|
| 600 | + }
|
| 601 | + TRACE_RET(HRESULT,23,glRenderer_Clear(renderer,&cmd));
|
583 | 602 | }
|
584 | 603 |
|
585 | 604 | // ComputeSphereVisibility based on modified code from the Wine project, subject
|
Index: ddraw/glRenderer.cpp |
— | — | @@ -424,33 +424,15 @@ |
425 | 425 | * Clears the viewport.
|
426 | 426 | * @param This
|
427 | 427 | * Pointer to glRenderer object
|
428 | | - * @param target
|
429 | | - * Surface to be cleared
|
430 | | - * @param dwCount
|
431 | | - * Number of rects to use to clear the buffer, or 0 to clear the entire buffer.
|
432 | | - * @param lpRects
|
433 | | - * Pointer to rects to clear.
|
434 | | - * @param dwFlags
|
435 | | - * Flags to determine which surfaces to clear.
|
436 | | - * @param dwColor
|
437 | | - * Color value to fill the surface with.
|
438 | | - * @param dvZ
|
439 | | - * Value to fill the Z buffer with.
|
440 | | - * @param dwStencil
|
441 | | - * Value to fill the stencil buffer with.
|
| 428 | + * @param cmd
|
| 429 | + * Pointer to structure contaning all paramaters for a Clear operation.
|
442 | 430 | * @return
|
443 | 431 | * Returns D3D_OK
|
444 | 432 | */
|
445 | | -HRESULT glRenderer_Clear(glRenderer *This, glDirectDrawSurface7 *target, DWORD dwCount, LPD3DRECT lpRects, DWORD dwFlags, DWORD dwColor, D3DVALUE dvZ, DWORD dwStencil)
|
| 433 | +HRESULT glRenderer_Clear(glRenderer *This, ClearCommand *cmd)
|
446 | 434 | {
|
447 | 435 | EnterCriticalSection(&This->cs);
|
448 | | - This->inputs[0] = target;
|
449 | | - This->inputs[1] = (void*)dwCount;
|
450 | | - This->inputs[2] = lpRects;
|
451 | | - This->inputs[3] = (void*)dwFlags;
|
452 | | - This->inputs[4] = (void*)dwColor;
|
453 | | - memcpy(&This->inputs[5],&dvZ,4);
|
454 | | - This->inputs[6] = (void*)dwStencil;
|
| 436 | + This->inputs[0] = cmd;
|
455 | 437 | This->opcode = OP_CLEAR;
|
456 | 438 | SetEvent(This->start);
|
457 | 439 | WaitForSingleObject(This->busy,INFINITE);
|
— | — | @@ -460,7 +442,7 @@ |
461 | 443 |
|
462 | 444 | /**
|
463 | 445 | * Instructs the OpenGL driver to send all queued commands to the GPU.
|
464 | | - * @param This
|
| 446 | + * @param Thisf
|
465 | 447 | * Pointer to glRenderer object
|
466 | 448 | */
|
467 | 449 | void glRenderer_Flush(glRenderer *This)
|
— | — | @@ -971,9 +953,7 @@ |
972 | 954 | glRenderer__InitD3D(This,(int)This->inputs[0],(int)This->inputs[1],(int)This->inputs[2]);
|
973 | 955 | break;
|
974 | 956 | case OP_CLEAR:
|
975 | | - memcpy(&tmpfloats[0],&This->inputs[5],4);
|
976 | | - glRenderer__Clear(This,(glDirectDrawSurface7*)This->inputs[0],(DWORD)This->inputs[1],
|
977 | | - (LPD3DRECT)This->inputs[2],(DWORD)This->inputs[3],(DWORD)This->inputs[4],tmpfloats[0],(DWORD)This->inputs[6]);
|
| 957 | + glRenderer__Clear(This,(ClearCommand*)This->inputs[0]);
|
978 | 958 | break;
|
979 | 959 | case OP_FLUSH:
|
980 | 960 | glRenderer__Flush(This);
|
— | — | @@ -1949,57 +1929,77 @@ |
1950 | 1930 | This->shaderstate3d.stateid = InitShaderState(This, This->renderstate, This->texstages, This->lights);
|
1951 | 1931 | }
|
1952 | 1932 |
|
1953 | | -void glRenderer__Clear(glRenderer *This, glDirectDrawSurface7 *target, DWORD dwCount, LPD3DRECT lpRects, DWORD dwFlags, DWORD dwColor, D3DVALUE dvZ, DWORD dwStencil)
|
| 1933 | +void glRenderer__Clear(glRenderer *This, ClearCommand *cmd)
|
1954 | 1934 | {
|
1955 | 1935 | This->outputs[0] = (void*)D3D_OK;
|
1956 | 1936 | GLfloat color[4];
|
1957 | 1937 | glTexture *ztexture = NULL;
|
1958 | 1938 | GLint zlevel = 0;
|
1959 | | - if (target->zbuffer)
|
| 1939 | + GLfloat mulx, muly;
|
| 1940 | + if (cmd->zbuffer)
|
1960 | 1941 | {
|
1961 | | - ztexture = target->zbuffer->texture;
|
1962 | | - zlevel = target->zbuffer->miplevel;
|
| 1942 | + ztexture = cmd->zbuffer;
|
| 1943 | + zlevel = cmd->zlevel;
|
1963 | 1944 | }
|
1964 | | - dwordto4float(dwColor,color);
|
| 1945 | + dwordto4float(cmd->dwColor,color);
|
1965 | 1946 | do
|
1966 | 1947 | {
|
1967 | | - if (glUtil_SetFBOSurface(This->util, target->texture, ztexture,
|
1968 | | - target->zbuffer->miplevel, zlevel, FALSE) == GL_FRAMEBUFFER_COMPLETE) break;
|
1969 | | - if (!target->texture->internalformats[1]) break;
|
1970 | | - glTexture__Repair(target->texture, TRUE);
|
| 1948 | + if (glUtil_SetFBOSurface(This->util, cmd->target, ztexture,
|
| 1949 | + cmd->targetlevel, zlevel, FALSE) == GL_FRAMEBUFFER_COMPLETE) break;
|
| 1950 | + if (!cmd->target->internalformats[1]) break;
|
| 1951 | + glTexture__Repair(cmd->target, TRUE);
|
1971 | 1952 | glUtil_SetFBO(This->util, NULL);
|
1972 | | - target->texture->levels[target->miplevel].fbo.fbcolor = NULL;
|
1973 | | - target->texture->levels[target->miplevel].fbo.fbz = NULL;
|
| 1953 | + cmd->target->levels[cmd->targetlevel].fbo.fbcolor = NULL;
|
| 1954 | + cmd->target->levels[cmd->targetlevel].fbo.fbz = NULL;
|
1974 | 1955 | } while (1);
|
1975 | 1956 | int clearbits = 0;
|
1976 | | - if(dwFlags & D3DCLEAR_TARGET)
|
| 1957 | + if(cmd->dwFlags & D3DCLEAR_TARGET)
|
1977 | 1958 | {
|
1978 | 1959 | clearbits |= GL_COLOR_BUFFER_BIT;
|
1979 | 1960 | glUtil_ClearColor(This->util, color[0], color[1], color[2], color[3]);
|
1980 | 1961 | }
|
1981 | | - if(dwFlags & D3DCLEAR_ZBUFFER)
|
| 1962 | + if(cmd->dwFlags & D3DCLEAR_ZBUFFER)
|
1982 | 1963 | {
|
1983 | 1964 | clearbits |= GL_DEPTH_BUFFER_BIT;
|
1984 | | - glUtil_ClearDepth(This->util, dvZ);
|
| 1965 | + glUtil_ClearDepth(This->util, cmd->dvZ);
|
1985 | 1966 | glUtil_DepthWrite(This->util, TRUE);
|
1986 | 1967 | }
|
1987 | | - if(dwFlags & D3DCLEAR_STENCIL)
|
| 1968 | + if(cmd->dwFlags & D3DCLEAR_STENCIL)
|
1988 | 1969 | {
|
1989 | 1970 | clearbits |= GL_STENCIL_BUFFER_BIT;
|
1990 | | - glUtil_ClearStencil(This->util, dwStencil);
|
| 1971 | + glUtil_ClearStencil(This->util, cmd->dwStencil);
|
1991 | 1972 | }
|
1992 | | - if(dwCount)
|
| 1973 | + if(cmd->dwCount)
|
1993 | 1974 | {
|
1994 | | - for(DWORD i = 0; i < dwCount; i++)
|
| 1975 | + if (cmd->targetlevel == 0 && (cmd->target->levels[0].ddsd.dwWidth != cmd->target->bigwidth) ||
|
| 1976 | + (cmd->target->levels[0].ddsd.dwHeight != cmd->target->bigheight))
|
1995 | 1977 | {
|
1996 | | - glUtil_SetScissor(This->util, TRUE, lpRects[i].x1, lpRects[i].y1, lpRects[i].x2, lpRects[i].y2);
|
1997 | | - glClear(clearbits);
|
| 1978 | + mulx = cmd->target->bigwidth / cmd->target->levels[0].ddsd.dwWidth;
|
| 1979 | + muly = cmd->target->bigheight / cmd->target->levels[0].ddsd.dwHeight;
|
| 1980 | + for (DWORD i = 0; i < cmd->dwCount; i++)
|
| 1981 | + {
|
| 1982 | + glUtil_SetScissor(This->util, TRUE, cmd->lpRects[i].x1*mulx,
|
| 1983 | + (cmd->target->bigheight - (GLsizei)((GLfloat)cmd->lpRects[i].y1*muly)),
|
| 1984 | + cmd->lpRects[i].x2*mulx, (cmd->target->bigheight - ((GLfloat)cmd->lpRects[i].y2*muly)));
|
| 1985 | + glClear(clearbits);
|
| 1986 | + }
|
1998 | 1987 | }
|
| 1988 | + else
|
| 1989 | + {
|
| 1990 | + for (DWORD i = 0; i < cmd->dwCount; i++)
|
| 1991 | + {
|
| 1992 | + glUtil_SetScissor(This->util, TRUE, cmd->lpRects[i].x1,
|
| 1993 | + cmd->target->levels[cmd->targetlevel].ddsd.dwHeight - cmd->lpRects[i].y1,
|
| 1994 | + cmd->lpRects[i].x2,
|
| 1995 | + cmd->target->levels[cmd->targetlevel].ddsd.dwHeight - cmd->lpRects[i].y2);
|
| 1996 | + glClear(clearbits);
|
| 1997 | + }
|
| 1998 | + }
|
1999 | 1999 | glUtil_SetScissor(This->util, false, 0, 0, 0, 0);
|
2000 | 2000 | }
|
2001 | 2001 | else glClear(clearbits);
|
2002 | | - if(target->zbuffer) target->zbuffer->texture->levels[target->zbuffer->miplevel].dirty |= 2;
|
2003 | | - target->texture->levels[target->miplevel].dirty |= 2;
|
| 2002 | + if(cmd->zbuffer) cmd->zbuffer->levels[zlevel].dirty |= 2;
|
| 2003 | + cmd->target->levels[cmd->targetlevel].dirty |= 2;
|
2004 | 2004 | SetEvent(This->busy);
|
2005 | 2005 | }
|
2006 | 2006 |
|
Index: ddraw/glRenderer.h |
— | — | @@ -168,7 +168,7 @@ |
169 | 169 | void glRenderer_InitD3D(glRenderer *This, int zbuffer, int x, int y);
|
170 | 170 | void glRenderer_Flush(glRenderer *This);
|
171 | 171 | void glRenderer_SetWnd(glRenderer *This, int width, int height, int bpp, int fullscreen, unsigned int frequency, HWND newwnd, BOOL devwnd);
|
172 | | -HRESULT glRenderer_Clear(glRenderer *This, glDirectDrawSurface7 *target, DWORD dwCount, LPD3DRECT lpRects, DWORD dwFlags, DWORD dwColor, D3DVALUE dvZ, DWORD dwStencil);
|
| 172 | +HRESULT glRenderer_Clear(glRenderer *This, ClearCommand *cmd);
|
173 | 173 | HRESULT glRenderer_DrawPrimitives(glRenderer *This, glDirect3DDevice7 *device, GLenum mode, GLVERTEX *vertices, int *texformats, DWORD count, LPWORD indices,
|
174 | 174 | DWORD indexcount, DWORD flags);
|
175 | 175 | void glRenderer_DeleteFBO(glRenderer *This, FBO *fbo);
|
— | — | @@ -197,7 +197,7 @@ |
198 | 198 | void glRenderer__DrawBackbuffer(glRenderer *This, glTexture **texture, int x, int y, int progtype);
|
199 | 199 | void glRenderer__DrawBackbufferRect(glRenderer *This, glTexture *texture, RECT srcrect, int progtype);
|
200 | 200 | void glRenderer__InitD3D(glRenderer *This, int zbuffer, int x, int y);
|
201 | | -void glRenderer__Clear(glRenderer *This, glDirectDrawSurface7 *target, DWORD dwCount, LPD3DRECT lpRects, DWORD dwFlags, DWORD dwColor, D3DVALUE dvZ, DWORD dwStencil);
|
| 201 | +void glRenderer__Clear(glRenderer *This, ClearCommand *cmd);
|
202 | 202 | void glRenderer__DrawPrimitives(glRenderer *This, glDirect3DDevice7 *device, GLenum mode, GLVERTEX *vertices, int *texcormats, DWORD count, LPWORD indices,
|
203 | 203 | DWORD indexcount, DWORD flags);
|
204 | 204 | void glRenderer__Flush(glRenderer *This);
|
Index: ddraw/struct.h |
— | — | @@ -376,6 +376,20 @@ |
377 | 377 | GLint patternlevel;
|
378 | 378 | }BltCommand;
|
379 | 379 |
|
| 380 | +typedef struct ClearCommand
|
| 381 | +{
|
| 382 | + DWORD dwCount;
|
| 383 | + LPD3DRECT lpRects;
|
| 384 | + DWORD dwFlags;
|
| 385 | + DWORD dwColor;
|
| 386 | + D3DVALUE dvZ;
|
| 387 | + DWORD dwStencil;
|
| 388 | + glTexture *target;
|
| 389 | + glTexture *zbuffer;
|
| 390 | + GLint targetlevel;
|
| 391 | + GLint zlevel;
|
| 392 | +}ClearCommand;
|
| 393 | +
|
380 | 394 | struct glDirectDrawPaletteVtbl;
|
381 | 395 |
|
382 | 396 | // Structure for glDirectDrawPalette, emulates IDirectDrawPalette
|