DXGL r440 - Code Review

Jump to navigation Jump to search
Repository:DXGL
Revision:r439‎ | r440 | r441 >
Date:19:36, 17 May 2014
Author:admin
Status:new
Tags:
Comment:
Convert glDirectDrawPalette to C.
Fix precompiled header errors in ddraw project.
Modified paths:
  • /ddraw/ddraw.vcxproj (modified) (history)
  • /ddraw/ddraw.vcxproj.filters (modified) (history)
  • /ddraw/glDirectDraw.cpp (modified) (history)
  • /ddraw/glDirectDrawPalette.c (added) (history)
  • /ddraw/glDirectDrawPalette.cpp (deleted) (history)
  • /ddraw/glDirectDrawPalette.h (modified) (history)
  • /ddraw/glDirectDrawSurface.cpp (modified) (history)
  • /ddraw/glDirectDrawSurface.h (modified) (history)
  • /ddraw/glRenderer.cpp (modified) (history)

Diff [purge]

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 @@
344344 <ClCompile Include="glDirect3DViewport.cpp" />
345345 <ClCompile Include="glDirectDraw.cpp" />
346346 <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>
348355 <ClCompile Include="glDirectDrawSurface.cpp" />
349356 <ClCompile Include="glExtensions.c">
350357 <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>
351363 </ClCompile>
352364 <ClCompile Include="glRenderer.cpp" />
353365 <ClCompile Include="glRenderWindow.cpp" />
@@ -368,6 +380,11 @@
369381 <ClCompile Include="timer.cpp" />
370382 <ClCompile Include="trace.c">
371383 <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>
372389 </ClCompile>
373390 <ClCompile Include="util.cpp" />
374391 </ItemGroup>
Index: ddraw/ddraw.vcxproj.filters
@@ -154,9 +154,6 @@
155155 <ClCompile Include="glDirectDrawClipper.cpp">
156156 <Filter>Source Files</Filter>
157157 </ClCompile>
158 - <ClCompile Include="glDirectDrawPalette.cpp">
159 - <Filter>Source Files</Filter>
160 - </ClCompile>
161158 <ClCompile Include="precomp.cpp">
162159 <Filter>Source Files</Filter>
163160 </ClCompile>
@@ -229,6 +226,9 @@
230227 <ClCompile Include="trace.c">
231228 <Filter>Source Files</Filter>
232229 </ClCompile>
 230+ <ClCompile Include="glDirectDrawPalette.c">
 231+ <Filter>Source Files</Filter>
 232+ </ClCompile>
233233 </ItemGroup>
234234 <ItemGroup>
235235 <ResourceCompile Include="ddraw.rc">
Index: ddraw/glDirectDraw.cpp
@@ -822,10 +822,10 @@
823823 if(!this) TRACE_RET(HRESULT,23,DDERR_INVALIDOBJECT);
824824 if(!lplpDDPalette) TRACE_RET(HRESULT,23,DDERR_INVALIDPARAMS);
825825 if(pUnkOuter) TRACE_RET(HRESULT,23,DDERR_INVALIDPARAMS);
826 - glDirectDrawPalette *pal = new glDirectDrawPalette(dwFlags,lpDDColorArray,lplpDDPalette);
 826+ HRESULT ret = glDirectDrawPalette_Create(dwFlags, lpDDColorArray, lplpDDPalette);
827827 TRACE_VAR("*lplpDDPalette",14,*lplpDDPalette);
828 - TRACE_EXIT(23,DD_OK);
829 - return DD_OK;
 828+ TRACE_EXIT(23,ret);
 829+ return ret;
830830 }
831831
832832 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 @@
1919 #ifndef _GLDIRECTDRAWPALETTE_H
2020 #define _GLDIRECTDRAWPALETTE_H
2121
22 -class glDirectDrawPalette : public IDirectDrawPalette
 22+#ifdef __cplusplus
 23+extern "C" {
 24+#endif
 25+
 26+struct glDirectDrawPaletteVtbl;
 27+
 28+typedef struct glDirectDrawPalette
2329 {
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;
3131
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;
4033 PALETTEENTRY palette[256];
4134 DWORD flags;
42 - ULONG refcount;
43 -};
 35+} glDirectDrawPalette;
4436
 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+
4568 #endif //_GLDIRECTDRAWPALETTE_H
\ No newline at end of file
Index: ddraw/glDirectDrawSurface.cpp
@@ -125,11 +125,11 @@
126126 }
127127 if(ddInterface->GetBPP() == 8)
128128 {
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);
130130 else
131131 {
132132 palette = palettein;
133 - palette->AddRef();
 133+ glDirectDrawPalette_AddRef(palette);
134134 }
135135 paltex = new TEXTURE;
136136 ZeroMemory(paltex,sizeof(TEXTURE));
@@ -372,7 +372,7 @@
373373 if(fbo.fbo) ddInterface->renderer->DeleteFBO(&fbo);
374374 if(stencilfbo.fbo) ddInterface->renderer->DeleteFBO(&stencilfbo);
375375 if(bitmapinfo) free(bitmapinfo);
376 - if(palette) palette->Release();
 376+ if(palette) glDirectDrawPalette_Release(palette);
377377 if(backbuffer) backbuffer->Release();
378378 if(clipper) clipper->Release();
379379 if(buffer) free(buffer);
@@ -919,7 +919,7 @@
920920 {
921921 if(palette) pal = palette;
922922 else pal = ddInterface->primary->palette;
923 - memcpy(colors,pal->GetPalette(NULL),1024);
 923+ memcpy(colors, glDirectDrawPalette_GetPalette(pal,NULL), 1024);
924924 for(int i = 0; i < 256; i++)
925925 colors[i] = ((colors[i]&0x0000FF)<<16) | (colors[i]&0x00FF00) | ((colors[i]&0xFF0000)>>16);
926926 memcpy(bitmapinfo->bmiColors,colors,1024);
@@ -960,8 +960,8 @@
961961 HRESULT err;
962962 if(palette)
963963 {
964 - palette->AddRef();
965 - *lplpDDPalette = palette;
 964+ glDirectDrawPalette_AddRef(palette);
 965+ *lplpDDPalette = (LPDIRECTDRAWPALETTE)palette;
966966 err = DD_OK;
967967 }
968968 else
@@ -1210,13 +1210,13 @@
12111211 if(!this) TRACE_RET(HRESULT,23,DDERR_INVALIDOBJECT);
12121212 if(palette)
12131213 {
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);
12161216 }
12171217 if(lpDDPalette)
12181218 {
12191219 palette = (glDirectDrawPalette *)lpDDPalette;
1220 - palette->AddRef();
 1220+ glDirectDrawPalette_AddRef(palette);
12211221 }
12221222 TRACE_EXIT(23,DD_OK);
12231223 return DD_OK;
Index: ddraw/glDirectDrawSurface.h
@@ -28,7 +28,7 @@
2929
3030 class glDirectDraw7;
3131 class glDirectDrawClipper;
32 -class glDirectDrawPalette;
 32+struct glDirectDrawPalette;
3333 class glDirectDrawSurface1;
3434 class glDirectDrawSurface2;
3535 class glDirectDrawSurface3;
Index: ddraw/glRenderer.cpp
@@ -1145,7 +1145,7 @@
11461146 {
11471147 shaders->SetShader(PROG_PAL256,NULL,NULL,0);
11481148 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);
11501150 ext->glUniform1i(shaders->shaders[progtype].tex0,0);
11511151 ext->glUniform1i(shaders->shaders[progtype].pal,1);
11521152 texman->SetTexture(0,texture);