Index: ddraw/glClassFactory.cpp |
— | — | @@ -18,6 +18,8 @@ |
19 | 19 | #include "common.h"
|
20 | 20 | #include "glClassFactory.h"
|
21 | 21 | #include "glDirectDraw.h"
|
| 22 | +#include "texture.h"
|
| 23 | +#include "glutil.h"
|
22 | 24 | #include "glDirectDrawClipper.h"
|
23 | 25 |
|
24 | 26 | LONG locks;
|
Index: ddraw/glDirectDrawClipper.cpp |
— | — | @@ -16,6 +16,8 @@ |
17 | 17 | // Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
18 | 18 |
|
19 | 19 | #include "common.h"
|
| 20 | +#include "texture.h"
|
| 21 | +#include "glutil.h"
|
20 | 22 | #include "glDirectDraw.h"
|
21 | 23 | #include "glDirectDrawClipper.h"
|
22 | 24 |
|
— | — | @@ -38,6 +40,9 @@ |
39 | 41 | glDirectDrawClipper::~glDirectDrawClipper()
|
40 | 42 | {
|
41 | 43 | TRACE_ENTER(1,14,this);
|
| 44 | + if (cliplist) free(cliplist);
|
| 45 | + if (vertices) free(vertices);
|
| 46 | + if (indices) free(indices);
|
42 | 47 | if(glDD7) glDD7->DeleteClipper(this);
|
43 | 48 | TRACE_EXIT(-1,0);
|
44 | 49 | }
|
— | — | @@ -111,6 +116,11 @@ |
112 | 117 | if(glDD7) hasparent = true;
|
113 | 118 | else hasparent = false;
|
114 | 119 | hWnd = NULL;
|
| 120 | + cliplist = NULL;
|
| 121 | + vertices = NULL;
|
| 122 | + indices = NULL;
|
| 123 | + hascliplist = false;
|
| 124 | + maxsize = clipsize = 0;
|
115 | 125 | refcount = 1;
|
116 | 126 | initialized = true;
|
117 | 127 | TRACE_EXIT(23,DD_OK);
|
— | — | @@ -128,9 +138,82 @@ |
129 | 139 | {
|
130 | 140 | TRACE_ENTER(3,14,this,14,lpClipList,9,dwFlags);
|
131 | 141 | if(!this) TRACE_RET(HRESULT,23,DDERR_INVALIDOBJECT);
|
132 | | - FIXME("IDirectDrawClipper::SetClipList: stub");
|
133 | | - TRACE_EXIT(23,DDERR_GENERIC);
|
134 | | - ERR(DDERR_GENERIC);
|
| 142 | + if(hWnd) TRACE_RET(HRESULT,23,DDERR_CLIPPERISUSINGHWND);
|
| 143 | + bool memfail;
|
| 144 | + if(lpClipList)
|
| 145 | + {
|
| 146 | + if(lpClipList->rdh.dwSize != sizeof(RGNDATAHEADER)) TRACE_RET(HRESULT,23,DDERR_INVALIDCLIPLIST);
|
| 147 | + if(lpClipList->rdh.iType != RDH_RECTANGLES) TRACE_RET(HRESULT,23,DDERR_INVALIDCLIPLIST);
|
| 148 | + if(lpClipList->rdh.nRgnSize != lpClipList->rdh.nCount * sizeof(RECT))
|
| 149 | + TRACE_RET(HRESULT,23,DDERR_INVALIDCLIPLIST);
|
| 150 | + if(!cliplist)
|
| 151 | + {
|
| 152 | + memfail = false;
|
| 153 | + maxsize = lpClipList->rdh.nCount;
|
| 154 | + cliplist = (RECT*)malloc(maxsize*sizeof(RECT));
|
| 155 | + if(!cliplist) memfail = true;
|
| 156 | + if(!memfail) vertices = (BltVertex*)malloc(maxsize*4*sizeof(BltVertex));
|
| 157 | + if(!vertices) memfail = true;
|
| 158 | + if(!memfail) indices = (WORD*)malloc(maxsize*6*sizeof(WORD));
|
| 159 | + if(!indices) memfail = true;
|
| 160 | + if(memfail)
|
| 161 | + {
|
| 162 | + if(vertices)
|
| 163 | + {
|
| 164 | + free(vertices);
|
| 165 | + vertices = NULL;
|
| 166 | + }
|
| 167 | + if(cliplist)
|
| 168 | + {
|
| 169 | + free(cliplist);
|
| 170 | + cliplist = NULL;
|
| 171 | + }
|
| 172 | + maxsize = 0;
|
| 173 | + TRACE_RET(HRESULT,23,DDERR_OUTOFMEMORY);
|
| 174 | + }
|
| 175 | + }
|
| 176 | + if(lpClipList->rdh.nCount > maxsize)
|
| 177 | + {
|
| 178 | + memfail = false;
|
| 179 | + RECT *newcliplist = NULL;
|
| 180 | + BltVertex *newvertices = NULL;
|
| 181 | + WORD *newindices = NULL;
|
| 182 | + newcliplist = (RECT*)realloc(cliplist,lpClipList->rdh.nCount*sizeof(RECT));
|
| 183 | + if(!newcliplist) memfail = true;
|
| 184 | + else cliplist = newcliplist;
|
| 185 | + if(!memfail) newvertices = (BltVertex*)realloc(vertices,lpClipList->rdh.nCount*4*sizeof(BltVertex));
|
| 186 | + if(!newvertices) memfail = true;
|
| 187 | + else vertices = newvertices;
|
| 188 | + if(!memfail) newindices = (WORD*)realloc(indices,lpClipList->rdh.nCount*6*sizeof(WORD));
|
| 189 | + if(!newindices) memfail = true;
|
| 190 | + else indices = newindices;
|
| 191 | + if(memfail) TRACE_RET(HRESULT,23,DDERR_OUTOFMEMORY);
|
| 192 | + maxsize = lpClipList->rdh.nCount;
|
| 193 | + }
|
| 194 | + clipsize = lpClipList->rdh.nCount;
|
| 195 | + memcpy(cliplist,lpClipList->Buffer,lpClipList->rdh.nCount*sizeof(RECT));
|
| 196 | + for(int i = 0; i < lpClipList->rdh.nCount; i++)
|
| 197 | + {
|
| 198 | + vertices[(i*4)+1].y = vertices[(i*4)+3].y = cliplist[i].left;
|
| 199 | + vertices[i*4].x = vertices[(i*4)+2].x = cliplist[i].right;
|
| 200 | + vertices[i*4].y = vertices[(i*4)+1].y = cliplist[i].top;
|
| 201 | + vertices[(i*4)+2].y = vertices[(i*4)+3].y = cliplist[i].bottom;
|
| 202 | + // 0 1 2 2 1 3
|
| 203 | + indices[i*6] = i*4;
|
| 204 | + indices[(i*6)+1] = indices[(i*6)+4] = (i*4)+1;
|
| 205 | + indices[(i*6)+2] = indices[(i*6)+3] = (i*4)+2;
|
| 206 | + indices[(i*6)+5] = (i*4)+3;
|
| 207 | + }
|
| 208 | + for(int i = 0; i < (4*lpClipList->rdh.nCount); i++)
|
| 209 | + {
|
| 210 | + vertices[i].r = 255;
|
| 211 | + vertices[i].g = vertices[i].b = vertices[i].a = 0;
|
| 212 | + vertices[i].s = vertices[i].t = 0.0f;
|
| 213 | + }
|
| 214 | + }
|
| 215 | + else clipsize = 0;
|
| 216 | + TRACE_EXIT(23,DD_OK);
|
| 217 | + return DD_OK;
|
135 | 218 | }
|
136 | 219 | HRESULT WINAPI glDirectDrawClipper::SetHWnd(DWORD dwFlags, HWND hWnd)
|
137 | 220 | {
|
Index: ddraw/glDirectDrawClipper.h |
— | — | @@ -43,5 +43,11 @@ |
44 | 44 | bool hasparent;
|
45 | 45 | bool initialized;
|
46 | 46 | HWND hWnd;
|
| 47 | + RECT *cliplist;
|
| 48 | + BltVertex *vertices;
|
| 49 | + WORD *indices;
|
| 50 | + int clipsize;
|
| 51 | + int maxsize;
|
| 52 | + bool hascliplist;
|
47 | 53 | };
|
48 | 54 | #endif //_GLDIRECTDRAWCLIPPER_H |
\ No newline at end of file |
Index: ddraw/glDirectDrawSurface.cpp |
— | — | @@ -368,6 +368,7 @@ |
369 | 369 | if(bitmapinfo) free(bitmapinfo);
|
370 | 370 | if(palette) palette->Release();
|
371 | 371 | if(backbuffer) backbuffer->Release();
|
| 372 | + if(clipper) clipper->Release();
|
372 | 373 | if(buffer) free(buffer);
|
373 | 374 | if(bigbuffer) free(bigbuffer);
|
374 | 375 | if(zbuffer) zbuffer->Release();
|
Index: ddraw/glRenderer.cpp |
— | — | @@ -34,9 +34,6 @@ |
35 | 35 | #include "shadergen.h"
|
36 | 36 | #include "matrix.h"
|
37 | 37 |
|
38 | | -TEXTURE *backbuffer = NULL;
|
39 | | -int backx = 0;
|
40 | | -int backy = 0;
|
41 | 38 | BltVertex bltvertices[4];
|
42 | 39 | const GLushort bltindices[4] = {0,1,2,3};
|
43 | 40 |
|
— | — | @@ -195,6 +192,8 @@ |
196 | 193 | */
|
197 | 194 | glRenderer::glRenderer(int width, int height, int bpp, bool fullscreen, unsigned int frequency, HWND hwnd, glDirectDraw7 *glDD7)
|
198 | 195 | {
|
| 196 | + backbuffer = NULL;
|
| 197 | + stenciltex = NULL;
|
199 | 198 | hDC = NULL;
|
200 | 199 | hRC = NULL;
|
201 | 200 | PBO = 0;
|
Index: ddraw/glRenderer.h |
— | — | @@ -51,14 +51,6 @@ |
52 | 52 | int stride;
|
53 | 53 | } GLVERTEX;
|
54 | 54 |
|
55 | | -typedef struct
|
56 | | -{
|
57 | | - GLfloat x,y;
|
58 | | - GLubyte r,g,b,a;
|
59 | | - GLfloat s,t;
|
60 | | - GLfloat padding[3];
|
61 | | -} BltVertex;
|
62 | | -
|
63 | 55 | extern BltVertex bltvertices[4];
|
64 | 56 |
|
65 | 57 | #define OP_NULL 0
|
— | — | @@ -145,6 +137,12 @@ |
146 | 138 | HANDLE start;
|
147 | 139 | unsigned int frequency;
|
148 | 140 | DXGLTimer timer;
|
| 141 | + TEXTURE *backbuffer;
|
| 142 | + int backx;
|
| 143 | + int backy;
|
| 144 | + TEXTURE *stenciltex;
|
| 145 | + int stencilx;
|
| 146 | + int stencily;
|
149 | 147 | };
|
150 | 148 |
|
151 | 149 | #endif //_GLRENDERER_H |
\ No newline at end of file |
Index: ddraw/glutil.h |
— | — | @@ -28,6 +28,14 @@ |
29 | 29 | GLenum status;
|
30 | 30 | } FBO;
|
31 | 31 |
|
| 32 | +typedef struct
|
| 33 | +{
|
| 34 | + GLfloat x, y;
|
| 35 | + GLubyte r, g, b, a;
|
| 36 | + GLfloat s, t;
|
| 37 | + GLfloat padding[3];
|
| 38 | +} BltVertex;
|
| 39 | +
|
32 | 40 | extern FBO *currentfbo;
|
33 | 41 | class glDirectDrawSurface7;
|
34 | 42 |
|