Index: ddraw/glDirectDrawClipper.cpp |
— | — | @@ -434,7 +434,7 @@ |
435 | 435 | if(!This->cliplist) memfail = true;
|
436 | 436 | if(!memfail) This->vertices = (BltVertex*)malloc(This->maxsize*4*sizeof(BltVertex));
|
437 | 437 | if(!This->vertices) memfail = true;
|
438 | | - if(!memfail) This->indices = (GLshort*)malloc(This->maxsize*6*sizeof(GLshort));
|
| 438 | + if(!memfail) This->indices = (GLushort*)malloc(This->maxsize*6*sizeof(GLushort));
|
439 | 439 | if(!This->indices) memfail = true;
|
440 | 440 | if(memfail)
|
441 | 441 | {
|
— | — | @@ -457,7 +457,7 @@ |
458 | 458 | memfail = false;
|
459 | 459 | RGNDATA *newcliplist = NULL;
|
460 | 460 | BltVertex *newvertices = NULL;
|
461 | | - GLshort *newindices = NULL;
|
| 461 | + GLushort *newindices = NULL;
|
462 | 462 | newcliplist = (RGNDATA*)realloc(This->cliplist,sizeof(RGNDATAHEADER)+(lpClipList->rdh.nCount*sizeof(RECT)));
|
463 | 463 | if(!newcliplist) memfail = true;
|
464 | 464 | else This->cliplist = newcliplist;
|
— | — | @@ -464,7 +464,7 @@ |
465 | 465 | if(!memfail) newvertices = (BltVertex*)realloc(This->vertices,lpClipList->rdh.nCount*4*sizeof(BltVertex));
|
466 | 466 | if(!newvertices) memfail = true;
|
467 | 467 | else This->vertices = newvertices;
|
468 | | - if(!memfail) newindices = (GLshort*)realloc(This->indices,lpClipList->rdh.nCount*6*sizeof(GLshort));
|
| 468 | + if(!memfail) newindices = (GLushort*)realloc(This->indices,lpClipList->rdh.nCount*6*sizeof(GLushort));
|
469 | 469 | if(!newindices) memfail = true;
|
470 | 470 | else This->indices = newindices;
|
471 | 471 | if(memfail) TRACE_RET(HRESULT,23,DDERR_OUTOFMEMORY);
|
Index: ddraw/glDirectDrawClipper.h |
— | — | @@ -33,7 +33,7 @@ |
34 | 34 | HWND hWnd;
|
35 | 35 | RGNDATA *cliplist;
|
36 | 36 | BltVertex *vertices;
|
37 | | - GLshort *indices;
|
| 37 | + GLushort *indices;
|
38 | 38 | size_t clipsize;
|
39 | 39 | size_t maxsize;
|
40 | 40 | bool hascliplist;
|
Index: ddraw/glDirectDrawSurface.cpp |
— | — | @@ -698,7 +698,7 @@ |
699 | 699 | cmd.flags |= 0x40000000;
|
700 | 700 | }
|
701 | 701 | glDirectDrawSurface7 *src = (glDirectDrawSurface7 *)lpDDSrcSurface;
|
702 | | -/* if (clipper)
|
| 702 | + if (clipper)
|
703 | 703 | {
|
704 | 704 | if (!clipper->hWnd)
|
705 | 705 | {
|
— | — | @@ -705,12 +705,13 @@ |
706 | 706 | if (!clipper->clipsize) TRACE_RET(HRESULT, 23, DDERR_NOCLIPLIST);
|
707 | 707 | if (clipper->dirty)
|
708 | 708 | {
|
709 | | - glRenderer_UpdateClipper(ddInterface->renderer, this);
|
| 709 | + glRenderer_UpdateClipper(ddInterface->renderer, this->clipper->texture, this->clipper->indices,
|
| 710 | + this->clipper->vertices,this->clipper->clipsize, this->ddsd.dwWidth, this->ddsd.dwHeight);
|
710 | 711 | clipper->dirty = false;
|
711 | 712 | }
|
712 | 713 | dwFlags |= 0x10000000;
|
713 | 714 | }
|
714 | | - }*/
|
| 715 | + }
|
715 | 716 | if (this->clipper && !(this->clipper->hWnd)) cmd.flags |= 0x10000000;
|
716 | 717 | if (lpDDBltFx) cmd.bltfx = *lpDDBltFx;
|
717 | 718 | if (dwFlags & DDBLT_DEPTHFILL)
|
Index: ddraw/glRenderer.cpp |
— | — | @@ -22,12 +22,9 @@ |
23 | 23 | #include "timer.h"
|
24 | 24 | #include "glDirectDraw.h"
|
25 | 25 | #include "glDirectDrawSurface.h"
|
26 | | -#include "glDirectDrawPalette.h"
|
27 | 26 | #include "glRenderWindow.h"
|
28 | 27 | #include "glRenderer.h"
|
29 | 28 | #include "glDirect3DDevice.h"
|
30 | | -#include "glDirect3DLight.h"
|
31 | | -#include "glDirectDrawClipper.h"
|
32 | 29 | #include "ddraw.h"
|
33 | 30 | #include "ShaderGen3D.h"
|
34 | 31 | #include "matrix.h"
|
— | — | @@ -602,16 +599,32 @@ |
603 | 600 | }
|
604 | 601 |
|
605 | 602 | /**
|
606 | | - * Updates the clipper stencil for a surface.
|
| 603 | + * Updates a clipping stencil.
|
607 | 604 | * @param This
|
608 | 605 | * Pointer to glRenderer object
|
609 | | - * @param surface
|
610 | | - * Surface to update clipper stencil on
|
| 606 | + * @param stencil
|
| 607 | + * Stencil texture to update
|
| 608 | + * @param indices
|
| 609 | + * Pointer to array of indices representing the clip list
|
| 610 | + * @param vertices
|
| 611 | + * Pointer to array of vertices representing the clip list
|
| 612 | + * @param count
|
| 613 | + * Number of entries in the clip list
|
| 614 | + * @param width
|
| 615 | + * Width of surface the stencil is attached to
|
| 616 | + * @param height
|
| 617 | + * Height of surface the stencil is attached to
|
611 | 618 | */
|
612 | | -void glRenderer_UpdateClipper(glRenderer *This, glDirectDrawSurface7 *surface)
|
| 619 | +void glRenderer_UpdateClipper(glRenderer *This, glTexture *stencil, GLushort *indices, BltVertex *vertices,
|
| 620 | + GLsizei count, GLsizei width, GLsizei height)
|
613 | 621 | {
|
614 | 622 | EnterCriticalSection(&This->cs);
|
615 | | - This->inputs[0] = surface;
|
| 623 | + This->inputs[0] = stencil;
|
| 624 | + This->inputs[1] = indices;
|
| 625 | + This->inputs[2] = vertices;
|
| 626 | + This->inputs[3] = (void*)count;
|
| 627 | + This->inputs[4] = (void*)width;
|
| 628 | + This->inputs[5] = (void*)height;
|
616 | 629 | This->opcode = OP_UPDATECLIPPER;
|
617 | 630 | SetEvent(This->start);
|
618 | 631 | WaitForSingleObject(This->busy,INFINITE);
|
— | — | @@ -967,7 +980,8 @@ |
968 | 981 | glRenderer__DeleteFBO(This,(FBO*)This->inputs[0]);
|
969 | 982 | break;
|
970 | 983 | case OP_UPDATECLIPPER:
|
971 | | - glRenderer__UpdateClipper(This,(glDirectDrawSurface7*)This->inputs[0]);
|
| 984 | + glRenderer__UpdateClipper(This,(glTexture*)This->inputs[0], (GLushort*)This->inputs[1],
|
| 985 | + (BltVertex*)This->inputs[2], (GLsizei)This->inputs[3], (GLsizei)This->inputs[4], (GLsizei)This->inputs[5]);
|
972 | 986 | break;
|
973 | 987 | case OP_DEPTHFILL:
|
974 | 988 | glRenderer__DepthFill(This, (BltCommand*)This->inputs[0], (glTexture*)This->inputs[1], (GLint)This->inputs[2]);
|
— | — | @@ -2411,35 +2425,35 @@ |
2412 | 2426 | SetEvent(This->busy);
|
2413 | 2427 | }
|
2414 | 2428 |
|
2415 | | -void glRenderer__UpdateClipper(glRenderer *This, glDirectDrawSurface7 *surface)
|
| 2429 | +void glRenderer__UpdateClipper(glRenderer *This, glTexture *stencil, GLushort *indices, BltVertex *vertices,
|
| 2430 | + GLsizei count, GLsizei width, GLsizei height)
|
2416 | 2431 | {
|
2417 | 2432 | GLfloat view[4];
|
2418 | 2433 | DDSURFACEDESC2 ddsd;
|
2419 | | - if ((surface->ddsd.dwWidth != surface->texture->stencil->levels[0].ddsd.dwWidth) ||
|
2420 | | - (surface->ddsd.dwHeight != surface->texture->stencil->levels[0].ddsd.dwHeight))
|
| 2434 | + if ((width != stencil->levels[0].ddsd.dwWidth) || (height != stencil->levels[0].ddsd.dwHeight))
|
2421 | 2435 | {
|
2422 | 2436 | ZeroMemory(&ddsd, sizeof(DDSURFACEDESC2));
|
2423 | 2437 | ddsd.dwSize = sizeof(DDSURFACEDESC2);
|
2424 | | - ddsd.dwWidth = surface->ddsd.dwWidth;
|
2425 | | - ddsd.dwHeight = surface->ddsd.dwHeight;
|
| 2438 | + ddsd.dwWidth = width;
|
| 2439 | + ddsd.dwHeight = height;
|
2426 | 2440 | ddsd.dwFlags = DDSD_WIDTH | DDSD_HEIGHT;
|
2427 | | - glTexture__SetSurfaceDesc(surface->texture->stencil, &ddsd);
|
| 2441 | + glTexture__SetSurfaceDesc(stencil, &ddsd);
|
2428 | 2442 | }
|
2429 | | - glUtil_SetFBOTextures(This->util, &surface->texture->stencil->levels[0].fbo, surface->texture->stencil, NULL, 0, 0, FALSE);
|
| 2443 | + glUtil_SetFBOTextures(This->util, &stencil->levels[0].fbo, stencil, NULL, 0, 0, FALSE);
|
2430 | 2444 | view[0] = view[2] = 0;
|
2431 | | - view[1] = (GLfloat)surface->ddsd.dwWidth;
|
2432 | | - view[3] = (GLfloat)surface->ddsd.dwHeight;
|
2433 | | - glUtil_SetViewport(This->util, 0, 0, surface->ddsd.dwWidth, surface->ddsd.dwHeight);
|
| 2445 | + view[1] = width;
|
| 2446 | + view[3] = height;
|
| 2447 | + glUtil_SetViewport(This->util, 0, 0, width, height);
|
2434 | 2448 | glClear(GL_COLOR_BUFFER_BIT);
|
2435 | 2449 | ShaderManager_SetShader(This->shaders,PROG_CLIPSTENCIL,NULL,0);
|
2436 | 2450 | This->ext->glUniform4f(This->shaders->shaders[PROG_CLIPSTENCIL].view,view[0],view[1],view[2],view[3]);
|
2437 | 2451 | glUtil_EnableArray(This->util, This->shaders->shaders[PROG_CLIPSTENCIL].pos, TRUE);
|
2438 | 2452 | This->ext->glVertexAttribPointer(This->shaders->shaders[PROG_CLIPSTENCIL].pos,
|
2439 | | - 2,GL_FLOAT,false,sizeof(BltVertex),&surface->clipper->vertices[0].x);
|
| 2453 | + 2,GL_FLOAT,false,sizeof(BltVertex),&vertices[0].x);
|
2440 | 2454 | glUtil_SetCull(This->util, D3DCULL_NONE);
|
2441 | 2455 | glUtil_SetPolyMode(This->util, D3DFILL_SOLID);
|
2442 | | - This->ext->glDrawRangeElements(GL_TRIANGLES, 0, (6 * surface->clipper->clipsize) - 1,
|
2443 | | - 6 * surface->clipper->clipsize, GL_UNSIGNED_SHORT, surface->clipper->indices);
|
| 2456 | + This->ext->glDrawRangeElements(GL_TRIANGLES, 0, (6 * count) - 1,
|
| 2457 | + 6 * count, GL_UNSIGNED_SHORT, indices);
|
2444 | 2458 | glUtil_SetFBO(This->util, NULL);
|
2445 | 2459 | SetEvent(This->busy);
|
2446 | 2460 | }
|
Index: ddraw/glRenderer.h |
— | — | @@ -172,7 +172,8 @@ |
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);
|
176 | | -void glRenderer_UpdateClipper(glRenderer *This, glDirectDrawSurface7 *surface);
|
| 176 | +void glRenderer_UpdateClipper(glRenderer *This, glTexture *stencil, GLushort *indices, BltVertex *vertices,
|
| 177 | + GLsizei count, GLsizei width, GLsizei height);
|
177 | 178 | unsigned int glRenderer_GetScanLine(glRenderer *This);
|
178 | 179 | HRESULT glRenderer_DepthFill(glRenderer *This, BltCommand *cmd, glTexture *parent, GLint parentlevel);
|
179 | 180 | void glRenderer_SetRenderState(glRenderer *This, D3DRENDERSTATETYPE dwRendStateType, DWORD dwRenderState);
|
— | — | @@ -203,7 +204,8 @@ |
204 | 205 | void glRenderer__Flush(glRenderer *This);
|
205 | 206 | void glRenderer__SetWnd(glRenderer *This, int width, int height, int fullscreen, int bpp, unsigned int frequency, HWND newwnd, BOOL devwnd);
|
206 | 207 | void glRenderer__DeleteFBO(glRenderer *This, FBO *fbo);
|
207 | | -void glRenderer__UpdateClipper(glRenderer *This, glDirectDrawSurface7 *surface);
|
| 208 | +void glRenderer__UpdateClipper(glRenderer *This, glTexture *stencil, GLushort *indices, BltVertex *vertices,
|
| 209 | + GLsizei count, GLsizei width, GLsizei height);
|
208 | 210 | void glRenderer__DepthFill(glRenderer *This, BltCommand *cmd, glTexture *parent, GLint parentlevel);
|
209 | 211 | void glRenderer__SetFogColor(glRenderer *This, DWORD color);
|
210 | 212 | void glRenderer__SetFogStart(glRenderer *This, GLfloat start);
|