Index: ddraw/ddraw.vcxproj |
— | — | @@ -278,6 +278,7 @@ |
279 | 279 | <ClInclude Include="glDirect3DViewport.h" />
|
280 | 280 | <ClInclude Include="glDirectDraw.h" />
|
281 | 281 | <ClInclude Include="glDirectDrawClipper.h" />
|
| 282 | + <ClInclude Include="glDirectDrawGammaControl.h" />
|
282 | 283 | <ClInclude Include="glDirectDrawPalette.h" />
|
283 | 284 | <ClInclude Include="glDirectDrawSurface.h" />
|
284 | 285 | <ClInclude Include="glExtensions.h" />
|
— | — | @@ -344,6 +345,7 @@ |
345 | 346 | <ClCompile Include="glDirect3DViewport.cpp" />
|
346 | 347 | <ClCompile Include="glDirectDraw.cpp" />
|
347 | 348 | <ClCompile Include="glDirectDrawClipper.cpp" />
|
| 349 | + <ClCompile Include="glDirectDrawGammaControl.cpp" />
|
348 | 350 | <ClCompile Include="glDirectDrawPalette.c">
|
349 | 351 | <PrecompiledHeader Condition="'$(Configuration)|$(Platform)'=='Debug Trace|Win32'">NotUsing</PrecompiledHeader>
|
350 | 352 | <PrecompiledHeader Condition="'$(Configuration)|$(Platform)'=='Release no DXGL|Win32'">NotUsing</PrecompiledHeader>
|
Index: ddraw/ddraw.vcxproj.filters |
— | — | @@ -140,6 +140,9 @@ |
141 | 141 | <ClInclude Include="ShaderGen2D.h">
|
142 | 142 | <Filter>Header Files</Filter>
|
143 | 143 | </ClInclude>
|
| 144 | + <ClInclude Include="glDirectDrawGammaControl.h">
|
| 145 | + <Filter>Header Files</Filter>
|
| 146 | + </ClInclude>
|
144 | 147 | </ItemGroup>
|
145 | 148 | <ItemGroup>
|
146 | 149 | <ClCompile Include="ddraw.cpp">
|
— | — | @@ -235,6 +238,9 @@ |
236 | 239 | <ClCompile Include="scalers.c">
|
237 | 240 | <Filter>Source Files</Filter>
|
238 | 241 | </ClCompile>
|
| 242 | + <ClCompile Include="glDirectDrawGammaControl.cpp">
|
| 243 | + <Filter>Source Files</Filter>
|
| 244 | + </ClCompile>
|
239 | 245 | </ItemGroup>
|
240 | 246 | <ItemGroup>
|
241 | 247 | <ResourceCompile Include="ddraw.rc">
|
Index: ddraw/glDirectDrawGammaControl.cpp |
— | — | @@ -0,0 +1,90 @@ |
| 2 | +// DXGL
|
| 3 | +// Copyright (C) 2011-2014 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 "TextureManager.h"
|
| 21 | +#include "glUtil.h"
|
| 22 | +#include "glDirectDrawSurface.h"
|
| 23 | +#include "glDirectDrawGammaControl.h"
|
| 24 | +
|
| 25 | +extern "C" {
|
| 26 | +
|
| 27 | +glDirectDrawGammaControlVtbl glDirectDrawGammaControl_iface =
|
| 28 | +{
|
| 29 | + glDirectDrawGammaControl_QueryInterface,
|
| 30 | + glDirectDrawGammaControl_AddRef,
|
| 31 | + glDirectDrawGammaControl_Release,
|
| 32 | + glDirectDrawGammaControl_GetGammaRamp,
|
| 33 | + glDirectDrawGammaControl_SetGammaRamp
|
| 34 | +};
|
| 35 | +
|
| 36 | +HRESULT glDirectDrawGammaControl_Create(glDirectDrawSurface7 *glDDS7, LPDIRECTDRAWGAMMACONTROL *gamma)
|
| 37 | +{
|
| 38 | + glDirectDrawGammaControl *newgamma;
|
| 39 | + TRACE_ENTER(2, 14, glDDS7, 14, gamma);
|
| 40 | + if (!glDDS7) TRACE_RET(HRESULT, 23, DDERR_INVALIDPARAMS);
|
| 41 | + if (!gamma) TRACE_RET(HRESULT, 23, DDERR_INVALIDPARAMS);
|
| 42 | + newgamma = (glDirectDrawGammaControl*)malloc(sizeof(glDirectDrawGammaControl));
|
| 43 | + if (!newgamma) TRACE_RET(HRESULT, 23, DDERR_OUTOFMEMORY);
|
| 44 | + ZeroMemory(newgamma, sizeof(glDirectDrawGammaControl));
|
| 45 | + newgamma->glDDS7 = glDDS7;
|
| 46 | + newgamma->lpVtbl = &glDirectDrawGammaControl_iface;
|
| 47 | + *gamma = (LPDIRECTDRAWGAMMACONTROL)newgamma;
|
| 48 | + TRACE_EXIT(23, DD_OK);
|
| 49 | + return DD_OK;
|
| 50 | +}
|
| 51 | +
|
| 52 | +HRESULT WINAPI glDirectDrawGammaControl_QueryInterface(glDirectDrawGammaControl *This, REFIID riid, void** ppvObj)
|
| 53 | +{
|
| 54 | + TRACE_ENTER(3, 14, This, 24, &riid, 14, ppvObj);
|
| 55 | + if (!This) TRACE_RET(HRESULT, 23, DDERR_INVALIDOBJECT);
|
| 56 | + if (riid == IID_IUnknown)
|
| 57 | + {
|
| 58 | + glDirectDrawGammaControl_AddRef(This);
|
| 59 | + *ppvObj = This;
|
| 60 | + TRACE_VAR("*ppvObj", 14, *ppvObj);
|
| 61 | + TRACE_EXIT(23, DD_OK);
|
| 62 | + return DD_OK;
|
| 63 | + }
|
| 64 | + TRACE_RET(HRESULT, 23, This->glDDS7->QueryInterface(riid, ppvObj));
|
| 65 | +}
|
| 66 | +ULONG WINAPI glDirectDrawGammaControl_AddRef(glDirectDrawGammaControl *This)
|
| 67 | +{
|
| 68 | + TRACE_ENTER(1, 14, This);
|
| 69 | + if (!This) TRACE_RET(ULONG, 8, 0);
|
| 70 | + TRACE_RET(ULONG, 8, This->glDDS7->AddRefGamma());
|
| 71 | +}
|
| 72 | +ULONG WINAPI glDirectDrawGammaControl_Release(glDirectDrawGammaControl *This)
|
| 73 | +{
|
| 74 | + TRACE_ENTER(1, 14, This);
|
| 75 | + if (!This) TRACE_RET(ULONG, 8, 0);
|
| 76 | + TRACE_RET(ULONG, 8, This->glDDS7->ReleaseGamma());
|
| 77 | +}
|
| 78 | +HRESULT WINAPI glDirectDrawGammaControl_GetGammaRamp(glDirectDrawGammaControl *This, DWORD dwFlags, LPDDGAMMARAMP lpRampData)
|
| 79 | +{
|
| 80 | + TRACE_ENTER(3, 14, This, 9, dwFlags, 14, lpRampData);
|
| 81 | + if (!This) TRACE_RET(HRESULT, 23, DDERR_INVALIDOBJECT);
|
| 82 | + TRACE_RET(HRESULT, 23, This->glDDS7->GetGammaRamp(dwFlags, lpRampData));
|
| 83 | +}
|
| 84 | +HRESULT WINAPI glDirectDrawGammaControl_SetGammaRamp(glDirectDrawGammaControl *This, DWORD dwFlags, LPDDGAMMARAMP lpRampData)
|
| 85 | +{
|
| 86 | + TRACE_ENTER(3, 14, This, 9, dwFlags, 14, lpRampData);
|
| 87 | + if (!This) TRACE_RET(HRESULT, 23, DDERR_INVALIDOBJECT);
|
| 88 | + TRACE_RET(HRESULT, 23, This->glDDS7->SetGammaRamp(dwFlags, lpRampData));
|
| 89 | +}
|
| 90 | +
|
| 91 | +} |
\ No newline at end of file |
Index: ddraw/glDirectDrawGammaControl.h |
— | — | @@ -0,0 +1,57 @@ |
| 2 | +// DXGL
|
| 3 | +// Copyright (C) 2014 William Feely
|
| 4 | +
|
| 5 | +// This library is free software; you can redistribute it and/or
|
| 6 | +// modify it under the terms of the GNU Lesser General Public
|
| 7 | +// License as published by the Free Software Foundation; either
|
| 8 | +// version 2.1 of the License, or (at your option) any later version.
|
| 9 | +
|
| 10 | +// This library is distributed in the hope that it will be useful,
|
| 11 | +// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
| 12 | +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
| 13 | +// Lesser General Public License for more details.
|
| 14 | +
|
| 15 | +// You should have received a copy of the GNU Lesser General Public
|
| 16 | +// License along with this library; if not, write to the Free Software
|
| 17 | +// Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
| 18 | +
|
| 19 | +#pragma once
|
| 20 | +#ifndef _GLDIRECTDRAWGAMMACONTROL_H
|
| 21 | +#define _GLDIRECTDRAWGAMMACONTROL_H
|
| 22 | +
|
| 23 | +#ifdef __cplusplus
|
| 24 | +extern "C" {
|
| 25 | +#endif
|
| 26 | +
|
| 27 | +class glDirectDrawSurface7;
|
| 28 | +struct glDirectDrawGammaControlVtbl;
|
| 29 | +
|
| 30 | +typedef struct glDirectDrawGammaControl
|
| 31 | +{
|
| 32 | + glDirectDrawGammaControlVtbl *lpVtbl;
|
| 33 | + glDirectDrawSurface7 *glDDS7;
|
| 34 | +} glDirectDrawGammaControl;
|
| 35 | +
|
| 36 | +typedef struct glDirectDrawGammaControlVtbl
|
| 37 | +{
|
| 38 | + HRESULT(WINAPI *QueryInterface)(glDirectDrawGammaControl *This, REFIID riid, void** ppvObj);
|
| 39 | + ULONG(WINAPI *AddRef)(glDirectDrawGammaControl *This);
|
| 40 | + ULONG(WINAPI *Release)(glDirectDrawGammaControl *This);
|
| 41 | + HRESULT(WINAPI *GetGammaRamp)(glDirectDrawGammaControl *This, DWORD dwFlags, LPDDGAMMARAMP lpRampData);
|
| 42 | + HRESULT(WINAPI *SetGammaRamp)(glDirectDrawGammaControl *This, DWORD dwFlags, LPDDGAMMARAMP lpRampData);
|
| 43 | +} glDirectDrawGammaControlVtbl;
|
| 44 | +
|
| 45 | +HRESULT glDirectDrawGammaControl_Create(glDirectDrawSurface7 *glDDS7, LPDIRECTDRAWGAMMACONTROL *gamma);
|
| 46 | +
|
| 47 | +HRESULT WINAPI glDirectDrawGammaControl_QueryInterface(glDirectDrawGammaControl *This, REFIID riid, void** ppvObj);
|
| 48 | +ULONG WINAPI glDirectDrawGammaControl_AddRef(glDirectDrawGammaControl *This);
|
| 49 | +ULONG WINAPI glDirectDrawGammaControl_Release(glDirectDrawGammaControl *This);
|
| 50 | +HRESULT WINAPI glDirectDrawGammaControl_GetGammaRamp(glDirectDrawGammaControl *This, DWORD dwFlags, LPDDGAMMARAMP lpRampData);
|
| 51 | +HRESULT WINAPI glDirectDrawGammaControl_SetGammaRamp(glDirectDrawGammaControl *This, DWORD dwFlags, LPDDGAMMARAMP lpRampData);
|
| 52 | +
|
| 53 | +
|
| 54 | +#ifdef __cplusplus
|
| 55 | +}
|
| 56 | +#endif
|
| 57 | +
|
| 58 | +#endif //_GLDIRECTDRAWGAMMACONTROL_H |
\ No newline at end of file |
Index: ddraw/glDirectDrawSurface.cpp |
— | — | @@ -29,6 +29,7 @@ |
30 | 30 | #include "glDirect3DTexture.h"
|
31 | 31 | #include "glDirectDrawPalette.h"
|
32 | 32 | #include "glDirectDrawClipper.h"
|
| 33 | +#include "glDirectDrawGammaControl.h"
|
33 | 34 | #include "glRenderer.h"
|
34 | 35 | #include <string>
|
35 | 36 | using namespace std;
|
— | — | @@ -66,6 +67,7 @@ |
67 | 68 | dds4 = new glDirectDrawSurface4(this);
|
68 | 69 | d3dt2 = new glDirect3DTexture2(this);
|
69 | 70 | d3dt1 = new glDirect3DTexture1(this);
|
| 71 | + glDirectDrawGammaControl_Create(this, (LPDIRECTDRAWGAMMACONTROL*)&gammacontrol);
|
70 | 72 | buffer = gdibuffer = NULL;
|
71 | 73 | bigbuffer = NULL;
|
72 | 74 | zbuffer = NULL;
|
— | — | @@ -396,6 +398,7 @@ |
397 | 399 | if (dds4) delete dds4;
|
398 | 400 | if (d3dt1) delete d3dt1;
|
399 | 401 | if (d3dt2) delete d3dt2;
|
| 402 | + if (gammacontrol) free(gammacontrol);
|
400 | 403 | if(paltex)
|
401 | 404 | {
|
402 | 405 | glRenderer_DeleteTexture(ddInterface->renderer, paltex);
|
— | — | @@ -489,9 +492,11 @@ |
490 | 493 | }
|
491 | 494 | if (riid == IID_IDirectDrawGammaControl)
|
492 | 495 | {
|
493 | | - FIXME("Add gamma control\n");
|
494 | | - TRACE_EXIT(23, E_NOINTERFACE);
|
495 | | - ERR(E_NOINTERFACE);
|
| 496 | + this->AddRefGamma();
|
| 497 | + *ppvObj = gammacontrol;
|
| 498 | + TRACE_VAR("*ppvObj",14,*ppvObj);
|
| 499 | + TRACE_EXIT(23,DD_OK);
|
| 500 | + return DD_OK;
|
496 | 501 | }
|
497 | 502 | if (riid == IID_IDirectDrawColorControl)
|
498 | 503 | {
|
— | — | @@ -1726,7 +1731,24 @@ |
1727 | 1732 | return D3D_OK;
|
1728 | 1733 | }
|
1729 | 1734 |
|
| 1735 | +HRESULT glDirectDrawSurface7::GetGammaRamp(DWORD dwFlags, LPDDGAMMARAMP lpRampData)
|
| 1736 | +{
|
| 1737 | + TRACE_ENTER(3, 14, this, 9, dwFlags, 14, lpRampData);
|
| 1738 | + if (!this) TRACE_RET(HRESULT, 23, DDERR_INVALIDOBJECT);
|
| 1739 | + FIXME("glDirectDrawSurface7::GetGammaRamp: stub\n");
|
| 1740 | + TRACE_EXIT(23, DDERR_GENERIC);
|
| 1741 | + ERR(DDERR_GENERIC);
|
| 1742 | +}
|
1730 | 1743 |
|
| 1744 | +HRESULT glDirectDrawSurface7::SetGammaRamp(DWORD dwFlags, LPDDGAMMARAMP lpRampData)
|
| 1745 | +{
|
| 1746 | + TRACE_ENTER(3, 14, this, 9, dwFlags, 14, lpRampData);
|
| 1747 | + if (!this) TRACE_RET(HRESULT, 23, DDERR_INVALIDOBJECT);
|
| 1748 | + FIXME("glDirectDrawSurface7::SetGammaRamp: stub\n");
|
| 1749 | + TRACE_EXIT(23, DDERR_GENERIC);
|
| 1750 | + ERR(DDERR_GENERIC);
|
| 1751 | +}
|
| 1752 | +
|
1731 | 1753 | // DDRAW1 wrapper
|
1732 | 1754 | glDirectDrawSurface1::glDirectDrawSurface1(glDirectDrawSurface7 *gl_DDS7)
|
1733 | 1755 | {
|
Index: ddraw/glDirectDrawSurface.h |
— | — | @@ -36,6 +36,7 @@ |
37 | 37 | class glDirect3DTexture2;
|
38 | 38 | class glDirect3DTexture1;
|
39 | 39 | class glDirect3DDevice7;
|
| 40 | +struct glDirectDrawGammaControl;
|
40 | 41 | class glDirectDrawSurface7 : public IDirectDrawSurface7
|
41 | 42 | {
|
42 | 43 | public:
|
— | — | @@ -123,6 +124,8 @@ |
124 | 125 | HRESULT WINAPI Unlock2(LPVOID lpSurfaceData);
|
125 | 126 | HRESULT GetHandle(glDirect3DDevice7 *glD3DDev7, LPD3DTEXTUREHANDLE lpHandle);
|
126 | 127 | HRESULT Load(glDirectDrawSurface7 *src);
|
| 128 | + HRESULT GetGammaRamp(DWORD dwFlags, LPDDGAMMARAMP lpRampData);
|
| 129 | + HRESULT SetGammaRamp(DWORD dwFlags, LPDDGAMMARAMP lpRampData);
|
127 | 130 | glDirectDrawSurface1 *dds1;
|
128 | 131 | glDirectDrawSurface2 *dds2;
|
129 | 132 | glDirectDrawSurface3 *dds3;
|
— | — | @@ -129,6 +132,7 @@ |
130 | 133 | glDirectDrawSurface4 *dds4;
|
131 | 134 | glDirect3DTexture2 *d3dt2;
|
132 | 135 | glDirect3DTexture1 *d3dt1;
|
| 136 | + glDirectDrawGammaControl *gammacontrol;
|
133 | 137 | DWORD flipcount;
|
134 | 138 | DWORD fakex,fakey;
|
135 | 139 | float mulx, muly;
|