Index: ddraw/glRenderer.cpp |
— | — | @@ -812,6 +812,8 @@ |
813 | 813 | ClearDepth(1.0);
|
814 | 814 | ClearStencil(0);
|
815 | 815 | EnableArray(-1,false);
|
| 816 | + BlendFunc(GL_ONE,GL_ZERO);
|
| 817 | + BlendEnable(false);
|
816 | 818 | glClear(GL_COLOR_BUFFER_BIT);
|
817 | 819 | glFlush();
|
818 | 820 | SetScissor(false,0,0,0,0);
|
— | — | @@ -848,6 +850,7 @@ |
849 | 851 | int progtype;
|
850 | 852 | LONG sizes[6];
|
851 | 853 | ddInterface->GetSizes(sizes);
|
| 854 | + BlendEnable(false);
|
852 | 855 | int error;
|
853 | 856 | error = SetFBO(dest->texture,0,false);
|
854 | 857 | SetViewport(0,0,dest->fakex,dest->fakey);
|
— | — | @@ -1043,6 +1046,7 @@ |
1044 | 1047 | {
|
1045 | 1048 | int progtype;
|
1046 | 1049 | RECT r,r2;
|
| 1050 | + BlendEnable(false);
|
1047 | 1051 | if((dest->ddsd.ddsCaps.dwCaps & DDSCAPS_PRIMARYSURFACE))
|
1048 | 1052 | {
|
1049 | 1053 | GetClientRect(hWnd,&r);
|
— | — | @@ -1293,6 +1297,108 @@ |
1294 | 1298 | SetEvent(busy);
|
1295 | 1299 | }
|
1296 | 1300 |
|
| 1301 | +void SetBlend(DWORD src, DWORD dest)
|
| 1302 | +{
|
| 1303 | + GLenum glsrc, gldest;
|
| 1304 | + bool bothalpha = false;
|
| 1305 | + switch(src)
|
| 1306 | + {
|
| 1307 | + case D3DBLEND_ZERO:
|
| 1308 | + glsrc = GL_ZERO;
|
| 1309 | + break;
|
| 1310 | + case D3DBLEND_ONE:
|
| 1311 | + default:
|
| 1312 | + glsrc = GL_ONE;
|
| 1313 | + break;
|
| 1314 | + case D3DBLEND_SRCCOLOR:
|
| 1315 | + glsrc = GL_SRC_COLOR;
|
| 1316 | + break;
|
| 1317 | + case D3DBLEND_INVSRCCOLOR:
|
| 1318 | + glsrc = GL_ONE_MINUS_SRC_COLOR;
|
| 1319 | + break;
|
| 1320 | + case D3DBLEND_SRCALPHA:
|
| 1321 | + glsrc = GL_SRC_ALPHA;
|
| 1322 | + break;
|
| 1323 | + case D3DBLEND_INVSRCALPHA:
|
| 1324 | + glsrc = GL_ONE_MINUS_SRC_ALPHA;
|
| 1325 | + break;
|
| 1326 | + case D3DBLEND_DESTALPHA:
|
| 1327 | + glsrc = GL_DST_ALPHA;
|
| 1328 | + break;
|
| 1329 | + case D3DBLEND_INVDESTALPHA:
|
| 1330 | + glsrc = GL_ONE_MINUS_DST_ALPHA;
|
| 1331 | + break;
|
| 1332 | + case D3DBLEND_DESTCOLOR:
|
| 1333 | + glsrc = GL_DST_COLOR;
|
| 1334 | + break;
|
| 1335 | + case D3DBLEND_INVDESTCOLOR:
|
| 1336 | + glsrc = GL_ONE_MINUS_DST_COLOR;
|
| 1337 | + break;
|
| 1338 | + case D3DBLEND_SRCALPHASAT:
|
| 1339 | + glsrc = GL_SRC_ALPHA_SATURATE;
|
| 1340 | + break;
|
| 1341 | + case D3DBLEND_BOTHSRCALPHA:
|
| 1342 | + bothalpha = true;
|
| 1343 | + glsrc = GL_SRC_ALPHA;
|
| 1344 | + gldest = GL_ONE_MINUS_SRC_ALPHA;
|
| 1345 | + break;
|
| 1346 | + case D3DBLEND_BOTHINVSRCALPHA:
|
| 1347 | + bothalpha = true;
|
| 1348 | + glsrc = GL_ONE_MINUS_SRC_ALPHA;
|
| 1349 | + gldest = GL_SRC_ALPHA;
|
| 1350 | + break;
|
| 1351 | + }
|
| 1352 | +
|
| 1353 | + if(!bothalpha) switch(dest)
|
| 1354 | + {
|
| 1355 | + case D3DBLEND_ZERO:
|
| 1356 | + default:
|
| 1357 | + gldest = GL_ZERO;
|
| 1358 | + break;
|
| 1359 | + case D3DBLEND_ONE:
|
| 1360 | + gldest = GL_ONE;
|
| 1361 | + break;
|
| 1362 | + case D3DBLEND_SRCCOLOR:
|
| 1363 | + gldest = GL_SRC_COLOR;
|
| 1364 | + break;
|
| 1365 | + case D3DBLEND_INVSRCCOLOR:
|
| 1366 | + gldest = GL_ONE_MINUS_SRC_COLOR;
|
| 1367 | + break;
|
| 1368 | + case D3DBLEND_SRCALPHA:
|
| 1369 | + gldest = GL_SRC_ALPHA;
|
| 1370 | + break;
|
| 1371 | + case D3DBLEND_INVSRCALPHA:
|
| 1372 | + gldest = GL_ONE_MINUS_SRC_ALPHA;
|
| 1373 | + break;
|
| 1374 | + case D3DBLEND_DESTALPHA:
|
| 1375 | + gldest = GL_DST_ALPHA;
|
| 1376 | + break;
|
| 1377 | + case D3DBLEND_INVDESTALPHA:
|
| 1378 | + gldest = GL_ONE_MINUS_DST_ALPHA;
|
| 1379 | + break;
|
| 1380 | + case D3DBLEND_DESTCOLOR:
|
| 1381 | + gldest = GL_DST_COLOR;
|
| 1382 | + break;
|
| 1383 | + case D3DBLEND_INVDESTCOLOR:
|
| 1384 | + gldest = GL_ONE_MINUS_DST_COLOR;
|
| 1385 | + break;
|
| 1386 | + case D3DBLEND_SRCALPHASAT:
|
| 1387 | + gldest = GL_SRC_ALPHA_SATURATE;
|
| 1388 | + break;
|
| 1389 | + case D3DBLEND_BOTHSRCALPHA:
|
| 1390 | + bothalpha = true;
|
| 1391 | + glsrc = GL_SRC_ALPHA;
|
| 1392 | + gldest = GL_ONE_MINUS_SRC_ALPHA;
|
| 1393 | + break;
|
| 1394 | + case D3DBLEND_BOTHINVSRCALPHA:
|
| 1395 | + bothalpha = true;
|
| 1396 | + glsrc = GL_ONE_MINUS_SRC_ALPHA;
|
| 1397 | + gldest = GL_SRC_ALPHA;
|
| 1398 | + break;
|
| 1399 | + }
|
| 1400 | + BlendFunc(glsrc,gldest);
|
| 1401 | +}
|
| 1402 | +
|
1297 | 1403 | void glRenderer::_DrawPrimitives(glDirect3DDevice7 *device, GLenum mode, GLVERTEX *vertices, int *texformats, DWORD count, LPWORD indices,
|
1298 | 1404 | DWORD indexcount, DWORD flags)
|
1299 | 1405 | {
|
— | — | @@ -1476,6 +1582,9 @@ |
1477 | 1583 | else SetFBO(device->glDDS7->texture,0,false);
|
1478 | 1584 | SetViewport(device->viewport.dwX,device->viewport.dwY,device->viewport.dwWidth,device->viewport.dwHeight);
|
1479 | 1585 | SetDepthRange(device->viewport.dvMinZ,device->viewport.dvMaxZ);
|
| 1586 | + if(device->renderstate[D3DRENDERSTATE_ALPHABLENDENABLE]) BlendEnable(true);
|
| 1587 | + else BlendEnable(false);
|
| 1588 | + SetBlend(device->renderstate[D3DRENDERSTATE_SRCBLEND],device->renderstate[D3DRENDERSTATE_DESTBLEND]);
|
1480 | 1589 | if(indices) glDrawElements(mode,indexcount,GL_UNSIGNED_SHORT,indices);
|
1481 | 1590 | else glDrawArrays(mode,0,count);
|
1482 | 1591 | if(device->glDDS7->zbuffer) device->glDDS7->zbuffer->dirty |= 2;
|
Index: ddraw/glutil.cpp |
— | — | @@ -51,6 +51,9 @@ |
52 | 52 | GLclampf cleara = 0.0;
|
53 | 53 | GLclampd cleardepth = 1.0;
|
54 | 54 | GLint clearstencil = 0;
|
| 55 | +GLenum blendsrc = GL_ONE;
|
| 56 | +GLenum blenddest = GL_ZERO;
|
| 57 | +bool blendenabled = false;
|
55 | 58 | bool arrays[42];
|
56 | 59 |
|
57 | 60 | void InitFBO()
|
— | — | @@ -345,4 +348,24 @@ |
346 | 349 | if(enabled) glEnableVertexAttribArray(index);
|
347 | 350 | else glDisableVertexAttribArray(index);
|
348 | 351 | }
|
| 352 | +}
|
| 353 | +
|
| 354 | +void BlendFunc(GLenum src, GLenum dest)
|
| 355 | +{
|
| 356 | + if((blendsrc != src) || (blenddest != dest))
|
| 357 | + {
|
| 358 | + blendsrc = src;
|
| 359 | + blenddest = dest;
|
| 360 | + glBlendFunc(src,dest);
|
| 361 | + }
|
| 362 | +}
|
| 363 | +
|
| 364 | +void BlendEnable(bool enabled)
|
| 365 | +{
|
| 366 | + if(enabled != blendenabled)
|
| 367 | + {
|
| 368 | + blendenabled = enabled;
|
| 369 | + if(enabled) glEnable(GL_BLEND);
|
| 370 | + else glDisable(GL_BLEND);
|
| 371 | + }
|
349 | 372 | } |
\ No newline at end of file |
Index: ddraw/glutil.h |
— | — | @@ -42,5 +42,7 @@ |
43 | 43 | void ClearDepth(GLclampd depth);
|
44 | 44 | void ClearStencil(GLint stencil);
|
45 | 45 | void EnableArray(int index, bool enabled);
|
| 46 | +void BlendFunc(GLenum src, GLenum dest);
|
| 47 | +void BlendEnable(bool enabled);
|
46 | 48 |
|
47 | 49 | #endif //_GLUTIL_H |
\ No newline at end of file |
Index: dxgltest/Resource.h |
— | — | @@ -39,6 +39,7 @@ |
40 | 40 | #define IDC_TEXTUREPREVIEW 1003
|
41 | 41 | #define IDC_DISPLAY 1004
|
42 | 42 | #define IDC_TESTLIST 1004
|
| 43 | +#define IDC_ALPHABLEND 1006
|
43 | 44 | #define IDC_BGCOLOR 1007
|
44 | 45 | #define IDC_WINDOWED 1008
|
45 | 46 | #define IDC_FULLSCREEN 1009
|
— | — | @@ -98,7 +99,6 @@ |
99 | 100 | #define IDC_FACTORSELECT 1085
|
100 | 101 | #define IDC_FOGCOLOR 1086
|
101 | 102 | #define IDC_FOGCOLORSELECT 1087
|
102 | | -#define IDC_ALPHATEST 1088
|
103 | 103 | #define IDC_SRCBLEND 1089
|
104 | 104 | #define IDC_DESTBLEND 1090
|
105 | 105 | #define IDC_ALPHAREF 1091
|
— | — | @@ -113,3 +113,4 @@ |
114 | 114 | #define IDC_FOGDENSITY 1100
|
115 | 115 | #define IDC_RANGEBASEDFOG 1101
|
116 | 116 | #define IDC_BGCOLORSELECT 1102
|
| 117 | +#define IDC_ALPHATEST 1103
|
Index: dxgltest/Tests3D.cpp |
— | — | @@ -1286,6 +1286,28 @@ |
1287 | 1287 | d3d7dev->SetRenderState(D3DRENDERSTATE_TEXTUREFACTOR,number);
|
1288 | 1288 | }
|
1289 | 1289 | break;
|
| 1290 | + case IDC_ALPHABLEND:
|
| 1291 | + if(HIWORD(wParam) == BN_CLICKED)
|
| 1292 | + {
|
| 1293 | + if(SendDlgItemMessage(hWnd,IDC_ALPHABLEND,BM_GETCHECK,0,0) == BST_CHECKED)
|
| 1294 | + d3d7dev->SetRenderState(D3DRENDERSTATE_ALPHABLENDENABLE,TRUE);
|
| 1295 | + else d3d7dev->SetRenderState(D3DRENDERSTATE_ALPHABLENDENABLE,FALSE);
|
| 1296 | + }
|
| 1297 | + break;
|
| 1298 | + case IDC_SRCBLEND:
|
| 1299 | + if(HIWORD(wParam) == CBN_SELCHANGE)
|
| 1300 | + {
|
| 1301 | + d3d7dev->SetRenderState(D3DRENDERSTATE_SRCBLEND,SendDlgItemMessage(hWnd,
|
| 1302 | + IDC_SRCBLEND,CB_GETCURSEL,0,0)+1);
|
| 1303 | + }
|
| 1304 | + case IDC_DESTBLEND:
|
| 1305 | + if(HIWORD(wParam) == CBN_SELCHANGE)
|
| 1306 | + {
|
| 1307 | + d3d7dev->SetRenderState(D3DRENDERSTATE_DESTBLEND,SendDlgItemMessage(hWnd,
|
| 1308 | + IDC_DESTBLEND,CB_GETCURSEL,0,0)+1);
|
| 1309 | + }
|
| 1310 | + break;
|
| 1311 | +
|
1290 | 1312 | }
|
1291 | 1313 | break;
|
1292 | 1314 | case WM_CLOSE:
|
Index: dxgltest/dxgltest.rc |
Cannot display: file marked as a binary type. |
svn:mime-type = application/octet-stream |