用SDL2绘制圆圈?

时间:2017-09-18 14:09:35

标签: c++ geometry sdl-2

是否有sdl"画圈"功能?或者我应该从cero那里制作? 或者,而不是那个...是否已经在c ++中创建了一个函数?

类似的东西:

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;
}

1 个答案:

答案 0 :(得分:1)

没有,就像SDL_Renderer系统中现成的那样。

您必须使用SDL_RenderDrawLines() / OpenGL滚动自己,或切换到类似SDL2_gfx的内容。