コード例 #1
0
ファイル: SDL_draw.c プロジェクト: 2bt/tetrisVI
static
void Draw_FillCircle_Init(SDL_Surface *super,
                          Sint16 x0, Sint16 y0, Uint16 r,
                          Uint32 color)
{
  Draw_Init();
  Draw_FillCircle(super, x0, y0, r, color);
}
コード例 #2
0
void Vertex::Draw()
{
 SDL_Surface* surface = Scene::GetInstance().GetViewport();
 SDL_PixelFormat* fmt = surface->format;
 if (ValidateScreenCoord(x, 0) && ValidateScreenCoord(y, 1))
 {
  Draw_FillCircle(surface, x, y, 2, SDL_MapRGB(fmt, 255, 0, 0));
  
  fmt = nullptr;
  delete fmt;
 }
}
コード例 #3
0
ファイル: main.c プロジェクト: c3d2/pent-rschild
int main(int argc, char *argv[]) {
	srand(time(NULL));

	SDL_Surface* screen = SDL_SetVideoMode(LED_WIDTH * ZOOM_X, LED_HEIGHT * ZOOM_Y,
		32, SDL_SWSURFACE | SDL_DOUBLEBUF);

	SDL_Rect rect = { 0, 0, LED_WIDTH*ZOOM_X, LED_HEIGHT*ZOOM_Y };
	SDL_FillRect(screen, &rect, SDL_MapRGB(screen->format, 0x00,0x00,0x00));

	unsigned int color[] = {
		SDL_MapRGB(screen->format, 0x57,0x10,0x10),
		SDL_MapRGB(screen->format, 0xff,0x80,0x80)
	};

	int running = 1;
	while(running) {
		SDL_Event ev;
		while(SDL_PollEvent(&ev)) {
            switch(ev.type) {
	            case SDL_QUIT:
    	            running = 0;
        	        break;
            	case SDL_KEYUP:
	            case SDL_KEYDOWN:
					switch(ev.key.keysym.sym) {
						case SDLK_ESCAPE:
							running = 0;
							break;

						default: break;
					}
				default: break;
			}
		}

		running &= !tick_fp();

		int x, y;
		for(x = 0; x < LED_WIDTH; x++) {
			for(y = 0; y < LED_HEIGHT; y++) {
				Draw_FillCircle(screen, ZOOM_X*x+(ZOOM_X/2),ZOOM_Y*y+(ZOOM_Y/2), (ZOOM_Y*0.4),color[leds[y][x]]);
			}
		}
		SDL_Flip(screen);

		usleep(interval*1000);
	}

	SDL_Quit();
	return 0;
}
コード例 #4
0
void tracePion(SDL_Surface * surf,int i_posX, int i_posY, int i_cordonnee_grille_i, int i_cordonnee_grille_j, int i_nb_intervales, int i_width, int i_height, int i_choixCouleur, float f_proportion_cercle)
{
	// trace le pion
	
	// determination taille case
	int i_width_case = ((i_width-i_nb_intervales+1) / i_nb_intervales);
	int i_height_case = ((i_height-i_nb_intervales+1) / i_nb_intervales);
	float f_rayon = (((i_width_case-2) / 2)*(f_proportion_cercle/100));
	// initialisation coordonnes pion
	int i_cordX_centre = ((i_posX + (i_height_case/2)) +(i_cordonnee_grille_i * i_height_case));
	int i_cordY_centre = ((i_posY + (i_width_case/2)) +(i_cordonnee_grille_j * i_width_case));

	
	Draw_FillCircle(screen, i_cordX_centre, i_cordY_centre, f_rayon, couleur[i_choixCouleur]);
	
}
コード例 #5
0
ファイル: sdlfn.c プロジェクト: 8l/bcpl
BCPLWORD sdlfn(BCPLWORD *a, BCPLWORD *g, BCPLWORD *W) {
  char tmpstr[256];

  //printf("sdlfn: fno=%d a1=%d a2=%d a3=%d a4=%d\n",
  //        a[0], a[1], a[2], a[3], a[4]);

  switch(a[0]) {
  default:
    printf("sdlfn: Unknown op: fno=%d a1=%d a2=%d a3=%d a4=%d\n",
            a[0], a[1], a[2], a[3], a[4]);
    return 0;

  case sdl_avail: // Test whether SDL is available
    return -1;    // SDL is available

  case gl_avail:  // Test whether OpenGL is available
#ifdef GLavail
    return -1;    // OpenGL is available
#else
    return  0;    // OpenGL is not available
#endif

  case sdl_init:  // Initialise all SDL features
  { BCPLWORD res = (BCPLWORD) SDL_Init(SDL_INIT_EVERYTHING);
      // Enable Unicode translation of keyboard events.
    SDL_EnableUNICODE(1);
    SDL_JoystickEventState(SDL_ENABLE);
    //printf("sdl_init\n");
    return res;
  }

  case sdl_setvideomode:  // width, height, bbp, flags
  { SDL_Surface *scr;
    //printf("Calling SetVideoMode(%d, %d, %d, %8x)\n", a[1], a[2], a[3], a[4]);
    scr = SDL_SetVideoMode((int)a[1], (int)a[2], (int)a[3], (Uint32)a[4]);
    SDL_Flip(scr);
    return (BCPLWORD) scr;
    //return (BCPLWORD) SDL_SetVideoMode((int)a[1], (int)a[2], (int)a[3], (Uint32)a[4]);
  }

  case sdl_quit:      // Shut down SDL
    printf("sdl_quit\n");
    SDL_Quit();
    return -1;

  case sdl_locksurface: // surf
    // Return 0 on success
    // Return -1 on failure
    return (BCPLWORD) SDL_LockSurface((SDL_Surface*) a[1]);

  case sdl_unlocksurface: // surf
    SDL_UnlockSurface((SDL_Surface*) a[1]);
    return 0;

  case sdl_getsurfaceinfo:
  // surf, surfinfo -> [flag, format, w, h, pitch, pixels, cliprect, refcount]
  { SDL_Surface *surf = (SDL_Surface*)a[1];
    BCPLWORD *info = &W[a[2]];
    info[ 0] = (BCPLWORD) (surf->flags);
    info[ 1] = (BCPLWORD) (surf->format);
    info[ 2] = (BCPLWORD) (surf->w);
    info[ 3] = (BCPLWORD) (surf->h);
    info[ 4] = (BCPLWORD) (surf->pitch);
    info[ 5] = (BCPLWORD) (surf->pixels);
    //info[ 6] = (BCPLWORD) (surf->clip_rect); // fields: x,y, w, h
    info[ 7] = (BCPLWORD) (surf->refcount);
    //printf("getsurfaceinfo: format=%d\n", info[1]);
    return 0;        
  }

  case sdl_getfmtinfo:
  // fmt, pxlinfo -> [palette, bitspp, bytespp, rmask, gmask, rmask, amask,
  //                  rloss, rshift, gloss, gshift, bloss, bshift, aloss, ashift,
  //                  colorkey, alpha]
  { SDL_PixelFormat *fmt = (SDL_PixelFormat*)(a[1]);
    BCPLWORD *info = &(W[a[2]]);
    //printf("getfmtinfo: format=%d\n", (BCPLWORD)fmt);
    info[ 0] = (BCPLWORD) (fmt->palette);
    info[ 1] = (BCPLWORD) (fmt->BitsPerPixel);
    info[ 2] = (BCPLWORD) (fmt->BytesPerPixel);
    info[ 3] = (BCPLWORD) (fmt->Rmask);
    info[ 4] = (BCPLWORD) (fmt->Gmask);
    info[ 5] = (BCPLWORD) (fmt->Bmask);
    info[ 6] = (BCPLWORD) (fmt->Amask);
    info[ 7] = (BCPLWORD) (fmt->Rshift);
    info[ 8] = (BCPLWORD) (fmt->Gshift);
    info[ 9] = (BCPLWORD) (fmt->Bshift);
    info[10] = (BCPLWORD) (fmt->Ashift);
    info[11] = (BCPLWORD) (fmt->Rloss);
    info[12] = (BCPLWORD) (fmt->Gloss);
    info[13] = (BCPLWORD) (fmt->Rloss);
    info[14] = (BCPLWORD) (fmt->Aloss);
    info[15] = (BCPLWORD) (fmt->colorkey);
    info[16] = (BCPLWORD) (fmt->alpha);

    return 0;        
  }

  case sdl_geterror:   // str -- fill str with BCPL string for the latest SDL error
  { char *str = SDL_GetError();
    printf("sdl_geterror: %s\n", str);
    return c2b_str(str, a[1]); // Convert to BCPL string format
  }

  case sdl_updaterect: // surf, left, top, right, bottom
    return 0;     // Not yet available

  case sdl_loadbmp:    // filename of a .bmp image
  { char tmpstr[256];
    b2c_str(a[1], tmpstr);
    return (BCPLWORD) SDL_LoadBMP(tmpstr);
  }

  case sdl_mksurface: //(format, w, h)
  { SDL_PixelFormat *fmt = (SDL_PixelFormat*)(a[1]);
    Uint32 rmask = fmt->Rmask;
    Uint32 gmask = fmt->Gmask;
    Uint32 bmask = fmt->Bmask;
    Uint32 amask = fmt->Amask;
    //printf("rmask=%8x gmask=%8x bmask=%8x amask=%8x\n", rmask, gmask, bmask, amask);
    return (BCPLWORD)SDL_CreateRGBSurface(
                         SDL_SWSURFACE,
                         a[2], a[3], // Width, Height
                         32,     // Not using a palette
                         rmask, gmask, bmask, amask);
  }

  case sdl_blitsurface: // src, srcrect, dest, destrect
    //printf("blitsurface: %d, %d, %d, %d)\n", a[1], a[2], a[3], a[4]);
  { BCPLWORD *p = &W[a[4]];
    SDL_Rect dstrect = {p[0],p[1],p[2],p[3]};
    //printf("x=%d, y=%d, w=%d, h=%d\n", p[0], p[1], p[2], p[3]);
    return (BCPLWORD) SDL_BlitSurface((SDL_Surface*) a[1],
                                      (SDL_Rect*)    0,
                                      (SDL_Surface*) a[3],
                                      &dstrect);
  }

  case sdl_setcolourkey: //(surf, key)
    // If key=-1 unset colour key
    // otherwise set colour key to given value.
    // key must be in the pixel format of the given surface
    //printf("sdl_setcolourkey: %8x\n", a[2]);
    if(a[2]==-1) {
      return (BCPLWORD)SDL_SetColorKey((SDL_Surface*)a[1], 0, (Uint32)a[2]);
    } else {
      return (BCPLWORD)SDL_SetColorKey((SDL_Surface*)a[1], SDL_SRCCOLORKEY, (Uint32)a[2]);
    }

  case sdl_freesurface: // surf
    SDL_FreeSurface((SDL_Surface*)a[1]);
    return 0;

  case sdl_setalpha:    // surf, flags, alpha
    return 0;     // Not yet available

  case sdl_imgload:     // filename -- using the SDL_image library
    return 0;     // Not yet available

  case sdl_delay:       // msecs -- the SDL delay function
    SDL_Delay((int)a[1]);
    return 0;

  case sdl_getticks:    // return msecs since initialisation
    return (BCPLWORD)SDL_GetTicks();

  case sdl_showcursor:  // Show the cursor
    return (BCPLWORD)SDL_ShowCursor(SDL_ENABLE);

  case sdl_hidecursor:  // Hide the cursor
    return (BCPLWORD)SDL_ShowCursor(SDL_DISABLE);

  case sdl_flip:        // surf -- Double buffered update of the screen
    return (BCPLWORD) SDL_Flip((SDL_Surface*)a[1]);

  case sdl_displayformat: // surf -- convert surf to display format
    return 0;     // Not yet available

  case sdl_waitevent:    // (pointer) to [type, args, ... ] to hold details of the next event
                 // return 0 if no events available
    return 0;     // Not yet available

  case sdl_pollevent:    // (pointer) to [type, args, ... ] to hold details of
			 // the next event
    { SDL_Event test_event;
      if (SDL_PollEvent(&test_event))
      { decodeevent(&test_event, &W[a[1]]);
        return -1;
      }
      decodeevent(0, &W[a[1]]);
      return 0;
    }

  case sdl_getmousestate: // pointer to [x, y] returns bit pattern of buttons currently pressed
    return 0;     // Not yet available

  case sdl_loadwav:      // file, spec, buff, len
    return 0;     // Not yet available

  case sdl_freewav:      // buffer
    return 0;     // Not yet available

  case sdl_wm_setcaption:      // surf, string
  { char tmpstr[256];
    b2c_str(a[1], tmpstr);
    SDL_WM_SetCaption(tmpstr, 0);
    return 0;
  }

  case sdl_videoinfo:      // buffer
  { const SDL_VideoInfo* p = SDL_GetVideoInfo();
    BCPLWORD *info = &W[a[1]];
    info[ 0] = (BCPLWORD) ((p->hw_available) |
                           (p->hw_available)<<1 |
                           (p->blit_hw)<<2 |
                           (p->blit_hw_CC)<<3 |
                           (p->blit_hw_A)<<4 |
                           (p->blit_sw)<<5 |
                           (p->blit_sw_CC)<<6 |
                           (p->blit_sw_A)<<7
                          );
    info[ 1] = (BCPLWORD) (p->blit_fill);
    info[ 2] = (BCPLWORD) (p->video_mem);
    info[ 3] = (BCPLWORD) (p->vfmt);
    info[ 4] = (BCPLWORD) (p->vfmt->BitsPerPixel);
    //printf("videoinfo: a[2]=%d %8X %8X %d %d %d\n",
    //          a[2], info[0], info[1], info[2], info[3], info[4]);
 
    return 0;
  }


  case sdl_maprgb:      // format, r, g, b
  { 
    return (BCPLWORD) SDL_MapRGB((SDL_PixelFormat*)(a[1]), a[2], a[3], a[4]); 
  }

  case sdl_drawline:
  { SDL_Surface *surf = (SDL_Surface*)(a[1]);
    //printf("\nDraw Line: %d %d %d %d %d %8x\n", a[1], a[2], a[3], a[4], a[5], a[6]);
    Draw_Line(surf, a[2], a[3], a[4], a[5], a[6]);
    return 0;
  }

  case sdl_drawhline:
  case sdl_drawvline:
  case sdl_drawcircle:
  case sdl_drawrect:
  case sdl_drawpixel:
  case sdl_drawellipse:
  case sdl_drawfillellipse:
  case sdl_drawround:
  case sdl_drawfillround:
    return 0;

  case sdl_drawfillcircle:
  { SDL_Surface *surf = (SDL_Surface*)(a[1]);
    Draw_FillCircle(surf, a[2], a[3], a[4], a[5]);
    return 0;
  }
    //  case sdl_drawfillrect:
    //return  Draw_FillRect((SDL_Surface*)a[1], 500,200, 50,70, 0xF0FF00);

  case sdl_fillrect:
  { SDL_Rect rect = {a[2],a[3],a[4],a[5]};
    //printf("\nfillrect: surface=%d rect=(%d,%d,%d,%d) col=%8x\n",
    //       a[1], a[2], a[3], a[4], a[5], a[6]);
    SDL_FillRect((SDL_Surface*)(a[1]), &rect, a[6]);
    return 0;
  }

  case sdl_fillsurf:
    //printf("\nfillsurf: surface=%d col=%8x\n",
    //        a[1], a[2]);
    SDL_FillRect((SDL_Surface*)(a[1]), 0, a[2]);
    return 0;

// Joystick functions
  case sdl_numjoysticks:
    return SDL_NumJoysticks();

  case sdl_joystickopen:       // 42 (index) => joy
    return (BCPLWORD)SDL_JoystickOpen(a[1]);

  case sdl_joystickclose:      // 43 (joy)
    SDL_JoystickClose((SDL_Joystick *)a[1]);
    return 0;

  case sdl_joystickname:       // 44 (index)
  { const char *name = SDL_JoystickName(a[1]);
    return c2b_str(name, a[1]);
  }

  case sdl_joysticknumaxes:    // 45 (joy)
    return SDL_JoystickNumAxes((SDL_Joystick*)a[1]);

  case sdl_joysticknumbuttons: // 46 (joy)
    return SDL_JoystickNumButtons((SDL_Joystick*)a[1]);

  case sdl_joysticknumballs:   // 47 (joy)
    return SDL_JoystickNumBalls((SDL_Joystick*)a[1]);

  case sdl_joysticknumhats:    // 47 (joy)
    return SDL_JoystickNumHats((SDL_Joystick*)a[1]);

  case sdl_joystickeventstate: //49  sdl_enable=1 or sdl_ignore=0
    return SDL_JoystickEventState(a[1]);

  case sdl_joystickgetbutton: // 55 (joy)
    return SDL_JoystickGetButton((SDL_Joystick*)a[1], a[2]);

  case sdl_joystickgetaxis: // 56 (joy)
    return SDL_JoystickGetAxis((SDL_Joystick*)a[1], a[2]);

  case sdl_joystickgethat: // 58 (joy)
    return SDL_JoystickGetHat((SDL_Joystick*)a[1], a[2]);

  case gl_setvideomode: // 200 (width, height)
  { // Setup minimum bit sizes, a depth buffer and double buffering.
    const SDL_VideoInfo* info = NULL;
    int bpp = 0;
    SDL_Surface *scr;

    info = SDL_GetVideoInfo();
    if(!info) return 0;
    bpp = info->vfmt->BitsPerPixel;
    printf("bpp=%d width=%d height=%d\n", bpp, a[1], a[2]);
    SDL_GL_SetAttribute(SDL_GL_RED_SIZE, 5);
    SDL_GL_SetAttribute(SDL_GL_GREEN_SIZE, 5);
    SDL_GL_SetAttribute(SDL_GL_BLUE_SIZE, 5);
    SDL_GL_SetAttribute(SDL_GL_DEPTH_SIZE, 16);
    SDL_GL_SetAttribute(SDL_GL_DOUBLEBUFFER, 1);
    printf("Calling SDL_SetVideoMode\n");
    scr = SDL_SetVideoMode((int)a[1], (int)a[2], bpp, SDL_OPENGL);
    return (BCPLWORD)scr;
  }

#ifdef GLavail
  case gl_ShadeModel:
    //printf("gl_ShadeModel: a[1]=%d GL_SMOOTH=%d\n", a[1], GL_SMOOTH);
    //glShadeModel((int)a[1]);
    //glShadeModel(GL_SMOOTH);
    return 0;
  case gl_CullFace:
    //printf("gl_CullFace: %d GL_BACK=%d\n", a[1], GL_BACK);
    //glCullFace(a[1]);
    glCullFace(GL_BACK);
    return 0;
  case gl_FrontFace:
    //printf("gl_FrontFace: %d\n", a[1]);
    //printf("   GL_CCW=%d\n", GL_CCW);
    //glFrontFace(a[1]);
    glFrontFace(GL_CCW);
    return 0;
  case gl_Enable:
    //printf("gl_Enable: %d\n", a[1]);
    //printf("   GL_CULLFACE=%d\n", GL_CULL_FACE);
    glEnable(a[1]);
    return 0;
  case gl_ClearColor:
    //printf("gl_ClearColor: %d %d %d %d\n", a[1], a[2], a[3], a[4]);
    glClearColor(a[1]/255.0, a[2]/255.0, a[3]/255.0, a[4]/255.0);
    return 0;
  case gl_ViewPort:
    //printf("gl_Viewport: %d %d %d %d\n", a[1], a[2], a[3], a[4]);
    glViewport(a[1], a[2], a[3], a[4]);
    //glViewport(0, 0, 800, 500);
    return 0;
  case gl_MatrixMode:
    //printf("gl_MatrixMode: %d\n", a[1]);
    //printf("   GL_PROJECTION=%d\n", GL_PROJECTION);
    //printf("   GL_MODELVIEW=%d\n", GL_MODELVIEW);
    glMatrixMode(a[1]);
    return 0;
  case gl_LoadIdentity:
    //printf("gl_LoadIdentity:\n");
    glLoadIdentity();
    return 0;
  case glu_Perspective:
    //printf("gl_Perspective: %d %d %d %d\n", a[1], a[2], a[3], a[4]);
    gluPerspective(((float)a[1])/1000000, ((float)a[2])/1000000,
                   ((float)a[3])/1000, ((float)a[4])/1000);  
    //gluPerspective(60.0, 800.0/500.0, 1.0, 1024.0);
    return 0;
  case gl_Clear:
    //printf("gl_Clear: #x%8X\n", a[1]);
    //printf("   GL_COLOR_BUFFER_BIT=%8X\n", GL_COLOR_BUFFER_BIT);
    //printf("   GL_DEPTH_BUFFER_BIT=%8X\n", GL_DEPTH_BUFFER_BIT);
    glClear(a[1]);
    //glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
    return 0;
  case gl_Translate:
    //printf("gl_Translate: %d %d %d\n", a[1], a[2], a[3]);
    glTranslatef(a[1]/1000.0, a[2]/1000.0, a[3]/1000.0);
    return 0;
  case gl_Rotate:
    //printf("gl_Rotate: %d %d %d %d\n", a[1], a[2], a[3], a[4]);
    glRotatef(a[1]/1000000.0, a[2]/1000.0, a[3]/1000.0, a[4]/1000.0);
    return 0;
  case gl_Begin:
    //printf("gl_Begin: %d\n", a[1]);
    //printf("   GL_TRIANGLES=%d\n", GL_TRIANGLES);
    glBegin(a[1]);
    return 0;
  case gl_End:
    //printf("gl_End:\n");
    glEnd();
    return 0;
  case gl_Color4v:
    //printf("gl_Color4v: %d\n", a[1]);
    glColor4ub(W[a[1]], W[a[1]+1], W[a[1]+2], W[a[1]+3]);
    return 0;
  case gl_Vertex3v:
    //printf("gl_Vertex3v: %d -> [%d %d %d]\n", a[1], W[a[1]], W[a[1]+1], W[a[1]+2]);
    glVertex3f(W[a[1]]/1000.0, W[a[1]+1]/1000.0, W[a[1]+2]/1000.0);
    return 0;
  case gl_SwapBuffers:
    //printf("gl_SwapBuffers:\n");
    SDL_GL_SwapBuffers();
    return 0;
#endif

// more to come ...

  }
}
コード例 #6
0
ファイル: sdldrawtest.c プロジェクト: 8l/bcpl
/*----------------------------------------------------------------------*/
int main(int argc, char *argv[])
{
  SDL_Surface *screen;
  int width, height;
  Uint8  video_bpp;
  Uint32 videoflags;
  int done;
  SDL_Event event;
  Uint32 then, now, frames;

  if ( SDL_Init(SDL_INIT_VIDEO) < 0 ) {
    fprintf(stderr, "SDL_Init problem: %s", SDL_GetError());
    exit(1);
  }
  atexit(SDL_Quit);

  videoflags = SDL_SWSURFACE | SDL_ANYFORMAT;
  width = 640;
  height = 480;
  video_bpp = 0;

  while ( argc > 1 ) {
      --argc;
           if ( strcmp(argv[argc-1], "-width") == 0 ) {
      width = atoi(argv[argc]);
      --argc;
    } else if ( strcmp(argv[argc-1], "-height") == 0 ) {
      height = atoi(argv[argc]);
      --argc;
    } else if ( strcmp(argv[argc-1], "-bpp") == 0 ) {
      video_bpp = atoi(argv[argc]);
      videoflags &= ~SDL_ANYFORMAT;
      --argc;
    } else if ( strcmp(argv[argc], "-fast") == 0 ) {
      videoflags = FastestFlags(videoflags, width, height, video_bpp);
    } else if ( strcmp(argv[argc], "-hw") == 0 ) {
      videoflags ^= SDL_HWSURFACE;
    } else if ( strcmp(argv[argc], "-flip") == 0 ) {
      videoflags ^= SDL_DOUBLEBUF;
    } else if ( strcmp(argv[argc], "-fullscreen") == 0 ) {
      videoflags ^= SDL_FULLSCREEN;
    } else {
      fprintf(stderr, "Use: %s [-bpp N] [-hw] [-flip] [-fast] [-fullscreen]\n",
              argv[0]);
      exit(1);
    }
  }/*while*/

  /*Video mode activation*/
  screen = SDL_SetVideoMode(width, height, video_bpp, videoflags);
  if (!screen) {
    fprintf(stderr, "I can not activate video mode: %dx%d: %s\n",
            width, height, SDL_GetError());
    exit(2);
  }

{/*BEGIN*/
  Uint32 c_white = SDL_MapRGB(screen->format, 255,255,255);
  Uint32 c_gray = SDL_MapRGB(screen->format, 200,200,200);
  Uint32 c_dgray= SDL_MapRGB(screen->format, 64,64,64);
  Uint32 c_cyan = SDL_MapRGB(screen->format, 32,255,255);

  //SDL_Rect r = {100,300,50,50};
  //SDL_SetClipRect(screen, &r);  //Test of clipping code

  frames = 0;
  then = SDL_GetTicks();
  done = 0;
  while( !done ) {
  
  Draw_Line(screen, 100,100, 30,0, c_white);
  Draw_Line(screen, 30,0, 100,100, c_white);

  Draw_Line(screen, 100,100, 30,0, c_white);
  Draw_Line(screen, 30,0, 100,100, c_white);
  Draw_Line(screen, 0,0, 100,100, c_white);
  Draw_Line(screen, 100,100, 300,200, c_white);
  Draw_Line(screen, 200,300, 250,400,
                SDL_MapRGB(screen->format, 128,128,255));
  Draw_Line(screen, 500,50, 600,70,
                SDL_MapRGB(screen->format, 128,255,128));
  Draw_Line(screen, 500,50, 600,70,
                SDL_MapRGB(screen->format, 128,255,128));
  //Draw_Circle(screen, 100+frames%200, 100, 50, c_white);
  Draw_Circle(screen, 100+(frames/3)%200, 100+(frames/2)%173, 50,
              SDL_MapRGB(screen->format, 128+frames,255+frames,68+frames));

  /*-------------*/
  Draw_Circle(screen, 150,150, 5, c_white);
  Draw_Circle(screen, 150,150, 4,
                 SDL_MapRGB(screen->format, 64,64,64));
  Draw_Circle(screen, 150,150, 3,
                 SDL_MapRGB(screen->format, 255,0,0));
  Draw_Circle(screen, 150,150, 2,
                 SDL_MapRGB(screen->format, 0,255,0));
  Draw_Circle(screen, 150,150, 1,
                 SDL_MapRGB(screen->format, 0,0,255));
  /*-------------*/

  Draw_Line(screen, 500,100, 600,120,
                SDL_MapRGB(screen->format, 128,255,128));
  Draw_Circle(screen, 601,121, 2, c_white);

  Draw_Circle(screen, 400,200, 2, c_white);
  Draw_Line(screen, 400,200, 409,200, c_white);
  Draw_Circle(screen, 409,200, 2, c_white);
  Draw_Line(screen, 400,200, 400,250, c_white);
  Draw_Circle(screen, 400,250, 2, c_white);
  Draw_Line(screen, 409,200, 400,250, c_white);


  Draw_Line(screen, 400,300, 409,300, c_gray);
  Draw_Line(screen, 400,300, 400,350, c_gray);
  Draw_Line(screen, 409,300, 400,350, c_dgray);
  Draw_Rect(screen, 398,298, 4,4, c_cyan);
  Draw_Rect(screen, 407,298, 4,4, c_cyan);
  Draw_Rect(screen, 398,348, 4,4, c_cyan);

  Draw_HLine(screen, 10,400, 50, c_white);
  Draw_VLine(screen, 60,400, 360, c_white);
  Draw_Rect(screen, 500,400, 50,50, c_white);
  Draw_Pixel(screen, 510,410, c_white);
  Draw_Pixel(screen, 520,420,
             SDL_MapRGB(screen->format, 255,0,0));
  Draw_Pixel(screen, 530,430,
             SDL_MapRGB(screen->format, 0,255,0));
  Draw_Pixel(screen, 540,440,
             SDL_MapRGB(screen->format, 0,0,255));


  Draw_Ellipse(screen, 100,300, 60,30, c_white);
  
  Draw_FillEllipse(screen, 300,300, 30,60,
               SDL_MapRGB(screen->format, 64,64,200));
  Draw_Ellipse(screen, 300,300, 30,60,
               SDL_MapRGB(screen->format, 255,0,0));

  Draw_Round(screen, 200,20, 70,50, 10, c_white);
  Draw_Round(screen, 300,20, 70,50, 20,
             SDL_MapRGB(screen->format, 255,0,0));
  Draw_FillRound(screen, 390,20, 70,50, 20,
                 SDL_MapRGB(screen->format, 255,0,0));
  Draw_Round(screen, 390,20, 70,50, 20, c_cyan);

  /*Draw_Round(screen, 500,400, 5,3, 4, c_cyan);*/

  Draw_Rect(screen, 499,199, 52,72,
            SDL_MapRGB(screen->format, 255,255,0));
  //Draw_FillRect(screen, 500,200, 50,70,
  //              SDL_MapRGB(screen->format, 64,200,64));

  Draw_FillCircle(screen, 500,330, 30, c_cyan);

  SDL_UpdateRect(screen, 0, 0, 0, 0);



    ++frames;
    while ( SDL_PollEvent(&event) ) {
      switch (event.type) {
        case SDL_KEYDOWN:
        /*break;*/
        case SDL_QUIT:
          done = 1;
        break;
        default:
        break;
      }
    }/*while*/
  }/*while(!done)*/

}/*END*/

  now = SDL_GetTicks();
  if ( now > then ) {
    printf("%2.2f frames per second\n",
          ((double)frames*1000)/(now-then));
  }

  fprintf(stderr, "[END]\n");
  return 0;

}/*main*/