annotate test/automated/surface/surface.c @ 3715:3c9d9c052c8f gsoc2009_unit_tests

Initial revision of SDL_Surface testsuite.
author Edgar Simo <bobbens@gmail.com>
date Wed, 01 Jul 2009 10:22:28 +0000
parents
children ac6bc19a2dfb
rev   line source
3715
3c9d9c052c8f Initial revision of SDL_Surface testsuite.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
1 /**
3c9d9c052c8f Initial revision of SDL_Surface testsuite.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
2 * Automated SDL_Surface test.
3c9d9c052c8f Initial revision of SDL_Surface testsuite.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
3 *
3c9d9c052c8f Initial revision of SDL_Surface testsuite.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
4 * Written by Edgar Simo "bobbens"
3c9d9c052c8f Initial revision of SDL_Surface testsuite.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
5 *
3c9d9c052c8f Initial revision of SDL_Surface testsuite.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
6 * Released under Public Domain.
3c9d9c052c8f Initial revision of SDL_Surface testsuite.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
7 */
3c9d9c052c8f Initial revision of SDL_Surface testsuite.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
8
3c9d9c052c8f Initial revision of SDL_Surface testsuite.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
9
3c9d9c052c8f Initial revision of SDL_Surface testsuite.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
10 #include "SDL.h"
3c9d9c052c8f Initial revision of SDL_Surface testsuite.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
11 #include "SDL_at.h"
3c9d9c052c8f Initial revision of SDL_Surface testsuite.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
12
3c9d9c052c8f Initial revision of SDL_Surface testsuite.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
13
3c9d9c052c8f Initial revision of SDL_Surface testsuite.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
14 #if (SDL_BYTEORDER == SDL_BIG_ENDIAN)
3c9d9c052c8f Initial revision of SDL_Surface testsuite.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
15 # define RMASK 0xff000000 /**< Red bit mask. */
3c9d9c052c8f Initial revision of SDL_Surface testsuite.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
16 # define GMASK 0x00ff0000 /**< Green bit mask. */
3c9d9c052c8f Initial revision of SDL_Surface testsuite.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
17 # define BMASK 0x0000ff00 /**< Blue bit mask. */
3c9d9c052c8f Initial revision of SDL_Surface testsuite.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
18 # define AMASK 0x000000ff /**< Alpha bit mask. */
3c9d9c052c8f Initial revision of SDL_Surface testsuite.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
19 #else
3c9d9c052c8f Initial revision of SDL_Surface testsuite.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
20 # define RMASK 0x000000ff /**< Red bit mask. */
3c9d9c052c8f Initial revision of SDL_Surface testsuite.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
21 # define GMASK 0x0000ff00 /**< Green bit mask. */
3c9d9c052c8f Initial revision of SDL_Surface testsuite.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
22 # define BMASK 0x00ff0000 /**< Blue bit mask. */
3c9d9c052c8f Initial revision of SDL_Surface testsuite.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
23 # define AMASK 0xff000000 /**< Alpha bit mask. */
3c9d9c052c8f Initial revision of SDL_Surface testsuite.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
24 #endif
3c9d9c052c8f Initial revision of SDL_Surface testsuite.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
25
3c9d9c052c8f Initial revision of SDL_Surface testsuite.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
26
3c9d9c052c8f Initial revision of SDL_Surface testsuite.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
27 typedef struct SurfaceImage_s {
3c9d9c052c8f Initial revision of SDL_Surface testsuite.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
28 unsigned int width;
3c9d9c052c8f Initial revision of SDL_Surface testsuite.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
29 unsigned int height;
3c9d9c052c8f Initial revision of SDL_Surface testsuite.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
30 unsigned int bytes_per_pixel; /* 3:RGB, 4:RGBA */
3c9d9c052c8f Initial revision of SDL_Surface testsuite.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
31 const unsigned char pixel_data[];
3c9d9c052c8f Initial revision of SDL_Surface testsuite.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
32 } SurfaceImage_t;
3c9d9c052c8f Initial revision of SDL_Surface testsuite.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
33
3c9d9c052c8f Initial revision of SDL_Surface testsuite.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
34
3c9d9c052c8f Initial revision of SDL_Surface testsuite.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
35 /*
3c9d9c052c8f Initial revision of SDL_Surface testsuite.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
36 * Pull in images for testcases.
3c9d9c052c8f Initial revision of SDL_Surface testsuite.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
37 */
3c9d9c052c8f Initial revision of SDL_Surface testsuite.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
38 #include "primitives.c"
3c9d9c052c8f Initial revision of SDL_Surface testsuite.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
39
3c9d9c052c8f Initial revision of SDL_Surface testsuite.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
40
3c9d9c052c8f Initial revision of SDL_Surface testsuite.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
41 /**
3c9d9c052c8f Initial revision of SDL_Surface testsuite.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
42 * @brief Compares a surface and a surface image for equality.
3c9d9c052c8f Initial revision of SDL_Surface testsuite.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
43 *
3c9d9c052c8f Initial revision of SDL_Surface testsuite.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
44 * @param sur Surface to compare.
3c9d9c052c8f Initial revision of SDL_Surface testsuite.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
45 * @param img Image to compare against.
3c9d9c052c8f Initial revision of SDL_Surface testsuite.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
46 * @return 0 if they are the same, -1 on error and positive if different.
3c9d9c052c8f Initial revision of SDL_Surface testsuite.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
47 */
3c9d9c052c8f Initial revision of SDL_Surface testsuite.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
48 static int surface_compare( SDL_Surface *sur, const SurfaceImage_t *img )
3c9d9c052c8f Initial revision of SDL_Surface testsuite.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
49 {
3c9d9c052c8f Initial revision of SDL_Surface testsuite.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
50 int ret;
3c9d9c052c8f Initial revision of SDL_Surface testsuite.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
51 int i,j;
3c9d9c052c8f Initial revision of SDL_Surface testsuite.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
52 Uint32 pix;
3c9d9c052c8f Initial revision of SDL_Surface testsuite.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
53 int bpp;
3c9d9c052c8f Initial revision of SDL_Surface testsuite.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
54 Uint8 *p, *pd;
3c9d9c052c8f Initial revision of SDL_Surface testsuite.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
55
3c9d9c052c8f Initial revision of SDL_Surface testsuite.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
56 /* Make sure size is the same. */
3c9d9c052c8f Initial revision of SDL_Surface testsuite.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
57 if ((sur->w != img->width) || (sur->h != img->height))
3c9d9c052c8f Initial revision of SDL_Surface testsuite.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
58 return -1;
3c9d9c052c8f Initial revision of SDL_Surface testsuite.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
59
3c9d9c052c8f Initial revision of SDL_Surface testsuite.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
60 SDL_LockSurface( sur );
3c9d9c052c8f Initial revision of SDL_Surface testsuite.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
61
3c9d9c052c8f Initial revision of SDL_Surface testsuite.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
62 ret = 0;
3c9d9c052c8f Initial revision of SDL_Surface testsuite.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
63 bpp = sur->format->BytesPerPixel;
3c9d9c052c8f Initial revision of SDL_Surface testsuite.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
64
3c9d9c052c8f Initial revision of SDL_Surface testsuite.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
65 /* Compare image - should be same format. */
3c9d9c052c8f Initial revision of SDL_Surface testsuite.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
66 for (j=0; j<sur->h; j++) {
3c9d9c052c8f Initial revision of SDL_Surface testsuite.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
67 for (i=0; i<sur->w; i++) {
3c9d9c052c8f Initial revision of SDL_Surface testsuite.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
68 p = (Uint8 *)sur->pixels + j * sur->pitch + i * bpp;
3c9d9c052c8f Initial revision of SDL_Surface testsuite.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
69 pd = (Uint8 *)img->pixel_data + (j*img->width + i) * img->bytes_per_pixel;
3c9d9c052c8f Initial revision of SDL_Surface testsuite.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
70 switch (bpp) {
3c9d9c052c8f Initial revision of SDL_Surface testsuite.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
71 case 1:
3c9d9c052c8f Initial revision of SDL_Surface testsuite.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
72 /* Paletted not supported atm. */
3c9d9c052c8f Initial revision of SDL_Surface testsuite.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
73 ret += 1;
3c9d9c052c8f Initial revision of SDL_Surface testsuite.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
74 break;
3c9d9c052c8f Initial revision of SDL_Surface testsuite.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
75
3c9d9c052c8f Initial revision of SDL_Surface testsuite.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
76 case 2:
3c9d9c052c8f Initial revision of SDL_Surface testsuite.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
77 /* 16 BPP not supported atm. */
3c9d9c052c8f Initial revision of SDL_Surface testsuite.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
78 ret += 1;
3c9d9c052c8f Initial revision of SDL_Surface testsuite.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
79 break;
3c9d9c052c8f Initial revision of SDL_Surface testsuite.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
80
3c9d9c052c8f Initial revision of SDL_Surface testsuite.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
81 case 3:
3c9d9c052c8f Initial revision of SDL_Surface testsuite.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
82 /* 24 BPP not supported atm. */
3c9d9c052c8f Initial revision of SDL_Surface testsuite.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
83 ret += 1;
3c9d9c052c8f Initial revision of SDL_Surface testsuite.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
84 break;
3c9d9c052c8f Initial revision of SDL_Surface testsuite.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
85
3c9d9c052c8f Initial revision of SDL_Surface testsuite.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
86 case 4:
3c9d9c052c8f Initial revision of SDL_Surface testsuite.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
87 ret += !( (p[0] == pd[0]) &&
3c9d9c052c8f Initial revision of SDL_Surface testsuite.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
88 (p[1] == pd[1]) &&
3c9d9c052c8f Initial revision of SDL_Surface testsuite.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
89 (p[2] == pd[2]) );
3c9d9c052c8f Initial revision of SDL_Surface testsuite.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
90 break;
3c9d9c052c8f Initial revision of SDL_Surface testsuite.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
91 }
3c9d9c052c8f Initial revision of SDL_Surface testsuite.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
92 }
3c9d9c052c8f Initial revision of SDL_Surface testsuite.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
93 }
3c9d9c052c8f Initial revision of SDL_Surface testsuite.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
94
3c9d9c052c8f Initial revision of SDL_Surface testsuite.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
95 SDL_UnlockSurface( sur );
3c9d9c052c8f Initial revision of SDL_Surface testsuite.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
96
3c9d9c052c8f Initial revision of SDL_Surface testsuite.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
97 return ret;
3c9d9c052c8f Initial revision of SDL_Surface testsuite.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
98 }
3c9d9c052c8f Initial revision of SDL_Surface testsuite.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
99
3c9d9c052c8f Initial revision of SDL_Surface testsuite.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
100
3c9d9c052c8f Initial revision of SDL_Surface testsuite.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
101 /**
3c9d9c052c8f Initial revision of SDL_Surface testsuite.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
102 * @brief Tests the SDL primitives for rendering.
3c9d9c052c8f Initial revision of SDL_Surface testsuite.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
103 */
3c9d9c052c8f Initial revision of SDL_Surface testsuite.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
104 static void surface_testPrimitives (void)
3c9d9c052c8f Initial revision of SDL_Surface testsuite.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
105 {
3c9d9c052c8f Initial revision of SDL_Surface testsuite.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
106 int ret;
3c9d9c052c8f Initial revision of SDL_Surface testsuite.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
107 int x, y;
3c9d9c052c8f Initial revision of SDL_Surface testsuite.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
108 SDL_Rect rect;
3c9d9c052c8f Initial revision of SDL_Surface testsuite.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
109 SDL_Surface *testsur;
3c9d9c052c8f Initial revision of SDL_Surface testsuite.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
110
3c9d9c052c8f Initial revision of SDL_Surface testsuite.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
111 SDL_ATbegin( "Primitives Test" );
3c9d9c052c8f Initial revision of SDL_Surface testsuite.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
112
3c9d9c052c8f Initial revision of SDL_Surface testsuite.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
113 /* Create the surface. */
3c9d9c052c8f Initial revision of SDL_Surface testsuite.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
114 testsur = SDL_CreateRGBSurface( 0, 80, 60, 32,
3c9d9c052c8f Initial revision of SDL_Surface testsuite.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
115 RMASK, GMASK, BMASK, AMASK );
3c9d9c052c8f Initial revision of SDL_Surface testsuite.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
116 if (SDL_ATassert( "SDL_CreateRGBSurface", testsur != NULL))
3c9d9c052c8f Initial revision of SDL_Surface testsuite.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
117 return;
3c9d9c052c8f Initial revision of SDL_Surface testsuite.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
118
3c9d9c052c8f Initial revision of SDL_Surface testsuite.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
119 /* Draw a rectangle. */
3c9d9c052c8f Initial revision of SDL_Surface testsuite.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
120 rect.x = 40;
3c9d9c052c8f Initial revision of SDL_Surface testsuite.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
121 rect.y = 0;
3c9d9c052c8f Initial revision of SDL_Surface testsuite.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
122 rect.w = 40;
3c9d9c052c8f Initial revision of SDL_Surface testsuite.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
123 rect.h = 80;
3c9d9c052c8f Initial revision of SDL_Surface testsuite.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
124 ret = SDL_FillRect( testsur, &rect,
3c9d9c052c8f Initial revision of SDL_Surface testsuite.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
125 SDL_MapRGB( testsur->format, 13, 73, 200 ) );
3c9d9c052c8f Initial revision of SDL_Surface testsuite.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
126 if (SDL_ATassert( "SDL_FillRect", ret == 0))
3c9d9c052c8f Initial revision of SDL_Surface testsuite.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
127 return;
3c9d9c052c8f Initial revision of SDL_Surface testsuite.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
128
3c9d9c052c8f Initial revision of SDL_Surface testsuite.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
129 /* Draw a rectangle. */
3c9d9c052c8f Initial revision of SDL_Surface testsuite.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
130 rect.x = 10;
3c9d9c052c8f Initial revision of SDL_Surface testsuite.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
131 rect.y = 10;
3c9d9c052c8f Initial revision of SDL_Surface testsuite.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
132 rect.w = 60;
3c9d9c052c8f Initial revision of SDL_Surface testsuite.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
133 rect.h = 40;
3c9d9c052c8f Initial revision of SDL_Surface testsuite.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
134 ret = SDL_FillRect( testsur, &rect,
3c9d9c052c8f Initial revision of SDL_Surface testsuite.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
135 SDL_MapRGB( testsur->format, 200, 0, 100 ) );
3c9d9c052c8f Initial revision of SDL_Surface testsuite.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
136 if (SDL_ATassert( "SDL_FillRect", ret == 0))
3c9d9c052c8f Initial revision of SDL_Surface testsuite.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
137 return;
3c9d9c052c8f Initial revision of SDL_Surface testsuite.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
138
3c9d9c052c8f Initial revision of SDL_Surface testsuite.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
139 /* Draw some points like so:
3c9d9c052c8f Initial revision of SDL_Surface testsuite.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
140 * X.X.X.X..
3c9d9c052c8f Initial revision of SDL_Surface testsuite.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
141 * .X.X.X.X.
3c9d9c052c8f Initial revision of SDL_Surface testsuite.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
142 * X.X.X.X.. */
3c9d9c052c8f Initial revision of SDL_Surface testsuite.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
143 for (y=0; y<3; y++) {
3c9d9c052c8f Initial revision of SDL_Surface testsuite.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
144 x = y % 2;
3c9d9c052c8f Initial revision of SDL_Surface testsuite.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
145 for (; x<80; x+=2)
3c9d9c052c8f Initial revision of SDL_Surface testsuite.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
146 ret = SDL_DrawPoint( testsur, x, y,
3c9d9c052c8f Initial revision of SDL_Surface testsuite.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
147 SDL_MapRGB( testsur->format, x*y, x*y/2, x*y/3 ) );
3c9d9c052c8f Initial revision of SDL_Surface testsuite.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
148 if (SDL_ATassert( "SDL_DrawPoint", ret == 0))
3c9d9c052c8f Initial revision of SDL_Surface testsuite.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
149 return;
3c9d9c052c8f Initial revision of SDL_Surface testsuite.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
150 }
3c9d9c052c8f Initial revision of SDL_Surface testsuite.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
151
3c9d9c052c8f Initial revision of SDL_Surface testsuite.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
152 /* Draw some lines. */
3c9d9c052c8f Initial revision of SDL_Surface testsuite.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
153 ret = SDL_DrawLine( testsur, 0, 30, 80, 30,
3c9d9c052c8f Initial revision of SDL_Surface testsuite.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
154 SDL_MapRGB( testsur->format, 0, 255, 0 ) );
3c9d9c052c8f Initial revision of SDL_Surface testsuite.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
155 if (SDL_ATassert( "SDL_DrawLine", ret == 0))
3c9d9c052c8f Initial revision of SDL_Surface testsuite.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
156 return;
3c9d9c052c8f Initial revision of SDL_Surface testsuite.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
157 ret = SDL_DrawLine( testsur, 40, 30, 40, 60,
3c9d9c052c8f Initial revision of SDL_Surface testsuite.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
158 SDL_MapRGB( testsur->format, 55, 55, 5 ) );
3c9d9c052c8f Initial revision of SDL_Surface testsuite.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
159 if (SDL_ATassert( "SDL_DrawLine", ret == 0))
3c9d9c052c8f Initial revision of SDL_Surface testsuite.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
160 return;
3c9d9c052c8f Initial revision of SDL_Surface testsuite.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
161 ret = SDL_DrawLine( testsur, 0, 60, 80, 0,
3c9d9c052c8f Initial revision of SDL_Surface testsuite.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
162 SDL_MapRGB( testsur->format, 5, 105, 105 ) );
3c9d9c052c8f Initial revision of SDL_Surface testsuite.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
163 if (SDL_ATassert( "SDL_DrawLine", ret == 0))
3c9d9c052c8f Initial revision of SDL_Surface testsuite.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
164 return;
3c9d9c052c8f Initial revision of SDL_Surface testsuite.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
165
3c9d9c052c8f Initial revision of SDL_Surface testsuite.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
166 /* See if it's the same. */
3c9d9c052c8f Initial revision of SDL_Surface testsuite.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
167 if (SDL_ATassert( "Primitives output not the same.",
3c9d9c052c8f Initial revision of SDL_Surface testsuite.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
168 surface_compare( testsur, &img_primitives )==0 ))
3c9d9c052c8f Initial revision of SDL_Surface testsuite.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
169 return;
3c9d9c052c8f Initial revision of SDL_Surface testsuite.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
170
3c9d9c052c8f Initial revision of SDL_Surface testsuite.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
171 /* Clean up. */
3c9d9c052c8f Initial revision of SDL_Surface testsuite.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
172 SDL_FreeSurface( testsur );
3c9d9c052c8f Initial revision of SDL_Surface testsuite.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
173
3c9d9c052c8f Initial revision of SDL_Surface testsuite.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
174 SDL_ATend();
3c9d9c052c8f Initial revision of SDL_Surface testsuite.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
175 }
3c9d9c052c8f Initial revision of SDL_Surface testsuite.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
176
3c9d9c052c8f Initial revision of SDL_Surface testsuite.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
177
3c9d9c052c8f Initial revision of SDL_Surface testsuite.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
178 /**
3c9d9c052c8f Initial revision of SDL_Surface testsuite.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
179 * @brief Entry point.
3c9d9c052c8f Initial revision of SDL_Surface testsuite.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
180 */
3c9d9c052c8f Initial revision of SDL_Surface testsuite.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
181 int main( int argc, const char *argv[] )
3c9d9c052c8f Initial revision of SDL_Surface testsuite.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
182 {
3c9d9c052c8f Initial revision of SDL_Surface testsuite.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
183 SDL_ATinit( "SDL_Surface" );
3c9d9c052c8f Initial revision of SDL_Surface testsuite.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
184
3c9d9c052c8f Initial revision of SDL_Surface testsuite.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
185 /* Initializes the SDL subsystems. */
3c9d9c052c8f Initial revision of SDL_Surface testsuite.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
186 SDL_Init(0);
3c9d9c052c8f Initial revision of SDL_Surface testsuite.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
187
3c9d9c052c8f Initial revision of SDL_Surface testsuite.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
188 surface_testPrimitives();
3c9d9c052c8f Initial revision of SDL_Surface testsuite.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
189 /*surface_testPrimitivesAlpha();*/
3c9d9c052c8f Initial revision of SDL_Surface testsuite.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
190
3c9d9c052c8f Initial revision of SDL_Surface testsuite.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
191 /* Exit SDL. */
3c9d9c052c8f Initial revision of SDL_Surface testsuite.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
192 SDL_Quit();
3c9d9c052c8f Initial revision of SDL_Surface testsuite.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
193
3c9d9c052c8f Initial revision of SDL_Surface testsuite.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
194 return SDL_ATfinish(1);
3c9d9c052c8f Initial revision of SDL_Surface testsuite.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
195 }