I’ve read about drawCircle method but i really can’t draw this simple thing even after searching on this forum. Here is my code.
DrawNode *drawnode = DrawNode::create();
drawnode->drawCircle(Vec2(100,100), 250, 0, 1, true, 1, 1, Color4F::BLACK);
this->addChild(drawnode);
The result is i only see the straight line (maybe it connect from the center to circle)
On the document:
void drawCircle ( const Vec2 & center,
float radius,
float angle,
unsigned int segments,
bool drawLineToCenter,
float scaleX,
float scaleY,
const Color4F & color
)
What’s scaleX,Y , what’s angle, what are segments.
I think the document is really poor to understand what are those.
I’ve succesfully drawn a circle with drawCircle()
after setted the segments to 1000.
Maybe itsn’t smooth enough.
drawDot()
can do it but it draws the solid circle like drawSolidCircle
.
All i want is drawing a circle with thick border and having difference background color.
Makes sense. I usually use drawdot
as I have wanted nested solid circles.
After certain times, i realize above method can’t even draw smooth circle.
Any way to make anti-aliasing for circle?
almax27
October 20, 2016, 10:28am
6
I’ve read the post, apply the code and see my sprite disappearing.
glprogram = new GLProgram();
glprogram->initWithFilenames("shader.vert", "shader.frag");
glprogram->bindAttribLocation(GLProgram::ATTRIBUTE_NAME_POSITION, GLProgram::VERTEX_ATTRIB_POSITION);
glprogram->bindAttribLocation(GLProgram::ATTRIBUTE_NAME_COLOR, GLProgram::VERTEX_ATTRIB_COLOR);
glprogram->bindAttribLocation(GLProgram::ATTRIBUTE_NAME_TEX_COORD, GLProgram::VERTEX_ATTRIB_TEX_COORDS);
glprogram->link();
glprogram->updateUniforms();
glprogram->use();
GLProgramState* state = GLProgramState::getOrCreateWithGLProgram(glprogram);
sprite->setGLProgram(glprogram);
sprite->setGLProgramState(state);
state->setUniformFloat("border", 0.01);
state->setUniformFloat("circle_radius", 5.0);
state->setUniformVec4("circle_color", Vec4(1.0, 1.0, 1.0, 1.0));
state->setUniformVec2("circle_center", Vec2(0.5, 0.5));
Please post the fragment shader you are using and check your logs to ensure there are no GL errors or indications of the shader failing to compile or bind
Basically, my goal is drawing and redrawing a smooth circle after each cursor moving step.
I use the shader code on the page 2 of your page: http://www.geeks3d.com/20130705/shader-library-circle-disc-fake-sphere-in-glsl-opengl-glslhacker/2/
I apply it to a sprite for testing, and it makes the sprite disappear.
I’ve tried some example of applying shader to the sprite.
But really don’t know with this above shader, it draws the circle itself or how do i apply to the drawCircle
.