aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorCrystalPT <CrystalPT@svn>2010-06-18 22:51:36 +0000
committerCrystalPT <CrystalPT@svn>2010-06-18 22:51:36 +0000
commitc34b0e0885aa190f5cb02752d0990f710b4c0546 (patch)
tree797e4dcd3e40667e65fc19274ef996bd7e66fbc6
parent7e75ee6f322d338e5093f2a3f3a3718d1294f57d (diff)
changed: set eol-style native
git-svn-id: https://xbmc.svn.sourceforge.net/svnroot/xbmc/trunk@31189 568bbfeb-2a22-0410-94d2-cc84cf5bfa90
-rw-r--r--guilib/D3DResource.cpp840
-rw-r--r--guilib/D3DResource.h266
-rw-r--r--guilib/DDSImage.h284
3 files changed, 695 insertions, 695 deletions
diff --git a/guilib/D3DResource.cpp b/guilib/D3DResource.cpp
index def32df0e1..bc17c72ab3 100644
--- a/guilib/D3DResource.cpp
+++ b/guilib/D3DResource.cpp
@@ -1,420 +1,420 @@
-/*
-* Copyright (C) 2005-2008 Team XBMC
-* http://www.xbmc.org
-*
-* This Program is free software; you can redistribute it and/or modify
-* it under the terms of the GNU General Public License as published by
-* the Free Software Foundation; either version 2, or (at your option)
-* any later version.
-*
-* This Program is distributed in the hope that it will be useful,
-* but WITHOUT ANY WARRANTY; without even the implied warranty of
-* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-* GNU General Public License for more details.
-*
-* You should have received a copy of the GNU General Public License
-* along with XBMC; see the file COPYING. If not, write to
-* the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.
-* http://www.gnu.org/copyleft/gpl.html
-*
-*/
-
-#include "system.h"
-#include "D3DResource.h"
-#include "WindowingFactory.h"
-#include "utils/log.h"
-
-#ifdef HAS_DX
-
-CD3DTexture::CD3DTexture()
-{
- m_width = 0;
- m_height = 0;
- m_mipLevels = 0;
- m_usage = 0;
- m_format = D3DFMT_A8R8G8B8;
- m_pool = D3DPOOL_DEFAULT;
- m_texture = NULL;
- m_data = NULL;
- m_pitch = 0;
-}
-
-CD3DTexture::~CD3DTexture()
-{
- Release();
- delete[] m_data;
-}
-
-bool CD3DTexture::Create(UINT width, UINT height, UINT mipLevels, DWORD usage, D3DFORMAT format, D3DPOOL pool)
-{
- m_width = width;
- m_height = height;
- m_mipLevels = mipLevels;
- m_usage = usage;
- m_format = format;
- m_pool = pool;
- // create the texture
- Release();
- HRESULT hr = D3DXCreateTexture(g_Windowing.Get3DDevice(), m_width, m_height, m_mipLevels, m_usage, m_format, m_pool, &m_texture);
- if (FAILED(hr))
- {
- CLog::Log(LOGERROR, __FUNCTION__" - failed 0x%08X", hr);
- }
- else
- {
- D3DSURFACE_DESC desc;
- if( D3D_OK == m_texture->GetLevelDesc(0, &desc))
- {
- if(desc.Format != m_format)
- CLog::Log(LOGWARNING, "CD3DTexture::Create - format changed from %d to %d", m_format, desc.Format);
- if(desc.Height != m_height || desc.Width != m_width)
- CLog::Log(LOGWARNING, "CD3DTexture::Create - size changed from %ux%u to %ux%u", m_width, m_height, desc.Width, desc.Height);
- }
-
- g_Windowing.Register(this);
- return true;
- }
- return false;
-}
-
-void CD3DTexture::Release()
-{
- g_Windowing.Unregister(this);
- SAFE_RELEASE(m_texture);
-}
-
-bool CD3DTexture::LockRect(UINT level, D3DLOCKED_RECT *lr, const RECT *rect, DWORD flags)
-{
- if (m_texture)
- return (D3D_OK == m_texture->LockRect(level, lr, rect, flags));
- return false;
-}
-
-void CD3DTexture::UnlockRect(UINT level)
-{
- if (m_texture)
- m_texture->UnlockRect(level);
-}
-
-bool CD3DTexture::GetLevelDesc(UINT level, D3DSURFACE_DESC *desc)
-{
- if (m_texture)
- return (D3D_OK == m_texture->GetLevelDesc(level, desc));
- return false;
-}
-
-bool CD3DTexture::GetSurfaceLevel(UINT level, LPDIRECT3DSURFACE9 *surface)
-{
- if (m_texture)
- return (D3D_OK == m_texture->GetSurfaceLevel(level, surface));
- return false;
-}
-
-void CD3DTexture::SaveTexture()
-{
- if (m_texture)
- {
- delete[] m_data;
- m_data = NULL;
- D3DLOCKED_RECT lr;
- if (LockRect( 0, &lr, NULL, 0 ))
- {
- m_pitch = lr.Pitch;
- unsigned int memUsage = GetMemoryUsage(lr.Pitch);
- m_data = new unsigned char[memUsage];
- memcpy(m_data, lr.pBits, memUsage);
- UnlockRect(0);
- }
- }
- SAFE_RELEASE(m_texture);
-}
-
-void CD3DTexture::OnDestroyDevice()
-{
- SaveTexture();
-}
-
-void CD3DTexture::OnLostDevice()
-{
- if (m_pool == D3DPOOL_DEFAULT)
- SaveTexture();
-}
-
-void CD3DTexture::RestoreTexture()
-{
- // yay, we're back - make a new copy of the texture
- if (!m_texture)
- {
- HRESULT hr = D3DXCreateTexture(g_Windowing.Get3DDevice(), m_width, m_height, m_mipLevels, m_usage, m_format, m_pool, &m_texture);
- if (FAILED(hr))
- {
- CLog::Log(LOGERROR, __FUNCTION__": D3DXCreateTexture failed 0x%08X", hr);
- }
- else
- {
- // copy the data to the texture
- D3DLOCKED_RECT lr;
- if (m_texture && m_data && LockRect(0, &lr, NULL, 0 ))
- {
- if (lr.Pitch == m_pitch)
- memcpy(lr.pBits, m_data, GetMemoryUsage(lr.Pitch));
- else
- {
- UINT minpitch = ((UINT)lr.Pitch < m_pitch) ? lr.Pitch : m_pitch;
-
- for(UINT i = 0; i < m_height; ++i)
- {
- // Get pointers to the "rows" of pixels in texture
- BYTE* pBits = (BYTE*)lr.pBits + i*lr.Pitch;
- BYTE* pData = m_data + i*m_pitch;
- memcpy(pBits, pData, minpitch);
- }
- }
- UnlockRect(0);
- }
- }
-
- delete[] m_data;
- m_data = NULL;
- m_pitch = 0;
- }
-}
-
-void CD3DTexture::OnCreateDevice()
-{
- RestoreTexture();
-}
-
-void CD3DTexture::OnResetDevice()
-{
- if (m_pool == D3DPOOL_DEFAULT)
- RestoreTexture();
-}
-
-
-unsigned int CD3DTexture::GetMemoryUsage(unsigned int pitch) const
-{
- switch (m_format)
- {
- case D3DFMT_DXT1:
- case D3DFMT_DXT3:
- case D3DFMT_DXT5:
- return pitch * m_height / 4;
- default:
- return pitch * m_height;
- }
-}
-
-CD3DEffect::CD3DEffect()
-{
- m_effect = NULL;
-}
-
-CD3DEffect::~CD3DEffect()
-{
- Release();
-}
-
-bool CD3DEffect::Create(const CStdString &effectString)
-{
- m_effectString = effectString;
- Release();
- if (CreateEffect())
- {
- g_Windowing.Register(this);
- return true;
- }
- return false;
-}
-
-void CD3DEffect::Release()
-{
- g_Windowing.Unregister(this);
- SAFE_RELEASE(m_effect);
-}
-
-void CD3DEffect::OnDestroyDevice()
-{
- SAFE_RELEASE(m_effect);
-}
-
-void CD3DEffect::OnCreateDevice()
-{
- CreateEffect();
-}
-
-bool CD3DEffect::SetFloatArray(D3DXHANDLE handle, const float* val, unsigned int count)
-{
- if(m_effect)
- return (D3D_OK == m_effect->SetFloatArray(handle, val, count));
- return false;
-}
-
-bool CD3DEffect::SetMatrix(D3DXHANDLE handle, const D3DXMATRIX* mat)
-{
- if (m_effect)
- return (D3D_OK == m_effect->SetMatrix(handle, mat));
- return false;
-}
-
-bool CD3DEffect::SetTechnique(D3DXHANDLE handle)
-{
- if (m_effect)
- return (D3D_OK == m_effect->SetTechnique(handle));
- return false;
-}
-
-bool CD3DEffect::SetTexture(D3DXHANDLE handle, CD3DTexture &texture)
-{
- if (m_effect)
- return (D3D_OK == m_effect->SetTexture(handle, texture.Get()));
- return false;
-}
-
-bool CD3DEffect::Begin(UINT *passes, DWORD flags)
-{
- if (m_effect)
- return (D3D_OK == m_effect->Begin(passes, flags));
- return false;
-}
-
-bool CD3DEffect::BeginPass(UINT pass)
-{
- if (m_effect)
- return (D3D_OK == m_effect->BeginPass(pass));
- return false;
-}
-
-void CD3DEffect::EndPass()
-{
- if (m_effect)
- m_effect->EndPass();
-}
-
-void CD3DEffect::End()
-{
- if (m_effect)
- m_effect->End();
-}
-
-bool CD3DEffect::CreateEffect()
-{
- HRESULT hr;
- LPD3DXBUFFER pError = NULL;
- hr = D3DXCreateEffect(g_Windowing.Get3DDevice(), m_effectString, m_effectString.length(), NULL, NULL, 0, NULL, &m_effect, &pError );
- if(hr == S_OK)
- return true;
- else if(pError)
- {
- CStdString error;
- error.assign((const char*)pError->GetBufferPointer(), pError->GetBufferSize());
- CLog::Log(LOGERROR, "%s", error.c_str());
- }
- return false;
-}
-
-void CD3DEffect::OnLostDevice()
-{
- if (m_effect)
- m_effect->OnLostDevice();
-}
-
-void CD3DEffect::OnResetDevice()
-{
- if (m_effect)
- m_effect->OnResetDevice();
-}
-
-CD3DVertexBuffer::CD3DVertexBuffer()
-{
- m_length = 0;
- m_usage = 0;
- m_fvf = 0;
- m_pool = D3DPOOL_DEFAULT;
- m_vertex = NULL;
- m_data = NULL;
-}
-
-CD3DVertexBuffer::~CD3DVertexBuffer()
-{
- Release();
- delete[] m_data;
-}
-
-bool CD3DVertexBuffer::Create(UINT length, DWORD usage, DWORD fvf, D3DPOOL pool)
-{
- m_length = length;
- m_usage = usage;
- m_fvf = fvf;
- m_pool = pool;
-
- // create the vertex buffer
- Release();
- if (CreateVertexBuffer())
- {
- g_Windowing.Register(this);
- return true;
- }
- return false;
-}
-
-void CD3DVertexBuffer::Release()
-{
- g_Windowing.Unregister(this);
- SAFE_RELEASE(m_vertex);
-}
-
-bool CD3DVertexBuffer::Lock(UINT level, UINT size, void **data, DWORD flags)
-{
- if (m_vertex)
- return (D3D_OK == m_vertex->Lock(level, size, data, flags));
- return false;
-}
-
-void CD3DVertexBuffer::Unlock()
-{
- if (m_vertex)
- m_vertex->Unlock();
-}
-
-void CD3DVertexBuffer::OnDestroyDevice()
-{
- if (m_vertex)
- {
- delete[] m_data;
- m_data = NULL;
- void* data;
- if (Lock(0, 0, &data, 0))
- {
- m_data = new BYTE[m_length];
- memcpy(m_data, data, m_length);
- Unlock();
- }
- }
- SAFE_RELEASE(m_vertex);
-}
-
-void CD3DVertexBuffer::OnCreateDevice()
-{
- // yay, we're back - make a new copy of the vertices
- if (!m_vertex && m_data && CreateVertexBuffer())
- {
- void *data = NULL;
- if (Lock(0, 0, &data, 0))
- {
- memcpy(data, m_data, m_length);
- Unlock();
- }
- delete[] m_data;
- m_data = NULL;
- }
-}
-
-bool CD3DVertexBuffer::CreateVertexBuffer()
-{
- if (D3D_OK == g_Windowing.Get3DDevice()->CreateVertexBuffer(m_length, m_usage, m_fvf, m_pool, &m_vertex, NULL))
- return true;
- return false;
-}
-
-#endif
+/*
+* Copyright (C) 2005-2008 Team XBMC
+* http://www.xbmc.org
+*
+* This Program is free software; you can redistribute it and/or modify
+* it under the terms of the GNU General Public License as published by
+* the Free Software Foundation; either version 2, or (at your option)
+* any later version.
+*
+* This Program is distributed in the hope that it will be useful,
+* but WITHOUT ANY WARRANTY; without even the implied warranty of
+* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+* GNU General Public License for more details.
+*
+* You should have received a copy of the GNU General Public License
+* along with XBMC; see the file COPYING. If not, write to
+* the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.
+* http://www.gnu.org/copyleft/gpl.html
+*
+*/
+
+#include "system.h"
+#include "D3DResource.h"
+#include "WindowingFactory.h"
+#include "utils/log.h"
+
+#ifdef HAS_DX
+
+CD3DTexture::CD3DTexture()
+{
+ m_width = 0;
+ m_height = 0;
+ m_mipLevels = 0;
+ m_usage = 0;
+ m_format = D3DFMT_A8R8G8B8;
+ m_pool = D3DPOOL_DEFAULT;
+ m_texture = NULL;
+ m_data = NULL;
+ m_pitch = 0;
+}
+
+CD3DTexture::~CD3DTexture()
+{
+ Release();
+ delete[] m_data;
+}
+
+bool CD3DTexture::Create(UINT width, UINT height, UINT mipLevels, DWORD usage, D3DFORMAT format, D3DPOOL pool)
+{
+ m_width = width;
+ m_height = height;
+ m_mipLevels = mipLevels;
+ m_usage = usage;
+ m_format = format;
+ m_pool = pool;
+ // create the texture
+ Release();
+ HRESULT hr = D3DXCreateTexture(g_Windowing.Get3DDevice(), m_width, m_height, m_mipLevels, m_usage, m_format, m_pool, &m_texture);
+ if (FAILED(hr))
+ {
+ CLog::Log(LOGERROR, __FUNCTION__" - failed 0x%08X", hr);
+ }
+ else
+ {
+ D3DSURFACE_DESC desc;
+ if( D3D_OK == m_texture->GetLevelDesc(0, &desc))
+ {
+ if(desc.Format != m_format)
+ CLog::Log(LOGWARNING, "CD3DTexture::Create - format changed from %d to %d", m_format, desc.Format);
+ if(desc.Height != m_height || desc.Width != m_width)
+ CLog::Log(LOGWARNING, "CD3DTexture::Create - size changed from %ux%u to %ux%u", m_width, m_height, desc.Width, desc.Height);
+ }
+
+ g_Windowing.Register(this);
+ return true;
+ }
+ return false;
+}
+
+void CD3DTexture::Release()
+{
+ g_Windowing.Unregister(this);
+ SAFE_RELEASE(m_texture);
+}
+
+bool CD3DTexture::LockRect(UINT level, D3DLOCKED_RECT *lr, const RECT *rect, DWORD flags)
+{
+ if (m_texture)
+ return (D3D_OK == m_texture->LockRect(level, lr, rect, flags));
+ return false;
+}
+
+void CD3DTexture::UnlockRect(UINT level)
+{
+ if (m_texture)
+ m_texture->UnlockRect(level);
+}
+
+bool CD3DTexture::GetLevelDesc(UINT level, D3DSURFACE_DESC *desc)
+{
+ if (m_texture)
+ return (D3D_OK == m_texture->GetLevelDesc(level, desc));
+ return false;
+}
+
+bool CD3DTexture::GetSurfaceLevel(UINT level, LPDIRECT3DSURFACE9 *surface)
+{
+ if (m_texture)
+ return (D3D_OK == m_texture->GetSurfaceLevel(level, surface));
+ return false;
+}
+
+void CD3DTexture::SaveTexture()
+{
+ if (m_texture)
+ {
+ delete[] m_data;
+ m_data = NULL;
+ D3DLOCKED_RECT lr;
+ if (LockRect( 0, &lr, NULL, 0 ))
+ {
+ m_pitch = lr.Pitch;
+ unsigned int memUsage = GetMemoryUsage(lr.Pitch);
+ m_data = new unsigned char[memUsage];
+ memcpy(m_data, lr.pBits, memUsage);
+ UnlockRect(0);
+ }
+ }
+ SAFE_RELEASE(m_texture);
+}
+
+void CD3DTexture::OnDestroyDevice()
+{
+ SaveTexture();
+}
+
+void CD3DTexture::OnLostDevice()
+{
+ if (m_pool == D3DPOOL_DEFAULT)
+ SaveTexture();
+}
+
+void CD3DTexture::RestoreTexture()
+{
+ // yay, we're back - make a new copy of the texture
+ if (!m_texture)
+ {
+ HRESULT hr = D3DXCreateTexture(g_Windowing.Get3DDevice(), m_width, m_height, m_mipLevels, m_usage, m_format, m_pool, &m_texture);
+ if (FAILED(hr))
+ {
+ CLog::Log(LOGERROR, __FUNCTION__": D3DXCreateTexture failed 0x%08X", hr);
+ }
+ else
+ {
+ // copy the data to the texture
+ D3DLOCKED_RECT lr;
+ if (m_texture && m_data && LockRect(0, &lr, NULL, 0 ))
+ {
+ if (lr.Pitch == m_pitch)
+ memcpy(lr.pBits, m_data, GetMemoryUsage(lr.Pitch));
+ else
+ {
+ UINT minpitch = ((UINT)lr.Pitch < m_pitch) ? lr.Pitch : m_pitch;
+
+ for(UINT i = 0; i < m_height; ++i)
+ {
+ // Get pointers to the "rows" of pixels in texture
+ BYTE* pBits = (BYTE*)lr.pBits + i*lr.Pitch;
+ BYTE* pData = m_data + i*m_pitch;
+ memcpy(pBits, pData, minpitch);
+ }
+ }
+ UnlockRect(0);
+ }
+ }
+
+ delete[] m_data;
+ m_data = NULL;
+ m_pitch = 0;
+ }
+}
+
+void CD3DTexture::OnCreateDevice()
+{
+ RestoreTexture();
+}
+
+void CD3DTexture::OnResetDevice()
+{
+ if (m_pool == D3DPOOL_DEFAULT)
+ RestoreTexture();
+}
+
+
+unsigned int CD3DTexture::GetMemoryUsage(unsigned int pitch) const
+{
+ switch (m_format)
+ {
+ case D3DFMT_DXT1:
+ case D3DFMT_DXT3:
+ case D3DFMT_DXT5:
+ return pitch * m_height / 4;
+ default:
+ return pitch * m_height;
+ }
+}
+
+CD3DEffect::CD3DEffect()
+{
+ m_effect = NULL;
+}
+
+CD3DEffect::~CD3DEffect()
+{
+ Release();
+}
+
+bool CD3DEffect::Create(const CStdString &effectString)
+{
+ m_effectString = effectString;
+ Release();
+ if (CreateEffect())
+ {
+ g_Windowing.Register(this);
+ return true;
+ }
+ return false;
+}
+
+void CD3DEffect::Release()
+{
+ g_Windowing.Unregister(this);
+ SAFE_RELEASE(m_effect);
+}
+
+void CD3DEffect::OnDestroyDevice()
+{
+ SAFE_RELEASE(m_effect);
+}
+
+void CD3DEffect::OnCreateDevice()
+{
+ CreateEffect();
+}
+
+bool CD3DEffect::SetFloatArray(D3DXHANDLE handle, const float* val, unsigned int count)
+{
+ if(m_effect)
+ return (D3D_OK == m_effect->SetFloatArray(handle, val, count));
+ return false;
+}
+
+bool CD3DEffect::SetMatrix(D3DXHANDLE handle, const D3DXMATRIX* mat)
+{
+ if (m_effect)
+ return (D3D_OK == m_effect->SetMatrix(handle, mat));
+ return false;
+}
+
+bool CD3DEffect::SetTechnique(D3DXHANDLE handle)
+{
+ if (m_effect)
+ return (D3D_OK == m_effect->SetTechnique(handle));
+ return false;
+}
+
+bool CD3DEffect::SetTexture(D3DXHANDLE handle, CD3DTexture &texture)
+{
+ if (m_effect)
+ return (D3D_OK == m_effect->SetTexture(handle, texture.Get()));
+ return false;
+}
+
+bool CD3DEffect::Begin(UINT *passes, DWORD flags)
+{
+ if (m_effect)
+ return (D3D_OK == m_effect->Begin(passes, flags));
+ return false;
+}
+
+bool CD3DEffect::BeginPass(UINT pass)
+{
+ if (m_effect)
+ return (D3D_OK == m_effect->BeginPass(pass));
+ return false;
+}
+
+void CD3DEffect::EndPass()
+{
+ if (m_effect)
+ m_effect->EndPass();
+}
+
+void CD3DEffect::End()
+{
+ if (m_effect)
+ m_effect->End();
+}
+
+bool CD3DEffect::CreateEffect()
+{
+ HRESULT hr;
+ LPD3DXBUFFER pError = NULL;
+ hr = D3DXCreateEffect(g_Windowing.Get3DDevice(), m_effectString, m_effectString.length(), NULL, NULL, 0, NULL, &m_effect, &pError );
+ if(hr == S_OK)
+ return true;
+ else if(pError)
+ {
+ CStdString error;
+ error.assign((const char*)pError->GetBufferPointer(), pError->GetBufferSize());
+ CLog::Log(LOGERROR, "%s", error.c_str());
+ }
+ return false;
+}
+
+void CD3DEffect::OnLostDevice()
+{
+ if (m_effect)
+ m_effect->OnLostDevice();
+}
+
+void CD3DEffect::OnResetDevice()
+{
+ if (m_effect)
+ m_effect->OnResetDevice();
+}
+
+CD3DVertexBuffer::CD3DVertexBuffer()
+{
+ m_length = 0;
+ m_usage = 0;
+ m_fvf = 0;
+ m_pool = D3DPOOL_DEFAULT;
+ m_vertex = NULL;
+ m_data = NULL;
+}
+
+CD3DVertexBuffer::~CD3DVertexBuffer()
+{
+ Release();
+ delete[] m_data;
+}
+
+bool CD3DVertexBuffer::Create(UINT length, DWORD usage, DWORD fvf, D3DPOOL pool)
+{
+ m_length = length;
+ m_usage = usage;
+ m_fvf = fvf;
+ m_pool = pool;
+
+ // create the vertex buffer
+ Release();
+ if (CreateVertexBuffer())
+ {
+ g_Windowing.Register(this);
+ return true;
+ }
+ return false;
+}
+
+void CD3DVertexBuffer::Release()
+{
+ g_Windowing.Unregister(this);
+ SAFE_RELEASE(m_vertex);
+}
+
+bool CD3DVertexBuffer::Lock(UINT level, UINT size, void **data, DWORD flags)
+{
+ if (m_vertex)
+ return (D3D_OK == m_vertex->Lock(level, size, data, flags));
+ return false;
+}
+
+void CD3DVertexBuffer::Unlock()
+{
+ if (m_vertex)
+ m_vertex->Unlock();
+}
+
+void CD3DVertexBuffer::OnDestroyDevice()
+{
+ if (m_vertex)
+ {
+ delete[] m_data;
+ m_data = NULL;
+ void* data;
+ if (Lock(0, 0, &data, 0))
+ {
+ m_data = new BYTE[m_length];
+ memcpy(m_data, data, m_length);
+ Unlock();
+ }
+ }
+ SAFE_RELEASE(m_vertex);
+}
+
+void CD3DVertexBuffer::OnCreateDevice()
+{
+ // yay, we're back - make a new copy of the vertices
+ if (!m_vertex && m_data && CreateVertexBuffer())
+ {
+ void *data = NULL;
+ if (Lock(0, 0, &data, 0))
+ {
+ memcpy(data, m_data, m_length);
+ Unlock();
+ }
+ delete[] m_data;
+ m_data = NULL;
+ }
+}
+
+bool CD3DVertexBuffer::CreateVertexBuffer()
+{
+ if (D3D_OK == g_Windowing.Get3DDevice()->CreateVertexBuffer(m_length, m_usage, m_fvf, m_pool, &m_vertex, NULL))
+ return true;
+ return false;
+}
+
+#endif
diff --git a/guilib/D3DResource.h b/guilib/D3DResource.h
index 93e9b1db21..cbe2ef7591 100644
--- a/guilib/D3DResource.h
+++ b/guilib/D3DResource.h
@@ -1,133 +1,133 @@
-/*
-* Copyright (C) 2005-2008 Team XBMC
-* http://www.xbmc.org
-*
-* This Program is free software; you can redistribute it and/or modify
-* it under the terms of the GNU General Public License as published by
-* the Free Software Foundation; either version 2, or (at your option)
-* any later version.
-*
-* This Program is distributed in the hope that it will be useful,
-* but WITHOUT ANY WARRANTY; without even the implied warranty of
-* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
-* GNU General Public License for more details.
-*
-* You should have received a copy of the GNU General Public License
-* along with XBMC; see the file COPYING. If not, write to
-* the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.
-* http://www.gnu.org/copyleft/gpl.html
-*
-*/
-
-#pragma once
-
-#ifdef HAS_DX
-#include "StdString.h"
-
-class ID3DResource
-{
-public:
- virtual ~ID3DResource() {};
-
- virtual void OnDestroyDevice()=0;
- virtual void OnCreateDevice()=0;
- virtual void OnLostDevice() {};
- virtual void OnResetDevice() {};
-};
-
-class CD3DTexture : public ID3DResource
-{
-public:
- CD3DTexture();
- ~CD3DTexture();
-
- bool Create(UINT width, UINT height, UINT mipLevels, DWORD usage, D3DFORMAT format, D3DPOOL pool);
- void Release();
- bool LockRect(UINT level, D3DLOCKED_RECT *lr, const RECT *rect, DWORD flags);
- void UnlockRect(UINT level);
- bool GetLevelDesc(UINT level, D3DSURFACE_DESC *desc);
- bool GetSurfaceLevel(UINT level, LPDIRECT3DSURFACE9 *surface);
-
- LPDIRECT3DTEXTURE9 Get() const { return m_texture; };
-
- virtual void OnDestroyDevice();
- virtual void OnCreateDevice();
- virtual void OnLostDevice();
- virtual void OnResetDevice();
-
-private:
- unsigned int GetMemoryUsage(unsigned int pitch) const;
-
- void SaveTexture();
- void RestoreTexture();
-
- // creation parameters
- UINT m_width;
- UINT m_height;
- UINT m_mipLevels;
- DWORD m_usage;
- D3DFORMAT m_format;
- D3DPOOL m_pool;
- UINT m_pitch;
-
- // created texture
- LPDIRECT3DTEXTURE9 m_texture;
-
- // saved data
- BYTE* m_data;
-};
-
-class CD3DEffect : public ID3DResource
-{
-public:
- CD3DEffect();
- virtual ~CD3DEffect();
- bool Create(const CStdString &effectString);
- void Release();
- bool SetFloatArray(D3DXHANDLE handle, const float* val, unsigned int count);
- bool SetMatrix(D3DXHANDLE handle, const D3DXMATRIX* mat);
- bool SetTechnique(D3DXHANDLE handle);
- bool SetTexture(D3DXHANDLE handle, CD3DTexture &texture);
- bool Begin(UINT *passes, DWORD flags);
- bool BeginPass(UINT pass);
- void EndPass();
- void End();
-
- ID3DXEffect *Get() const { return m_effect; };
-
- virtual void OnDestroyDevice();
- virtual void OnCreateDevice();
- virtual void OnLostDevice();
- virtual void OnResetDevice();
-private:
- bool CreateEffect();
- CStdString m_effectString;
- ID3DXEffect *m_effect;
-};
-
-class CD3DVertexBuffer : public ID3DResource
-{
-public:
- CD3DVertexBuffer();
- virtual ~CD3DVertexBuffer();
- bool Create(UINT length, DWORD usage, DWORD fvf, D3DPOOL pool);
- void Release();
- bool Lock(UINT offset, UINT size, void **data, DWORD flags);
- void Unlock();
-
- LPDIRECT3DVERTEXBUFFER9 Get() const { return m_vertex; };
-
- virtual void OnDestroyDevice();
- virtual void OnCreateDevice();
-private:
- bool CreateVertexBuffer();
- UINT m_length;
- DWORD m_usage;
- DWORD m_fvf;
- D3DPOOL m_pool;
- LPDIRECT3DVERTEXBUFFER9 m_vertex;
-
- // saved data
- BYTE* m_data;
-};
-#endif
+/*
+* Copyright (C) 2005-2008 Team XBMC
+* http://www.xbmc.org
+*
+* This Program is free software; you can redistribute it and/or modify
+* it under the terms of the GNU General Public License as published by
+* the Free Software Foundation; either version 2, or (at your option)
+* any later version.
+*
+* This Program is distributed in the hope that it will be useful,
+* but WITHOUT ANY WARRANTY; without even the implied warranty of
+* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+* GNU General Public License for more details.
+*
+* You should have received a copy of the GNU General Public License
+* along with XBMC; see the file COPYING. If not, write to
+* the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.
+* http://www.gnu.org/copyleft/gpl.html
+*
+*/
+
+#pragma once
+
+#ifdef HAS_DX
+#include "StdString.h"
+
+class ID3DResource
+{
+public:
+ virtual ~ID3DResource() {};
+
+ virtual void OnDestroyDevice()=0;
+ virtual void OnCreateDevice()=0;
+ virtual void OnLostDevice() {};
+ virtual void OnResetDevice() {};
+};
+
+class CD3DTexture : public ID3DResource
+{
+public:
+ CD3DTexture();
+ ~CD3DTexture();
+
+ bool Create(UINT width, UINT height, UINT mipLevels, DWORD usage, D3DFORMAT format, D3DPOOL pool);
+ void Release();
+ bool LockRect(UINT level, D3DLOCKED_RECT *lr, const RECT *rect, DWORD flags);
+ void UnlockRect(UINT level);
+ bool GetLevelDesc(UINT level, D3DSURFACE_DESC *desc);
+ bool GetSurfaceLevel(UINT level, LPDIRECT3DSURFACE9 *surface);
+
+ LPDIRECT3DTEXTURE9 Get() const { return m_texture; };
+
+ virtual void OnDestroyDevice();
+ virtual void OnCreateDevice();
+ virtual void OnLostDevice();
+ virtual void OnResetDevice();
+
+private:
+ unsigned int GetMemoryUsage(unsigned int pitch) const;
+
+ void SaveTexture();
+ void RestoreTexture();
+
+ // creation parameters
+ UINT m_width;
+ UINT m_height;
+ UINT m_mipLevels;
+ DWORD m_usage;
+ D3DFORMAT m_format;
+ D3DPOOL m_pool;
+ UINT m_pitch;
+
+ // created texture
+ LPDIRECT3DTEXTURE9 m_texture;
+
+ // saved data
+ BYTE* m_data;
+};
+
+class CD3DEffect : public ID3DResource
+{
+public:
+ CD3DEffect();
+ virtual ~CD3DEffect();
+ bool Create(const CStdString &effectString);
+ void Release();
+ bool SetFloatArray(D3DXHANDLE handle, const float* val, unsigned int count);
+ bool SetMatrix(D3DXHANDLE handle, const D3DXMATRIX* mat);
+ bool SetTechnique(D3DXHANDLE handle);
+ bool SetTexture(D3DXHANDLE handle, CD3DTexture &texture);
+ bool Begin(UINT *passes, DWORD flags);
+ bool BeginPass(UINT pass);
+ void EndPass();
+ void End();
+
+ ID3DXEffect *Get() const { return m_effect; };
+
+ virtual void OnDestroyDevice();
+ virtual void OnCreateDevice();
+ virtual void OnLostDevice();
+ virtual void OnResetDevice();
+private:
+ bool CreateEffect();
+ CStdString m_effectString;
+ ID3DXEffect *m_effect;
+};
+
+class CD3DVertexBuffer : public ID3DResource
+{
+public:
+ CD3DVertexBuffer();
+ virtual ~CD3DVertexBuffer();
+ bool Create(UINT length, DWORD usage, DWORD fvf, D3DPOOL pool);
+ void Release();
+ bool Lock(UINT offset, UINT size, void **data, DWORD flags);
+ void Unlock();
+
+ LPDIRECT3DVERTEXBUFFER9 Get() const { return m_vertex; };
+
+ virtual void OnDestroyDevice();
+ virtual void OnCreateDevice();
+private:
+ bool CreateVertexBuffer();
+ UINT m_length;
+ DWORD m_usage;
+ DWORD m_fvf;
+ D3DPOOL m_pool;
+ LPDIRECT3DVERTEXBUFFER9 m_vertex;
+
+ // saved data
+ BYTE* m_data;
+};
+#endif
diff --git a/guilib/DDSImage.h b/guilib/DDSImage.h
index 9b2656cfae..f4f0eaf7fd 100644
--- a/guilib/DDSImage.h
+++ b/guilib/DDSImage.h
@@ -1,142 +1,142 @@
-/*
- * Copyright (C) 2005-2009 Team XBMC
- * http://www.xbmc.org
- *
- * This Program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License as published by
- * the Free Software Foundation; either version 2, or (at your option)
- * any later version.
- *
- * This Program is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
- * GNU General Public License for more details.
- *
- * You should have received a copy of the GNU General Public License
- * along with XBMC; see the file COPYING. If not, write to
- * the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.
- * http://www.gnu.org/copyleft/gpl.html
- *
- */
-
-#pragma once
-
-#include <string>
-#include <stdint.h>
-
-class CDDSImage
-{
-public:
- CDDSImage();
- CDDSImage(unsigned int width, unsigned int height, unsigned int format);
- ~CDDSImage();
-
- unsigned int GetWidth() const;
- unsigned int GetHeight() const;
- unsigned int GetFormat() const;
- unsigned int GetSize() const;
- unsigned char *GetData() const;
-
- bool ReadFile(const std::string &file);
-
- /*! \brief Create a DDS image file from the given an ARGB buffer
- \param file name of the file to write
- \param width width of the pixel buffer
- \param height height of the pixel buffer
- \param pitch pitch of the pixel buffer
- \param argb pixel buffer
- \param maxMSE maximum mean square error to allow, ignored if 0 (the default)
- \return true on successful image creation, false otherwise
- */
- bool Create(const std::string &file, unsigned int width, unsigned int height, unsigned int pitch, unsigned char const *argb, double maxMSE = 0);
-
- /*! \brief Decompress a DXT1/3/5 image to the given buffer
- Assumes the buffer has been allocated to at least width*height*4
- \param argb pixel buffer to write to (at least width*height*4 bytes)
- \param width width of the pixel buffer
- \param height height of the pixel buffer
- \param pitch pitch of the pixel buffer
- \param dxt compressed dxt data
- \param format format of the compressed dxt data
- \return true on success, false otherwise
- */
- static bool Decompress(unsigned char *argb, unsigned int width, unsigned int height, unsigned int pitch, unsigned char const *dxt, unsigned int format);
-
-private:
- void Allocate(unsigned int width, unsigned int height, unsigned int format);
- const char *GetFourCC(unsigned int format) const;
- bool WriteFile(const std::string &file) const;
-
- /*! \brief Compress an ARGB buffer into a DXT1/3/5 image
- \param width width of the pixel buffer
- \param height height of the pixel buffer
- \param pitch pitch of the pixel buffer
- \param argb pixel buffer
- \param maxMSE maximum mean square error to allow, ignored if 0 (the default)
- \return true on successful compression within the given maxMSE, false otherwise
- */
- bool Compress(unsigned int width, unsigned int height, unsigned int pitch, unsigned char const *argb, double maxMSE = 0);
-
- unsigned int GetStorageRequirements(unsigned int width, unsigned int height, unsigned int format) const;
- enum {
- ddsd_caps = 0x00000001,
- ddsd_height = 0x00000002,
- ddsd_width = 0x00000004,
- ddsd_pitch = 0x00000008,
- ddsd_pixelformat = 0x00001000,
- ddsd_mipmapcount = 0x00020000,
- ddsd_linearsize = 0x00080000,
- ddsd_depth = 0x00800000
- };
-
- enum {
- ddpf_alphapixels = 0x00000001,
- ddpf_fourcc = 0x00000004,
- ddpf_rgb = 0x00000040
- };
-
- enum {
- ddscaps_complex = 0x00000008,
- ddscaps_texture = 0x00001000,
- ddscaps_mipmap = 0x00400000
- };
-
- #pragma pack(push, 2)
- typedef struct
- {
- uint32_t size;
- uint32_t flags;
- uint32_t fourcc;
- uint32_t rgbBitCount;
- uint32_t rBitMask;
- uint32_t gBitMask;
- uint32_t bBitMask;
- uint32_t aBitMask;
- } ddpixelformat;
-
- typedef struct
- {
- uint32_t flags1;
- uint32_t flags2;
- uint32_t reserved[2];
- } ddcaps2;
-
- typedef struct
- {
- uint32_t size;
- uint32_t flags;
- uint32_t height;
- uint32_t width;
- uint32_t linearSize;
- uint32_t depth;
- uint32_t mipmapcount;
- uint32_t reserved[11];
- ddpixelformat pixelFormat;
- ddcaps2 caps;
- uint32_t reserved2;
- } ddsurfacedesc2;
- #pragma pack(pop)
-
- ddsurfacedesc2 m_desc;
- unsigned char *m_data;
-};
+/*
+ * Copyright (C) 2005-2009 Team XBMC
+ * http://www.xbmc.org
+ *
+ * This Program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2, or (at your option)
+ * any later version.
+ *
+ * This Program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with XBMC; see the file COPYING. If not, write to
+ * the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.
+ * http://www.gnu.org/copyleft/gpl.html
+ *
+ */
+
+#pragma once
+
+#include <string>
+#include <stdint.h>
+
+class CDDSImage
+{
+public:
+ CDDSImage();
+ CDDSImage(unsigned int width, unsigned int height, unsigned int format);
+ ~CDDSImage();
+
+ unsigned int GetWidth() const;
+ unsigned int GetHeight() const;
+ unsigned int GetFormat() const;
+ unsigned int GetSize() const;
+ unsigned char *GetData() const;
+
+ bool ReadFile(const std::string &file);
+
+ /*! \brief Create a DDS image file from the given an ARGB buffer
+ \param file name of the file to write
+ \param width width of the pixel buffer
+ \param height height of the pixel buffer
+ \param pitch pitch of the pixel buffer
+ \param argb pixel buffer
+ \param maxMSE maximum mean square error to allow, ignored if 0 (the default)
+ \return true on successful image creation, false otherwise
+ */
+ bool Create(const std::string &file, unsigned int width, unsigned int height, unsigned int pitch, unsigned char const *argb, double maxMSE = 0);
+
+ /*! \brief Decompress a DXT1/3/5 image to the given buffer
+ Assumes the buffer has been allocated to at least width*height*4
+ \param argb pixel buffer to write to (at least width*height*4 bytes)
+ \param width width of the pixel buffer
+ \param height height of the pixel buffer
+ \param pitch pitch of the pixel buffer
+ \param dxt compressed dxt data
+ \param format format of the compressed dxt data
+ \return true on success, false otherwise
+ */
+ static bool Decompress(unsigned char *argb, unsigned int width, unsigned int height, unsigned int pitch, unsigned char const *dxt, unsigned int format);
+
+private:
+ void Allocate(unsigned int width, unsigned int height, unsigned int format);
+ const char *GetFourCC(unsigned int format) const;
+ bool WriteFile(const std::string &file) const;
+
+ /*! \brief Compress an ARGB buffer into a DXT1/3/5 image
+ \param width width of the pixel buffer
+ \param height height of the pixel buffer
+ \param pitch pitch of the pixel buffer
+ \param argb pixel buffer
+ \param maxMSE maximum mean square error to allow, ignored if 0 (the default)
+ \return true on successful compression within the given maxMSE, false otherwise
+ */
+ bool Compress(unsigned int width, unsigned int height, unsigned int pitch, unsigned char const *argb, double maxMSE = 0);
+
+ unsigned int GetStorageRequirements(unsigned int width, unsigned int height, unsigned int format) const;
+ enum {
+ ddsd_caps = 0x00000001,
+ ddsd_height = 0x00000002,
+ ddsd_width = 0x00000004,
+ ddsd_pitch = 0x00000008,
+ ddsd_pixelformat = 0x00001000,
+ ddsd_mipmapcount = 0x00020000,
+ ddsd_linearsize = 0x00080000,
+ ddsd_depth = 0x00800000
+ };
+
+ enum {
+ ddpf_alphapixels = 0x00000001,
+ ddpf_fourcc = 0x00000004,
+ ddpf_rgb = 0x00000040
+ };
+
+ enum {
+ ddscaps_complex = 0x00000008,
+ ddscaps_texture = 0x00001000,
+ ddscaps_mipmap = 0x00400000
+ };
+
+ #pragma pack(push, 2)
+ typedef struct
+ {
+ uint32_t size;
+ uint32_t flags;
+ uint32_t fourcc;
+ uint32_t rgbBitCount;
+ uint32_t rBitMask;
+ uint32_t gBitMask;
+ uint32_t bBitMask;
+ uint32_t aBitMask;
+ } ddpixelformat;
+
+ typedef struct
+ {
+ uint32_t flags1;
+ uint32_t flags2;
+ uint32_t reserved[2];
+ } ddcaps2;
+
+ typedef struct
+ {
+ uint32_t size;
+ uint32_t flags;
+ uint32_t height;
+ uint32_t width;
+ uint32_t linearSize;
+ uint32_t depth;
+ uint32_t mipmapcount;
+ uint32_t reserved[11];
+ ddpixelformat pixelFormat;
+ ddcaps2 caps;
+ uint32_t reserved2;
+ } ddsurfacedesc2;
+ #pragma pack(pop)
+
+ ddsurfacedesc2 m_desc;
+ unsigned char *m_data;
+};