Added RenderPiont() API
authorSam Lantinga <slouken@libsdl.org>
Sun, 21 Dec 2008 17:39:41 +0000
changeset 2901133601e3b255
parent 2900 3a9636c83849
child 2902 83c3a4b0e421
Added RenderPiont() API
Merged the drawing tests into a single test program
include/SDL_surface.h
include/SDL_video.h
src/video/SDL_blendpoint.c
src/video/SDL_draw.h
src/video/SDL_drawline.c
src/video/SDL_drawpoint.c
src/video/SDL_renderer_gl.c
src/video/SDL_renderer_sw.c
src/video/SDL_sysvideo.h
src/video/SDL_video.c
src/video/directfb/SDL_DirectFB_render.c
src/video/dummy/SDL_nullrender.c
src/video/x11/SDL_x11render.c
src/video/x11/SDL_x11sym.h
test/testdraw2.c
test/testfill2.c
test/testlines2.c
     1.1 --- a/include/SDL_surface.h	Sun Dec 21 08:59:56 2008 +0000
     1.2 +++ b/include/SDL_surface.h	Sun Dec 21 17:39:41 2008 +0000
     1.3 @@ -366,6 +366,25 @@
     1.4      (SDL_Surface * src, SDL_PixelFormat * fmt, Uint32 flags);
     1.5  
     1.6  /*
     1.7 + * This function draws a point with 'color'
     1.8 + * The color should be a pixel of the format used by the surface, and 
     1.9 + * can be generated by the SDL_MapRGB() function.
    1.10 + * This function returns 0 on success, or -1 on error.
    1.11 + */
    1.12 +extern DECLSPEC int SDLCALL SDL_DrawPoint
    1.13 +    (SDL_Surface * dst, int x, int y, Uint32 color);
    1.14 +
    1.15 +/*
    1.16 + * This function blends a point with an RGBA value
    1.17 + * The color should be a pixel of the format used by the surface, and 
    1.18 + * can be generated by the SDL_MapRGB() function.
    1.19 + * This function returns 0 on success, or -1 on error.
    1.20 + */
    1.21 +extern DECLSPEC int SDLCALL SDL_BlendPoint
    1.22 +    (SDL_Surface * dst, int x, int y, int blendMode,
    1.23 +     Uint8 r, Uint8 g, Uint8 b, Uint8 a);
    1.24 +
    1.25 +/*
    1.26   * This function draws a line with 'color'
    1.27   * The color should be a pixel of the format used by the surface, and 
    1.28   * can be generated by the SDL_MapRGB() function.
     2.1 --- a/include/SDL_video.h	Sun Dec 21 08:59:56 2008 +0000
     2.2 +++ b/include/SDL_video.h	Sun Dec 21 17:39:41 2008 +0000
     2.3 @@ -1197,6 +1197,18 @@
     2.4  extern DECLSPEC int SDLCALL SDL_GetRenderDrawBlendMode(int *blendMode);
     2.5  
     2.6  /**
     2.7 + * \fn int SDL_RenderPoint(int x, int y)
     2.8 + *
     2.9 + * \brief Draw a point on the current rendering target.
    2.10 + *
    2.11 + * \param x The x coordinate of the point
    2.12 + * \param y The y coordinate of the point
    2.13 + *
    2.14 + * \return 0 on success, or -1 if there is no rendering context current
    2.15 + */
    2.16 +extern DECLSPEC int SDLCALL SDL_RenderPoint(int x, int y);
    2.17 +
    2.18 +/**
    2.19   * \fn int SDL_RenderLine(int x1, int y1, int x2, int y2)
    2.20   *
    2.21   * \brief Draw a line on the current rendering target.
    2.22 @@ -1208,7 +1220,6 @@
    2.23   *
    2.24   * \return 0 on success, or -1 if there is no rendering context current
    2.25   */
    2.26 -
    2.27  extern DECLSPEC int SDLCALL SDL_RenderLine(int x1, int y1, int x2, int y2);
    2.28  
    2.29  /**
     3.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     3.2 +++ b/src/video/SDL_blendpoint.c	Sun Dec 21 17:39:41 2008 +0000
     3.3 @@ -0,0 +1,256 @@
     3.4 +/*
     3.5 +    SDL - Simple DirectMedia Layer
     3.6 +    Copyright (C) 1997-2009 Sam Lantinga
     3.7 +
     3.8 +    This library is free software; you can redistribute it and/or
     3.9 +    modify it under the terms of the GNU Lesser General Public
    3.10 +    License as published by the Free Software Foundation; either
    3.11 +    version 2.1 of the License, or (at your option) any later version.
    3.12 +
    3.13 +    This library is distributed in the hope that it will be useful,
    3.14 +    but WITHOUT ANY WARRANTY; without even the implied warranty of
    3.15 +    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
    3.16 +    Lesser General Public License for more details.
    3.17 +
    3.18 +    You should have received a copy of the GNU Lesser General Public
    3.19 +    License along with this library; if not, write to the Free Software
    3.20 +    Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
    3.21 +
    3.22 +    Sam Lantinga
    3.23 +    slouken@libsdl.org
    3.24 +*/
    3.25 +#include "SDL_config.h"
    3.26 +
    3.27 +#include "SDL_draw.h"
    3.28 +
    3.29 +static int
    3.30 +SDL_BlendPoint_RGB555(SDL_Surface * dst, int x, int y, int blendMode, Uint8 r,
    3.31 +                      Uint8 g, Uint8 b, Uint8 a)
    3.32 +{
    3.33 +    unsigned inva = 0xff - a;
    3.34 +
    3.35 +    switch (blendMode) {
    3.36 +    case SDL_BLENDMODE_BLEND:
    3.37 +        DRAW_SETPIXELXY_BLEND_RGB555(x, y);
    3.38 +        break;
    3.39 +    case SDL_BLENDMODE_ADD:
    3.40 +        DRAW_SETPIXELXY_ADD_RGB555(x, y);
    3.41 +        break;
    3.42 +    case SDL_BLENDMODE_MOD:
    3.43 +        DRAW_SETPIXELXY_MOD_RGB555(x, y);
    3.44 +        break;
    3.45 +    default:
    3.46 +        DRAW_SETPIXELXY_RGB555(x, y);
    3.47 +        break;
    3.48 +    }
    3.49 +    return 0;
    3.50 +}
    3.51 +
    3.52 +static int
    3.53 +SDL_BlendPoint_RGB565(SDL_Surface * dst, int x, int y, int blendMode, Uint8 r,
    3.54 +                      Uint8 g, Uint8 b, Uint8 a)
    3.55 +{
    3.56 +    unsigned inva = 0xff - a;
    3.57 +
    3.58 +    switch (blendMode) {
    3.59 +    case SDL_BLENDMODE_BLEND:
    3.60 +        DRAW_SETPIXELXY_BLEND_RGB565(x, y);
    3.61 +        break;
    3.62 +    case SDL_BLENDMODE_ADD:
    3.63 +        DRAW_SETPIXELXY_ADD_RGB565(x, y);
    3.64 +        break;
    3.65 +    case SDL_BLENDMODE_MOD:
    3.66 +        DRAW_SETPIXELXY_MOD_RGB565(x, y);
    3.67 +        break;
    3.68 +    default:
    3.69 +        DRAW_SETPIXELXY_RGB565(x, y);
    3.70 +        break;
    3.71 +    }
    3.72 +    return 0;
    3.73 +}
    3.74 +
    3.75 +static int
    3.76 +SDL_BlendPoint_RGB888(SDL_Surface * dst, int x, int y, int blendMode, Uint8 r,
    3.77 +                      Uint8 g, Uint8 b, Uint8 a)
    3.78 +{
    3.79 +    unsigned inva = 0xff - a;
    3.80 +
    3.81 +    switch (blendMode) {
    3.82 +    case SDL_BLENDMODE_BLEND:
    3.83 +        DRAW_SETPIXELXY_BLEND_RGB888(x, y);
    3.84 +        break;
    3.85 +    case SDL_BLENDMODE_ADD:
    3.86 +        DRAW_SETPIXELXY_ADD_RGB888(x, y);
    3.87 +        break;
    3.88 +    case SDL_BLENDMODE_MOD:
    3.89 +        DRAW_SETPIXELXY_MOD_RGB888(x, y);
    3.90 +        break;
    3.91 +    default:
    3.92 +        DRAW_SETPIXELXY_RGB888(x, y);
    3.93 +        break;
    3.94 +    }
    3.95 +    return 0;
    3.96 +}
    3.97 +
    3.98 +static int
    3.99 +SDL_BlendPoint_ARGB8888(SDL_Surface * dst, int x, int y, int blendMode,
   3.100 +                        Uint8 r, Uint8 g, Uint8 b, Uint8 a)
   3.101 +{
   3.102 +    unsigned inva = 0xff - a;
   3.103 +
   3.104 +    switch (blendMode) {
   3.105 +    case SDL_BLENDMODE_BLEND:
   3.106 +        DRAW_SETPIXELXY_BLEND_ARGB8888(x, y);
   3.107 +        break;
   3.108 +    case SDL_BLENDMODE_ADD:
   3.109 +        DRAW_SETPIXELXY_ADD_ARGB8888(x, y);
   3.110 +        break;
   3.111 +    case SDL_BLENDMODE_MOD:
   3.112 +        DRAW_SETPIXELXY_MOD_ARGB8888(x, y);
   3.113 +        break;
   3.114 +    default:
   3.115 +        DRAW_SETPIXELXY_ARGB8888(x, y);
   3.116 +        break;
   3.117 +    }
   3.118 +    return 0;
   3.119 +}
   3.120 +
   3.121 +static int
   3.122 +SDL_BlendPoint_RGB(SDL_Surface * dst, int x, int y, int blendMode, Uint8 r,
   3.123 +                   Uint8 g, Uint8 b, Uint8 a)
   3.124 +{
   3.125 +    SDL_PixelFormat *fmt = dst->format;
   3.126 +    unsigned inva = 0xff - a;
   3.127 +
   3.128 +    switch (fmt->BytesPerPixel) {
   3.129 +    case 2:
   3.130 +        switch (blendMode) {
   3.131 +        case SDL_BLENDMODE_BLEND:
   3.132 +            DRAW_SETPIXELXY2_BLEND_RGB(x, y);
   3.133 +            break;
   3.134 +        case SDL_BLENDMODE_ADD:
   3.135 +            DRAW_SETPIXELXY2_ADD_RGB(x, y);
   3.136 +            break;
   3.137 +        case SDL_BLENDMODE_MOD:
   3.138 +            DRAW_SETPIXELXY2_MOD_RGB(x, y);
   3.139 +            break;
   3.140 +        default:
   3.141 +            DRAW_SETPIXELXY2_RGB(x, y);
   3.142 +            break;
   3.143 +        }
   3.144 +        return 0;
   3.145 +    case 4:
   3.146 +        switch (blendMode) {
   3.147 +        case SDL_BLENDMODE_BLEND:
   3.148 +            DRAW_SETPIXELXY4_BLEND_RGB(x, y);
   3.149 +            break;
   3.150 +        case SDL_BLENDMODE_ADD:
   3.151 +            DRAW_SETPIXELXY4_ADD_RGB(x, y);
   3.152 +            break;
   3.153 +        case SDL_BLENDMODE_MOD:
   3.154 +            DRAW_SETPIXELXY4_MOD_RGB(x, y);
   3.155 +            break;
   3.156 +        default:
   3.157 +            DRAW_SETPIXELXY4_RGB(x, y);
   3.158 +            break;
   3.159 +        }
   3.160 +        return 0;
   3.161 +    default:
   3.162 +        SDL_Unsupported();
   3.163 +        return -1;
   3.164 +    }
   3.165 +}
   3.166 +
   3.167 +static int
   3.168 +SDL_BlendPoint_RGBA(SDL_Surface * dst, int x, int y, int blendMode, Uint8 r,
   3.169 +                    Uint8 g, Uint8 b, Uint8 a)
   3.170 +{
   3.171 +    SDL_PixelFormat *fmt = dst->format;
   3.172 +    unsigned inva = 0xff - a;
   3.173 +
   3.174 +    switch (fmt->BytesPerPixel) {
   3.175 +    case 4:
   3.176 +        switch (blendMode) {
   3.177 +        case SDL_BLENDMODE_BLEND:
   3.178 +            DRAW_SETPIXELXY4_BLEND_RGBA(x, y);
   3.179 +            break;
   3.180 +        case SDL_BLENDMODE_ADD:
   3.181 +            DRAW_SETPIXELXY4_ADD_RGBA(x, y);
   3.182 +            break;
   3.183 +        case SDL_BLENDMODE_MOD:
   3.184 +            DRAW_SETPIXELXY4_MOD_RGBA(x, y);
   3.185 +            break;
   3.186 +        default:
   3.187 +            DRAW_SETPIXELXY4_RGBA(x, y);
   3.188 +            break;
   3.189 +        }
   3.190 +        return 0;
   3.191 +    default:
   3.192 +        SDL_Unsupported();
   3.193 +        return -1;
   3.194 +    }
   3.195 +}
   3.196 +
   3.197 +int
   3.198 +SDL_BlendPoint(SDL_Surface * dst, int x, int y, int blendMode, Uint8 r,
   3.199 +               Uint8 g, Uint8 b, Uint8 a)
   3.200 +{
   3.201 +    SDL_PixelFormat *fmt = dst->format;
   3.202 +
   3.203 +    /* This function doesn't work on surfaces < 8 bpp */
   3.204 +    if (dst->format->BitsPerPixel < 8) {
   3.205 +        SDL_SetError("SDL_BlendPoint(): Unsupported surface format");
   3.206 +        return (-1);
   3.207 +    }
   3.208 +
   3.209 +    /* Perform clipping */
   3.210 +    if (x < dst->clip_rect.x || y < dst->clip_rect.y ||
   3.211 +        x >= (dst->clip_rect.x + dst->clip_rect.w) ||
   3.212 +        y >= (dst->clip_rect.y + dst->clip_rect.h)) {
   3.213 +        return 0;
   3.214 +    }
   3.215 +
   3.216 +    if ((blendMode == SDL_BLENDMODE_BLEND)
   3.217 +        || (blendMode == SDL_BLENDMODE_ADD)) {
   3.218 +        r = DRAW_MUL(r, a);
   3.219 +        g = DRAW_MUL(g, a);
   3.220 +        b = DRAW_MUL(b, a);
   3.221 +    }
   3.222 +
   3.223 +    switch (fmt->BitsPerPixel) {
   3.224 +    case 15:
   3.225 +        switch (fmt->Rmask) {
   3.226 +        case 0x7C00:
   3.227 +            return SDL_BlendPoint_RGB555(dst, x, y, blendMode, r, g, b, a);
   3.228 +        }
   3.229 +        break;
   3.230 +    case 16:
   3.231 +        switch (fmt->Rmask) {
   3.232 +        case 0xF800:
   3.233 +            return SDL_BlendPoint_RGB565(dst, x, y, blendMode, r, g, b, a);
   3.234 +        }
   3.235 +        break;
   3.236 +    case 32:
   3.237 +        switch (fmt->Rmask) {
   3.238 +        case 0x00FF0000:
   3.239 +            if (!fmt->Amask) {
   3.240 +                return SDL_BlendPoint_RGB888(dst, x, y, blendMode, r, g, b,
   3.241 +                                             a);
   3.242 +            } else {
   3.243 +                return SDL_BlendPoint_ARGB8888(dst, x, y, blendMode, r, g, b,
   3.244 +                                               a);
   3.245 +            }
   3.246 +            break;
   3.247 +        }
   3.248 +    default:
   3.249 +        break;
   3.250 +    }
   3.251 +
   3.252 +    if (!fmt->Amask) {
   3.253 +        return SDL_BlendPoint_RGB(dst, x, y, blendMode, r, g, b, a);
   3.254 +    } else {
   3.255 +        return SDL_BlendPoint_RGBA(dst, x, y, blendMode, r, g, b, a);
   3.256 +    }
   3.257 +}
   3.258 +
   3.259 +/* vi: set ts=4 sw=4 expandtab: */
     4.1 --- a/src/video/SDL_draw.h	Sun Dec 21 08:59:56 2008 +0000
     4.2 +++ b/src/video/SDL_draw.h	Sun Dec 21 17:39:41 2008 +0000
     4.3 @@ -29,6 +29,13 @@
     4.4  
     4.5  #define DRAW_MUL(_a, _b) (((unsigned)(_a)*(_b))/255)
     4.6  
     4.7 +#define DRAW_FASTSETPIXEL(x, y, type, bpp, color) \
     4.8 +    *(type *)(dst->pixels + y * dst->pitch + x * bpp) = (type) color
     4.9 +
    4.10 +#define DRAW_FASTSETPIXEL1(x, y) DRAW_FASTSETPIXEL(x, y, Uint8, 1, color);
    4.11 +#define DRAW_FASTSETPIXEL2(x, y) DRAW_FASTSETPIXEL(x, y, Uint16, 2, color);
    4.12 +#define DRAW_FASTSETPIXEL4(x, y) DRAW_FASTSETPIXEL(x, y, Uint32, 4, color);
    4.13 +
    4.14  #define DRAW_SETPIXEL(setpixel) \
    4.15  do { \
    4.16      unsigned sr = r, sg = g, sb = b, sa = a; \
     5.1 --- a/src/video/SDL_drawline.c	Sun Dec 21 08:59:56 2008 +0000
     5.2 +++ b/src/video/SDL_drawline.c	Sun Dec 21 17:39:41 2008 +0000
     5.3 @@ -23,13 +23,8 @@
     5.4  
     5.5  #include "SDL_draw.h"
     5.6  
     5.7 -#define SETPIXEL(x, y, type, bpp, color) \
     5.8 -    *(type *)(dst->pixels + y * dst->pitch + x * bpp) = (type) color
     5.9  
    5.10 -#define SETPIXEL1(x, y) SETPIXEL(x, y, Uint8, 1, color);
    5.11 -#define SETPIXEL2(x, y) SETPIXEL(x, y, Uint16, 2, color);
    5.12 -#define SETPIXEL4(x, y) SETPIXEL(x, y, Uint32, 4, color);
    5.13 -
    5.14 +int
    5.15  SDL_DrawLine(SDL_Surface * dst, int x1, int y1, int x2, int y2, Uint32 color)
    5.16  {
    5.17      /* This function doesn't work on surfaces < 8 bpp */
    5.18 @@ -47,16 +42,16 @@
    5.19  
    5.20      switch (dst->format->BytesPerPixel) {
    5.21      case 1:
    5.22 -        DRAWLINE(x1, y1, x2, y2, SETPIXEL1);
    5.23 +        DRAWLINE(x1, y1, x2, y2, DRAW_FASTSETPIXEL1);
    5.24          break;
    5.25      case 2:
    5.26 -        DRAWLINE(x1, y1, x2, y2, SETPIXEL2);
    5.27 +        DRAWLINE(x1, y1, x2, y2, DRAW_FASTSETPIXEL2);
    5.28          break;
    5.29      case 3:
    5.30          SDL_Unsupported();
    5.31          return -1;
    5.32      case 4:
    5.33 -        DRAWLINE(x1, y1, x2, y2, SETPIXEL4);
    5.34 +        DRAWLINE(x1, y1, x2, y2, DRAW_FASTSETPIXEL4);
    5.35          break;
    5.36      }
    5.37      return 0;
     6.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     6.2 +++ b/src/video/SDL_drawpoint.c	Sun Dec 21 17:39:41 2008 +0000
     6.3 @@ -0,0 +1,60 @@
     6.4 +/*
     6.5 +    SDL - Simple DirectMedia Layer
     6.6 +    Copyright (C) 1997-2009 Sam Lantinga
     6.7 +
     6.8 +    This library is free software; you can redistribute it and/or
     6.9 +    modify it under the terms of the GNU Lesser General Public
    6.10 +    License as published by the Free Software Foundation; either
    6.11 +    version 2.1 of the License, or (at your option) any later version.
    6.12 +
    6.13 +    This library is distributed in the hope that it will be useful,
    6.14 +    but WITHOUT ANY WARRANTY; without even the implied warranty of
    6.15 +    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
    6.16 +    Lesser General Public License for more details.
    6.17 +
    6.18 +    You should have received a copy of the GNU Lesser General Public
    6.19 +    License along with this library; if not, write to the Free Software
    6.20 +    Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
    6.21 +
    6.22 +    Sam Lantinga
    6.23 +    slouken@libsdl.org
    6.24 +*/
    6.25 +#include "SDL_config.h"
    6.26 +
    6.27 +#include "SDL_draw.h"
    6.28 +
    6.29 +
    6.30 +int
    6.31 +SDL_DrawPoint(SDL_Surface * dst, int x, int y, Uint32 color)
    6.32 +{
    6.33 +    /* This function doesn't work on surfaces < 8 bpp */
    6.34 +    if (dst->format->BitsPerPixel < 8) {
    6.35 +        SDL_SetError("SDL_DrawLine(): Unsupported surface format");
    6.36 +        return (-1);
    6.37 +    }
    6.38 +
    6.39 +    /* Perform clipping */
    6.40 +    if (x < dst->clip_rect.x || y < dst->clip_rect.y ||
    6.41 +        x >= (dst->clip_rect.x + dst->clip_rect.w) ||
    6.42 +        y >= (dst->clip_rect.y + dst->clip_rect.h)) {
    6.43 +        return 0;
    6.44 +    }
    6.45 +
    6.46 +    switch (dst->format->BytesPerPixel) {
    6.47 +    case 1:
    6.48 +        DRAW_FASTSETPIXEL1(x, y);
    6.49 +        break;
    6.50 +    case 2:
    6.51 +        DRAW_FASTSETPIXEL2(x, y);
    6.52 +        break;
    6.53 +    case 3:
    6.54 +        SDL_Unsupported();
    6.55 +        return -1;
    6.56 +    case 4:
    6.57 +        DRAW_FASTSETPIXEL4(x, y);
    6.58 +        break;
    6.59 +    }
    6.60 +    return 0;
    6.61 +}
    6.62 +
    6.63 +/* vi: set ts=4 sw=4 expandtab: */
     7.1 --- a/src/video/SDL_renderer_gl.c	Sun Dec 21 08:59:56 2008 +0000
     7.2 +++ b/src/video/SDL_renderer_gl.c	Sun Dec 21 17:39:41 2008 +0000
     7.3 @@ -98,6 +98,7 @@
     7.4                              int numrects, const SDL_Rect * rects);
     7.5  static int GL_SetDrawColor(SDL_Renderer * renderer);
     7.6  static int GL_SetDrawBlendMode(SDL_Renderer * renderer);
     7.7 +static int GL_RenderPoint(SDL_Renderer * renderer, int x, int y);
     7.8  static int GL_RenderLine(SDL_Renderer * renderer, int x1, int y1, int x2,
     7.9                           int y2);
    7.10  static int GL_RenderFill(SDL_Renderer * renderer, const SDL_Rect * rect);
    7.11 @@ -313,6 +314,7 @@
    7.12      renderer->DirtyTexture = GL_DirtyTexture;
    7.13      renderer->SetDrawColor = GL_SetDrawColor;
    7.14      renderer->SetDrawBlendMode = GL_SetDrawBlendMode;
    7.15 +    renderer->RenderPoint = GL_RenderPoint;
    7.16      renderer->RenderLine = GL_RenderLine;
    7.17      renderer->RenderFill = GL_RenderFill;
    7.18      renderer->RenderCopy = GL_RenderCopy;
    7.19 @@ -1097,11 +1099,9 @@
    7.20  }
    7.21  
    7.22  static int
    7.23 -GL_RenderLine(SDL_Renderer * renderer, int x1, int y1, int x2, int y2)
    7.24 +GL_RenderPoint(SDL_Renderer * renderer, int x, int y)
    7.25  {
    7.26      GL_RenderData *data = (GL_RenderData *) renderer->driverdata;
    7.27 -    //data->glLineWidth(1.0);
    7.28 -    //data->glPointSize(1.0);
    7.29  
    7.30      SetBlendMode(data, renderer->blendMode);
    7.31  
    7.32 @@ -1110,16 +1110,30 @@
    7.33                      (GLfloat) renderer->b * inv255f,
    7.34                      (GLfloat) renderer->a * inv255f);
    7.35  
    7.36 -    if ((x1 == x2) && (y1 == y2)) {
    7.37 -        data->glBegin(GL_POINTS);
    7.38 -        data->glVertex2i(x1, y1);
    7.39 -        data->glEnd();
    7.40 -    } else {
    7.41 -        data->glBegin(GL_LINES);
    7.42 -        data->glVertex2i(x1, y1);
    7.43 -        data->glVertex2i(x2, y2);
    7.44 -        data->glEnd();
    7.45 -    }
    7.46 +    data->glBegin(GL_POINTS);
    7.47 +    data->glVertex2i(x, y);
    7.48 +    data->glEnd();
    7.49 +
    7.50 +    return 0;
    7.51 +}
    7.52 +
    7.53 +static int
    7.54 +GL_RenderLine(SDL_Renderer * renderer, int x1, int y1, int x2, int y2)
    7.55 +{
    7.56 +    GL_RenderData *data = (GL_RenderData *) renderer->driverdata;
    7.57 +
    7.58 +    SetBlendMode(data, renderer->blendMode);
    7.59 +
    7.60 +    data->glColor4f((GLfloat) renderer->r * inv255f,
    7.61 +                    (GLfloat) renderer->g * inv255f,
    7.62 +                    (GLfloat) renderer->b * inv255f,
    7.63 +                    (GLfloat) renderer->a * inv255f);
    7.64 +
    7.65 +    data->glBegin(GL_LINES);
    7.66 +    data->glVertex2i(x1, y1);
    7.67 +    data->glVertex2i(x2, y2);
    7.68 +    data->glEnd();
    7.69 +
    7.70      return 0;
    7.71  }
    7.72  
     8.1 --- a/src/video/SDL_renderer_sw.c	Sun Dec 21 08:59:56 2008 +0000
     8.2 +++ b/src/video/SDL_renderer_sw.c	Sun Dec 21 17:39:41 2008 +0000
     8.3 @@ -61,6 +61,7 @@
     8.4  static void SW_UnlockTexture(SDL_Renderer * renderer, SDL_Texture * texture);
     8.5  static int SW_SetDrawColor(SDL_Renderer * renderer);
     8.6  static int SW_SetDrawBlendMode(SDL_Renderer * renderer);
     8.7 +static int SW_RenderPoint(SDL_Renderer * renderer, int x, int y);
     8.8  static int SW_RenderLine(SDL_Renderer * renderer, int x1, int y1, int x2,
     8.9                           int y2);
    8.10  static int SW_RenderFill(SDL_Renderer * renderer, const SDL_Rect * rect);
    8.11 @@ -227,6 +228,7 @@
    8.12  
    8.13      renderer->SetDrawColor = SW_SetDrawColor;
    8.14      renderer->SetDrawBlendMode = SW_SetDrawBlendMode;
    8.15 +    renderer->RenderPoint = SW_RenderPoint;
    8.16      renderer->RenderLine = SW_RenderLine;
    8.17      renderer->RenderFill = SW_RenderFill;
    8.18      renderer->RenderCopy = SW_RenderCopy;
    8.19 @@ -538,6 +540,49 @@
    8.20  }
    8.21  
    8.22  static int
    8.23 +SW_RenderPoint(SDL_Renderer * renderer, int x, int y)
    8.24 +{
    8.25 +    SW_RenderData *data = (SW_RenderData *) renderer->driverdata;
    8.26 +    int status;
    8.27 +
    8.28 +    if (data->renderer->info.flags & SDL_RENDERER_PRESENTCOPY) {
    8.29 +        SDL_Rect rect;
    8.30 +
    8.31 +        rect.x = x;
    8.32 +        rect.y = y;
    8.33 +        rect.w = 1;
    8.34 +        rect.h = 1;
    8.35 +        SDL_AddDirtyRect(&data->dirty, &rect);
    8.36 +    }
    8.37 +
    8.38 +    if (data->renderer->LockTexture(data->renderer,
    8.39 +                                    data->texture[data->current_texture],
    8.40 +                                    &data->surface.clip_rect, 1,
    8.41 +                                    &data->surface.pixels,
    8.42 +                                    &data->surface.pitch) < 0) {
    8.43 +        return -1;
    8.44 +    }
    8.45 +
    8.46 +    if (renderer->blendMode == SDL_BLENDMODE_NONE ||
    8.47 +        renderer->blendMode == SDL_BLENDMODE_MASK) {
    8.48 +        Uint32 color =
    8.49 +            SDL_MapRGBA(data->surface.format, renderer->r, renderer->g,
    8.50 +                        renderer->b, renderer->a);
    8.51 +
    8.52 +        status = SDL_DrawPoint(&data->surface, x, y, color);
    8.53 +    } else {
    8.54 +        status =
    8.55 +            SDL_BlendPoint(&data->surface, x, y, renderer->blendMode,
    8.56 +                           renderer->r, renderer->g, renderer->b,
    8.57 +                           renderer->a);
    8.58 +    }
    8.59 +
    8.60 +    data->renderer->UnlockTexture(data->renderer,
    8.61 +                                  data->texture[data->current_texture]);
    8.62 +    return status;
    8.63 +}
    8.64 +
    8.65 +static int
    8.66  SW_RenderLine(SDL_Renderer * renderer, int x1, int y1, int x2, int y2)
    8.67  {
    8.68      SW_RenderData *data = (SW_RenderData *) renderer->driverdata;
    8.69 @@ -571,7 +616,8 @@
    8.70          return -1;
    8.71      }
    8.72  
    8.73 -    if (renderer->blendMode == SDL_BLENDMODE_NONE) {
    8.74 +    if (renderer->blendMode == SDL_BLENDMODE_NONE ||
    8.75 +        renderer->blendMode == SDL_BLENDMODE_MASK) {
    8.76          Uint32 color =
    8.77              SDL_MapRGBA(data->surface.format, renderer->r, renderer->g,
    8.78                          renderer->b, renderer->a);
     9.1 --- a/src/video/SDL_sysvideo.h	Sun Dec 21 08:59:56 2008 +0000
     9.2 +++ b/src/video/SDL_sysvideo.h	Sun Dec 21 17:39:41 2008 +0000
     9.3 @@ -90,6 +90,7 @@
     9.4                            int numrects, const SDL_Rect * rects);
     9.5      int (*SetDrawColor) (SDL_Renderer * renderer);
     9.6      int (*SetDrawBlendMode) (SDL_Renderer * renderer);
     9.7 +    int (*RenderPoint) (SDL_Renderer * renderer, int x, int y);
     9.8      int (*RenderLine) (SDL_Renderer * renderer, int x1, int y1, int x2,
     9.9                         int y2);
    9.10      int (*RenderFill) (SDL_Renderer * renderer, const SDL_Rect * rect);
    10.1 --- a/src/video/SDL_video.c	Sun Dec 21 08:59:56 2008 +0000
    10.2 +++ b/src/video/SDL_video.c	Sun Dec 21 17:39:41 2008 +0000
    10.3 @@ -2070,6 +2070,70 @@
    10.4      return 0;
    10.5  }
    10.6  
    10.7 +int
    10.8 +SDL_RenderPoint(int x, int y)
    10.9 +{
   10.10 +    SDL_Renderer *renderer;
   10.11 +    SDL_Window *window;
   10.12 +    SDL_Rect real_rect;
   10.13 +
   10.14 +    if (!_this) {
   10.15 +        SDL_UninitializedVideo();
   10.16 +        return -1;
   10.17 +    }
   10.18 +    renderer = SDL_CurrentDisplay.current_renderer;
   10.19 +    if (!renderer) {
   10.20 +        return -1;
   10.21 +    }
   10.22 +    if (!renderer->RenderPoint) {
   10.23 +        SDL_Unsupported();
   10.24 +        return -1;
   10.25 +    }
   10.26 +    window = SDL_GetWindowFromID(renderer->window);
   10.27 +    if (x < 0 || y < 0 || x >= window->w || y >= window->h) {
   10.28 +        return 0;
   10.29 +    }
   10.30 +    return renderer->RenderPoint(renderer, x, y);
   10.31 +}
   10.32 +
   10.33 +int
   10.34 +SDL_RenderLine(int x1, int y1, int x2, int y2)
   10.35 +{
   10.36 +    SDL_Renderer *renderer;
   10.37 +    SDL_Window *window;
   10.38 +    SDL_Rect real_rect;
   10.39 +
   10.40 +    if (x1 == x2 && y1 == y2) {
   10.41 +        return SDL_RenderPoint(x1, y1);
   10.42 +    }
   10.43 +
   10.44 +    if (!_this) {
   10.45 +        SDL_UninitializedVideo();
   10.46 +        return -1;
   10.47 +    }
   10.48 +    renderer = SDL_CurrentDisplay.current_renderer;
   10.49 +    if (!renderer) {
   10.50 +        return -1;
   10.51 +    }
   10.52 +    if (!renderer->RenderLine) {
   10.53 +        SDL_Unsupported();
   10.54 +        return -1;
   10.55 +    }
   10.56 +#if 0
   10.57 +    //FIXME: Need line intersect routine
   10.58 +    window = SDL_GetWindowFromID(renderer->window);
   10.59 +    real_rect.x = 0;
   10.60 +    real_rect.y = 0;
   10.61 +    real_rect.w = window->w;
   10.62 +    real_rect.h = window->h;
   10.63 +    if (rect) {
   10.64 +        if (!SDL_IntersectRect(rect, &real_rect, &real_rect)) {
   10.65 +            return 0;
   10.66 +        }
   10.67 +    }
   10.68 +#endif
   10.69 +    return renderer->RenderLine(renderer, x1, y1, x2, y2);
   10.70 +}
   10.71  
   10.72  int
   10.73  SDL_RenderFill(const SDL_Rect * rect)
   10.74 @@ -2104,41 +2168,6 @@
   10.75  }
   10.76  
   10.77  int
   10.78 -SDL_RenderLine(int x1, int y1, int x2, int y2)
   10.79 -{
   10.80 -    SDL_Renderer *renderer;
   10.81 -    SDL_Window *window;
   10.82 -    SDL_Rect real_rect;
   10.83 -
   10.84 -    if (!_this) {
   10.85 -        SDL_UninitializedVideo();
   10.86 -        return -1;
   10.87 -    }
   10.88 -    renderer = SDL_CurrentDisplay.current_renderer;
   10.89 -    if (!renderer) {
   10.90 -        return -1;
   10.91 -    }
   10.92 -    if (!renderer->RenderLine) {
   10.93 -        SDL_Unsupported();
   10.94 -        return -1;
   10.95 -    }
   10.96 -#if 0
   10.97 -    //FIXME: Need line intersect routine
   10.98 -    window = SDL_GetWindowFromID(renderer->window);
   10.99 -    real_rect.x = 0;
  10.100 -    real_rect.y = 0;
  10.101 -    real_rect.w = window->w;
  10.102 -    real_rect.h = window->h;
  10.103 -    if (rect) {
  10.104 -        if (!SDL_IntersectRect(rect, &real_rect, &real_rect)) {
  10.105 -            return 0;
  10.106 -        }
  10.107 -    }
  10.108 -#endif
  10.109 -    return renderer->RenderLine(renderer, x1, y1, x2, y2);
  10.110 -}
  10.111 -
  10.112 -int
  10.113  SDL_RenderCopy(SDL_TextureID textureID, const SDL_Rect * srcrect,
  10.114                 const SDL_Rect * dstrect)
  10.115  {
    11.1 --- a/src/video/directfb/SDL_DirectFB_render.c	Sun Dec 21 08:59:56 2008 +0000
    11.2 +++ b/src/video/directfb/SDL_DirectFB_render.c	Sun Dec 21 17:39:41 2008 +0000
    11.3 @@ -73,6 +73,7 @@
    11.4                                    const SDL_Rect * rects);
    11.5  static int DirectFB_SetDrawColor(SDL_Renderer * renderer);
    11.6  static int DirectFB_SetDrawBlendMode(SDL_Renderer * renderer);
    11.7 +static int DirectFB_RenderPoint(SDL_Renderer * renderer, int x, int y);
    11.8  static int DirectFB_RenderLine(SDL_Renderer * renderer, int x1, int y1,
    11.9                                 int x2, int y2);
   11.10  static int DirectFB_RenderFill(SDL_Renderer * renderer,
   11.11 @@ -295,6 +296,7 @@
   11.12      renderer->DirtyTexture = DirectFB_DirtyTexture;
   11.13      renderer->SetDrawColor = DirectFB_SetDrawColor;
   11.14      renderer->SetDrawBlendMode = DirectFB_SetDrawBlendMode;
   11.15 +    renderer->RenderPoint = DirectFB_RenderPoint;
   11.16      renderer->RenderLine = DirectFB_RenderLine;
   11.17      renderer->RenderFill = DirectFB_RenderFill;
   11.18      renderer->RenderCopy = DirectFB_RenderCopy;
   11.19 @@ -844,6 +846,19 @@
   11.20  }
   11.21  
   11.22  static int
   11.23 +DirectFB_RenderPoint(SDL_Renderer * renderer, int x, int y)
   11.24 +{
   11.25 +    DirectFB_RenderData *data = (DirectFB_RenderData *) renderer->driverdata;
   11.26 +    DFBResult ret;
   11.27 +
   11.28 +    PrepareDraw(renderer);
   11.29 +    SDL_DFB_CHECKERR(data->surface->DrawPoint(data->surface, x, y));
   11.30 +    return 0;
   11.31 +  error:
   11.32 +    return -1;
   11.33 +}
   11.34 +
   11.35 +static int
   11.36  DirectFB_RenderLine(SDL_Renderer * renderer, int x1, int y1, int x2, int y2)
   11.37  {
   11.38      DirectFB_RenderData *data = (DirectFB_RenderData *) renderer->driverdata;
    12.1 --- a/src/video/dummy/SDL_nullrender.c	Sun Dec 21 08:59:56 2008 +0000
    12.2 +++ b/src/video/dummy/SDL_nullrender.c	Sun Dec 21 17:39:41 2008 +0000
    12.3 @@ -33,6 +33,7 @@
    12.4                                                Uint32 flags);
    12.5  static int SDL_DUMMY_SetDrawColor(SDL_Renderer * renderer);
    12.6  static int SDL_DUMMY_SetDrawBlendMode(SDL_Renderer * renderer);
    12.7 +static int SDL_DUMMY_RenderPoint(SDL_Renderer * renderer, int x, int y);
    12.8  static int SDL_DUMMY_RenderLine(SDL_Renderer * renderer, int x1, int y1,
    12.9                                  int x2, int y2);
   12.10  static int SDL_DUMMY_RenderFill(SDL_Renderer * renderer,
   12.11 @@ -94,6 +95,7 @@
   12.12  
   12.13      renderer->SetDrawColor = SDL_DUMMY_SetDrawColor;
   12.14      renderer->SetDrawBlendMode = SDL_DUMMY_SetDrawBlendMode;
   12.15 +    renderer->RenderPoint = SDL_DUMMY_RenderPoint;
   12.16      renderer->RenderLine = SDL_DUMMY_RenderLine;
   12.17      renderer->RenderFill = SDL_DUMMY_RenderFill;
   12.18      renderer->RenderCopy = SDL_DUMMY_RenderCopy;
   12.19 @@ -143,6 +145,29 @@
   12.20  }
   12.21  
   12.22  static int
   12.23 +SDL_DUMMY_RenderPoint(SDL_Renderer * renderer, int x, int y)
   12.24 +{
   12.25 +    SDL_DUMMY_RenderData *data =
   12.26 +        (SDL_DUMMY_RenderData *) renderer->driverdata;
   12.27 +    SDL_Surface *target = data->screens[data->current_screen];
   12.28 +    int status;
   12.29 +
   12.30 +    if (renderer->blendMode == SDL_BLENDMODE_NONE ||
   12.31 +        renderer->blendMode == SDL_BLENDMODE_MASK) {
   12.32 +        Uint32 color =
   12.33 +            SDL_MapRGBA(target->format, renderer->r, renderer->g, renderer->b,
   12.34 +                        renderer->a);
   12.35 +
   12.36 +        status = SDL_DrawPoint(target, x, y, color);
   12.37 +    } else {
   12.38 +        status =
   12.39 +            SDL_BlendPoint(target, x, y, renderer->blendMode, renderer->r,
   12.40 +                           renderer->g, renderer->b, renderer->a);
   12.41 +    }
   12.42 +    return status;
   12.43 +}
   12.44 +
   12.45 +static int
   12.46  SDL_DUMMY_RenderLine(SDL_Renderer * renderer, int x1, int y1, int x2, int y2)
   12.47  {
   12.48      SDL_DUMMY_RenderData *data =
   12.49 @@ -150,7 +175,8 @@
   12.50      SDL_Surface *target = data->screens[data->current_screen];
   12.51      int status;
   12.52  
   12.53 -    if (renderer->blendMode == SDL_BLENDMODE_NONE) {
   12.54 +    if (renderer->blendMode == SDL_BLENDMODE_NONE ||
   12.55 +        renderer->blendMode == SDL_BLENDMODE_MASK) {
   12.56          Uint32 color =
   12.57              SDL_MapRGBA(target->format, renderer->r, renderer->g, renderer->b,
   12.58                          renderer->a);
    13.1 --- a/src/video/x11/SDL_x11render.c	Sun Dec 21 08:59:56 2008 +0000
    13.2 +++ b/src/video/x11/SDL_x11render.c	Sun Dec 21 17:39:41 2008 +0000
    13.3 @@ -49,6 +49,7 @@
    13.4  static void X11_UnlockTexture(SDL_Renderer * renderer, SDL_Texture * texture);
    13.5  static int X11_SetDrawColor(SDL_Renderer * renderer);
    13.6  static int X11_SetDrawBlendMode(SDL_Renderer * renderer);
    13.7 +static int X11_RenderPoint(SDL_Renderer * renderer, int x, int y);
    13.8  static int X11_RenderLine(SDL_Renderer * renderer, int x1, int y1, int x2,
    13.9                            int y2);
   13.10  static int X11_RenderFill(SDL_Renderer * renderer, const SDL_Rect * rect);
   13.11 @@ -196,6 +197,7 @@
   13.12      renderer->UnlockTexture = X11_UnlockTexture;
   13.13      renderer->SetDrawColor = X11_SetDrawColor;
   13.14      renderer->SetDrawBlendMode = X11_SetDrawBlendMode;
   13.15 +    renderer->RenderPoint = X11_RenderPoint;
   13.16      renderer->RenderLine = X11_RenderLine;
   13.17      renderer->RenderFill = X11_RenderFill;
   13.18      renderer->RenderCopy = X11_RenderCopy;
   13.19 @@ -593,6 +595,28 @@
   13.20  }
   13.21  
   13.22  static int
   13.23 +X11_RenderPoint(SDL_Renderer * renderer, int x, int y)
   13.24 +{
   13.25 +    X11_RenderData *data = (X11_RenderData *) renderer->driverdata;
   13.26 +    unsigned long foreground;
   13.27 +
   13.28 +    if (data->makedirty) {
   13.29 +        SDL_Rect rect;
   13.30 +
   13.31 +        rect.x = x;
   13.32 +        rect.y = y;
   13.33 +        rect.w = 1;
   13.34 +        rect.h = 1;
   13.35 +        SDL_AddDirtyRect(&data->dirty, &rect);
   13.36 +    }
   13.37 +
   13.38 +    foreground = renderdrawcolor(renderer, 1);
   13.39 +    XSetForeground(data->display, data->gc, foreground);
   13.40 +    XDrawPoint(data->display, data->drawable, data->gc, x, y);
   13.41 +    return 0;
   13.42 +}
   13.43 +
   13.44 +static int
   13.45  X11_RenderLine(SDL_Renderer * renderer, int x1, int y1, int x2, int y2)
   13.46  {
   13.47      X11_RenderData *data = (X11_RenderData *) renderer->driverdata;
    14.1 --- a/src/video/x11/SDL_x11sym.h	Sun Dec 21 08:59:56 2008 +0000
    14.2 +++ b/src/video/x11/SDL_x11sym.h	Sun Dec 21 17:39:41 2008 +0000
    14.3 @@ -96,6 +96,7 @@
    14.4  SDL_X11_SYM(int,XPending,(Display* a),(a),return)
    14.5  SDL_X11_SYM(int,XPutImage,(Display* a,Drawable b,GC c,XImage* d,int e,int f,int g,int h,unsigned int i,unsigned int j),(a,b,c,d,e,f,g,h,i,j),return)
    14.6  SDL_X11_SYM(int,XDrawLine,(Display* a, Drawable b, GC c, int d, int e, int f, int g),(a,b,c,d,e,f,g),return)
    14.7 +SDL_X11_SYM(int,XDrawPoint,(Display* a, Drawable b, GC c, int d, int e),(a,b,c,d,e),return)
    14.8  SDL_X11_SYM(int,XQueryColors,(Display* a,Colormap b,XColor* c,int d),(a,b,c,d),return)
    14.9  SDL_X11_SYM(int,XQueryKeymap,(Display* a,char *b),(a,b),return)
   14.10  SDL_X11_SYM(Bool,XQueryPointer,(Display* a,Window b,Window* c,Window* d,int* e,int* f,int* g,int* h,unsigned int* i),(a,b,c,d,e,f,g,h,i),return)
    15.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
    15.2 +++ b/test/testdraw2.c	Sun Dec 21 17:39:41 2008 +0000
    15.3 @@ -0,0 +1,284 @@
    15.4 +
    15.5 +/* Simple program:  draw as many random objects on the screen as possible */
    15.6 +
    15.7 +#include <stdlib.h>
    15.8 +#include <stdio.h>
    15.9 +#include <time.h>
   15.10 +
   15.11 +#include "common.h"
   15.12 +
   15.13 +#define NUM_OBJECTS	100
   15.14 +
   15.15 +static CommonState *state;
   15.16 +static int num_objects;
   15.17 +static SDL_bool cycle_color;
   15.18 +static SDL_bool cycle_alpha;
   15.19 +static int cycle_direction = 1;
   15.20 +static int current_alpha = 255;
   15.21 +static int current_color = 255;
   15.22 +static SDL_BlendMode blendMode = SDL_BLENDMODE_NONE;
   15.23 +
   15.24 +void
   15.25 +DrawPoints(SDL_WindowID window)
   15.26 +{
   15.27 +    int i;
   15.28 +    int x, y;
   15.29 +    int window_w, window_h;
   15.30 +
   15.31 +    /* Query the sizes */
   15.32 +    SDL_GetWindowSize(window, &window_w, &window_h);
   15.33 +
   15.34 +    SDL_SetRenderDrawBlendMode(blendMode);
   15.35 +    for (i = 0; i < num_objects; ++i) {
   15.36 +        /* Cycle the color and alpha, if desired */
   15.37 +        if (cycle_color) {
   15.38 +            current_color += cycle_direction;
   15.39 +            if (current_color < 0) {
   15.40 +                current_color = 0;
   15.41 +                cycle_direction = -cycle_direction;
   15.42 +            }
   15.43 +            if (current_color > 255) {
   15.44 +                current_color = 255;
   15.45 +                cycle_direction = -cycle_direction;
   15.46 +            }
   15.47 +        }
   15.48 +        if (cycle_alpha) {
   15.49 +            current_alpha += cycle_direction;
   15.50 +            if (current_alpha < 0) {
   15.51 +                current_alpha = 0;
   15.52 +                cycle_direction = -cycle_direction;
   15.53 +            }
   15.54 +            if (current_alpha > 255) {
   15.55 +                current_alpha = 255;
   15.56 +                cycle_direction = -cycle_direction;
   15.57 +            }
   15.58 +        }
   15.59 +        SDL_SetRenderDrawColor(255, (Uint8) current_color,
   15.60 +                               (Uint8) current_color, (Uint8) current_alpha);
   15.61 +
   15.62 +        x = rand() % window_w;
   15.63 +        y = rand() % window_h;
   15.64 +        SDL_RenderPoint(x, y);
   15.65 +    }
   15.66 +    SDL_SetRenderDrawBlendMode(SDL_BLENDMODE_NONE);
   15.67 +}
   15.68 +
   15.69 +void
   15.70 +DrawLines(SDL_WindowID window)
   15.71 +{
   15.72 +    int i;
   15.73 +    int x1, y1, x2, y2;
   15.74 +    int window_w, window_h;
   15.75 +
   15.76 +    /* Query the sizes */
   15.77 +    SDL_GetWindowSize(window, &window_w, &window_h);
   15.78 +
   15.79 +    SDL_SetRenderDrawBlendMode(blendMode);
   15.80 +    for (i = 0; i < num_objects; ++i) {
   15.81 +        /* Cycle the color and alpha, if desired */
   15.82 +        if (cycle_color) {
   15.83 +            current_color += cycle_direction;
   15.84 +            if (current_color < 0) {
   15.85 +                current_color = 0;
   15.86 +                cycle_direction = -cycle_direction;
   15.87 +            }
   15.88 +            if (current_color > 255) {
   15.89 +                current_color = 255;
   15.90 +                cycle_direction = -cycle_direction;
   15.91 +            }
   15.92 +        }
   15.93 +        if (cycle_alpha) {
   15.94 +            current_alpha += cycle_direction;
   15.95 +            if (current_alpha < 0) {
   15.96 +                current_alpha = 0;
   15.97 +                cycle_direction = -cycle_direction;
   15.98 +            }
   15.99 +            if (current_alpha > 255) {
  15.100 +                current_alpha = 255;
  15.101 +                cycle_direction = -cycle_direction;
  15.102 +            }
  15.103 +        }
  15.104 +        SDL_SetRenderDrawColor(255, (Uint8) current_color,
  15.105 +                               (Uint8) current_color, (Uint8) current_alpha);
  15.106 +
  15.107 +        if (i == 0) {
  15.108 +            SDL_RenderLine(0, 0, window_w, window_h);
  15.109 +            SDL_RenderLine(0, window_h, window_w, 0);
  15.110 +            SDL_RenderLine(0, window_h / 2, window_w, window_h / 2);
  15.111 +            SDL_RenderLine(window_w / 2, 0, window_w / 2, window_h);
  15.112 +        } else {
  15.113 +            x1 = rand() % window_w;
  15.114 +            x2 = rand() % window_w;
  15.115 +            y1 = rand() % window_h;
  15.116 +            y2 = rand() % window_h;
  15.117 +            SDL_RenderLine(x1, y1, x2, y2);
  15.118 +        }
  15.119 +    }
  15.120 +    SDL_SetRenderDrawBlendMode(SDL_BLENDMODE_NONE);
  15.121 +}
  15.122 +
  15.123 +void
  15.124 +DrawRects(SDL_WindowID window)
  15.125 +{
  15.126 +    int i;
  15.127 +    SDL_Rect rect;
  15.128 +    int window_w, window_h;
  15.129 +
  15.130 +    /* Query the sizes */
  15.131 +    SDL_GetWindowSize(window, &window_w, &window_h);
  15.132 +
  15.133 +    SDL_SetRenderDrawBlendMode(blendMode);
  15.134 +    for (i = 0; i < num_objects/4; ++i) {
  15.135 +        /* Cycle the color and alpha, if desired */
  15.136 +        if (cycle_color) {
  15.137 +            current_color += cycle_direction;
  15.138 +            if (current_color < 0) {
  15.139 +                current_color = 0;
  15.140 +                cycle_direction = -cycle_direction;
  15.141 +            }
  15.142 +            if (current_color > 255) {
  15.143 +                current_color = 255;
  15.144 +                cycle_direction = -cycle_direction;
  15.145 +            }
  15.146 +        }
  15.147 +        if (cycle_alpha) {
  15.148 +            current_alpha += cycle_direction;
  15.149 +            if (current_alpha < 0) {
  15.150 +                current_alpha = 0;
  15.151 +                cycle_direction = -cycle_direction;
  15.152 +            }
  15.153 +            if (current_alpha > 255) {
  15.154 +                current_alpha = 255;
  15.155 +                cycle_direction = -cycle_direction;
  15.156 +            }
  15.157 +        }
  15.158 +        SDL_SetRenderDrawColor(255, (Uint8) current_color,
  15.159 +                               (Uint8) current_color, (Uint8) current_alpha);
  15.160 +
  15.161 +        rect.w = rand() % (window_h / 2);
  15.162 +        rect.h = rand() % (window_h / 2);
  15.163 +        rect.x = (rand() % window_w) - (rect.w / 2);
  15.164 +        rect.y = (rand() % window_w) - (rect.h / 2);
  15.165 +        SDL_RenderFill(&rect);
  15.166 +    }
  15.167 +    SDL_SetRenderDrawBlendMode(SDL_BLENDMODE_NONE);
  15.168 +}
  15.169 +
  15.170 +int
  15.171 +main(int argc, char *argv[])
  15.172 +{
  15.173 +    int i, done;
  15.174 +    SDL_Event event;
  15.175 +    Uint32 then, now, frames;
  15.176 +
  15.177 +    /* Initialize parameters */
  15.178 +    num_objects = NUM_OBJECTS;
  15.179 +
  15.180 +    /* Initialize test framework */
  15.181 +    state = CommonCreateState(argv, SDL_INIT_VIDEO);
  15.182 +    if (!state) {
  15.183 +        return 1;
  15.184 +    }
  15.185 +    for (i = 1; i < argc;) {
  15.186 +        int consumed;
  15.187 +
  15.188 +        consumed = CommonArg(state, i);
  15.189 +        if (consumed == 0) {
  15.190 +            consumed = -1;
  15.191 +            if (SDL_strcasecmp(argv[i], "--blend") == 0) {
  15.192 +                if (argv[i + 1]) {
  15.193 +                    if (SDL_strcasecmp(argv[i + 1], "none") == 0) {
  15.194 +                        blendMode = SDL_BLENDMODE_NONE;
  15.195 +                        consumed = 2;
  15.196 +                    } else if (SDL_strcasecmp(argv[i + 1], "mask") == 0) {
  15.197 +                        blendMode = SDL_BLENDMODE_MASK;
  15.198 +                        consumed = 2;
  15.199 +                    } else if (SDL_strcasecmp(argv[i + 1], "blend") == 0) {
  15.200 +                        blendMode = SDL_BLENDMODE_BLEND;
  15.201 +                        consumed = 2;
  15.202 +                    } else if (SDL_strcasecmp(argv[i + 1], "add") == 0) {
  15.203 +                        blendMode = SDL_BLENDMODE_ADD;
  15.204 +                        consumed = 2;
  15.205 +                    } else if (SDL_strcasecmp(argv[i + 1], "mod") == 0) {
  15.206 +                        blendMode = SDL_BLENDMODE_MOD;
  15.207 +                        consumed = 2;
  15.208 +                    }
  15.209 +                }
  15.210 +            } else if (SDL_strcasecmp(argv[i], "--cyclecolor") == 0) {
  15.211 +                cycle_color = SDL_TRUE;
  15.212 +                consumed = 1;
  15.213 +            } else if (SDL_strcasecmp(argv[i], "--cyclealpha") == 0) {
  15.214 +                cycle_alpha = SDL_TRUE;
  15.215 +                consumed = 1;
  15.216 +            } else if (SDL_isdigit(*argv[i])) {
  15.217 +                num_objects = SDL_atoi(argv[i]);
  15.218 +                consumed = 1;
  15.219 +            }
  15.220 +        }
  15.221 +        if (consumed < 0) {
  15.222 +            fprintf(stderr,
  15.223 +                    "Usage: %s %s [--blend none|mask|blend|add|mod] [--cyclecolor] [--cyclealpha]\n",
  15.224 +                    argv[0], CommonUsage(state));
  15.225 +            return 1;
  15.226 +        }
  15.227 +        i += consumed;
  15.228 +    }
  15.229 +    if (!CommonInit(state)) {
  15.230 +        return 2;
  15.231 +    }
  15.232 +
  15.233 +    /* Create the windows and initialize the renderers */
  15.234 +    for (i = 0; i < state->num_windows; ++i) {
  15.235 +        SDL_SelectRenderer(state->windows[i]);
  15.236 +        SDL_SetRenderDrawColor(0xA0, 0xA0, 0xA0, 0xFF);
  15.237 +        SDL_RenderFill(NULL);
  15.238 +    }
  15.239 +
  15.240 +    srand(time(NULL));
  15.241 +
  15.242 +    /* Main render loop */
  15.243 +    frames = 0;
  15.244 +    then = SDL_GetTicks();
  15.245 +    done = 0;
  15.246 +    while (!done) {
  15.247 +        /* Check for events */
  15.248 +        ++frames;
  15.249 +        while (SDL_PollEvent(&event)) {
  15.250 +            CommonEvent(state, &event, &done);
  15.251 +            switch (event.type) {
  15.252 +            case SDL_WINDOWEVENT:
  15.253 +                switch (event.window.event) {
  15.254 +                case SDL_WINDOWEVENT_EXPOSED:
  15.255 +                    SDL_SelectRenderer(event.window.windowID);
  15.256 +                    SDL_SetRenderDrawColor(0xA0, 0xA0, 0xA0, 0xFF);
  15.257 +                    SDL_RenderFill(NULL);
  15.258 +                    break;
  15.259 +                }
  15.260 +                break;
  15.261 +            default:
  15.262 +                break;
  15.263 +            }
  15.264 +        }
  15.265 +        for (i = 0; i < state->num_windows; ++i) {
  15.266 +            SDL_SelectRenderer(state->windows[i]);
  15.267 +            SDL_SetRenderDrawColor(0xA0, 0xA0, 0xA0, 0xFF);
  15.268 +            SDL_RenderFill(NULL);
  15.269 +
  15.270 +            DrawRects(state->windows[i]);
  15.271 +            DrawLines(state->windows[i]);
  15.272 +            DrawPoints(state->windows[i]);
  15.273 +
  15.274 +            SDL_RenderPresent();
  15.275 +        }
  15.276 +    }
  15.277 +
  15.278 +    /* Print out some timing information */
  15.279 +    now = SDL_GetTicks();
  15.280 +    if (now > then) {
  15.281 +        double fps = ((double) frames * 1000) / (now - then);
  15.282 +        printf("%2.2f frames per second\n", fps);
  15.283 +    }
  15.284 +    return 0;
  15.285 +}
  15.286 +
  15.287 +/* vi: set ts=4 sw=4 expandtab: */
    16.1 --- a/test/testfill2.c	Sun Dec 21 08:59:56 2008 +0000
    16.2 +++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
    16.3 @@ -1,187 +0,0 @@
    16.4 -
    16.5 -/* Simple program:  draw as many random rectangles on the screen as possible */
    16.6 -
    16.7 -#include <stdlib.h>
    16.8 -#include <stdio.h>
    16.9 -#include <time.h>
   16.10 -
   16.11 -#include "common.h"
   16.12 -
   16.13 -#define NUM_RECTS	100
   16.14 -
   16.15 -static CommonState *state;
   16.16 -static int num_rects;
   16.17 -static SDL_bool cycle_color;
   16.18 -static SDL_bool cycle_alpha;
   16.19 -static int cycle_direction = 1;
   16.20 -static int current_alpha = 255;
   16.21 -static int current_color = 255;
   16.22 -static SDL_BlendMode blendMode = SDL_BLENDMODE_NONE;
   16.23 -
   16.24 -void
   16.25 -DrawRects(SDL_WindowID window)
   16.26 -{
   16.27 -    int i, n;
   16.28 -    SDL_Rect rect;
   16.29 -    int window_w, window_h;
   16.30 -
   16.31 -    SDL_SelectRenderer(window);
   16.32 -
   16.33 -    /* Query the sizes */
   16.34 -    SDL_GetWindowSize(window, &window_w, &window_h);
   16.35 -
   16.36 -    /* Move the sprite, bounce at the wall, and draw */
   16.37 -    n = 0;
   16.38 -    SDL_SetRenderDrawColor(0xA0, 0xA0, 0xA0, 0xFF);
   16.39 -    SDL_RenderFill(NULL);
   16.40 -
   16.41 -    SDL_SetRenderDrawBlendMode(blendMode);
   16.42 -    for (i = 0; i < num_rects; ++i) {
   16.43 -        /* Cycle the color and alpha, if desired */
   16.44 -        if (cycle_color) {
   16.45 -            current_color += cycle_direction;
   16.46 -            if (current_color < 0) {
   16.47 -                current_color = 0;
   16.48 -                cycle_direction = -cycle_direction;
   16.49 -            }
   16.50 -            if (current_color > 255) {
   16.51 -                current_color = 255;
   16.52 -                cycle_direction = -cycle_direction;
   16.53 -            }
   16.54 -        }
   16.55 -        if (cycle_alpha) {
   16.56 -            current_alpha += cycle_direction;
   16.57 -            if (current_alpha < 0) {
   16.58 -                current_alpha = 0;
   16.59 -                cycle_direction = -cycle_direction;
   16.60 -            }
   16.61 -            if (current_alpha > 255) {
   16.62 -                current_alpha = 255;
   16.63 -                cycle_direction = -cycle_direction;
   16.64 -            }
   16.65 -        }
   16.66 -        SDL_SetRenderDrawColor(255, (Uint8) current_color,
   16.67 -                               (Uint8) current_color, (Uint8) current_alpha);
   16.68 -
   16.69 -        rect.w = rand() % (window_h / 2);
   16.70 -        rect.h = rand() % (window_h / 2);
   16.71 -        rect.x = (rand() % window_w) - (rect.w / 2);
   16.72 -        rect.y = (rand() % window_w) - (rect.h / 2);
   16.73 -        SDL_RenderFill(&rect);
   16.74 -    }
   16.75 -    SDL_SetRenderDrawBlendMode(SDL_BLENDMODE_NONE);
   16.76 -
   16.77 -    /* Update the screen! */
   16.78 -    SDL_RenderPresent();
   16.79 -}
   16.80 -
   16.81 -int
   16.82 -main(int argc, char *argv[])
   16.83 -{
   16.84 -    int i, done;
   16.85 -    SDL_Event event;
   16.86 -    Uint32 then, now, frames;
   16.87 -
   16.88 -    /* Initialize parameters */
   16.89 -    num_rects = NUM_RECTS;
   16.90 -
   16.91 -    /* Initialize test framework */
   16.92 -    state = CommonCreateState(argv, SDL_INIT_VIDEO);
   16.93 -    if (!state) {
   16.94 -        return 1;
   16.95 -    }
   16.96 -    for (i = 1; i < argc;) {
   16.97 -        int consumed;
   16.98 -
   16.99 -        consumed = CommonArg(state, i);
  16.100 -        if (consumed == 0) {
  16.101 -            consumed = -1;
  16.102 -            if (SDL_strcasecmp(argv[i], "--blend") == 0) {
  16.103 -                if (argv[i + 1]) {
  16.104 -                    if (SDL_strcasecmp(argv[i + 1], "none") == 0) {
  16.105 -                        blendMode = SDL_BLENDMODE_NONE;
  16.106 -                        consumed = 2;
  16.107 -                    } else if (SDL_strcasecmp(argv[i + 1], "mask") == 0) {
  16.108 -                        blendMode = SDL_BLENDMODE_MASK;
  16.109 -                        consumed = 2;
  16.110 -                    } else if (SDL_strcasecmp(argv[i + 1], "blend") == 0) {
  16.111 -                        blendMode = SDL_BLENDMODE_BLEND;
  16.112 -                        consumed = 2;
  16.113 -                    } else if (SDL_strcasecmp(argv[i + 1], "add") == 0) {
  16.114 -                        blendMode = SDL_BLENDMODE_ADD;
  16.115 -                        consumed = 2;
  16.116 -                    } else if (SDL_strcasecmp(argv[i + 1], "mod") == 0) {
  16.117 -                        blendMode = SDL_BLENDMODE_MOD;
  16.118 -                        consumed = 2;
  16.119 -                    }
  16.120 -                }
  16.121 -            } else if (SDL_strcasecmp(argv[i], "--cyclecolor") == 0) {
  16.122 -                cycle_color = SDL_TRUE;
  16.123 -                consumed = 1;
  16.124 -            } else if (SDL_strcasecmp(argv[i], "--cyclealpha") == 0) {
  16.125 -                cycle_alpha = SDL_TRUE;
  16.126 -                consumed = 1;
  16.127 -            } else if (SDL_isdigit(*argv[i])) {
  16.128 -                num_rects = SDL_atoi(argv[i]);
  16.129 -                consumed = 1;
  16.130 -            }
  16.131 -        }
  16.132 -        if (consumed < 0) {
  16.133 -            fprintf(stderr,
  16.134 -                    "Usage: %s %s [--blend none|mask|blend|add|mod] [--cyclecolor] [--cyclealpha]\n",
  16.135 -                    argv[0], CommonUsage(state));
  16.136 -            return 1;
  16.137 -        }
  16.138 -        i += consumed;
  16.139 -    }
  16.140 -    if (!CommonInit(state)) {
  16.141 -        return 2;
  16.142 -    }
  16.143 -
  16.144 -    /* Create the windows and initialize the renderers */
  16.145 -    for (i = 0; i < state->num_windows; ++i) {
  16.146 -        SDL_SelectRenderer(state->windows[i]);
  16.147 -        SDL_SetRenderDrawColor(0xA0, 0xA0, 0xA0, 0xFF);
  16.148 -        SDL_RenderFill(NULL);
  16.149 -    }
  16.150 -
  16.151 -    srand(time(NULL));
  16.152 -
  16.153 -    /* Main render loop */
  16.154 -    frames = 0;
  16.155 -    then = SDL_GetTicks();
  16.156 -    done = 0;
  16.157 -    while (!done) {
  16.158 -        /* Check for events */
  16.159 -        ++frames;
  16.160 -        while (SDL_PollEvent(&event)) {
  16.161 -            CommonEvent(state, &event, &done);
  16.162 -            switch (event.type) {
  16.163 -            case SDL_WINDOWEVENT:
  16.164 -                switch (event.window.event) {
  16.165 -                case SDL_WINDOWEVENT_EXPOSED:
  16.166 -                    SDL_SelectRenderer(event.window.windowID);
  16.167 -                    SDL_SetRenderDrawColor(0xA0, 0xA0, 0xA0, 0xFF);
  16.168 -                    SDL_RenderFill(NULL);
  16.169 -                    break;
  16.170 -                }
  16.171 -                break;
  16.172 -            default:
  16.173 -                break;
  16.174 -            }
  16.175 -        }
  16.176 -        for (i = 0; i < state->num_windows; ++i) {
  16.177 -            DrawRects(state->windows[i]);
  16.178 -        }
  16.179 -    }
  16.180 -
  16.181 -    /* Print out some timing information */
  16.182 -    now = SDL_GetTicks();
  16.183 -    if (now > then) {
  16.184 -        double fps = ((double) frames * 1000) / (now - then);
  16.185 -        printf("%2.2f frames per second\n", fps);
  16.186 -    }
  16.187 -    return 0;
  16.188 -}
  16.189 -
  16.190 -/* vi: set ts=4 sw=4 expandtab: */
    17.1 --- a/test/testlines2.c	Sun Dec 21 08:59:56 2008 +0000
    17.2 +++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
    17.3 @@ -1,194 +0,0 @@
    17.4 -
    17.5 -/* Simple program:  draw as many random lines on the screen as possible */
    17.6 -
    17.7 -#include <stdlib.h>
    17.8 -#include <stdio.h>
    17.9 -#include <time.h>
   17.10 -
   17.11 -#include "common.h"
   17.12 -
   17.13 -#define NUM_LINES	100
   17.14 -
   17.15 -static CommonState *state;
   17.16 -static int num_lines;
   17.17 -static SDL_bool cycle_color;
   17.18 -static SDL_bool cycle_alpha;
   17.19 -static int cycle_direction = 1;
   17.20 -static int current_alpha = 255;
   17.21 -static int current_color = 255;
   17.22 -static SDL_BlendMode blendMode = SDL_BLENDMODE_NONE;
   17.23 -
   17.24 -void
   17.25 -DrawLines(SDL_WindowID window)
   17.26 -{
   17.27 -    int i, n;
   17.28 -    int x1, y1, x2, y2;
   17.29 -    int window_w, window_h;
   17.30 -
   17.31 -    SDL_SelectRenderer(window);
   17.32 -
   17.33 -    /* Query the sizes */
   17.34 -    SDL_GetWindowSize(window, &window_w, &window_h);
   17.35 -
   17.36 -    /* Move the sprite, bounce at the wall, and draw */
   17.37 -    n = 0;
   17.38 -    SDL_SetRenderDrawColor(0xA0, 0xA0, 0xA0, 0xFF);
   17.39 -    SDL_RenderFill(NULL);
   17.40 -
   17.41 -    SDL_SetRenderDrawBlendMode(blendMode);
   17.42 -    for (i = 0; i < num_lines; ++i) {
   17.43 -        /* Cycle the color and alpha, if desired */
   17.44 -        if (cycle_color) {
   17.45 -            current_color += cycle_direction;
   17.46 -            if (current_color < 0) {
   17.47 -                current_color = 0;
   17.48 -                cycle_direction = -cycle_direction;
   17.49 -            }
   17.50 -            if (current_color > 255) {
   17.51 -                current_color = 255;
   17.52 -                cycle_direction = -cycle_direction;
   17.53 -            }
   17.54 -        }
   17.55 -        if (cycle_alpha) {
   17.56 -            current_alpha += cycle_direction;
   17.57 -            if (current_alpha < 0) {
   17.58 -                current_alpha = 0;
   17.59 -                cycle_direction = -cycle_direction;
   17.60 -            }
   17.61 -            if (current_alpha > 255) {
   17.62 -                current_alpha = 255;
   17.63 -                cycle_direction = -cycle_direction;
   17.64 -            }
   17.65 -        }
   17.66 -        SDL_SetRenderDrawColor(255, (Uint8) current_color,
   17.67 -                               (Uint8) current_color, (Uint8) current_alpha);
   17.68 -
   17.69 -        if (i == 0) {
   17.70 -            SDL_RenderLine(0, 0, window_w, window_h);
   17.71 -            SDL_RenderLine(0, window_h, window_w, 0);
   17.72 -            SDL_RenderLine(0, window_h / 2, window_w, window_h / 2);
   17.73 -            SDL_RenderLine(window_w / 2, 0, window_w / 2, window_h);
   17.74 -        } else {
   17.75 -            x1 = rand() % window_w;
   17.76 -            x2 = rand() % window_w;
   17.77 -            y1 = rand() % window_h;
   17.78 -            y2 = rand() % window_h;
   17.79 -            SDL_RenderLine(x1, y1, x2, y2);
   17.80 -        }
   17.81 -    }
   17.82 -    SDL_SetRenderDrawBlendMode(SDL_BLENDMODE_NONE);
   17.83 -
   17.84 -    /* Update the screen! */
   17.85 -    SDL_RenderPresent();
   17.86 -}
   17.87 -
   17.88 -int
   17.89 -main(int argc, char *argv[])
   17.90 -{
   17.91 -    int i, done;
   17.92 -    SDL_Event event;
   17.93 -    Uint32 then, now, frames;
   17.94 -
   17.95 -    /* Initialize parameters */
   17.96 -    num_lines = NUM_LINES;
   17.97 -
   17.98 -    /* Initialize test framework */
   17.99 -    state = CommonCreateState(argv, SDL_INIT_VIDEO);
  17.100 -    if (!state) {
  17.101 -        return 1;
  17.102 -    }
  17.103 -    for (i = 1; i < argc;) {
  17.104 -        int consumed;
  17.105 -
  17.106 -        consumed = CommonArg(state, i);
  17.107 -        if (consumed == 0) {
  17.108 -            consumed = -1;
  17.109 -            if (SDL_strcasecmp(argv[i], "--blend") == 0) {
  17.110 -                if (argv[i + 1]) {
  17.111 -                    if (SDL_strcasecmp(argv[i + 1], "none") == 0) {
  17.112 -                        blendMode = SDL_BLENDMODE_NONE;
  17.113 -                        consumed = 2;
  17.114 -                    } else if (SDL_strcasecmp(argv[i + 1], "mask") == 0) {
  17.115 -                        blendMode = SDL_BLENDMODE_MASK;
  17.116 -                        consumed = 2;
  17.117 -                    } else if (SDL_strcasecmp(argv[i + 1], "blend") == 0) {
  17.118 -                        blendMode = SDL_BLENDMODE_BLEND;
  17.119 -                        consumed = 2;
  17.120 -                    } else if (SDL_strcasecmp(argv[i + 1], "add") == 0) {
  17.121 -                        blendMode = SDL_BLENDMODE_ADD;
  17.122 -                        consumed = 2;
  17.123 -                    } else if (SDL_strcasecmp(argv[i + 1], "mod") == 0) {
  17.124 -                        blendMode = SDL_BLENDMODE_MOD;
  17.125 -                        consumed = 2;
  17.126 -                    }
  17.127 -                }
  17.128 -            } else if (SDL_strcasecmp(argv[i], "--cyclecolor") == 0) {
  17.129 -                cycle_color = SDL_TRUE;
  17.130 -                consumed = 1;
  17.131 -            } else if (SDL_strcasecmp(argv[i], "--cyclealpha") == 0) {
  17.132 -                cycle_alpha = SDL_TRUE;
  17.133 -                consumed = 1;
  17.134 -            } else if (SDL_isdigit(*argv[i])) {
  17.135 -                num_lines = SDL_atoi(argv[i]);
  17.136 -                consumed = 1;
  17.137 -            }
  17.138 -        }
  17.139 -        if (consumed < 0) {
  17.140 -            fprintf(stderr,
  17.141 -                    "Usage: %s %s [--blend none|mask|blend|add|mod] [--cyclecolor] [--cyclealpha]\n",
  17.142 -                    argv[0], CommonUsage(state));
  17.143 -            return 1;
  17.144 -        }
  17.145 -        i += consumed;
  17.146 -    }
  17.147 -    if (!CommonInit(state)) {
  17.148 -        return 2;
  17.149 -    }
  17.150 -
  17.151 -    /* Create the windows and initialize the renderers */
  17.152 -    for (i = 0; i < state->num_windows; ++i) {
  17.153 -        SDL_SelectRenderer(state->windows[i]);
  17.154 -        SDL_SetRenderDrawColor(0xA0, 0xA0, 0xA0, 0xFF);
  17.155 -        SDL_RenderFill(NULL);
  17.156 -    }
  17.157 -
  17.158 -    srand(time(NULL));
  17.159 -
  17.160 -    /* Main render loop */
  17.161 -    frames = 0;
  17.162 -    then = SDL_GetTicks();
  17.163 -    done = 0;
  17.164 -    while (!done) {
  17.165 -        /* Check for events */
  17.166 -        ++frames;
  17.167 -        while (SDL_PollEvent(&event)) {
  17.168 -            CommonEvent(state, &event, &done);
  17.169 -            switch (event.type) {
  17.170 -            case SDL_WINDOWEVENT:
  17.171 -                switch (event.window.event) {
  17.172 -                case SDL_WINDOWEVENT_EXPOSED:
  17.173 -                    SDL_SelectRenderer(event.window.windowID);
  17.174 -                    SDL_SetRenderDrawColor(0xA0, 0xA0, 0xA0, 0xFF);
  17.175 -                    SDL_RenderFill(NULL);
  17.176 -                    break;
  17.177 -                }
  17.178 -                break;
  17.179 -            default:
  17.180 -                break;
  17.181 -            }
  17.182 -        }
  17.183 -        for (i = 0; i < state->num_windows; ++i) {
  17.184 -            DrawLines(state->windows[i]);
  17.185 -        }
  17.186 -    }
  17.187 -
  17.188 -    /* Print out some timing information */
  17.189 -    now = SDL_GetTicks();
  17.190 -    if (now > then) {
  17.191 -        double fps = ((double) frames * 1000) / (now - then);
  17.192 -        printf("%2.2f frames per second\n", fps);
  17.193 -    }
  17.194 -    return 0;
  17.195 -}
  17.196 -
  17.197 -/* vi: set ts=4 sw=4 expandtab: */