c++ - SDL2 draw and fill shapes -


how can draw different shapes (other rectangle , line) , fill them using sdl2 in c++? tried using sdl2_gfx, couldn't sdl2_gfx compiled, coudnt't try it. found compiled sdl_gfx since i'm using renderer not surfaces can't use it. drawing polygons simple, can calculate point , draw lines, how fill them? , how draw circle?

if has compiled sdl2_gfx (same way sdl2_ttf , sdl2_image) maybe send me?

thank :)!

if want fill polygon quick google search gives efficient algorithm here. or copying way sdl2_gfx possible, have access sources?

for drawing circle, there the midpoint circle algorithm code given:

void drawcircle(int x0, int y0, int radius) {     int x = 0, y = radius;     int dp = 1 - radius;         {         if (dp < 0)             dp = dp + 2 * (++x) + 3;         else             dp = dp + 2 * (++x) - 2 * (--y) + 5;          putpixel(x0 + x, y0 + y, 15);     //for 8 octants         putpixel(x0 - x, y0 + y, 15);         putpixel(x0 + x, y0 - y, 15);         putpixel(x0 - x, y0 - y, 15);         putpixel(x0 + y, y0 + x, 15);         putpixel(x0 - y, y0 + x, 15);         putpixel(x0 + y, y0 - x, 15);         putpixel(x0 - y, y0 - x, 15);      } while (x < y); } 

but should done seek in solving problem of compiling sdl2_gfx. worst comes worst, can't put source files of sdl2_gfx in project directly? it's 4 files can put in subfolder of project.


Comments

Popular posts from this blog

ios - RestKit 0.20 — CoreData: error: Failed to call designated initializer on NSManagedObject class (again) -

laravel - PDOException in Connector.php line 55: SQLSTATE[HY000] [1045] Access denied for user 'root'@'localhost' (using password: YES) -

java - Digest auth with Spring Security using javaconfig -