HelloWorldScene.h
For example, the following code is added:
Protected: void OnDraw (const KMMAT4 &transform, bool transformupdated); Customcommand _customcommand;
HelloWorldScene.cpp
void HelloWorld::d Raw (Cocos2d::renderer *renderer, const KMMAT4 &transform, bool transformupdated) {_customcommand . init (1); _customcommand.func = Cc_callback_0 (Helloworld::ondraw, this,transform,transformupdated); Renderer->addcommand (&_customcommand);} void Helloworld::ondraw (const KMMAT4 &transform, bool transformupdated) {Kmglpushmatrix (); Kmglloadmatrix (&transform); /* Straight line */Check_gl_error_debug (); Drawprimitives::d rawline (Visiblerect::leftbottom (), Visiblerect::righttop ()); Check_gl_error_debug (); Gllinewidth (5.0f); DRAWPRIMITIVES::SETDRAWCOLOR4B (255,0,0,255); Drawprimitives::d rawline (Point (0, 0), point (100, 100)); Draw big Point in the center Drawprimitives::setpointsize (64); DRAWPRIMITIVES::SETDRAWCOLOR4B (100, 0, 255, 128); Drawprimitives::d rawpoint (Visiblerect::center ()); Check_gl_error_debug (); Draw 4 small points point points[] = {point (60,60), point (70,70), point (160,70), point (170,60)}; Drawprimitives::setpointsize (10); DRAWPRIMITIVES::SETDRAWCOLOR4B (0,10,255,255); Drawprimitives::d rawpoints (points, 4); Check_gl_error_debug (); Draw a green circle with ten segments gllinewidth (16); DRAWPRIMITIVES::SETDRAWCOLOR4B (0, 255, 0, 255); Drawprimitives::d rawcircle (Visiblerect::center (), 0, N, false); Check_gl_error_debug (); Draw a green circle with the segments with line to center Gllinewidth (2); DRAWPRIMITIVES::SETDRAWCOLOR4B (0, 255, 255, 255); Drawprimitives::d rawcircle (Visiblerect::center (), Max, Cc_degrees_to_radians (+), and false); Check_gl_error_debug (); Draw a pink solid circle with segments Gllinewidth (2); DRAWPRIMITIVES::SETDRAWCOLOR4B (255, 0, 255, 255); Drawprimitives::d rawsolidcircle (Visiblerect::center () + point (140,0), Max, Cc_degrees_to_radians (n), 1.0f, 1.0f); Check_gl_error_debug (); Open Yellow Poly DRAWPRIMITIVES::SETDRAWCOLOR4B (255, 255, 0, 255); Gllinewidth (5); Point vertices[] = {point (10,10), point (50,50), point (100,50), point (150,100), point (200,150)}; Drawprimitives::d rawpoly (vertices, 5, false); Check_gl_error_debug (); Filled Poly gllinewidth (1); Point filledvertices[] = {point (0,120), point (50,120), point (50,170), point (25,200), point (0,170)}; Drawprimitives::d rawsolidpoly (Filledvertices, 5, color4f (0.5f, 0.5f, 1, 1)); Closed Purble Poly drawprimitives::setdrawcolor4b (255, 0, 255, 255); Gllinewidth (2); Point vertices2[] = {point (30,130), point (30,230), point (50,200)}; Drawprimitives::d rawpoly (Vertices2, 3, true); Check_gl_error_debug (); Draw Quad Bézier path drawprimitives::d rawquadbezier (Visiblerect::lefttop (), Visiblerect::center (), Visiblerect:: Righttop (), 50); Check_gl_error_debug (); Draw cubic Bézier path drawprimitives::d RawcubicbeziER (Visiblerect::center (), point (Visiblerect::center (). X+30,visiblerect::center (). y+150), point (Visiblerect:: Center (). X+60,visiblerect::center (). y-300), point (Visiblerect::center (). X+90,visiblerect::center (). y+150), 100); Check_gl_error_debug (); Draw a solid polygon point vertices3[] = {point (60,160), point (70,190), point (100,190), point (90,160)}; Drawprimitives::d rawsolidpoly (Vertices3, 4, color4f (1,1,0,1)); Check_gl_error_debug (); End Draw Kmglpopmatrix ();}
cocos2d-x3.0 often use drawing methods