基于SDL的画圆和矩形

#include <stdlib.h>
#include "SDL.h"
#include "SDL_draw.h"

int main(int argc, char *argv[])
{
  SDL_Surface *screen;// 屏幕
  int width, height;
  Uint8  video_bpp;
  Uint32 videoflags;
   if ( SDL_Init(SDL_INIT_VIDEO) < 0 ) {
    fprintf(stderr, "SDL初始化失败。。。。 %s", SDL_GetError());
    exit(1);
  }
  atexit(SDL_Quit);  //退出
  videoflags = SDL_SWSURFACE | SDL_ANYFORMAT;
  width = 640;
  height = 480;
  video_bpp = 0;
  /*Video mode activation*/
  screen = SDL_SetVideoMode(width, height, video_bpp, videoflags);
  if (!screen) {
    fprintf(stderr, "不能激活视频模式: %dx%d: %s\n",
            width, height, SDL_GetError());
    exit(2);
  }
{
  Uint32 c_red = SDL_MapRGB(screen->format, 255,0,0);
  Draw_Circle(screen, 50,50, 50, c_red); // 画圆,圆心(50,50) 半径50
  Draw_Rect(screen, 500,400, 50,50, c_red);//画矩形 
  SDL_UpdateRect(screen, 0, 0, 0, 0);//刷新屏幕
//Wait 10 seconds
    SDL_Delay( 10000 );
  fprintf(stderr, "显示结束。。。。");
  return 0;
 
}
}

你可能感兴趣的:(画圆,sdl)