Index: ddraw/common.h |
— | — | @@ -1,5 +1,5 @@ |
2 | 2 | // DXGL
|
3 | | -// Copyright (C) 2011-2015 William Feely
|
| 3 | +// Copyright (C) 2011-2016 William Feely
|
4 | 4 |
|
5 | 5 | // This library is free software; you can redistribute it and/or
|
6 | 6 | // modify it under the terms of the GNU Lesser General Public
|
— | — | @@ -31,6 +31,7 @@ |
32 | 32 | #include "include/GL/glext.h"
|
33 | 33 | #include "include/GL/wglext.h"
|
34 | 34 | #include "struct.h"
|
| 35 | +#include "const.h"
|
35 | 36 | #include "glExtensions.h"
|
36 | 37 | #ifdef __cplusplus
|
37 | 38 | #include "string.h"
|
Index: ddraw/const.c |
— | — | @@ -0,0 +1,20 @@ |
| 2 | +// DXGL
|
| 3 | +// Copyright (C) 2016 William Feely
|
| 4 | +
|
| 5 | +// This library is free software; you can redistribute it and/or
|
| 6 | +// modify it under the terms of the GNU Lesser General Public
|
| 7 | +// License as published by the Free Software Foundation; either
|
| 8 | +// version 2.1 of the License, or (at your option) any later version.
|
| 9 | +
|
| 10 | +// This library is distributed in the hope that it will be useful,
|
| 11 | +// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
| 12 | +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
| 13 | +// Lesser General Public License for more details.
|
| 14 | +
|
| 15 | +// You should have received a copy of the GNU Lesser General Public
|
| 16 | +// License along with this library; if not, write to the Free Software
|
| 17 | +// Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
| 18 | +
|
| 19 | +#include "common.h"
|
| 20 | +
|
| 21 | +const RECT nullrect = { -1,-1,-1,-1 }; |
\ No newline at end of file |
Index: ddraw/const.h |
— | — | @@ -0,0 +1,32 @@ |
| 2 | +// DXGL
|
| 3 | +// Copyright (C) 2016 William Feely
|
| 4 | +
|
| 5 | +// This library is free software; you can redistribute it and/or
|
| 6 | +// modify it under the terms of the GNU Lesser General Public
|
| 7 | +// License as published by the Free Software Foundation; either
|
| 8 | +// version 2.1 of the License, or (at your option) any later version.
|
| 9 | +
|
| 10 | +// This library is distributed in the hope that it will be useful,
|
| 11 | +// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
| 12 | +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
| 13 | +// Lesser General Public License for more details.
|
| 14 | +
|
| 15 | +// You should have received a copy of the GNU Lesser General Public
|
| 16 | +// License along with this library; if not, write to the Free Software
|
| 17 | +// Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
| 18 | +
|
| 19 | +#pragma once
|
| 20 | +#ifndef __CONST_H
|
| 21 | +#define __CONST_H
|
| 22 | +
|
| 23 | +#ifdef __cplusplus
|
| 24 | +extern "C" {
|
| 25 | +#endif
|
| 26 | +
|
| 27 | + extern const RECT nullrect;
|
| 28 | +
|
| 29 | +#ifdef __cplusplus
|
| 30 | +}
|
| 31 | +#endif
|
| 32 | +
|
| 33 | +#endif //__CONST_H |
\ No newline at end of file |
Index: ddraw/ddraw.vcxproj |
— | — | @@ -278,6 +278,7 @@ |
279 | 279 | </ItemGroup>
|
280 | 280 | <ItemGroup>
|
281 | 281 | <ClInclude Include="common.h" />
|
| 282 | + <ClInclude Include="const.h" />
|
282 | 283 | <ClInclude Include="ddraw.h" />
|
283 | 284 | <ClInclude Include="glClassFactory.h" />
|
284 | 285 | <ClInclude Include="glDirect3D.h" />
|
— | — | @@ -320,6 +321,14 @@ |
321 | 322 | <ClInclude Include="util.h" />
|
322 | 323 | </ItemGroup>
|
323 | 324 | <ItemGroup>
|
| 325 | + <ClCompile Include="const.c">
|
| 326 | + <PrecompiledHeader Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">NotUsing</PrecompiledHeader>
|
| 327 | + <PrecompiledHeader Condition="'$(Configuration)|$(Platform)'=='Release no DXGL|Win32'">NotUsing</PrecompiledHeader>
|
| 328 | + <PrecompiledHeader Condition="'$(Configuration)|$(Platform)'=='Debug No MSVCRT|Win32'">NotUsing</PrecompiledHeader>
|
| 329 | + <PrecompiledHeader Condition="'$(Configuration)|$(Platform)'=='Debug no DXGL|Win32'">NotUsing</PrecompiledHeader>
|
| 330 | + <PrecompiledHeader Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">NotUsing</PrecompiledHeader>
|
| 331 | + <PrecompiledHeader Condition="'$(Configuration)|$(Platform)'=='Debug Trace|Win32'">NotUsing</PrecompiledHeader>
|
| 332 | + </ClCompile>
|
324 | 333 | <ClCompile Include="ddraw.cpp" />
|
325 | 334 | <ClCompile Include="dllmain.cpp">
|
326 | 335 | <CompileAsManaged Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">false</CompileAsManaged>
|
Index: ddraw/ddraw.vcxproj.filters |
— | — | @@ -152,6 +152,9 @@ |
153 | 153 | <ClInclude Include="struct.h">
|
154 | 154 | <Filter>Header Files</Filter>
|
155 | 155 | </ClInclude>
|
| 156 | + <ClInclude Include="const.h">
|
| 157 | + <Filter>Header Files</Filter>
|
| 158 | + </ClInclude>
|
156 | 159 | </ItemGroup>
|
157 | 160 | <ItemGroup>
|
158 | 161 | <ClCompile Include="ddraw.cpp">
|
— | — | @@ -256,6 +259,9 @@ |
257 | 260 | <ClCompile Include="glTexture.cpp">
|
258 | 261 | <Filter>Source Files</Filter>
|
259 | 262 | </ClCompile>
|
| 263 | + <ClCompile Include="const.c">
|
| 264 | + <Filter>Source Files</Filter>
|
| 265 | + </ClCompile>
|
260 | 266 | </ItemGroup>
|
261 | 267 | <ItemGroup>
|
262 | 268 | <ResourceCompile Include="ddraw.rc">
|
Index: ddraw/glDirectDraw.cpp |
— | — | @@ -470,8 +470,8 @@ |
471 | 471 | DEVMODE *tmp;
|
472 | 472 | if(!modes) ERR(DDERR_OUTOFMEMORY);
|
473 | 473 | DDSURFACEDESC2 ddmode;
|
474 | | - ZeroMemory(&ddmode,sizeof(DDSURFACEDESC));
|
475 | | - ddmode.dwSize = sizeof(DDSURFACEDESC);
|
| 474 | + ZeroMemory(&ddmode,sizeof(DDSURFACEDESC2));
|
| 475 | + ddmode.dwSize = sizeof(DDSURFACEDESC2);
|
476 | 476 | ddmode.dwFlags = DDSD_HEIGHT | DDSD_WIDTH | DDSD_PITCH | DDSD_PIXELFORMAT | DDSD_REFRESHRATE;
|
477 | 477 | while(EnumDisplaySettings(NULL,modenum++,&mode))
|
478 | 478 | {
|
— | — | @@ -1442,7 +1442,7 @@ |
1443 | 1443 | glDD7->internalx = glDD7->screenx = dwWidth;
|
1444 | 1444 | glDD7->internaly = glDD7->screeny = dwHeight;
|
1445 | 1445 | if (glDD7->renderer && glDD7->primary) glRenderer_DrawScreen(glDD7->renderer, glDD7->primary->texture,
|
1446 | | - glDD7->primary->texture->palette, glDD7->primary, glDD7->primary, 0);
|
| 1446 | + glDD7->primary->texture->palette, 0);
|
1447 | 1447 | }
|
1448 | 1448 |
|
1449 | 1449 |
|
— | — | @@ -1952,7 +1952,7 @@ |
1953 | 1953 | if(dwFlags & 0xFFFFFFFA) TRACE_RET(HRESULT,23,DDERR_INVALIDPARAMS);
|
1954 | 1954 | if(dwFlags == 5) TRACE_RET(HRESULT,23,DDERR_INVALIDPARAMS);
|
1955 | 1955 | if(!lastsync) lastsync = true;
|
1956 | | - else if(primary) primary->RenderScreen(primary->texture,primary,1);
|
| 1956 | + else if(primary) primary->RenderScreen(primary->texture,1);
|
1957 | 1957 | TRACE_EXIT(23,DD_OK);
|
1958 | 1958 | return DD_OK;
|
1959 | 1959 | }
|
Index: ddraw/glDirectDrawClipper.cpp |
— | — | @@ -517,5 +517,5 @@ |
518 | 518 | ddsd.dwWidth = texture->levels[0].ddsd.dwWidth;
|
519 | 519 | ddsd.lPitch = NextMultipleOf4(ddsd.dwWidth * 2);
|
520 | 520 | ddsd.dwHeight = texture->levels[0].ddsd.dwHeight;
|
521 | | - glTexture_Create(&ddsd, &This->texture, renderer, ddsd.dwWidth, ddsd.dwHeight, FALSE);
|
| 521 | + glTexture_Create(&ddsd, &This->texture, renderer, ddsd.dwWidth, ddsd.dwHeight, FALSE, FALSE);
|
522 | 522 | } |
\ No newline at end of file |
Index: ddraw/glDirectDrawPalette.c |
— | — | @@ -309,7 +309,7 @@ |
310 | 310 | DDSURFACEDESC2 ddsd;
|
311 | 311 | ZeroMemory(&ddsd, sizeof(DDSURFACEDESC2));
|
312 | 312 | memcpy(&ddsd, &ddsd256pal, sizeof(DDSURFACEDESC2));
|
313 | | - glTexture_Create(&ddsd256pal, &This->texture, renderer, 256, 1, FALSE);
|
| 313 | + glTexture_Create(&ddsd256pal, &This->texture, renderer, 256, 1, FALSE, FALSE);
|
314 | 314 | glTexture_Lock(This->texture, 0, NULL, &ddsd, 0, FALSE);
|
315 | 315 | memcpy(ddsd.lpSurface, This->palette, 1024);
|
316 | 316 | glTexture_Unlock(This->texture, 0, NULL, FALSE);
|
Index: ddraw/glDirectDrawSurface.cpp |
— | — | @@ -52,9 +52,6 @@ |
53 | 53 | pagelocked = 0;
|
54 | 54 | flipcount = 0;
|
55 | 55 | ZeroMemory(colorkey,4*sizeof(CKEY));
|
56 | | - ZeroMemory(&fbo,sizeof(FBO));
|
57 | | - ZeroMemory(&zfbo,sizeof(FBO));
|
58 | | - ZeroMemory(&stencilfbo,sizeof(FBO));
|
59 | 56 | palette = NULL;
|
60 | 57 | texture = NULL;
|
61 | 58 | clipper = NULL;
|
— | — | @@ -197,7 +194,7 @@ |
198 | 195 | texture = parenttex;
|
199 | 196 | glTexture_AddRef(texture);
|
200 | 197 | }
|
201 | | - else glTexture_Create(&ddsd, &texture, ddInterface->renderer, fakex, fakey, FALSE);
|
| 198 | + else glTexture_Create(&ddsd, &texture, ddInterface->renderer, fakex, fakey, hasstencil, FALSE);
|
202 | 199 | if (!(ddsd.dwFlags & DDSD_PITCH))
|
203 | 200 | {
|
204 | 201 | ddsd.dwFlags |= DDSD_PITCH;
|
— | — | @@ -305,8 +302,6 @@ |
306 | 303 | if (d3dt2) delete d3dt2;
|
307 | 304 | if (gammacontrol) free(gammacontrol);
|
308 | 305 | if (texture) glTexture_Release(texture, FALSE);
|
309 | | - if(fbo.fbo) glRenderer_DeleteFBO(ddInterface->renderer, &fbo);
|
310 | | - if(stencilfbo.fbo) glRenderer_DeleteFBO(ddInterface->renderer, &stencilfbo);
|
311 | 306 | //if(bitmapinfo) free(bitmapinfo);
|
312 | 307 | if(palette) glDirectDrawPalette_Release(palette);
|
313 | 308 | if(backbuffer) backbuffer->Release();
|
— | — | @@ -628,11 +623,6 @@ |
629 | 624 | {
|
630 | 625 | if (zbuffer)
|
631 | 626 | {
|
632 | | - if (zbuffer->zfbo.fbo)
|
633 | | - {
|
634 | | - glRenderer_DeleteFBO(ddInterface->renderer, &zbuffer->zfbo);
|
635 | | - ZeroMemory(&zbuffer->zfbo, sizeof(FBO));
|
636 | | - }
|
637 | 627 | if (zbuffer->texture->dummycolor)
|
638 | 628 | {
|
639 | 629 | glTexture_DeleteDummyColor(zbuffer->texture, FALSE);
|
— | — | @@ -660,11 +650,25 @@ |
661 | 651 | HRESULT error;
|
662 | 652 | RECT tmprect;
|
663 | 653 | glDirectDrawSurface7 *pattern;
|
| 654 | + BltCommand cmd;
|
664 | 655 | TRACE_ENTER(6,14,this,26,lpDestRect,14,lpDDSrcSurface,26,lpSrcRect,9,dwFlags,14,lpDDBltFx);
|
665 | | - if(!this) TRACE_RET(HRESULT,23,DDERR_INVALIDOBJECT);
|
666 | | - if ((dwFlags & DDBLT_DEPTHFILL) && !lpDDBltFx) TRACE_RET(HRESULT,32,DDERR_INVALIDPARAMS);
|
667 | | - if((dwFlags & DDBLT_COLORFILL) && !lpDDBltFx) TRACE_RET(HRESULT,23,DDERR_INVALIDPARAMS);
|
668 | | - if((dwFlags & DDBLT_DDFX) && !lpDDBltFx) TRACE_RET(HRESULT,23,DDERR_INVALIDPARAMS);
|
| 656 | + if (!this) TRACE_RET(HRESULT, 23, DDERR_INVALIDOBJECT);
|
| 657 | + if ((dwFlags & DDBLT_DEPTHFILL) && !lpDDBltFx) TRACE_RET(HRESULT, 32, DDERR_INVALIDPARAMS);
|
| 658 | + if ((dwFlags & DDBLT_COLORFILL) && !lpDDBltFx) TRACE_RET(HRESULT, 23, DDERR_INVALIDPARAMS);
|
| 659 | + if ((dwFlags & DDBLT_DDFX) && !lpDDBltFx) TRACE_RET(HRESULT, 23, DDERR_INVALIDPARAMS);
|
| 660 | + ZeroMemory(&cmd, sizeof(BltCommand));
|
| 661 | + cmd.dest = this->texture;
|
| 662 | + cmd.destlevel = this->miplevel;
|
| 663 | + if (lpDestRect) cmd.destrect = *lpDestRect;
|
| 664 | + else cmd.destrect = nullrect;
|
| 665 | + if (lpSrcRect) cmd.srcrect = *lpSrcRect;
|
| 666 | + else cmd.srcrect = nullrect;
|
| 667 | + if (lpDDSrcSurface)
|
| 668 | + {
|
| 669 | + cmd.src = ((glDirectDrawSurface7*)lpDDSrcSurface)->texture;
|
| 670 | + cmd.srclevel = ((glDirectDrawSurface7*)lpDDSrcSurface)->miplevel;
|
| 671 | + }
|
| 672 | + cmd.flags = dwFlags;
|
669 | 673 | if (dwFlags & DDBLT_ROP)
|
670 | 674 | {
|
671 | 675 | if (!lpDDBltFx) TRACE_RET(HRESULT, 23, DDERR_INVALIDPARAMS);
|
— | — | @@ -672,16 +676,27 @@ |
673 | 677 | {
|
674 | 678 | if (!lpDDBltFx->lpDDSPattern) TRACE_RET(HRESULT, 23, DDERR_INVALIDPARAMS);
|
675 | 679 | pattern = (glDirectDrawSurface7*)lpDDBltFx->lpDDSPattern;
|
| 680 | + cmd.pattern = pattern->texture;
|
| 681 | + cmd.patternlevel = pattern->miplevel;
|
676 | 682 | }
|
677 | 683 | }
|
678 | 684 | if (dwFlags & DDBLT_KEYSRC)
|
679 | 685 | {
|
680 | 686 | if (!lpDDSrcSurface) TRACE_RET(HRESULT, 23, DDERR_INVALIDPARAMS);
|
681 | | - if (((glDirectDrawSurface7*)lpDDSrcSurface)->colorkey[0].colorspace) dwFlags |= 0x20000000;
|
| 687 | + if (!(((glDirectDrawSurface7*)lpDDSrcSurface)->ddsd.dwFlags & DDSD_CKSRCBLT))
|
| 688 | + TRACE_RET(HRESULT, 23, DDERR_INVALIDPARAMS);
|
| 689 | + if (((glDirectDrawSurface7*)lpDDSrcSurface)->ddsd.ddckCKSrcBlt.dwColorSpaceHighValue !=
|
| 690 | + ((glDirectDrawSurface7*)lpDDSrcSurface)->ddsd.ddckCKSrcBlt.dwColorSpaceLowValue)
|
| 691 | + cmd.flags |= 0x20000000;
|
682 | 692 | }
|
683 | | - if ((dwFlags & DDBLT_KEYDEST) && colorkey[1].colorspace) dwFlags |= 0x40000000;
|
| 693 | + if (dwFlags & DDBLT_KEYDEST)
|
| 694 | + {
|
| 695 | + if (!(this->ddsd.dwFlags & DDSD_CKDESTBLT)) TRACE_RET(HRESULT, 23, DDERR_INVALIDPARAMS);
|
| 696 | + if (this->ddsd.ddckCKDestBlt.dwColorSpaceHighValue != this->ddsd.ddckCKDestBlt.dwColorSpaceLowValue)
|
| 697 | + cmd.flags |= 0x40000000;
|
| 698 | + }
|
684 | 699 | glDirectDrawSurface7 *src = (glDirectDrawSurface7 *)lpDDSrcSurface;
|
685 | | - if (clipper)
|
| 700 | +/* if (clipper)
|
686 | 701 | {
|
687 | 702 | if (!clipper->hWnd)
|
688 | 703 | {
|
— | — | @@ -693,24 +708,42 @@ |
694 | 709 | }
|
695 | 710 | dwFlags |= 0x10000000;
|
696 | 711 | }
|
697 | | - }
|
| 712 | + }*/
|
| 713 | + if (this->clipper && !(this->clipper->hWnd)) cmd.flags |= 0x10000000;
|
| 714 | + if (lpDDBltFx) cmd.bltfx = *lpDDBltFx;
|
698 | 715 | if (dwFlags & DDBLT_DEPTHFILL)
|
699 | 716 | {
|
700 | | - if (!(ddsd.ddpfPixelFormat.dwFlags & DDPF_ZBUFFER)) TRACE_RET(HRESULT, 23, DDERR_UNSUPPORTED);
|
701 | | - TRACE_RET(HRESULT, 23, glRenderer_DepthFill(ddInterface->renderer, lpDestRect, this, lpDDBltFx));
|
| 717 | + if (!(this->ddsd.ddpfPixelFormat.dwFlags & DDPF_ZBUFFER)) TRACE_RET(HRESULT, 23, DDERR_UNSUPPORTED);
|
| 718 | + if (this->attachparent)
|
| 719 | + {
|
| 720 | + TRACE_RET(HRESULT, 23, glRenderer_DepthFill(this->ddInterface->renderer, &cmd, this->attachparent->texture, this->attachparent->miplevel));
|
| 721 | + }
|
| 722 | + else
|
| 723 | + {
|
| 724 | + TRACE_RET(HRESULT, 23, glRenderer_DepthFill(this->ddInterface->renderer, &cmd, NULL, 0));
|
| 725 | + }
|
702 | 726 | }
|
703 | 727 | if (this == src)
|
704 | 728 | {
|
705 | 729 | tmprect.left = tmprect.top = 0;
|
706 | | - tmprect.right = lpSrcRect->right - lpSrcRect->left;
|
707 | | - tmprect.bottom = lpSrcRect->bottom - lpSrcRect->top;
|
708 | | - error = ddInterface->SetupTempSurface(tmprect.right, tmprect.bottom);
|
709 | | - if (error) TRACE_RET(HRESULT, 23, error);
|
710 | | - error = ddInterface->tmpsurface->Blt(&tmprect, lpDDSrcSurface, lpSrcRect, 0, NULL);
|
711 | | - if (error) TRACE_RET(HRESULT, 23, error);
|
712 | | - TRACE_RET(HRESULT,23,this->Blt(lpDestRect, ddInterface->tmpsurface, &tmprect, dwFlags, lpDDBltFx));
|
| 730 | + if (lpSrcRect)
|
| 731 | + {
|
| 732 | + tmprect.right = lpSrcRect->right - lpSrcRect->left;
|
| 733 | + tmprect.bottom = lpSrcRect->bottom - lpSrcRect->top;
|
| 734 | + }
|
| 735 | + else
|
| 736 | + {
|
| 737 | + tmprect.right = src->ddsd.dwWidth;
|
| 738 | + tmprect.bottom = src->ddsd.dwHeight;
|
| 739 | + }
|
| 740 | + error = this->ddInterface->SetupTempSurface(tmprect.right, tmprect.bottom);
|
| 741 | + if (FAILED(error)) TRACE_RET(HRESULT, 23, error);
|
| 742 | + error = this->ddInterface->tmpsurface->Blt(&tmprect, lpDDSrcSurface, lpSrcRect, 0, NULL);
|
| 743 | + if (FAILED(error)) TRACE_RET(HRESULT, 23, error);
|
| 744 | + TRACE_RET(HRESULT, 23, this->Blt(lpDestRect, (LPDIRECTDRAWSURFACE7)this->ddInterface->tmpsurface,
|
| 745 | + &tmprect, dwFlags, lpDDBltFx));
|
713 | 746 | }
|
714 | | - else TRACE_RET(HRESULT,23,glRenderer_Blt(ddInterface->renderer,lpDestRect,src,this,lpSrcRect,dwFlags,lpDDBltFx));
|
| 747 | + else TRACE_RET(HRESULT, 23, glRenderer_Blt(this->ddInterface->renderer, &cmd));
|
715 | 748 | }
|
716 | 749 | HRESULT WINAPI glDirectDrawSurface7::BltBatch(LPDDBLTBATCH lpDDBltBatch, DWORD dwCount, DWORD dwFlags)
|
717 | 750 | {
|
— | — | @@ -809,7 +842,7 @@ |
810 | 843 | swapinterval++;
|
811 | 844 | ddInterface->lastsync = false;
|
812 | 845 | }
|
813 | | - RenderScreen(texture,this,swapinterval);
|
| 846 | + RenderScreen(texture,swapinterval);
|
814 | 847 | }
|
815 | 848 | TRACE_EXIT(23,ret);
|
816 | 849 | return ret;
|
— | — | @@ -1045,7 +1078,7 @@ |
1046 | 1079 | TRACE_ENTER(2,14,this,14,lphDC);
|
1047 | 1080 | if(!this) TRACE_RET(HRESULT,23,DDERR_INVALIDOBJECT);
|
1048 | 1081 | if(!lphDC) TRACE_RET(HRESULT,23,DDERR_INVALIDPARAMS);
|
1049 | | - glDirectDrawPalette *pal;
|
| 1082 | + glDirectDrawPalette *pal = NULL;
|
1050 | 1083 | HRESULT error;
|
1051 | 1084 | if (ddsd.ddpfPixelFormat.dwRGBBitCount == 8)
|
1052 | 1085 | {
|
— | — | @@ -1155,10 +1188,10 @@ |
1156 | 1189 | {
|
1157 | 1190 | if (ddInterface->lastsync)
|
1158 | 1191 | {
|
1159 | | - RenderScreen(texture, this, 1);
|
| 1192 | + RenderScreen(texture, 1);
|
1160 | 1193 | ddInterface->lastsync = false;
|
1161 | 1194 | }
|
1162 | | - else RenderScreen(texture, this, 0);
|
| 1195 | + else RenderScreen(texture, 0);
|
1163 | 1196 | }
|
1164 | 1197 | TRACE_EXIT(23,error);
|
1165 | 1198 | return error;
|
— | — | @@ -1301,6 +1334,7 @@ |
1302 | 1335 | ddsd.dwFlags |= DDSD_CKDESTOVERLAY;
|
1303 | 1336 | colorkey[3] = key;
|
1304 | 1337 | }
|
| 1338 | + glRenderer_SetTextureColorKey(this->ddInterface->renderer, this->texture, dwFlags, lpDDColorKey, this->miplevel);
|
1305 | 1339 | TRACE_EXIT(23,DD_OK);
|
1306 | 1340 | return DD_OK;
|
1307 | 1341 | }
|
— | — | @@ -1357,10 +1391,10 @@ |
1358 | 1392 | {
|
1359 | 1393 | if(ddInterface->lastsync)
|
1360 | 1394 | {
|
1361 | | - RenderScreen(texture,this,1);
|
| 1395 | + RenderScreen(texture,1);
|
1362 | 1396 | ddInterface->lastsync = false;
|
1363 | 1397 | }
|
1364 | | - else RenderScreen(texture,this,0);
|
| 1398 | + else RenderScreen(texture,0);
|
1365 | 1399 | }
|
1366 | 1400 | TRACE_EXIT(23, DD_OK);
|
1367 | 1401 | return DD_OK;
|
— | — | @@ -1390,10 +1424,10 @@ |
1391 | 1425 | ERR(DDERR_GENERIC);
|
1392 | 1426 | }
|
1393 | 1427 |
|
1394 | | -void glDirectDrawSurface7::RenderScreen(glTexture *texture, glDirectDrawSurface7 *surface, int vsync)
|
| 1428 | +void glDirectDrawSurface7::RenderScreen(glTexture *texture, int vsync)
|
1395 | 1429 | {
|
1396 | | - TRACE_ENTER(3,14,this,14,texture,14,surface);
|
1397 | | - glRenderer_DrawScreen(ddInterface->renderer,texture, texture->palette, this, surface, vsync);
|
| 1430 | + TRACE_ENTER(3,14,this,14,texture,14,vsync);
|
| 1431 | + glRenderer_DrawScreen(ddInterface->renderer,texture, texture->palette, vsync);
|
1398 | 1432 | TRACE_EXIT(0,0);
|
1399 | 1433 | }
|
1400 | 1434 | // ddraw 2+ api
|
Index: ddraw/glDirectDrawSurface.h |
— | — | @@ -117,7 +117,7 @@ |
118 | 118 | void SetTexture(glTexture *newtexture){ texture = newtexture; };
|
119 | 119 | glDirectDrawSurface7 *GetBackbuffer(){return backbuffer;};
|
120 | 120 | glDirectDrawSurface7 *GetZBuffer(){return zbuffer;};
|
121 | | - void RenderScreen(glTexture *texture, glDirectDrawSurface7 *surface, int vsync);
|
| 121 | + void RenderScreen(glTexture *texture, int vsync);
|
122 | 122 | // Special ddraw2->ddraw7 api
|
123 | 123 | HRESULT WINAPI Unlock2(LPVOID lpSurfaceData);
|
124 | 124 | HRESULT GetHandle(glDirect3DDevice7 *glD3DDev7, LPD3DTEXTUREHANDLE lpHandle);
|
— | — | @@ -142,9 +142,6 @@ |
143 | 143 | glDirectDrawPalette *palette;
|
144 | 144 | HGLRC hRC;
|
145 | 145 | D3DMATERIALHANDLE handle;
|
146 | | - FBO fbo;
|
147 | | - FBO zfbo;
|
148 | | - FBO stencilfbo;
|
149 | 146 | glDirectDrawClipper *clipper;
|
150 | 147 | IUnknown *creator;
|
151 | 148 | IUnknown *textureparent;
|
Index: ddraw/glRenderer.cpp |
— | — | @@ -343,51 +343,29 @@ |
344 | 344 | }
|
345 | 345 |
|
346 | 346 | /**
|
347 | | - * Copies the contents of one surface to another.
|
| 347 | + * Copies part or all of the contents of one texture to another.
|
348 | 348 | * @param This
|
349 | 349 | * Pointer to glRenderer object
|
350 | | - * @param lpDestRect
|
351 | | - * Pointer to the coordinates to blit to. If NULL, blits to the entire surface.
|
352 | | - * @param src
|
353 | | - * Surface to be used as the source.
|
354 | | - * @param dest
|
355 | | - * Surface to blit to.
|
356 | | - * @param lpSrcRect
|
357 | | - * Pointer of the coordinates to blit from on the source surface. If NULL, the
|
358 | | - * entire surface will be used.
|
359 | | - * @param dwFlags
|
360 | | - * Flags to determine the behavior of the blitter. Certain flags control the
|
361 | | - * synchronization of the operation: (not yet implemented)
|
362 | | - * - DDBLT_ASYNC: Adds the command to the queue. If the queue is full, returns
|
363 | | - * DDERR_WASSTILLDRAWING.
|
364 | | - * - DDBLT_DONOTWAIT: Fails and returns DDERR_WASSTILLDRAWING if the queue is full.
|
365 | | - * - DDBLT_WAIT: Waits until the Blt command is processed before returning.
|
366 | | - * @param lpDDBltFx
|
367 | | - * Effect parameters for the Blt operation.
|
| 350 | + * @param cmd
|
| 351 | + * Pointer to structure contaning all paramaters for a Blt operation.
|
368 | 352 | * @return
|
369 | | - * DD_OK if the call succeeds, or DDERR_WASSTILLDRAWING if busy.
|
| 353 | + * DD_OK if the call succeeds, or DDERR_WASSTILLDRAWING if queue is full and not waiting.
|
370 | 354 | */
|
371 | | -HRESULT glRenderer_Blt(glRenderer *This, LPRECT lpDestRect, glDirectDrawSurface7 *src,
|
372 | | - glDirectDrawSurface7 *dest, LPRECT lpSrcRect, DWORD dwFlags, LPDDBLTFX lpDDBltFx)
|
| 355 | +HRESULT glRenderer_Blt(glRenderer *This, BltCommand *cmd)
|
373 | 356 | {
|
374 | 357 | EnterCriticalSection(&This->cs);
|
375 | 358 | RECT r,r2;
|
376 | | - if(((dest->ddsd.ddsCaps.dwCaps & (DDSCAPS_FRONTBUFFER)) &&
|
377 | | - (dest->ddsd.ddsCaps.dwCaps & DDSCAPS_PRIMARYSURFACE)) ||
|
378 | | - ((dest->ddsd.ddsCaps.dwCaps & DDSCAPS_PRIMARYSURFACE) &&
|
379 | | - !(dest->ddsd.ddsCaps.dwCaps & DDSCAPS_FLIP)))
|
| 359 | + if(((cmd->dest->levels[0].ddsd.ddsCaps.dwCaps & (DDSCAPS_FRONTBUFFER)) &&
|
| 360 | + (cmd->dest->levels[0].ddsd.ddsCaps.dwCaps & DDSCAPS_PRIMARYSURFACE)) ||
|
| 361 | + ((cmd->dest->levels[0].ddsd.ddsCaps.dwCaps & DDSCAPS_PRIMARYSURFACE) &&
|
| 362 | + !(cmd->dest->levels[0].ddsd.ddsCaps.dwCaps & DDSCAPS_FLIP)))
|
380 | 363 | {
|
381 | 364 | GetClientRect(This->hWnd,&r);
|
382 | 365 | GetClientRect(This->RenderWnd->GetHWnd(),&r2);
|
383 | 366 | if(memcmp(&r2,&r,sizeof(RECT)) != 0)
|
384 | | - SetWindowPos(This->RenderWnd->GetHWnd(),NULL,0,0,r.right,r.bottom,SWP_SHOWWINDOW);
|
| 367 | + SetWindowPos(This->RenderWnd->GetHWnd(),NULL,0,0,r.right,r.bottom,SWP_SHOWWINDOW);
|
385 | 368 | }
|
386 | | - This->inputs[0] = lpDestRect;
|
387 | | - This->inputs[1] = src;
|
388 | | - This->inputs[2] = dest;
|
389 | | - This->inputs[3] = lpSrcRect;
|
390 | | - This->inputs[4] = (void*)dwFlags;
|
391 | | - This->inputs[5] = lpDDBltFx;
|
| 369 | + This->inputs[0] = cmd;
|
392 | 370 | This->opcode = OP_BLT;
|
393 | 371 | SetEvent(This->start);
|
394 | 372 | WaitForSingleObject(This->busy,INFINITE);
|
— | — | @@ -410,14 +388,12 @@ |
411 | 389 | * @param vsync
|
412 | 390 | * Vertical sync count
|
413 | 391 | */
|
414 | | -void glRenderer_DrawScreen(glRenderer *This, glTexture *texture, glTexture *paltex, glDirectDrawSurface7 *dest, glDirectDrawSurface7 *src, GLint vsync)
|
| 392 | +void glRenderer_DrawScreen(glRenderer *This, glTexture *texture, glTexture *paltex, GLint vsync)
|
415 | 393 | {
|
416 | 394 | EnterCriticalSection(&This->cs);
|
417 | 395 | This->inputs[0] = texture;
|
418 | 396 | This->inputs[1] = paltex;
|
419 | | - This->inputs[2] = dest;
|
420 | | - This->inputs[3] = src;
|
421 | | - This->inputs[4] = (void*)vsync;
|
| 397 | + This->inputs[2] = (void*)vsync;
|
422 | 398 | This->opcode = OP_DRAWSCREEN;
|
423 | 399 | SetEvent(This->start);
|
424 | 400 | WaitForSingleObject(This->busy,INFINITE);
|
— | — | @@ -671,22 +647,25 @@ |
672 | 648 | }
|
673 | 649 |
|
674 | 650 | /**
|
675 | | - * Fills a depth surface with a specified value.
|
676 | | - * @param This
|
677 | | - * Pointer to glRenderer object
|
678 | | - * @param lpDestRect
|
679 | | - * Pointer to bounding rectangle for depth fill. If NULL, then fill entire surface
|
680 | | - * @param dest
|
681 | | - * Destination surface to depth fill
|
682 | | - * @param lpDDBltFx
|
683 | | - * Pointer to DDBLTFX structure with dwFillDepth defining the depth value.
|
684 | | - */
|
685 | | -HRESULT glRenderer_DepthFill(glRenderer *This, LPRECT lpDestRect, glDirectDrawSurface7 *dest, LPDDBLTFX lpDDBltFx)
|
| 651 | +* Fills a depth surface with a specified value.
|
| 652 | +* @param This
|
| 653 | +* Pointer to glRenderer object
|
| 654 | +* @param cmd
|
| 655 | +* Pointer to structure contaning all paramaters for a Blt operation, with
|
| 656 | +* appropriate depth fill parameters filled in.
|
| 657 | +* @param parent
|
| 658 | +* Texture representing parent surface
|
| 659 | +* @param parentlevel
|
| 660 | +* Mipmap level of parent surface
|
| 661 | +* @return
|
| 662 | +* DD_OK if the depth fill succeeded.
|
| 663 | +*/
|
| 664 | +HRESULT glRenderer_DepthFill(glRenderer *This, BltCommand *cmd, glTexture *parent, GLint parentlevel)
|
686 | 665 | {
|
687 | 666 | EnterCriticalSection(&This->cs);
|
688 | | - This->inputs[0] = lpDestRect;
|
689 | | - This->inputs[1] = dest;
|
690 | | - This->inputs[2] = lpDDBltFx;
|
| 667 | + This->inputs[0] = cmd;
|
| 668 | + This->inputs[1] = parent;
|
| 669 | + This->inputs[2] = (void*)parentlevel;
|
691 | 670 | This->opcode = OP_DEPTHFILL;
|
692 | 671 | SetEvent(This->start);
|
693 | 672 | WaitForSingleObject(This->busy, INFINITE);
|
— | — | @@ -836,6 +815,32 @@ |
837 | 816 | }
|
838 | 817 |
|
839 | 818 | /**
|
| 819 | +* Sets a color key for a texture object.
|
| 820 | +* @param This
|
| 821 | +* Pointer to glRenderer object
|
| 822 | +* @param texture
|
| 823 | +* Texture to set color key on
|
| 824 | +* @param dwFlags
|
| 825 | +* DDraw color key flags to select color key to add or update
|
| 826 | +* @param lpDDColorKey
|
| 827 | +* Pointer to a DDraw color key structure to set in the texture
|
| 828 | +* @param level
|
| 829 | +* Mip level of color key to set for DirectDraw; Direct3D colorkey operations use level 0
|
| 830 | +*/
|
| 831 | +void glRenderer_SetTextureColorKey(glRenderer *This, glTexture *texture, DWORD dwFlags, LPDDCOLORKEY lpDDColorKey, GLint level)
|
| 832 | +{
|
| 833 | + EnterCriticalSection(&This->cs);
|
| 834 | + This->inputs[0] = texture;
|
| 835 | + This->inputs[1] = (void*)dwFlags;
|
| 836 | + This->inputs[2] = lpDDColorKey;
|
| 837 | + This->inputs[3] = (void*)level;
|
| 838 | + This->opcode = OP_SETTEXTURECOLORKEY;
|
| 839 | + SetEvent(This->start);
|
| 840 | + WaitForSingleObject(This->busy, INFINITE);
|
| 841 | + LeaveCriticalSection(&This->cs);
|
| 842 | +}
|
| 843 | +
|
| 844 | +/**
|
840 | 845 | * Generates a glFrameTerminatorGREMEDY command in OpenGL if the
|
841 | 846 | * glFrameTerminatorGREMEDY command is available (i.e. running under gDebugger).
|
842 | 847 | * @param This
|
— | — | @@ -931,12 +936,11 @@ |
932 | 937 | glRenderer__DeleteTexture(This,(glTexture*)This->inputs[0]);
|
933 | 938 | break;
|
934 | 939 | case OP_BLT:
|
935 | | - glRenderer__Blt(This,(LPRECT)This->inputs[0],(glDirectDrawSurface7*)This->inputs[1],
|
936 | | - (glDirectDrawSurface7*)This->inputs[2],(LPRECT)This->inputs[3],(DWORD)This->inputs[4],(LPDDBLTFX)This->inputs[5]);
|
| 940 | + glRenderer__Blt(This, (BltCommand*)This->inputs[0]);
|
937 | 941 | break;
|
938 | 942 | case OP_DRAWSCREEN:
|
939 | 943 | glRenderer__DrawScreen(This,(glTexture*)This->inputs[0],(glTexture*)This->inputs[1],
|
940 | | - (glDirectDrawSurface7*)This->inputs[2],(glDirectDrawSurface7*)This->inputs[3],(GLint)This->inputs[4],true);
|
| 944 | + (GLint)This->inputs[2],true);
|
941 | 945 | break;
|
942 | 946 | case OP_INITD3D:
|
943 | 947 | glRenderer__InitD3D(This,(int)This->inputs[0],(int)This->inputs[1],(int)This->inputs[2]);
|
— | — | @@ -961,8 +965,7 @@ |
962 | 966 | glRenderer__UpdateClipper(This,(glDirectDrawSurface7*)This->inputs[0]);
|
963 | 967 | break;
|
964 | 968 | case OP_DEPTHFILL:
|
965 | | - glRenderer__DepthFill(This, (LPRECT)This->inputs[0], (glDirectDrawSurface7*)This->inputs[1],
|
966 | | - (LPDDBLTFX)This->inputs[2]);
|
| 969 | + glRenderer__DepthFill(This, (BltCommand*)This->inputs[0], (glTexture*)This->inputs[1], (GLint)This->inputs[2]);
|
967 | 970 | break;
|
968 | 971 | case OP_SETRENDERSTATE:
|
969 | 972 | glRenderer__SetRenderState(This, (D3DRENDERSTATETYPE)(DWORD)This->inputs[0], (DWORD)This->inputs[1]);
|
— | — | @@ -986,6 +989,10 @@ |
987 | 990 | case OP_SETVIEWPORT:
|
988 | 991 | glRenderer__SetViewport(This, (LPD3DVIEWPORT7)This->inputs[0]);
|
989 | 992 | break;
|
| 993 | + case OP_SETTEXTURECOLORKEY:
|
| 994 | + glRenderer__SetTextureColorKey(This, (glTexture*)This->inputs[0], (DWORD)This->inputs[1],
|
| 995 | + (LPDDCOLORKEY)This->inputs[2], (GLint)This->inputs[3]);
|
| 996 | + break;
|
990 | 997 | case OP_DXGLBREAK:
|
991 | 998 | glRenderer__DXGLBreak(This);
|
992 | 999 | break;
|
— | — | @@ -1339,8 +1346,7 @@ |
1340 | 1347 | }
|
1341 | 1348 | }
|
1342 | 1349 |
|
1343 | | -void glRenderer__Blt(glRenderer *This, LPRECT lpDestRect, glDirectDrawSurface7 *src,
|
1344 | | - glDirectDrawSurface7 *dest, LPRECT lpSrcRect, DWORD dwFlags, LPDDBLTFX lpDDBltFx)
|
| 1350 | +void glRenderer__Blt(glRenderer *This, BltCommand *cmd)
|
1345 | 1351 | {
|
1346 | 1352 | int rotates = 0;
|
1347 | 1353 | BOOL usedest = FALSE;
|
— | — | @@ -1351,9 +1357,8 @@ |
1352 | 1358 | This->ddInterface->GetSizes(sizes);
|
1353 | 1359 | DWORD shaderid;
|
1354 | 1360 | DDSURFACEDESC2 ddsd;
|
1355 | | - ddsd.dwSize = sizeof(DDSURFACEDESC2);
|
1356 | | - dest->GetSurfaceDesc(&ddsd);
|
1357 | | - if (!lpDestRect)
|
| 1361 | + ddsd = cmd->dest->levels[cmd->destlevel].ddsd;
|
| 1362 | + if (!memcmp(&cmd->destrect, &nullrect, sizeof(RECT)))
|
1358 | 1363 | {
|
1359 | 1364 | destrect.left = 0;
|
1360 | 1365 | destrect.top = 0;
|
— | — | @@ -1360,19 +1365,19 @@ |
1361 | 1366 | destrect.right = ddsd.dwWidth;
|
1362 | 1367 | destrect.bottom = ddsd.dwHeight;
|
1363 | 1368 | }
|
1364 | | - else destrect = *lpDestRect;
|
1365 | | - if ((lpDDBltFx) && (dwFlags & DDBLT_ROP))
|
| 1369 | + else destrect = cmd->destrect;
|
| 1370 | + if ((cmd->bltfx.dwSize == sizeof(DDBLTFX)) && (cmd->flags & DDBLT_ROP))
|
1366 | 1371 | {
|
1367 | | - shaderid = PackROPBits(lpDDBltFx->dwROP, dwFlags);
|
1368 | | - if (rop_texture_usage[(lpDDBltFx->dwROP >> 16) & 0xFF] & 2) usedest = TRUE;
|
1369 | | - if (rop_texture_usage[(lpDDBltFx->dwROP >> 16) & 0xFF] & 4) usepattern = TRUE;
|
| 1372 | + shaderid = PackROPBits(cmd->bltfx.dwROP, cmd->flags);
|
| 1373 | + if (rop_texture_usage[(cmd->bltfx.dwROP >> 16) & 0xFF] & 2) usedest = TRUE;
|
| 1374 | + if (rop_texture_usage[(cmd->bltfx.dwROP >> 16) & 0xFF] & 4) usepattern = TRUE;
|
1370 | 1375 | }
|
1371 | | - else shaderid = dwFlags & 0xF2FAADFF;
|
1372 | | - if (dwFlags & DDBLT_KEYDEST) usedest = TRUE;
|
| 1376 | + else shaderid = cmd->flags & 0xF2FAADFF;
|
| 1377 | + if (cmd->flags & DDBLT_KEYDEST) usedest = TRUE;
|
1373 | 1378 | if (usedest)
|
1374 | 1379 | {
|
1375 | 1380 | ShaderManager_SetShader(This->shaders, PROG_TEXTURE, NULL, 0);
|
1376 | | - glRenderer__DrawBackbufferRect(This, dest->texture, destrect, PROG_TEXTURE);
|
| 1381 | + glRenderer__DrawBackbufferRect(This, cmd->dest, destrect, PROG_TEXTURE);
|
1377 | 1382 | This->bltvertices[1].dests = This->bltvertices[3].dests = 0.;
|
1378 | 1383 | This->bltvertices[0].dests = This->bltvertices[2].dests = (GLfloat)(destrect.right - destrect.left) / (GLfloat)This->backx;
|
1379 | 1384 | This->bltvertices[0].destt = This->bltvertices[1].destt = 1.;
|
— | — | @@ -1383,23 +1388,25 @@ |
1384 | 1389 | glUtil_BlendEnable(This->util, FALSE);
|
1385 | 1390 | do
|
1386 | 1391 | {
|
1387 | | - if (glUtil_SetFBOSurface(This->util, dest) == GL_FRAMEBUFFER_COMPLETE) break;
|
1388 | | - if (!dest->texture->internalformats[1]) break;
|
1389 | | - glTexture__Repair(dest->texture, TRUE);
|
| 1392 | + if (glUtil_SetFBOSurface(This->util, cmd->dest, NULL, cmd->destlevel, 0, TRUE) == GL_FRAMEBUFFER_COMPLETE) break;
|
| 1393 | + if (!cmd->dest->internalformats[1]) break;
|
| 1394 | + glTexture__Repair(cmd->dest, TRUE);
|
1390 | 1395 | glUtil_SetFBO(This->util, NULL);
|
1391 | | - dest->fbo.fbcolor = NULL;
|
1392 | | - dest->fbo.fbz = NULL;
|
| 1396 | + cmd->dest->levels[cmd->destlevel].fbo.fbcolor = NULL;
|
| 1397 | + cmd->dest->levels[cmd->destlevel].fbo.fbz = NULL;
|
1393 | 1398 | } while (1);
|
1394 | | - glUtil_SetViewport(This->util,0,0,dest->fakex,dest->fakey);
|
| 1399 | + glUtil_SetViewport(This->util,0,0,cmd->dest->bigwidth,cmd->dest->bigheight);
|
1395 | 1400 | glUtil_DepthTest(This->util, FALSE);
|
1396 | 1401 | DDSURFACEDESC2 ddsdSrc;
|
1397 | 1402 | ddsdSrc.dwSize = sizeof(DDSURFACEDESC2);
|
1398 | | - if (src)
|
| 1403 | + if (cmd->src)
|
1399 | 1404 | {
|
1400 | | - src->GetSurfaceDesc(&ddsdSrc);
|
1401 | | - if (src->texture->levels[src->miplevel].dirty & 1) glTexture__Upload(src->texture, src->miplevel);
|
| 1405 | + ddsdSrc = cmd->src->levels[cmd->srclevel].ddsd;
|
| 1406 | + if (cmd->src->levels[cmd->srclevel].dirty & 1) glTexture__Upload(cmd->src, cmd->srclevel);
|
1402 | 1407 | }
|
1403 | | - if(!lpSrcRect)
|
| 1408 | + if (cmd->dest->levels[cmd->destlevel].dirty & 1)
|
| 1409 | + glTexture__Upload(cmd->dest, cmd->destlevel);
|
| 1410 | + if (!memcmp(&cmd->srcrect, &nullrect, sizeof(RECT)))
|
1404 | 1411 | {
|
1405 | 1412 | srcrect.left = 0;
|
1406 | 1413 | srcrect.top = 0;
|
— | — | @@ -1406,25 +1413,38 @@ |
1407 | 1414 | srcrect.right = ddsdSrc.dwWidth;
|
1408 | 1415 | srcrect.bottom = ddsdSrc.dwHeight;
|
1409 | 1416 | }
|
1410 | | - else srcrect = *lpSrcRect;
|
1411 | | - if (dest->texture->levels[dest->miplevel].dirty & 1) glTexture__Upload(dest->texture, dest->miplevel);
|
1412 | | - This->bltvertices[1].x = This->bltvertices[3].x = (GLfloat)destrect.left * ((GLfloat)dest->fakex/(GLfloat)ddsd.dwWidth);
|
1413 | | - This->bltvertices[0].x = This->bltvertices[2].x = (GLfloat)destrect.right * ((GLfloat)dest->fakex/(GLfloat)ddsd.dwWidth);
|
1414 | | - This->bltvertices[0].y = This->bltvertices[1].y = (GLfloat)dest->fakey-((GLfloat)destrect.top * ((GLfloat)dest->fakey/(GLfloat)ddsd.dwHeight));
|
1415 | | - This->bltvertices[2].y = This->bltvertices[3].y = (GLfloat)dest->fakey-((GLfloat)destrect.bottom * ((GLfloat)dest->fakey/(GLfloat)ddsd.dwHeight));
|
| 1417 | + else srcrect = cmd->srcrect;
|
| 1418 | + if (cmd->destlevel == 0)
|
| 1419 | + {
|
| 1420 | + This->bltvertices[1].x = This->bltvertices[3].x =
|
| 1421 | + (GLfloat)destrect.left * ((GLfloat)cmd->dest->bigwidth / (GLfloat)ddsd.dwWidth);
|
| 1422 | + This->bltvertices[0].x = This->bltvertices[2].x =
|
| 1423 | + (GLfloat)destrect.right * ((GLfloat)cmd->dest->bigwidth / (GLfloat)ddsd.dwWidth);
|
| 1424 | + This->bltvertices[0].y = This->bltvertices[1].y =
|
| 1425 | + (GLfloat)cmd->dest->bigheight - ((GLfloat)destrect.top * ((GLfloat)cmd->dest->bigheight / (GLfloat)ddsd.dwHeight));
|
| 1426 | + This->bltvertices[2].y = This->bltvertices[3].y =
|
| 1427 | + (GLfloat)cmd->dest->bigheight - ((GLfloat)destrect.bottom * ((GLfloat)cmd->dest->bigheight / (GLfloat)ddsd.dwHeight));
|
| 1428 | + }
|
| 1429 | + else
|
| 1430 | + {
|
| 1431 | + This->bltvertices[1].x = This->bltvertices[3].x = (GLfloat)destrect.left;
|
| 1432 | + This->bltvertices[0].x = This->bltvertices[2].x = (GLfloat)destrect.right;
|
| 1433 | + This->bltvertices[0].y = This->bltvertices[1].y = (GLfloat)ddsd.dwHeight - (GLfloat)destrect.top;
|
| 1434 | + This->bltvertices[2].y = This->bltvertices[3].y = (GLfloat)ddsd.dwHeight - (GLfloat)destrect.bottom;
|
| 1435 | + }
|
1416 | 1436 | This->bltvertices[1].s = This->bltvertices[3].s = (GLfloat)srcrect.left / (GLfloat)ddsdSrc.dwWidth;
|
1417 | 1437 | This->bltvertices[0].s = This->bltvertices[2].s = (GLfloat)srcrect.right / (GLfloat)ddsdSrc.dwWidth;
|
1418 | 1438 | This->bltvertices[0].t = This->bltvertices[1].t = (GLfloat)srcrect.top / (GLfloat)ddsdSrc.dwHeight;
|
1419 | 1439 | This->bltvertices[2].t = This->bltvertices[3].t = (GLfloat)srcrect.bottom / (GLfloat)ddsdSrc.dwHeight;
|
1420 | | - if ((lpDDBltFx) && (dwFlags & DDBLT_DDFX))
|
| 1440 | + if ((cmd->bltfx.dwSize == sizeof(DDBLTFX)) && (cmd->flags & DDBLT_DDFX))
|
1421 | 1441 | {
|
1422 | | - if (lpDDBltFx->dwDDFX & DDBLTFX_MIRRORLEFTRIGHT)
|
| 1442 | + if (cmd->bltfx.dwDDFX & DDBLTFX_MIRRORLEFTRIGHT)
|
1423 | 1443 | BltFlipLR(This->bltvertices);
|
1424 | | - if (lpDDBltFx->dwDDFX & DDBLTFX_MIRRORUPDOWN)
|
| 1444 | + if (cmd->bltfx.dwDDFX & DDBLTFX_MIRRORUPDOWN)
|
1425 | 1445 | BltFlipUD(This->bltvertices);
|
1426 | | - if (lpDDBltFx->dwDDFX & DDBLTFX_ROTATE90) rotates++;
|
1427 | | - if (lpDDBltFx->dwDDFX & DDBLTFX_ROTATE180) rotates += 2;
|
1428 | | - if (lpDDBltFx->dwDDFX & DDBLTFX_ROTATE270) rotates += 3;
|
| 1446 | + if (cmd->bltfx.dwDDFX & DDBLTFX_ROTATE90) rotates++;
|
| 1447 | + if (cmd->bltfx.dwDDFX & DDBLTFX_ROTATE180) rotates += 2;
|
| 1448 | + if (cmd->bltfx.dwDDFX & DDBLTFX_ROTATE270) rotates += 3;
|
1429 | 1449 | rotates &= 3;
|
1430 | 1450 | if (rotates)
|
1431 | 1451 | {
|
— | — | @@ -1431,30 +1451,30 @@ |
1432 | 1452 | RotateBlt90(This->bltvertices, rotates);
|
1433 | 1453 | }
|
1434 | 1454 | }
|
1435 | | - if (dwFlags & 0x10000000)
|
1436 | | - {
|
1437 | | - This->bltvertices[1].stencils = This->bltvertices[3].stencils = This->bltvertices[1].x / (GLfloat)dest->fakex;
|
1438 | | - This->bltvertices[0].stencils = This->bltvertices[2].stencils = This->bltvertices[0].x / (GLfloat)dest->fakex;
|
1439 | | - This->bltvertices[0].stencilt = This->bltvertices[1].stencilt = This->bltvertices[0].y / (GLfloat)dest->fakey;
|
1440 | | - This->bltvertices[2].stencilt = This->bltvertices[3].stencilt = This->bltvertices[2].y / (GLfloat)dest->fakey;
|
| 1455 | + if (cmd->flags & 0x10000000)
|
| 1456 | + {
|
| 1457 | + This->bltvertices[1].stencils = This->bltvertices[3].stencils = This->bltvertices[1].x / (GLfloat)cmd->dest->levels[cmd->destlevel].ddsd.dwWidth;
|
| 1458 | + This->bltvertices[0].stencils = This->bltvertices[2].stencils = This->bltvertices[0].x / (GLfloat)cmd->dest->levels[cmd->destlevel].ddsd.dwWidth;
|
| 1459 | + This->bltvertices[0].stencilt = This->bltvertices[1].stencilt = This->bltvertices[0].y / (GLfloat)cmd->dest->levels[cmd->destlevel].ddsd.dwHeight;
|
| 1460 | + This->bltvertices[2].stencilt = This->bltvertices[3].stencilt = This->bltvertices[2].y / (GLfloat)cmd->dest->levels[cmd->destlevel].ddsd.dwHeight;
|
1441 | 1461 | }
|
1442 | | - if(dest->zbuffer) glClear(GL_DEPTH_BUFFER_BIT);
|
1443 | | - if (dwFlags & DDBLT_COLORFILL) SetColorFillUniform(lpDDBltFx->dwFillColor, dest->texture->colorsizes,
|
1444 | | - dest->texture->colororder, dest->texture->colorbits, shader->shader.uniforms[12], This->ext);
|
1445 | | - if ((dwFlags & DDBLT_KEYSRC) && (src && src->colorkey[0].enabled) && !(dwFlags & DDBLT_COLORFILL))
|
| 1462 | + if (cmd->dest->levels[cmd->destlevel].fbo.fbz) glClear(GL_DEPTH_BUFFER_BIT);
|
| 1463 | + if (cmd->flags & DDBLT_COLORFILL) SetColorFillUniform(cmd->bltfx.dwFillColor, cmd->dest->colorsizes,
|
| 1464 | + cmd->dest->colororder, cmd->dest->colorbits, shader->shader.uniforms[12], This->ext);
|
| 1465 | + if ((cmd->flags & DDBLT_KEYSRC) && (cmd->src && (cmd->src->levels[cmd->srclevel].ddsd.dwFlags & DDSD_CKSRCBLT)) && !(cmd->flags & DDBLT_COLORFILL))
|
1446 | 1466 | {
|
1447 | | - SetColorKeyUniform(src->colorkey[0].key.dwColorSpaceLowValue, src->texture->colorsizes,
|
1448 | | - src->texture->colororder, shader->shader.uniforms[5], src->texture->colorbits, This->ext);
|
1449 | | - if (dwFlags & 0x20000000) SetColorKeyUniform(src->colorkey[0].key.dwColorSpaceHighValue, src->texture->colorsizes,
|
1450 | | - src->texture->colororder, shader->shader.uniforms[7], src->texture->colorbits, This->ext);
|
| 1467 | + SetColorKeyUniform(cmd->src->levels[cmd->srclevel].ddsd.ddckCKSrcBlt.dwColorSpaceLowValue, cmd->src->colorsizes,
|
| 1468 | + cmd->src->colororder, shader->shader.uniforms[5], cmd->src->colorbits, This->ext);
|
| 1469 | + if (cmd->flags & 0x20000000) SetColorKeyUniform(cmd->src->levels[cmd->srclevel].ddsd.ddckCKSrcBlt.dwColorSpaceHighValue, cmd->src->colorsizes,
|
| 1470 | + cmd->src->colororder, shader->shader.uniforms[7], cmd->src->colorbits, This->ext);
|
1451 | 1471 | }
|
1452 | | - if (!(dwFlags & DDBLT_COLORFILL)) This->ext->glUniform1i(shader->shader.uniforms[1], 0);
|
1453 | | - if ((dwFlags & DDBLT_KEYDEST) && (This && dest->colorkey[1].enabled))
|
| 1472 | + if (!(cmd->flags & DDBLT_COLORFILL)) This->ext->glUniform1i(shader->shader.uniforms[1], 0);
|
| 1473 | + if ((cmd->flags & DDBLT_KEYDEST) && (This && (cmd->dest->levels[cmd->destlevel].ddsd.dwFlags & DDSD_CKDESTBLT)))
|
1454 | 1474 | {
|
1455 | | - SetColorKeyUniform(dest->colorkey[1].key.dwColorSpaceLowValue, dest->texture->colorsizes,
|
1456 | | - dest->texture->colororder, shader->shader.uniforms[6], dest->texture->colorbits, This->ext);
|
1457 | | - if(dwFlags & 0x40000000) SetColorKeyUniform(dest->colorkey[1].key.dwColorSpaceHighValue, dest->texture->colorsizes,
|
1458 | | - dest->texture->colororder, shader->shader.uniforms[8], dest->texture->colorbits, This->ext);
|
| 1475 | + SetColorKeyUniform(cmd->dest->levels[cmd->destlevel].ddsd.ddckCKDestBlt.dwColorSpaceLowValue, cmd->dest->colorsizes,
|
| 1476 | + cmd->dest->colororder, shader->shader.uniforms[6], cmd->dest->colorbits, This->ext);
|
| 1477 | + if (cmd->flags & 0x40000000) SetColorKeyUniform(cmd->dest->levels[cmd->destlevel].ddsd.ddckCKDestBlt.dwColorSpaceHighValue, cmd->dest->colorsizes,
|
| 1478 | + cmd->dest->colororder, shader->shader.uniforms[8], cmd->dest->colorbits, This->ext);
|
1459 | 1479 | }
|
1460 | 1480 | if (usedest && (shader->shader.uniforms[2] != -1))
|
1461 | 1481 | {
|
— | — | @@ -1463,40 +1483,40 @@ |
1464 | 1484 | }
|
1465 | 1485 | if (usepattern && (shader->shader.uniforms[3] != -1))
|
1466 | 1486 | {
|
1467 | | - glDirectDrawSurface7 *pattern = (glDirectDrawSurface7*)lpDDBltFx->lpDDSPattern;
|
1468 | | - if (pattern->texture->levels[0].dirty & 1) glTexture__Upload(pattern->texture, 0);
|
1469 | | - glUtil_SetTexture(This->util, 2, pattern->texture);
|
| 1487 | + if (cmd->pattern->levels[cmd->patternlevel].dirty & 1) glTexture__Upload(cmd->pattern, cmd->patternlevel);
|
| 1488 | + glUtil_SetTexture(This->util, 2, cmd->pattern);
|
1470 | 1489 | This->ext->glUniform1i(shader->shader.uniforms[3], 2);
|
1471 | 1490 | This->ext->glUniform2i(shader->shader.uniforms[9],
|
1472 | | - pattern->texture->levels[0].ddsd.dwWidth, pattern->texture->levels[0].ddsd.dwHeight);
|
| 1491 | + cmd->pattern->levels[cmd->patternlevel].ddsd.dwWidth, cmd->pattern->levels[cmd->patternlevel].ddsd.dwHeight);
|
1473 | 1492 | }
|
1474 | | - if (dwFlags & 0x10000000) // Use clipper
|
| 1493 | + if (cmd->flags & 0x10000000) // Use clipper
|
1475 | 1494 | {
|
1476 | | - glUtil_SetTexture(This->util, 3, dest->texture->stencil);
|
| 1495 | + glUtil_SetTexture(This->util, 3, cmd->dest->stencil);
|
1477 | 1496 | This->ext->glUniform1i(shader->shader.uniforms[4],3);
|
1478 | 1497 | glUtil_EnableArray(This->util, shader->shader.attribs[5], TRUE);
|
1479 | 1498 | This->ext->glVertexAttribPointer(shader->shader.attribs[5], 2, GL_FLOAT, GL_FALSE, sizeof(BltVertex), &This->bltvertices[0].stencils);
|
1480 | 1499 | }
|
1481 | | - if(src)
|
| 1500 | + if (cmd->src)
|
1482 | 1501 | {
|
1483 | | - glUtil_SetTexture(This->util,0,src->texture);
|
| 1502 | + glUtil_SetTexture(This->util, 0, cmd->src);
|
1484 | 1503 | if(This->ext->GLEXT_ARB_sampler_objects)
|
1485 | 1504 | {
|
1486 | | - if((dxglcfg.scalingfilter == 0) || (This->ddInterface->GetBPP() == 8))
|
1487 | | - glTexture__SetFilter(src->texture, 0, GL_NEAREST, GL_NEAREST, This);
|
1488 | | - else glTexture__SetFilter(src->texture, 0, GL_LINEAR, GL_LINEAR, This);
|
| 1505 | + if((dxglcfg.scalingfilter == 0) || (This->ddInterface->GetBPP() == 8))\
|
| 1506 | + glTexture__SetFilter(cmd->src, 0, GL_NEAREST, GL_NEAREST, This);
|
| 1507 | + else glTexture__SetFilter(cmd->src, 0, GL_LINEAR, GL_LINEAR, This);
|
1489 | 1508 | }
|
1490 | 1509 | }
|
1491 | 1510 | else glUtil_SetTexture(This->util,0,NULL);
|
1492 | | - This->ext->glUniform4f(shader->shader.uniforms[0],0,(GLfloat)dest->fakex,0,(GLfloat)dest->fakey);
|
1493 | | - if(src) This->ext->glUniform4i(shader->shader.uniforms[10], src->texture->colorsizes[0], src->texture->colorsizes[1],
|
1494 | | - src->texture->colorsizes[2], src->texture->colorsizes[3]);
|
1495 | | - if(dest) This->ext->glUniform4i(shader->shader.uniforms[11], dest->texture->colorsizes[0], dest->texture->colorsizes[1],
|
1496 | | - dest->texture->colorsizes[2], dest->texture->colorsizes[3]);
|
1497 | | - dest->texture->levels[dest->miplevel].dirty |= 2;
|
| 1511 | + This->ext->glUniform4f(shader->shader.uniforms[0], 0,
|
| 1512 | + (GLfloat)cmd->dest->levels[cmd->destlevel].ddsd.dwWidth, 0, (GLfloat)cmd->dest->levels[cmd->destlevel].ddsd.dwHeight);
|
| 1513 | + if (cmd->src) This->ext->glUniform4i(shader->shader.uniforms[10], cmd->src->colorsizes[0], cmd->src->colorsizes[1],
|
| 1514 | + cmd->src->colorsizes[2], cmd->src->colorsizes[3]);
|
| 1515 | + if (cmd->dest) This->ext->glUniform4i(shader->shader.uniforms[11], cmd->dest->colorsizes[0], cmd->dest->colorsizes[1],
|
| 1516 | + cmd->dest->colorsizes[2], cmd->dest->colorsizes[3]);
|
| 1517 | + cmd->dest->levels[cmd->destlevel].dirty |= 2;
|
1498 | 1518 | glUtil_EnableArray(This->util, shader->shader.attribs[0], TRUE);
|
1499 | 1519 | This->ext->glVertexAttribPointer(shader->shader.attribs[0],2,GL_FLOAT,GL_FALSE,sizeof(BltVertex),&This->bltvertices[0].x);
|
1500 | | - if((!(dwFlags & DDBLT_COLORFILL)) && (shader->shader.attribs[3] != -1))
|
| 1520 | + if((!(cmd->flags & DDBLT_COLORFILL)) && (shader->shader.attribs[3] != -1))
|
1501 | 1521 | {
|
1502 | 1522 | glUtil_EnableArray(This->util, shader->shader.attribs[3], TRUE);
|
1503 | 1523 | This->ext->glVertexAttribPointer(shader->shader.attribs[3],2,GL_FLOAT,GL_FALSE,sizeof(BltVertex),&This->bltvertices[0].s);
|
— | — | @@ -1514,7 +1534,7 @@ |
1515 | 1535 | (ddsd.ddsCaps.dwCaps & DDSCAPS_PRIMARYSURFACE)) ||
|
1516 | 1536 | ((ddsd.ddsCaps.dwCaps & DDSCAPS_PRIMARYSURFACE) &&
|
1517 | 1537 | !(ddsd.ddsCaps.dwCaps & DDSCAPS_FLIP)))
|
1518 | | - glRenderer__DrawScreen(This,dest->texture,dest->texture->palette,dest,dest,0,false);
|
| 1538 | + glRenderer__DrawScreen(This,cmd->dest,cmd->dest->palette,0,false);
|
1519 | 1539 | This->outputs[0] = DD_OK;
|
1520 | 1540 | SetEvent(This->busy);
|
1521 | 1541 | }
|
— | — | @@ -1536,7 +1556,7 @@ |
1537 | 1557 | ddsd.dwWidth = x;
|
1538 | 1558 | ddsd.lPitch = x * 4;
|
1539 | 1559 | ddsd.dwHeight = y;
|
1540 | | - glTexture_Create(&ddsd, &This->backbuffer, This, x, y, TRUE);
|
| 1560 | + glTexture_Create(&ddsd, &This->backbuffer, This, x, y, FALSE, TRUE);
|
1541 | 1561 | This->backx = x;
|
1542 | 1562 | This->backy = y;
|
1543 | 1563 | }
|
— | — | @@ -1551,7 +1571,7 @@ |
1552 | 1572 | This->backx = x;
|
1553 | 1573 | This->backy = y;
|
1554 | 1574 | }
|
1555 | | - glUtil_SetFBOTextures(This->util,&This->fbo,This->backbuffer,0,FALSE);
|
| 1575 | + glUtil_SetFBOTextures(This->util,&This->fbo,This->backbuffer,NULL,0,0,FALSE);
|
1556 | 1576 | view[0] = view[2] = 0;
|
1557 | 1577 | view[1] = (GLfloat)x;
|
1558 | 1578 | view[3] = (GLfloat)y;
|
— | — | @@ -1590,7 +1610,7 @@ |
1591 | 1611 | ddsd.dwWidth = x;
|
1592 | 1612 | ddsd.lPitch = x * 4;
|
1593 | 1613 | ddsd.dwHeight = y;
|
1594 | | - glTexture_Create(&ddsd, &This->backbuffer, This, x, y, TRUE);
|
| 1614 | + glTexture_Create(&ddsd, &This->backbuffer, This, x, y, FALSE, TRUE);
|
1595 | 1615 | }
|
1596 | 1616 | if ((This->backx < x) || (This->backy < y))
|
1597 | 1617 | {
|
— | — | @@ -1605,7 +1625,7 @@ |
1606 | 1626 | This->backx = x;
|
1607 | 1627 | This->backy = y;
|
1608 | 1628 | }
|
1609 | | - glUtil_SetFBOTextures(This->util, &This->fbo, This->backbuffer, 0, FALSE);
|
| 1629 | + glUtil_SetFBOTextures(This->util, &This->fbo, This->backbuffer, NULL, 0, 0, FALSE);
|
1610 | 1630 | view[0] = view[2] = 0;
|
1611 | 1631 | view[1] = (GLfloat)This->backx;
|
1612 | 1632 | view[3] = (GLfloat)This->backy;
|
— | — | @@ -1633,12 +1653,12 @@ |
1634 | 1654 | glUtil_SetFBO(This->util, NULL);
|
1635 | 1655 | }
|
1636 | 1656 |
|
1637 | | -void glRenderer__DrawScreen(glRenderer *This, glTexture *texture, glTexture *paltex, glDirectDrawSurface7 *dest, glDirectDrawSurface7 *src, GLint vsync, BOOL setsync)
|
| 1657 | +void glRenderer__DrawScreen(glRenderer *This, glTexture *texture, glTexture *paltex, GLint vsync, BOOL setsync)
|
1638 | 1658 | {
|
1639 | 1659 | int progtype;
|
1640 | 1660 | RECT r,r2;
|
1641 | 1661 | glUtil_BlendEnable(This->util, FALSE);
|
1642 | | - if((dest->ddsd.ddsCaps.dwCaps & DDSCAPS_PRIMARYSURFACE))
|
| 1662 | + if((texture->levels[0].ddsd.ddsCaps.dwCaps & DDSCAPS_PRIMARYSURFACE))
|
1643 | 1663 | {
|
1644 | 1664 | GetClientRect(This->hWnd,&r);
|
1645 | 1665 | GetClientRect(This->RenderWnd->GetHWnd(),&r2);
|
— | — | @@ -1651,9 +1671,8 @@ |
1652 | 1672 | LONG sizes[6];
|
1653 | 1673 | GLfloat view[4];
|
1654 | 1674 | GLint viewport[4];
|
1655 | | - if(src->texture->levels[src->miplevel].dirty & 1)
|
1656 | | - glTexture__Upload(src->texture, src->miplevel);
|
1657 | | - if(dest->ddsd.ddsCaps.dwCaps & DDSCAPS_PRIMARYSURFACE)
|
| 1675 | + if(texture->levels[0].dirty & 1) glTexture__Upload(texture, 0);
|
| 1676 | + if(texture->levels[0].ddsd.ddsCaps.dwCaps & DDSCAPS_PRIMARYSURFACE)
|
1658 | 1677 | {
|
1659 | 1678 | if(This->ddInterface->GetFullscreen())
|
1660 | 1679 | {
|
— | — | @@ -1675,16 +1694,16 @@ |
1676 | 1695 | ClientToScreen(This->RenderWnd->GetHWnd(),(LPPOINT)&viewrect->right);
|
1677 | 1696 | view[0] = (GLfloat)viewrect->left;
|
1678 | 1697 | view[1] = (GLfloat)viewrect->right;
|
1679 | | - view[2] = (GLfloat)dest->fakey-(GLfloat)viewrect->top;
|
1680 | | - view[3] = (GLfloat)dest->fakey-(GLfloat)viewrect->bottom;
|
| 1698 | + view[2] = (GLfloat)texture->bigheight-(GLfloat)viewrect->top;
|
| 1699 | + view[3] = (GLfloat)texture->bigheight-(GLfloat)viewrect->bottom;
|
1681 | 1700 | }
|
1682 | 1701 | }
|
1683 | 1702 | else
|
1684 | 1703 | {
|
1685 | 1704 | view[0] = 0;
|
1686 | | - view[1] = (GLfloat)dest->fakex;
|
| 1705 | + view[1] = (GLfloat)texture->bigwidth;
|
1687 | 1706 | view[2] = 0;
|
1688 | | - view[3] = (GLfloat)dest->fakey;
|
| 1707 | + view[3] = (GLfloat)texture->bigheight;
|
1689 | 1708 | }
|
1690 | 1709 | glUtil_SetFBO(This->util, NULL);
|
1691 | 1710 | glClear(GL_COLOR_BUFFER_BIT|GL_DEPTH_BUFFER_BIT);
|
— | — | @@ -1699,7 +1718,7 @@ |
1700 | 1719 | glUtil_SetTexture(This->util,1,paltex);
|
1701 | 1720 | if(dxglcfg.scalingfilter)
|
1702 | 1721 | {
|
1703 | | - glRenderer__DrawBackbuffer(This,&texture,dest->fakex,dest->fakey,progtype);
|
| 1722 | + glRenderer__DrawBackbuffer(This,&texture,texture->bigwidth,texture->bigheight,progtype);
|
1704 | 1723 | ShaderManager_SetShader(This->shaders,PROG_TEXTURE,NULL,0);
|
1705 | 1724 | progtype = PROG_TEXTURE;
|
1706 | 1725 | glUtil_SetTexture(This->util,0,texture);
|
— | — | @@ -1732,9 +1751,9 @@ |
1733 | 1752 | }
|
1734 | 1753 | else
|
1735 | 1754 | {
|
1736 | | - This->bltvertices[0].x = This->bltvertices[2].x = (float)dest->fakex;
|
| 1755 | + This->bltvertices[0].x = This->bltvertices[2].x = (float)texture->bigwidth;
|
1737 | 1756 | This->bltvertices[0].y = This->bltvertices[1].y = This->bltvertices[1].x = This->bltvertices[3].x = 0.;
|
1738 | | - This->bltvertices[2].y = This->bltvertices[3].y = (float)dest->fakey;
|
| 1757 | + This->bltvertices[2].y = This->bltvertices[3].y = (float)texture->bigheight;
|
1739 | 1758 | }
|
1740 | 1759 | This->bltvertices[0].s = This->bltvertices[0].t = This->bltvertices[1].t = This->bltvertices[2].s = 1.;
|
1741 | 1760 | This->bltvertices[1].s = This->bltvertices[2].t = This->bltvertices[3].s = This->bltvertices[3].t = 0.;
|
— | — | @@ -1918,15 +1937,23 @@ |
1919 | 1938 | {
|
1920 | 1939 | This->outputs[0] = (void*)D3D_OK;
|
1921 | 1940 | GLfloat color[4];
|
| 1941 | + glTexture *ztexture = NULL;
|
| 1942 | + GLint zlevel = 0;
|
| 1943 | + if (target->zbuffer)
|
| 1944 | + {
|
| 1945 | + ztexture = target->zbuffer->texture;
|
| 1946 | + zlevel = target->zbuffer->miplevel;
|
| 1947 | + }
|
1922 | 1948 | dwordto4float(dwColor,color);
|
1923 | 1949 | do
|
1924 | 1950 | {
|
1925 | | - if (glUtil_SetFBOSurface(This->util, target) == GL_FRAMEBUFFER_COMPLETE) break;
|
| 1951 | + if (glUtil_SetFBOSurface(This->util, target->texture, ztexture,
|
| 1952 | + target->zbuffer->miplevel, zlevel, FALSE) == GL_FRAMEBUFFER_COMPLETE) break;
|
1926 | 1953 | if (!target->texture->internalformats[1]) break;
|
1927 | 1954 | glTexture__Repair(target->texture, TRUE);
|
1928 | 1955 | glUtil_SetFBO(This->util, NULL);
|
1929 | | - target->fbo.fbcolor = NULL;
|
1930 | | - target->fbo.fbz = NULL;
|
| 1956 | + target->texture->levels[target->miplevel].fbo.fbcolor = NULL;
|
| 1957 | + target->texture->levels[target->miplevel].fbo.fbz = NULL;
|
1931 | 1958 | } while (1);
|
1932 | 1959 | int clearbits = 0;
|
1933 | 1960 | if(dwFlags & D3DCLEAR_TARGET)
|
— | — | @@ -2119,6 +2146,13 @@ |
2120 | 2147 | char strvar[] = "strX";
|
2121 | 2148 | char strqvar[] = "strqX";
|
2122 | 2149 | int i;
|
| 2150 | + glTexture *ztexture = NULL;
|
| 2151 | + GLint zlevel = 0;
|
| 2152 | + if (device->glDDS7->zbuffer)
|
| 2153 | + {
|
| 2154 | + ztexture = device->glDDS7->zbuffer->texture;
|
| 2155 | + zlevel = device->glDDS7->zbuffer->miplevel;
|
| 2156 | + }
|
2123 | 2157 | if(vertices[1].data) transformed = true;
|
2124 | 2158 | else transformed = false;
|
2125 | 2159 | if(!vertices[0].data)
|
— | — | @@ -2321,12 +2355,13 @@ |
2322 | 2356 | if(prog->uniforms[150]!= -1) This->ext->glUniform4iv(prog->uniforms[150],1,(GLint*)device->glDDS7->texture->colorbits);
|
2323 | 2357 | do
|
2324 | 2358 | {
|
2325 | | - if (glUtil_SetFBOSurface(This->util, device->glDDS7) == GL_FRAMEBUFFER_COMPLETE) break;
|
| 2359 | + if (glUtil_SetFBOSurface(This->util, device->glDDS7->texture, ztexture,
|
| 2360 | + device->glDDS7->miplevel, zlevel, FALSE) == GL_FRAMEBUFFER_COMPLETE) break;
|
2326 | 2361 | if (!device->glDDS7->texture->internalformats[1]) break;
|
2327 | 2362 | glTexture__Repair(device->glDDS7->texture, TRUE);
|
2328 | 2363 | glUtil_SetFBO(This->util, NULL);
|
2329 | | - device->glDDS7->fbo.fbcolor = NULL;
|
2330 | | - device->glDDS7->fbo.fbz = NULL;
|
| 2364 | + device->glDDS7->texture->levels[device->glDDS7->miplevel].fbo.fbcolor = NULL;
|
| 2365 | + device->glDDS7->texture->levels[device->glDDS7->miplevel].fbo.fbz = NULL;
|
2331 | 2366 | } while (1);
|
2332 | 2367 | glUtil_SetViewport(This->util, (int)((float)This->viewport.dwX*device->glDDS7->mulx),
|
2333 | 2368 | (int)((float)This->viewport.dwY*device->glDDS7->muly),
|
— | — | @@ -2373,7 +2408,7 @@ |
2374 | 2409 | ddsd.dwFlags = DDSD_WIDTH | DDSD_HEIGHT;
|
2375 | 2410 | glTexture__SetSurfaceDesc(surface->texture->stencil, &ddsd);
|
2376 | 2411 | }
|
2377 | | - glUtil_SetFBOTextures(This->util, &surface->stencilfbo, surface->texture->stencil, 0, FALSE);
|
| 2412 | + glUtil_SetFBOTextures(This->util, &surface->texture->stencil->levels[0].fbo, surface->texture->stencil, NULL, 0, 0, FALSE);
|
2378 | 2413 | view[0] = view[2] = 0;
|
2379 | 2414 | view[1] = (GLfloat)surface->ddsd.dwWidth;
|
2380 | 2415 | view[3] = (GLfloat)surface->ddsd.dwHeight;
|
— | — | @@ -2392,14 +2427,14 @@ |
2393 | 2428 | SetEvent(This->busy);
|
2394 | 2429 | }
|
2395 | 2430 |
|
2396 | | -void glRenderer__DepthFill(glRenderer *This, LPRECT lpDestRect, glDirectDrawSurface7 *dest, LPDDBLTFX lpDDBltFx)
|
| 2431 | +void glRenderer__DepthFill(glRenderer *This, BltCommand *cmd, glTexture *parent, GLint parentlevel)
|
2397 | 2432 | {
|
2398 | 2433 | RECT destrect;
|
2399 | 2434 | DDSURFACEDESC2 ddsd;
|
2400 | | - DDSURFACEDESC2 ddsd2;
|
2401 | | - ddsd.dwSize = sizeof(DDSURFACEDESC2);
|
2402 | | - dest->GetSurfaceDesc(&ddsd);
|
2403 | | - if (!lpDestRect)
|
| 2435 | + DDSURFACEDESC2 tmpddsd;
|
| 2436 | + BOOL usedestrect = FALSE;
|
| 2437 | + ddsd = cmd->dest->levels[cmd->destlevel].ddsd;
|
| 2438 | + if (!memcmp(&cmd->destrect, &nullrect, sizeof(RECT)))
|
2404 | 2439 | {
|
2405 | 2440 | destrect.left = 0;
|
2406 | 2441 | destrect.top = 0;
|
— | — | @@ -2406,44 +2441,50 @@ |
2407 | 2442 | destrect.right = ddsd.dwWidth;
|
2408 | 2443 | destrect.bottom = ddsd.dwHeight;
|
2409 | 2444 | }
|
2410 | | - else destrect = *lpDestRect;
|
2411 | | - if (dest->attachparent)
|
| 2445 | + else
|
2412 | 2446 | {
|
| 2447 | + destrect = cmd->destrect;
|
| 2448 | + usedestrect = TRUE;
|
| 2449 | + }
|
| 2450 | + if (parent)
|
| 2451 | + {
|
2413 | 2452 | do
|
2414 | 2453 | {
|
2415 | | - if (glUtil_SetFBOSurface(This->util, dest->attachparent) == GL_FRAMEBUFFER_COMPLETE) break;
|
2416 | | - if (!dest->attachparent->texture->internalformats[1]) break;
|
2417 | | - glTexture__Repair(dest->attachparent->texture, TRUE);
|
| 2454 | + if (glUtil_SetFBOSurface(This->util, parent, NULL, parentlevel, 0, TRUE) == GL_FRAMEBUFFER_COMPLETE) break;
|
| 2455 | + if (!parent->internalformats[1]) break;
|
| 2456 | + glTexture__Repair(parent, TRUE);
|
2418 | 2457 | glUtil_SetFBO(This->util, NULL);
|
2419 | | - dest->attachparent->fbo.fbcolor = NULL;
|
2420 | | - dest->attachparent->fbo.fbz = NULL;
|
| 2458 | + parent->levels[parentlevel].fbo.fbcolor = NULL;
|
| 2459 | + parent->levels[parentlevel].fbo.fbz = NULL;
|
2421 | 2460 | } while (1);
|
2422 | 2461 | }
|
2423 | 2462 | else
|
2424 | 2463 | {
|
2425 | | - if (!dest->texture->dummycolor)
|
| 2464 | + if (!cmd->dest->dummycolor)
|
2426 | 2465 | {
|
2427 | | - glTexture_CreateDummyColor(dest->texture, TRUE);
|
| 2466 | + glTexture_CreateDummyColor(cmd->dest, TRUE);
|
2428 | 2467 | }
|
2429 | | - if ((dest->ddsd.dwWidth != dest->texture->dummycolor->levels[0].ddsd.dwWidth) ||
|
2430 | | - (dest->ddsd.dwHeight != dest->texture->dummycolor->levels[0].ddsd.dwHeight))
|
| 2468 | + if ((cmd->dest->levels[cmd->destlevel].ddsd.dwWidth != cmd->dest->dummycolor->levels[0].ddsd.dwWidth) ||
|
| 2469 | + (cmd->dest->levels[cmd->destlevel].ddsd.dwHeight != cmd->dest->dummycolor->levels[0].ddsd.dwHeight))
|
2431 | 2470 | {
|
2432 | | - ZeroMemory(&ddsd2, sizeof(DDSURFACEDESC2));
|
2433 | | - ddsd2.dwSize = sizeof(DDSURFACEDESC2);
|
2434 | | - ddsd2.dwWidth = dest->ddsd.dwWidth;
|
2435 | | - ddsd2.dwHeight = dest->ddsd.dwHeight;
|
2436 | | - ddsd2.dwFlags = DDSD_WIDTH | DDSD_HEIGHT;
|
2437 | | - glTexture__SetSurfaceDesc(dest->texture->dummycolor, &ddsd2);
|
| 2471 | + ZeroMemory(&tmpddsd, sizeof(DDSURFACEDESC2));
|
| 2472 | + tmpddsd.dwSize = sizeof(DDSURFACEDESC2);
|
| 2473 | + tmpddsd.dwWidth = cmd->dest->levels[cmd->destlevel].ddsd.dwWidth;
|
| 2474 | + tmpddsd.dwHeight = cmd->dest->levels[cmd->destlevel].ddsd.dwHeight;
|
| 2475 | + tmpddsd.dwFlags = DDSD_WIDTH | DDSD_HEIGHT;
|
| 2476 | + glTexture__SetSurfaceDesc(cmd->dest->dummycolor, &tmpddsd);
|
2438 | 2477 | }
|
2439 | | - glUtil_SetFBOTextures(This->util, &dest->zfbo, dest->texture->dummycolor, dest->texture, FALSE);
|
| 2478 | + glUtil_SetFBOTextures(This->util, &cmd->dest->dummycolor->levels[0].fbo, cmd->dest->dummycolor,
|
| 2479 | + cmd->dest, cmd->destlevel, 0, FALSE);
|
2440 | 2480 | }
|
2441 | | - glUtil_SetViewport(This->util, 0, 0, dest->ddsd.dwWidth, dest->ddsd.dwHeight);
|
2442 | | - if (lpDestRect) glUtil_SetScissor(This->util, TRUE, lpDestRect->left, lpDestRect->top,
|
2443 | | - lpDestRect->right, lpDestRect->bottom);
|
| 2481 | + glUtil_SetViewport(This->util, 0, 0, cmd->dest->levels[cmd->destlevel].ddsd.dwWidth,
|
| 2482 | + cmd->dest->levels[cmd->destlevel].ddsd.dwHeight);
|
| 2483 | + if (usedestrect) glUtil_SetScissor(This->util, TRUE, cmd->destrect.left, cmd->destrect.top,
|
| 2484 | + cmd->destrect.right, cmd->destrect.bottom);
|
2444 | 2485 | glUtil_DepthWrite(This->util, TRUE);
|
2445 | | - glUtil_ClearDepth(This->util, lpDDBltFx->dwFillDepth / (double)0xFFFF); // FIXME: SOTE depth workaround
|
| 2486 | + glUtil_ClearDepth(This->util, cmd->bltfx.dwFillDepth / (double)0xFFFF); // FIXME: SOTE depth workaround
|
2446 | 2487 | glClear(GL_DEPTH_BUFFER_BIT);
|
2447 | | - if (lpDestRect)glUtil_SetScissor(This->util, false, 0, 0, 0, 0);
|
| 2488 | + if (usedestrect)glUtil_SetScissor(This->util, false, 0, 0, 0, 0);
|
2448 | 2489 | This->outputs[0] = DD_OK;
|
2449 | 2490 | SetEvent(This->busy);
|
2450 | 2491 | }
|
— | — | @@ -2878,6 +2919,39 @@ |
2879 | 2920 | }
|
2880 | 2921 | }
|
2881 | 2922 |
|
| 2923 | +void glRenderer__SetTextureColorKey(glRenderer *This, glTexture *texture, DWORD dwFlags, LPDDCOLORKEY lpDDColorKey, GLint level)
|
| 2924 | +{
|
| 2925 | + if (dwFlags & DDCKEY_SRCBLT)
|
| 2926 | + {
|
| 2927 | + texture->levels[level].ddsd.dwFlags |= DDSD_CKSRCBLT;
|
| 2928 | + texture->levels[level].ddsd.ddckCKSrcBlt.dwColorSpaceLowValue = lpDDColorKey->dwColorSpaceLowValue;
|
| 2929 | + if (DDCKEY_COLORSPACE) texture->levels[level].ddsd.ddckCKSrcBlt.dwColorSpaceHighValue = lpDDColorKey->dwColorSpaceLowValue;
|
| 2930 | + else texture->levels[level].ddsd.ddckCKSrcBlt.dwColorSpaceHighValue = lpDDColorKey->dwColorSpaceHighValue;
|
| 2931 | + }
|
| 2932 | + if (dwFlags & DDCKEY_DESTBLT)
|
| 2933 | + {
|
| 2934 | + texture->levels[level].ddsd.dwFlags |= DDSD_CKDESTBLT;
|
| 2935 | + texture->levels[level].ddsd.ddckCKDestBlt.dwColorSpaceLowValue = lpDDColorKey->dwColorSpaceLowValue;
|
| 2936 | + if (DDCKEY_COLORSPACE) texture->levels[level].ddsd.ddckCKDestBlt.dwColorSpaceHighValue = lpDDColorKey->dwColorSpaceLowValue;
|
| 2937 | + else texture->levels[level].ddsd.ddckCKDestBlt.dwColorSpaceHighValue = lpDDColorKey->dwColorSpaceHighValue;
|
| 2938 | + }
|
| 2939 | + if (dwFlags & DDCKEY_SRCOVERLAY)
|
| 2940 | + {
|
| 2941 | + texture->levels[level].ddsd.dwFlags |= DDSD_CKSRCOVERLAY;
|
| 2942 | + texture->levels[level].ddsd.ddckCKSrcOverlay.dwColorSpaceLowValue = lpDDColorKey->dwColorSpaceLowValue;
|
| 2943 | + if (DDCKEY_COLORSPACE) texture->levels[level].ddsd.ddckCKSrcOverlay.dwColorSpaceHighValue = lpDDColorKey->dwColorSpaceLowValue;
|
| 2944 | + else texture->levels[level].ddsd.ddckCKSrcOverlay.dwColorSpaceHighValue = lpDDColorKey->dwColorSpaceHighValue;
|
| 2945 | + }
|
| 2946 | + if (dwFlags & DDCKEY_DESTOVERLAY)
|
| 2947 | + {
|
| 2948 | + texture->levels[level].ddsd.dwFlags |= DDSD_CKDESTOVERLAY;
|
| 2949 | + texture->levels[level].ddsd.ddckCKDestOverlay.dwColorSpaceLowValue = lpDDColorKey->dwColorSpaceLowValue;
|
| 2950 | + if (DDCKEY_COLORSPACE) texture->levels[level].ddsd.ddckCKDestOverlay.dwColorSpaceHighValue = lpDDColorKey->dwColorSpaceLowValue;
|
| 2951 | + else texture->levels[level].ddsd.ddckCKDestOverlay.dwColorSpaceHighValue = lpDDColorKey->dwColorSpaceHighValue;
|
| 2952 | + }
|
| 2953 | + SetEvent(This->busy);
|
| 2954 | +}
|
| 2955 | +
|
2882 | 2956 | void glRenderer__DXGLBreak(glRenderer *This)
|
2883 | 2957 | {
|
2884 | 2958 | if (This->ext->GLEXT_GREMEDY_frame_terminator) This->ext->glFrameTerminatorGREMEDY();
|
Index: ddraw/glRenderer.h |
— | — | @@ -104,6 +104,7 @@ |
105 | 105 | #define OP_SETLIGHT 21
|
106 | 106 | #define OP_SETVIEWPORT 22
|
107 | 107 | #define OP_DXGLBREAK 23
|
| 108 | +#define OP_SETTEXTURECOLORKEY 24
|
108 | 109 |
|
109 | 110 | extern const DWORD renderstate_default[153];
|
110 | 111 | extern const TEXTURESTAGE texstagedefault0;
|
— | — | @@ -159,10 +160,9 @@ |
160 | 161 | static DWORD WINAPI glRenderer_ThreadEntry(void *entry);
|
161 | 162 | void glRenderer_UploadTexture(glRenderer *This, glTexture *texture, GLint level);
|
162 | 163 | void glRenderer_DownloadTexture(glRenderer *This, glTexture *texture, GLint level);
|
163 | | -HRESULT glRenderer_Blt(glRenderer *This, LPRECT lpDestRect, glDirectDrawSurface7 *src,
|
164 | | - glDirectDrawSurface7 *dest, LPRECT lpSrcRect, DWORD dwFlags, LPDDBLTFX lpDDBltFx);
|
| 164 | +HRESULT glRenderer_Blt(glRenderer *This, BltCommand *cmd);
|
165 | 165 | void glRenderer_MakeTexture(glRenderer *This, glTexture *texture);
|
166 | | -void glRenderer_DrawScreen(glRenderer *This, glTexture *texture, glTexture *paltex, glDirectDrawSurface7 *dest, glDirectDrawSurface7 *src, GLint vsync);
|
| 166 | +void glRenderer_DrawScreen(glRenderer *This, glTexture *texture, glTexture *paltex, GLint vsync);
|
167 | 167 | void glRenderer_DeleteTexture(glRenderer *This, glTexture *texture);
|
168 | 168 | void glRenderer_InitD3D(glRenderer *This, int zbuffer, int x, int y);
|
169 | 169 | void glRenderer_Flush(glRenderer *This);
|
— | — | @@ -173,7 +173,7 @@ |
174 | 174 | void glRenderer_DeleteFBO(glRenderer *This, FBO *fbo);
|
175 | 175 | void glRenderer_UpdateClipper(glRenderer *This, glDirectDrawSurface7 *surface);
|
176 | 176 | unsigned int glRenderer_GetScanLine(glRenderer *This);
|
177 | | -HRESULT glRenderer_DepthFill(glRenderer *This, LPRECT lpDestRect, glDirectDrawSurface7 *dest, LPDDBLTFX lpDDBltFx);
|
| 177 | +HRESULT glRenderer_DepthFill(glRenderer *This, BltCommand *cmd, glTexture *parent, GLint parentlevel);
|
178 | 178 | void glRenderer_SetRenderState(glRenderer *This, D3DRENDERSTATETYPE dwRendStateType, DWORD dwRenderState);
|
179 | 179 | void glRenderer_SetTexture(glRenderer *This, DWORD dwStage, glDirectDrawSurface7 *Texture);
|
180 | 180 | void glRenderer_SetTextureStageState(glRenderer *This, DWORD dwStage, D3DTEXTURESTAGESTATETYPE dwState, DWORD dwValue);
|
— | — | @@ -181,6 +181,7 @@ |
182 | 182 | void glRenderer_SetMaterial(glRenderer *This, LPD3DMATERIAL7 lpMaterial);
|
183 | 183 | void glRenderer_SetLight(glRenderer *This, DWORD index, LPD3DLIGHT7 light, BOOL remove);
|
184 | 184 | void glRenderer_SetViewport(glRenderer *This, LPD3DVIEWPORT7 lpViewport);
|
| 185 | +void glRenderer_SetTextureColorKey(glRenderer *This, glTexture *texture, DWORD dwFlags, LPDDCOLORKEY lpDDColorKey, GLint level);
|
185 | 186 | void glRenderer_DXGLBreak(glRenderer *This);
|
186 | 187 | // In-thread APIs
|
187 | 188 | DWORD glRenderer__Entry(glRenderer *This);
|
— | — | @@ -187,10 +188,9 @@ |
188 | 189 | BOOL glRenderer__InitGL(glRenderer *This, int width, int height, int bpp, int fullscreen, unsigned int frequency, HWND hWnd, glDirectDraw7 *glDD7);
|
189 | 190 | void glRenderer__UploadTexture(glRenderer *This, glTexture *texture, GLint level);
|
190 | 191 | void glRenderer__DownloadTexture(glRenderer *This, glTexture *texture, GLint level);
|
191 | | -void glRenderer__Blt(glRenderer *This, LPRECT lpDestRect, glDirectDrawSurface7 *src,
|
192 | | - glDirectDrawSurface7 *dest, LPRECT lpSrcRect, DWORD dwFlags, LPDDBLTFX lpDDBltFx);
|
| 192 | +void glRenderer__Blt(glRenderer *This, BltCommand *cmd);
|
193 | 193 | void glRenderer__MakeTexture(glRenderer *This, glTexture *texture);
|
194 | | -void glRenderer__DrawScreen(glRenderer *This, glTexture *texture, glTexture *paltex, glDirectDrawSurface7 *dest, glDirectDrawSurface7 *src, GLint vsync, BOOL setsync);
|
| 194 | +void glRenderer__DrawScreen(glRenderer *This, glTexture *texture, glTexture *paltex, GLint vsync, BOOL setsync);
|
195 | 195 | void glRenderer__DeleteTexture(glRenderer *This, glTexture *texture);
|
196 | 196 | void glRenderer__DrawBackbuffer(glRenderer *This, glTexture **texture, int x, int y, int progtype);
|
197 | 197 | void glRenderer__DrawBackbufferRect(glRenderer *This, glTexture *texture, RECT srcrect, int progtype);
|
— | — | @@ -202,7 +202,7 @@ |
203 | 203 | void glRenderer__SetWnd(glRenderer *This, int width, int height, int fullscreen, int bpp, unsigned int frequency, HWND newwnd, BOOL devwnd);
|
204 | 204 | void glRenderer__DeleteFBO(glRenderer *This, FBO *fbo);
|
205 | 205 | void glRenderer__UpdateClipper(glRenderer *This, glDirectDrawSurface7 *surface);
|
206 | | -void glRenderer__DepthFill(glRenderer *This, LPRECT lpDestRect, glDirectDrawSurface7 *dest, LPDDBLTFX lpDDBltFx);
|
| 206 | +void glRenderer__DepthFill(glRenderer *This, BltCommand *cmd, glTexture *parent, GLint parentlevel);
|
207 | 207 | void glRenderer__SetFogColor(glRenderer *This, DWORD color);
|
208 | 208 | void glRenderer__SetFogStart(glRenderer *This, GLfloat start);
|
209 | 209 | void glRenderer__SetFogEnd(glRenderer *This, GLfloat end);
|
— | — | @@ -216,6 +216,7 @@ |
217 | 217 | void glRenderer__SetMaterial(glRenderer *This, LPD3DMATERIAL7 lpMaterial);
|
218 | 218 | void glRenderer__SetLight(glRenderer *This, DWORD index, LPD3DLIGHT7 light, BOOL remove);
|
219 | 219 | void glRenderer__SetViewport(glRenderer *This, LPD3DVIEWPORT7 lpViewport);
|
| 220 | +void glRenderer__SetTextureColorKey(glRenderer *This, glTexture *texture, DWORD dwFlags, LPDDCOLORKEY lpDDColorKey, GLint level);
|
220 | 221 | void glRenderer__SetDepthComp(glRenderer *This);
|
221 | 222 | void glRenderer__DXGLBreak(glRenderer *This);
|
222 | 223 |
|
Index: ddraw/glTexture.cpp |
— | — | @@ -122,7 +122,7 @@ |
123 | 123 | *y = max(1, (DWORD)floorf((float)*y / 2.0f));
|
124 | 124 | }
|
125 | 125 |
|
126 | | -HRESULT glTexture_Create(const DDSURFACEDESC2 *ddsd, glTexture **texture, struct glRenderer *renderer, GLint bigwidth, GLint bigheight, BOOL backend)
|
| 126 | +HRESULT glTexture_Create(const DDSURFACEDESC2 *ddsd, glTexture **texture, struct glRenderer *renderer, GLint bigwidth, GLint bigheight, BOOL zhasstencil, BOOL backend)
|
127 | 127 | {
|
128 | 128 | glTexture *newtexture;
|
129 | 129 | if (!texture) return DDERR_INVALIDPARAMS;
|
— | — | @@ -164,6 +164,7 @@ |
165 | 165 | newtexture->levels[0].ddsd.ddpfPixelFormat.dwZBitMask = 0xFFFFFFFF;
|
166 | 166 | break;
|
167 | 167 | }
|
| 168 | + newtexture->zhasstencil = zhasstencil;
|
168 | 169 | }
|
169 | 170 |
|
170 | 171 | if (!(newtexture->levels[0].ddsd.dwFlags & DDSD_PIXELFORMAT))
|
— | — | @@ -386,7 +387,7 @@ |
387 | 388 | ddsd.dwWidth = This->levels[0].ddsd.dwWidth;
|
388 | 389 | ddsd.lPitch = NextMultipleOf4(ddsd.dwWidth * 2);
|
389 | 390 | ddsd.dwHeight = This->levels[0].ddsd.dwHeight;
|
390 | | - glTexture_Create(&ddsd, &This->dummycolor, This->renderer, ddsd.dwWidth, ddsd.dwHeight, FALSE);
|
| 391 | + glTexture_Create(&ddsd, &This->dummycolor, This->renderer, ddsd.dwWidth, ddsd.dwHeight, FALSE, backend);
|
391 | 392 | }
|
392 | 393 | void glTexture_DeleteDummyColor(glTexture *This, BOOL backend)
|
393 | 394 | {
|
Index: ddraw/glTexture.h |
— | — | @@ -32,7 +32,7 @@ |
33 | 33 |
|
34 | 34 | DWORD CalculateMipLevels(DWORD width, DWORD height);
|
35 | 35 |
|
36 | | -HRESULT glTexture_Create(const DDSURFACEDESC2 *ddsd, glTexture **texture, struct glRenderer *renderer, GLint bigwidth, GLint bigheight, BOOL backend);
|
| 36 | +HRESULT glTexture_Create(const DDSURFACEDESC2 *ddsd, glTexture **texture, struct glRenderer *renderer, GLint bigwidth, GLint bigheight, BOOL zhasstencil, BOOL backend);
|
37 | 37 | ULONG glTexture_AddRef(glTexture *This);
|
38 | 38 | ULONG glTexture_Release(glTexture *This, BOOL backend);
|
39 | 39 | HRESULT glTexture_Lock(glTexture *This, GLint level, LPRECT r, LPDDSURFACEDESC2 ddsd, DWORD flags, BOOL backend);
|
Index: ddraw/glUtil.cpp |
— | — | @@ -1,5 +1,5 @@ |
2 | 2 | // DXGL
|
3 | | -// Copyright (C) 2012-2014 William Feely
|
| 3 | +// Copyright (C) 2012-2016 William Feely
|
4 | 4 |
|
5 | 5 | // This library is free software; you can redistribute it and/or
|
6 | 6 | // modify it under the terms of the GNU Lesser General Public
|
— | — | @@ -142,7 +142,7 @@ |
143 | 143 | }
|
144 | 144 | }
|
145 | 145 |
|
146 | | -void glUtil_SetFBOTexture(glUtil *This, FBO *fbo, glTexture *color, glTexture *z, BOOL stencil)
|
| 146 | +void glUtil_SetFBOTexture(glUtil *This, FBO *fbo, glTexture *color, glTexture *z, GLint level, GLint zlevel, BOOL stencil)
|
147 | 147 | {
|
148 | 148 | if(!color) return;
|
149 | 149 | if(!fbo->fbo) return;
|
— | — | @@ -150,18 +150,18 @@ |
151 | 151 | {
|
152 | 152 | if(This->currentfbo != fbo) This->ext->glBindFramebuffer(GL_FRAMEBUFFER,fbo->fbo);
|
153 | 153 | This->currentfbo = fbo;
|
154 | | - This->ext->glFramebufferTexture2D(GL_FRAMEBUFFER,GL_COLOR_ATTACHMENT0,GL_TEXTURE_2D,color->id,0);
|
| 154 | + This->ext->glFramebufferTexture2D(GL_FRAMEBUFFER,GL_COLOR_ATTACHMENT0,GL_TEXTURE_2D,color->id,level);
|
155 | 155 | fbo->fbcolor = color;
|
156 | 156 | if(stencil)
|
157 | 157 | {
|
158 | 158 | if(!fbo->stencil) This->ext->glFramebufferTexture2D(GL_FRAMEBUFFER,GL_DEPTH_ATTACHMENT,GL_TEXTURE_2D,0,0);
|
159 | | - if(z)This->ext->glFramebufferTexture2D(GL_FRAMEBUFFER,GL_DEPTH_STENCIL_ATTACHMENT,GL_TEXTURE_2D,z->id,0);
|
| 159 | + if(z)This->ext->glFramebufferTexture2D(GL_FRAMEBUFFER,GL_DEPTH_STENCIL_ATTACHMENT,GL_TEXTURE_2D,z->id,zlevel);
|
160 | 160 | else This->ext->glFramebufferTexture2D(GL_FRAMEBUFFER,GL_DEPTH_STENCIL_ATTACHMENT,GL_TEXTURE_2D,0,0);
|
161 | 161 | }
|
162 | 162 | else
|
163 | 163 | {
|
164 | 164 | if(fbo->stencil) This->ext->glFramebufferTexture2D(GL_FRAMEBUFFER,GL_DEPTH_STENCIL_ATTACHMENT,GL_TEXTURE_2D,0,0);
|
165 | | - if(z) This->ext->glFramebufferTexture2D(GL_FRAMEBUFFER,GL_DEPTH_ATTACHMENT,GL_TEXTURE_2D,z->id,0);
|
| 165 | + if(z) This->ext->glFramebufferTexture2D(GL_FRAMEBUFFER,GL_DEPTH_ATTACHMENT,GL_TEXTURE_2D,z->id,zlevel);
|
166 | 166 | else This->ext->glFramebufferTexture2D(GL_FRAMEBUFFER,GL_DEPTH_ATTACHMENT,GL_TEXTURE_2D,0,0);
|
167 | 167 | }
|
168 | 168 | fbo->stencil = stencil;
|
— | — | @@ -172,14 +172,14 @@ |
173 | 173 | {
|
174 | 174 | if (This->currentfbo != fbo) This->ext->glBindFramebufferEXT(GL_FRAMEBUFFER_EXT, fbo->fbo);
|
175 | 175 | This->currentfbo = fbo;
|
176 | | - This->ext->glFramebufferTexture2DEXT(GL_FRAMEBUFFER_EXT, GL_COLOR_ATTACHMENT0_EXT, GL_TEXTURE_2D, color->id, 0);
|
| 176 | + This->ext->glFramebufferTexture2DEXT(GL_FRAMEBUFFER_EXT, GL_COLOR_ATTACHMENT0_EXT, GL_TEXTURE_2D, color->id, level);
|
177 | 177 | fbo->fbcolor = color;
|
178 | 178 | if(stencil)
|
179 | 179 | {
|
180 | 180 | if(z)
|
181 | 181 | {
|
182 | | - This->ext->glFramebufferTexture2DEXT(GL_FRAMEBUFFER_EXT, GL_DEPTH_ATTACHMENT_EXT, GL_TEXTURE_2D, z->id, 0);
|
183 | | - This->ext->glFramebufferTexture2DEXT(GL_FRAMEBUFFER_EXT, GL_STENCIL_ATTACHMENT_EXT, GL_TEXTURE_2D, z->id, 0);
|
| 182 | + This->ext->glFramebufferTexture2DEXT(GL_FRAMEBUFFER_EXT, GL_DEPTH_ATTACHMENT_EXT, GL_TEXTURE_2D, z->id, zlevel);
|
| 183 | + This->ext->glFramebufferTexture2DEXT(GL_FRAMEBUFFER_EXT, GL_STENCIL_ATTACHMENT_EXT, GL_TEXTURE_2D, z->id, zlevel);
|
184 | 184 | }
|
185 | 185 | else
|
186 | 186 | {
|
— | — | @@ -190,7 +190,7 @@ |
191 | 191 | else
|
192 | 192 | {
|
193 | 193 | This->ext->glFramebufferTexture2DEXT(GL_FRAMEBUFFER_EXT, GL_STENCIL_ATTACHMENT_EXT, GL_TEXTURE_2D, 0, 0);
|
194 | | - if (z)This->ext->glFramebufferTexture2DEXT(GL_FRAMEBUFFER_EXT, GL_DEPTH_ATTACHMENT_EXT, GL_TEXTURE_2D, z->id, 0);
|
| 194 | + if (z)This->ext->glFramebufferTexture2DEXT(GL_FRAMEBUFFER_EXT, GL_DEPTH_ATTACHMENT_EXT, GL_TEXTURE_2D, z->id, zlevel);
|
195 | 195 | else This->ext->glFramebufferTexture2DEXT(GL_FRAMEBUFFER_EXT, GL_DEPTH_ATTACHMENT_EXT, GL_TEXTURE_2D, 0, 0);
|
196 | 196 | }
|
197 | 197 | fbo->stencil = stencil;
|
— | — | @@ -199,11 +199,23 @@ |
200 | 200 | }
|
201 | 201 | }
|
202 | 202 |
|
203 | | -GLenum glUtil_SetFBOSurface(glUtil *This, glDirectDrawSurface7 *surface)
|
| 203 | +// Transitions away from using surface objects and adds miplevel
|
| 204 | +GLenum glUtil_SetFBOSurface(glUtil *This, glTexture *surface, glTexture *zbuffer, GLint level, GLint zlevel, BOOL skipz)
|
204 | 205 | {
|
205 | 206 | if (!surface) return glUtil_SetFBO(This, (FBO*)NULL);
|
206 | | - if (surface->zbuffer) return glUtil_SetFBOTextures(This, &surface->fbo, surface->texture, surface->zbuffer->texture, surface->zbuffer->hasstencil);
|
207 | | - else return glUtil_SetFBOTextures(This, &surface->fbo, surface->texture, NULL, FALSE);
|
| 207 | + if (skipz)
|
| 208 | + {
|
| 209 | + if (surface->levels[level].fbo.fbz)
|
| 210 | + return glUtil_SetFBOTextures(This, &surface->levels[level].fbo, surface,
|
| 211 | + surface->levels[level].fbo.fbz, level, zlevel, surface->levels[level].fbo.fbz->zhasstencil);
|
| 212 | + else return glUtil_SetFBOTextures(This, &surface->levels[level].fbo, surface, NULL, level, zlevel, FALSE);
|
| 213 | + }
|
| 214 | + else
|
| 215 | + {
|
| 216 | + if (zbuffer) return glUtil_SetFBOTextures(This, &surface->levels[level].fbo, surface,
|
| 217 | + zbuffer, level, zlevel, zbuffer->zhasstencil);
|
| 218 | + else return glUtil_SetFBOTextures(This, &surface->levels[level].fbo, surface, NULL, 0, 0, FALSE);
|
| 219 | + }
|
208 | 220 | }
|
209 | 221 |
|
210 | 222 | GLenum glUtil_SetFBO(glUtil *This, FBO *fbo)
|
— | — | @@ -241,7 +253,7 @@ |
242 | 254 | }
|
243 | 255 | }
|
244 | 256 |
|
245 | | -GLenum glUtil_SetFBOTextures(glUtil *This, FBO *fbo, glTexture *color, glTexture *z, BOOL stencil)
|
| 257 | +GLenum glUtil_SetFBOTextures(glUtil *This, FBO *fbo, glTexture *color, glTexture *z, GLint level, GLint zlevel, BOOL stencil)
|
246 | 258 | {
|
247 | 259 | if(!fbo)
|
248 | 260 | {
|
— | — | @@ -250,7 +262,7 @@ |
251 | 263 | if(!fbo->fbo) glUtil_InitFBO(This, fbo);
|
252 | 264 | if (!color) return GL_INVALID_ENUM;
|
253 | 265 | if((color != fbo->fbcolor) || (z != fbo->fbz) || (stencil != fbo->stencil))
|
254 | | - glUtil_SetFBOTexture(This, fbo,color,z,stencil);
|
| 266 | + glUtil_SetFBOTexture(This, fbo,color,z,level,zlevel,stencil);
|
255 | 267 | if(fbo != This->currentfbo) return glUtil_SetFBO(This, fbo);
|
256 | 268 | else return fbo->status;
|
257 | 269 | }
|
— | — | @@ -637,7 +649,7 @@ |
638 | 650 | {
|
639 | 651 | glUtil_SetActiveTexture(This, level);
|
640 | 652 | glBindTexture(GL_TEXTURE_2D, texname);
|
641 | | - This->textures[level] = texname;
|
| 653 | + //This->textures[level] = texname;
|
642 | 654 | }
|
643 | 655 | }
|
644 | 656 |
|
Index: ddraw/glUtil.h |
— | — | @@ -34,11 +34,11 @@ |
35 | 35 | void glUtil_Release(glUtil *This);
|
36 | 36 | void glUtil_InitFBO(glUtil *This, FBO *fbo);
|
37 | 37 | void glUtil_DeleteFBO(glUtil *This, FBO *fbo);
|
38 | | -void glUtil_SetFBOTexture(glUtil *This, FBO *fbo, glTexture *color, glTexture *z, BOOL stencil);
|
| 38 | +void glUtil_SetFBOTexture(glUtil *This, FBO *fbo, glTexture *color, glTexture *z, GLint level, GLint zlevel, BOOL stencil);
|
39 | 39 | void glUtil_SetWrap(glUtil *This, int level, DWORD coord, DWORD address);
|
40 | | -GLenum glUtil_SetFBOSurface(glUtil *This, glDirectDrawSurface7 *surface);
|
| 40 | +GLenum glUtil_SetFBOSurface(glUtil *This, glTexture *surface, glTexture *zbuffer, GLint level, GLint zlevel, BOOL skipz);
|
41 | 41 | GLenum glUtil_SetFBO(glUtil *This, FBO *fbo);
|
42 | | -GLenum glUtil_SetFBOTextures(glUtil *This, FBO *fbo, glTexture *color, glTexture *z, BOOL stencil);
|
| 42 | +GLenum glUtil_SetFBOTextures(glUtil *This, FBO *fbo, glTexture *color, glTexture *z, GLint level, GLint zlevel, BOOL stencil);
|
43 | 43 | void glUtil_SetDepthComp(glUtil *This, GLenum comp);
|
44 | 44 | void glUtil_DepthWrite(glUtil *This, BOOL enabled);
|
45 | 45 | void glUtil_DepthTest(glUtil *This, BOOL enabled);
|
Index: ddraw/struct.h |
— | — | @@ -284,6 +284,7 @@ |
285 | 285 | // 1 - Surface was locked
|
286 | 286 | // 2 - Texture was written to by GPU
|
287 | 287 | DWORD locked;
|
| 288 | + FBO fbo;
|
288 | 289 | } MIPLEVEL;
|
289 | 290 |
|
290 | 291 | // Surface texture object
|
— | — | @@ -307,6 +308,7 @@ |
308 | 309 | int colororder;
|
309 | 310 | GLenum format;
|
310 | 311 | GLenum type;
|
| 312 | + BOOL zhasstencil;
|
311 | 313 | struct glTexture *palette;
|
312 | 314 | struct glTexture *stencil;
|
313 | 315 | struct glTexture *dummycolor;
|