bennyk / SmoothDrawing-x

Draw smooth lines on Cocos2d-X
MIT License
7 stars 5 forks source link

can't compile with cocos2dx 3-13 #1

Open intmainreturn00 opened 7 years ago

intmainreturn00 commented 7 years ago

Hello, I'm currently doing something simillar

Interesting project, but I can't compile it with cocos2dx 3-13.

linedrawer.hpp(369): error C2668: 'cocos2d::TrianglesCommand::init': ambiguous call to overloaded function
2>  c:\work\awesomenode\cocos2d\cocos\renderer\cctrianglescommand.h(74): note: could be 'void cocos2d::TrianglesCommand::init(float,cocos2d::Texture2D *,cocos2d::GLProgramState *,cocos2d::BlendFunc,const cocos2d::TrianglesCommand::Triangles &,const cocos2d::Mat4 &,uint32_t)'
2>  c:\work\awesomenode\cocos2d\cocos\renderer\cctrianglescommand.h(71): note: or       'void cocos2d::TrianglesCommand::init(float,GLuint,cocos2d::GLProgramState *,cocos2d::BlendFunc,const cocos2d::TrianglesCommand::Triangles &,const cocos2d::Mat4 &,uint32_t)'
2>  c:\work\awesomenode\classes\linedrawer.hpp(369): note: while trying to match the argument list '(float, int, cocos2d::GLProgramState *, const cocos2d::BlendFunc, cocos2d::TrianglesCommand::Triangles, const cocos2d::Mat4, int)'
intmainreturn00 commented 7 years ago

and then if I specify concrete overloading function version by cast to Texture2D* or GLuint the code fails at assertion at CCNode

intmainreturn00 commented 7 years ago

Here TrianglesCommand::Triangles trs{&_vertices[0], &_indices[0], static_cast<ssize_t>(_vertices.size()), static_cast<ssize_t>(_indices.size())}; _triangleCommand.init(getGlobalZOrder(), nullptr, getGLProgramState(), cocos2d::BlendFunc::ALPHA_PREMULTIPLIED, trs, transform, 0); renderer->addCommand(&_triangleCommand);

when I touch screen I get _vertices and _indices size = 0 and so I've got vector out of bounds exception.

intmainreturn00 commented 7 years ago

Well...I can rewrite the initialization list to this: TrianglesCommand::Triangles trs; trs.indexCount = static_cast<ssize_t>(_indices.size()); trs.indexCount = static_cast<ssize_t>(_vertices.size()); trs.verts = _vertices.data(); trs.indices = _indices.data();

You see your version probably incorrect, since it use _vertices[0] form and can lead to exception at vector with 0 elements. But even after that I've get crashed.

intmainreturn00 commented 7 years ago

Ok, I leave the TriangleCommand and rewrite this code with my custom DrawNode::drawTriangle call. now I can test it)

intmainreturn00 commented 7 years ago

aghhh. and now I see, that your algorithm is pretty much like my own, it has the same limitation with drawing non-opacity colors =(

intmainreturn00 commented 7 years ago

image

intmainreturn00 commented 7 years ago

and anti-aliasing is too small... =( image

Can we varray the level of anti-aliasing? set the width of the line's feathers?