Merge branch 'v3' into wp8.1-universal

This commit is contained in:
Dale Stammen 2014-10-24 07:08:55 -07:00
commit 40e49cdc12
7 changed files with 38 additions and 50 deletions

View File

@ -1,3 +1,7 @@
cocos2d-x-3.3 ??
[FIX] Label: label shifting when outline feature enabled
[FIX] Sprite3D: did not create attached sprite from cache
cocos2d-x-3.3-rc0 Oct.21 2014
[NEW] 3d: added light support: direction light, point light, spot light and ambient light
[NEW] Added ClippingRectangleNode

View File

@ -67,7 +67,7 @@ FontAtlas::FontAtlas(Font &theFont)
auto outlineSize = fontTTf->getOutlineSize();
if(outlineSize > 0)
{
_commonLineHeight += 2 * outlineSize * CC_CONTENT_SCALE_FACTOR();
_commonLineHeight += 2 * outlineSize;
_currentPageDataSize *= 2;
}

View File

@ -95,12 +95,12 @@ FT_Library FontFreeType::getFTLibrary()
FontFreeType::FontFreeType(bool distanceFieldEnabled /* = false */,int outline /* = 0 */)
: _fontRef(nullptr)
,_distanceFieldEnabled(distanceFieldEnabled)
,_outlineSize(outline)
,_outlineSize(0.0f)
,_stroker(nullptr)
{
if (_outlineSize > 0)
if (outline > 0)
{
_outlineSize *= CC_CONTENT_SCALE_FACTOR();
_outlineSize = outline * CC_CONTENT_SCALE_FACTOR();
FT_Stroker_New(FontFreeType::getFTLibrary(), &_stroker);
FT_Stroker_Set(_stroker,
(int)(_outlineSize * 64),
@ -328,8 +328,6 @@ unsigned char* FontFreeType::getGlyphBitmap(unsigned short theChar, long &outWid
}
}
outRect.origin.x = bbox.xMin >> 6;
outRect.origin.y = - (bbox.yMax >> 6);
xAdvance += 2 * _outlineSize;
outRect.size.width = blendWidth;
outRect.size.height = blendHeight;

View File

@ -92,6 +92,14 @@ bool Sprite3D::loadFromCache(const std::string& path)
}
}
for(const auto& it : spritedata->nodedatas->skeleton)
{
if(it)
{
createAttachSprite3DNode(it,*(spritedata->materialdatas));
}
}
for (ssize_t i = 0; i < _meshes.size(); i++) {
_meshes.at(i)->setGLProgramState(spritedata->glProgramStates.at(i));
}

View File

@ -69,6 +69,9 @@ public:
/**get mesh*/
Mesh* getMesh() const { return _meshes.at(0); }
/** get mesh count */
ssize_t getMeshCount() const { return _meshes.size(); }
/**get skin*/
CC_DEPRECATED_ATTRIBUTE MeshSkin* getSkin() const;

View File

@ -45,13 +45,6 @@ THE SOFTWARE.
NS_CC_BEGIN
typedef struct _hashUniformEntry
{
GLvoid* value; // value
unsigned int location; // Key
UT_hash_handle hh; // hash entry
} tHashUniformEntry;
const char* GLProgram::SHADER_NAME_POSITION_TEXTURE_COLOR = "ShaderPositionTextureColor";
const char* GLProgram::SHADER_NAME_POSITION_TEXTURE_COLOR_NO_MVP = "ShaderPositionTextureColor_noMVP";
const char* GLProgram::SHADER_NAME_POSITION_TEXTURE_ALPHA_TEST = "ShaderPositionTextureColorAlphaTest";
@ -136,7 +129,6 @@ GLProgram::GLProgram()
: _program(0)
, _vertShader(0)
, _fragShader(0)
, _hashForUniforms(nullptr)
, _flags()
{
memset(_builtInUniforms, 0, sizeof(_builtInUniforms));
@ -163,15 +155,11 @@ GLProgram::~GLProgram()
GL::deleteProgram(_program);
}
tHashUniformEntry *current_element, *tmp;
// Purge uniform hash
HASH_ITER(hh, _hashForUniforms, current_element, tmp)
for (auto e : _hashForUniforms)
{
HASH_DEL(_hashForUniforms, current_element);
free(current_element->value);
free(current_element);
free(e.second);
}
_hashForUniforms.clear();
}
bool GLProgram::initWithByteArrays(const GLchar* vShaderByteArray, const GLchar* fShaderByteArray)
@ -222,7 +210,8 @@ bool GLProgram::initWithByteArrays(const GLchar* vShaderByteArray, const GLchar*
{
glAttachShader(_program, _fragShader);
}
_hashForUniforms = nullptr;
_hashForUniforms.clear();
CHECK_GL_ERROR_DEBUG();
@ -260,7 +249,7 @@ bool GLProgram::initWithPrecompiledProgramByteArray(const GLchar* vShaderByteArr
haveProgram = CCPrecompiledShaders::getInstance()->loadProgram(_program, vShaderByteArray, fShaderByteArray);
CHECK_GL_ERROR_DEBUG();
_hashForUniforms = nullptr;
_hashForUniforms.clear();
CHECK_GL_ERROR_DEBUG();
@ -633,31 +622,23 @@ bool GLProgram::updateUniformLocation(GLint location, const GLvoid* data, unsign
}
bool updated = true;
tHashUniformEntry *element = nullptr;
HASH_FIND_INT(_hashForUniforms, &location, element);
if (! element)
auto element = _hashForUniforms.find(location);
if (element == _hashForUniforms.end())
{
element = (tHashUniformEntry*)malloc( sizeof(*element) );
// key
element->location = location;
// value
element->value = malloc( bytes );
memcpy(element->value, data, bytes );
HASH_ADD_INT(_hashForUniforms, location, element);
GLvoid* value = malloc(bytes);
memcpy(value, data, bytes );
_hashForUniforms.insert(std::make_pair(location, value));
}
else
{
if (memcmp(element->value, data, bytes) == 0)
if (memcmp(element->second, data, bytes) == 0)
{
updated = false;
}
else
{
memcpy(element->value, data, bytes);
memcpy(element->second, data, bytes);
}
}
@ -923,17 +904,12 @@ void GLProgram::reset()
//GL::deleteProgram(_program);
_program = 0;
tHashUniformEntry *current_element, *tmp;
// Purge uniform hash
HASH_ITER(hh, _hashForUniforms, current_element, tmp)
for (auto e: _hashForUniforms)
{
HASH_DEL(_hashForUniforms, current_element);
free(current_element->value);
free(current_element);
free(e.second);
}
_hashForUniforms = nullptr;
_hashForUniforms.clear();
}
NS_CC_END

View File

@ -45,7 +45,6 @@ NS_CC_BEGIN
* @{
*/
struct _hashUniformEntry;
class GLProgram;
typedef void (*GLInfoFunction)(GLuint program, GLenum pname, GLint* params);
@ -340,7 +339,6 @@ protected:
GLuint _vertShader;
GLuint _fragShader;
GLint _builtInUniforms[UNIFORM_MAX];
struct _hashUniformEntry* _hashForUniforms;
bool _hasShaderCompiler;
#if (CC_TARGET_PLATFORM == CC_PLATFORM_WP8) || defined(WP8_SHADER_COMPILER)
@ -360,6 +358,7 @@ protected:
std::unordered_map<std::string, Uniform> _userUniforms;
std::unordered_map<std::string, VertexAttrib> _vertexAttribs;
std::unordered_map<GLint, GLvoid*> _hashForUniforms;
};
NS_CC_END