DXGL r192 - Code Review

Jump to navigation Jump to search
Repository:DXGL
Revision:r191‎ | r192 | r193 >
Date:18:17, 3 July 2012
Author:admin
Status:new
Tags:
Comment:
(DOES NOT BUILD) Add remaining IDirect3DDevice3 functions, must add functions to glDirect3DDevice7 next.
Add IDirect3DTexture2
Modified paths:
  • /ddraw/ddraw.vcxproj (modified) (history)
  • /ddraw/ddraw.vcxproj.filters (modified) (history)
  • /ddraw/glDirect3DDevice.cpp (modified) (history)
  • /ddraw/glDirect3DDevice.h (modified) (history)
  • /ddraw/glDirect3DTexture.cpp (added) (history)
  • /ddraw/glDirect3DTexture.h (added) (history)

Diff [purge]

Index: ddraw/ddraw.vcxproj
@@ -171,6 +171,7 @@
172172 <ClInclude Include="glDirect3DDevice.h" />
173173 <ClInclude Include="glDirect3DLight.h" />
174174 <ClInclude Include="glDirect3DMaterial.h" />
 175+ <ClInclude Include="glDirect3DTexture.h" />
175176 <ClInclude Include="glDirect3DVertexBuffer.h" />
176177 <ClInclude Include="glDirect3DViewport.h" />
177178 <ClInclude Include="glDirectDraw.h" />
@@ -220,6 +221,7 @@
221222 <ClCompile Include="glDirect3DDevice.cpp" />
222223 <ClCompile Include="glDirect3DLight.cpp" />
223224 <ClCompile Include="glDirect3DMaterial.cpp" />
 225+ <ClCompile Include="glDirect3DTexture.cpp" />
224226 <ClCompile Include="glDirect3DVertexBuffer.cpp" />
225227 <ClCompile Include="glDirect3DViewport.cpp" />
226228 <ClCompile Include="glDirectDraw.cpp" />
Index: ddraw/ddraw.vcxproj.filters
@@ -113,6 +113,9 @@
114114 <ClInclude Include="glDirect3DMaterial.h">
115115 <Filter>Header Files</Filter>
116116 </ClInclude>
 117+ <ClInclude Include="glDirect3DTexture.h">
 118+ <Filter>Header Files</Filter>
 119+ </ClInclude>
117120 </ItemGroup>
118121 <ItemGroup>
119122 <ClCompile Include="ddraw.cpp">
@@ -184,6 +187,9 @@
185188 <ClCompile Include="glDirect3DMaterial.cpp">
186189 <Filter>Source Files</Filter>
187190 </ClCompile>
 191+ <ClCompile Include="glDirect3DTexture.cpp">
 192+ <Filter>Source Files</Filter>
 193+ </ClCompile>
188194 </ItemGroup>
189195 <ItemGroup>
190196 <ResourceCompile Include="ddraw.rc">
Index: ddraw/glDirect3DDevice.cpp
@@ -21,6 +21,7 @@
2222 #include "glRenderer.h"
2323 #include "glDirectDraw.h"
2424 #include "glDirectDrawSurface.h"
 25+#include "glDirect3DTexture.h"
2526 #include "glDirect3DMaterial.h"
2627 #include "glDirect3DViewport.h"
2728 #include "glDirect3DVertexBuffer.h"
@@ -1569,14 +1570,68 @@
15701571 if(!this) return DDERR_INVALIDOBJECT;
15711572 return glD3DDev7->MultiplyTransform(dtstTransformStateType,lpD3DMatrix);
15721573 }
1573 - HRESULT WINAPI NextViewport(LPDIRECT3DVIEWPORT3 lpDirect3DViewport, LPDIRECT3DVIEWPORT3 *lplpAnotherViewport, DWORD dwFlags);
1574 - HRESULT WINAPI SetClipStatus(LPD3DCLIPSTATUS lpD3DClipStatus);
1575 - HRESULT WINAPI SetCurrentViewport(LPDIRECT3DVIEWPORT3 lpd3dViewport);
1576 - HRESULT WINAPI SetLightState(D3DLIGHTSTATETYPE dwLightStateType, DWORD dwLightState);
1577 - HRESULT WINAPI SetRenderState(D3DRENDERSTATETYPE dwRendStateType, DWORD dwRenderState);
1578 - HRESULT WINAPI SetRenderTarget(LPDIRECTDRAWSURFACE4 lpNewRenderTarget, DWORD dwFlags);
1579 - HRESULT WINAPI SetTexture(DWORD dwStage, LPDIRECT3DTEXTURE2 lpTexture);
1580 - HRESULT WINAPI SetTextureStageState(DWORD dwStage, D3DTEXTURESTAGESTATETYPE dwState, DWORD dwValue);
1581 - HRESULT WINAPI SetTransform(D3DTRANSFORMSTATETYPE dtstTransformStateType, LPD3DMATRIX lpD3DMatrix);
1582 - HRESULT WINAPI ValidateDevice(LPDWORD lpdwPasses);
1583 - HRESULT WINAPI Vertex(LPVOID lpVertex);
 1574+HRESULT WINAPI glDirect3DDevice3::NextViewport(LPDIRECT3DVIEWPORT3 lpDirect3DViewport, LPDIRECT3DVIEWPORT3 *lplpAnotherViewport, DWORD dwFlags)
 1575+{
 1576+ if(!this) return DDERR_INVALIDOBJECT;
 1577+ return glD3DDev7->NextViewport(lpDirect3DViewport,lplpAnotherViewport,dwFlags);
 1578+}
 1579+
 1580+HRESULT WINAPI glDirect3DDevice3::SetClipStatus(LPD3DCLIPSTATUS lpD3DClipStatus)
 1581+{
 1582+ if(!this) return DDERR_INVALIDOBJECT;
 1583+ return glD3DDev7->SetClipStatus(lpD3DClipStatus);
 1584+}
 1585+
 1586+HRESULT WINAPI glDirect3DDevice3::SetCurrentViewport(LPDIRECT3DVIEWPORT3 lpd3dViewport)
 1587+{
 1588+ if(!this) return DDERR_INVALIDOBJECT;
 1589+ return glD3DDev7->SetCurrentViewport(lpd3dViewport);
 1590+}
 1591+
 1592+HRESULT WINAPI glDirect3DDevice3::SetLightState(D3DLIGHTSTATETYPE dwLightStateType, DWORD dwLightState)
 1593+{
 1594+ if(!this) return DDERR_INVALIDOBJECT;
 1595+ return glD3DDev7->SetLightState(dwLightStateType,dwLightState);
 1596+}
 1597+
 1598+HRESULT WINAPI glDirect3DDevice3::SetRenderState(D3DRENDERSTATETYPE dwRendStateType, DWORD dwRenderState)
 1599+{
 1600+ if(!this) return DDERR_INVALIDOBJECT;
 1601+ return glD3DDev7->SetRenderState(dwRendStateType,dwRenderState);
 1602+}
 1603+
 1604+HRESULT WINAPI glDirect3DDevice3::SetRenderTarget(LPDIRECTDRAWSURFACE4 lpNewRenderTarget, DWORD dwFlags)
 1605+{
 1606+ if(!this) return DDERR_INVALIDOBJECT;
 1607+ return glD3DDev7->SetRenderTarget(((glDirectDrawSurface4*)lpNewRenderTarget)->GetDDS7(),dwFlags);
 1608+}
 1609+
 1610+HRESULT WINAPI glDirect3DDevice3::SetTexture(DWORD dwStage, LPDIRECT3DTEXTURE2 lpTexture)
 1611+{
 1612+ if(!this) return DDERR_INVALIDOBJECT;
 1613+ return glD3DDev7->SetTexture(dwStage,((glDirect3DTexture2*)lpTexture)->GetDDS7());
 1614+}
 1615+
 1616+HRESULT WINAPI glDirect3DDevice3::SetTextureStageState(DWORD dwStage, D3DTEXTURESTAGESTATETYPE dwState, DWORD dwValue)
 1617+{
 1618+ if(!this) return DDERR_INVALIDOBJECT;
 1619+ return glD3DDev7->SetTextureStageState(dwStage,dwState,dwValue);
 1620+}
 1621+
 1622+HRESULT WINAPI glDirect3DDevice3::SetTransform(D3DTRANSFORMSTATETYPE dtstTransformStateType, LPD3DMATRIX lpD3DMatrix)
 1623+{
 1624+ if(!this) return DDERR_INVALIDOBJECT;
 1625+ return glD3DDev7->SetTransform(dtstTransformStateType,lpD3DMatrix);
 1626+}
 1627+
 1628+HRESULT WINAPI glDirect3DDevice3::ValidateDevice(LPDWORD lpdwPasses)
 1629+{
 1630+ if(!this) return DDERR_INVALIDOBJECT;
 1631+ return glD3DDev7->ValidateDevice(lpdwPasses);
 1632+}
 1633+
 1634+HRESULT WINAPI glDirect3DDevice3::Vertex(LPVOID lpVertex)
 1635+{
 1636+ if(!this) return DDERR_INVALIDOBJECT;
 1637+ return glD3DDev7->Vertex(lpVertex);
 1638+}
\ No newline at end of file
Index: ddraw/glDirect3DDevice.h
@@ -127,9 +127,12 @@
128128 D3DMATERIALHANDLE AddMaterial(glDirect3DMaterial3* material);
129129 HRESULT AddViewport(LPDIRECT3DVIEWPORT3 lpDirect3DViewport);
130130 HRESULT DeleteViewport(LPDIRECT3DVIEWPORT3 lpDirect3DViewport);
 131+ HRESULT NextViewport(LPDIRECT3DVIEWPORT3 lpDirect3DViewport, LPDIRECT3DVIEWPORT3 *lplpAnotherViewport, DWORD dwFlags);
 132+ HRESULT SetCurrentViewport(LPDIRECT3DVIEWPORT3 lpd3dViewport);
131133 HRESULT Begin(D3DPRIMITIVETYPE d3dpt, DWORD dwVertexTypeDesc, DWORD dwFlags);
132134 HRESULT BeginIndexed(D3DPRIMITIVETYPE dptPrimitiveType, DWORD dwVertexTypeDesc, LPVOID lpvVertices, DWORD dwNumVertices, DWORD dwFlags);
133135 HRESULT Index(WORD wVertexIndex);
 136+ HRESULT Vertex(LPVOID lpVertex);
134137 HRESULT End(DWORD dwFlags);
135138 HRESULT ComputeSphereVisibility3(LPD3DVECTOR lpCenters, LPD3DVALUE lpRadii, DWORD dwNumSpheres, DWORD dwFlags, LPDWORD lpdwReturnValues);
136139 HRESULT GetCaps3(LPD3DDEVICEDESC lpD3DHWDevDesc, LPD3DDEVICEDESC lpD3DHELDevDesc);
Index: ddraw/glDirect3DTexture.cpp
@@ -0,0 +1,78 @@
 2+// DXGL
 3+// Copyright (C) 2012 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 "glRenderer.h"
 21+#include "glDirectDraw.h"
 22+#include "glDirectDrawSurface.h"
 23+#include "glDirect3DTexture.h"
 24+
 25+glDirect3DTexture2::glDirect3DTexture2(glDirectDrawSurface7 *glDDS7)
 26+{
 27+ this->glDDS7 = glDDS7;
 28+ refcount = 1;
 29+}
 30+
 31+glDirect3DTexture2::~glDirect3DTexture2()
 32+{
 33+ glDDS7->Release();
 34+}
 35+
 36+HRESULT WINAPI glDirect3DTexture2::QueryInterface(REFIID riid, void** ppvObj)
 37+{
 38+ if(!this) return DDERR_INVALIDPARAMS;
 39+ if(riid == IID_IUnknown)
 40+ {
 41+ this->AddRef();
 42+ *ppvObj = this;
 43+ return DD_OK;
 44+ }
 45+ return glDDS7->QueryInterface(riid,ppvObj);
 46+}
 47+
 48+ULONG WINAPI glDirect3DTexture2::AddRef()
 49+{
 50+ if(!this) return 0;
 51+ refcount++;
 52+ return refcount;
 53+}
 54+
 55+ULONG WINAPI glDirect3DTexture2::Release()
 56+{
 57+ if(!this) return 0;
 58+ ULONG ret;
 59+ refcount--;
 60+ ret = refcount;
 61+ if(refcount == 0) delete this;
 62+ return ret;
 63+}
 64+
 65+HRESULT WINAPI glDirect3DTexture2::GetHandle(LPDIRECT3DDEVICE2 lpDirect3DDevice2, LPD3DTEXTUREHANDLE lpHandle)
 66+{
 67+ if(!this) return DDERR_INVALIDOBJECT;
 68+ FIXME("glDirect3DTexture2::GetHandle: stub");
 69+}
 70+HRESULT WINAPI glDirect3DTexture2::Load(LPDIRECT3DTEXTURE2 lpD3DTexture2)
 71+{
 72+ if(!this) return DDERR_INVALIDOBJECT;
 73+ FIXME("glDirect3DTexture2::Load: stub");
 74+}
 75+HRESULT WINAPI glDirect3DTexture2::PaletteChanged(DWORD dwStart, DWORD dwCount)
 76+{
 77+ if(!this) return DDERR_INVALIDOBJECT;
 78+ FIXME("glDirect3DTexture2::PaletteChanged: stub");
 79+}
Index: ddraw/glDirect3DTexture.h
@@ -0,0 +1,39 @@
 2+// DXGL
 3+// Copyright (C) 2012 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 __GLDIRECT3DTEXTURE_H
 21+#define __GLDIRECT3DTEXTURE_H
 22+
 23+class glDirect3DTexture2 : public IDirect3DTexture2
 24+{
 25+public:
 26+ glDirect3DTexture2(glDirectDrawSurface7 *glDDS7);
 27+ virtual ~glDirect3DTexture2();
 28+ HRESULT WINAPI QueryInterface(REFIID riid, void** ppvObj);
 29+ ULONG WINAPI AddRef();
 30+ ULONG WINAPI Release();
 31+ HRESULT WINAPI GetHandle(LPDIRECT3DDEVICE2 lpDirect3DDevice2, LPD3DTEXTUREHANDLE lpHandle);
 32+ HRESULT WINAPI Load(LPDIRECT3DTEXTURE2 lpD3DTexture2);
 33+ HRESULT WINAPI PaletteChanged(DWORD dwStart, DWORD dwCount);
 34+ glDirectDrawSurface7 *GetDDS7(){return glDDS7;}
 35+private:
 36+ glDirectDrawSurface7 *glDDS7;
 37+ ULONG refcount;
 38+};
 39+
 40+#endif //__GLDIRECT3DTEXTURE_H
\ No newline at end of file