Index: ddraw/glDirectDrawPalette.cpp |
— | — | @@ -1,220 +0,0 @@ |
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 "glDirectDraw.h"
|
21 | | -#include "glDirectDrawPalette.h"
|
22 | | -
|
23 | | -
|
24 | | -const unsigned char DefaultPalette[1024] = {
|
25 | | -0x00,0x00,0x00,0x00,0x80,0x00,0x00,0x00,0x00,0x80,0x00,0x00,0x80,0x80,0x00,0x00,
|
26 | | -0x00,0x00,0x80,0x00,0x80,0x00,0x80,0x00,0x00,0x80,0x80,0x00,0xc0,0xc0,0xc0,0x00,
|
27 | | -0xa0,0xa0,0xa0,0x00,0xf0,0xf0,0xf0,0x00,0x40,0x20,0x00,0x00,0x60,0x20,0x00,0x00,
|
28 | | -0x80,0x20,0x00,0x00,0xa0,0x20,0x00,0x00,0xc0,0x20,0x00,0x00,0xe0,0x20,0x00,0x00,
|
29 | | -0x00,0x40,0x00,0x00,0x20,0x40,0x00,0x00,0x40,0x40,0x00,0x00,0x60,0x40,0x00,0x00,
|
30 | | -0x80,0x40,0x00,0x00,0xa0,0x40,0x00,0x00,0xc0,0x40,0x00,0x00,0xe0,0x40,0x00,0x00,
|
31 | | -0x00,0x60,0x00,0x00,0x20,0x60,0x00,0x00,0x40,0x60,0x00,0x00,0x60,0x60,0x00,0x00,
|
32 | | -0x80,0x60,0x00,0x00,0xa0,0x60,0x00,0x00,0xc0,0x60,0x00,0x00,0xe0,0x60,0x00,0x00,
|
33 | | -0x00,0x80,0x00,0x00,0x20,0x80,0x00,0x00,0x40,0x80,0x00,0x00,0x60,0x80,0x00,0x00,
|
34 | | -0x80,0x80,0x00,0x00,0xa0,0x80,0x00,0x00,0xc0,0x80,0x00,0x00,0xe0,0x80,0x00,0x00,
|
35 | | -0x00,0xa0,0x00,0x00,0x20,0xa0,0x00,0x00,0x40,0xa0,0x00,0x00,0x60,0xa0,0x00,0x00,
|
36 | | -0x80,0xa0,0x00,0x00,0xa0,0xa0,0x00,0x00,0xc0,0xa0,0x00,0x00,0xe0,0xa0,0x00,0x00,
|
37 | | -0x00,0xc0,0x00,0x00,0x20,0xc0,0x00,0x00,0x40,0xc0,0x00,0x00,0x60,0xc0,0x00,0x00,
|
38 | | -0x80,0xc0,0x00,0x00,0xa0,0xc0,0x00,0x00,0xc0,0xc0,0x00,0x00,0xe0,0xc0,0x00,0x00,
|
39 | | -0x00,0xe0,0x00,0x00,0x20,0xe0,0x00,0x00,0x40,0xe0,0x00,0x00,0x60,0xe0,0x00,0x00,
|
40 | | -0x80,0xe0,0x00,0x00,0xa0,0xe0,0x00,0x00,0xc0,0xe0,0x00,0x00,0xe0,0xe0,0x00,0x00,
|
41 | | -0x00,0x00,0x40,0x00,0x20,0x00,0x40,0x00,0x40,0x00,0x40,0x00,0x60,0x00,0x40,0x00,
|
42 | | -0x80,0x00,0x40,0x00,0xa0,0x00,0x40,0x00,0xc0,0x00,0x40,0x00,0xe0,0x00,0x40,0x00,
|
43 | | -0x00,0x20,0x40,0x00,0x20,0x20,0x40,0x00,0x40,0x20,0x40,0x00,0x60,0x20,0x40,0x00,
|
44 | | -0x80,0x20,0x40,0x00,0xa0,0x20,0x40,0x00,0xc0,0x20,0x40,0x00,0xe0,0x20,0x40,0x00,
|
45 | | -0x00,0x40,0x40,0x00,0x20,0x40,0x40,0x00,0x40,0x40,0x40,0x00,0x60,0x40,0x40,0x00,
|
46 | | -0x80,0x40,0x40,0x00,0xa0,0x40,0x40,0x00,0xc0,0x40,0x40,0x00,0xe0,0x40,0x40,0x00,
|
47 | | -0x00,0x60,0x40,0x00,0x20,0x60,0x40,0x00,0x40,0x60,0x40,0x00,0x60,0x60,0x40,0x00,
|
48 | | -0x80,0x60,0x40,0x00,0xa0,0x60,0x40,0x00,0xc0,0x60,0x40,0x00,0xe0,0x60,0x40,0x00,
|
49 | | -0x00,0x80,0x40,0x00,0x20,0x80,0x40,0x00,0x40,0x80,0x40,0x00,0x60,0x80,0x40,0x00,
|
50 | | -0x80,0x80,0x40,0x00,0xa0,0x80,0x40,0x00,0xc0,0x80,0x40,0x00,0xe0,0x80,0x40,0x00,
|
51 | | -0x00,0xa0,0x40,0x00,0x20,0xa0,0x40,0x00,0x40,0xa0,0x40,0x00,0x60,0xa0,0x40,0x00,
|
52 | | -0x80,0xa0,0x40,0x00,0xa0,0xa0,0x40,0x00,0xc0,0xa0,0x40,0x00,0xe0,0xa0,0x40,0x00,
|
53 | | -0x00,0xc0,0x40,0x00,0x20,0xc0,0x40,0x00,0x40,0xc0,0x40,0x00,0x60,0xc0,0x40,0x00,
|
54 | | -0x80,0xc0,0x40,0x00,0xa0,0xc0,0x40,0x00,0xc0,0xc0,0x40,0x00,0xe0,0xc0,0x40,0x00,
|
55 | | -0x00,0xe0,0x40,0x00,0x20,0xe0,0x40,0x00,0x40,0xe0,0x40,0x00,0x60,0xe0,0x40,0x00,
|
56 | | -0x80,0xe0,0x40,0x00,0xa0,0xe0,0x40,0x00,0xc0,0xe0,0x40,0x00,0xe0,0xe0,0x40,0x00,
|
57 | | -0x00,0x00,0x80,0x00,0x20,0x00,0x80,0x00,0x40,0x00,0x80,0x00,0x60,0x00,0x80,0x00,
|
58 | | -0x80,0x00,0x80,0x00,0xa0,0x00,0x80,0x00,0xc0,0x00,0x80,0x00,0xe0,0x00,0x80,0x00,
|
59 | | -0x00,0x20,0x80,0x00,0x20,0x20,0x80,0x00,0x40,0x20,0x80,0x00,0x60,0x20,0x80,0x00,
|
60 | | -0x80,0x20,0x80,0x00,0xa0,0x20,0x80,0x00,0xc0,0x20,0x80,0x00,0xe0,0x20,0x80,0x00,
|
61 | | -0x00,0x40,0x80,0x00,0x20,0x40,0x80,0x00,0x40,0x40,0x80,0x00,0x60,0x40,0x80,0x00,
|
62 | | -0x80,0x40,0x80,0x00,0xa0,0x40,0x80,0x00,0xc0,0x40,0x80,0x00,0xe0,0x40,0x80,0x00,
|
63 | | -0x00,0x60,0x80,0x00,0x20,0x60,0x80,0x00,0x40,0x60,0x80,0x00,0x60,0x60,0x80,0x00,
|
64 | | -0x80,0x60,0x80,0x00,0xa0,0x60,0x80,0x00,0xc0,0x60,0x80,0x00,0xe0,0x60,0x80,0x00,
|
65 | | -0x00,0x80,0x80,0x00,0x20,0x80,0x80,0x00,0x40,0x80,0x80,0x00,0x60,0x80,0x80,0x00,
|
66 | | -0x80,0x80,0x80,0x00,0xa0,0x80,0x80,0x00,0xc0,0x80,0x80,0x00,0xe0,0x80,0x80,0x00,
|
67 | | -0x00,0xa0,0x80,0x00,0x20,0xa0,0x80,0x00,0x40,0xa0,0x80,0x00,0x60,0xa0,0x80,0x00,
|
68 | | -0x80,0xa0,0x80,0x00,0xa0,0xa0,0x80,0x00,0xc0,0xa0,0x80,0x00,0xe0,0xa0,0x80,0x00,
|
69 | | -0x00,0xc0,0x80,0x00,0x20,0xc0,0x80,0x00,0x40,0xc0,0x80,0x00,0x60,0xc0,0x80,0x00,
|
70 | | -0x80,0xc0,0x80,0x00,0xa0,0xc0,0x80,0x00,0xc0,0xc0,0x80,0x00,0xe0,0xc0,0x80,0x00,
|
71 | | -0x00,0xe0,0x80,0x00,0x20,0xe0,0x80,0x00,0x40,0xe0,0x80,0x00,0x60,0xe0,0x80,0x00,
|
72 | | -0x80,0xe0,0x80,0x00,0xa0,0xe0,0x80,0x00,0xc0,0xe0,0x80,0x00,0xe0,0xe0,0x80,0x00,
|
73 | | -0x00,0x00,0xc0,0x00,0x20,0x00,0xc0,0x00,0x40,0x00,0xc0,0x00,0x60,0x00,0xc0,0x00,
|
74 | | -0x80,0x00,0xc0,0x00,0xa0,0x00,0xc0,0x00,0xc0,0x00,0xc0,0x00,0xe0,0x00,0xc0,0x00,
|
75 | | -0x00,0x20,0xc0,0x00,0x20,0x20,0xc0,0x00,0x40,0x20,0xc0,0x00,0x60,0x20,0xc0,0x00,
|
76 | | -0x80,0x20,0xc0,0x00,0xa0,0x20,0xc0,0x00,0xc0,0x20,0xc0,0x00,0xe0,0x20,0xc0,0x00,
|
77 | | -0x00,0x40,0xc0,0x00,0x20,0x40,0xc0,0x00,0x40,0x40,0xc0,0x00,0x60,0x40,0xc0,0x00,
|
78 | | -0x80,0x40,0xc0,0x00,0xa0,0x40,0xc0,0x00,0xc0,0x40,0xc0,0x00,0xe0,0x40,0xc0,0x00,
|
79 | | -0x00,0x60,0xc0,0x00,0x20,0x60,0xc0,0x00,0x40,0x60,0xc0,0x00,0x60,0x60,0xc0,0x00,
|
80 | | -0x80,0x60,0xc0,0x00,0xa0,0x60,0xc0,0x00,0xc0,0x60,0xc0,0x00,0xe0,0x60,0xc0,0x00,
|
81 | | -0x00,0x80,0xc0,0x00,0x20,0x80,0xc0,0x00,0x40,0x80,0xc0,0x00,0x60,0x80,0xc0,0x00,
|
82 | | -0x80,0x80,0xc0,0x00,0xa0,0x80,0xc0,0x00,0xc0,0x80,0xc0,0x00,0xe0,0x80,0xc0,0x00,
|
83 | | -0x00,0xa0,0xc0,0x00,0x20,0xa0,0xc0,0x00,0x40,0xa0,0xc0,0x00,0x60,0xa0,0xc0,0x00,
|
84 | | -0x80,0xa0,0xc0,0x00,0xa0,0xa0,0xc0,0x00,0xc0,0xa0,0xc0,0x00,0xe0,0xa0,0xc0,0x00,
|
85 | | -0x00,0xc0,0xc0,0x00,0x20,0xc0,0xc0,0x00,0x40,0xc0,0xc0,0x00,0x60,0xc0,0xc0,0x00,
|
86 | | -0x80,0xc0,0xc0,0x00,0xa0,0xc0,0xc0,0x00,0xff,0xfb,0xf0,0x00,0xa0,0xa0,0xa4,0x00,
|
87 | | -0x80,0x80,0x80,0x00,0xff,0x00,0x00,0x00,0x00,0xff,0x00,0x00,0xff,0xff,0x00,0x00,
|
88 | | -0x00,0x00,0xff,0x00,0xff,0x00,0xff,0x00,0x00,0xff,0xff,0x00,0xff,0xff,0xff,0x00
|
89 | | -}; // Grabbed from a Windows DDRAW run
|
90 | | -
|
91 | | -
|
92 | | -glDirectDrawPalette::glDirectDrawPalette(DWORD dwFlags, LPPALETTEENTRY lpDDColorArray, LPDIRECTDRAWPALETTE FAR *lplpDDPalette)
|
93 | | -{
|
94 | | - TRACE_ENTER(4,14,this,9,dwFlags,14,lpDDColorArray,14,lplpDDPalette);
|
95 | | - refcount = 1;
|
96 | | - flags = dwFlags;
|
97 | | - if(lpDDColorArray == NULL) memcpy(palette,DefaultPalette,1024);
|
98 | | - else
|
99 | | - {
|
100 | | - if(flags & DDPCAPS_1BIT)
|
101 | | - if(flags & DDPCAPS_8BITENTRIES) memcpy(palette,lpDDColorArray,2);
|
102 | | - else memcpy(palette,lpDDColorArray,2*sizeof(PALETTEENTRY));
|
103 | | - else if(flags & DDPCAPS_2BIT)
|
104 | | - if(flags & DDPCAPS_8BITENTRIES) memcpy(palette,lpDDColorArray,4);
|
105 | | - else memcpy(palette,lpDDColorArray,4*sizeof(PALETTEENTRY));
|
106 | | - else if(flags & DDPCAPS_4BIT)
|
107 | | - if(flags & DDPCAPS_8BITENTRIES) memcpy(palette,lpDDColorArray,16);
|
108 | | - else memcpy(palette,lpDDColorArray,16*sizeof(PALETTEENTRY));
|
109 | | - else memcpy(palette,lpDDColorArray,256*sizeof(PALETTEENTRY));
|
110 | | - }
|
111 | | - if(lplpDDPalette) *lplpDDPalette = this;
|
112 | | - TRACE_EXIT(-1,0);
|
113 | | -}
|
114 | | -
|
115 | | -glDirectDrawPalette::~glDirectDrawPalette()
|
116 | | -{
|
117 | | - TRACE_ENTER(1,14,this);
|
118 | | - TRACE_EXIT(-1,0);
|
119 | | -}
|
120 | | -
|
121 | | -HRESULT WINAPI glDirectDrawPalette::QueryInterface(REFIID riid, void** ppvObj)
|
122 | | -{
|
123 | | - TRACE_ENTER(3,14,this,24,&riid,14,ppvObj);
|
124 | | - if(!this) TRACE_RET(HRESULT,23,DDERR_INVALIDOBJECT);
|
125 | | - if(!ppvObj) TRACE_RET(HRESULT,23,DDERR_INVALIDPARAMS);
|
126 | | - if(riid == IID_IUnknown)
|
127 | | - {
|
128 | | - this->AddRef();
|
129 | | - *ppvObj = this;
|
130 | | - TRACE_VAR("*ppvObj",14,*ppvObj);
|
131 | | - TRACE_EXIT(23,DD_OK);
|
132 | | - return DD_OK;
|
133 | | - }
|
134 | | - TRACE_EXIT(23,E_NOINTERFACE);
|
135 | | - ERR(E_NOINTERFACE);
|
136 | | -}
|
137 | | -
|
138 | | -ULONG WINAPI glDirectDrawPalette::AddRef()
|
139 | | -{
|
140 | | - TRACE_ENTER(1,14,this);
|
141 | | - if(!this) return 0;
|
142 | | - refcount++;
|
143 | | - TRACE_EXIT(8,refcount);
|
144 | | - return refcount;
|
145 | | -}
|
146 | | -
|
147 | | -ULONG WINAPI glDirectDrawPalette::Release()
|
148 | | -{
|
149 | | - TRACE_ENTER(1,14,this);
|
150 | | - if(!this) return 0;
|
151 | | - ULONG ret;
|
152 | | - refcount--;
|
153 | | - ret = refcount;
|
154 | | - if(refcount == 0) delete this;
|
155 | | - TRACE_EXIT(8,ret);
|
156 | | - return ret;
|
157 | | -}
|
158 | | -
|
159 | | -HRESULT WINAPI glDirectDrawPalette::GetCaps(LPDWORD lpdwCaps)
|
160 | | -{
|
161 | | - TRACE_ENTER(2,14,this,14,lpdwCaps);
|
162 | | - if(!this) TRACE_RET(HRESULT,23,DDERR_INVALIDOBJECT);
|
163 | | - *lpdwCaps = flags;
|
164 | | - TRACE_VAR("*lpdwCaps",9,*lpdwCaps);
|
165 | | - TRACE_EXIT(23,DD_OK);
|
166 | | - return DD_OK;
|
167 | | -}
|
168 | | -
|
169 | | -HRESULT WINAPI glDirectDrawPalette::GetEntries(DWORD dwFlags, DWORD dwBase, DWORD dwNumEntries, LPPALETTEENTRY lpEntries)
|
170 | | -{
|
171 | | - TRACE_ENTER(5,14,this,9,dwFlags,8,dwBase,8,dwNumEntries,14,lpEntries);
|
172 | | - if(!this) TRACE_RET(HRESULT,23,DDERR_INVALIDOBJECT);
|
173 | | - DWORD allentries = 256;
|
174 | | - DWORD entrysize;
|
175 | | - if(flags & DDPCAPS_1BIT) allentries=2;
|
176 | | - if(flags & DDPCAPS_2BIT) allentries=4;
|
177 | | - if(flags & DDPCAPS_4BIT) allentries=16;
|
178 | | - if(flags & DDPCAPS_8BIT) allentries=256;
|
179 | | - if(flags & DDPCAPS_8BITENTRIES) entrysize = 1;
|
180 | | - else entrysize = sizeof(PALETTEENTRY);
|
181 | | - if((dwBase + dwNumEntries) > allentries) TRACE_RET(HRESULT,23,DDERR_INVALIDPARAMS);
|
182 | | - memcpy(lpEntries,((char *)palette)+(dwBase*entrysize),dwNumEntries*entrysize);
|
183 | | - TRACE_EXIT(23,DD_OK);
|
184 | | - return DD_OK;
|
185 | | -}
|
186 | | -HRESULT WINAPI glDirectDrawPalette::Initialize(LPDIRECTDRAW lpDD, DWORD dwFlags, LPPALETTEENTRY lpDDColorTable)
|
187 | | -{
|
188 | | - TRACE_ENTER(4,14,this,14,lpDD,9,dwFlags,14,lpDDColorTable);
|
189 | | - if(!this) TRACE_RET(HRESULT,23,DDERR_INVALIDOBJECT);
|
190 | | - TRACE_EXIT(23,DDERR_ALREADYINITIALIZED);
|
191 | | - return DDERR_ALREADYINITIALIZED;
|
192 | | -}
|
193 | | -HRESULT WINAPI glDirectDrawPalette::SetEntries(DWORD dwFlags, DWORD dwStartingEntry, DWORD dwCount, LPPALETTEENTRY lpEntries)
|
194 | | -{
|
195 | | - TRACE_ENTER(5,14,this,9,dwFlags,8,dwStartingEntry,8,dwCount,14,lpEntries);
|
196 | | - if(!this) TRACE_RET(HRESULT,23,DDERR_INVALIDOBJECT);
|
197 | | - DWORD allentries = 256;
|
198 | | - DWORD entrysize;
|
199 | | - if(flags & DDPCAPS_1BIT) allentries=2;
|
200 | | - if(flags & DDPCAPS_2BIT) allentries=4;
|
201 | | - if(flags & DDPCAPS_4BIT) allentries=16;
|
202 | | - if(flags & DDPCAPS_8BIT) allentries=256;
|
203 | | - if(flags & DDPCAPS_8BITENTRIES) entrysize = 1;
|
204 | | - else entrysize = sizeof(PALETTEENTRY);
|
205 | | - if((dwStartingEntry + dwCount) > allentries) TRACE_RET(HRESULT,23,DDERR_INVALIDPARAMS);
|
206 | | - memcpy(((char *)palette)+(dwStartingEntry*entrysize),lpEntries,dwCount*entrysize);
|
207 | | - TRACE_EXIT(23,DD_OK);
|
208 | | - return DD_OK;
|
209 | | -}
|
210 | | -
|
211 | | -LPPALETTEENTRY glDirectDrawPalette::GetPalette(DWORD *flags)
|
212 | | -{
|
213 | | - TRACE_ENTER(2,14,this,14,flags);
|
214 | | - if(flags)
|
215 | | - {
|
216 | | - *flags = this->flags;
|
217 | | - TRACE_VAR("*flags",9,*flags);
|
218 | | - }
|
219 | | - TRACE_RET(LPPALETTEENTRY,14,palette);
|
220 | | - return palette;
|
221 | | -}
|
Index: ddraw/ddraw.vcxproj |
— | — | @@ -343,10 +343,22 @@ |
344 | 344 | <ClCompile Include="glDirect3DViewport.cpp" />
|
345 | 345 | <ClCompile Include="glDirectDraw.cpp" />
|
346 | 346 | <ClCompile Include="glDirectDrawClipper.cpp" />
|
347 | | - <ClCompile Include="glDirectDrawPalette.cpp" />
|
| 347 | + <ClCompile Include="glDirectDrawPalette.c">
|
| 348 | + <PrecompiledHeader Condition="'$(Configuration)|$(Platform)'=='Debug Trace|Win32'">NotUsing</PrecompiledHeader>
|
| 349 | + <PrecompiledHeader Condition="'$(Configuration)|$(Platform)'=='Release no DXGL|Win32'">NotUsing</PrecompiledHeader>
|
| 350 | + <PrecompiledHeader Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">NotUsing</PrecompiledHeader>
|
| 351 | + <PrecompiledHeader Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">NotUsing</PrecompiledHeader>
|
| 352 | + <PrecompiledHeader Condition="'$(Configuration)|$(Platform)'=='Debug no DXGL|Win32'">NotUsing</PrecompiledHeader>
|
| 353 | + <PrecompiledHeader Condition="'$(Configuration)|$(Platform)'=='Debug No MSVCRT|Win32'">NotUsing</PrecompiledHeader>
|
| 354 | + </ClCompile>
|
348 | 355 | <ClCompile Include="glDirectDrawSurface.cpp" />
|
349 | 356 | <ClCompile Include="glExtensions.c">
|
350 | 357 | <PrecompiledHeader Condition="'$(Configuration)|$(Platform)'=='Debug Trace|Win32'">NotUsing</PrecompiledHeader>
|
| 358 | + <PrecompiledHeader Condition="'$(Configuration)|$(Platform)'=='Release no DXGL|Win32'">NotUsing</PrecompiledHeader>
|
| 359 | + <PrecompiledHeader Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">NotUsing</PrecompiledHeader>
|
| 360 | + <PrecompiledHeader Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">NotUsing</PrecompiledHeader>
|
| 361 | + <PrecompiledHeader Condition="'$(Configuration)|$(Platform)'=='Debug no DXGL|Win32'">NotUsing</PrecompiledHeader>
|
| 362 | + <PrecompiledHeader Condition="'$(Configuration)|$(Platform)'=='Debug No MSVCRT|Win32'">NotUsing</PrecompiledHeader>
|
351 | 363 | </ClCompile>
|
352 | 364 | <ClCompile Include="glRenderer.cpp" />
|
353 | 365 | <ClCompile Include="glRenderWindow.cpp" />
|
— | — | @@ -368,6 +380,11 @@ |
369 | 381 | <ClCompile Include="timer.cpp" />
|
370 | 382 | <ClCompile Include="trace.c">
|
371 | 383 | <PrecompiledHeader Condition="'$(Configuration)|$(Platform)'=='Debug Trace|Win32'">NotUsing</PrecompiledHeader>
|
| 384 | + <PrecompiledHeader Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">NotUsing</PrecompiledHeader>
|
| 385 | + <PrecompiledHeader Condition="'$(Configuration)|$(Platform)'=='Release no DXGL|Win32'">NotUsing</PrecompiledHeader>
|
| 386 | + <PrecompiledHeader Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">NotUsing</PrecompiledHeader>
|
| 387 | + <PrecompiledHeader Condition="'$(Configuration)|$(Platform)'=='Debug no DXGL|Win32'">NotUsing</PrecompiledHeader>
|
| 388 | + <PrecompiledHeader Condition="'$(Configuration)|$(Platform)'=='Debug No MSVCRT|Win32'">NotUsing</PrecompiledHeader>
|
372 | 389 | </ClCompile>
|
373 | 390 | <ClCompile Include="util.cpp" />
|
374 | 391 | </ItemGroup>
|
Index: ddraw/ddraw.vcxproj.filters |
— | — | @@ -154,9 +154,6 @@ |
155 | 155 | <ClCompile Include="glDirectDrawClipper.cpp">
|
156 | 156 | <Filter>Source Files</Filter>
|
157 | 157 | </ClCompile>
|
158 | | - <ClCompile Include="glDirectDrawPalette.cpp">
|
159 | | - <Filter>Source Files</Filter>
|
160 | | - </ClCompile>
|
161 | 158 | <ClCompile Include="precomp.cpp">
|
162 | 159 | <Filter>Source Files</Filter>
|
163 | 160 | </ClCompile>
|
— | — | @@ -229,6 +226,9 @@ |
230 | 227 | <ClCompile Include="trace.c">
|
231 | 228 | <Filter>Source Files</Filter>
|
232 | 229 | </ClCompile>
|
| 230 | + <ClCompile Include="glDirectDrawPalette.c">
|
| 231 | + <Filter>Source Files</Filter>
|
| 232 | + </ClCompile>
|
233 | 233 | </ItemGroup>
|
234 | 234 | <ItemGroup>
|
235 | 235 | <ResourceCompile Include="ddraw.rc">
|
Index: ddraw/glDirectDraw.cpp |
— | — | @@ -822,10 +822,10 @@ |
823 | 823 | if(!this) TRACE_RET(HRESULT,23,DDERR_INVALIDOBJECT);
|
824 | 824 | if(!lplpDDPalette) TRACE_RET(HRESULT,23,DDERR_INVALIDPARAMS);
|
825 | 825 | if(pUnkOuter) TRACE_RET(HRESULT,23,DDERR_INVALIDPARAMS);
|
826 | | - glDirectDrawPalette *pal = new glDirectDrawPalette(dwFlags,lpDDColorArray,lplpDDPalette);
|
| 826 | + HRESULT ret = glDirectDrawPalette_Create(dwFlags, lpDDColorArray, lplpDDPalette);
|
827 | 827 | TRACE_VAR("*lplpDDPalette",14,*lplpDDPalette);
|
828 | | - TRACE_EXIT(23,DD_OK);
|
829 | | - return DD_OK;
|
| 828 | + TRACE_EXIT(23,ret);
|
| 829 | + return ret;
|
830 | 830 | }
|
831 | 831 |
|
832 | 832 | HRESULT WINAPI glDirectDraw7::CreateSurface(LPDDSURFACEDESC2 lpDDSurfaceDesc2, LPDIRECTDRAWSURFACE7 FAR *lplpDDSurface, IUnknown FAR *pUnkOuter)
|
Index: ddraw/glDirectDrawPalette.c |
— | — | @@ -0,0 +1,231 @@ |
| 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 "glDirectDrawPalette.h"
|
| 21 | +
|
| 22 | +
|
| 23 | +const unsigned char DefaultPalette[1024] = {
|
| 24 | +0x00,0x00,0x00,0x00,0x80,0x00,0x00,0x00,0x00,0x80,0x00,0x00,0x80,0x80,0x00,0x00,
|
| 25 | +0x00,0x00,0x80,0x00,0x80,0x00,0x80,0x00,0x00,0x80,0x80,0x00,0xc0,0xc0,0xc0,0x00,
|
| 26 | +0xa0,0xa0,0xa0,0x00,0xf0,0xf0,0xf0,0x00,0x40,0x20,0x00,0x00,0x60,0x20,0x00,0x00,
|
| 27 | +0x80,0x20,0x00,0x00,0xa0,0x20,0x00,0x00,0xc0,0x20,0x00,0x00,0xe0,0x20,0x00,0x00,
|
| 28 | +0x00,0x40,0x00,0x00,0x20,0x40,0x00,0x00,0x40,0x40,0x00,0x00,0x60,0x40,0x00,0x00,
|
| 29 | +0x80,0x40,0x00,0x00,0xa0,0x40,0x00,0x00,0xc0,0x40,0x00,0x00,0xe0,0x40,0x00,0x00,
|
| 30 | +0x00,0x60,0x00,0x00,0x20,0x60,0x00,0x00,0x40,0x60,0x00,0x00,0x60,0x60,0x00,0x00,
|
| 31 | +0x80,0x60,0x00,0x00,0xa0,0x60,0x00,0x00,0xc0,0x60,0x00,0x00,0xe0,0x60,0x00,0x00,
|
| 32 | +0x00,0x80,0x00,0x00,0x20,0x80,0x00,0x00,0x40,0x80,0x00,0x00,0x60,0x80,0x00,0x00,
|
| 33 | +0x80,0x80,0x00,0x00,0xa0,0x80,0x00,0x00,0xc0,0x80,0x00,0x00,0xe0,0x80,0x00,0x00,
|
| 34 | +0x00,0xa0,0x00,0x00,0x20,0xa0,0x00,0x00,0x40,0xa0,0x00,0x00,0x60,0xa0,0x00,0x00,
|
| 35 | +0x80,0xa0,0x00,0x00,0xa0,0xa0,0x00,0x00,0xc0,0xa0,0x00,0x00,0xe0,0xa0,0x00,0x00,
|
| 36 | +0x00,0xc0,0x00,0x00,0x20,0xc0,0x00,0x00,0x40,0xc0,0x00,0x00,0x60,0xc0,0x00,0x00,
|
| 37 | +0x80,0xc0,0x00,0x00,0xa0,0xc0,0x00,0x00,0xc0,0xc0,0x00,0x00,0xe0,0xc0,0x00,0x00,
|
| 38 | +0x00,0xe0,0x00,0x00,0x20,0xe0,0x00,0x00,0x40,0xe0,0x00,0x00,0x60,0xe0,0x00,0x00,
|
| 39 | +0x80,0xe0,0x00,0x00,0xa0,0xe0,0x00,0x00,0xc0,0xe0,0x00,0x00,0xe0,0xe0,0x00,0x00,
|
| 40 | +0x00,0x00,0x40,0x00,0x20,0x00,0x40,0x00,0x40,0x00,0x40,0x00,0x60,0x00,0x40,0x00,
|
| 41 | +0x80,0x00,0x40,0x00,0xa0,0x00,0x40,0x00,0xc0,0x00,0x40,0x00,0xe0,0x00,0x40,0x00,
|
| 42 | +0x00,0x20,0x40,0x00,0x20,0x20,0x40,0x00,0x40,0x20,0x40,0x00,0x60,0x20,0x40,0x00,
|
| 43 | +0x80,0x20,0x40,0x00,0xa0,0x20,0x40,0x00,0xc0,0x20,0x40,0x00,0xe0,0x20,0x40,0x00,
|
| 44 | +0x00,0x40,0x40,0x00,0x20,0x40,0x40,0x00,0x40,0x40,0x40,0x00,0x60,0x40,0x40,0x00,
|
| 45 | +0x80,0x40,0x40,0x00,0xa0,0x40,0x40,0x00,0xc0,0x40,0x40,0x00,0xe0,0x40,0x40,0x00,
|
| 46 | +0x00,0x60,0x40,0x00,0x20,0x60,0x40,0x00,0x40,0x60,0x40,0x00,0x60,0x60,0x40,0x00,
|
| 47 | +0x80,0x60,0x40,0x00,0xa0,0x60,0x40,0x00,0xc0,0x60,0x40,0x00,0xe0,0x60,0x40,0x00,
|
| 48 | +0x00,0x80,0x40,0x00,0x20,0x80,0x40,0x00,0x40,0x80,0x40,0x00,0x60,0x80,0x40,0x00,
|
| 49 | +0x80,0x80,0x40,0x00,0xa0,0x80,0x40,0x00,0xc0,0x80,0x40,0x00,0xe0,0x80,0x40,0x00,
|
| 50 | +0x00,0xa0,0x40,0x00,0x20,0xa0,0x40,0x00,0x40,0xa0,0x40,0x00,0x60,0xa0,0x40,0x00,
|
| 51 | +0x80,0xa0,0x40,0x00,0xa0,0xa0,0x40,0x00,0xc0,0xa0,0x40,0x00,0xe0,0xa0,0x40,0x00,
|
| 52 | +0x00,0xc0,0x40,0x00,0x20,0xc0,0x40,0x00,0x40,0xc0,0x40,0x00,0x60,0xc0,0x40,0x00,
|
| 53 | +0x80,0xc0,0x40,0x00,0xa0,0xc0,0x40,0x00,0xc0,0xc0,0x40,0x00,0xe0,0xc0,0x40,0x00,
|
| 54 | +0x00,0xe0,0x40,0x00,0x20,0xe0,0x40,0x00,0x40,0xe0,0x40,0x00,0x60,0xe0,0x40,0x00,
|
| 55 | +0x80,0xe0,0x40,0x00,0xa0,0xe0,0x40,0x00,0xc0,0xe0,0x40,0x00,0xe0,0xe0,0x40,0x00,
|
| 56 | +0x00,0x00,0x80,0x00,0x20,0x00,0x80,0x00,0x40,0x00,0x80,0x00,0x60,0x00,0x80,0x00,
|
| 57 | +0x80,0x00,0x80,0x00,0xa0,0x00,0x80,0x00,0xc0,0x00,0x80,0x00,0xe0,0x00,0x80,0x00,
|
| 58 | +0x00,0x20,0x80,0x00,0x20,0x20,0x80,0x00,0x40,0x20,0x80,0x00,0x60,0x20,0x80,0x00,
|
| 59 | +0x80,0x20,0x80,0x00,0xa0,0x20,0x80,0x00,0xc0,0x20,0x80,0x00,0xe0,0x20,0x80,0x00,
|
| 60 | +0x00,0x40,0x80,0x00,0x20,0x40,0x80,0x00,0x40,0x40,0x80,0x00,0x60,0x40,0x80,0x00,
|
| 61 | +0x80,0x40,0x80,0x00,0xa0,0x40,0x80,0x00,0xc0,0x40,0x80,0x00,0xe0,0x40,0x80,0x00,
|
| 62 | +0x00,0x60,0x80,0x00,0x20,0x60,0x80,0x00,0x40,0x60,0x80,0x00,0x60,0x60,0x80,0x00,
|
| 63 | +0x80,0x60,0x80,0x00,0xa0,0x60,0x80,0x00,0xc0,0x60,0x80,0x00,0xe0,0x60,0x80,0x00,
|
| 64 | +0x00,0x80,0x80,0x00,0x20,0x80,0x80,0x00,0x40,0x80,0x80,0x00,0x60,0x80,0x80,0x00,
|
| 65 | +0x80,0x80,0x80,0x00,0xa0,0x80,0x80,0x00,0xc0,0x80,0x80,0x00,0xe0,0x80,0x80,0x00,
|
| 66 | +0x00,0xa0,0x80,0x00,0x20,0xa0,0x80,0x00,0x40,0xa0,0x80,0x00,0x60,0xa0,0x80,0x00,
|
| 67 | +0x80,0xa0,0x80,0x00,0xa0,0xa0,0x80,0x00,0xc0,0xa0,0x80,0x00,0xe0,0xa0,0x80,0x00,
|
| 68 | +0x00,0xc0,0x80,0x00,0x20,0xc0,0x80,0x00,0x40,0xc0,0x80,0x00,0x60,0xc0,0x80,0x00,
|
| 69 | +0x80,0xc0,0x80,0x00,0xa0,0xc0,0x80,0x00,0xc0,0xc0,0x80,0x00,0xe0,0xc0,0x80,0x00,
|
| 70 | +0x00,0xe0,0x80,0x00,0x20,0xe0,0x80,0x00,0x40,0xe0,0x80,0x00,0x60,0xe0,0x80,0x00,
|
| 71 | +0x80,0xe0,0x80,0x00,0xa0,0xe0,0x80,0x00,0xc0,0xe0,0x80,0x00,0xe0,0xe0,0x80,0x00,
|
| 72 | +0x00,0x00,0xc0,0x00,0x20,0x00,0xc0,0x00,0x40,0x00,0xc0,0x00,0x60,0x00,0xc0,0x00,
|
| 73 | +0x80,0x00,0xc0,0x00,0xa0,0x00,0xc0,0x00,0xc0,0x00,0xc0,0x00,0xe0,0x00,0xc0,0x00,
|
| 74 | +0x00,0x20,0xc0,0x00,0x20,0x20,0xc0,0x00,0x40,0x20,0xc0,0x00,0x60,0x20,0xc0,0x00,
|
| 75 | +0x80,0x20,0xc0,0x00,0xa0,0x20,0xc0,0x00,0xc0,0x20,0xc0,0x00,0xe0,0x20,0xc0,0x00,
|
| 76 | +0x00,0x40,0xc0,0x00,0x20,0x40,0xc0,0x00,0x40,0x40,0xc0,0x00,0x60,0x40,0xc0,0x00,
|
| 77 | +0x80,0x40,0xc0,0x00,0xa0,0x40,0xc0,0x00,0xc0,0x40,0xc0,0x00,0xe0,0x40,0xc0,0x00,
|
| 78 | +0x00,0x60,0xc0,0x00,0x20,0x60,0xc0,0x00,0x40,0x60,0xc0,0x00,0x60,0x60,0xc0,0x00,
|
| 79 | +0x80,0x60,0xc0,0x00,0xa0,0x60,0xc0,0x00,0xc0,0x60,0xc0,0x00,0xe0,0x60,0xc0,0x00,
|
| 80 | +0x00,0x80,0xc0,0x00,0x20,0x80,0xc0,0x00,0x40,0x80,0xc0,0x00,0x60,0x80,0xc0,0x00,
|
| 81 | +0x80,0x80,0xc0,0x00,0xa0,0x80,0xc0,0x00,0xc0,0x80,0xc0,0x00,0xe0,0x80,0xc0,0x00,
|
| 82 | +0x00,0xa0,0xc0,0x00,0x20,0xa0,0xc0,0x00,0x40,0xa0,0xc0,0x00,0x60,0xa0,0xc0,0x00,
|
| 83 | +0x80,0xa0,0xc0,0x00,0xa0,0xa0,0xc0,0x00,0xc0,0xa0,0xc0,0x00,0xe0,0xa0,0xc0,0x00,
|
| 84 | +0x00,0xc0,0xc0,0x00,0x20,0xc0,0xc0,0x00,0x40,0xc0,0xc0,0x00,0x60,0xc0,0xc0,0x00,
|
| 85 | +0x80,0xc0,0xc0,0x00,0xa0,0xc0,0xc0,0x00,0xff,0xfb,0xf0,0x00,0xa0,0xa0,0xa4,0x00,
|
| 86 | +0x80,0x80,0x80,0x00,0xff,0x00,0x00,0x00,0x00,0xff,0x00,0x00,0xff,0xff,0x00,0x00,
|
| 87 | +0x00,0x00,0xff,0x00,0xff,0x00,0xff,0x00,0x00,0xff,0xff,0x00,0xff,0xff,0xff,0x00
|
| 88 | +}; // Grabbed from a Windows DDRAW run
|
| 89 | +
|
| 90 | +
|
| 91 | +HRESULT WINAPI glDirectDrawPalette_QueryInterface(glDirectDrawPalette *This, REFIID riid, void** ppvObj)
|
| 92 | +{
|
| 93 | + TRACE_ENTER(3,14,This,24,&riid,14,ppvObj);
|
| 94 | + if(!This) TRACE_RET(HRESULT,23,DDERR_INVALIDOBJECT);
|
| 95 | + if(!ppvObj) TRACE_RET(HRESULT,23,DDERR_INVALIDPARAMS);
|
| 96 | + if(!memcmp(riid,&IID_IUnknown,sizeof(GUID)))
|
| 97 | + {
|
| 98 | + glDirectDrawPalette_AddRef(This);
|
| 99 | + *ppvObj = This;
|
| 100 | + TRACE_VAR("*ppvObj",14,*ppvObj);
|
| 101 | + TRACE_EXIT(23,DD_OK);
|
| 102 | + return DD_OK;
|
| 103 | + }
|
| 104 | + TRACE_EXIT(23,E_NOINTERFACE);
|
| 105 | + ERR(E_NOINTERFACE);
|
| 106 | +}
|
| 107 | +
|
| 108 | +ULONG WINAPI glDirectDrawPalette_AddRef(glDirectDrawPalette *This)
|
| 109 | +{
|
| 110 | + TRACE_ENTER(1,14,This);
|
| 111 | + if(!This) return 0;
|
| 112 | + This->refcount++;
|
| 113 | + TRACE_EXIT(8,This->refcount);
|
| 114 | + return This->refcount;
|
| 115 | +}
|
| 116 | +
|
| 117 | +ULONG WINAPI glDirectDrawPalette_Release(glDirectDrawPalette *This)
|
| 118 | +{
|
| 119 | + ULONG ret;
|
| 120 | + TRACE_ENTER(1, 14, This);
|
| 121 | + if(!This) return 0;
|
| 122 | + This->refcount--;
|
| 123 | + ret = This->refcount;
|
| 124 | + if (This->refcount == 0) free(This);
|
| 125 | + TRACE_EXIT(8,ret);
|
| 126 | + return ret;
|
| 127 | +}
|
| 128 | +
|
| 129 | +HRESULT WINAPI glDirectDrawPalette_GetCaps(glDirectDrawPalette *This, LPDWORD lpdwCaps)
|
| 130 | +{
|
| 131 | + TRACE_ENTER(2,14,This,14,lpdwCaps);
|
| 132 | + if(!This) TRACE_RET(HRESULT,23,DDERR_INVALIDOBJECT);
|
| 133 | + *lpdwCaps = This->flags;
|
| 134 | + TRACE_VAR("*lpdwCaps",9,*lpdwCaps);
|
| 135 | + TRACE_EXIT(23,DD_OK);
|
| 136 | + return DD_OK;
|
| 137 | +}
|
| 138 | +
|
| 139 | +HRESULT WINAPI glDirectDrawPalette_GetEntries(glDirectDrawPalette *This, DWORD dwFlags, DWORD dwBase, DWORD dwNumEntries, LPPALETTEENTRY lpEntries)
|
| 140 | +{
|
| 141 | + DWORD allentries = 256;
|
| 142 | + DWORD entrysize;
|
| 143 | + TRACE_ENTER(5, 14, This, 9, dwFlags, 8, dwBase, 8, dwNumEntries, 14, lpEntries);
|
| 144 | + if(!This) TRACE_RET(HRESULT,23,DDERR_INVALIDOBJECT);
|
| 145 | + if(This->flags & DDPCAPS_1BIT) allentries=2;
|
| 146 | + if(This->flags & DDPCAPS_2BIT) allentries=4;
|
| 147 | + if(This->flags & DDPCAPS_4BIT) allentries=16;
|
| 148 | + if(This->flags & DDPCAPS_8BIT) allentries=256;
|
| 149 | + if(This->flags & DDPCAPS_8BITENTRIES) entrysize = 1;
|
| 150 | + else entrysize = sizeof(PALETTEENTRY);
|
| 151 | + if((dwBase + dwNumEntries) > allentries) TRACE_RET(HRESULT,23,DDERR_INVALIDPARAMS);
|
| 152 | + memcpy(lpEntries,((char *)This->palette)+(dwBase*entrysize),dwNumEntries*entrysize);
|
| 153 | + TRACE_EXIT(23,DD_OK);
|
| 154 | + return DD_OK;
|
| 155 | +}
|
| 156 | +HRESULT WINAPI glDirectDrawPalette_Initialize(glDirectDrawPalette *This, LPDIRECTDRAW lpDD, DWORD dwFlags, LPPALETTEENTRY lpDDColorTable)
|
| 157 | +{
|
| 158 | + TRACE_ENTER(4,14,This,14,lpDD,9,dwFlags,14,lpDDColorTable);
|
| 159 | + if(!This) TRACE_RET(HRESULT,23,DDERR_INVALIDOBJECT);
|
| 160 | + TRACE_EXIT(23,DDERR_ALREADYINITIALIZED);
|
| 161 | + return DDERR_ALREADYINITIALIZED;
|
| 162 | +}
|
| 163 | +HRESULT WINAPI glDirectDrawPalette_SetEntries(glDirectDrawPalette *This, DWORD dwFlags, DWORD dwStartingEntry, DWORD dwCount, LPPALETTEENTRY lpEntries)
|
| 164 | +{
|
| 165 | + DWORD allentries = 256;
|
| 166 | + DWORD entrysize;
|
| 167 | + TRACE_ENTER(5, 14, This, 9, dwFlags, 8, dwStartingEntry, 8, dwCount, 14, lpEntries);
|
| 168 | + if(!This) TRACE_RET(HRESULT,23,DDERR_INVALIDOBJECT);
|
| 169 | + if(This->flags & DDPCAPS_1BIT) allentries=2;
|
| 170 | + if(This->flags & DDPCAPS_2BIT) allentries=4;
|
| 171 | + if(This->flags & DDPCAPS_4BIT) allentries=16;
|
| 172 | + if(This->flags & DDPCAPS_8BIT) allentries=256;
|
| 173 | + if(This->flags & DDPCAPS_8BITENTRIES) entrysize = 1;
|
| 174 | + else entrysize = sizeof(PALETTEENTRY);
|
| 175 | + if((dwStartingEntry + dwCount) > allentries) TRACE_RET(HRESULT,23,DDERR_INVALIDPARAMS);
|
| 176 | + memcpy(((char *)This->palette)+(dwStartingEntry*entrysize),lpEntries,dwCount*entrysize);
|
| 177 | + TRACE_EXIT(23,DD_OK);
|
| 178 | + return DD_OK;
|
| 179 | +}
|
| 180 | +
|
| 181 | +LPPALETTEENTRY glDirectDrawPalette_GetPalette(glDirectDrawPalette *This, DWORD *flags)
|
| 182 | +{
|
| 183 | + TRACE_ENTER(2,14,This,14,flags);
|
| 184 | + if(flags)
|
| 185 | + {
|
| 186 | + *flags = This->flags;
|
| 187 | + TRACE_VAR("*flags",9,*flags);
|
| 188 | + }
|
| 189 | + TRACE_EXIT(14,This->palette);
|
| 190 | + return This->palette;
|
| 191 | +}
|
| 192 | +
|
| 193 | +glDirectDrawPaletteVtbl glDirectDrawPalette_iface =
|
| 194 | +{
|
| 195 | + glDirectDrawPalette_QueryInterface,
|
| 196 | + glDirectDrawPalette_AddRef,
|
| 197 | + glDirectDrawPalette_Release,
|
| 198 | + glDirectDrawPalette_GetCaps,
|
| 199 | + glDirectDrawPalette_GetEntries,
|
| 200 | + glDirectDrawPalette_Initialize,
|
| 201 | + glDirectDrawPalette_SetEntries
|
| 202 | +};
|
| 203 | +
|
| 204 | +HRESULT glDirectDrawPalette_Create(DWORD dwFlags, LPPALETTEENTRY lpDDColorArray, LPDIRECTDRAWPALETTE FAR *lplpDDPalette)
|
| 205 | +{
|
| 206 | + glDirectDrawPalette *newpal;
|
| 207 | + TRACE_ENTER(3,9,dwFlags,14,lpDDColorArray,14,lplpDDPalette);
|
| 208 | + newpal = (glDirectDrawPalette*)malloc(sizeof(glDirectDrawPalette));
|
| 209 | + if (!lplpDDPalette) TRACE_RET(HRESULT,23,DDERR_INVALIDPARAMS);
|
| 210 | + if (!newpal) TRACE_RET(HRESULT,23,DDERR_OUTOFMEMORY);
|
| 211 | + ZeroMemory(newpal, sizeof(glDirectDrawPalette));
|
| 212 | + newpal->refcount = 1;
|
| 213 | + newpal->flags = dwFlags;
|
| 214 | + newpal->lpVtbl = &glDirectDrawPalette_iface;
|
| 215 | + if(lpDDColorArray == NULL) memcpy(newpal->palette,DefaultPalette,1024);
|
| 216 | + else
|
| 217 | + {
|
| 218 | + if(newpal->flags & DDPCAPS_1BIT)
|
| 219 | + if(newpal->flags & DDPCAPS_8BITENTRIES) memcpy(newpal->palette,lpDDColorArray,2);
|
| 220 | + else memcpy(newpal->palette,lpDDColorArray,2*sizeof(PALETTEENTRY));
|
| 221 | + else if(newpal->flags & DDPCAPS_2BIT)
|
| 222 | + if(newpal->flags & DDPCAPS_8BITENTRIES) memcpy(newpal->palette,lpDDColorArray,4);
|
| 223 | + else memcpy(newpal->palette,lpDDColorArray,4*sizeof(PALETTEENTRY));
|
| 224 | + else if(newpal->flags & DDPCAPS_4BIT)
|
| 225 | + if(newpal->flags & DDPCAPS_8BITENTRIES) memcpy(newpal->palette,lpDDColorArray,16);
|
| 226 | + else memcpy(newpal->palette,lpDDColorArray,16*sizeof(PALETTEENTRY));
|
| 227 | + else memcpy(newpal->palette,lpDDColorArray,256*sizeof(PALETTEENTRY));
|
| 228 | + }
|
| 229 | + if(lplpDDPalette) *lplpDDPalette = (LPDIRECTDRAWPALETTE)newpal;
|
| 230 | + TRACE_EXIT(23,DD_OK);
|
| 231 | + return DD_OK;
|
| 232 | +} |
\ No newline at end of file |
Index: ddraw/glDirectDrawPalette.h |
— | — | @@ -18,27 +18,50 @@ |
19 | 19 | #ifndef _GLDIRECTDRAWPALETTE_H
|
20 | 20 | #define _GLDIRECTDRAWPALETTE_H
|
21 | 21 |
|
22 | | -class glDirectDrawPalette : public IDirectDrawPalette
|
| 22 | +#ifdef __cplusplus
|
| 23 | +extern "C" {
|
| 24 | +#endif
|
| 25 | +
|
| 26 | +struct glDirectDrawPaletteVtbl;
|
| 27 | +
|
| 28 | +typedef struct glDirectDrawPalette
|
23 | 29 | {
|
24 | | -public:
|
25 | | - glDirectDrawPalette(DWORD dwFlags, LPPALETTEENTRY lpDDColorArray, LPDIRECTDRAWPALETTE FAR *lplpDDPalette);
|
26 | | - virtual ~glDirectDrawPalette();
|
27 | | - // DirectDraw (all versions) API
|
28 | | - HRESULT WINAPI QueryInterface(REFIID riid, void** ppvObj);
|
29 | | - ULONG WINAPI AddRef();
|
30 | | - ULONG WINAPI Release();
|
| 30 | + struct glDirectDrawPaletteVtbl *lpVtbl;
|
31 | 31 |
|
32 | | - HRESULT WINAPI GetCaps(LPDWORD lpdwCaps);
|
33 | | - HRESULT WINAPI GetEntries(DWORD dwFlags, DWORD dwBase, DWORD dwNumEntries, LPPALETTEENTRY lpEntries);
|
34 | | - HRESULT WINAPI Initialize(LPDIRECTDRAW lpDD, DWORD dwFlags, LPPALETTEENTRY lpDDColorTable);
|
35 | | - HRESULT WINAPI SetEntries(DWORD dwFlags, DWORD dwStartingEntry, DWORD dwCount, LPPALETTEENTRY lpEntries);
|
36 | | -
|
37 | | - // Internal function
|
38 | | - LPPALETTEENTRY GetPalette(DWORD *flags);
|
39 | | -private:
|
| 32 | + ULONG refcount;
|
40 | 33 | PALETTEENTRY palette[256];
|
41 | 34 | DWORD flags;
|
42 | | - ULONG refcount;
|
43 | | -};
|
| 35 | +} glDirectDrawPalette;
|
44 | 36 |
|
| 37 | +typedef struct glDirectDrawPaletteVtbl
|
| 38 | +{
|
| 39 | + // DirectDraw (all versions) API
|
| 40 | + HRESULT(WINAPI *QueryInterface)(glDirectDrawPalette *This, REFIID riid, void** ppvObj);
|
| 41 | + ULONG(WINAPI *AddRef)(glDirectDrawPalette *This);
|
| 42 | + ULONG(WINAPI *Release)(glDirectDrawPalette *This);
|
| 43 | +
|
| 44 | + HRESULT(WINAPI *GetCaps)(glDirectDrawPalette *This, LPDWORD lpdwCaps);
|
| 45 | + HRESULT(WINAPI *GetEntries)(glDirectDrawPalette *This, DWORD dwFlags, DWORD dwBase, DWORD dwNumEntries, LPPALETTEENTRY lpEntries);
|
| 46 | + HRESULT(WINAPI *Initialize)(glDirectDrawPalette *This, LPDIRECTDRAW lpDD, DWORD dwFlags, LPPALETTEENTRY lpDDColorTable);
|
| 47 | + HRESULT(WINAPI *SetEntries)(glDirectDrawPalette *This, DWORD dwFlags, DWORD dwStartingEntry, DWORD dwCount, LPPALETTEENTRY lpEntries);
|
| 48 | +} glDirectDrawPaletteVtbl;
|
| 49 | +
|
| 50 | +HRESULT glDirectDrawPalette_Create(DWORD dwFlags, LPPALETTEENTRY lpDDColorArray, LPDIRECTDRAWPALETTE FAR *lplpDDPalette);
|
| 51 | +LPPALETTEENTRY glDirectDrawPalette_GetPalette(glDirectDrawPalette *This, DWORD *flags);
|
| 52 | +
|
| 53 | +HRESULT WINAPI glDirectDrawPalette_QueryInterface(glDirectDrawPalette *This, REFIID riid, void** ppvObj);
|
| 54 | +ULONG WINAPI glDirectDrawPalette_AddRef(glDirectDrawPalette *This);
|
| 55 | +ULONG WINAPI glDirectDrawPalette_Release(glDirectDrawPalette *This);
|
| 56 | +HRESULT WINAPI glDirectDrawPalette_GetCaps(glDirectDrawPalette *This, LPDWORD lpdwCaps);
|
| 57 | +HRESULT WINAPI glDirectDrawPalette_GetEntries(glDirectDrawPalette *This, DWORD dwFlags, DWORD dwBase, DWORD dwNumEntries, LPPALETTEENTRY lpEntries);
|
| 58 | +HRESULT WINAPI glDirectDrawPalette_Initialize(glDirectDrawPalette *This, LPDIRECTDRAW lpDD, DWORD dwFlags, LPPALETTEENTRY lpDDColorTable);
|
| 59 | +HRESULT WINAPI glDirectDrawPalette_SetEntries(glDirectDrawPalette *This, DWORD dwFlags, DWORD dwStartingEntry, DWORD dwCount, LPPALETTEENTRY lpEntries);
|
| 60 | +LPPALETTEENTRY glDirectDrawPalette_GetPalette(glDirectDrawPalette *This, DWORD *flags);
|
| 61 | +
|
| 62 | +
|
| 63 | +
|
| 64 | +#ifdef __cplusplus
|
| 65 | +}
|
| 66 | +#endif
|
| 67 | +
|
45 | 68 | #endif //_GLDIRECTDRAWPALETTE_H |
\ No newline at end of file |
Index: ddraw/glDirectDrawSurface.cpp |
— | — | @@ -125,11 +125,11 @@ |
126 | 126 | }
|
127 | 127 | if(ddInterface->GetBPP() == 8)
|
128 | 128 | {
|
129 | | - if(!palettein) palette = new glDirectDrawPalette(DDPCAPS_8BIT|DDPCAPS_ALLOW256|DDPCAPS_PRIMARYSURFACE,NULL,NULL);
|
| 129 | + if (!palettein) glDirectDrawPalette_Create(DDPCAPS_8BIT|DDPCAPS_ALLOW256|DDPCAPS_PRIMARYSURFACE,NULL,(LPDIRECTDRAWPALETTE*)&palette);
|
130 | 130 | else
|
131 | 131 | {
|
132 | 132 | palette = palettein;
|
133 | | - palette->AddRef();
|
| 133 | + glDirectDrawPalette_AddRef(palette);
|
134 | 134 | }
|
135 | 135 | paltex = new TEXTURE;
|
136 | 136 | ZeroMemory(paltex,sizeof(TEXTURE));
|
— | — | @@ -372,7 +372,7 @@ |
373 | 373 | if(fbo.fbo) ddInterface->renderer->DeleteFBO(&fbo);
|
374 | 374 | if(stencilfbo.fbo) ddInterface->renderer->DeleteFBO(&stencilfbo);
|
375 | 375 | if(bitmapinfo) free(bitmapinfo);
|
376 | | - if(palette) palette->Release();
|
| 376 | + if(palette) glDirectDrawPalette_Release(palette);
|
377 | 377 | if(backbuffer) backbuffer->Release();
|
378 | 378 | if(clipper) clipper->Release();
|
379 | 379 | if(buffer) free(buffer);
|
— | — | @@ -919,7 +919,7 @@ |
920 | 920 | {
|
921 | 921 | if(palette) pal = palette;
|
922 | 922 | else pal = ddInterface->primary->palette;
|
923 | | - memcpy(colors,pal->GetPalette(NULL),1024);
|
| 923 | + memcpy(colors, glDirectDrawPalette_GetPalette(pal,NULL), 1024);
|
924 | 924 | for(int i = 0; i < 256; i++)
|
925 | 925 | colors[i] = ((colors[i]&0x0000FF)<<16) | (colors[i]&0x00FF00) | ((colors[i]&0xFF0000)>>16);
|
926 | 926 | memcpy(bitmapinfo->bmiColors,colors,1024);
|
— | — | @@ -960,8 +960,8 @@ |
961 | 961 | HRESULT err;
|
962 | 962 | if(palette)
|
963 | 963 | {
|
964 | | - palette->AddRef();
|
965 | | - *lplpDDPalette = palette;
|
| 964 | + glDirectDrawPalette_AddRef(palette);
|
| 965 | + *lplpDDPalette = (LPDIRECTDRAWPALETTE)palette;
|
966 | 966 | err = DD_OK;
|
967 | 967 | }
|
968 | 968 | else
|
— | — | @@ -1210,13 +1210,13 @@ |
1211 | 1211 | if(!this) TRACE_RET(HRESULT,23,DDERR_INVALIDOBJECT);
|
1212 | 1212 | if(palette)
|
1213 | 1213 | {
|
1214 | | - palette->Release();
|
1215 | | - if(!lpDDPalette) palette = new glDirectDrawPalette(DDPCAPS_8BIT|DDPCAPS_ALLOW256|DDPCAPS_PRIMARYSURFACE,NULL,NULL);
|
| 1214 | + glDirectDrawPalette_Release(palette);
|
| 1215 | + if(!lpDDPalette) glDirectDrawPalette_Create(DDPCAPS_8BIT|DDPCAPS_ALLOW256|DDPCAPS_PRIMARYSURFACE,NULL,(LPDIRECTDRAWPALETTE*)&palette);
|
1216 | 1216 | }
|
1217 | 1217 | if(lpDDPalette)
|
1218 | 1218 | {
|
1219 | 1219 | palette = (glDirectDrawPalette *)lpDDPalette;
|
1220 | | - palette->AddRef();
|
| 1220 | + glDirectDrawPalette_AddRef(palette);
|
1221 | 1221 | }
|
1222 | 1222 | TRACE_EXIT(23,DD_OK);
|
1223 | 1223 | return DD_OK;
|
Index: ddraw/glDirectDrawSurface.h |
— | — | @@ -28,7 +28,7 @@ |
29 | 29 |
|
30 | 30 | class glDirectDraw7;
|
31 | 31 | class glDirectDrawClipper;
|
32 | | -class glDirectDrawPalette;
|
| 32 | +struct glDirectDrawPalette;
|
33 | 33 | class glDirectDrawSurface1;
|
34 | 34 | class glDirectDrawSurface2;
|
35 | 35 | class glDirectDrawSurface3;
|
Index: ddraw/glRenderer.cpp |
— | — | @@ -1145,7 +1145,7 @@ |
1146 | 1146 | {
|
1147 | 1147 | shaders->SetShader(PROG_PAL256,NULL,NULL,0);
|
1148 | 1148 | progtype = PROG_PAL256;
|
1149 | | - texman->_UploadTexture(paltex,0,dest->palette->GetPalette(NULL),256,1);
|
| 1149 | + texman->_UploadTexture(paltex,0,glDirectDrawPalette_GetPalette(dest->palette,NULL),256,1);
|
1150 | 1150 | ext->glUniform1i(shaders->shaders[progtype].tex0,0);
|
1151 | 1151 | ext->glUniform1i(shaders->shaders[progtype].pal,1);
|
1152 | 1152 | texman->SetTexture(0,texture);
|