Index: ddraw/dllmain.c |
— | — | @@ -1,53 +0,0 @@ |
2 | | -// DXGL
|
3 | | -// Copyright (C) 2011-2015 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 | | -#include "ddraw.h"
|
21 | | -#include "hooks.h"
|
22 | | -ATOM WindowClass = 0;
|
23 | | -BOOL smp = FALSE;
|
24 | | -CRITICAL_SECTION dll_cs = {NULL,0,0,NULL,NULL,0};
|
25 | | -SYSTEM_INFO sysinfo;
|
26 | | -BOOL APIENTRY DllMain(HMODULE hModule,
|
27 | | - DWORD ul_reason_for_call,
|
28 | | - LPVOID lpReserved
|
29 | | - )
|
30 | | -{
|
31 | | - switch (ul_reason_for_call)
|
32 | | - {
|
33 | | - case DLL_PROCESS_ATTACH:
|
34 | | - GetSystemInfo(&sysinfo);
|
35 | | - if (sysinfo.dwNumberOfProcessors > 1) smp = TRUE;
|
36 | | - if(!dll_cs.LockCount && !dll_cs.OwningThread) InitializeCriticalSection(&dll_cs);
|
37 | | - if (!hook_cs.LockCount && !hook_cs.OwningThread) InitializeCriticalSection(&hook_cs);
|
38 | | - InitHooks();
|
39 | | - GetCurrentConfig(&dxglcfg, TRUE);
|
40 | | - break;
|
41 | | - case DLL_THREAD_ATTACH:
|
42 | | - case DLL_THREAD_DETACH:
|
43 | | - break;
|
44 | | - case DLL_PROCESS_DETACH:
|
45 | | - ShutdownHooks();
|
46 | | - DeleteCriticalSection(&hook_cs);
|
47 | | - ZeroMemory(&hook_cs, sizeof(CRITICAL_SECTION));
|
48 | | - DeleteCriticalSection(&dll_cs);
|
49 | | - ZeroMemory(&dll_cs, sizeof(CRITICAL_SECTION));
|
50 | | - break;
|
51 | | - }
|
52 | | - return TRUE;
|
53 | | -}
|
54 | | -
|
Index: ddraw/common.h |
— | — | @@ -1,5 +1,5 @@ |
2 | 2 | // DXGL
|
3 | | -// Copyright (C) 2011-2012 William Feely
|
| 3 | +// Copyright (C) 2011-2015 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
|
— | — | @@ -88,7 +88,6 @@ |
89 | 89 | #define ERR(error) return error;
|
90 | 90 | #endif
|
91 | 91 |
|
92 | | -static INLINE int NextMultipleOf64K(int number){return ((number+65535) & (~65535));}
|
93 | 92 | static INLINE int NextMultipleOf8(int number){return ((number+7) & (~7));}
|
94 | 93 | static INLINE int NextMultipleOf4(int number){return ((number+3) & (~3));}
|
95 | 94 | static INLINE int NextMultipleOf2(int number){return ((number+1) & (~1));}
|
— | — | @@ -114,16 +113,7 @@ |
115 | 114 | #define NextMultipleOfWord NextMultipleOf4
|
116 | 115 | #endif
|
117 | 116 |
|
118 | | -#ifdef __cplusplus
|
119 | | -extern "C"
|
120 | | -{
|
121 | | - extern CRITICAL_SECTION dll_cs;
|
122 | | - extern BOOL smp;
|
123 | | -}
|
124 | | -#else
|
125 | 117 | extern CRITICAL_SECTION dll_cs;
|
126 | | -extern BOOL smp;
|
127 | | -#endif
|
128 | 118 |
|
129 | 119 | #include "trace.h"
|
130 | 120 | #include "../cfgmgr/cfgmgr.h"
|
Index: ddraw/ddraw.cpp |
— | — | @@ -28,8 +28,6 @@ |
29 | 29 | #include "hooks.h"
|
30 | 30 | #include <intrin.h>
|
31 | 31 |
|
32 | | -extern "C" {
|
33 | | -
|
34 | 32 | DXGLCFG dxglcfg;
|
35 | 33 | DWORD gllock = 0;
|
36 | 34 | HMODULE sysddraw = NULL;
|
— | — | @@ -570,5 +568,3 @@ |
571 | 569 | TRACE_EXIT(0,0);
|
572 | 570 | return TRUE;
|
573 | 571 | }
|
574 | | -
|
575 | | -} |
\ No newline at end of file |
Index: ddraw/ddraw.h |
— | — | @@ -19,10 +19,6 @@ |
20 | 20 | #ifndef _DDRAW_PRIVATE_H
|
21 | 21 | #define _DDRAW_PRIVATE_H
|
22 | 22 |
|
23 | | -#ifdef __cplusplus
|
24 | | -extern "C" {
|
25 | | -#endif
|
26 | | -
|
27 | 23 | #ifdef DDRAW_EXPORTS
|
28 | 24 | #define DDRAW_API __declspec(dllexport)
|
29 | 25 | #else
|
— | — | @@ -55,7 +51,7 @@ |
56 | 52 | HRESULT WINAPI DllGetClassObject(REFCLSID rclsid, REFIID riid, LPVOID *ppv);
|
57 | 53 | DDRAW_API void WINAPI GetDDSurfaceLocal();
|
58 | 54 | DDRAW_API HANDLE WINAPI GetOLEThunkData(int i1);
|
59 | | -DDRAW_API HRESULT WINAPI GlobalGetSurfaceFromDC(LPDIRECTDRAW7 lpDD, HDC hdc, LPDIRECTDRAWSURFACE7 *lpDDS);
|
| 55 | +DDRAW_API HRESULT WINAPI GlobalGetSurfaceFromDC(LPDIRECTDRAW lpDD, HDC hdc, LPDIRECTDRAWSURFACE7 *lpDDS);
|
60 | 56 | DDRAW_API void WINAPI RegisterSpecialCase();
|
61 | 57 | DDRAW_API void WINAPI ReleaseDDThreadLock();
|
62 | 58 | DDRAW_API BOOL IsDXGLDDraw();
|
— | — | @@ -64,17 +60,7 @@ |
65 | 61 | extern DWORD gllock;
|
66 | 62 | extern const GUID device_template;
|
67 | 63 | struct glRenderer;
|
68 | | -#ifdef __cplusplus
|
69 | 64 | class glDirectDraw7;
|
70 | | -#else
|
71 | | -typedef void glDirectDraw7;
|
72 | | -typedef BOOL bool;
|
73 | | -#endif
|
74 | 65 | void InitGL(int width, int height, int bpp, bool fullscreen, unsigned int frequency, HWND hWnd, glDirectDraw7 *glDD7, bool devwnd);
|
75 | 66 |
|
76 | | -
|
77 | | -#ifdef __cplusplus
|
78 | | -}
|
79 | | -#endif
|
80 | | -
|
81 | 67 | #endif //_DDRAW_PRIVATE_H
|
Index: ddraw/ddraw.vcxproj |
— | — | @@ -66,7 +66,6 @@ |
67 | 67 | </PropertyGroup>
|
68 | 68 | <Import Project="$(VCTargetsPath)\Microsoft.Cpp.props" />
|
69 | 69 | <ImportGroup Label="ExtensionSettings">
|
70 | | - <Import Project="$(VCTargetsPath)\BuildCustomizations\masm.props" />
|
71 | 70 | </ImportGroup>
|
72 | 71 | <ImportGroup Label="PropertySheets" Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
|
73 | 72 | <Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
|
— | — | @@ -191,7 +190,7 @@ |
192 | 191 | <SubSystem>Windows</SubSystem>
|
193 | 192 | <GenerateDebugInformation>true</GenerateDebugInformation>
|
194 | 193 | <ModuleDefinitionFile>ddraw.def</ModuleDefinitionFile>
|
195 | | - <AdditionalDependencies>$(OutDir)..\Debug\libMinHook.x86.lib;$(OutDir)cfgmgr.lib;glu32.lib;opengl32.lib;winmm.lib;%(AdditionalDependencies)</AdditionalDependencies>
|
| 194 | + <AdditionalDependencies>$(OutDir)libMinHook.x86.lib;$(OutDir)cfgmgr.lib;glu32.lib;opengl32.lib;winmm.lib;%(AdditionalDependencies)</AdditionalDependencies>
|
196 | 195 | <ImportLibrary>$(OutDir)ddraw.lib</ImportLibrary>
|
197 | 196 | </Link>
|
198 | 197 | <PostBuildEvent />
|
— | — | @@ -308,7 +307,7 @@ |
309 | 308 | </ItemGroup>
|
310 | 309 | <ItemGroup>
|
311 | 310 | <ClCompile Include="ddraw.cpp" />
|
312 | | - <ClCompile Include="dllmain.c">
|
| 311 | + <ClCompile Include="dllmain.cpp">
|
313 | 312 | <CompileAsManaged Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">false</CompileAsManaged>
|
314 | 313 | <CompileAsManaged Condition="'$(Configuration)|$(Platform)'=='Debug Trace|Win32'">false</CompileAsManaged>
|
315 | 314 | <CompileAsManaged Condition="'$(Configuration)|$(Platform)'=='Debug No MSVCRT|Win32'">false</CompileAsManaged>
|
— | — | @@ -315,14 +314,18 @@ |
316 | 315 | <CompileAsManaged Condition="'$(Configuration)|$(Platform)'=='Debug no DXGL|Win32'">false</CompileAsManaged>
|
317 | 316 | <PrecompiledHeader Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
|
318 | 317 | </PrecompiledHeader>
|
319 | | - <PrecompiledHeader Condition="'$(Configuration)|$(Platform)'=='Debug Trace|Win32'">NotUsing</PrecompiledHeader>
|
320 | | - <PrecompiledHeader Condition="'$(Configuration)|$(Platform)'=='Debug No MSVCRT|Win32'">NotUsing</PrecompiledHeader>
|
321 | | - <PrecompiledHeader Condition="'$(Configuration)|$(Platform)'=='Debug no DXGL|Win32'">NotUsing</PrecompiledHeader>
|
| 318 | + <PrecompiledHeader Condition="'$(Configuration)|$(Platform)'=='Debug Trace|Win32'">
|
| 319 | + </PrecompiledHeader>
|
| 320 | + <PrecompiledHeader Condition="'$(Configuration)|$(Platform)'=='Debug No MSVCRT|Win32'">
|
| 321 | + </PrecompiledHeader>
|
| 322 | + <PrecompiledHeader Condition="'$(Configuration)|$(Platform)'=='Debug no DXGL|Win32'">
|
| 323 | + </PrecompiledHeader>
|
322 | 324 | <CompileAsManaged Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">false</CompileAsManaged>
|
323 | 325 | <CompileAsManaged Condition="'$(Configuration)|$(Platform)'=='Release no DXGL|Win32'">false</CompileAsManaged>
|
324 | 326 | <PrecompiledHeader Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
|
325 | 327 | </PrecompiledHeader>
|
326 | | - <PrecompiledHeader Condition="'$(Configuration)|$(Platform)'=='Release no DXGL|Win32'">NotUsing</PrecompiledHeader>
|
| 328 | + <PrecompiledHeader Condition="'$(Configuration)|$(Platform)'=='Release no DXGL|Win32'">
|
| 329 | + </PrecompiledHeader>
|
327 | 330 | </ClCompile>
|
328 | 331 | <ClCompile Include="glClassFactory.cpp" />
|
329 | 332 | <ClCompile Include="dxguid.c">
|
— | — | @@ -445,6 +448,5 @@ |
446 | 449 | </ItemGroup>
|
447 | 450 | <Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
|
448 | 451 | <ImportGroup Label="ExtensionTargets">
|
449 | | - <Import Project="$(VCTargetsPath)\BuildCustomizations\masm.targets" />
|
450 | 452 | </ImportGroup>
|
451 | 453 | </Project> |
\ No newline at end of file |
Index: ddraw/ddraw.vcxproj.filters |
— | — | @@ -151,6 +151,9 @@ |
152 | 152 | <ClCompile Include="ddraw.cpp">
|
153 | 153 | <Filter>Source Files</Filter>
|
154 | 154 | </ClCompile>
|
| 155 | + <ClCompile Include="dllmain.cpp">
|
| 156 | + <Filter>Source Files</Filter>
|
| 157 | + </ClCompile>
|
155 | 158 | <ClCompile Include="glDirectDraw.cpp">
|
156 | 159 | <Filter>Source Files</Filter>
|
157 | 160 | </ClCompile>
|
— | — | @@ -244,9 +247,6 @@ |
245 | 248 | <ClCompile Include="hooks.c">
|
246 | 249 | <Filter>Source Files</Filter>
|
247 | 250 | </ClCompile>
|
248 | | - <ClCompile Include="dllmain.c">
|
249 | | - <Filter>Source Files</Filter>
|
250 | | - </ClCompile>
|
251 | 251 | </ItemGroup>
|
252 | 252 | <ItemGroup>
|
253 | 253 | <ResourceCompile Include="ddraw.rc">
|
Index: ddraw/dllmain.cpp |
— | — | @@ -0,0 +1,49 @@ |
| 2 | +// DXGL
|
| 3 | +// Copyright (C) 2011-2015 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 | +#include "ddraw.h"
|
| 21 | +#include "hooks.h"
|
| 22 | +ATOM WindowClass = NULL;
|
| 23 | +CRITICAL_SECTION dll_cs = {NULL,0,0,NULL,NULL,0};
|
| 24 | +BOOL APIENTRY DllMain( HMODULE hModule,
|
| 25 | + DWORD ul_reason_for_call,
|
| 26 | + LPVOID lpReserved
|
| 27 | + )
|
| 28 | +{
|
| 29 | + switch (ul_reason_for_call)
|
| 30 | + {
|
| 31 | + case DLL_PROCESS_ATTACH:
|
| 32 | + if(!dll_cs.LockCount && !dll_cs.OwningThread) InitializeCriticalSection(&dll_cs);
|
| 33 | + if (!hook_cs.LockCount && !hook_cs.OwningThread) InitializeCriticalSection(&hook_cs);
|
| 34 | + InitHooks();
|
| 35 | + GetCurrentConfig(&dxglcfg, true);
|
| 36 | + break;
|
| 37 | + case DLL_THREAD_ATTACH:
|
| 38 | + case DLL_THREAD_DETACH:
|
| 39 | + break;
|
| 40 | + case DLL_PROCESS_DETACH:
|
| 41 | + ShutdownHooks();
|
| 42 | + DeleteCriticalSection(&hook_cs);
|
| 43 | + ZeroMemory(&hook_cs, sizeof(CRITICAL_SECTION));
|
| 44 | + DeleteCriticalSection(&dll_cs);
|
| 45 | + ZeroMemory(&dll_cs, sizeof(CRITICAL_SECTION));
|
| 46 | + break;
|
| 47 | + }
|
| 48 | + return TRUE;
|
| 49 | +}
|
| 50 | +
|
Index: ddraw/glDirect3DDevice.cpp |
— | — | @@ -578,9 +578,7 @@ |
579 | 579 | TRACE_ENTER(7,14,this,8,dwCount,14,lpRects,9,dwFlags,9,dwColor,19,&dvZ,9,dwStencil);
|
580 | 580 | if(!this) TRACE_RET(HRESULT,23,DDERR_INVALIDOBJECT);
|
581 | 581 | if(dwCount && !lpRects) TRACE_RET(HRESULT,23,DDERR_INVALIDPARAMS);
|
582 | | - glRenderer_Clear(renderer,glDDS7,dwCount,lpRects,dwFlags,dwColor,dvZ,dwStencil);
|
583 | | - TRACE_EXIT(23, DD_OK);
|
584 | | - return DD_OK;
|
| 582 | + TRACE_RET(HRESULT,23,glRenderer_Clear(renderer,glDDS7,dwCount,lpRects,dwFlags,dwColor,dvZ,dwStencil));
|
585 | 583 | }
|
586 | 584 |
|
587 | 585 | // ComputeSphereVisibility based on modified code from the Wine project, subject
|
— | — | @@ -812,49 +810,6 @@ |
813 | 811 | return shader;
|
814 | 812 | }*/
|
815 | 813 |
|
816 | | -HRESULT GetFVFStride(DWORD dwVertexTypeDesc, LPDWORD stride)
|
817 | | -{
|
818 | | - TRACE_ENTER(2, 9, dwVertexTypeDesc, 14, stride);
|
819 | | - int i;
|
820 | | - int pos = (dwVertexTypeDesc & D3DFVF_POSITION_MASK) >> 1;
|
821 | | - int ptr = 0;
|
822 | | - DWORD texformats[8];
|
823 | | - if (pos == 1)
|
824 | | - {
|
825 | | - ptr += 3;
|
826 | | - if (dwVertexTypeDesc & D3DFVF_RESERVED1) ptr++;
|
827 | | - }
|
828 | | - else if (pos == 2) ptr += 4;
|
829 | | - else if (!pos) { TRACE_RET(HRESULT, 23, DDERR_INVALIDPARAMS); }
|
830 | | - else ptr += (3 + (pos - 2));
|
831 | | - if (dwVertexTypeDesc & D3DFVF_NORMAL) ptr += 3;
|
832 | | - if (dwVertexTypeDesc & D3DFVF_DIFFUSE) ptr++;
|
833 | | - if (dwVertexTypeDesc & D3DFVF_SPECULAR) ptr++;
|
834 | | - int numtex = (dwVertexTypeDesc&D3DFVF_TEXCOUNT_MASK) >> D3DFVF_TEXCOUNT_SHIFT;
|
835 | | - for (i = 0; i < 8; i++)
|
836 | | - {
|
837 | | - if (i >= numtex) texformats[i] = -1;
|
838 | | - else texformats[i] = (dwVertexTypeDesc >> (16 + (2 * i)) & 3);
|
839 | | - switch (texformats[i])
|
840 | | - {
|
841 | | - case 0: // st
|
842 | | - ptr += 2;
|
843 | | - break;
|
844 | | - case 1: // str
|
845 | | - ptr += 3;
|
846 | | - break;
|
847 | | - case 2: // strq
|
848 | | - ptr += 4;
|
849 | | - break;
|
850 | | - case 3: // s
|
851 | | - ptr++;
|
852 | | - break;
|
853 | | - }
|
854 | | - }
|
855 | | - *stride = ptr * 4;
|
856 | | - TRACE_EXIT(23, D3D_OK);
|
857 | | - return D3D_OK;
|
858 | | -}
|
859 | 814 | HRESULT glDirect3DDevice7::fvftoglvertex(DWORD dwVertexTypeDesc,LPDWORD vertptr)
|
860 | 815 | {
|
861 | 816 | TRACE_ENTER(3,14,this,9,dwVertexTypeDesc,14,vertptr);
|
— | — | @@ -907,7 +862,7 @@ |
908 | 863 | else vertdata[9].data = NULL;
|
909 | 864 | for(i = 0; i < 8; i++)
|
910 | 865 | vertdata[i+10].data = NULL;
|
911 | | - int numtex = (dwVertexTypeDesc & D3DFVF_TEXCOUNT_MASK) >> D3DFVF_TEXCOUNT_SHIFT;
|
| 866 | + int numtex = (dwVertexTypeDesc&D3DFVF_TEXCOUNT_MASK)>>D3DFVF_TEXCOUNT_SHIFT;
|
912 | 867 | for(i = 0; i < 8; i++)
|
913 | 868 | {
|
914 | 869 | vertdata[i+10].data = &vertptr[ptr];
|
— | — | @@ -949,15 +904,12 @@ |
950 | 905 | TRACE_ENTER(8,9,d3dptPrimitiveType,9,dwVertexTypeDesc,14,lpvVertices,8,dwVertexCount,14,lpwIndices,8,dwIndexCount,9,dwFlags);
|
951 | 906 | if(!this) TRACE_RET(HRESULT,23,DDERR_INVALIDOBJECT);
|
952 | 907 | if(!inscene) TRACE_RET(HRESULT,23,D3DERR_SCENE_NOT_IN_SCENE);
|
953 | | - DWORD stride;
|
954 | | - HRESULT err = GetFVFStride(dwVertexTypeDesc, &stride);
|
| 908 | + HRESULT err = fvftoglvertex(dwVertexTypeDesc,(LPDWORD)lpvVertices);
|
955 | 909 | if(lpwIndices) AddStats(d3dptPrimitiveType,dwIndexCount,&stats);
|
956 | 910 | else AddStats(d3dptPrimitiveType,dwVertexCount,&stats);
|
957 | 911 | if(err != D3D_OK) TRACE_RET(HRESULT,23,err);
|
958 | | - glRenderer_DrawPrimitives(renderer,this,setdrawmode(d3dptPrimitiveType),stride,(BYTE*)lpvVertices,
|
959 | | - dwVertexTypeDesc,dwVertexCount,lpwIndices,dwIndexCount,dwFlags);
|
960 | | - TRACE_EXIT(23, D3D_OK);
|
961 | | - return D3D_OK;
|
| 912 | + TRACE_RET(HRESULT,23,glRenderer_DrawPrimitives(renderer,this,setdrawmode(d3dptPrimitiveType),vertdata,texformats,
|
| 913 | + dwVertexCount,lpwIndices,dwIndexCount,dwFlags));
|
962 | 914 | }
|
963 | 915 | HRESULT WINAPI glDirect3DDevice7::DrawIndexedPrimitiveStrided(D3DPRIMITIVETYPE d3dptPrimitiveType, DWORD dwVertexTypeDesc,
|
964 | 916 | LPD3DDRAWPRIMITIVESTRIDEDDATA lpvVertexArray, DWORD dwVertexCount, LPWORD lpwIndices, DWORD dwIndexCount, DWORD dwFlags)
|
Index: ddraw/glDirectDraw.cpp |
— | — | @@ -1164,7 +1164,6 @@ |
1165 | 1165 | mode.dmSize = sizeof(DEVMODE);
|
1166 | 1166 | EnumDisplaySettings(NULL, ENUM_CURRENT_SETTINGS, &mode);
|
1167 | 1167 | glRenderer_Init(tmprenderer, 16, 16, mode.dmBitsPerPel, false, mode.dmDisplayFrequency, hGLWnd, NULL, FALSE);
|
1168 | | - glRenderer_Sync(tmprenderer,0);
|
1169 | 1168 | if (tmprenderer->ext->glver_major >= 3) fullrop = TRUE;
|
1170 | 1169 | if (tmprenderer->ext->GLEXT_EXT_gpu_shader4) fullrop = TRUE;
|
1171 | 1170 | glRenderer_Delete(tmprenderer);
|
— | — | @@ -1172,7 +1171,6 @@ |
1173 | 1172 | }
|
1174 | 1173 | else
|
1175 | 1174 | {
|
1176 | | - glRenderer_Sync(renderer,0);
|
1177 | 1175 | if (renderer->ext->glver_major >= 3) fullrop = TRUE;
|
1178 | 1176 | if (renderer->ext->GLEXT_EXT_gpu_shader4) fullrop = TRUE;
|
1179 | 1177 | }
|
— | — | @@ -1376,6 +1374,7 @@ |
1377 | 1375 | threadsafe = false;
|
1378 | 1376 | nowindowchanges = false;
|
1379 | 1377 | cooplevel = 0;
|
| 1378 | + timer = timeGetTime();
|
1380 | 1379 | ZeroMemory(&oldmode,sizeof(DEVMODE));
|
1381 | 1380 | surfaces = (glDirectDrawSurface7 **)malloc(1024*sizeof(glDirectDrawSurface7 *));
|
1382 | 1381 | if(!surfaces) TRACE_RET(HRESULT,23,DDERR_OUTOFMEMORY);
|
— | — | @@ -1909,7 +1908,7 @@ |
1910 | 1909 | if(dwFlags & 0xFFFFFFFA) TRACE_RET(HRESULT,23,DDERR_INVALIDPARAMS);
|
1911 | 1910 | if(dwFlags == 5) TRACE_RET(HRESULT,23,DDERR_INVALIDPARAMS);
|
1912 | 1911 | if(!lastsync) lastsync = true;
|
1913 | | - else if(primary) primary->RenderScreen(primary->texture,primary,1);
|
| 1912 | + else primary->RenderScreen(primary->texture,primary,1);
|
1914 | 1913 | TRACE_EXIT(23,DD_OK);
|
1915 | 1914 | return DD_OK;
|
1916 | 1915 | }
|
Index: ddraw/glDirectDraw.h |
— | — | @@ -136,6 +136,7 @@ |
137 | 137 | glDirect3D3 *glD3D3;
|
138 | 138 | glDirect3D2 *glD3D2;
|
139 | 139 | glDirect3D1 *glD3D1;
|
| 140 | + DWORD timer;
|
140 | 141 | bool devwnd;
|
141 | 142 | DWORD cooplevel;
|
142 | 143 | };
|
Index: ddraw/glDirectDrawSurface.cpp |
— | — | @@ -30,6 +30,7 @@ |
31 | 31 | #include "glDirectDrawPalette.h"
|
32 | 32 | #include "glDirectDrawClipper.h"
|
33 | 33 | #include "glDirectDrawGammaControl.h"
|
| 34 | +#include "glRenderer.h"
|
34 | 35 | #include <string>
|
35 | 36 | using namespace std;
|
36 | 37 | #include "ShaderGen3D.h"
|
— | — | @@ -224,9 +225,9 @@ |
225 | 226 | switch(surfacetype)
|
226 | 227 | {
|
227 | 228 | case 0:
|
228 | | - buffer = (BYTE *)malloc(NextMultipleOf4((ddsd.ddpfPixelFormat.dwRGBBitCount * ddsd.dwWidth)/8) * ddsd.dwHeight);
|
| 229 | + buffer = (char *)malloc(NextMultipleOf4((ddsd.ddpfPixelFormat.dwRGBBitCount * ddsd.dwWidth)/8) * ddsd.dwHeight);
|
229 | 230 | if((ddsd.dwWidth != fakex) || (ddsd.dwHeight != fakey))
|
230 | | - bigbuffer = (BYTE *)malloc(NextMultipleOf4((ddsd.ddpfPixelFormat.dwRGBBitCount * fakex)/8) * fakey);
|
| 231 | + bigbuffer = (char *)malloc(NextMultipleOf4((ddsd.ddpfPixelFormat.dwRGBBitCount * fakex)/8) * fakey);
|
231 | 232 | if(!buffer) *error = DDERR_OUTOFMEMORY;
|
232 | 233 | goto maketex;
|
233 | 234 | break;
|
— | — | @@ -401,7 +402,6 @@ |
402 | 403 | glDirectDrawSurface7::~glDirectDrawSurface7()
|
403 | 404 | {
|
404 | 405 | TRACE_ENTER(1,14,this);
|
405 | | - glRenderer_Sync(ddInterface->renderer, 0);
|
406 | 406 | AddRef();
|
407 | 407 | if (dds1) delete dds1;
|
408 | 408 | if (dds2) delete dds2;
|
— | — | @@ -852,9 +852,7 @@ |
853 | 853 | if (dwFlags & DDBLT_DEPTHFILL)
|
854 | 854 | {
|
855 | 855 | if (!(ddsd.ddpfPixelFormat.dwFlags & DDPF_ZBUFFER)) TRACE_RET(HRESULT, 23, DDERR_UNSUPPORTED);
|
856 | | - glRenderer_DepthFill(ddInterface->renderer, lpDestRect, this, lpDDBltFx);
|
857 | | - TRACE_EXIT(23, DD_OK);
|
858 | | - return DD_OK;
|
| 856 | + TRACE_RET(HRESULT, 23, glRenderer_DepthFill(ddInterface->renderer, lpDestRect, this, lpDDBltFx));
|
859 | 857 | }
|
860 | 858 | if (this == src)
|
861 | 859 | {
|
— | — | @@ -865,12 +863,9 @@ |
866 | 864 | if (error) TRACE_RET(HRESULT, 23, error);
|
867 | 865 | error = ddInterface->tmpsurface->Blt(&tmprect, lpDDSrcSurface, lpSrcRect, 0, NULL);
|
868 | 866 | if (error) TRACE_RET(HRESULT, 23, error);
|
869 | | - this->Blt(lpDestRect, ddInterface->tmpsurface, &tmprect, dwFlags, lpDDBltFx);
|
| 867 | + TRACE_RET(HRESULT,23,this->Blt(lpDestRect, ddInterface->tmpsurface, &tmprect, dwFlags, lpDDBltFx));
|
870 | 868 | }
|
871 | | - else glRenderer_Blt(ddInterface->renderer,lpDestRect,src,this,lpSrcRect,dwFlags,lpDDBltFx);
|
872 | | - if (this == ddInterface->primary) glRenderer_Sync(ddInterface->renderer,0);
|
873 | | - TRACE_EXIT(23, DD_OK);
|
874 | | - return DD_OK;
|
| 869 | + else TRACE_RET(HRESULT,23,glRenderer_Blt(ddInterface->renderer,lpDestRect,src,this,lpSrcRect,dwFlags,lpDDBltFx));
|
875 | 870 | }
|
876 | 871 | HRESULT WINAPI glDirectDrawSurface7::BltBatch(LPDDBLTBATCH lpDDBltBatch, DWORD dwCount, DWORD dwFlags)
|
877 | 872 | {
|
— | — | @@ -991,7 +986,6 @@ |
992 | 987 | else if(dwFlags & DDFLIP_INTERVAL4) swapinterval=4;
|
993 | 988 | else swapinterval=1;
|
994 | 989 | }
|
995 | | - glRenderer_Sync(ddInterface->renderer,0);
|
996 | 990 | int flips = 1;
|
997 | 991 | if(lpDDSurfaceTargetOverride)
|
998 | 992 | {
|
— | — | @@ -1332,9 +1326,9 @@ |
1333 | 1327 | ERR(DDERR_UNSUPPORTED);
|
1334 | 1328 | break;
|
1335 | 1329 | case 2:
|
1336 | | - buffer = (BYTE *)malloc(ddsd.lPitch * ddsd.dwHeight);
|
| 1330 | + buffer = (char *)malloc(ddsd.lPitch * ddsd.dwHeight);
|
1337 | 1331 | if((ddsd.dwWidth != fakex) || (ddsd.dwHeight != fakey))
|
1338 | | - bigbuffer = (BYTE *)malloc((ddsd.ddpfPixelFormat.dwRGBBitCount * NextMultipleOf4(fakex) * fakey)/8);
|
| 1332 | + bigbuffer = (char *)malloc((ddsd.ddpfPixelFormat.dwRGBBitCount * NextMultipleOf4(fakex) * fakey)/8);
|
1339 | 1333 | else bigbuffer = NULL;
|
1340 | 1334 | glRenderer_DownloadTexture(ddInterface->renderer,buffer,bigbuffer,texture,ddsd.dwWidth,ddsd.dwHeight,fakex,fakey,ddsd.lPitch,
|
1341 | 1335 | (ddInterface->GetBPPMultipleOf8()/8)*fakex,ddsd.ddpfPixelFormat.dwRGBBitCount,miplevel);
|
Index: ddraw/glDirectDrawSurface.h |
— | — | @@ -148,9 +148,9 @@ |
149 | 149 | TEXTURE *dummycolor;
|
150 | 150 | bool hasstencil;
|
151 | 151 | DWORD miplevel;
|
152 | | - BYTE *buffer;
|
153 | | - BYTE *bigbuffer;
|
154 | | - BYTE *gdibuffer;
|
| 152 | + char *buffer;
|
| 153 | + char *bigbuffer;
|
| 154 | + char *gdibuffer;
|
155 | 155 | DDSURFACEDESC2 ddsd;
|
156 | 156 | glDirectDrawPalette *palette;
|
157 | 157 | HGLRC hRC;
|
Index: ddraw/glRenderWindow.cpp |
— | — | @@ -129,7 +129,7 @@ |
130 | 130 | #ifdef _DEBUG
|
131 | 131 | if(hotkeyregistered) UnregisterHotKey(hWnd,1);
|
132 | 132 | #endif
|
133 | | - PostMessage(hWnd,WM_CLOSE,0,0);
|
| 133 | + SendMessage(hWnd,WM_CLOSE,0,0);
|
134 | 134 | WaitForSingleObject(hThread,INFINITE);
|
135 | 135 | CloseHandle(hThread);
|
136 | 136 | }
|
Index: ddraw/glRenderer.cpp |
— | — | @@ -35,7 +35,6 @@ |
36 | 36 | extern "C" {
|
37 | 37 |
|
38 | 38 | const GLushort bltindices[4] = {0,1,2,3};
|
39 | | -const RECT nullrect = { -1, -1, -1, -1 };
|
40 | 39 |
|
41 | 40 | /**
|
42 | 41 | * Expands a 5-bit value to 8 bits.
|
— | — | @@ -79,236 +78,111 @@ |
80 | 79 | }
|
81 | 80 |
|
82 | 81 | /**
|
83 | | -* Adds a command to the renderer queue.\n
|
84 | | -* If the command requires more space than the queue buffer, the buffer will be
|
85 | | -* expanded. If there is no free space for the command, execution will pause
|
86 | | -* until the queue has been sufficiently emptied.
|
87 | | -* @param This
|
88 | | -* Pointer to glRenderer object
|
89 | | -* @param opcode
|
90 | | -* Code that describes the command to be added to the queue.
|
91 | | -* @param mode
|
92 | | -* Method to use for synchronization:
|
93 | | -* - 0: Do not fail the call
|
94 | | -* - 1: Fail if queue is full
|
95 | | -* - 2: Fail if queue is not empty
|
96 | | -* @param size
|
97 | | -* Size of the command in DWORDs
|
98 | | -* @param paramcount
|
99 | | -* Number of parameters to add to the queue command.
|
100 | | -* @param ...
|
101 | | -* Parameters for the command, when required. This is given in pairs of two
|
102 | | -* arguments:
|
103 | | -* - size: The size of the parameter, in bytes. Note that parameters are DWORD
|
104 | | -* aligned. The size cannot exceed the size of the command, minus data already
|
105 | | -* written to the queue.
|
106 | | -* - pointer: A pointer to the data to be added to the command.\n
|
107 | | -* If no parameters are used for the opcode, then supply 0 and NULL for the ...
|
108 | | -* parameter.
|
109 | | -* @return
|
110 | | -* Zero if the call succeeds, nonzero otherwise.
|
111 | | -*/
|
112 | | -int glRenderer_AddQueue(glRenderer *This, DWORD opcode, int mode, DWORD size, int paramcount, ...)
|
113 | | -{
|
114 | | - EnterCriticalSection(&This->queuecs);
|
115 | | - if ((mode == 2) && This->queuelength)
|
116 | | - {
|
117 | | - LeaveCriticalSection(&This->queuecs);
|
118 | | - return 1;
|
119 | | - }
|
120 | | - va_list params;
|
121 | | - // Check queue size
|
122 | | - va_start(params, paramcount);
|
123 | | - int argsize;
|
124 | | - void *argptr;
|
125 | | - if (size > This->queuesize)
|
126 | | - {
|
127 | | - This->queue = (LPDWORD)realloc(This->queue, (This->queuesize + size)*sizeof(DWORD));
|
128 | | - This->queuesize += size;
|
129 | | - }
|
130 | | - if (This->queuesize - This->queue_write < size)
|
131 | | - {
|
132 | | -/* if (This->queue_read < size)
|
133 | | - {
|
134 | | - if (mode == 1)
|
135 | | - {
|
136 | | - LeaveCriticalSection(&This->queuecs);
|
137 | | - return 1;
|
138 | | - }
|
139 | | - if (This->queue_write < This->queuesize)
|
140 | | - {
|
141 | | - This->queue[This->queue_write] = OP_RESETQUEUE;
|
142 | | - This->queuelength++;
|
143 | | - }
|
144 | | - LeaveCriticalSection(&This->queuecs);
|
145 | | - glRenderer_Sync(This, size);
|
146 | | - EnterCriticalSection(&This->queuecs);
|
147 | | - }*/
|
148 | | - LeaveCriticalSection(&This->queuecs);
|
149 | | - glRenderer_Sync(This, 0);
|
150 | | - EnterCriticalSection(&This->queuecs);
|
151 | | - }
|
152 | | - if (This->queue_write < This->queue_read)
|
153 | | - {
|
154 | | - if (This->queue_read - This->queue_write < size)
|
155 | | - {
|
156 | | - LeaveCriticalSection(&This->queuecs);
|
157 | | - glRenderer_Sync(This, size);
|
158 | | - EnterCriticalSection(&This->queuecs);
|
159 | | - }
|
160 | | - }
|
161 | | - This->queue[This->queue_write++] = opcode;
|
162 | | - This->queue[This->queue_write++] = size;
|
163 | | - size -= 2;
|
164 | | - for (int i = 0; i < paramcount; i++)
|
165 | | - {
|
166 | | - argsize = va_arg(params, int);
|
167 | | - argptr = va_arg(params, void*);
|
168 | | - if (!argsize)
|
169 | | - {
|
170 | | - This->queue[This->queue_write++] = argsize;
|
171 | | - size -= 1;
|
172 | | - continue;
|
173 | | - }
|
174 | | - if ((NextMultipleOf4(argsize) / 4) > size) break;
|
175 | | - This->queue[This->queue_write++] = argsize;
|
176 | | - if (argptr) memcpy(This->queue + This->queue_write, argptr, argsize);
|
177 | | - This->queue_write += (NextMultipleOf4(argsize) / 4);
|
178 | | - size -= 1 + (NextMultipleOf4(argsize) / 4);
|
179 | | - }
|
180 | | - va_end(params);
|
181 | | - if (size != 0)
|
182 | | - {
|
183 | | - FIXME("Opcode size mismatch!\n")
|
184 | | - }
|
185 | | - This->queuelength++;
|
186 | | - if (!This->running) SetEvent(This->start);
|
187 | | - LeaveCriticalSection(&This->queuecs);
|
188 | | - return 0;
|
189 | | -}
|
190 | | -
|
191 | | -/**
|
192 | | -* Waits until the specified amount of queue space is free
|
193 | | -* @param This
|
194 | | -* Pointer to glRenderer object
|
195 | | -* @param size
|
196 | | -* If nonzero, the number of DWORDs that must be available within the queue.
|
197 | | -* If zero, waits until the queue is empty.
|
198 | | -*/
|
199 | | -void glRenderer_Sync(glRenderer *This, int size)
|
200 | | -{
|
201 | | - EnterCriticalSection(&This->queuecs);
|
202 | | - if (!This->queuelength && !This->running)
|
203 | | - {
|
204 | | - LeaveCriticalSection(&This->queuecs);
|
205 | | - return;
|
206 | | - }
|
207 | | - ResetEvent(This->sync);
|
208 | | - This->syncsize = size;
|
209 | | - if (!This->running) SetEvent(This->start);
|
210 | | - LeaveCriticalSection(&This->queuecs);
|
211 | | - WaitForSingleObject(This->sync, INFINITE);
|
212 | | -}
|
213 | | -
|
214 | | -/**
|
215 | 82 | * Internal function for uploading surface content to an OpenGL texture
|
216 | 83 | * @param This
|
217 | 84 | * Pointer to glRenderer object
|
218 | 85 | * @param buffer
|
219 | 86 | * Contains the contents of the surface
|
| 87 | + * @param bigbuffer
|
| 88 | + * Optional buffer to receive the rescaled surface contents, for when primary
|
| 89 | + * scaling is enabled.
|
220 | 90 | * @param texture
|
221 | 91 | * Texture object to upload to
|
222 | 92 | * @param x,y
|
223 | 93 | * Width and height of the surface
|
| 94 | + * @param bigx,bigy
|
| 95 | + * Width and height of the scaled surface buffer
|
224 | 96 | * @param pitch
|
225 | 97 | * Bytes from one line of graphics to the next in the surface
|
| 98 | + * @param bigpitch
|
| 99 | + * Pitch of the scaled surface buffer
|
| 100 | + * @param bpp
|
| 101 | + * Number of bits per surface pixel
|
226 | 102 | * @param miplevel
|
227 | 103 | * Mipmap level of texture to write
|
228 | 104 | */
|
229 | | -void glRenderer__UploadTexture(glRenderer *This, BYTE *buffer, TEXTURE *texture,
|
230 | | - DWORD x, DWORD y, DWORD pitch, DWORD miplevel)
|
| 105 | +void glRenderer__UploadTexture(glRenderer *This, char *buffer, char *bigbuffer, TEXTURE *texture, int x, int y,
|
| 106 | + int bigx, int bigy, int pitch, int bigpitch, int bpp, int miplevel)
|
231 | 107 | {
|
232 | | - TextureManager__UploadTexture(This->texman, texture, miplevel, buffer, x, y, FALSE, FALSE);
|
233 | | -}
|
234 | | -
|
235 | | -/**
|
236 | | -* Uploads the content of a surface to an OpenGL texture, called from the backend.
|
237 | | -* @param This
|
238 | | -* Pointer to glRenderer object
|
239 | | -* @param buffer
|
240 | | -* Contains the contents of the surface
|
241 | | -* @param bigbuffer
|
242 | | -* Optional buffer to receive the rescaled surface contents, for when primary
|
243 | | -* scaling is enabled. Scaling will be performed before the surface is uploaded.
|
244 | | -* @param texture
|
245 | | -* Texture object to upload to
|
246 | | -* @param x,y
|
247 | | -* Width and height of the surface
|
248 | | -* @param bigx,bigy
|
249 | | -* Width and height of the scaled surface buffer
|
250 | | -* @param pitch
|
251 | | -* Bytes from one line of graphics to the next in the surface
|
252 | | -* @param bigpitch
|
253 | | -* Pitch of the scaled surface buffer
|
254 | | -* @param bpp
|
255 | | -* Number of bits per surface pixel
|
256 | | -* @param miplevel
|
257 | | -* Mipmap level of texture to write
|
258 | | -*/
|
259 | | -void glRenderer__UploadTextureSurface(glRenderer *This, BYTE *buffer, BYTE *bigbuffer, TEXTURE *texture, DWORD x, DWORD y, DWORD bigx, DWORD bigy, DWORD pitch, DWORD bigpitch, DWORD bpp, DWORD miplevel)
|
260 | | -{
|
261 | | - BYTE *outbuffer;
|
262 | | - DWORD outx, outy, outpitch, outbpp;
|
263 | | - if (bpp == 15) outbpp = 16;
|
264 | | - else outbpp = bpp;
|
265 | | - if ((x == bigx && y == bigy) || !bigbuffer)
|
| 108 | + if(bpp == 15) bpp = 16;
|
| 109 | + if((x == bigx && y == bigy) || !bigbuffer)
|
266 | 110 | {
|
267 | | - outbuffer = buffer;
|
268 | | - outx = x;
|
269 | | - outy = y;
|
270 | | - outpitch = pitch;
|
| 111 | + TextureManager__UploadTexture(This->texman, texture, miplevel, buffer, x, y, FALSE, FALSE);
|
271 | 112 | }
|
272 | 113 | else
|
273 | 114 | {
|
274 | | - switch (outbpp)
|
| 115 | + switch(bpp)
|
275 | 116 | {
|
276 | 117 | case 8:
|
277 | | - ScaleNearest8(bigbuffer, buffer, bigx, bigy, x, y, pitch, bigpitch);
|
| 118 | + ScaleNearest8(bigbuffer,buffer,bigx,bigy,x,y,pitch,bigpitch);
|
278 | 119 | break;
|
279 | 120 | case 16:
|
280 | | - ScaleNearest16(bigbuffer, buffer, bigx, bigy, x, y, pitch / 2, bigpitch / 2);
|
| 121 | + ScaleNearest16(bigbuffer,buffer,bigx,bigy,x,y,pitch/2,bigpitch/2);
|
281 | 122 | break;
|
282 | 123 | case 24:
|
283 | | - ScaleNearest24(bigbuffer, buffer, bigx, bigy, x, y, pitch, bigpitch);
|
| 124 | + ScaleNearest24(bigbuffer,buffer,bigx,bigy,x,y,pitch,bigpitch);
|
284 | 125 | break;
|
285 | 126 | case 32:
|
286 | | - ScaleNearest32(bigbuffer, buffer, bigx, bigy, x, y, pitch / 4, bigpitch / 4);
|
| 127 | + ScaleNearest32(bigbuffer,buffer,bigx,bigy,x,y,pitch/4,bigpitch/4);
|
287 | 128 | break;
|
288 | | - break;
|
| 129 | + break;
|
289 | 130 | }
|
290 | | - outbuffer = bigbuffer;
|
291 | | - outx = bigx;
|
292 | | - outy = bigy;
|
293 | | - outpitch = bigpitch;
|
| 131 | + TextureManager__UploadTexture(This->texman, texture, miplevel, bigbuffer, bigx, bigy, FALSE, FALSE);
|
294 | 132 | }
|
295 | | - glRenderer__UploadTexture(This, outbuffer, texture, outx, outy, outpitch, miplevel);
|
296 | 133 | }
|
297 | 134 |
|
298 | 135 | /**
|
299 | | - * Internal function for downloading surface content from an OpenGL texture.
|
300 | | - * Forwards the request to the Texture Manager.
|
| 136 | + * Internal function for downloading surface content from an OpenGL texture
|
301 | 137 | * @param This
|
302 | 138 | * Pointer to glRenderer object
|
303 | 139 | * @param buffer
|
304 | 140 | * Buffer to receive the surface contents
|
| 141 | + * @param bigbuffer
|
| 142 | + * Optional buffer to receive the rescaled surface contents, for when primary
|
| 143 | + * scaling is enabled.
|
305 | 144 | * @param texture
|
306 | 145 | * Texture object to download from
|
| 146 | + * @param x,y
|
| 147 | + * Width and height of the surface
|
| 148 | + * @param bigx,bigy
|
| 149 | + * Width and height of the scaled surface buffer
|
| 150 | + * @param pitch
|
| 151 | + * Bytes from one line of graphics to the next in the surface
|
| 152 | + * @param bigpitch
|
| 153 | + * Pitch of the scaled surface buffer
|
| 154 | + * @param bpp
|
| 155 | + * Number of bits per surface pixel
|
307 | 156 | * @param miplevel
|
308 | 157 | * Mipmap level of texture to read
|
309 | 158 | */
|
310 | | -void glRenderer__DownloadTexture(glRenderer *This, BYTE *buffer, TEXTURE *texture, DWORD miplevel)
|
| 159 | +void glRenderer__DownloadTexture(glRenderer *This, char *buffer, char *bigbuffer, TEXTURE *texture, int x, int y,
|
| 160 | + int bigx, int bigy, int pitch, int bigpitch, int bpp, int miplevel)
|
311 | 161 | {
|
312 | | - TextureManager__DownloadTexture(This->texman,texture,miplevel,buffer);
|
| 162 | + if((bigx == x && bigy == y) || !bigbuffer)
|
| 163 | + {
|
| 164 | + TextureManager__DownloadTexture(This->texman,texture,miplevel,buffer);
|
| 165 | + }
|
| 166 | + else
|
| 167 | + {
|
| 168 | + TextureManager__DownloadTexture(This->texman,texture,miplevel,bigbuffer);
|
| 169 | + switch(bpp)
|
| 170 | + {
|
| 171 | + case 8:
|
| 172 | + ScaleNearest8(buffer,bigbuffer,x,y,bigx,bigy,bigpitch,pitch);
|
| 173 | + break;
|
| 174 | + case 15:
|
| 175 | + case 16:
|
| 176 | + ScaleNearest16(buffer,bigbuffer,x,y,bigx,bigy,bigpitch/2,pitch/2);
|
| 177 | + break;
|
| 178 | + case 24:
|
| 179 | + ScaleNearest24(buffer,bigbuffer,x,y,bigx,bigy,bigpitch,pitch);
|
| 180 | + break;
|
| 181 | + case 32:
|
| 182 | + ScaleNearest32(buffer,bigbuffer,x,y,bigx,bigy,bigpitch/4,pitch/4);
|
| 183 | + break;
|
| 184 | + break;
|
| 185 | + }
|
| 186 | + }
|
313 | 187 | }
|
314 | 188 |
|
315 | 189 | /**
|
— | — | @@ -327,7 +201,7 @@ |
328 | 202 | * @param devwnd
|
329 | 203 | * True if creating window with name "DirectDrawDeviceWnd"
|
330 | 204 | */
|
331 | | -void glRenderer_Init(glRenderer *This, DWORD width, DWORD height, DWORD bpp, BOOL fullscreen, DWORD frequency, HWND hwnd, glDirectDraw7 *glDD7, BOOL devwnd)
|
| 205 | +void glRenderer_Init(glRenderer *This, int width, int height, int bpp, bool fullscreen, unsigned int frequency, HWND hwnd, glDirectDraw7 *glDD7, BOOL devwnd)
|
332 | 206 | {
|
333 | 207 | LONG_PTR winstyle, winstyleex;
|
334 | 208 | This->oldswap = 0;
|
— | — | @@ -340,12 +214,11 @@ |
341 | 215 | This->hRC = NULL;
|
342 | 216 | This->PBO = 0;
|
343 | 217 | This->dib.enabled = false;
|
344 | | - This->running = FALSE;
|
345 | 218 | This->hWnd = hwnd;
|
346 | | - This->busy = CreateEvent(NULL, FALSE, FALSE, NULL);
|
347 | | - InitializeCriticalSection(&This->commandcs);
|
348 | | - InitializeCriticalSection(&This->queuecs);
|
349 | | - if (fullscreen)
|
| 219 | + InitializeCriticalSection(&This->cs);
|
| 220 | + This->busy = CreateEvent(NULL,FALSE,FALSE,NULL);
|
| 221 | + This->start = CreateEvent(NULL,FALSE,FALSE,NULL);
|
| 222 | + if(fullscreen)
|
350 | 223 | {
|
351 | 224 | winstyle = GetWindowLongPtrA(This->hWnd, GWL_STYLE);
|
352 | 225 | winstyleex = GetWindowLongPtrA(This->hWnd, GWL_EXSTYLE);
|
— | — | @@ -357,7 +230,6 @@ |
358 | 231 | {
|
359 | 232 | // TODO: Adjust window rect
|
360 | 233 | }
|
361 | | - EnterCriticalSection(&This->commandcs);
|
362 | 234 | SetWindowPos(This->hWnd,HWND_TOP,0,0,0,0,SWP_NOMOVE | SWP_NOSIZE | SWP_FRAMECHANGED);
|
363 | 235 | This->RenderWnd = new glRenderWindow(width,height,fullscreen,This->hWnd,glDD7,devwnd);
|
364 | 236 | This->inputs[0] = (void*)width;
|
— | — | @@ -367,9 +239,10 @@ |
368 | 240 | This->inputs[4] = (void*)frequency;
|
369 | 241 | This->inputs[5] = (void*)This->hWnd;
|
370 | 242 | This->inputs[6] = glDD7;
|
371 | | - This->hThread = CreateThread(NULL, 0, (LPTHREAD_START_ROUTINE)glRenderer__Entry, This, 0, NULL);
|
372 | | - WaitForSingleObject(This->busy, INFINITE);
|
373 | | - LeaveCriticalSection(&This->commandcs);
|
| 243 | + This->inputs[7] = This;
|
| 244 | + This->inputs[8] = (void*)devwnd;
|
| 245 | + This->hThread = CreateThread(NULL, 0, glRenderer_ThreadEntry, This->inputs, 0, NULL);
|
| 246 | + WaitForSingleObject(This->busy,INFINITE);
|
374 | 247 | }
|
375 | 248 |
|
376 | 249 | /**
|
— | — | @@ -379,19 +252,30 @@ |
380 | 253 | */
|
381 | 254 | void glRenderer_Delete(glRenderer *This)
|
382 | 255 | {
|
383 | | - MSG Msg;
|
384 | | - EnterCriticalSection(&This->commandcs);
|
385 | | - glRenderer_AddQueue(This, OP_DELETE, 0, 2, 0);
|
386 | | - LeaveCriticalSection(&This->commandcs);
|
387 | | - WaitForObjectAndMessages(This->hThread);
|
388 | | - DeleteCriticalSection(&This->commandcs);
|
| 256 | + EnterCriticalSection(&This->cs);
|
| 257 | + This->opcode = OP_DELETE;
|
| 258 | + SetEvent(This->start);
|
| 259 | + WaitForObjectAndMessages(This->busy);
|
| 260 | + CloseHandle(This->start);
|
389 | 261 | CloseHandle(This->busy);
|
390 | | - CloseHandle(This->sync);
|
391 | | - CloseHandle(This->start);
|
| 262 | + LeaveCriticalSection(&This->cs);
|
| 263 | + DeleteCriticalSection(&This->cs);
|
392 | 264 | CloseHandle(This->hThread);
|
393 | 265 | }
|
394 | 266 |
|
395 | 267 | /**
|
| 268 | + * Entry point for the renderer thread
|
| 269 | + * @param entry
|
| 270 | + * Pointer to the inputs passed by the CreateThread function
|
| 271 | + */
|
| 272 | +DWORD WINAPI glRenderer_ThreadEntry(void *entry)
|
| 273 | +{
|
| 274 | + void **inputsin = (void**)entry;
|
| 275 | + glRenderer *This = (glRenderer*)inputsin[7];
|
| 276 | + return glRenderer__Entry(This);
|
| 277 | +}
|
| 278 | +
|
| 279 | +/**
|
396 | 280 | * Creates an OpenGL texture.
|
397 | 281 | * @param This
|
398 | 282 | * Pointer to glRenderer object
|
— | — | @@ -412,10 +296,14 @@ |
413 | 297 | */
|
414 | 298 | void glRenderer_MakeTexture(glRenderer *This, TEXTURE *texture, DWORD width, DWORD height)
|
415 | 299 | {
|
416 | | - EnterCriticalSection(&This->commandcs);
|
417 | | - glRenderer_AddQueue(This, OP_CREATE, 0, 8, 3, 4, &texture, 4, &width, 4, &height);
|
418 | | - glRenderer_Sync(This, 0);
|
419 | | - LeaveCriticalSection(&This->commandcs);
|
| 300 | + EnterCriticalSection(&This->cs);
|
| 301 | + This->inputs[0] = texture;
|
| 302 | + This->inputs[1] = (void*)width;
|
| 303 | + This->inputs[2] = (void*)height;
|
| 304 | + This->opcode = OP_CREATE;
|
| 305 | + SetEvent(This->start);
|
| 306 | + WaitForSingleObject(This->busy,INFINITE);
|
| 307 | + LeaveCriticalSection(&This->cs);
|
420 | 308 | }
|
421 | 309 |
|
422 | 310 | /**
|
— | — | @@ -426,7 +314,7 @@ |
427 | 315 | * Contains the contents of the surface
|
428 | 316 | * @param bigbuffer
|
429 | 317 | * Optional buffer to receive the rescaled surface contents, for when primary
|
430 | | - * scaling is enabled. Scaling will be performed before the surface is uploaded.
|
| 318 | + * scaling is enabled.
|
431 | 319 | * @param texture
|
432 | 320 | * Texture object to upload to
|
433 | 321 | * @param x,y
|
— | — | @@ -442,50 +330,25 @@ |
443 | 331 | * @param miplevel
|
444 | 332 | * Mipmap level of texture to write
|
445 | 333 | */
|
446 | | -void glRenderer_UploadTexture(glRenderer *This, BYTE *buffer, BYTE *bigbuffer, TEXTURE *texture, DWORD x, DWORD y,
|
447 | | - DWORD bigx, DWORD bigy, DWORD pitch, DWORD bigpitch, DWORD bpp, DWORD miplevel)
|
| 334 | +void glRenderer_UploadTexture(glRenderer *This, char *buffer, char *bigbuffer, TEXTURE *texture, int x, int y,
|
| 335 | + int bigx, int bigy, int pitch, int bigpitch, int bpp, int miplevel)
|
448 | 336 | {
|
449 | | - BYTE *outbuffer;
|
450 | | - DWORD outx, outy, outpitch, outbpp;
|
451 | | - DWORD *opbuffer;
|
452 | | - DWORD uploadopsize;
|
453 | | - if (bpp == 15) outbpp = 16;
|
454 | | - else outbpp = bpp;
|
455 | | - if ((x == bigx && y == bigy) || !bigbuffer)
|
456 | | - {
|
457 | | - outbuffer = buffer;
|
458 | | - outx = x;
|
459 | | - outy = y;
|
460 | | - outpitch = pitch;
|
461 | | - }
|
462 | | - else
|
463 | | - {
|
464 | | - switch (outbpp)
|
465 | | - {
|
466 | | - case 8:
|
467 | | - ScaleNearest8(bigbuffer, buffer, bigx, bigy, x, y, pitch, bigpitch);
|
468 | | - break;
|
469 | | - case 16:
|
470 | | - ScaleNearest16(bigbuffer, buffer, bigx, bigy, x, y, pitch / 2, bigpitch / 2);
|
471 | | - break;
|
472 | | - case 24:
|
473 | | - ScaleNearest24(bigbuffer, buffer, bigx, bigy, x, y, pitch, bigpitch);
|
474 | | - break;
|
475 | | - case 32:
|
476 | | - ScaleNearest32(bigbuffer, buffer, bigx, bigy, x, y, pitch / 4, bigpitch / 4);
|
477 | | - break;
|
478 | | - break;
|
479 | | - }
|
480 | | - outbuffer = bigbuffer;
|
481 | | - outx = bigx;
|
482 | | - outy = bigy;
|
483 | | - outpitch = bigpitch;
|
484 | | - }
|
485 | | - EnterCriticalSection(&This->commandcs);
|
486 | | - glRenderer_AddQueue(This, OP_UPLOAD, 0, 14, 6, 4, &outbuffer, 4, &texture, 4, &outx, 4, &outy,
|
487 | | - 4, &outpitch, 4, &miplevel);
|
488 | | - glRenderer_Sync(This, 0);
|
489 | | - LeaveCriticalSection(&This->commandcs);
|
| 337 | + EnterCriticalSection(&This->cs);
|
| 338 | + This->inputs[0] = buffer;
|
| 339 | + This->inputs[1] = bigbuffer;
|
| 340 | + This->inputs[2] = texture;
|
| 341 | + This->inputs[3] = (void*)x;
|
| 342 | + This->inputs[4] = (void*)y;
|
| 343 | + This->inputs[5] = (void*)bigx;
|
| 344 | + This->inputs[6] = (void*)bigy;
|
| 345 | + This->inputs[7] = (void*)pitch;
|
| 346 | + This->inputs[8] = (void*)bigpitch;
|
| 347 | + This->inputs[9] = (void*)bpp;
|
| 348 | + This->inputs[10] = (void*)miplevel;
|
| 349 | + This->opcode = OP_UPLOAD;
|
| 350 | + SetEvent(This->start);
|
| 351 | + WaitForSingleObject(This->busy,INFINITE);
|
| 352 | + LeaveCriticalSection(&This->cs);
|
490 | 353 | }
|
491 | 354 |
|
492 | 355 | /**
|
— | — | @@ -496,7 +359,7 @@ |
497 | 360 | * Buffer to receive the surface contents
|
498 | 361 | * @param bigbuffer
|
499 | 362 | * Optional buffer to receive the rescaled surface contents, for when primary
|
500 | | - * scaling is enabled. Scaling will be performed after the download is complete.
|
| 363 | + * scaling is enabled.
|
501 | 364 | * @param texture
|
502 | 365 | * Texture object to download from
|
503 | 366 | * @param x,y
|
— | — | @@ -512,52 +375,25 @@ |
513 | 376 | * @param miplevel
|
514 | 377 | * Mipmap level of texture to read
|
515 | 378 | */
|
516 | | -void glRenderer_DownloadTexture(glRenderer *This, BYTE *buffer, BYTE *bigbuffer, TEXTURE *texture, DWORD x, DWORD y,
|
517 | | - DWORD bigx, DWORD bigy, DWORD pitch, DWORD bigpitch, DWORD bpp, DWORD miplevel)
|
| 379 | +void glRenderer_DownloadTexture(glRenderer *This, char *buffer, char *bigbuffer, TEXTURE *texture, int x, int y,
|
| 380 | + int bigx, int bigy, int pitch, int bigpitch, int bpp, int miplevel)
|
518 | 381 | {
|
519 | | - BOOL doscale;
|
520 | | - BYTE *inbuffer;
|
521 | | - DWORD inx, iny, inpitch;
|
522 | | - if ((x == bigx && y == bigy) || !bigbuffer)
|
523 | | - {
|
524 | | - doscale = FALSE;
|
525 | | - inbuffer = buffer;
|
526 | | - inx = x;
|
527 | | - iny = y;
|
528 | | - inpitch = pitch;
|
529 | | - }
|
530 | | - else
|
531 | | - {
|
532 | | - doscale = TRUE;
|
533 | | - inbuffer = bigbuffer;
|
534 | | - inx = bigx;
|
535 | | - iny = bigy;
|
536 | | - inpitch = bigpitch;
|
537 | | - }
|
538 | | - EnterCriticalSection(&This->commandcs);
|
539 | | - glRenderer_AddQueue(This, OP_DOWNLOAD, 0, 8, 3, 4, &inbuffer, 4, &texture, 4, &miplevel);
|
540 | | - glRenderer_Sync(This, 0);
|
541 | | - LeaveCriticalSection(&This->commandcs);
|
542 | | - if (doscale)
|
543 | | - {
|
544 | | - switch (bpp)
|
545 | | - {
|
546 | | - case 8:
|
547 | | - ScaleNearest8(buffer, bigbuffer, x, y, bigx, bigy, bigpitch, pitch);
|
548 | | - break;
|
549 | | - case 15:
|
550 | | - case 16:
|
551 | | - ScaleNearest16(buffer, bigbuffer, x, y, bigx, bigy, bigpitch / 2, pitch / 2);
|
552 | | - break;
|
553 | | - case 24:
|
554 | | - ScaleNearest24(buffer, bigbuffer, x, y, bigx, bigy, bigpitch, pitch);
|
555 | | - break;
|
556 | | - case 32:
|
557 | | - ScaleNearest32(buffer, bigbuffer, x, y, bigx, bigy, bigpitch / 4, pitch / 4);
|
558 | | - break;
|
559 | | - break;
|
560 | | - }
|
561 | | - }
|
| 382 | + EnterCriticalSection(&This->cs);
|
| 383 | + This->inputs[0] = buffer;
|
| 384 | + This->inputs[1] = bigbuffer;
|
| 385 | + This->inputs[2] = texture;
|
| 386 | + This->inputs[3] = (void*)x;
|
| 387 | + This->inputs[4] = (void*)y;
|
| 388 | + This->inputs[5] = (void*)bigx;
|
| 389 | + This->inputs[6] = (void*)bigy;
|
| 390 | + This->inputs[7] = (void*)pitch;
|
| 391 | + This->inputs[8] = (void*)bigpitch;
|
| 392 | + This->inputs[9] = (void*)bpp;
|
| 393 | + This->inputs[10] = (void*)miplevel;
|
| 394 | + This->opcode = OP_DOWNLOAD;
|
| 395 | + SetEvent(This->start);
|
| 396 | + WaitForSingleObject(This->busy,INFINITE);
|
| 397 | + LeaveCriticalSection(&This->cs);
|
562 | 398 | }
|
563 | 399 |
|
564 | 400 | /**
|
— | — | @@ -569,9 +405,12 @@ |
570 | 406 | */
|
571 | 407 | void glRenderer_DeleteTexture(glRenderer *This, TEXTURE * texture)
|
572 | 408 | {
|
573 | | - EnterCriticalSection(&This->commandcs);
|
574 | | - glRenderer_AddQueue(This, OP_DELETETEX, 0, 4, 1, 4, &texture);
|
575 | | - LeaveCriticalSection(&This->commandcs);
|
| 409 | + EnterCriticalSection(&This->cs);
|
| 410 | + This->inputs[0] = texture;
|
| 411 | + This->opcode = OP_DELETETEX;
|
| 412 | + SetEvent(This->start);
|
| 413 | + WaitForSingleObject(This->busy,INFINITE);
|
| 414 | + LeaveCriticalSection(&This->cs);
|
576 | 415 | }
|
577 | 416 |
|
578 | 417 | /**
|
— | — | @@ -589,36 +428,42 @@ |
590 | 429 | * entire surface will be used.
|
591 | 430 | * @param dwFlags
|
592 | 431 | * Flags to determine the behavior of the blitter. Certain flags control the
|
593 | | - * synchronization of the operation: (not yet fully implemented)
|
| 432 | + * synchronization of the operation: (not yet implemented)
|
594 | 433 | * - DDBLT_ASYNC: Adds the command to the queue. If the queue is full, returns
|
595 | 434 | * DDERR_WASSTILLDRAWING.
|
596 | 435 | * - DDBLT_DONOTWAIT: Fails and returns DDERR_WASSTILLDRAWING if the queue is full.
|
597 | | - * - DDBLT_WAIT: Waits until the Blt command is added to the queue before returning.
|
| 436 | + * - DDBLT_WAIT: Waits until the Blt command is processed before returning.
|
598 | 437 | * @param lpDDBltFx
|
599 | 438 | * Effect parameters for the Blt operation.
|
| 439 | + * @return
|
| 440 | + * DD_OK if the call succeeds, or DDERR_WASSTILLDRAWING if busy.
|
600 | 441 | */
|
601 | 442 | HRESULT glRenderer_Blt(glRenderer *This, LPRECT lpDestRect, glDirectDrawSurface7 *src,
|
602 | 443 | glDirectDrawSurface7 *dest, LPRECT lpSrcRect, DWORD dwFlags, LPDDBLTFX lpDDBltFx)
|
603 | 444 | {
|
604 | | - DWORD nullfx = 0xFFFFFFFF;
|
605 | | - RECT emptyrect = nullrect;
|
606 | | - EnterCriticalSection(&This->commandcs);
|
607 | | - int syncmode = 0;
|
608 | | - if (dwFlags & DDBLT_ASYNC) syncmode = 1;
|
609 | | - if (dwFlags & DDBLT_DONOTWAIT) syncmode = 2;
|
610 | | - if (!lpSrcRect) lpSrcRect = &emptyrect;
|
611 | | - if (!lpDestRect) lpDestRect = &emptyrect;
|
612 | | - int fxsize = 4;
|
613 | | - if (lpDDBltFx) fxsize = sizeof(DDBLTFX);
|
614 | | - else lpDDBltFx = (LPDDBLTFX)&nullfx;
|
615 | | - if (glRenderer_AddQueue(This, OP_BLT, syncmode, 11 + (sizeof(RECT) / 2) + (fxsize / 4), 6, sizeof(RECT), lpDestRect, 4, &src,
|
616 | | - 4, &dest, sizeof(RECT), lpSrcRect, 4, &dwFlags, fxsize, lpDDBltFx))
|
| 445 | + EnterCriticalSection(&This->cs);
|
| 446 | + RECT r,r2;
|
| 447 | + if(((dest->ddsd.ddsCaps.dwCaps & (DDSCAPS_FRONTBUFFER)) &&
|
| 448 | + (dest->ddsd.ddsCaps.dwCaps & DDSCAPS_PRIMARYSURFACE)) ||
|
| 449 | + ((dest->ddsd.ddsCaps.dwCaps & DDSCAPS_PRIMARYSURFACE) &&
|
| 450 | + !(dest->ddsd.ddsCaps.dwCaps & DDSCAPS_FLIP)))
|
617 | 451 | {
|
618 | | - LeaveCriticalSection(&This->commandcs);
|
619 | | - return DDERR_WASSTILLDRAWING;
|
| 452 | + GetClientRect(This->hWnd,&r);
|
| 453 | + GetClientRect(This->RenderWnd->GetHWnd(),&r2);
|
| 454 | + if(memcmp(&r2,&r,sizeof(RECT)))
|
| 455 | + SetWindowPos(This->RenderWnd->GetHWnd(),NULL,0,0,r.right,r.bottom,SWP_SHOWWINDOW);
|
620 | 456 | }
|
621 | | - LeaveCriticalSection(&This->commandcs);
|
622 | | - return DD_OK;
|
| 457 | + This->inputs[0] = lpDestRect;
|
| 458 | + This->inputs[1] = src;
|
| 459 | + This->inputs[2] = dest;
|
| 460 | + This->inputs[3] = lpSrcRect;
|
| 461 | + This->inputs[4] = (void*)dwFlags;
|
| 462 | + This->inputs[5] = lpDDBltFx;
|
| 463 | + This->opcode = OP_BLT;
|
| 464 | + SetEvent(This->start);
|
| 465 | + WaitForSingleObject(This->busy,INFINITE);
|
| 466 | + LeaveCriticalSection(&This->cs);
|
| 467 | + return (HRESULT)This->outputs[0];
|
623 | 468 | }
|
624 | 469 |
|
625 | 470 | /**
|
— | — | @@ -638,10 +483,16 @@ |
639 | 484 | */
|
640 | 485 | void glRenderer_DrawScreen(glRenderer *This, TEXTURE *texture, TEXTURE *paltex, glDirectDrawSurface7 *dest, glDirectDrawSurface7 *src, GLint vsync)
|
641 | 486 | {
|
642 | | - EnterCriticalSection(&This->commandcs);
|
643 | | - glRenderer_AddQueue(This, OP_DRAWSCREEN, 0, 12, 5, 4, &texture, 4, &paltex, 4, &dest, 4, &src, 4, &vsync);
|
644 | | - glRenderer_Sync(This, 0);
|
645 | | - LeaveCriticalSection(&This->commandcs);
|
| 487 | + EnterCriticalSection(&This->cs);
|
| 488 | + This->inputs[0] = texture;
|
| 489 | + This->inputs[1] = paltex;
|
| 490 | + This->inputs[2] = dest;
|
| 491 | + This->inputs[3] = src;
|
| 492 | + This->inputs[4] = (void*)vsync;
|
| 493 | + This->opcode = OP_DRAWSCREEN;
|
| 494 | + SetEvent(This->start);
|
| 495 | + WaitForSingleObject(This->busy,INFINITE);
|
| 496 | + LeaveCriticalSection(&This->cs);
|
646 | 497 | }
|
647 | 498 |
|
648 | 499 | /**
|
— | — | @@ -653,9 +504,14 @@ |
654 | 505 | */
|
655 | 506 | void glRenderer_InitD3D(glRenderer *This, int zbuffer, int x, int y)
|
656 | 507 | {
|
657 | | - EnterCriticalSection(&This->commandcs);
|
658 | | - glRenderer_AddQueue(This, OP_INITD3D, 0, 8, 3, 4, &zbuffer, 4, &x, 4, &y);
|
659 | | - LeaveCriticalSection(&This->commandcs);
|
| 508 | + EnterCriticalSection(&This->cs);
|
| 509 | + This->inputs[0] = (void*)zbuffer;
|
| 510 | + This->inputs[1] = (void*)x;
|
| 511 | + This->inputs[2] = (void*)y;
|
| 512 | + This->opcode = OP_INITD3D;
|
| 513 | + SetEvent(This->start);
|
| 514 | + WaitForSingleObject(This->busy,INFINITE);
|
| 515 | + LeaveCriticalSection(&This->cs);
|
660 | 516 | }
|
661 | 517 |
|
662 | 518 | /**
|
— | — | @@ -676,27 +532,38 @@ |
677 | 533 | * Value to fill the Z buffer with.
|
678 | 534 | * @param dwStencil
|
679 | 535 | * Value to fill the stencil buffer with.
|
| 536 | + * @return
|
| 537 | + * Returns D3D_OK
|
680 | 538 | */
|
681 | | -void glRenderer_Clear(glRenderer *This, glDirectDrawSurface7 *target, DWORD dwCount, LPD3DRECT lpRects, DWORD dwFlags, DWORD dwColor, D3DVALUE dvZ, DWORD dwStencil)
|
| 539 | +HRESULT glRenderer_Clear(glRenderer *This, glDirectDrawSurface7 *target, DWORD dwCount, LPD3DRECT lpRects, DWORD dwFlags, DWORD dwColor, D3DVALUE dvZ, DWORD dwStencil)
|
682 | 540 | {
|
683 | | - EnterCriticalSection(&This->commandcs);
|
684 | | - int rectsize = dwCount * sizeof(D3DRECT);
|
685 | | - glRenderer_AddQueue(This, OP_CLEAR, 0, 15 + (rectsize / 4), 7, 4, &target, 4, &dwCount,
|
686 | | - 4, &dwFlags, 4, &dwColor, 4, &dvZ, 4, &dwStencil, rectsize, lpRects);
|
687 | | - LeaveCriticalSection(&This->commandcs);
|
| 541 | + EnterCriticalSection(&This->cs);
|
| 542 | + This->inputs[0] = target;
|
| 543 | + This->inputs[1] = (void*)dwCount;
|
| 544 | + This->inputs[2] = lpRects;
|
| 545 | + This->inputs[3] = (void*)dwFlags;
|
| 546 | + This->inputs[4] = (void*)dwColor;
|
| 547 | + memcpy(&This->inputs[5],&dvZ,4);
|
| 548 | + This->inputs[6] = (void*)dwStencil;
|
| 549 | + This->opcode = OP_CLEAR;
|
| 550 | + SetEvent(This->start);
|
| 551 | + WaitForSingleObject(This->busy,INFINITE);
|
| 552 | + LeaveCriticalSection(&This->cs);
|
| 553 | + return (HRESULT)This->outputs[0];
|
688 | 554 | }
|
689 | 555 |
|
690 | 556 | /**
|
691 | | - * Instructs the OpenGL driver to send all queued commands to the GPU, and empties the queue.
|
| 557 | + * Instructs the OpenGL driver to send all queued commands to the GPU.
|
692 | 558 | * @param This
|
693 | 559 | * Pointer to glRenderer object
|
694 | 560 | */
|
695 | 561 | void glRenderer_Flush(glRenderer *This)
|
696 | 562 | {
|
697 | | - EnterCriticalSection(&This->commandcs);
|
698 | | - glRenderer_AddQueue(This, OP_CLEAR, 0, 2, 0, 0, NULL);
|
699 | | - glRenderer_Sync(This, 0);
|
700 | | - LeaveCriticalSection(&This->commandcs);
|
| 563 | + EnterCriticalSection(&This->cs);
|
| 564 | + This->opcode = OP_FLUSH;
|
| 565 | + SetEvent(This->start);
|
| 566 | + WaitForSingleObject(This->busy,INFINITE);
|
| 567 | + LeaveCriticalSection(&This->cs);
|
701 | 568 | }
|
702 | 569 |
|
703 | 570 | /**
|
— | — | @@ -712,13 +579,26 @@ |
713 | 580 | * @param devwnd
|
714 | 581 | * True if creating window with name "DirectDrawDeviceWnd"
|
715 | 582 | */
|
716 | | -void glRenderer_SetWnd(glRenderer *This, DWORD width, DWORD height, DWORD bpp, DWORD fullscreen, DWORD frequency, HWND newwnd, BOOL devwnd)
|
| 583 | +void glRenderer_SetWnd(glRenderer *This, int width, int height, int bpp, int fullscreen, unsigned int frequency, HWND newwnd, BOOL devwnd)
|
717 | 584 | {
|
718 | | - EnterCriticalSection(&This->commandcs);
|
719 | | - glRenderer_AddQueue(This, OP_SETWND, 0, 16, 7, 4, &width, 4, &height, 4, &bpp, 4, &fullscreen,
|
720 | | - 4, &frequency, 4, &newwnd, 4, &devwnd);
|
721 | | - glRenderer_Sync(This, 0);
|
722 | | - LeaveCriticalSection(&This->commandcs);
|
| 585 | + EnterCriticalSection(&This->cs);
|
| 586 | + if(fullscreen && newwnd)
|
| 587 | + {
|
| 588 | + SetWindowLongPtrA(newwnd,GWL_EXSTYLE,WS_EX_APPWINDOW);
|
| 589 | + SetWindowLongPtrA(newwnd,GWL_STYLE,WS_OVERLAPPED);
|
| 590 | + ShowWindow(newwnd,SW_MAXIMIZE);
|
| 591 | + }
|
| 592 | + This->inputs[0] = (void*)width;
|
| 593 | + This->inputs[1] = (void*)height;
|
| 594 | + This->inputs[2] = (void*)bpp;
|
| 595 | + This->inputs[3] = (void*)fullscreen;
|
| 596 | + This->inputs[4] = (void*)frequency;
|
| 597 | + This->inputs[5] = (void*)newwnd;
|
| 598 | + This->inputs[6] = (void*)devwnd;
|
| 599 | + This->opcode = OP_SETWND;
|
| 600 | + SetEvent(This->start);
|
| 601 | + WaitForObjectAndMessages(This->busy);
|
| 602 | + LeaveCriticalSection(&This->cs);
|
723 | 603 | }
|
724 | 604 | /**
|
725 | 605 | * Draws one or more primitives to the currently selected render target.
|
— | — | @@ -728,12 +608,12 @@ |
729 | 609 | * glDirect3DDevice7 interface to use for drawing
|
730 | 610 | * @param mode
|
731 | 611 | * OpenGL primitive drawing mode to use
|
732 | | - * @param stride
|
733 | | - * Distance between vertex sets in bytes
|
734 | 612 | * @param vertices
|
735 | 613 | * Pointer to vertex data
|
736 | | - * @param dwVertexTypeDesc
|
737 | | - * FVF flags for vertex type.
|
| 614 | + * @param packed
|
| 615 | + * True if vertex data is packed (e.g. xyz,normal,texcoord,xyz,normal,etc.)
|
| 616 | + * @param texformats
|
| 617 | + * Pointer to texture coordinate formats used in the call
|
738 | 618 | * @param count
|
739 | 619 | * Number of vertices to copy to the draw command
|
740 | 620 | * @param indices
|
— | — | @@ -742,25 +622,29 @@ |
743 | 623 | * @param indexcount
|
744 | 624 | * Number of vertex indices. May be 0 for non-indexed mode.
|
745 | 625 | * @param flags
|
746 | | - * Set to D3DDP_WAIT to wait until the queue has processed the call.
|
| 626 | + * Set to D3DDP_WAIT to wait until the queue has processed the call. (not yet
|
| 627 | + * implemented)
|
747 | 628 | * @return
|
748 | 629 | * D3D_OK if the call succeeds, or D3DERR_INVALIDVERTEXTYPE if the vertex format
|
749 | 630 | * has no position coordinates.
|
750 | 631 | */
|
751 | | -void glRenderer_DrawPrimitives(glRenderer *This, glDirect3DDevice7 *device, GLenum mode, DWORD stride, BYTE *vertices, DWORD dwVertexTypeDesc, DWORD count, LPWORD indices,
|
| 632 | +HRESULT glRenderer_DrawPrimitives(glRenderer *This, glDirect3DDevice7 *device, GLenum mode, GLVERTEX *vertices, int *texformats, DWORD count, LPWORD indices,
|
752 | 633 | DWORD indexcount, DWORD flags)
|
753 | 634 | {
|
754 | | - EnterCriticalSection(&This->commandcs);
|
755 | | - DWORD vertsize = 0;
|
756 | | - DWORD indexsize = 0;
|
757 | | - if (!indices) indexcount = 0;
|
758 | | - vertsize = stride * count;
|
759 | | - indexsize = NextMultipleOf4(indexcount * 2);
|
760 | | - glRenderer_AddQueue(This, OP_DRAWPRIMITIVES, 0, 16 + ((vertsize + indexsize)/4), 8, 4, &device,
|
761 | | - 4, &mode, 4, &stride, 4, &dwVertexTypeDesc, 4, &count, 4, &indexcount,
|
762 | | - vertsize, vertices, indexsize, indices);
|
763 | | - if (flags & D3DDP_WAIT) glRenderer_Sync(This, 0);
|
764 | | - LeaveCriticalSection(&This->commandcs);
|
| 635 | + EnterCriticalSection(&This->cs);
|
| 636 | + This->inputs[0] = device;
|
| 637 | + This->inputs[1] = (void*)mode;
|
| 638 | + This->inputs[2] = vertices;
|
| 639 | + This->inputs[3] = texformats;
|
| 640 | + This->inputs[4] = (void*)count;
|
| 641 | + This->inputs[5] = indices;
|
| 642 | + This->inputs[6] = (void*)indexcount;
|
| 643 | + This->inputs[7] = (void*)flags;
|
| 644 | + This->opcode = OP_DRAWPRIMITIVES;
|
| 645 | + SetEvent(This->start);
|
| 646 | + WaitForSingleObject(This->busy,INFINITE);
|
| 647 | + LeaveCriticalSection(&This->cs);
|
| 648 | + return (HRESULT)This->outputs[0];
|
765 | 649 | }
|
766 | 650 |
|
767 | 651 | /**
|
— | — | @@ -772,10 +656,12 @@ |
773 | 657 | */
|
774 | 658 | void glRenderer_DeleteFBO(glRenderer *This, FBO *fbo)
|
775 | 659 | {
|
776 | | - EnterCriticalSection(&This->commandcs);
|
777 | | - glRenderer_AddQueue(This, OP_DELETEFBO, 0, 4, 1, 4, &fbo);
|
778 | | - glRenderer_Sync(This, 0);
|
779 | | - LeaveCriticalSection(&This->commandcs);
|
| 660 | + EnterCriticalSection(&This->cs);
|
| 661 | + This->inputs[0] = fbo;
|
| 662 | + This->opcode = OP_DELETEFBO;
|
| 663 | + SetEvent(This->start);
|
| 664 | + WaitForSingleObject(This->busy,INFINITE);
|
| 665 | + LeaveCriticalSection(&This->cs);
|
780 | 666 | }
|
781 | 667 |
|
782 | 668 | /**
|
— | — | @@ -787,9 +673,12 @@ |
788 | 674 | */
|
789 | 675 | void glRenderer_UpdateClipper(glRenderer *This, glDirectDrawSurface7 *surface)
|
790 | 676 | {
|
791 | | - EnterCriticalSection(&This->commandcs);
|
792 | | - glRenderer_AddQueue(This, OP_UPDATECLIPPER, 0, 4, 1, 4, &surface);
|
793 | | - LeaveCriticalSection(&This->commandcs);
|
| 677 | + EnterCriticalSection(&This->cs);
|
| 678 | + This->inputs[0] = surface;
|
| 679 | + This->opcode = OP_UPDATECLIPPER;
|
| 680 | + SetEvent(This->start);
|
| 681 | + WaitForSingleObject(This->busy,INFINITE);
|
| 682 | + LeaveCriticalSection(&This->cs);
|
794 | 683 | }
|
795 | 684 |
|
796 | 685 |
|
— | — | @@ -814,14 +703,17 @@ |
815 | 704 | * @param lpDDBltFx
|
816 | 705 | * Pointer to DDBLTFX structure with dwFillDepth defining the depth value.
|
817 | 706 | */
|
818 | | -void glRenderer_DepthFill(glRenderer *This, LPRECT lpDestRect, glDirectDrawSurface7 *dest, LPDDBLTFX lpDDBltFx)
|
| 707 | +HRESULT glRenderer_DepthFill(glRenderer *This, LPRECT lpDestRect, glDirectDrawSurface7 *dest, LPDDBLTFX lpDDBltFx)
|
819 | 708 | {
|
820 | | - EnterCriticalSection(&This->commandcs);
|
821 | | - RECT emptyrect = nullrect;
|
822 | | - if (!lpDestRect) lpDestRect = &emptyrect;
|
823 | | - glRenderer_AddQueue(This, OP_DEPTHFILL, 0, 6 + (sizeof(RECT) / 4) + (sizeof(DDBLTFX) / 4),
|
824 | | - 3, 4, &dest, sizeof(RECT), lpDestRect, sizeof(DDBLTFX), lpDDBltFx);
|
825 | | - LeaveCriticalSection(&This->commandcs);
|
| 709 | + EnterCriticalSection(&This->cs);
|
| 710 | + This->inputs[0] = lpDestRect;
|
| 711 | + This->inputs[1] = dest;
|
| 712 | + This->inputs[2] = lpDDBltFx;
|
| 713 | + This->opcode = OP_DEPTHFILL;
|
| 714 | + SetEvent(This->start);
|
| 715 | + WaitForSingleObject(This->busy, INFINITE);
|
| 716 | + LeaveCriticalSection(&This->cs);
|
| 717 | + return (HRESULT)This->outputs[0];
|
826 | 718 | }
|
827 | 719 |
|
828 | 720 | /**
|
— | — | @@ -835,10 +727,13 @@ |
836 | 728 | */
|
837 | 729 | void glRenderer_SetRenderState(glRenderer *This, D3DRENDERSTATETYPE dwRendStateType, DWORD dwRenderState)
|
838 | 730 | {
|
839 | | - EnterCriticalSection(&This->commandcs);
|
840 | | - if (!This->running) This->renderstate[dwRendStateType] = dwRenderState;
|
841 | | - else glRenderer_AddQueue(This, OP_SETRENDERSTATE, 0, 6, 2, 4, &dwRendStateType, 4, &dwRenderState);
|
842 | | - LeaveCriticalSection(&This->commandcs);
|
| 731 | + EnterCriticalSection(&This->cs);
|
| 732 | + This->inputs[0] = (void*)dwRendStateType;
|
| 733 | + This->inputs[1] = (void*)dwRenderState;
|
| 734 | + This->opcode = OP_SETRENDERSTATE;
|
| 735 | + SetEvent(This->start);
|
| 736 | + WaitForSingleObject(This->busy, INFINITE);
|
| 737 | + LeaveCriticalSection(&This->cs);
|
843 | 738 | }
|
844 | 739 |
|
845 | 740 | /**
|
— | — | @@ -852,9 +747,13 @@ |
853 | 748 | */
|
854 | 749 | void glRenderer_SetTexture(glRenderer *This, DWORD dwStage, glDirectDrawSurface7 *Texture)
|
855 | 750 | {
|
856 | | - EnterCriticalSection(&This->commandcs);
|
857 | | - glRenderer_AddQueue(This, OP_SETTEXTURE, 0, 6, 2, 4, &dwStage, 4, &Texture);
|
858 | | - LeaveCriticalSection(&This->commandcs);
|
| 751 | + EnterCriticalSection(&This->cs);
|
| 752 | + This->inputs[0] = (void*)dwStage;
|
| 753 | + This->inputs[1] = Texture;
|
| 754 | + This->opcode = OP_SETTEXTURE;
|
| 755 | + SetEvent(This->start);
|
| 756 | + WaitForSingleObject(This->busy, INFINITE);
|
| 757 | + LeaveCriticalSection(&This->cs);
|
859 | 758 | }
|
860 | 759 |
|
861 | 760 | /**
|
— | — | @@ -870,9 +769,14 @@ |
871 | 770 | */
|
872 | 771 | void glRenderer_SetTextureStageState(glRenderer *This, DWORD dwStage, D3DTEXTURESTAGESTATETYPE dwState, DWORD dwValue)
|
873 | 772 | {
|
874 | | - EnterCriticalSection(&This->commandcs);
|
875 | | - glRenderer_AddQueue(This, OP_SETTEXTURESTAGESTATE, 0, 8, 3, 4, &dwStage, 4, &dwState, 4, &dwValue);
|
876 | | - LeaveCriticalSection(&This->commandcs);
|
| 773 | + EnterCriticalSection(&This->cs);
|
| 774 | + This->inputs[0] = (void*)dwStage;
|
| 775 | + This->inputs[1] = (void*)dwState;
|
| 776 | + This->inputs[2] = (void*)dwValue;
|
| 777 | + This->opcode = OP_SETTEXTURESTAGESTATE;
|
| 778 | + SetEvent(This->start);
|
| 779 | + WaitForSingleObject(This->busy, INFINITE);
|
| 780 | + LeaveCriticalSection(&This->cs);
|
877 | 781 | }
|
878 | 782 |
|
879 | 783 | /**
|
— | — | @@ -886,11 +790,13 @@ |
887 | 791 | */
|
888 | 792 | void glRenderer_SetTransform(glRenderer *This, D3DTRANSFORMSTATETYPE dtstTransformStateType, LPD3DMATRIX lpD3DMatrix)
|
889 | 793 | {
|
890 | | - EnterCriticalSection(&This->commandcs);
|
891 | | - if (!This->running) memcpy(&This->transform[dtstTransformStateType], lpD3DMatrix, sizeof(D3DMATRIX));
|
892 | | - else glRenderer_AddQueue(This, OP_SETTRANSFORM, 0, 5 + (sizeof(D3DMATRIX) / 4), 2,
|
893 | | - 4, &dtstTransformStateType, sizeof(D3DMATRIX), lpD3DMatrix);
|
894 | | - LeaveCriticalSection(&This->commandcs);
|
| 794 | + EnterCriticalSection(&This->cs);
|
| 795 | + This->inputs[0] = (void*)dtstTransformStateType;
|
| 796 | + This->inputs[1] = lpD3DMatrix;
|
| 797 | + This->opcode = OP_SETTRANSFORM;
|
| 798 | + SetEvent(This->start);
|
| 799 | + WaitForSingleObject(This->busy, INFINITE);
|
| 800 | + LeaveCriticalSection(&This->cs);
|
895 | 801 | }
|
896 | 802 |
|
897 | 803 | /**
|
— | — | @@ -902,11 +808,12 @@ |
903 | 809 | */
|
904 | 810 | void glRenderer_SetMaterial(glRenderer *This, LPD3DMATERIAL7 lpMaterial)
|
905 | 811 | {
|
906 | | - EnterCriticalSection(&This->commandcs);
|
907 | | - if (!This->running) memcpy(&This->material, lpMaterial, sizeof(D3DMATERIAL7));
|
908 | | - glRenderer_AddQueue(This, OP_SETMATERIAL, 0, 3 + (sizeof(D3DMATERIAL7) / 4), 1,
|
909 | | - sizeof(D3DMATERIAL7), lpMaterial);
|
910 | | - LeaveCriticalSection(&This->commandcs);
|
| 812 | + EnterCriticalSection(&This->cs);
|
| 813 | + This->inputs[0] = lpMaterial;
|
| 814 | + This->opcode = OP_SETMATERIAL;
|
| 815 | + SetEvent(This->start);
|
| 816 | + WaitForSingleObject(This->busy, INFINITE);
|
| 817 | + LeaveCriticalSection(&This->cs);
|
911 | 818 | }
|
912 | 819 |
|
913 | 820 | /**
|
— | — | @@ -923,15 +830,14 @@ |
924 | 831 |
|
925 | 832 | void glRenderer_SetLight(glRenderer *This, DWORD index, LPD3DLIGHT7 light, BOOL remove)
|
926 | 833 | {
|
927 | | - EnterCriticalSection(&This->commandcs);
|
928 | | - D3DLIGHT7 null_light;
|
929 | | - D3DLIGHT7 *light7;
|
930 | | - DWORD _remove = remove;
|
931 | | - if (light) light7 = light;
|
932 | | - else light7 = &null_light;
|
933 | | - glRenderer_AddQueue(This, OP_SETLIGHT, 0, 7 + (sizeof(D3DLIGHT7) / 4), 3, 4, &index,
|
934 | | - 4, &_remove, sizeof(D3DLIGHT7), light7);
|
935 | | - LeaveCriticalSection(&This->commandcs);
|
| 834 | + EnterCriticalSection(&This->cs);
|
| 835 | + This->inputs[0] = (void*)index;
|
| 836 | + This->inputs[1] = light;
|
| 837 | + This->inputs[2] = (void*)remove;
|
| 838 | + This->opcode = OP_SETLIGHT;
|
| 839 | + SetEvent(This->start);
|
| 840 | + WaitForSingleObject(This->busy, INFINITE);
|
| 841 | + LeaveCriticalSection(&This->cs);
|
936 | 842 | }
|
937 | 843 |
|
938 | 844 | /**
|
— | — | @@ -943,10 +849,12 @@ |
944 | 850 | */
|
945 | 851 | void glRenderer_SetViewport(glRenderer *This, LPD3DVIEWPORT7 lpViewport)
|
946 | 852 | {
|
947 | | - EnterCriticalSection(&This->commandcs);
|
948 | | - glRenderer_AddQueue(This, OP_SETVIEWPORT, 0, 3 + (sizeof(D3DVIEWPORT7) / 4), 1,
|
949 | | - sizeof(D3DVIEWPORT7), lpViewport);
|
950 | | - LeaveCriticalSection(&This->commandcs);
|
| 853 | + EnterCriticalSection(&This->cs);
|
| 854 | + This->inputs[0] = lpViewport;
|
| 855 | + This->opcode = OP_SETVIEWPORT;
|
| 856 | + SetEvent(This->start);
|
| 857 | + WaitForSingleObject(This->busy, INFINITE);
|
| 858 | + LeaveCriticalSection(&This->cs);
|
951 | 859 | }
|
952 | 860 |
|
953 | 861 | /**
|
— | — | @@ -956,31 +864,19 @@ |
957 | 865 | * @return
|
958 | 866 | * Returns 0 to signal successful thread termination
|
959 | 867 | */
|
960 | | -DWORD WINAPI glRenderer__Entry(glRenderer *This)
|
| 868 | +DWORD glRenderer__Entry(glRenderer *This)
|
961 | 869 | {
|
962 | 870 | float tmpfloats[16];
|
963 | | - RECT *r1;
|
964 | | - RECT *r2;
|
965 | | - WORD *indexptr;
|
966 | | - DDBLTFX *fxptr;
|
967 | | - glRenderer__InitGL(This, (DWORD)This->inputs[0], (DWORD)This->inputs[1], (DWORD)This->inputs[2],
|
968 | | - (BOOL)This->inputs[3],(DWORD)This->inputs[4], (HWND)This->inputs[5], (glDirectDraw7*)This->inputs[6]);
|
969 | | - This->dead = false;
|
970 | | - This->queue = (LPDWORD)malloc(1048576);
|
971 | | - This->queuesize = 1048576 / sizeof(DWORD);
|
972 | | - This->queuelength = This->queue_read = This->queue_write = This->syncsize = 0;
|
| 871 | + EnterCriticalSection(&This->cs);
|
| 872 | + glRenderer__InitGL(This,(int)This->inputs[0],(int)This->inputs[1],(int)This->inputs[2],
|
| 873 | + (int)This->inputs[3],(unsigned int)This->inputs[4],(HWND)This->inputs[5],
|
| 874 | + (glDirectDraw7*)This->inputs[6]);
|
| 875 | + LeaveCriticalSection(&This->cs);
|
973 | 876 | SetEvent(This->busy);
|
974 | | - This->start = CreateEvent(NULL, TRUE, FALSE, NULL);
|
975 | | - ResetEvent(This->start);
|
976 | | - This->sync = CreateEvent(NULL, TRUE, FALSE, NULL);
|
977 | | -queueloop:
|
978 | | - WaitForSingleObject(&This->start, INFINITE);
|
979 | | - if (This->queuelength)
|
| 877 | + while(1)
|
980 | 878 | {
|
981 | | - EnterCriticalSection(&This->queuecs);
|
982 | | - This->running = TRUE;
|
983 | | - LeaveCriticalSection(&This->queuecs);
|
984 | | - switch (This->queue[This->queue_read])
|
| 879 | + WaitForSingleObject(This->start,INFINITE);
|
| 880 | + switch(This->opcode)
|
985 | 881 | {
|
986 | 882 | case OP_DELETE:
|
987 | 883 | if(This->hRC)
|
— | — | @@ -1021,151 +917,90 @@ |
1022 | 918 | This->hDC = NULL;
|
1023 | 919 | delete This->RenderWnd;
|
1024 | 920 | This->RenderWnd = NULL;
|
1025 | | - This->dead = true;
|
| 921 | + SetEvent(This->busy);
|
| 922 | + return 0;
|
1026 | 923 | break;
|
1027 | | - case OP_NULL:
|
1028 | | - break;
|
1029 | 924 | case OP_SETWND:
|
1030 | | - if (This->queue[This->queue_read + 1] != 16) break;
|
1031 | | - glRenderer__SetWnd(This, (DWORD)This->queue[This->queue_read + 3], (DWORD)This->queue[This->queue_read + 5],
|
1032 | | - (DWORD)This->queue[This->queue_read + 7], (DWORD)This->queue[This->queue_read + 9], (DWORD)This->queue[This->queue_read + 11],
|
1033 | | - (HWND)This->queue[This->queue_read + 13], (BOOL)This->queue[This->queue_read + 15]);
|
| 925 | + glRenderer__SetWnd(This,(int)This->inputs[0],(int)This->inputs[1],(int)This->inputs[2],
|
| 926 | + (int)This->inputs[3],(unsigned int)This->inputs[4],(HWND)This->inputs[5],(BOOL)This->inputs[6]);
|
1034 | 927 | break;
|
1035 | 928 | case OP_CREATE:
|
1036 | | - if (This->queue[This->queue_read + 1] != 8) break;
|
1037 | | - glRenderer__MakeTexture(This, (TEXTURE*)This->queue[This->queue_read + 3],
|
1038 | | - (DWORD)This->queue[This->queue_read + 5], (DWORD)This->queue[This->queue_read + 7]);
|
| 929 | + glRenderer__MakeTexture(This,(TEXTURE*)This->inputs[0],(DWORD)This->inputs[1],(DWORD)This->inputs[2]);
|
| 930 | + SetEvent(This->busy);
|
1039 | 931 | break;
|
1040 | 932 | case OP_UPLOAD:
|
1041 | | - if (This->queue[This->queue_read + 1] != 14) break;
|
1042 | | - glRenderer__UploadTexture(This, (BYTE*)This->queue[This->queue_read + 3], (TEXTURE*)This->queue[This->queue_read + 5],
|
1043 | | - (DWORD)This->queue[This->queue_read + 7], (DWORD)This->queue[This->queue_read + 9],
|
1044 | | - (DWORD)This->queue[This->queue_read + 11], (DWORD)This->queue[This->queue_read + 13]);
|
| 933 | + glRenderer__UploadTexture(This,(char*)This->inputs[0],(char*)This->inputs[1],(TEXTURE*)This->inputs[2],
|
| 934 | + (int)This->inputs[3],(int)This->inputs[4],(int)This->inputs[5],(int)This->inputs[6],
|
| 935 | + (int)This->inputs[7],(int)This->inputs[8],(int)This->inputs[9],(int)This->inputs[10]);
|
| 936 | + SetEvent(This->busy);
|
1045 | 937 | break;
|
1046 | 938 | case OP_DOWNLOAD:
|
1047 | | - if (This->queue[This->queue_read + 1] != 8) break;
|
1048 | | - glRenderer__DownloadTexture(This, (BYTE*)This->queue[This->queue_read + 3],
|
1049 | | - (TEXTURE*)This->queue[This->queue_read + 5], (DWORD)This->queue[This->queue_read + 7]);
|
| 939 | + glRenderer__DownloadTexture(This,(char*)This->inputs[0],(char*)This->inputs[1],(TEXTURE*)This->inputs[2],
|
| 940 | + (int)This->inputs[3],(int)This->inputs[4],(int)This->inputs[5],(int)This->inputs[6],
|
| 941 | + (int)This->inputs[7],(int)This->inputs[8],(int)This->inputs[9],(int)This->inputs[10]);
|
| 942 | + SetEvent(This->busy);
|
1050 | 943 | break;
|
1051 | 944 | case OP_DELETETEX:
|
1052 | | - if (This->queue[This->queue_read + 1] != 4) break;
|
1053 | | - glRenderer__DeleteTexture(This, (TEXTURE*)This->queue[This->queue_read + 3]);
|
| 945 | + glRenderer__DeleteTexture(This,(TEXTURE*)This->inputs[0]);
|
1054 | 946 | break;
|
1055 | 947 | case OP_BLT:
|
1056 | | - if (This->queue[This->queue_read + 1] < (10 + (sizeof(RECT) / 2))) break;
|
1057 | | - r1 = (RECT*)&This->queue[This->queue_read + 3];
|
1058 | | - r2 = (RECT*)&This->queue[This->queue_read + 8 + (sizeof(RECT) / 4)];
|
1059 | | - if (!memcmp(r1, &nullrect, sizeof(RECT))) r1 = NULL;
|
1060 | | - if (!memcmp(r2, &nullrect, sizeof(RECT))) r2 = NULL;
|
1061 | | - if ((This->queue[This->queue_read + 10 + (sizeof(RECT) / 2)]) == 4) fxptr = NULL;
|
1062 | | - else fxptr = (DDBLTFX*)&This->queue[This->queue_read + 11 + (sizeof(RECT) / 2)];
|
1063 | | - glRenderer__Blt(This, r1, (glDirectDrawSurface7*)This->queue[This->queue_read + 4 + (sizeof(RECT) / 4)],
|
1064 | | - (glDirectDrawSurface7*)This->queue[This->queue_read + 6 + (sizeof(RECT) / 4)], r2,
|
1065 | | - (DWORD)This->queue[This->queue_read + 9 + (sizeof(RECT) / 2)], fxptr);
|
| 948 | + glRenderer__Blt(This,(LPRECT)This->inputs[0],(glDirectDrawSurface7*)This->inputs[1],
|
| 949 | + (glDirectDrawSurface7*)This->inputs[2],(LPRECT)This->inputs[3],(DWORD)This->inputs[4],(LPDDBLTFX)This->inputs[5]);
|
1066 | 950 | break;
|
1067 | 951 | case OP_DRAWSCREEN:
|
1068 | | - if (This->queue[This->queue_read + 1] != 12) break;
|
1069 | | - glRenderer__DrawScreen(This, (TEXTURE*)This->queue[This->queue_read + 3], (TEXTURE*)This->queue[This->queue_read + 5],
|
1070 | | - (glDirectDrawSurface7*)This->queue[This->queue_read + 7], (glDirectDrawSurface7*)This->queue[This->queue_read + 9],
|
1071 | | - (GLint)This->queue[This->queue_read + 11]);
|
| 952 | + glRenderer__DrawScreen(This,(TEXTURE*)This->inputs[0],(TEXTURE*)This->inputs[1],
|
| 953 | + (glDirectDrawSurface7*)This->inputs[2],(glDirectDrawSurface7*)This->inputs[3],(GLint)This->inputs[4],true);
|
1072 | 954 | break;
|
1073 | 955 | case OP_INITD3D:
|
1074 | | - if (This->queue[This->queue_read + 1] != 8) break;
|
1075 | | - glRenderer__InitD3D(This,(int)This->queue[This->queue_read+3],(int)This->queue[This->queue_read+5],
|
1076 | | - (int)This->queue[This->queue_read + 7]);
|
| 956 | + glRenderer__InitD3D(This,(int)This->inputs[0],(int)This->inputs[1],(int)This->inputs[2]);
|
1077 | 957 | break;
|
1078 | 958 | case OP_CLEAR:
|
1079 | | - if (This->queue[This->queue_read + 1] < 15) break;
|
1080 | | - if (This->queue[This->queue_read + 14] != 0) r1 = (RECT*)&This->queue[This->queue_read + 15];
|
1081 | | - else r1 = NULL;
|
1082 | | - glRenderer__Clear(This, (glDirectDrawSurface7*)This->queue[This->queue_read + 3], (DWORD)This->queue[This->queue_read + 5],
|
1083 | | - (LPD3DRECT)r1, (DWORD)This->queue[This->queue_read + 7], (DWORD)This->queue[This->queue_read + 9],
|
1084 | | - (D3DVALUE)This->queue[This->queue_read + 11], (DWORD)This->queue[This->queue_read + 13]);
|
| 959 | + memcpy(&tmpfloats[0],&This->inputs[5],4);
|
| 960 | + glRenderer__Clear(This,(glDirectDrawSurface7*)This->inputs[0],(DWORD)This->inputs[1],
|
| 961 | + (LPD3DRECT)This->inputs[2],(DWORD)This->inputs[3],(DWORD)This->inputs[4],tmpfloats[0],(DWORD)This->inputs[6]);
|
1085 | 962 | break;
|
1086 | 963 | case OP_FLUSH:
|
1087 | | - if (This->queue[This->queue_read + 1] != 2) break;
|
1088 | 964 | glRenderer__Flush(This);
|
1089 | 965 | break;
|
1090 | 966 | case OP_DRAWPRIMITIVES:
|
1091 | | - if (This->queue[This->queue_read + 1] < 16) break;
|
1092 | | - if (!This->queue[This->queue_read + 15 + (This->queue[This->queue_read + 14] / 4)]) indexptr = NULL;
|
1093 | | - else indexptr = (WORD*)&This->queue[This->queue_read + 16 + (This->queue[This->queue_read + 14] / 4)];
|
1094 | | - glRenderer__DrawPrimitives(This, (glDirect3DDevice7*)This->queue[This->queue_read + 3], (GLenum)This->queue[This->queue_read+5],
|
1095 | | - (DWORD)This->queue[This->queue_read + 7], (BYTE*)&This->queue[This->queue_read+15], (DWORD)This->queue[This->queue_read + 9],
|
1096 | | - (DWORD)This->queue[This->queue_read + 11], indexptr, (DWORD)This->queue[This->queue_read + 13], 0);
|
| 967 | + glRenderer__DrawPrimitives(This,(glDirect3DDevice7*)This->inputs[0],(GLenum)This->inputs[1],
|
| 968 | + (GLVERTEX*)This->inputs[2],(int*)This->inputs[3],(DWORD)This->inputs[4],(LPWORD)This->inputs[5],
|
| 969 | + (DWORD)This->inputs[6],(DWORD)This->inputs[7]);
|
1097 | 970 | break;
|
1098 | 971 | case OP_DELETEFBO:
|
1099 | | - if (This->queue[This->queue_read + 1] != 4) break;
|
1100 | | - glRenderer__DeleteFBO(This, (FBO*)This->queue[This->queue_read + 3]);
|
| 972 | + glRenderer__DeleteFBO(This,(FBO*)This->inputs[0]);
|
1101 | 973 | break;
|
1102 | 974 | case OP_UPDATECLIPPER:
|
1103 | | - if (This->queue[This->queue_read + 1] != 4) break;
|
1104 | | - glRenderer__UpdateClipper(This, (glDirectDrawSurface7*)This->queue[This->queue_read + 3]);
|
| 975 | + glRenderer__UpdateClipper(This,(glDirectDrawSurface7*)This->inputs[0]);
|
1105 | 976 | break;
|
1106 | 977 | case OP_DEPTHFILL:
|
1107 | | - if (This->queue[This->queue_read + 1] != (6 + (sizeof(RECT) / 4) + (sizeof(DDBLTFX) / 4))) break;
|
1108 | | - r1 = (RECT*)&This->queue[This->queue_read + 5];
|
1109 | | - if (!memcmp(r1, &nullrect, sizeof(RECT))) r1 = NULL;
|
1110 | | - glRenderer__DepthFill(This, r1, (glDirectDrawSurface7*)This->queue[This->queue_read + 3],
|
1111 | | - (LPDDBLTFX)&This->queue[This->queue_read + 6 + (sizeof(RECT) / 4)]);
|
| 978 | + glRenderer__DepthFill(This, (LPRECT)This->inputs[0], (glDirectDrawSurface7*)This->inputs[1],
|
| 979 | + (LPDDBLTFX)This->inputs[2]);
|
1112 | 980 | break;
|
1113 | 981 | case OP_SETRENDERSTATE:
|
1114 | | - if (This->queue[This->queue_read + 1] != 6) break;
|
1115 | | - glRenderer__SetRenderState(This, (D3DRENDERSTATETYPE)This->queue[This->queue_read + 3],
|
1116 | | - (DWORD)This->queue[This->queue_read + 5]);
|
| 982 | + glRenderer__SetRenderState(This, (D3DRENDERSTATETYPE)(DWORD)This->inputs[0], (DWORD)This->inputs[1]);
|
1117 | 983 | break;
|
1118 | 984 | case OP_SETTEXTURE:
|
1119 | | - if (This->queue[This->queue_read + 1] != 6) break;
|
1120 | | - glRenderer__SetTexture(This, (DWORD)This->queue[This->queue_read + 3],
|
1121 | | - (glDirectDrawSurface7*)This->queue[This->queue_read + 5]);
|
| 985 | + glRenderer__SetTexture(This, (DWORD)This->inputs[0], (glDirectDrawSurface7*)This->inputs[1]);
|
1122 | 986 | break;
|
1123 | 987 | case OP_SETTEXTURESTAGESTATE:
|
1124 | | - if (This->queue[This->queue_read + 1] != 8) break;
|
1125 | | - glRenderer__SetTextureStageState(This, (DWORD)This->queue[This->queue_read + 3],
|
1126 | | - (D3DTEXTURESTAGESTATETYPE)This->queue[This->queue_read + 5], (DWORD)This->queue[This->queue_read + 7]);
|
| 988 | + glRenderer__SetTextureStageState(This, (DWORD)This->inputs[0], (D3DTEXTURESTAGESTATETYPE)(DWORD)This->inputs[1],
|
| 989 | + (DWORD)This->inputs[2]);
|
1127 | 990 | break;
|
1128 | 991 | case OP_SETTRANSFORM:
|
1129 | | - if (This->queue[This->queue_read + 1] != (5 + (sizeof(D3DMATRIX) / 4))) break;
|
1130 | | - glRenderer__SetTransform(This, (D3DTRANSFORMSTATETYPE)This->queue[This->queue_read + 3],
|
1131 | | - (LPD3DMATRIX)&This->queue[This->queue_read + 5]);
|
| 992 | + glRenderer__SetTransform(This, (D3DTRANSFORMSTATETYPE)(DWORD)This->inputs[0], (LPD3DMATRIX)This->inputs[1]);
|
1132 | 993 | break;
|
1133 | 994 | case OP_SETMATERIAL:
|
1134 | | - if (This->queue[This->queue_read + 1] != (3 + (sizeof(D3DMATERIAL7) / 4))) break;
|
1135 | | - glRenderer__SetMaterial(This, (LPD3DMATERIAL7)&This->queue[This->queue_read + 3]);
|
| 995 | + glRenderer__SetMaterial(This, (LPD3DMATERIAL7)This->inputs[0]);
|
1136 | 996 | break;
|
1137 | 997 | case OP_SETLIGHT:
|
1138 | | - if (This->queue[This->queue_read + 1] != (7 + (sizeof(D3DLIGHT7) / 4))) break;
|
1139 | | - glRenderer__SetLight(This, (DWORD)This->queue[This->queue_read + 3], (LPD3DLIGHT7)&This->queue[This->queue_read + 7],
|
1140 | | - (BOOL)This->queue[This->queue_read + 5]);
|
| 998 | + glRenderer__SetLight(This, (DWORD)This->inputs[0], (LPD3DLIGHT7)This->inputs[1], (BOOL)This->inputs[2]);
|
1141 | 999 | break;
|
1142 | 1000 | case OP_SETVIEWPORT:
|
1143 | | - if (This->queue[This->queue_read + 1] != (3 + (sizeof(D3DVIEWPORT7) / 4))) break;
|
1144 | | - glRenderer__SetViewport(This, (LPD3DVIEWPORT7)&This->queue[This->queue_read + 3]);
|
| 1001 | + glRenderer__SetViewport(This, (LPD3DVIEWPORT7)This->inputs[0]);
|
1145 | 1002 | break;
|
1146 | | - case OP_RESETQUEUE:
|
1147 | | - break;
|
1148 | | - default:
|
1149 | | - FIXME("Invalid opcode detected");
|
1150 | | - break;
|
1151 | 1003 | }
|
1152 | | - EnterCriticalSection(&This->queuecs);
|
1153 | | - This->queuelength--;
|
1154 | | - This->queue_read += This->queue[This->queue_read + 1];
|
1155 | | - if ((This->queue_read >= This->syncsize) && This->syncsize != 0) SetEvent(This->sync);
|
1156 | 1004 | }
|
1157 | | - else EnterCriticalSection(&This->queuecs);
|
1158 | | - if (!This->queuelength)
|
1159 | | - {
|
1160 | | - ResetEvent(This->start);
|
1161 | | - This->queue_read = 0;
|
1162 | | - This->queue_write = 0;
|
1163 | | - This->running = false;
|
1164 | | - SetEvent(This->sync);
|
1165 | | - }
|
1166 | | - LeaveCriticalSection(&This->queuecs);
|
1167 | | - if (!This->dead) goto queueloop;
|
1168 | | - free(This->queue);
|
1169 | | - This->queue = NULL;
|
1170 | 1005 | return 0;
|
1171 | 1006 | }
|
1172 | 1007 |
|
— | — | @@ -1187,7 +1022,7 @@ |
1188 | 1023 | * @return
|
1189 | 1024 | * TRUE if OpenGL has been initialized, FALSE otherwise.
|
1190 | 1025 | */
|
1191 | | -BOOL glRenderer__InitGL(glRenderer *This, DWORD width, DWORD height, DWORD bpp, BOOL fullscreen, DWORD frequency, HWND hWnd, glDirectDraw7 *glDD7)
|
| 1026 | +BOOL glRenderer__InitGL(glRenderer *This, int width, int height, int bpp, int fullscreen, unsigned int frequency, HWND hWnd, glDirectDraw7 *glDD7)
|
1192 | 1027 | {
|
1193 | 1028 | EnterCriticalSection(&dll_cs);
|
1194 | 1029 | This->ddInterface = glDD7;
|
— | — | @@ -1684,7 +1519,9 @@ |
1685 | 1520 | (ddsd.ddsCaps.dwCaps & DDSCAPS_PRIMARYSURFACE)) ||
|
1686 | 1521 | ((ddsd.ddsCaps.dwCaps & DDSCAPS_PRIMARYSURFACE) &&
|
1687 | 1522 | !(ddsd.ddsCaps.dwCaps & DDSCAPS_FLIP)))
|
1688 | | - glRenderer__DrawScreen(This,dest->texture,dest->paltex,dest,dest,0);
|
| 1523 | + glRenderer__DrawScreen(This,dest->texture,dest->paltex,dest,dest,0,false);
|
| 1524 | + This->outputs[0] = DD_OK;
|
| 1525 | + SetEvent(This->busy);
|
1689 | 1526 | }
|
1690 | 1527 |
|
1691 | 1528 | void glRenderer__MakeTexture(glRenderer *This, TEXTURE *texture, DWORD width, DWORD height)
|
— | — | @@ -1799,7 +1636,7 @@ |
1800 | 1637 | This->util->SetFBO((FBO*)NULL);
|
1801 | 1638 | }
|
1802 | 1639 |
|
1803 | | -void glRenderer__DrawScreen(glRenderer *This, TEXTURE *texture, TEXTURE *paltex, glDirectDrawSurface7 *dest, glDirectDrawSurface7 *src, GLint vsync)
|
| 1640 | +void glRenderer__DrawScreen(glRenderer *This, TEXTURE *texture, TEXTURE *paltex, glDirectDrawSurface7 *dest, glDirectDrawSurface7 *src, GLint vsync, bool setsync)
|
1804 | 1641 | {
|
1805 | 1642 | int progtype;
|
1806 | 1643 | RECT r,r2;
|
— | — | @@ -1819,7 +1656,7 @@ |
1820 | 1657 | GLint viewport[4];
|
1821 | 1658 | if(src->dirty & 1)
|
1822 | 1659 | {
|
1823 | | - glRenderer__UploadTextureSurface(This,src->buffer,src->bigbuffer,texture,src->ddsd.dwWidth,src->ddsd.dwHeight,
|
| 1660 | + glRenderer__UploadTexture(This,src->buffer,src->bigbuffer,texture,src->ddsd.dwWidth,src->ddsd.dwHeight,
|
1824 | 1661 | src->fakex,src->fakey,src->ddsd.lPitch,
|
1825 | 1662 | (NextMultipleOf4((This->ddInterface->GetBPPMultipleOf8()/8)*src->fakex)),
|
1826 | 1663 | src->ddsd.ddpfPixelFormat.dwRGBBitCount,src->miplevel);
|
— | — | @@ -1950,11 +1787,14 @@ |
1951 | 1788 | SelectObject(This->dib.hdc,hPrevObj);
|
1952 | 1789 | ReleaseDC(This->RenderWnd->GetHWnd(),hRenderDC);
|
1953 | 1790 | }
|
| 1791 | + if(setsync) SetEvent(This->busy);
|
| 1792 | +
|
1954 | 1793 | }
|
1955 | 1794 |
|
1956 | 1795 | void glRenderer__DeleteTexture(glRenderer *This, TEXTURE *texture)
|
1957 | 1796 | {
|
1958 | 1797 | TextureManager__DeleteTexture(This->texman,texture);
|
| 1798 | + SetEvent(This->busy);
|
1959 | 1799 | }
|
1960 | 1800 |
|
1961 | 1801 | __int64 InitShaderState(glRenderer *renderer, DWORD *renderstate, TEXTURESTAGE *texstages, D3DLIGHT7 *lights)
|
— | — | @@ -2053,6 +1893,7 @@ |
2054 | 1894 |
|
2055 | 1895 | void glRenderer__InitD3D(glRenderer *This, int zbuffer, int x, int y)
|
2056 | 1896 | {
|
| 1897 | + SetEvent(This->busy);
|
2057 | 1898 | glHint(GL_PERSPECTIVE_CORRECTION_HINT,GL_NICEST);
|
2058 | 1899 | GLfloat ambient[] = {0.0,0.0,0.0,0.0};
|
2059 | 1900 | if(zbuffer) This->util->DepthTest(true);
|
— | — | @@ -2083,6 +1924,7 @@ |
2084 | 1925 |
|
2085 | 1926 | void glRenderer__Clear(glRenderer *This, glDirectDrawSurface7 *target, DWORD dwCount, LPD3DRECT lpRects, DWORD dwFlags, DWORD dwColor, D3DVALUE dvZ, DWORD dwStencil)
|
2086 | 1927 | {
|
| 1928 | + This->outputs[0] = (void*)D3D_OK;
|
2087 | 1929 | GLfloat color[4];
|
2088 | 1930 | dwordto4float(dwColor,color);
|
2089 | 1931 | do
|
— | — | @@ -2123,14 +1965,16 @@ |
2124 | 1966 | else glClear(clearbits);
|
2125 | 1967 | if(target->zbuffer) target->zbuffer->dirty |= 2;
|
2126 | 1968 | target->dirty |= 2;
|
| 1969 | + SetEvent(This->busy);
|
2127 | 1970 | }
|
2128 | 1971 |
|
2129 | 1972 | void glRenderer__Flush(glRenderer *This)
|
2130 | 1973 | {
|
2131 | 1974 | glFlush();
|
| 1975 | + SetEvent(This->busy);
|
2132 | 1976 | }
|
2133 | 1977 |
|
2134 | | -void glRenderer__SetWnd(glRenderer *This, DWORD width, DWORD height, DWORD fullscreen, DWORD bpp, DWORD frequency, HWND newwnd, BOOL devwnd)
|
| 1978 | +void glRenderer__SetWnd(glRenderer *This, int width, int height, int bpp, int fullscreen, unsigned int frequency, HWND newwnd, BOOL devwnd)
|
2135 | 1979 | {
|
2136 | 1980 | if(newwnd != This->hWnd)
|
2137 | 1981 | {
|
— | — | @@ -2168,6 +2012,8 @@ |
2169 | 2013 | glRenderer__SetSwap(This,0);
|
2170 | 2014 | This->util->SetViewport(0,0,width,height);
|
2171 | 2015 | }
|
| 2016 | +
|
| 2017 | + SetEvent(This->busy);
|
2172 | 2018 | }
|
2173 | 2019 |
|
2174 | 2020 | void glRenderer__SetBlend(glRenderer *This, DWORD src, DWORD dest)
|
— | — | @@ -2272,7 +2118,7 @@ |
2273 | 2119 | This->util->BlendFunc(glsrc,gldest);
|
2274 | 2120 | }
|
2275 | 2121 |
|
2276 | | -void glRenderer__DrawPrimitives(glRenderer *This, glDirect3DDevice7 *device, GLenum mode, DWORD stride, BYTE *vertices, DWORD dwVertexTypeDesc, DWORD count, LPWORD indices,
|
| 2122 | +void glRenderer__DrawPrimitives(glRenderer *This, glDirect3DDevice7 *device, GLenum mode, GLVERTEX *vertices, int *texformats, DWORD count, LPWORD indices,
|
2277 | 2123 | DWORD indexcount, DWORD flags)
|
2278 | 2124 | {
|
2279 | 2125 | bool transformed;
|
— | — | @@ -2281,140 +2127,113 @@ |
2282 | 2128 | char strvar[] = "strX";
|
2283 | 2129 | char strqvar[] = "strqX";
|
2284 | 2130 | int i;
|
2285 | | - int ptr = 0;
|
2286 | | - int numtex;
|
2287 | | - int texcoords[8];
|
2288 | | - if ((dwVertexTypeDesc & D3DFVF_POSITION_MASK) == D3DFVF_XYZRHW) transformed = true;
|
| 2131 | + if(vertices[1].data) transformed = true;
|
2289 | 2132 | else transformed = false;
|
2290 | | - This->shaderstate3d.stateid &= 0xFFFA3FFC7FFFFFFFi64;
|
| 2133 | + if(!vertices[0].data)
|
| 2134 | + {
|
| 2135 | + This->outputs[0] = (void*)DDERR_INVALIDPARAMS;
|
| 2136 | + SetEvent(This->busy);
|
| 2137 | + return;
|
| 2138 | + }
|
2291 | 2139 | This->shaderstate3d.stateid &= 0xFFFA3FF87FFFFFFFi64;
|
2292 | | - int numtextures = (dwVertexTypeDesc & D3DFVF_TEXCOUNT_MASK) >> D3DFVF_TEXCOUNT_SHIFT;
|
| 2140 | + int numtextures = 0;
|
| 2141 | + for (i = 0; i < 8; i++)
|
| 2142 | + {
|
| 2143 | + This->shaderstate3d.texstageid[i] &= 0xFFE7FFFFFFFFFFFFi64;
|
| 2144 | + This->shaderstate3d.texstageid[i] |= (__int64)(texformats[i] - 1) << 51;
|
| 2145 | + if (vertices[i + 10].data) numtextures++;
|
| 2146 | + }
|
2293 | 2147 | This->shaderstate3d.stateid |= (__int64)((numtextures-1)&7) << 31;
|
2294 | 2148 | if (numtextures) This->shaderstate3d.stateid |= (1i64 << 34);
|
2295 | 2149 | int blendweights = 0;
|
2296 | | - if (((dwVertexTypeDesc & D3DFVF_POSITION_MASK) >> 1) > 2)
|
2297 | | - blendweights = ((dwVertexTypeDesc & D3DFVF_POSITION_MASK) >> 1) - 2;
|
| 2150 | + for (i = 0; i < 5; i++)
|
| 2151 | + if (vertices[i + 2].data) blendweights++;
|
2298 | 2152 | This->shaderstate3d.stateid |= (__int64)blendweights << 46;
|
2299 | | - if (transformed) This->shaderstate3d.stateid |= (1i64 << 50);
|
2300 | | - if (dwVertexTypeDesc & D3DFVF_DIFFUSE) This->shaderstate3d.stateid |= (1i64 << 35);
|
2301 | | - if (dwVertexTypeDesc & D3DFVF_SPECULAR) This->shaderstate3d.stateid |= (1i64 << 36);
|
2302 | | - if (dwVertexTypeDesc & D3DFVF_NORMAL) This->shaderstate3d.stateid |= (1i64 << 37);
|
2303 | | - numtex = (dwVertexTypeDesc & D3DFVF_TEXCOUNT_MASK) >> D3DFVF_TEXCOUNT_SHIFT;
|
2304 | | - for(i = 0; i < numtex; i++)
|
2305 | | - {
|
2306 | | - This->shaderstate3d.texstageid[i] &= 0xFFE7FFFFFFFFFFFFi64;
|
2307 | | - switch (dwVertexTypeDesc >> (16 + (2 * i)) & 3)
|
2308 | | - {
|
2309 | | - case 0: // st
|
2310 | | - texcoords[i] = 2;
|
2311 | | - break;
|
2312 | | - case 1: // str
|
2313 | | - texcoords[i] = 3;
|
2314 | | - break;
|
2315 | | - case 2: // strq
|
2316 | | - texcoords[i] = 4;
|
2317 | | - break;
|
2318 | | - case 3: // s
|
2319 | | - texcoords[i] = 1;
|
2320 | | - break;
|
2321 | | - }
|
2322 | | - This->shaderstate3d.texstageid[i] |= (__int64)(texcoords[i] - 1) << 51;
|
2323 | | - }
|
2324 | | - ShaderManager_SetShader(This->shaders, This->shaderstate3d.stateid, This->shaderstate3d.texstageid, 2);
|
2325 | | - _GENSHADER *prog = &This->shaders->gen3d->genshaders[This->shaders->gen3d->current_genshader].shader;
|
2326 | | - This->util->EnableArray(prog->attribs[0], true);
|
2327 | | - This->ext->glVertexAttribPointer(prog->attribs[0], 3, GL_FLOAT, false, stride, &vertices[ptr]);
|
2328 | | - ptr += 12;
|
2329 | | - if (transformed)
|
2330 | | - {
|
2331 | | - if (prog->attribs[1] != -1)
|
2332 | | - {
|
2333 | | - This->util->EnableArray(prog->attribs[1], true);
|
2334 | | - This->ext->glVertexAttribPointer(prog->attribs[1], 4, GL_FLOAT, false, stride, &vertices[ptr]);
|
2335 | | - }
|
2336 | | - ptr += 4;
|
2337 | | - }
|
2338 | | - else if (dwVertexTypeDesc & D3DFVF_RESERVED1) ptr += 4;
|
| 2153 | + if (vertices[1].data) This->shaderstate3d.stateid |= (1i64 << 50);
|
| 2154 | + if (vertices[8].data) This->shaderstate3d.stateid |= (1i64 << 35);
|
| 2155 | + if (vertices[9].data) This->shaderstate3d.stateid |= (1i64 << 36);
|
| 2156 | + if (vertices[7].data) This->shaderstate3d.stateid |= (1i64 << 37);
|
| 2157 | + ShaderManager_SetShader(This->shaders,This->shaderstate3d.stateid,This->shaderstate3d.texstageid,2);
|
2339 | 2158 | glRenderer__SetDepthComp(This);
|
2340 | 2159 | if(This->renderstate[D3DRENDERSTATE_ZENABLE]) This->util->DepthTest(true);
|
2341 | 2160 | else This->util->DepthTest(false);
|
2342 | 2161 | if(This->renderstate[D3DRENDERSTATE_ZWRITEENABLE]) This->util->DepthWrite(true);
|
2343 | 2162 | else This->util->DepthWrite(false);
|
2344 | | - for(i = 0; i < blendweights; i++)
|
| 2163 | + _GENSHADER *prog = &This->shaders->gen3d->genshaders[This->shaders->gen3d->current_genshader].shader;
|
| 2164 | + This->util->EnableArray(prog->attribs[0],true);
|
| 2165 | + This->ext->glVertexAttribPointer(prog->attribs[0],3,GL_FLOAT,false,vertices[0].stride,vertices[0].data);
|
| 2166 | + if(transformed)
|
2345 | 2167 | {
|
2346 | | - if(prog->attribs[i+2] != -1)
|
| 2168 | + if(prog->attribs[1] != -1)
|
2347 | 2169 | {
|
2348 | | - This->util->EnableArray(prog->attribs[i+2],true);
|
2349 | | - This->ext->glVertexAttribPointer(prog->attribs[i + 2], 1, GL_FLOAT, false, stride, &vertices[ptr]);
|
| 2170 | + This->util->EnableArray(prog->attribs[1],true);
|
| 2171 | + This->ext->glVertexAttribPointer(prog->attribs[1],4,GL_FLOAT,false,vertices[1].stride,vertices[1].data);
|
2350 | 2172 | }
|
2351 | | - ptr += 4;
|
2352 | 2173 | }
|
2353 | | - if (dwVertexTypeDesc & D3DFVF_NORMAL)
|
| 2174 | + for(i = 0; i < 5; i++)
|
2354 | 2175 | {
|
2355 | | - if(prog->attribs[7] != -1)
|
| 2176 | + if(vertices[i+2].data)
|
2356 | 2177 | {
|
2357 | | - This->util->EnableArray(prog->attribs[7],true);
|
2358 | | - This->ext->glVertexAttribPointer(prog->attribs[7], 3, GL_FLOAT, false, stride, &vertices[ptr]);
|
| 2178 | + if(prog->attribs[i+2] != -1)
|
| 2179 | + {
|
| 2180 | + This->util->EnableArray(prog->attribs[i+2],true);
|
| 2181 | + This->ext->glVertexAttribPointer(prog->attribs[i+2],1,GL_FLOAT,false,vertices[i+2].stride,vertices[i+2].data);
|
| 2182 | + }
|
2359 | 2183 | }
|
2360 | | - ptr += 12;
|
2361 | 2184 | }
|
2362 | | - if (dwVertexTypeDesc & D3DFVF_DIFFUSE)
|
| 2185 | + if(vertices[7].data)
|
2363 | 2186 | {
|
2364 | | - if (prog->attribs[8] != -1)
|
| 2187 | + if(prog->attribs[7] != -1)
|
2365 | 2188 | {
|
2366 | | - This->util->EnableArray(prog->attribs[8], true);
|
2367 | | - This->ext->glVertexAttribPointer(prog->attribs[8], 4, GL_UNSIGNED_BYTE, true, stride, &vertices[ptr]);
|
| 2189 | + This->util->EnableArray(prog->attribs[7],true);
|
| 2190 | + This->ext->glVertexAttribPointer(prog->attribs[7],3,GL_FLOAT,false,vertices[7].stride,vertices[7].data);
|
2368 | 2191 | }
|
2369 | | - ptr += 4;
|
2370 | 2192 | }
|
2371 | | - if (dwVertexTypeDesc & D3DFVF_SPECULAR)
|
| 2193 | + for(i = 0; i < 2; i++)
|
2372 | 2194 | {
|
2373 | | - if (prog->attribs[9] != -1)
|
| 2195 | + if(vertices[i+8].data)
|
2374 | 2196 | {
|
2375 | | - This->util->EnableArray(prog->attribs[9], true);
|
2376 | | - This->ext->glVertexAttribPointer(prog->attribs[9], 4, GL_UNSIGNED_BYTE, true, stride, &vertices[ptr]);
|
| 2197 | + if(prog->attribs[8+i] != -1)
|
| 2198 | + {
|
| 2199 | + This->util->EnableArray(prog->attribs[8+i],true);
|
| 2200 | + This->ext->glVertexAttribPointer(prog->attribs[8+i],4,GL_UNSIGNED_BYTE,true,vertices[i+8].stride,vertices[i+8].data);
|
| 2201 | + }
|
2377 | 2202 | }
|
2378 | | - ptr += 4;
|
2379 | 2203 | }
|
2380 | | - for(i = 0; i < numtex; i++)
|
| 2204 | + for(i = 0; i < 8; i++)
|
2381 | 2205 | {
|
2382 | 2206 | {
|
2383 | | - switch(texcoords[i])
|
| 2207 | + switch(texformats[i])
|
2384 | 2208 | {
|
2385 | 2209 | case -1: // Null
|
2386 | | - default:
|
2387 | 2210 | break;
|
2388 | 2211 | case 1: // s
|
2389 | 2212 | if (prog->attribs[i + 10] != -1)
|
2390 | 2213 | {
|
2391 | 2214 | This->util->EnableArray(prog->attribs[i + 10], true);
|
2392 | | - This->ext->glVertexAttribPointer(prog->attribs[i + 10], 1, GL_FLOAT, false, stride, &vertices[ptr]);
|
| 2215 | + This->ext->glVertexAttribPointer(prog->attribs[i + 10], 1, GL_FLOAT, false, vertices[i + 10].stride, vertices[i + 10].data);
|
2393 | 2216 | }
|
2394 | | - ptr += 4;
|
2395 | 2217 | break;
|
2396 | 2218 | case 2: // st
|
2397 | 2219 | if(prog->attribs[i+18] != -1)
|
2398 | 2220 | {
|
2399 | 2221 | This->util->EnableArray(prog->attribs[i+18],true);
|
2400 | | - This->ext->glVertexAttribPointer(prog->attribs[i + 18], 2, GL_FLOAT, false, stride, &vertices[ptr]);
|
| 2222 | + This->ext->glVertexAttribPointer(prog->attribs[i+18],2,GL_FLOAT,false,vertices[i+10].stride,vertices[i+10].data);
|
2401 | 2223 | }
|
2402 | | - ptr += 8;
|
2403 | 2224 | break;
|
2404 | 2225 | case 3: // str
|
2405 | 2226 | if(prog->attribs[i+26] != -1)
|
2406 | 2227 | {
|
2407 | 2228 | This->util->EnableArray(prog->attribs[i+26],true);
|
2408 | | - This->ext->glVertexAttribPointer(prog->attribs[i + 26], 3, GL_FLOAT, false, stride, &vertices[ptr]);
|
| 2229 | + This->ext->glVertexAttribPointer(prog->attribs[i+26],3,GL_FLOAT,false,vertices[i+10].stride,vertices[i+10].data);
|
2409 | 2230 | }
|
2410 | | - ptr += 12;
|
2411 | 2231 | break;
|
2412 | 2232 | case 4: // strq
|
2413 | 2233 | if(prog->attribs[i+34] != -1)
|
2414 | 2234 | {
|
2415 | 2235 | This->util->EnableArray(prog->attribs[i+34],true);
|
2416 | | - This->ext->glVertexAttribPointer(prog->attribs[i + 34], 4, GL_FLOAT, false, stride, &vertices[ptr]);
|
| 2236 | + This->ext->glVertexAttribPointer(prog->attribs[i+34],4,GL_FLOAT,false,vertices[i+10].stride,vertices[i+10].data);
|
2417 | 2237 | }
|
2418 | | - ptr += 16;
|
2419 | 2238 | break;
|
2420 | 2239 | }
|
2421 | 2240 |
|
— | — | @@ -2478,7 +2297,7 @@ |
2479 | 2298 | {
|
2480 | 2299 | if(This->texstages[i].texture->dirty & 1)
|
2481 | 2300 | {
|
2482 | | - glRenderer__UploadTextureSurface(This,This->texstages[i].texture->buffer,This->texstages[i].texture->bigbuffer,
|
| 2301 | + glRenderer__UploadTexture(This,This->texstages[i].texture->buffer,This->texstages[i].texture->bigbuffer,
|
2483 | 2302 | This->texstages[i].texture->texture,This->texstages[i].texture->ddsd.dwWidth,
|
2484 | 2303 | This->texstages[i].texture->ddsd.dwHeight,This->texstages[i].texture->fakex,
|
2485 | 2304 | This->texstages[i].texture->fakey,This->texstages[i].texture->ddsd.lPitch,
|
— | — | @@ -2544,6 +2363,8 @@ |
2545 | 2364 | if(device->glDDS7->zbuffer) device->glDDS7->zbuffer->dirty |= 2;
|
2546 | 2365 | device->glDDS7->dirty |= 2;
|
2547 | 2366 | if(flags & D3DDP_WAIT) glFlush();
|
| 2367 | + This->outputs[0] = (void*)D3D_OK;
|
| 2368 | + SetEvent(This->busy);
|
2548 | 2369 | return;
|
2549 | 2370 | }
|
2550 | 2371 |
|
— | — | @@ -2550,6 +2371,7 @@ |
2551 | 2372 | void glRenderer__DeleteFBO(glRenderer *This, FBO *fbo)
|
2552 | 2373 | {
|
2553 | 2374 | This->util->DeleteFBO(fbo);
|
| 2375 | + SetEvent(This->busy);
|
2554 | 2376 | }
|
2555 | 2377 |
|
2556 | 2378 | void glRenderer__UpdateClipper(glRenderer *This, glDirectDrawSurface7 *surface)
|
— | — | @@ -2589,6 +2411,7 @@ |
2590 | 2412 | This->ext->glDrawRangeElements(GL_TRIANGLES, 0, (6 * surface->clipper->clipsize) - 1,
|
2591 | 2413 | 6 * surface->clipper->clipsize, GL_UNSIGNED_SHORT, surface->clipper->indices);
|
2592 | 2414 | This->util->SetFBO((FBO*)NULL);
|
| 2415 | + SetEvent(This->busy);
|
2593 | 2416 | }
|
2594 | 2417 |
|
2595 | 2418 | void glRenderer__DepthFill(glRenderer *This, LPRECT lpDestRect, glDirectDrawSurface7 *dest, LPDDBLTFX lpDDBltFx)
|
— | — | @@ -2648,11 +2471,13 @@ |
2649 | 2472 | This->util->ClearDepth(lpDDBltFx->dwFillDepth / (double)0xFFFF);
|
2650 | 2473 | glClear(GL_DEPTH_BUFFER_BIT);
|
2651 | 2474 | if (lpDestRect)This->util->SetScissor(false, 0, 0, 0, 0);
|
| 2475 | + This->outputs[0] = DD_OK;
|
| 2476 | + SetEvent(This->busy);
|
2652 | 2477 | }
|
2653 | 2478 |
|
2654 | 2479 | void glRenderer__SetRenderState(glRenderer *This, D3DRENDERSTATETYPE dwRendStateType, DWORD dwRenderState)
|
2655 | 2480 | {
|
2656 | | - if (dwRendStateType > 152) return;
|
| 2481 | + SetEvent(This->busy);
|
2657 | 2482 | if (This->renderstate[dwRendStateType] == dwRenderState) return;
|
2658 | 2483 | This->renderstate[dwRendStateType] = dwRenderState;
|
2659 | 2484 | switch (dwRendStateType)
|
— | — | @@ -2755,7 +2580,11 @@ |
2756 | 2581 |
|
2757 | 2582 | void glRenderer__SetTexture(glRenderer *This, DWORD dwStage, glDirectDrawSurface7 *Texture)
|
2758 | 2583 | {
|
2759 | | - if (This->texstages[dwStage].texture == Texture) return;
|
| 2584 | + if (This->texstages[dwStage].texture == Texture)
|
| 2585 | + {
|
| 2586 | + SetEvent(This->busy);
|
| 2587 | + return;
|
| 2588 | + }
|
2760 | 2589 | This->texstages[dwStage].texture = Texture;
|
2761 | 2590 | if (Texture)
|
2762 | 2591 | {
|
— | — | @@ -2764,10 +2593,12 @@ |
2765 | 2594 | else This->shaderstate3d.texstageid[dwStage] &= 0xEFFFFFFFFFFFFFFFi64;
|
2766 | 2595 | }
|
2767 | 2596 | else This->shaderstate3d.texstageid[dwStage] &= 0xE7FFFFFFFFFFFFFFi64;
|
| 2597 | + SetEvent(This->busy);
|
2768 | 2598 | }
|
2769 | 2599 |
|
2770 | 2600 | void glRenderer__SetTextureStageState(glRenderer *This, DWORD dwStage, D3DTEXTURESTAGESTATETYPE dwState, DWORD dwValue)
|
2771 | 2601 | {
|
| 2602 | + SetEvent(This->busy);
|
2772 | 2603 | switch (dwState)
|
2773 | 2604 | {
|
2774 | 2605 | case D3DTSS_COLOROP:
|
— | — | @@ -2963,13 +2794,19 @@ |
2964 | 2795 |
|
2965 | 2796 | void glRenderer__SetTransform(glRenderer *This, D3DTRANSFORMSTATETYPE dtstTransformStateType, LPD3DMATRIX lpD3DMatrix)
|
2966 | 2797 | {
|
2967 | | - if (dtstTransformStateType > 23) return;
|
| 2798 | + if (dtstTransformStateType > 23)
|
| 2799 | + {
|
| 2800 | + SetEvent(This->busy);
|
| 2801 | + return;
|
| 2802 | + }
|
2968 | 2803 | memcpy(&This->transform[dtstTransformStateType], lpD3DMatrix, sizeof(D3DMATRIX));
|
| 2804 | + SetEvent(This->busy);
|
2969 | 2805 | }
|
2970 | 2806 |
|
2971 | 2807 | void glRenderer__SetMaterial(glRenderer *This, LPD3DMATERIAL7 lpMaterial)
|
2972 | 2808 | {
|
2973 | 2809 | memcpy(&This->material, lpMaterial, sizeof(D3DMATERIAL));
|
| 2810 | + SetEvent(This->busy);
|
2974 | 2811 | }
|
2975 | 2812 |
|
2976 | 2813 | void glRenderer__SetLight(glRenderer *This, DWORD index, LPD3DLIGHT7 light, BOOL remove)
|
— | — | @@ -2978,6 +2815,7 @@ |
2979 | 2816 | int lightindex = 0;
|
2980 | 2817 | if(!remove)memcpy(&This->lights[index], light, sizeof(D3DLIGHT7));
|
2981 | 2818 | else ZeroMemory(&This->lights[index], sizeof(D3DLIGHT7));
|
| 2819 | + SetEvent(This->busy);
|
2982 | 2820 | for (int i = 0; i < 8; i++)
|
2983 | 2821 | if (This->lights[i].dltType) numlights++;
|
2984 | 2822 | This->shaderstate3d.stateid &= 0xF807C03FFFE3FFFFi64;
|
— | — | @@ -2999,6 +2837,7 @@ |
3000 | 2838 | void glRenderer__SetViewport(glRenderer *This, LPD3DVIEWPORT7 lpViewport)
|
3001 | 2839 | {
|
3002 | 2840 | memcpy(&This->viewport, lpViewport, sizeof(D3DVIEWPORT7));
|
| 2841 | + SetEvent(This->busy);
|
3003 | 2842 | }
|
3004 | 2843 |
|
3005 | 2844 | void glRenderer__SetFogColor(glRenderer *This, DWORD color)
|
Index: ddraw/glRenderer.h |
— | — | @@ -88,31 +88,32 @@ |
89 | 89 | };
|
90 | 90 |
|
91 | 91 | #define OP_NULL 0
|
92 | | -#define OP_INIT 1
|
93 | | -#define OP_SETWND 2
|
94 | | -#define OP_DELETE 3
|
95 | | -#define OP_CREATE 4
|
96 | | -#define OP_UPLOAD 5
|
97 | | -#define OP_DOWNLOAD 6
|
98 | | -#define OP_DELETETEX 7
|
99 | | -#define OP_BLT 8
|
100 | | -#define OP_DRAWSCREEN 9
|
101 | | -#define OP_INITD3D 10
|
102 | | -#define OP_CLEAR 11
|
103 | | -#define OP_FLUSH 12
|
104 | | -#define OP_DRAWPRIMITIVES 13
|
105 | | -#define OP_DELETEFBO 14
|
106 | | -#define OP_UPDATECLIPPER 15
|
107 | | -#define OP_DEPTHFILL 16
|
108 | | -#define OP_SETRENDERSTATE 17
|
109 | | -#define OP_SETTEXTURE 18
|
110 | | -#define OP_SETTEXTURESTAGESTATE 19
|
111 | | -#define OP_SETTRANSFORM 20
|
112 | | -#define OP_SETMATERIAL 21
|
113 | | -#define OP_SETLIGHT 22
|
114 | | -#define OP_SETVIEWPORT 23
|
| 92 | +#define OP_SETWND 1
|
| 93 | +#define OP_DELETE 2
|
| 94 | +#define OP_CREATE 3
|
| 95 | +#define OP_UPLOAD 4
|
| 96 | +#define OP_DOWNLOAD 5
|
| 97 | +#define OP_DELETETEX 6
|
| 98 | +#define OP_BLT 7
|
| 99 | +#define OP_DRAWSCREEN 8
|
| 100 | +#define OP_INITD3D 9
|
| 101 | +#define OP_CLEAR 10
|
| 102 | +#define OP_FLUSH 11
|
| 103 | +#define OP_DRAWPRIMITIVES 12
|
| 104 | +#define OP_DELETEFBO 13
|
| 105 | +#define OP_UPDATECLIPPER 14
|
| 106 | +#define OP_DEPTHFILL 15
|
| 107 | +#define OP_SETRENDERSTATE 16
|
| 108 | +#define OP_SETTEXTURE 17
|
| 109 | +#define OP_SETTEXTURESTAGESTATE 18
|
| 110 | +#define OP_SETTRANSFORM 19
|
| 111 | +#define OP_SETMATERIAL 20
|
| 112 | +#define OP_SETLIGHT 21
|
| 113 | +#define OP_SETVIEWPORT 22
|
115 | 114 |
|
116 | | -#define OP_RESETQUEUE 0xFFFFFFFF
|
| 115 | +extern const DWORD renderstate_default[153];
|
| 116 | +extern const TEXTURESTAGE texstagedefault0;
|
| 117 | +extern const TEXTURESTAGE texstagedefault1;
|
117 | 118 |
|
118 | 119 | #ifdef __cplusplus
|
119 | 120 | class glDirectDraw7;
|
— | — | @@ -119,6 +120,7 @@ |
120 | 121 | class glDirect3DDevice7;
|
121 | 122 | class glDirectDrawSurface7;
|
122 | 123 | class glRenderWindow;
|
| 124 | +extern "C" {
|
123 | 125 | #else
|
124 | 126 | typedef int glDirectDraw7;
|
125 | 127 | typedef int glDirect3DDevice7;
|
— | — | @@ -126,14 +128,6 @@ |
127 | 129 | typedef int glRenderWindow;
|
128 | 130 | #endif
|
129 | 131 |
|
130 | | -extern const DWORD renderstate_default[153];
|
131 | | -extern const TEXTURESTAGE texstagedefault0;
|
132 | | -extern const TEXTURESTAGE texstagedefault1;
|
133 | | -
|
134 | | -#ifdef __cplusplus
|
135 | | -extern "C" {
|
136 | | -#endif
|
137 | | -
|
138 | 132 | /** @brief glRenderer struct
|
139 | 133 | * OpenGL renderer structure for DXGL.
|
140 | 134 | */
|
— | — | @@ -143,8 +137,9 @@ |
144 | 138 | GLCAPS gl_caps;
|
145 | 139 | glExtensions *ext;
|
146 | 140 | glDirectDraw7 *ddInterface;
|
147 | | - void* inputs[7];
|
148 | | - void *output;
|
| 141 | + int opcode;
|
| 142 | + void* inputs[32];
|
| 143 | + void* outputs[32];
|
149 | 144 | HANDLE hThread;
|
150 | 145 | HDC hDC;
|
151 | 146 | HWND hWnd;
|
— | — | @@ -152,6 +147,9 @@ |
153 | 148 | DIB dib;
|
154 | 149 | FBO fbo;
|
155 | 150 | GLuint PBO;
|
| 151 | + CRITICAL_SECTION cs;
|
| 152 | + HANDLE busy;
|
| 153 | + HANDLE start;
|
156 | 154 | unsigned int frequency;
|
157 | 155 | DXGLTimer timer;
|
158 | 156 | TEXTURE *backbuffer;
|
— | — | @@ -173,27 +171,13 @@ |
174 | 172 | D3DLIGHT7 lights[8];
|
175 | 173 | D3DMATRIX transform[24];
|
176 | 174 | D3DVIEWPORT7 viewport;
|
177 | | - HANDLE busy;
|
178 | | - HANDLE start;
|
179 | | - HANDLE sync;
|
180 | | - BOOL running;
|
181 | | - CRITICAL_SECTION commandcs;
|
182 | | - CRITICAL_SECTION queuecs;
|
183 | | - LPDWORD queue;
|
184 | | - DWORD queuesize;
|
185 | | - DWORD queuelength;
|
186 | | - DWORD queue_read;
|
187 | | - DWORD queue_write;
|
188 | | - DWORD syncsize;
|
189 | | - BOOL dead;
|
190 | 175 | } glRenderer;
|
191 | 176 |
|
192 | | -void glRenderer_Init(glRenderer *This, DWORD width, DWORD height, DWORD bpp, BOOL fullscreen, DWORD frequency, HWND hwnd, glDirectDraw7 *glDD7, BOOL devwnd);
|
| 177 | +void glRenderer_Init(glRenderer *This, int width, int height, int bpp, bool fullscreen, unsigned int frequency, HWND hwnd, glDirectDraw7 *glDD7, BOOL devwnd);
|
193 | 178 | void glRenderer_Delete(glRenderer *This);
|
194 | | -int glRenderer_AddQueue(glRenderer *This, DWORD opcode, int mode, DWORD size, int paramcount, ...);
|
195 | | -void glRenderer_Sync(glRenderer *This, int size);
|
196 | | -void glRenderer_UploadTexture(glRenderer *This, BYTE *buffer, BYTE *bigbuffer, TEXTURE *texture, DWORD x, DWORD y, DWORD bigx, DWORD bigy, DWORD pitch, DWORD bigpitch, DWORD bpp, DWORD miplevel);
|
197 | | -void glRenderer_DownloadTexture(glRenderer *This, BYTE *buffer, BYTE *bigbuffer, TEXTURE *texture, DWORD x, DWORD y, DWORD bigx, DWORD bigy, DWORD pitch, DWORD bigpitch, DWORD bpp, DWORD miplevel);
|
| 179 | +static DWORD WINAPI glRenderer_ThreadEntry(void *entry);
|
| 180 | +void glRenderer_UploadTexture(glRenderer *This, char *buffer, char *bigbuffer, TEXTURE *texture, int x, int y, int bigx, int bigy, int pitch, int bigpitch, int bpp, int miplevel);
|
| 181 | +void glRenderer_DownloadTexture(glRenderer *This, char *buffer, char *bigbuffer, TEXTURE *texture, int x, int y, int bigx, int bigy, int pitch, int bigpitch, int bpp, int miplevel);
|
198 | 182 | HRESULT glRenderer_Blt(glRenderer *This, LPRECT lpDestRect, glDirectDrawSurface7 *src,
|
199 | 183 | glDirectDrawSurface7 *dest, LPRECT lpSrcRect, DWORD dwFlags, LPDDBLTFX lpDDBltFx);
|
200 | 184 | void glRenderer_MakeTexture(glRenderer *This, TEXTURE *texture, DWORD width, DWORD height);
|
— | — | @@ -201,14 +185,14 @@ |
202 | 186 | void glRenderer_DeleteTexture(glRenderer *This, TEXTURE *texture);
|
203 | 187 | void glRenderer_InitD3D(glRenderer *This, int zbuffer, int x, int y);
|
204 | 188 | void glRenderer_Flush(glRenderer *This);
|
205 | | -void glRenderer_SetWnd(glRenderer *This, DWORD width, DWORD height, DWORD bpp, DWORD fullscreen, DWORD frequency, HWND newwnd, BOOL devwnd);
|
206 | | -void glRenderer_Clear(glRenderer *This, glDirectDrawSurface7 *target, DWORD dwCount, LPD3DRECT lpRects, DWORD dwFlags, DWORD dwColor, D3DVALUE dvZ, DWORD dwStencil);
|
207 | | -void glRenderer_DrawPrimitives(glRenderer *This, glDirect3DDevice7 *device, GLenum mode, DWORD stride, BYTE *vertices, DWORD dwVertexTypeDesc, DWORD count, LPWORD indices,
|
| 189 | +void glRenderer_SetWnd(glRenderer *This, int width, int height, int bpp, int fullscreen, unsigned int frequency, HWND newwnd, BOOL devwnd);
|
| 190 | +HRESULT glRenderer_Clear(glRenderer *This, glDirectDrawSurface7 *target, DWORD dwCount, LPD3DRECT lpRects, DWORD dwFlags, DWORD dwColor, D3DVALUE dvZ, DWORD dwStencil);
|
| 191 | +HRESULT glRenderer_DrawPrimitives(glRenderer *This, glDirect3DDevice7 *device, GLenum mode, GLVERTEX *vertices, int *texformats, DWORD count, LPWORD indices,
|
208 | 192 | DWORD indexcount, DWORD flags);
|
209 | 193 | void glRenderer_DeleteFBO(glRenderer *This, FBO *fbo);
|
210 | 194 | void glRenderer_UpdateClipper(glRenderer *This, glDirectDrawSurface7 *surface);
|
211 | 195 | unsigned int glRenderer_GetScanLine(glRenderer *This);
|
212 | | -void glRenderer_DepthFill(glRenderer *This, LPRECT lpDestRect, glDirectDrawSurface7 *dest, LPDDBLTFX lpDDBltFx);
|
| 196 | +HRESULT glRenderer_DepthFill(glRenderer *This, LPRECT lpDestRect, glDirectDrawSurface7 *dest, LPDDBLTFX lpDDBltFx);
|
213 | 197 | void glRenderer_SetRenderState(glRenderer *This, D3DRENDERSTATETYPE dwRendStateType, DWORD dwRenderState);
|
214 | 198 | void glRenderer_SetTexture(glRenderer *This, DWORD dwStage, glDirectDrawSurface7 *Texture);
|
215 | 199 | void glRenderer_SetTextureStageState(glRenderer *This, DWORD dwStage, D3DTEXTURESTAGESTATETYPE dwState, DWORD dwValue);
|
— | — | @@ -217,24 +201,23 @@ |
218 | 202 | void glRenderer_SetLight(glRenderer *This, DWORD index, LPD3DLIGHT7 light, BOOL remove);
|
219 | 203 | void glRenderer_SetViewport(glRenderer *This, LPD3DVIEWPORT7 lpViewport);
|
220 | 204 | // In-thread APIs
|
221 | | -DWORD WINAPI glRenderer__Entry(glRenderer *This);
|
222 | | -BOOL glRenderer__InitGL(glRenderer *This, DWORD width, DWORD height, DWORD bpp, BOOL fullscreen, DWORD frequency, HWND hWnd, glDirectDraw7 *glDD7);
|
223 | | -void glRenderer__UploadTexture(glRenderer *This, BYTE *buffer, TEXTURE *texture, DWORD x, DWORD y, DWORD pitch, DWORD miplevel);
|
224 | | -void glRenderer__UploadTextureSurface(glRenderer *This, BYTE *buffer, BYTE *bigbuffer, TEXTURE *texture, DWORD x, DWORD y, DWORD bigx, DWORD bigy, DWORD pitch, DWORD bigpitch, DWORD bpp, DWORD miplevel);
|
225 | | -void glRenderer__DownloadTexture(glRenderer *This, BYTE *buffer, TEXTURE *texture, DWORD miplevel);
|
| 205 | +DWORD glRenderer__Entry(glRenderer *This);
|
| 206 | +BOOL glRenderer__InitGL(glRenderer *This, int width, int height, int bpp, int fullscreen, unsigned int frequency, HWND hWnd, glDirectDraw7 *glDD7);
|
| 207 | +void glRenderer__UploadTexture(glRenderer *This, char *buffer, char *bigbuffer, TEXTURE *texture, int x, int y, int bigx, int bigy, int pitch, int bigpitch, int bpp, int miplevel);
|
| 208 | +void glRenderer__DownloadTexture(glRenderer *This, char *buffer, char *bigbuffer, TEXTURE *texture, int x, int y, int bigx, int bigy, int pitch, int bigpitch, int bpp, int miplevel);
|
226 | 209 | void glRenderer__Blt(glRenderer *This, LPRECT lpDestRect, glDirectDrawSurface7 *src,
|
227 | 210 | glDirectDrawSurface7 *dest, LPRECT lpSrcRect, DWORD dwFlags, LPDDBLTFX lpDDBltFx);
|
228 | 211 | void glRenderer__MakeTexture(glRenderer *This, TEXTURE *texture, DWORD width, DWORD height);
|
229 | | -void glRenderer__DrawScreen(glRenderer *This, TEXTURE *texture, TEXTURE *paltex, glDirectDrawSurface7 *dest, glDirectDrawSurface7 *src, GLint vsync);
|
| 212 | +void glRenderer__DrawScreen(glRenderer *This, TEXTURE *texture, TEXTURE *paltex, glDirectDrawSurface7 *dest, glDirectDrawSurface7 *src, GLint vsync, bool setsync);
|
230 | 213 | void glRenderer__DeleteTexture(glRenderer *This, TEXTURE *texture);
|
231 | 214 | void glRenderer__DrawBackbuffer(glRenderer *This, TEXTURE **texture, int x, int y, int progtype);
|
232 | 215 | void glRenderer__DrawBackbufferRect(glRenderer *This, TEXTURE *texture, RECT srcrect, int progtype);
|
233 | 216 | void glRenderer__InitD3D(glRenderer *This, int zbuffer, int x, int y);
|
234 | 217 | void glRenderer__Clear(glRenderer *This, glDirectDrawSurface7 *target, DWORD dwCount, LPD3DRECT lpRects, DWORD dwFlags, DWORD dwColor, D3DVALUE dvZ, DWORD dwStencil);
|
235 | | -void glRenderer__DrawPrimitives(glRenderer *This, glDirect3DDevice7 *device, GLenum mode, DWORD stride, BYTE *vertices, DWORD dwVertexTypeDesc, DWORD count, LPWORD indices,
|
| 218 | +void glRenderer__DrawPrimitives(glRenderer *This, glDirect3DDevice7 *device, GLenum mode, GLVERTEX *vertices, int *texcormats, DWORD count, LPWORD indices,
|
236 | 219 | DWORD indexcount, DWORD flags);
|
237 | 220 | void glRenderer__Flush(glRenderer *This);
|
238 | | -void glRenderer__SetWnd(glRenderer *This, DWORD width, DWORD height, DWORD fullscreen, DWORD bpp, DWORD frequency, HWND newwnd, BOOL devwnd);
|
| 221 | +void glRenderer__SetWnd(glRenderer *This, int width, int height, int fullscreen, int bpp, unsigned int frequency, HWND newwnd, BOOL devwnd);
|
239 | 222 | void glRenderer__DeleteFBO(glRenderer *This, FBO *fbo);
|
240 | 223 | void glRenderer__UpdateClipper(glRenderer *This, glDirectDrawSurface7 *surface);
|
241 | 224 | void glRenderer__DepthFill(glRenderer *This, LPRECT lpDestRect, glDirectDrawSurface7 *dest, LPDDBLTFX lpDDBltFx);
|
Index: ddraw/timer.c |
— | — | @@ -28,10 +28,10 @@ |
29 | 29 | QueryPerformanceFrequency(&freq);
|
30 | 30 | if (!freq.QuadPart)
|
31 | 31 | {
|
32 | | - /*timeGetDevCaps(&mmcaps, sizeof(TIMECAPS));
|
| 32 | + timeGetDevCaps(&mmcaps, sizeof(TIMECAPS));
|
33 | 33 | timeBeginPeriod(mmcaps.wPeriodMin);
|
34 | 34 | timer->timer_frequency = ((double) mmcaps.wPeriodMin / 1.0) * 1000.0;
|
35 | | - timer->timertype = 2;*/
|
| 35 | + timer->timertype = 2;
|
36 | 36 | }
|
37 | 37 | else
|
38 | 38 | {
|
— | — | @@ -52,7 +52,7 @@ |
53 | 53 | }
|
54 | 54 | else
|
55 | 55 | {
|
56 | | - //timer->timer_base.QuadPart = timeGetTime();
|
| 56 | + timer->timer_base.QuadPart = timeGetTime();
|
57 | 57 | linesperms = (double) lines / ((1.0 / (double) frequency) * 1000.0);
|
58 | 58 | timer->vsync_lines = (unsigned int)(linesperms * (frequency / 1000.0));
|
59 | 59 | timer->lines = lines + timer->vsync_lines;
|
— | — | @@ -65,7 +65,7 @@ |
66 | 66 | double sync_pos;
|
67 | 67 | double milliseconds;
|
68 | 68 | if (timer->timertype == 1) QueryPerformanceCounter(&timerpos);
|
69 | | - //else timerpos.QuadPart = timeGetTime();
|
| 69 | + else timerpos.QuadPart = timeGetTime();
|
70 | 70 | timerpos.QuadPart -= timer->timer_base.QuadPart;
|
71 | 71 | if (timer->timertype == 1) milliseconds = ((double) timerpos.QuadPart / (double)timer->timer_frequency) * 1000.0;
|
72 | 72 | else milliseconds = (double) timerpos.QuadPart;
|