update all shader subclasses to use Initialize() methods for all complex initialization instead of the constructor
This commit is contained in:
parent
6a5444abe0
commit
543e6bf409
|
@ -1,45 +1,40 @@
|
|||
#include "../debug.h"
|
||||
|
||||
#include "customspriteshader.h"
|
||||
#include "../support/text.h"
|
||||
|
||||
CustomSpriteShader::CustomSpriteShader(const char *vertexShaderSource, const char *fragmentShaderSource)
|
||||
: SpriteShader()
|
||||
CustomSpriteShader::CustomSpriteShader()
|
||||
{
|
||||
STACK_TRACE;
|
||||
ASSERT(vertexShaderSource != NULL);
|
||||
ASSERT(fragmentShaderSource != NULL);
|
||||
|
||||
BOOL result = LoadCompileAndLink(vertexShaderSource, fragmentShaderSource);
|
||||
ASSERT(result == TRUE);
|
||||
|
||||
CacheShaderSources(vertexShaderSource, fragmentShaderSource);
|
||||
|
||||
ASSERT(HasUniform(GetModelViewMatrixUniform()) == TRUE);
|
||||
ASSERT(HasUniform(GetProjectionMatrixUniform()) == TRUE);
|
||||
ASSERT(HasUniform(GetTextureHasAlphaOnlyUniform()) == TRUE);
|
||||
}
|
||||
|
||||
CustomSpriteShader::CustomSpriteShader(const Text *vertexShaderSource, const Text *fragmentShaderSource)
|
||||
: SpriteShader()
|
||||
{
|
||||
STACK_TRACE;
|
||||
ASSERT(vertexShaderSource != NULL);
|
||||
ASSERT(vertexShaderSource->GetLength() > 0);
|
||||
ASSERT(fragmentShaderSource != NULL);
|
||||
ASSERT(fragmentShaderSource->GetLength() > 0);
|
||||
|
||||
BOOL result = LoadCompileAndLink(vertexShaderSource->GetText(), fragmentShaderSource->GetText());
|
||||
ASSERT(result == TRUE);
|
||||
|
||||
CacheShaderSources(vertexShaderSource->GetText(), fragmentShaderSource->GetText());
|
||||
|
||||
ASSERT(HasUniform(GetModelViewMatrixUniform()) == TRUE);
|
||||
ASSERT(HasUniform(GetProjectionMatrixUniform()) == TRUE);
|
||||
ASSERT(HasUniform(GetTextureHasAlphaOnlyUniform()) == TRUE);
|
||||
}
|
||||
|
||||
CustomSpriteShader::~CustomSpriteShader()
|
||||
{
|
||||
STACK_TRACE;
|
||||
}
|
||||
|
||||
BOOL CustomSpriteShader::Initialize(GraphicsDevice *graphicsDevice, const char *vertexShaderSource, const char *fragmentShaderSource)
|
||||
{
|
||||
STACK_TRACE;
|
||||
if (!SpriteShader::Initialize(graphicsDevice, vertexShaderSource, fragmentShaderSource))
|
||||
return FALSE;
|
||||
|
||||
ASSERT(HasUniform(GetModelViewMatrixUniform()) == TRUE);
|
||||
ASSERT(HasUniform(GetProjectionMatrixUniform()) == TRUE);
|
||||
ASSERT(HasUniform(GetTextureHasAlphaOnlyUniform()) == TRUE);
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
BOOL CustomSpriteShader::Initialize(GraphicsDevice *graphicsDevice, const Text *vertexShaderSource, const Text *fragmentShaderSource)
|
||||
{
|
||||
STACK_TRACE;
|
||||
if (!SpriteShader::Initialize(graphicsDevice, vertexShaderSource, fragmentShaderSource))
|
||||
return FALSE;
|
||||
|
||||
ASSERT(HasUniform(GetModelViewMatrixUniform()) == TRUE);
|
||||
ASSERT(HasUniform(GetProjectionMatrixUniform()) == TRUE);
|
||||
ASSERT(HasUniform(GetTextureHasAlphaOnlyUniform()) == TRUE);
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
|
|
|
@ -3,6 +3,7 @@
|
|||
|
||||
#include "spriteshader.h"
|
||||
|
||||
class GraphicsDevice;
|
||||
class Text;
|
||||
|
||||
/**
|
||||
|
@ -12,23 +13,28 @@ class Text;
|
|||
class CustomSpriteShader : public SpriteShader
|
||||
{
|
||||
public:
|
||||
/**
|
||||
* Creates a new shader object for rendering sprites using the given vertex
|
||||
* and fragment shader sources.
|
||||
* @param vertexShaderSource GLSL source for a vertex shader
|
||||
* @param fragmentShaderSource GLSL source for a vertex shader
|
||||
*/
|
||||
CustomSpriteShader(const char *vertexShaderSource, const char *fragmentShaderSource);
|
||||
|
||||
/**
|
||||
* Creates a new shader object for rendering sprites using the given vertex
|
||||
* and fragment shader sources.
|
||||
* @param vertexShaderSource GLSL source for a vertex shader
|
||||
* @param fragmentShaderSource GLSL source for a vertex shader
|
||||
*/
|
||||
CustomSpriteShader(const Text *vertexShaderSource, const Text *fragmentShaderSource);
|
||||
|
||||
CustomSpriteShader();
|
||||
virtual ~CustomSpriteShader();
|
||||
|
||||
/**
|
||||
* Initializes the shader object for rendering sprites using the given vertex
|
||||
* and fragment shader sources.
|
||||
* @param graphicsDevice the graphics device to associate this shader with
|
||||
* @param vertexShaderSource GLSL source for a vertex shader
|
||||
* @param fragmentShaderSource GLSL source for a vertex shader
|
||||
* @return TRUE if successful, FALSE if not
|
||||
*/
|
||||
BOOL Initialize(GraphicsDevice *graphicsDevice, const char *vertexShaderSource, const char *fragmentShaderSource);
|
||||
|
||||
/**
|
||||
* Initializes the shader object for rendering sprites using the given vertex
|
||||
* and fragment shader sources.
|
||||
* @param graphicsDevice the graphics device to associate this shader with
|
||||
* @param vertexShaderSource GLSL source for a vertex shader
|
||||
* @param fragmentShaderSource GLSL source for a vertex shader
|
||||
* @return TRUE if successful, FALSE if not
|
||||
*/
|
||||
BOOL Initialize(GraphicsDevice *graphicsDevice, const Text *vertexShaderSource, const Text *fragmentShaderSource);
|
||||
};
|
||||
|
||||
#endif
|
||||
|
|
|
@ -1,43 +1,37 @@
|
|||
#include "../debug.h"
|
||||
|
||||
#include "customstandardshader.h"
|
||||
#include "../support/text.h"
|
||||
|
||||
CustomStandardShader::CustomStandardShader(const char *vertexShaderSource, const char *fragmentShaderSource)
|
||||
: StandardShader()
|
||||
CustomStandardShader::CustomStandardShader()
|
||||
{
|
||||
STACK_TRACE;
|
||||
ASSERT(vertexShaderSource != NULL);
|
||||
ASSERT(fragmentShaderSource != NULL);
|
||||
|
||||
BOOL result = LoadCompileAndLink(vertexShaderSource, fragmentShaderSource);
|
||||
ASSERT(result == TRUE);
|
||||
|
||||
CacheShaderSources(vertexShaderSource, fragmentShaderSource);
|
||||
|
||||
ASSERT(HasUniform(GetModelViewMatrixUniform()) == TRUE);
|
||||
ASSERT(HasUniform(GetProjectionMatrixUniform()) == TRUE);
|
||||
}
|
||||
|
||||
CustomStandardShader::CustomStandardShader(const Text *vertexShaderSource, const Text *fragmentShaderSource)
|
||||
: StandardShader()
|
||||
{
|
||||
STACK_TRACE;
|
||||
ASSERT(vertexShaderSource != NULL);
|
||||
ASSERT(vertexShaderSource->GetLength() > 0);
|
||||
ASSERT(fragmentShaderSource != NULL);
|
||||
ASSERT(fragmentShaderSource->GetLength() > 0);
|
||||
|
||||
BOOL result = LoadCompileAndLink(vertexShaderSource->GetText(), fragmentShaderSource->GetText());
|
||||
ASSERT(result == TRUE);
|
||||
|
||||
CacheShaderSources(vertexShaderSource->GetText(), fragmentShaderSource->GetText());
|
||||
|
||||
ASSERT(HasUniform(GetModelViewMatrixUniform()) == TRUE);
|
||||
ASSERT(HasUniform(GetProjectionMatrixUniform()) == TRUE);
|
||||
}
|
||||
|
||||
CustomStandardShader::~CustomStandardShader()
|
||||
{
|
||||
STACK_TRACE;
|
||||
}
|
||||
|
||||
BOOL CustomStandardShader::Initialize(GraphicsDevice *graphicsDevice, const char *vertexShaderSource, const char *fragmentShaderSource)
|
||||
{
|
||||
STACK_TRACE;
|
||||
if (!StandardShader::Initialize(graphicsDevice, vertexShaderSource, fragmentShaderSource))
|
||||
return FALSE;
|
||||
|
||||
ASSERT(HasUniform(GetModelViewMatrixUniform()) == TRUE);
|
||||
ASSERT(HasUniform(GetProjectionMatrixUniform()) == TRUE);
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
BOOL CustomStandardShader::Initialize(GraphicsDevice *graphicsDevice, const Text *vertexShaderSource, const Text *fragmentShaderSource)
|
||||
{
|
||||
STACK_TRACE;
|
||||
if (!StandardShader::Initialize(graphicsDevice, vertexShaderSource, fragmentShaderSource))
|
||||
return FALSE;
|
||||
|
||||
ASSERT(HasUniform(GetModelViewMatrixUniform()) == TRUE);
|
||||
ASSERT(HasUniform(GetProjectionMatrixUniform()) == TRUE);
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
|
|
|
@ -3,6 +3,7 @@
|
|||
|
||||
#include "standardshader.h"
|
||||
|
||||
class GraphicsDevice;
|
||||
class Text;
|
||||
|
||||
/**
|
||||
|
@ -11,23 +12,28 @@ class Text;
|
|||
class CustomStandardShader : public StandardShader
|
||||
{
|
||||
public:
|
||||
/**
|
||||
* Creates a new shader object using the given vertex and fragment shader
|
||||
* sources.
|
||||
* @param vertexShaderSource GLSL source for a vertex shader
|
||||
* @param fragmentShaderSource GLSL source for a vertex shader
|
||||
*/
|
||||
CustomStandardShader(const char *vertexShaderSource, const char *fragmentShaderSource);
|
||||
|
||||
/**
|
||||
* Creates a new shader object using the given vertex and fragment shader
|
||||
* sources.
|
||||
* @param vertexShaderSource GLSL source for a vertex shader
|
||||
* @param fragmentShaderSource GLSL source for a vertex shader
|
||||
*/
|
||||
CustomStandardShader(const Text *vertexShaderSource, const Text *fragmentShaderSource);
|
||||
|
||||
CustomStandardShader();
|
||||
virtual ~CustomStandardShader();
|
||||
|
||||
/**
|
||||
* Initializes the shader object using the given vertex and fragment shader
|
||||
* sources.
|
||||
* @param graphicsDevice the graphics device to associate this shader with
|
||||
* @param vertexShaderSource GLSL source for a vertex shader
|
||||
* @param fragmentShaderSource GLSL source for a vertex shader
|
||||
* @return TRUE if successful, FALSE if not
|
||||
*/
|
||||
BOOL Initialize(GraphicsDevice *graphicsDevice, const char *vertexShaderSource, const char *fragmentShaderSource);
|
||||
|
||||
/**
|
||||
* Initializes the shader object using the given vertex and fragment shader
|
||||
* sources.
|
||||
* @param graphicsDevice the graphics device to associate this shader with
|
||||
* @param vertexShaderSource GLSL source for a vertex shader
|
||||
* @param fragmentShaderSource GLSL source for a vertex shader
|
||||
* @return TRUE if successful, FALSE if not
|
||||
*/
|
||||
BOOL Initialize(GraphicsDevice *graphicsDevice, const Text *vertexShaderSource, const Text *fragmentShaderSource);
|
||||
};
|
||||
|
||||
#endif
|
||||
|
|
|
@ -1,45 +1,39 @@
|
|||
#include "../debug.h"
|
||||
|
||||
#include "customvertexlerpshader.h"
|
||||
#include "../support/text.h"
|
||||
|
||||
CustomVertexLerpShader::CustomVertexLerpShader(const char *vertexShaderSource, const char *fragmentShaderSource)
|
||||
: VertexLerpShader()
|
||||
CustomVertexLerpShader::CustomVertexLerpShader()
|
||||
{
|
||||
STACK_TRACE;
|
||||
ASSERT(vertexShaderSource != NULL);
|
||||
ASSERT(fragmentShaderSource != NULL);
|
||||
|
||||
BOOL result = LoadCompileAndLink(vertexShaderSource, fragmentShaderSource);
|
||||
ASSERT(result == TRUE);
|
||||
|
||||
CacheShaderSources(vertexShaderSource, fragmentShaderSource);
|
||||
|
||||
ASSERT(HasUniform(GetModelViewMatrixUniform()) == TRUE);
|
||||
ASSERT(HasUniform(GetProjectionMatrixUniform()) == TRUE);
|
||||
ASSERT(HasUniform(GetLerpUniform()) == TRUE);
|
||||
}
|
||||
|
||||
CustomVertexLerpShader::CustomVertexLerpShader(const Text *vertexShaderSource, const Text *fragmentShaderSource)
|
||||
: VertexLerpShader()
|
||||
{
|
||||
STACK_TRACE;
|
||||
ASSERT(vertexShaderSource != NULL);
|
||||
ASSERT(vertexShaderSource->GetLength() > 0);
|
||||
ASSERT(fragmentShaderSource != NULL);
|
||||
ASSERT(fragmentShaderSource->GetLength() > 0);
|
||||
|
||||
BOOL result = LoadCompileAndLink(vertexShaderSource->GetText(), fragmentShaderSource->GetText());
|
||||
ASSERT(result == TRUE);
|
||||
|
||||
CacheShaderSources(vertexShaderSource->GetText(), fragmentShaderSource->GetText());
|
||||
|
||||
ASSERT(HasUniform(GetModelViewMatrixUniform()) == TRUE);
|
||||
ASSERT(HasUniform(GetProjectionMatrixUniform()) == TRUE);
|
||||
ASSERT(HasUniform(GetLerpUniform()) == TRUE);
|
||||
}
|
||||
|
||||
CustomVertexLerpShader::~CustomVertexLerpShader()
|
||||
{
|
||||
STACK_TRACE;
|
||||
}
|
||||
|
||||
BOOL CustomVertexLerpShader::Initialize(GraphicsDevice *graphicsDevice, const char *vertexShaderSource, const char *fragmentShaderSource)
|
||||
{
|
||||
STACK_TRACE;
|
||||
if (!VertexLerpShader::Initialize(graphicsDevice, vertexShaderSource, fragmentShaderSource))
|
||||
return FALSE;
|
||||
|
||||
ASSERT(HasUniform(GetModelViewMatrixUniform()) == TRUE);
|
||||
ASSERT(HasUniform(GetProjectionMatrixUniform()) == TRUE);
|
||||
ASSERT(HasUniform(GetLerpUniform()) == TRUE);
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
BOOL CustomVertexLerpShader::Initialize(GraphicsDevice *graphicsDevice, const Text *vertexShaderSource, const Text *fragmentShaderSource)
|
||||
{
|
||||
STACK_TRACE;
|
||||
if (!VertexLerpShader::Initialize(graphicsDevice, vertexShaderSource, fragmentShaderSource))
|
||||
return FALSE;
|
||||
|
||||
ASSERT(HasUniform(GetModelViewMatrixUniform()) == TRUE);
|
||||
ASSERT(HasUniform(GetProjectionMatrixUniform()) == TRUE);
|
||||
ASSERT(HasUniform(GetLerpUniform()) == TRUE);
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
|
|
|
@ -3,16 +3,17 @@
|
|||
|
||||
#include "vertexlerpshader.h"
|
||||
|
||||
class GraphicsDevice;
|
||||
class Text;
|
||||
|
||||
class CustomVertexLerpShader : public VertexLerpShader
|
||||
{
|
||||
public:
|
||||
CustomVertexLerpShader(const char *vertexShaderSource, const char *fragmentShaderSource);
|
||||
|
||||
CustomVertexLerpShader(const Text *vertexShaderSource, const Text *fragmentShaderSource);
|
||||
|
||||
CustomVertexLerpShader();
|
||||
virtual ~CustomVertexLerpShader();
|
||||
|
||||
BOOL Initialize(GraphicsDevice *graphicsDevice, const char *vertexShaderSource, const char *fragmentShaderSource);
|
||||
BOOL Initialize(GraphicsDevice *graphicsDevice, const Text *vertexShaderSource, const Text *fragmentShaderSource);
|
||||
};
|
||||
|
||||
#endif
|
||||
|
|
|
@ -3,45 +3,40 @@
|
|||
#include "customvertexskinningshader.h"
|
||||
#include "../support/text.h"
|
||||
|
||||
CustomVertexSkinningShader::CustomVertexSkinningShader(const char *vertexShaderSource, const char *fragmentShaderSource)
|
||||
: VertexSkinningShader()
|
||||
CustomVertexSkinningShader::CustomVertexSkinningShader()
|
||||
{
|
||||
STACK_TRACE;
|
||||
ASSERT(vertexShaderSource != NULL);
|
||||
ASSERT(fragmentShaderSource != NULL);
|
||||
|
||||
BOOL result = LoadCompileAndLink(vertexShaderSource, fragmentShaderSource);
|
||||
ASSERT(result == TRUE);
|
||||
|
||||
CacheShaderSources(vertexShaderSource, fragmentShaderSource);
|
||||
|
||||
ASSERT(HasUniform(GetModelViewMatrixUniform()) == TRUE);
|
||||
ASSERT(HasUniform(GetProjectionMatrixUniform()) == TRUE);
|
||||
ASSERT(HasUniform(GetJointPositionsUniform()) == TRUE);
|
||||
ASSERT(HasUniform(GetJointRotationsUniform()) == TRUE);
|
||||
}
|
||||
|
||||
CustomVertexSkinningShader::CustomVertexSkinningShader(const Text *vertexShaderSource, const Text *fragmentShaderSource)
|
||||
: VertexSkinningShader()
|
||||
{
|
||||
STACK_TRACE;
|
||||
ASSERT(vertexShaderSource != NULL);
|
||||
ASSERT(vertexShaderSource->GetLength() > 0);
|
||||
ASSERT(fragmentShaderSource != NULL);
|
||||
ASSERT(fragmentShaderSource->GetLength() > 0);
|
||||
|
||||
BOOL result = LoadCompileAndLink(vertexShaderSource->GetText(), fragmentShaderSource->GetText());
|
||||
ASSERT(result == TRUE);
|
||||
|
||||
CacheShaderSources(vertexShaderSource->GetText(), fragmentShaderSource->GetText());
|
||||
|
||||
ASSERT(HasUniform(GetModelViewMatrixUniform()) == TRUE);
|
||||
ASSERT(HasUniform(GetProjectionMatrixUniform()) == TRUE);
|
||||
ASSERT(HasUniform(GetJointPositionsUniform()) == TRUE);
|
||||
ASSERT(HasUniform(GetJointRotationsUniform()) == TRUE);
|
||||
}
|
||||
|
||||
CustomVertexSkinningShader::~CustomVertexSkinningShader()
|
||||
{
|
||||
STACK_TRACE;
|
||||
}
|
||||
|
||||
BOOL CustomVertexSkinningShader::Initialize(GraphicsDevice *graphicsDevice, const char *vertexShaderSource, const char *fragmentShaderSource)
|
||||
{
|
||||
STACK_TRACE;
|
||||
if (!VertexSkinningShader::Initialize(graphicsDevice, vertexShaderSource, fragmentShaderSource))
|
||||
return FALSE;
|
||||
|
||||
ASSERT(HasUniform(GetModelViewMatrixUniform()) == TRUE);
|
||||
ASSERT(HasUniform(GetProjectionMatrixUniform()) == TRUE);
|
||||
ASSERT(HasUniform(GetJointPositionsUniform()) == TRUE);
|
||||
ASSERT(HasUniform(GetJointRotationsUniform()) == TRUE);
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
BOOL CustomVertexSkinningShader::Initialize(GraphicsDevice *graphicsDevice, const Text *vertexShaderSource, const Text *fragmentShaderSource)
|
||||
{
|
||||
STACK_TRACE;
|
||||
if (!VertexSkinningShader::Initialize(graphicsDevice, vertexShaderSource, fragmentShaderSource))
|
||||
return FALSE;
|
||||
|
||||
ASSERT(HasUniform(GetModelViewMatrixUniform()) == TRUE);
|
||||
ASSERT(HasUniform(GetProjectionMatrixUniform()) == TRUE);
|
||||
ASSERT(HasUniform(GetJointPositionsUniform()) == TRUE);
|
||||
ASSERT(HasUniform(GetJointRotationsUniform()) == TRUE);
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
|
|
|
@ -3,16 +3,17 @@
|
|||
|
||||
#include "vertexskinningshader.h"
|
||||
|
||||
class GraphicsDevice;
|
||||
class Text;
|
||||
|
||||
class CustomVertexSkinningShader : public VertexSkinningShader
|
||||
{
|
||||
public:
|
||||
CustomVertexSkinningShader(const char *vertexShaderSource, const char *fragmentShaderSource);
|
||||
|
||||
CustomVertexSkinningShader(const Text *vertexShaderSource, const Text *fragmentShaderSource);
|
||||
|
||||
CustomVertexSkinningShader();
|
||||
virtual ~CustomVertexSkinningShader();
|
||||
|
||||
BOOL Initialize(GraphicsDevice *graphicsDevice, const char *vertexShaderSource, const char *fragmentShaderSource);
|
||||
BOOL Initialize(GraphicsDevice *graphicsDevice, const Text *vertexShaderSource, const Text *fragmentShaderSource);
|
||||
};
|
||||
|
||||
#endif
|
||||
|
|
|
@ -31,17 +31,26 @@ const char* DebugShader::m_fragmentShaderSource =
|
|||
"}\n";
|
||||
|
||||
DebugShader::DebugShader()
|
||||
: StandardShader()
|
||||
{
|
||||
STACK_TRACE;
|
||||
BOOL result = LoadCompileAndLinkInlineSources(m_vertexShaderSource, m_fragmentShaderSource);
|
||||
ASSERT(result == TRUE);
|
||||
|
||||
MapAttributeToStandardAttribType("a_position", VERTEX_STD_POS_3D);
|
||||
MapAttributeToStandardAttribType("a_color", VERTEX_STD_COLOR);
|
||||
}
|
||||
|
||||
DebugShader::~DebugShader()
|
||||
{
|
||||
STACK_TRACE;
|
||||
}
|
||||
|
||||
BOOL DebugShader::Initialize(GraphicsDevice *graphicsDevice)
|
||||
{
|
||||
STACK_TRACE;
|
||||
if (!StandardShader::Initialize(graphicsDevice))
|
||||
return FALSE;
|
||||
|
||||
BOOL result = LoadCompileAndLinkInlineSources(m_vertexShaderSource, m_fragmentShaderSource);
|
||||
ASSERT(result == TRUE);
|
||||
|
||||
MapAttributeToStandardAttribType("a_position", VERTEX_STD_POS_3D);
|
||||
MapAttributeToStandardAttribType("a_color", VERTEX_STD_COLOR);
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
|
|
|
@ -3,6 +3,8 @@
|
|||
|
||||
#include "standardshader.h"
|
||||
|
||||
class GraphicsDevice;
|
||||
|
||||
/**
|
||||
* Shader for rendering debug geometry. Will render using solid colors
|
||||
* with thicker lines and larger point sizes.
|
||||
|
@ -12,6 +14,8 @@ class DebugShader : public StandardShader
|
|||
public:
|
||||
DebugShader();
|
||||
virtual ~DebugShader();
|
||||
|
||||
BOOL Initialize(GraphicsDevice *graphicsDevice);
|
||||
|
||||
private:
|
||||
static const char *m_vertexShaderSource;
|
||||
|
|
|
@ -30,17 +30,26 @@ const char* SimpleColorShader::m_fragmentShaderSource =
|
|||
"}\n";
|
||||
|
||||
SimpleColorShader::SimpleColorShader()
|
||||
: StandardShader()
|
||||
{
|
||||
STACK_TRACE;
|
||||
BOOL result = LoadCompileAndLinkInlineSources(m_vertexShaderSource, m_fragmentShaderSource);
|
||||
ASSERT(result == TRUE);
|
||||
|
||||
MapAttributeToStandardAttribType("a_position", VERTEX_STD_POS_3D);
|
||||
MapAttributeToStandardAttribType("a_color", VERTEX_STD_COLOR);
|
||||
}
|
||||
|
||||
SimpleColorShader::~SimpleColorShader()
|
||||
{
|
||||
STACK_TRACE;
|
||||
}
|
||||
|
||||
BOOL SimpleColorShader::Initialize(GraphicsDevice *graphicsDevice)
|
||||
{
|
||||
STACK_TRACE;
|
||||
if (!StandardShader::Initialize(graphicsDevice))
|
||||
return FALSE;
|
||||
|
||||
BOOL result = LoadCompileAndLinkInlineSources(m_vertexShaderSource, m_fragmentShaderSource);
|
||||
ASSERT(result == TRUE);
|
||||
|
||||
MapAttributeToStandardAttribType("a_position", VERTEX_STD_POS_3D);
|
||||
MapAttributeToStandardAttribType("a_color", VERTEX_STD_COLOR);
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
|
|
|
@ -3,6 +3,8 @@
|
|||
|
||||
#include "standardshader.h"
|
||||
|
||||
class GraphicsDevice;
|
||||
|
||||
/**
|
||||
* Shader which renders geometry with vertex colors but no textures.
|
||||
*/
|
||||
|
@ -11,6 +13,8 @@ class SimpleColorShader : public StandardShader
|
|||
public:
|
||||
SimpleColorShader();
|
||||
virtual ~SimpleColorShader();
|
||||
|
||||
BOOL Initialize(GraphicsDevice *graphicsDevice);
|
||||
|
||||
private:
|
||||
static const char *m_vertexShaderSource;
|
||||
|
|
|
@ -35,18 +35,27 @@ const char* SimpleColorTextureShader::m_fragmentShaderSource =
|
|||
"}\n";
|
||||
|
||||
SimpleColorTextureShader::SimpleColorTextureShader()
|
||||
: StandardShader()
|
||||
{
|
||||
STACK_TRACE;
|
||||
BOOL result = LoadCompileAndLinkInlineSources(m_vertexShaderSource, m_fragmentShaderSource);
|
||||
ASSERT(result == TRUE);
|
||||
|
||||
MapAttributeToStandardAttribType("a_position", VERTEX_STD_POS_3D);
|
||||
MapAttributeToStandardAttribType("a_color", VERTEX_STD_COLOR);
|
||||
MapAttributeToStandardAttribType("a_texcoord0", VERTEX_STD_TEXCOORD);
|
||||
}
|
||||
|
||||
SimpleColorTextureShader::~SimpleColorTextureShader()
|
||||
{
|
||||
STACK_TRACE;
|
||||
}
|
||||
|
||||
BOOL SimpleColorTextureShader::Initialize(GraphicsDevice *graphicsDevice)
|
||||
{
|
||||
STACK_TRACE;
|
||||
if (!StandardShader::Initialize(graphicsDevice))
|
||||
return FALSE;
|
||||
|
||||
BOOL result = LoadCompileAndLinkInlineSources(m_vertexShaderSource, m_fragmentShaderSource);
|
||||
ASSERT(result == TRUE);
|
||||
|
||||
MapAttributeToStandardAttribType("a_position", VERTEX_STD_POS_3D);
|
||||
MapAttributeToStandardAttribType("a_color", VERTEX_STD_COLOR);
|
||||
MapAttributeToStandardAttribType("a_texcoord0", VERTEX_STD_TEXCOORD);
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
|
|
|
@ -3,6 +3,8 @@
|
|||
|
||||
#include "standardshader.h"
|
||||
|
||||
class GraphicsDevice;
|
||||
|
||||
/**
|
||||
* Shader which renders geometry using vertex colors modulated with a texture.
|
||||
*/
|
||||
|
@ -11,6 +13,8 @@ class SimpleColorTextureShader : public StandardShader
|
|||
public:
|
||||
SimpleColorTextureShader();
|
||||
virtual ~SimpleColorTextureShader();
|
||||
|
||||
BOOL Initialize(GraphicsDevice *graphicsDevice);
|
||||
|
||||
private:
|
||||
static const char *m_vertexShaderSource;
|
||||
|
|
|
@ -28,18 +28,28 @@ const char* SimpleTextureShader::m_fragmentShaderSource =
|
|||
" gl_FragColor = texture2D(u_texture, v_texCoords);\n"
|
||||
"}\n";
|
||||
|
||||
|
||||
SimpleTextureShader::SimpleTextureShader()
|
||||
: StandardShader()
|
||||
{
|
||||
STACK_TRACE;
|
||||
BOOL result = LoadCompileAndLinkInlineSources(m_vertexShaderSource, m_fragmentShaderSource);
|
||||
ASSERT(result == TRUE);
|
||||
|
||||
MapAttributeToStandardAttribType("a_position", VERTEX_STD_POS_3D);
|
||||
MapAttributeToStandardAttribType("a_texcoord0", VERTEX_STD_TEXCOORD);
|
||||
}
|
||||
|
||||
SimpleTextureShader::~SimpleTextureShader()
|
||||
{
|
||||
STACK_TRACE;
|
||||
}
|
||||
|
||||
BOOL SimpleTextureShader::Initialize(GraphicsDevice *graphicsDevice)
|
||||
{
|
||||
STACK_TRACE;
|
||||
if (!StandardShader::Initialize(graphicsDevice))
|
||||
return FALSE;
|
||||
|
||||
BOOL result = LoadCompileAndLinkInlineSources(m_vertexShaderSource, m_fragmentShaderSource);
|
||||
ASSERT(result == TRUE);
|
||||
|
||||
MapAttributeToStandardAttribType("a_position", VERTEX_STD_POS_3D);
|
||||
MapAttributeToStandardAttribType("a_texcoord0", VERTEX_STD_TEXCOORD);
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
|
|
|
@ -3,6 +3,8 @@
|
|||
|
||||
#include "standardshader.h"
|
||||
|
||||
class GraphicsDevice;
|
||||
|
||||
/**
|
||||
* Shader which renders geometry with texturing but no vertex colors.
|
||||
*/
|
||||
|
@ -11,6 +13,8 @@ class SimpleTextureShader : public StandardShader
|
|||
public:
|
||||
SimpleTextureShader();
|
||||
virtual ~SimpleTextureShader();
|
||||
|
||||
BOOL Initialize(GraphicsDevice *graphicsDevice);
|
||||
|
||||
private:
|
||||
static const char *m_vertexShaderSource;
|
||||
|
|
|
@ -31,18 +31,27 @@ const char* SimpleTextureVertexLerpShader::m_fragmentShaderSource =
|
|||
"}\n";
|
||||
|
||||
SimpleTextureVertexLerpShader::SimpleTextureVertexLerpShader()
|
||||
: VertexLerpShader()
|
||||
{
|
||||
STACK_TRACE;
|
||||
BOOL result = LoadCompileAndLinkInlineSources(m_vertexShaderSource, m_fragmentShaderSource);
|
||||
ASSERT(result == TRUE);
|
||||
|
||||
MapAttributeToVboAttribIndex("a_position1", 0);
|
||||
MapAttributeToVboAttribIndex("a_position2", 1);
|
||||
MapAttributeToStandardAttribType("a_texcoord0", VERTEX_STD_TEXCOORD);
|
||||
}
|
||||
|
||||
SimpleTextureVertexLerpShader::~SimpleTextureVertexLerpShader()
|
||||
{
|
||||
STACK_TRACE;
|
||||
}
|
||||
|
||||
BOOL SimpleTextureVertexLerpShader::Initialize(GraphicsDevice *graphicsDevice)
|
||||
{
|
||||
STACK_TRACE;
|
||||
if (!VertexLerpShader::Initialize(graphicsDevice))
|
||||
return FALSE;
|
||||
|
||||
BOOL result = LoadCompileAndLinkInlineSources(m_vertexShaderSource, m_fragmentShaderSource);
|
||||
ASSERT(result == TRUE);
|
||||
|
||||
MapAttributeToVboAttribIndex("a_position1", 0);
|
||||
MapAttributeToVboAttribIndex("a_position2", 1);
|
||||
MapAttributeToStandardAttribType("a_texcoord0", VERTEX_STD_TEXCOORD);
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
|
|
|
@ -3,11 +3,15 @@
|
|||
|
||||
#include "vertexlerpshader.h"
|
||||
|
||||
class GraphicsDevice;
|
||||
|
||||
class SimpleTextureVertexLerpShader : public VertexLerpShader
|
||||
{
|
||||
public:
|
||||
SimpleTextureVertexLerpShader();
|
||||
virtual ~SimpleTextureVertexLerpShader();
|
||||
|
||||
BOOL Initialize(GraphicsDevice *graphicsDevice);
|
||||
|
||||
private:
|
||||
static const char *m_vertexShaderSource;
|
||||
|
|
|
@ -49,18 +49,27 @@ const char* SimpleTextureVertexSkinningShader::m_fragmentShaderSource =
|
|||
"}\n";
|
||||
|
||||
SimpleTextureVertexSkinningShader::SimpleTextureVertexSkinningShader()
|
||||
: VertexSkinningShader()
|
||||
{
|
||||
STACK_TRACE;
|
||||
BOOL result = LoadCompileAndLinkInlineSources(m_vertexShaderSource, m_fragmentShaderSource);
|
||||
ASSERT(result == TRUE);
|
||||
|
||||
MapAttributeToVboAttribIndex("a_jointIndex", 0);
|
||||
MapAttributeToStandardAttribType("a_position", VERTEX_STD_POS_3D);
|
||||
MapAttributeToStandardAttribType("a_texcoord0", VERTEX_STD_TEXCOORD);
|
||||
}
|
||||
|
||||
SimpleTextureVertexSkinningShader::~SimpleTextureVertexSkinningShader()
|
||||
{
|
||||
STACK_TRACE;
|
||||
}
|
||||
|
||||
BOOL SimpleTextureVertexSkinningShader::Initialize(GraphicsDevice *graphicsDevice)
|
||||
{
|
||||
STACK_TRACE;
|
||||
if (!VertexSkinningShader::Initialize(graphicsDevice))
|
||||
return FALSE;
|
||||
|
||||
BOOL result = LoadCompileAndLinkInlineSources(m_vertexShaderSource, m_fragmentShaderSource);
|
||||
ASSERT(result == TRUE);
|
||||
|
||||
MapAttributeToVboAttribIndex("a_jointIndex", 0);
|
||||
MapAttributeToStandardAttribType("a_position", VERTEX_STD_POS_3D);
|
||||
MapAttributeToStandardAttribType("a_texcoord0", VERTEX_STD_TEXCOORD);
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
|
|
|
@ -3,12 +3,16 @@
|
|||
|
||||
#include "vertexskinningshader.h"
|
||||
|
||||
class GraphicsDevice;
|
||||
|
||||
class SimpleTextureVertexSkinningShader : public VertexSkinningShader
|
||||
{
|
||||
public:
|
||||
SimpleTextureVertexSkinningShader();
|
||||
virtual ~SimpleTextureVertexSkinningShader();
|
||||
|
||||
BOOL Initialize(GraphicsDevice *graphicsDevice);
|
||||
|
||||
private:
|
||||
static const char *m_vertexShaderSource;
|
||||
static const char *m_fragmentShaderSource;
|
||||
|
|
|
@ -41,18 +41,27 @@ const char* Sprite2DShader::m_fragmentShaderSource =
|
|||
"}\n";
|
||||
|
||||
Sprite2DShader::Sprite2DShader()
|
||||
: SpriteShader()
|
||||
{
|
||||
STACK_TRACE;
|
||||
BOOL result = LoadCompileAndLinkInlineSources(m_vertexShaderSource, m_fragmentShaderSource);
|
||||
ASSERT(result == TRUE);
|
||||
|
||||
MapAttributeToStandardAttribType("a_position", VERTEX_STD_POS_2D);
|
||||
MapAttributeToStandardAttribType("a_color", VERTEX_STD_COLOR);
|
||||
MapAttributeToStandardAttribType("a_texcoord0", VERTEX_STD_TEXCOORD);
|
||||
}
|
||||
|
||||
Sprite2DShader::~Sprite2DShader()
|
||||
{
|
||||
STACK_TRACE;
|
||||
}
|
||||
|
||||
BOOL Sprite2DShader::Initialize(GraphicsDevice *graphicsDevice)
|
||||
{
|
||||
STACK_TRACE;
|
||||
if (!SpriteShader::Initialize(graphicsDevice))
|
||||
return FALSE;
|
||||
|
||||
BOOL result = LoadCompileAndLinkInlineSources(m_vertexShaderSource, m_fragmentShaderSource);
|
||||
ASSERT(result == TRUE);
|
||||
|
||||
MapAttributeToStandardAttribType("a_position", VERTEX_STD_POS_2D);
|
||||
MapAttributeToStandardAttribType("a_color", VERTEX_STD_COLOR);
|
||||
MapAttributeToStandardAttribType("a_texcoord0", VERTEX_STD_TEXCOORD);
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
|
|
|
@ -3,6 +3,8 @@
|
|||
|
||||
#include "spriteshader.h"
|
||||
|
||||
class GraphicsDevice;
|
||||
|
||||
/**
|
||||
* Shader for rendering 2D sprites with vertex color modulation. Includes
|
||||
* special support for color modulation using RGB, RGBA, and alpha-only
|
||||
|
@ -13,6 +15,8 @@ class Sprite2DShader : public SpriteShader
|
|||
public:
|
||||
Sprite2DShader();
|
||||
virtual ~Sprite2DShader();
|
||||
|
||||
BOOL Initialize(GraphicsDevice *graphicsDevice);
|
||||
|
||||
private:
|
||||
static const char *m_vertexShaderSource;
|
||||
|
|
|
@ -47,18 +47,27 @@ const char* Sprite3DShader::m_fragmentShaderSource =
|
|||
"}\n";
|
||||
|
||||
Sprite3DShader::Sprite3DShader()
|
||||
: SpriteShader()
|
||||
{
|
||||
STACK_TRACE;
|
||||
BOOL result = LoadCompileAndLinkInlineSources(m_vertexShaderSource, m_fragmentShaderSource);
|
||||
ASSERT(result == TRUE);
|
||||
|
||||
MapAttributeToStandardAttribType("a_position", VERTEX_STD_POS_3D);
|
||||
MapAttributeToStandardAttribType("a_color", VERTEX_STD_COLOR);
|
||||
MapAttributeToStandardAttribType("a_texcoord0", VERTEX_STD_TEXCOORD);
|
||||
}
|
||||
|
||||
Sprite3DShader::~Sprite3DShader()
|
||||
{
|
||||
STACK_TRACE;
|
||||
}
|
||||
|
||||
BOOL Sprite3DShader::Initialize(GraphicsDevice *graphicsDevice)
|
||||
{
|
||||
STACK_TRACE;
|
||||
if (!SpriteShader::Initialize(graphicsDevice))
|
||||
return FALSE;
|
||||
|
||||
BOOL result = LoadCompileAndLinkInlineSources(m_vertexShaderSource, m_fragmentShaderSource);
|
||||
ASSERT(result == TRUE);
|
||||
|
||||
MapAttributeToStandardAttribType("a_position", VERTEX_STD_POS_3D);
|
||||
MapAttributeToStandardAttribType("a_color", VERTEX_STD_COLOR);
|
||||
MapAttributeToStandardAttribType("a_texcoord0", VERTEX_STD_TEXCOORD);
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
|
|
|
@ -3,6 +3,8 @@
|
|||
|
||||
#include "spriteshader.h"
|
||||
|
||||
class GraphicsDevice;
|
||||
|
||||
/**
|
||||
* Shader for rendering 3D billboard sprites with vertex color modulation.
|
||||
* Includes special support for color modulation using RGB, RGBA, and
|
||||
|
@ -14,6 +16,8 @@ class Sprite3DShader : public SpriteShader
|
|||
public:
|
||||
Sprite3DShader();
|
||||
virtual ~Sprite3DShader();
|
||||
|
||||
BOOL Initialize(GraphicsDevice *graphicsDevice);
|
||||
|
||||
private:
|
||||
static const char *m_vertexShaderSource;
|
||||
|
|
|
@ -3,7 +3,6 @@
|
|||
#include "spriteshader.h"
|
||||
|
||||
SpriteShader::SpriteShader()
|
||||
: StandardShader()
|
||||
{
|
||||
STACK_TRACE;
|
||||
SetTextureHasAlphaOnlyUniform("u_textureHasAlphaOnly");
|
||||
|
|
|
@ -4,7 +4,6 @@
|
|||
#include "../math/matrix4x4.h"
|
||||
|
||||
StandardShader::StandardShader()
|
||||
: Shader()
|
||||
{
|
||||
STACK_TRACE;
|
||||
m_inlineVertexShaderSource = NULL;
|
||||
|
|
|
@ -3,7 +3,6 @@
|
|||
#include "vertexlerpshader.h"
|
||||
|
||||
VertexLerpShader::VertexLerpShader()
|
||||
: StandardShader()
|
||||
{
|
||||
STACK_TRACE;
|
||||
SetLerpUniform("u_lerp");
|
||||
|
|
|
@ -5,7 +5,6 @@
|
|||
#include "../math/vector3.h"
|
||||
|
||||
VertexSkinningShader::VertexSkinningShader()
|
||||
: StandardShader()
|
||||
{
|
||||
STACK_TRACE;
|
||||
SetJointPositionsUniform("u_jointPositions");
|
||||
|
|
Reference in a new issue