From 7c870cfcc17cf0fbd972e04d544faa3f48fdfc78 Mon Sep 17 00:00:00 2001 From: "Huabing.Xu" Date: Fri, 29 Aug 2014 09:50:26 +0800 Subject: [PATCH 1/3] fix skew matrix bug --- cocos/2d/CCNode.cpp | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/cocos/2d/CCNode.cpp b/cocos/2d/CCNode.cpp index 887ab70cbf..4ac0373528 100644 --- a/cocos/2d/CCNode.cpp +++ b/cocos/2d/CCNode.cpp @@ -1672,10 +1672,14 @@ const Mat4& Node::getNodeToParentTransform() const // If skew is needed, apply skew and then anchor point if (needsSkewMatrix) { - Mat4 skewMatrix(1, (float)tanf(CC_DEGREES_TO_RADIANS(_skewY)), 0, 0, - (float)tanf(CC_DEGREES_TO_RADIANS(_skewX)), 1, 0, 0, - 0, 0, 1, 0, - 0, 0, 0, 1); + float skewMatArray[16] = + { + 1, (float)tanf(CC_DEGREES_TO_RADIANS(_skewY)), 0, 0, + (float)tanf(CC_DEGREES_TO_RADIANS(_skewX)), 1, 0, 0, + 0, 0, 1, 0, + 0, 0, 0, 1 + }; + Mat4 skewMatrix(skewMatArray); _transform = _transform * skewMatrix; From 528f4b5c0ce8100bf6d92fd6cd3f07d4ea590aa2 Mon Sep 17 00:00:00 2001 From: "Huabing.Xu" Date: Fri, 29 Aug 2014 10:06:44 +0800 Subject: [PATCH 2/3] fix TextureAtlas drawNumberofQuads bug --- cocos/renderer/CCTextureAtlas.cpp | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/cocos/renderer/CCTextureAtlas.cpp b/cocos/renderer/CCTextureAtlas.cpp index b60c47bc92..a1c721011f 100644 --- a/cocos/renderer/CCTextureAtlas.cpp +++ b/cocos/renderer/CCTextureAtlas.cpp @@ -625,9 +625,9 @@ void TextureAtlas::drawNumberOfQuads(ssize_t numberOfQuads, ssize_t start) // glBufferData(GL_ARRAY_BUFFER, sizeof(quads_[0]) * (n-start), &quads_[start], GL_DYNAMIC_DRAW); // option 3: orphaning + glMapBuffer - glBufferData(GL_ARRAY_BUFFER, sizeof(_quads[0]) * (numberOfQuads-start), nullptr, GL_DYNAMIC_DRAW); + glBufferData(GL_ARRAY_BUFFER, sizeof(_quads[0]) * _capacity, nullptr, GL_DYNAMIC_DRAW); void *buf = glMapBuffer(GL_ARRAY_BUFFER, GL_WRITE_ONLY); - memcpy(buf, _quads, sizeof(_quads[0])* (numberOfQuads-start)); + memcpy(buf, _quads, sizeof(_quads[0])* _totalQuads); glUnmapBuffer(GL_ARRAY_BUFFER); glBindBuffer(GL_ARRAY_BUFFER, 0); @@ -661,7 +661,7 @@ void TextureAtlas::drawNumberOfQuads(ssize_t numberOfQuads, ssize_t start) // XXX: update is done in draw... perhaps it should be done in a timer if (_dirty) { - glBufferSubData(GL_ARRAY_BUFFER, sizeof(_quads[0])*start, sizeof(_quads[0]) * numberOfQuads , &_quads[start] ); + glBufferSubData(GL_ARRAY_BUFFER, 0, sizeof(_quads[0]) * _totalQuads , &_quads[0] ); _dirty = false; } From 8e51377f2dca717e9ecb8d81ed1264f785063249 Mon Sep 17 00:00:00 2001 From: "Huabing.Xu" Date: Fri, 29 Aug 2014 16:00:04 +0800 Subject: [PATCH 3/3] fix primitive draw error --- cocos/renderer/CCPrimitive.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/cocos/renderer/CCPrimitive.cpp b/cocos/renderer/CCPrimitive.cpp index 357e61fa43..e7a896c1ad 100644 --- a/cocos/renderer/CCPrimitive.cpp +++ b/cocos/renderer/CCPrimitive.cpp @@ -86,7 +86,7 @@ bool Primitive::init(VertexData* verts, IndexBuffer* indices, int type) void Primitive::draw() { - if(_verts && _indices) + if(_verts) { _verts->use(); if(_indices!= nullptr) @@ -98,7 +98,7 @@ void Primitive::draw() } else { - glDrawArrays((GLenum)_type, _count, _start); + glDrawArrays((GLenum)_type, _start, _count); } glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, 0);