简体   繁体   中英

Drawing circles with SDL2?

is there a sdl "draw circle" function? or should i make it from cero? or, instead of that... is there an already made function in c++ for that?

something like:

int main (){
  // create the window
  SDL_Window * window1 =
        SDL_CreateWindow("Window",700,50,500,450, SDL_WINDOW_SHOWN);
  // create the renderer
  SDL_Renderer * renderer =  SDL_CreateRenderer( window1, -1 , SDL_RENDERER_ACCELERATED);

  // Set background
  SDL_SetRenderDrawColor( renderer, 255, 255, 255, 255 );
  SDL_RenderClear( renderer );
  SDL_RenderPresent(renderer);

  // Set circle's position
  int x = 100; int y = 100;
  int radius = 40;

  // Loop to hold the window in screen
  bool running = true;
  while(running)  {

        SDL_Event event1;
        while(SDL_PollEvent(&event1) !=0){

              // CIRCLE FUNCTION ??????
              functionSDLcircle(x, y, radius);

              if(event1.type ==SDL_KEYDOWN) {
                    switch (event1.key.keysym.sym){
                    case SDLK_RETURN:
                       running = false;
                       break;
                       }
                 }
           }
     }

  return 0;
}

Nope, nothing like that off-the-shelf in the SDL_Renderer system.

You'll have to roll your own using SDL_RenderDrawLines() /OpenGL or switch to something like SDL2_gfx .

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM