From 86567afa5f8858185058e7f5142a1a31c491bda9 Mon Sep 17 00:00:00 2001 From: Dale Stammen Date: Fri, 16 Jan 2015 15:02:05 -0800 Subject: [PATCH] added kShaderType_PositionColor_noMVP_GrayScale for WP8 to support UIScale9Sprite --- cocos/renderer/CCGLProgram.cpp | 3 +++ cocos/renderer/CCGLProgram.h | 3 +++ cocos/renderer/CCGLProgramCache.cpp | 20 +++++++++++++++++++- 3 files changed, 25 insertions(+), 1 deletion(-) diff --git a/cocos/renderer/CCGLProgram.cpp b/cocos/renderer/CCGLProgram.cpp index cef6a240a6..3c878b42eb 100644 --- a/cocos/renderer/CCGLProgram.cpp +++ b/cocos/renderer/CCGLProgram.cpp @@ -52,6 +52,9 @@ const char* GLProgram::SHADER_NAME_POSITION_TEXTURE_ALPHA_TEST_NO_MV = "ShaderPo const char* GLProgram::SHADER_NAME_POSITION_COLOR = "ShaderPositionColor"; const char* GLProgram::SHADER_NAME_POSITION_COLOR_POINTSIZE = "ShaderPositionColorPointsize"; const char* GLProgram::SHADER_NAME_POSITION_COLOR_NO_MVP = "ShaderPositionColor_noMVP"; +#if CC_TARGET_PLATFORM == CC_PLATFORM_WP8 || defined(WP8_SHADER_COMPILER) +const char* GLProgram::SHADER_NAME_POSITION_COLOR_NO_MVP_GRAYSCALE = "ShaderPositionColor_noMVP_GrayScale"; +#endif const char* GLProgram::SHADER_NAME_POSITION_TEXTURE = "ShaderPositionTexture"; const char* GLProgram::SHADER_NAME_POSITION_TEXTURE_U_COLOR = "ShaderPositionTexture_uColor"; const char* GLProgram::SHADER_NAME_POSITION_TEXTURE_A8_COLOR = "ShaderPositionTextureA8Color"; diff --git a/cocos/renderer/CCGLProgram.h b/cocos/renderer/CCGLProgram.h index 9566846f5b..a348f54854 100644 --- a/cocos/renderer/CCGLProgram.h +++ b/cocos/renderer/CCGLProgram.h @@ -122,6 +122,9 @@ public: static const char* SHADER_NAME_POSITION_COLOR; static const char* SHADER_NAME_POSITION_COLOR_POINTSIZE; static const char* SHADER_NAME_POSITION_COLOR_NO_MVP; +#if CC_TARGET_PLATFORM == CC_PLATFORM_WP8 || defined(WP8_SHADER_COMPILER) + static const char* SHADER_NAME_POSITION_COLOR_NO_MVP_GRAYSCALE; +#endif static const char* SHADER_NAME_POSITION_TEXTURE; static const char* SHADER_NAME_POSITION_TEXTURE_U_COLOR; static const char* SHADER_NAME_POSITION_TEXTURE_A8_COLOR; diff --git a/cocos/renderer/CCGLProgramCache.cpp b/cocos/renderer/CCGLProgramCache.cpp index da8d77fc8c..1954420ab2 100644 --- a/cocos/renderer/CCGLProgramCache.cpp +++ b/cocos/renderer/CCGLProgramCache.cpp @@ -32,6 +32,10 @@ THE SOFTWARE. #include "base/ccMacros.h" #include "base/CCConfiguration.h" +#if CC_TARGET_PLATFORM == CC_PLATFORM_WP8 || defined(WP8_SHADER_COMPILER) +#include "ui/shaders/UIShaders.h" +#endif + NS_CC_BEGIN enum { @@ -57,6 +61,9 @@ enum { kShaderType_3DPositionNormal, kShaderType_3DPositionNormalTex, kShaderType_3DSkinPositionNormalTex, +#if CC_TARGET_PLATFORM == CC_PLATFORM_WP8 || defined(WP8_SHADER_COMPILER) + kShaderType_PositionColor_noMVP_GrayScale, +#endif kShaderType_MAX, }; @@ -228,6 +235,13 @@ void GLProgramCache::loadDefaultGLPrograms() p = new GLProgram(); loadDefaultGLProgram(p, kShaderType_3DSkinPositionNormalTex); _programs.insert(std::make_pair(GLProgram::SHADER_3D_SKINPOSITION_NORMAL_TEXTURE, p)); + +#if CC_TARGET_PLATFORM == CC_PLATFORM_WP8 || defined(WP8_SHADER_COMPILER) + p = new GLProgram(); + loadDefaultGLProgram(p, kShaderType_PositionColor_noMVP_GrayScale); + _programs.insert(std::make_pair(GLProgram::SHADER_NAME_POSITION_COLOR_NO_MVP_GRAYSCALE, p)); +#endif + } void GLProgramCache::reloadDefaultGLPrograms() @@ -358,7 +372,6 @@ void GLProgramCache::loadDefaultGLProgram(GLProgram *p, int type) case kShaderType_PositionTextureColor_noMVP: p->initWithByteArrays(ccPositionTextureColor_noMVP_vert, ccPositionTextureColor_noMVP_frag); break; - case kShaderType_PositionTextureColorAlphaTest: p->initWithByteArrays(ccPositionTextureColor_vert, ccPositionTextureColorAlphaTest_frag); break; @@ -431,6 +444,11 @@ void GLProgramCache::loadDefaultGLProgram(GLProgram *p, int type) p->initWithByteArrays((def + std::string(cc3D_SkinPositionNormalTex_vert)).c_str(), (def + std::string(cc3D_ColorNormalTex_frag)).c_str()); } break; +#if CC_TARGET_PLATFORM == CC_PLATFORM_WP8 || defined(WP8_SHADER_COMPILER) + case kShaderType_PositionColor_noMVP_GrayScale: + p->initWithByteArrays(ccPositionTextureColor_noMVP_vert, ccUIGrayScale_frag); + break; +#endif default: CCLOG("cocos2d: %s:%d, error shader type", __FUNCTION__, __LINE__); return;