Merge pull request #7908 from dabingnn/v3_fix_bugs

V3 fix bugs
This commit is contained in:
minggo 2014-08-29 16:45:52 +08:00
commit afaea360fd
3 changed files with 13 additions and 9 deletions

View File

@ -1693,10 +1693,14 @@ const Mat4& Node::getNodeToParentTransform() const
// If skew is needed, apply skew and then anchor point // If skew is needed, apply skew and then anchor point
if (needsSkewMatrix) if (needsSkewMatrix)
{ {
Mat4 skewMatrix(1, (float)tanf(CC_DEGREES_TO_RADIANS(_skewY)), 0, 0, float skewMatArray[16] =
(float)tanf(CC_DEGREES_TO_RADIANS(_skewX)), 1, 0, 0, {
0, 0, 1, 0, 1, (float)tanf(CC_DEGREES_TO_RADIANS(_skewY)), 0, 0,
0, 0, 0, 1); (float)tanf(CC_DEGREES_TO_RADIANS(_skewX)), 1, 0, 0,
0, 0, 1, 0,
0, 0, 0, 1
};
Mat4 skewMatrix(skewMatArray);
_transform = _transform * skewMatrix; _transform = _transform * skewMatrix;

View File

@ -86,7 +86,7 @@ bool Primitive::init(VertexData* verts, IndexBuffer* indices, int type)
void Primitive::draw() void Primitive::draw()
{ {
if(_verts && _indices) if(_verts)
{ {
_verts->use(); _verts->use();
if(_indices!= nullptr) if(_indices!= nullptr)
@ -98,7 +98,7 @@ void Primitive::draw()
} }
else else
{ {
glDrawArrays((GLenum)_type, _count, _start); glDrawArrays((GLenum)_type, _start, _count);
} }
glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, 0); glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, 0);

View File

@ -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); // glBufferData(GL_ARRAY_BUFFER, sizeof(quads_[0]) * (n-start), &quads_[start], GL_DYNAMIC_DRAW);
// option 3: orphaning + glMapBuffer // 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); 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); glUnmapBuffer(GL_ARRAY_BUFFER);
glBindBuffer(GL_ARRAY_BUFFER, 0); 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 // XXX: update is done in draw... perhaps it should be done in a timer
if (_dirty) 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; _dirty = false;
} }