aboutsummaryrefslogtreecommitdiff
path: root/guilib
diff options
context:
space:
mode:
authorCrystalPT <CrystalPT@svn>2010-07-10 01:39:42 +0000
committerCrystalPT <CrystalPT@svn>2010-07-10 01:39:42 +0000
commitbd64b1952a361b08d3d4a76e40b2f1041b8f8b7e (patch)
tree784122db5d22837977d295f3ad0e8f9cbbf0b37b /guilib
parentb4d9cd5e6cd9d944dc508c4d9ce0928050a54600 (diff)
Merge branch 'commit-shaders'
git-svn-id: https://xbmc.svn.sourceforge.net/svnroot/xbmc/trunk@31685 568bbfeb-2a22-0410-94d2-cc84cf5bfa90
Diffstat (limited to 'guilib')
-rw-r--r--guilib/D3DResource.cpp29
-rw-r--r--guilib/D3DResource.h11
2 files changed, 34 insertions, 6 deletions
diff --git a/guilib/D3DResource.cpp b/guilib/D3DResource.cpp
index c0425ff533..6b3978d5d7 100644
--- a/guilib/D3DResource.cpp
+++ b/guilib/D3DResource.cpp
@@ -26,6 +26,8 @@
#ifdef HAS_DX
+using namespace std;
+
CD3DTexture::CD3DTexture()
{
m_width = 0;
@@ -215,10 +217,13 @@ CD3DEffect::~CD3DEffect()
Release();
}
-bool CD3DEffect::Create(const CStdString &effectString)
+bool CD3DEffect::Create(const CStdString &effectString, DefinesMap* defines)
{
- m_effectString = effectString;
Release();
+ m_effectString = effectString;
+ m_defines.clear();
+ if (defines != NULL)
+ m_defines = *defines; //FIXME: is this a copy of all members?
if (CreateEffect())
{
g_Windowing.Register(this);
@@ -301,7 +306,25 @@ 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 );
+
+ std::vector<D3DXMACRO> definemacros;
+
+ for( DefinesMap::const_iterator it = m_defines.begin(); it != m_defines.end(); ++it )
+ {
+ D3DXMACRO m;
+ m.Name = it->first.c_str();
+ if (it->second.IsEmpty())
+ m.Definition = NULL;
+ else
+ m.Definition = it->second.c_str();
+ definemacros.push_back( m );
+ }
+
+ definemacros.push_back(D3DXMACRO());
+ definemacros.back().Name = 0;
+ definemacros.back().Definition = 0;
+
+ hr = D3DXCreateEffect(g_Windowing.Get3DDevice(), m_effectString, m_effectString.length(), &definemacros[0], NULL, 0, NULL, &m_effect, &pError );
if(hr == S_OK)
return true;
else if(pError)
diff --git a/guilib/D3DResource.h b/guilib/D3DResource.h
index cbe2ef7591..f70bbaf277 100644
--- a/guilib/D3DResource.h
+++ b/guilib/D3DResource.h
@@ -23,6 +23,7 @@
#ifdef HAS_DX
#include "StdString.h"
+#include <map>
class ID3DResource
{
@@ -77,12 +78,14 @@ private:
BYTE* m_data;
};
+typedef std::map<CStdString, CStdString> DefinesMap;
+
class CD3DEffect : public ID3DResource
{
public:
CD3DEffect();
virtual ~CD3DEffect();
- bool Create(const CStdString &effectString);
+ bool Create(const CStdString &effectString, DefinesMap* defines);
void Release();
bool SetFloatArray(D3DXHANDLE handle, const float* val, unsigned int count);
bool SetMatrix(D3DXHANDLE handle, const D3DXMATRIX* mat);
@@ -100,9 +103,10 @@ public:
virtual void OnLostDevice();
virtual void OnResetDevice();
private:
- bool CreateEffect();
+ bool CreateEffect();
CStdString m_effectString;
- ID3DXEffect *m_effect;
+ ID3DXEffect *m_effect;
+ DefinesMap m_defines;
};
class CD3DVertexBuffer : public ID3DResource
@@ -130,4 +134,5 @@ private:
// saved data
BYTE* m_data;
};
+
#endif