2 * Copyright (C) 2005-2013 Team XBMC
5 * This Program is free software; you can redistribute it and/or modify
6 * it under the terms of the GNU General Public License as published by
7 * the Free Software Foundation; either version 2, or (at your option)
10 * This Program 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
13 * GNU General Public License for more details.
15 * You should have received a copy of the GNU General Public License
16 * along with XBMC; see the file COPYING. If not, see
17 * <http://www.gnu.org/licenses/>.
24 #include "utils/StdString.h"
30 virtual ~ID3DResource() {};
32 virtual void OnDestroyDevice()=0;
33 virtual void OnCreateDevice()=0;
34 virtual void OnLostDevice() {};
35 virtual void OnResetDevice() {};
38 class CD3DTexture : public ID3DResource
44 bool Create(UINT width, UINT height, UINT mipLevels, DWORD usage, D3DFORMAT format, D3DPOOL pool);
46 bool LockRect(UINT level, D3DLOCKED_RECT *lr, const RECT *rect, DWORD flags);
47 bool UnlockRect(UINT level);
48 bool GetLevelDesc(UINT level, D3DSURFACE_DESC *desc);
49 bool GetSurfaceLevel(UINT level, LPDIRECT3DSURFACE9 *surface);
52 LPDIRECT3DTEXTURE9 Get() const { return m_texture; };
53 UINT GetWidth() { return m_width; }
54 UINT GetHeight() { return m_height; }
56 virtual void OnDestroyDevice();
57 virtual void OnCreateDevice();
58 virtual void OnLostDevice();
59 virtual void OnResetDevice();
63 unsigned int GetMemoryUsage(unsigned int pitch) const;
66 void RestoreTexture();
68 // creation parameters
78 LPDIRECT3DTEXTURE9 m_texture;
84 typedef std::map<CStdString, CStdString> DefinesMap;
86 class CD3DEffect : public ID3DResource
90 virtual ~CD3DEffect();
91 bool Create(const CStdString &effectString, DefinesMap* defines);
93 bool SetFloatArray(D3DXHANDLE handle, const float* val, unsigned int count);
94 bool SetMatrix(D3DXHANDLE handle, const D3DXMATRIX* mat);
95 bool SetTechnique(D3DXHANDLE handle);
96 bool SetTexture(D3DXHANDLE handle, CD3DTexture &texture);
97 bool Begin(UINT *passes, DWORD flags);
98 bool BeginPass(UINT pass);
102 ID3DXEffect *Get() const { return m_effect; };
104 virtual void OnDestroyDevice();
105 virtual void OnCreateDevice();
106 virtual void OnLostDevice();
107 virtual void OnResetDevice();
110 CStdString m_effectString;
111 ID3DXEffect *m_effect;
112 DefinesMap m_defines;
115 class CD3DVertexBuffer : public ID3DResource
119 virtual ~CD3DVertexBuffer();
120 bool Create(UINT length, DWORD usage, DWORD fvf, D3DPOOL pool);
122 bool Lock(UINT offset, UINT size, void **data, DWORD flags);
125 LPDIRECT3DVERTEXBUFFER9 Get() const { return m_vertex; };
127 virtual void OnDestroyDevice();
128 virtual void OnCreateDevice();
130 bool CreateVertexBuffer();
135 LPDIRECT3DVERTEXBUFFER9 m_vertex;