annotate test/automated/render/render.c @ 3730:dafd796f0c95 gsoc2009_unit_tests

* Added preliminary render tests, missing some SDL functions to work properly.
author Edgar Simo <bobbens@gmail.com>
date Sun, 12 Jul 2009 12:05:28 +0000
parents
children f5ddf1b670f0
rev   line source
3730
dafd796f0c95 * Added preliminary render tests, missing some SDL functions to work properly.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
1 /**
dafd796f0c95 * Added preliminary render tests, missing some SDL functions to work properly.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
2 * Automated SDL_Surface test.
dafd796f0c95 * Added preliminary render tests, missing some SDL functions to work properly.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
3 *
dafd796f0c95 * Added preliminary render tests, missing some SDL functions to work properly.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
4 * Written by Edgar Simo "bobbens"
dafd796f0c95 * Added preliminary render tests, missing some SDL functions to work properly.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
5 *
dafd796f0c95 * Added preliminary render tests, missing some SDL functions to work properly.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
6 * Released under Public Domain.
dafd796f0c95 * Added preliminary render tests, missing some SDL functions to work properly.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
7 */
dafd796f0c95 * Added preliminary render tests, missing some SDL functions to work properly.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
8
dafd796f0c95 * Added preliminary render tests, missing some SDL functions to work properly.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
9
dafd796f0c95 * Added preliminary render tests, missing some SDL functions to work properly.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
10 #include "SDL.h"
dafd796f0c95 * Added preliminary render tests, missing some SDL functions to work properly.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
11 #include "SDL_at.h"
dafd796f0c95 * Added preliminary render tests, missing some SDL functions to work properly.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
12
dafd796f0c95 * Added preliminary render tests, missing some SDL functions to work properly.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
13 #include "common/common.h"
dafd796f0c95 * Added preliminary render tests, missing some SDL functions to work properly.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
14
dafd796f0c95 * Added preliminary render tests, missing some SDL functions to work properly.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
15
dafd796f0c95 * Added preliminary render tests, missing some SDL functions to work properly.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
16 /*
dafd796f0c95 * Added preliminary render tests, missing some SDL functions to work properly.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
17 * Pull in images for testcases.
dafd796f0c95 * Added preliminary render tests, missing some SDL functions to work properly.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
18 */
dafd796f0c95 * Added preliminary render tests, missing some SDL functions to work properly.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
19 #include "common/images.h"
dafd796f0c95 * Added preliminary render tests, missing some SDL functions to work properly.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
20
dafd796f0c95 * Added preliminary render tests, missing some SDL functions to work properly.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
21
dafd796f0c95 * Added preliminary render tests, missing some SDL functions to work properly.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
22 /*
dafd796f0c95 * Added preliminary render tests, missing some SDL functions to work properly.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
23 * Prototypes.
dafd796f0c95 * Added preliminary render tests, missing some SDL functions to work properly.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
24 */
dafd796f0c95 * Added preliminary render tests, missing some SDL functions to work properly.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
25 static int render_compare( const char *msg, const SurfaceImage_t *s );
dafd796f0c95 * Added preliminary render tests, missing some SDL functions to work properly.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
26 static int render_clearScreen (void);
dafd796f0c95 * Added preliminary render tests, missing some SDL functions to work properly.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
27 /* Testcases. */
dafd796f0c95 * Added preliminary render tests, missing some SDL functions to work properly.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
28 static void render_testPrimitives (void);
dafd796f0c95 * Added preliminary render tests, missing some SDL functions to work properly.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
29 static void render_testPrimitivesBlend (void);
dafd796f0c95 * Added preliminary render tests, missing some SDL functions to work properly.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
30 static void render_testBlit (void);
dafd796f0c95 * Added preliminary render tests, missing some SDL functions to work properly.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
31 static int render_testBlitBlendMode (void);
dafd796f0c95 * Added preliminary render tests, missing some SDL functions to work properly.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
32 static void render_testBlitBlend (void);
dafd796f0c95 * Added preliminary render tests, missing some SDL functions to work properly.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
33
dafd796f0c95 * Added preliminary render tests, missing some SDL functions to work properly.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
34
dafd796f0c95 * Added preliminary render tests, missing some SDL functions to work properly.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
35 /**
dafd796f0c95 * Added preliminary render tests, missing some SDL functions to work properly.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
36 * Compares screen pixels with image pixels.
dafd796f0c95 * Added preliminary render tests, missing some SDL functions to work properly.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
37 */
dafd796f0c95 * Added preliminary render tests, missing some SDL functions to work properly.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
38 static int render_compare( const char *msg, const SurfaceImage_t *s )
dafd796f0c95 * Added preliminary render tests, missing some SDL functions to work properly.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
39 {
dafd796f0c95 * Added preliminary render tests, missing some SDL functions to work properly.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
40 int ret;
dafd796f0c95 * Added preliminary render tests, missing some SDL functions to work properly.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
41 void *pix;
dafd796f0c95 * Added preliminary render tests, missing some SDL functions to work properly.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
42 SDL_Surface *testsur;
dafd796f0c95 * Added preliminary render tests, missing some SDL functions to work properly.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
43
dafd796f0c95 * Added preliminary render tests, missing some SDL functions to work properly.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
44 #if 0
dafd796f0c95 * Added preliminary render tests, missing some SDL functions to work properly.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
45
dafd796f0c95 * Added preliminary render tests, missing some SDL functions to work properly.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
46 /* Allocate pixel space. */
dafd796f0c95 * Added preliminary render tests, missing some SDL functions to work properly.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
47 pix = malloc( 4*80*60 );
dafd796f0c95 * Added preliminary render tests, missing some SDL functions to work properly.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
48 if (SDL_ATassert( "malloc", pix!=NULL ))
dafd796f0c95 * Added preliminary render tests, missing some SDL functions to work properly.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
49 return 1;
dafd796f0c95 * Added preliminary render tests, missing some SDL functions to work properly.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
50
dafd796f0c95 * Added preliminary render tests, missing some SDL functions to work properly.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
51 /* Read pixels. */
dafd796f0c95 * Added preliminary render tests, missing some SDL functions to work properly.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
52 ret = SDL_RenderReadPixels( NULL, pix, 80*4 );
dafd796f0c95 * Added preliminary render tests, missing some SDL functions to work properly.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
53 if (SDL_ATassert( "SDL_RenderReadPixels", ret==0) )
dafd796f0c95 * Added preliminary render tests, missing some SDL functions to work properly.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
54 return 1;
dafd796f0c95 * Added preliminary render tests, missing some SDL functions to work properly.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
55
dafd796f0c95 * Added preliminary render tests, missing some SDL functions to work properly.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
56 /* Create surface. */
dafd796f0c95 * Added preliminary render tests, missing some SDL functions to work properly.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
57 testsur = SDL_CreateRGBSurfaceFrom( pix, 80, 60, 32, 80*4,
dafd796f0c95 * Added preliminary render tests, missing some SDL functions to work properly.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
58 RMASK, GMASK, BMASK, AMASK );
dafd796f0c95 * Added preliminary render tests, missing some SDL functions to work properly.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
59 if (SDL_ATassert( "SDL_CreateRGBSurfaceFrom", testsur!=NULL ))
dafd796f0c95 * Added preliminary render tests, missing some SDL functions to work properly.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
60 return 1;
dafd796f0c95 * Added preliminary render tests, missing some SDL functions to work properly.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
61
dafd796f0c95 * Added preliminary render tests, missing some SDL functions to work properly.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
62 /* Compare surface. */
dafd796f0c95 * Added preliminary render tests, missing some SDL functions to work properly.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
63 ret = surface_compare( testsur, s );
dafd796f0c95 * Added preliminary render tests, missing some SDL functions to work properly.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
64 if (SDL_ATassert( msg, ret==0 ))
dafd796f0c95 * Added preliminary render tests, missing some SDL functions to work properly.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
65 return 1;
dafd796f0c95 * Added preliminary render tests, missing some SDL functions to work properly.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
66
dafd796f0c95 * Added preliminary render tests, missing some SDL functions to work properly.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
67 /* Clean up. */
dafd796f0c95 * Added preliminary render tests, missing some SDL functions to work properly.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
68 SDL_FreeSurface( testsur );
dafd796f0c95 * Added preliminary render tests, missing some SDL functions to work properly.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
69 free(pix);
dafd796f0c95 * Added preliminary render tests, missing some SDL functions to work properly.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
70
dafd796f0c95 * Added preliminary render tests, missing some SDL functions to work properly.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
71 #endif
dafd796f0c95 * Added preliminary render tests, missing some SDL functions to work properly.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
72
dafd796f0c95 * Added preliminary render tests, missing some SDL functions to work properly.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
73 return 0;
dafd796f0c95 * Added preliminary render tests, missing some SDL functions to work properly.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
74 }
dafd796f0c95 * Added preliminary render tests, missing some SDL functions to work properly.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
75
dafd796f0c95 * Added preliminary render tests, missing some SDL functions to work properly.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
76 /**
dafd796f0c95 * Added preliminary render tests, missing some SDL functions to work properly.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
77 * @brief Clears the screen.
dafd796f0c95 * Added preliminary render tests, missing some SDL functions to work properly.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
78 */
dafd796f0c95 * Added preliminary render tests, missing some SDL functions to work properly.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
79 static int render_clearScreen (void)
dafd796f0c95 * Added preliminary render tests, missing some SDL functions to work properly.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
80 {
dafd796f0c95 * Added preliminary render tests, missing some SDL functions to work properly.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
81 int ret;
dafd796f0c95 * Added preliminary render tests, missing some SDL functions to work properly.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
82
dafd796f0c95 * Added preliminary render tests, missing some SDL functions to work properly.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
83 /* Set colour. */
dafd796f0c95 * Added preliminary render tests, missing some SDL functions to work properly.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
84 ret = SDL_SetRenderDrawColor( 0, 0, 0, SDL_ALPHA_OPAQUE );
dafd796f0c95 * Added preliminary render tests, missing some SDL functions to work properly.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
85 if (SDL_ATassert( "SDL_SetRenderDrawColor", ret == 0))
dafd796f0c95 * Added preliminary render tests, missing some SDL functions to work properly.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
86 return -1;
dafd796f0c95 * Added preliminary render tests, missing some SDL functions to work properly.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
87
dafd796f0c95 * Added preliminary render tests, missing some SDL functions to work properly.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
88 /* Clear screen. */
dafd796f0c95 * Added preliminary render tests, missing some SDL functions to work properly.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
89 ret = SDL_RenderFill( NULL );
dafd796f0c95 * Added preliminary render tests, missing some SDL functions to work properly.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
90 if (SDL_ATassert( "SDL_RenderFill", ret == 0))
dafd796f0c95 * Added preliminary render tests, missing some SDL functions to work properly.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
91 return -1;
dafd796f0c95 * Added preliminary render tests, missing some SDL functions to work properly.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
92
dafd796f0c95 * Added preliminary render tests, missing some SDL functions to work properly.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
93 return 0;
dafd796f0c95 * Added preliminary render tests, missing some SDL functions to work properly.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
94 }
dafd796f0c95 * Added preliminary render tests, missing some SDL functions to work properly.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
95
dafd796f0c95 * Added preliminary render tests, missing some SDL functions to work properly.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
96
dafd796f0c95 * Added preliminary render tests, missing some SDL functions to work properly.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
97 /**
dafd796f0c95 * Added preliminary render tests, missing some SDL functions to work properly.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
98 * @brief Tests the SDL primitives for rendering.
dafd796f0c95 * Added preliminary render tests, missing some SDL functions to work properly.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
99 */
dafd796f0c95 * Added preliminary render tests, missing some SDL functions to work properly.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
100 static void render_testPrimitives (void)
dafd796f0c95 * Added preliminary render tests, missing some SDL functions to work properly.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
101 {
dafd796f0c95 * Added preliminary render tests, missing some SDL functions to work properly.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
102 int ret;
dafd796f0c95 * Added preliminary render tests, missing some SDL functions to work properly.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
103 int x, y;
dafd796f0c95 * Added preliminary render tests, missing some SDL functions to work properly.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
104 SDL_Rect rect;
dafd796f0c95 * Added preliminary render tests, missing some SDL functions to work properly.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
105
dafd796f0c95 * Added preliminary render tests, missing some SDL functions to work properly.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
106 /* Clear surface. */
dafd796f0c95 * Added preliminary render tests, missing some SDL functions to work properly.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
107 if (render_clearScreen())
dafd796f0c95 * Added preliminary render tests, missing some SDL functions to work properly.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
108 return;
dafd796f0c95 * Added preliminary render tests, missing some SDL functions to work properly.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
109
dafd796f0c95 * Added preliminary render tests, missing some SDL functions to work properly.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
110 /* Draw a rectangle. */
dafd796f0c95 * Added preliminary render tests, missing some SDL functions to work properly.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
111 rect.x = 40;
dafd796f0c95 * Added preliminary render tests, missing some SDL functions to work properly.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
112 rect.y = 0;
dafd796f0c95 * Added preliminary render tests, missing some SDL functions to work properly.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
113 rect.w = 40;
dafd796f0c95 * Added preliminary render tests, missing some SDL functions to work properly.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
114 rect.h = 80;
dafd796f0c95 * Added preliminary render tests, missing some SDL functions to work properly.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
115 ret = SDL_SetRenderDrawColor( 13, 73, 200, SDL_ALPHA_OPAQUE );
dafd796f0c95 * Added preliminary render tests, missing some SDL functions to work properly.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
116 if (SDL_ATassert( "SDL_SetRenderDrawColor", ret == 0))
dafd796f0c95 * Added preliminary render tests, missing some SDL functions to work properly.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
117 return;
dafd796f0c95 * Added preliminary render tests, missing some SDL functions to work properly.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
118 ret = SDL_RenderFill( &rect );
dafd796f0c95 * Added preliminary render tests, missing some SDL functions to work properly.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
119 if (SDL_ATassert( "SDL_RenderRect", ret == 0))
dafd796f0c95 * Added preliminary render tests, missing some SDL functions to work properly.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
120 return;
dafd796f0c95 * Added preliminary render tests, missing some SDL functions to work properly.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
121
dafd796f0c95 * Added preliminary render tests, missing some SDL functions to work properly.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
122 /* Draw a rectangle. */
dafd796f0c95 * Added preliminary render tests, missing some SDL functions to work properly.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
123 rect.x = 10;
dafd796f0c95 * Added preliminary render tests, missing some SDL functions to work properly.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
124 rect.y = 10;
dafd796f0c95 * Added preliminary render tests, missing some SDL functions to work properly.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
125 rect.w = 60;
dafd796f0c95 * Added preliminary render tests, missing some SDL functions to work properly.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
126 rect.h = 40;
dafd796f0c95 * Added preliminary render tests, missing some SDL functions to work properly.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
127 ret = SDL_SetRenderDrawColor( 200, 0, 100, SDL_ALPHA_OPAQUE );
dafd796f0c95 * Added preliminary render tests, missing some SDL functions to work properly.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
128 if (SDL_ATassert( "SDL_SetRenderDrawColor", ret == 0))
dafd796f0c95 * Added preliminary render tests, missing some SDL functions to work properly.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
129 return;
dafd796f0c95 * Added preliminary render tests, missing some SDL functions to work properly.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
130 ret = SDL_RenderFill( &rect );
dafd796f0c95 * Added preliminary render tests, missing some SDL functions to work properly.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
131 if (SDL_ATassert( "SDL_RenderRect", ret == 0))
dafd796f0c95 * Added preliminary render tests, missing some SDL functions to work properly.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
132 return;
dafd796f0c95 * Added preliminary render tests, missing some SDL functions to work properly.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
133
dafd796f0c95 * Added preliminary render tests, missing some SDL functions to work properly.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
134 /* Draw some points like so:
dafd796f0c95 * Added preliminary render tests, missing some SDL functions to work properly.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
135 * X.X.X.X..
dafd796f0c95 * Added preliminary render tests, missing some SDL functions to work properly.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
136 * .X.X.X.X.
dafd796f0c95 * Added preliminary render tests, missing some SDL functions to work properly.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
137 * X.X.X.X.. */
dafd796f0c95 * Added preliminary render tests, missing some SDL functions to work properly.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
138 for (y=0; y<3; y++) {
dafd796f0c95 * Added preliminary render tests, missing some SDL functions to work properly.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
139 x = y % 2;
dafd796f0c95 * Added preliminary render tests, missing some SDL functions to work properly.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
140 for (; x<80; x+=2) {
dafd796f0c95 * Added preliminary render tests, missing some SDL functions to work properly.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
141 ret = SDL_SetRenderDrawColor( x*y, x*y/2, x*y/3, SDL_ALPHA_OPAQUE );
dafd796f0c95 * Added preliminary render tests, missing some SDL functions to work properly.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
142 if (SDL_ATassert( "SDL_SetRenderDrawColor", ret == 0))
dafd796f0c95 * Added preliminary render tests, missing some SDL functions to work properly.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
143 return;
dafd796f0c95 * Added preliminary render tests, missing some SDL functions to work properly.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
144 ret = SDL_RenderPoint( x, y );
dafd796f0c95 * Added preliminary render tests, missing some SDL functions to work properly.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
145 if (SDL_ATassert( "SDL_RenderPoint", ret == 0))
dafd796f0c95 * Added preliminary render tests, missing some SDL functions to work properly.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
146 return;
dafd796f0c95 * Added preliminary render tests, missing some SDL functions to work properly.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
147 }
dafd796f0c95 * Added preliminary render tests, missing some SDL functions to work properly.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
148 }
dafd796f0c95 * Added preliminary render tests, missing some SDL functions to work properly.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
149
dafd796f0c95 * Added preliminary render tests, missing some SDL functions to work properly.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
150 /* Draw some lines. */
dafd796f0c95 * Added preliminary render tests, missing some SDL functions to work properly.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
151 ret = SDL_SetRenderDrawColor( 0, 255, 0, SDL_ALPHA_OPAQUE );
dafd796f0c95 * Added preliminary render tests, missing some SDL functions to work properly.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
152 if (SDL_ATassert( "SDL_SetRenderDrawColor", ret == 0))
dafd796f0c95 * Added preliminary render tests, missing some SDL functions to work properly.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
153 return;
dafd796f0c95 * Added preliminary render tests, missing some SDL functions to work properly.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
154 ret = SDL_RenderLine( 0, 30, 80, 30 );
dafd796f0c95 * Added preliminary render tests, missing some SDL functions to work properly.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
155 if (SDL_ATassert( "SDL_RenderLine", ret == 0))
dafd796f0c95 * Added preliminary render tests, missing some SDL functions to work properly.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
156 return;
dafd796f0c95 * Added preliminary render tests, missing some SDL functions to work properly.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
157 ret = SDL_SetRenderDrawColor( 55, 55, 5, SDL_ALPHA_OPAQUE );
dafd796f0c95 * Added preliminary render tests, missing some SDL functions to work properly.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
158 if (SDL_ATassert( "SDL_SetRenderDrawColor", ret == 0))
dafd796f0c95 * Added preliminary render tests, missing some SDL functions to work properly.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
159 return;
dafd796f0c95 * Added preliminary render tests, missing some SDL functions to work properly.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
160 ret = SDL_RenderLine( 40, 30, 40, 60 );
dafd796f0c95 * Added preliminary render tests, missing some SDL functions to work properly.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
161 if (SDL_ATassert( "SDL_RenderLine", ret == 0))
dafd796f0c95 * Added preliminary render tests, missing some SDL functions to work properly.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
162 return;
dafd796f0c95 * Added preliminary render tests, missing some SDL functions to work properly.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
163 ret = SDL_SetRenderDrawColor( 5, 105, 105, SDL_ALPHA_OPAQUE );
dafd796f0c95 * Added preliminary render tests, missing some SDL functions to work properly.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
164 if (SDL_ATassert( "SDL_SetRenderDrawColor", ret == 0))
dafd796f0c95 * Added preliminary render tests, missing some SDL functions to work properly.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
165 return;
dafd796f0c95 * Added preliminary render tests, missing some SDL functions to work properly.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
166 ret = SDL_RenderLine( 0, 60, 80, 0 );
dafd796f0c95 * Added preliminary render tests, missing some SDL functions to work properly.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
167 if (SDL_ATassert( "SDL_RenderLine", ret == 0))
dafd796f0c95 * Added preliminary render tests, missing some SDL functions to work properly.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
168 return;
dafd796f0c95 * Added preliminary render tests, missing some SDL functions to work properly.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
169
dafd796f0c95 * Added preliminary render tests, missing some SDL functions to work properly.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
170 /* See if it's the same. */
dafd796f0c95 * Added preliminary render tests, missing some SDL functions to work properly.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
171 if (render_compare( "Primitives output not the same.", &img_primitives ))
dafd796f0c95 * Added preliminary render tests, missing some SDL functions to work properly.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
172 return;
dafd796f0c95 * Added preliminary render tests, missing some SDL functions to work properly.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
173 }
dafd796f0c95 * Added preliminary render tests, missing some SDL functions to work properly.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
174 #if 0
dafd796f0c95 * Added preliminary render tests, missing some SDL functions to work properly.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
175
dafd796f0c95 * Added preliminary render tests, missing some SDL functions to work properly.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
176
dafd796f0c95 * Added preliminary render tests, missing some SDL functions to work properly.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
177 /**
dafd796f0c95 * Added preliminary render tests, missing some SDL functions to work properly.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
178 * @brief Tests the SDL primitives with alpha for rendering.
dafd796f0c95 * Added preliminary render tests, missing some SDL functions to work properly.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
179 */
dafd796f0c95 * Added preliminary render tests, missing some SDL functions to work properly.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
180 static void render_testPrimitivesBlend (void)
dafd796f0c95 * Added preliminary render tests, missing some SDL functions to work properly.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
181 {
dafd796f0c95 * Added preliminary render tests, missing some SDL functions to work properly.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
182 int ret;
dafd796f0c95 * Added preliminary render tests, missing some SDL functions to work properly.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
183 int i, j;
dafd796f0c95 * Added preliminary render tests, missing some SDL functions to work properly.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
184 SDL_Rect rect;
dafd796f0c95 * Added preliminary render tests, missing some SDL functions to work properly.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
185
dafd796f0c95 * Added preliminary render tests, missing some SDL functions to work properly.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
186 SDL_ATbegin( "Primitives Blend Test" );
dafd796f0c95 * Added preliminary render tests, missing some SDL functions to work properly.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
187
dafd796f0c95 * Added preliminary render tests, missing some SDL functions to work properly.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
188 /* Clear surface. */
dafd796f0c95 * Added preliminary render tests, missing some SDL functions to work properly.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
189 ret = SDL_FillRect( testsur, NULL,
dafd796f0c95 * Added preliminary render tests, missing some SDL functions to work properly.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
190 SDL_MapRGB( testsur->format, 0, 0, 0 ) );
dafd796f0c95 * Added preliminary render tests, missing some SDL functions to work properly.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
191 if (SDL_ATassert( "SDL_FillRect", ret == 0))
dafd796f0c95 * Added preliminary render tests, missing some SDL functions to work properly.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
192 return;
dafd796f0c95 * Added preliminary render tests, missing some SDL functions to work properly.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
193
dafd796f0c95 * Added preliminary render tests, missing some SDL functions to work properly.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
194 /* Create some rectangles for each blend mode. */
dafd796f0c95 * Added preliminary render tests, missing some SDL functions to work properly.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
195 ret = SDL_BlendRect( testsur, NULL, SDL_BLENDMODE_NONE, 255, 255, 255, 0 );
dafd796f0c95 * Added preliminary render tests, missing some SDL functions to work properly.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
196 if (SDL_ATassert( "SDL_BlendRect", ret == 0))
dafd796f0c95 * Added preliminary render tests, missing some SDL functions to work properly.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
197 return;
dafd796f0c95 * Added preliminary render tests, missing some SDL functions to work properly.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
198 rect.x = 10;
dafd796f0c95 * Added preliminary render tests, missing some SDL functions to work properly.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
199 rect.y = 25;
dafd796f0c95 * Added preliminary render tests, missing some SDL functions to work properly.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
200 rect.w = 40;
dafd796f0c95 * Added preliminary render tests, missing some SDL functions to work properly.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
201 rect.h = 25;
dafd796f0c95 * Added preliminary render tests, missing some SDL functions to work properly.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
202 ret = SDL_BlendRect( testsur, &rect, SDL_BLENDMODE_ADD, 240, 10, 10, 75 );
dafd796f0c95 * Added preliminary render tests, missing some SDL functions to work properly.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
203 if (SDL_ATassert( "SDL_BlendRect", ret == 0))
dafd796f0c95 * Added preliminary render tests, missing some SDL functions to work properly.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
204 return;
dafd796f0c95 * Added preliminary render tests, missing some SDL functions to work properly.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
205 rect.x = 30;
dafd796f0c95 * Added preliminary render tests, missing some SDL functions to work properly.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
206 rect.y = 40;
dafd796f0c95 * Added preliminary render tests, missing some SDL functions to work properly.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
207 rect.w = 45;
dafd796f0c95 * Added preliminary render tests, missing some SDL functions to work properly.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
208 rect.h = 15;
dafd796f0c95 * Added preliminary render tests, missing some SDL functions to work properly.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
209 ret = SDL_BlendRect( testsur, &rect, SDL_BLENDMODE_BLEND, 10, 240, 10, 100 );
dafd796f0c95 * Added preliminary render tests, missing some SDL functions to work properly.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
210 if (SDL_ATassert( "SDL_BlendRect", ret == 0))
dafd796f0c95 * Added preliminary render tests, missing some SDL functions to work properly.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
211 return;
dafd796f0c95 * Added preliminary render tests, missing some SDL functions to work properly.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
212 rect.x = 25;
dafd796f0c95 * Added preliminary render tests, missing some SDL functions to work properly.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
213 rect.y = 25;
dafd796f0c95 * Added preliminary render tests, missing some SDL functions to work properly.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
214 rect.w = 25;
dafd796f0c95 * Added preliminary render tests, missing some SDL functions to work properly.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
215 rect.h = 25;
dafd796f0c95 * Added preliminary render tests, missing some SDL functions to work properly.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
216 ret = SDL_BlendRect( testsur, &rect, SDL_BLENDMODE_MOD, 10, 10, 240, 125 );
dafd796f0c95 * Added preliminary render tests, missing some SDL functions to work properly.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
217 if (SDL_ATassert( "SDL_BlendRect", ret == 0))
dafd796f0c95 * Added preliminary render tests, missing some SDL functions to work properly.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
218 return;
dafd796f0c95 * Added preliminary render tests, missing some SDL functions to work properly.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
219
dafd796f0c95 * Added preliminary render tests, missing some SDL functions to work properly.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
220 /* Draw blended lines, lines for everyone. */
dafd796f0c95 * Added preliminary render tests, missing some SDL functions to work properly.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
221 for (i=0; i<testsur->w; i+=2) {
dafd796f0c95 * Added preliminary render tests, missing some SDL functions to work properly.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
222 ret = SDL_BlendLine( testsur, 0, 0, i, 59,
dafd796f0c95 * Added preliminary render tests, missing some SDL functions to work properly.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
223 (((i/2)%3)==0) ? SDL_BLENDMODE_BLEND :
dafd796f0c95 * Added preliminary render tests, missing some SDL functions to work properly.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
224 (((i/2)%3)==1) ? SDL_BLENDMODE_ADD : SDL_BLENDMODE_MOD,
dafd796f0c95 * Added preliminary render tests, missing some SDL functions to work properly.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
225 60+2*i, 240-2*i, 50, 3*i );
dafd796f0c95 * Added preliminary render tests, missing some SDL functions to work properly.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
226 if (SDL_ATassert( "SDL_BlendLine", ret == 0))
dafd796f0c95 * Added preliminary render tests, missing some SDL functions to work properly.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
227 return;
dafd796f0c95 * Added preliminary render tests, missing some SDL functions to work properly.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
228 }
dafd796f0c95 * Added preliminary render tests, missing some SDL functions to work properly.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
229 for (i=0; i<testsur->h; i+=2) {
dafd796f0c95 * Added preliminary render tests, missing some SDL functions to work properly.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
230 ret = SDL_BlendLine( testsur, 0, 0, 79, i,
dafd796f0c95 * Added preliminary render tests, missing some SDL functions to work properly.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
231 (((i/2)%3)==0) ? SDL_BLENDMODE_BLEND :
dafd796f0c95 * Added preliminary render tests, missing some SDL functions to work properly.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
232 (((i/2)%3)==1) ? SDL_BLENDMODE_ADD : SDL_BLENDMODE_MOD,
dafd796f0c95 * Added preliminary render tests, missing some SDL functions to work properly.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
233 60+2*i, 240-2*i, 50, 3*i );
dafd796f0c95 * Added preliminary render tests, missing some SDL functions to work properly.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
234 if (SDL_ATassert( "SDL_BlendLine", ret == 0))
dafd796f0c95 * Added preliminary render tests, missing some SDL functions to work properly.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
235 return;
dafd796f0c95 * Added preliminary render tests, missing some SDL functions to work properly.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
236 }
dafd796f0c95 * Added preliminary render tests, missing some SDL functions to work properly.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
237
dafd796f0c95 * Added preliminary render tests, missing some SDL functions to work properly.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
238 /* Draw points. */
dafd796f0c95 * Added preliminary render tests, missing some SDL functions to work properly.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
239 for (j=0; j<testsur->h; j+=3) {
dafd796f0c95 * Added preliminary render tests, missing some SDL functions to work properly.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
240 for (i=0; i<testsur->w; i+=3) {
dafd796f0c95 * Added preliminary render tests, missing some SDL functions to work properly.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
241 ret = SDL_BlendPoint( testsur, i, j,
dafd796f0c95 * Added preliminary render tests, missing some SDL functions to work properly.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
242 ((((i+j)/3)%3)==0) ? SDL_BLENDMODE_BLEND :
dafd796f0c95 * Added preliminary render tests, missing some SDL functions to work properly.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
243 ((((i+j)/3)%3)==1) ? SDL_BLENDMODE_ADD : SDL_BLENDMODE_MOD,
dafd796f0c95 * Added preliminary render tests, missing some SDL functions to work properly.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
244 j*4, i*3, j*4, i*3 );
dafd796f0c95 * Added preliminary render tests, missing some SDL functions to work properly.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
245 if (SDL_ATassert( "SDL_BlendPoint", ret == 0))
dafd796f0c95 * Added preliminary render tests, missing some SDL functions to work properly.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
246 return;
dafd796f0c95 * Added preliminary render tests, missing some SDL functions to work properly.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
247 }
dafd796f0c95 * Added preliminary render tests, missing some SDL functions to work properly.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
248 }
dafd796f0c95 * Added preliminary render tests, missing some SDL functions to work properly.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
249
dafd796f0c95 * Added preliminary render tests, missing some SDL functions to work properly.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
250 /* See if it's the same. */
dafd796f0c95 * Added preliminary render tests, missing some SDL functions to work properly.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
251 if (SDL_ATassert( "Primitives output not the same.",
dafd796f0c95 * Added preliminary render tests, missing some SDL functions to work properly.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
252 render_compare( testsur, &img_blend )==0 ))
dafd796f0c95 * Added preliminary render tests, missing some SDL functions to work properly.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
253 return;
dafd796f0c95 * Added preliminary render tests, missing some SDL functions to work properly.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
254
dafd796f0c95 * Added preliminary render tests, missing some SDL functions to work properly.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
255 SDL_ATend();
dafd796f0c95 * Added preliminary render tests, missing some SDL functions to work properly.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
256 }
dafd796f0c95 * Added preliminary render tests, missing some SDL functions to work properly.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
257
dafd796f0c95 * Added preliminary render tests, missing some SDL functions to work properly.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
258
dafd796f0c95 * Added preliminary render tests, missing some SDL functions to work properly.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
259 /**
dafd796f0c95 * Added preliminary render tests, missing some SDL functions to work properly.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
260 * @brief Tests some blitting routines.
dafd796f0c95 * Added preliminary render tests, missing some SDL functions to work properly.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
261 */
dafd796f0c95 * Added preliminary render tests, missing some SDL functions to work properly.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
262 static void render_testBlit (void)
dafd796f0c95 * Added preliminary render tests, missing some SDL functions to work properly.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
263 {
dafd796f0c95 * Added preliminary render tests, missing some SDL functions to work properly.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
264 int ret;
dafd796f0c95 * Added preliminary render tests, missing some SDL functions to work properly.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
265 SDL_Rect rect;
dafd796f0c95 * Added preliminary render tests, missing some SDL functions to work properly.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
266 SDL_Surface *face;
dafd796f0c95 * Added preliminary render tests, missing some SDL functions to work properly.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
267 int i, j, ni, nj;
dafd796f0c95 * Added preliminary render tests, missing some SDL functions to work properly.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
268
dafd796f0c95 * Added preliminary render tests, missing some SDL functions to work properly.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
269 SDL_ATbegin( "Blit Tests" );
dafd796f0c95 * Added preliminary render tests, missing some SDL functions to work properly.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
270
dafd796f0c95 * Added preliminary render tests, missing some SDL functions to work properly.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
271 /* Clear surface. */
dafd796f0c95 * Added preliminary render tests, missing some SDL functions to work properly.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
272 ret = SDL_FillRect( testsur, NULL,
dafd796f0c95 * Added preliminary render tests, missing some SDL functions to work properly.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
273 SDL_MapRGB( testsur->format, 0, 0, 0 ) );
dafd796f0c95 * Added preliminary render tests, missing some SDL functions to work properly.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
274 if (SDL_ATassert( "SDL_FillRect", ret == 0))
dafd796f0c95 * Added preliminary render tests, missing some SDL functions to work properly.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
275 return;
dafd796f0c95 * Added preliminary render tests, missing some SDL functions to work properly.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
276
dafd796f0c95 * Added preliminary render tests, missing some SDL functions to work properly.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
277 /* Create face surface. */
dafd796f0c95 * Added preliminary render tests, missing some SDL functions to work properly.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
278 face = SDL_CreateRGBSurfaceFrom( (void*)img_face.pixel_data,
dafd796f0c95 * Added preliminary render tests, missing some SDL functions to work properly.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
279 img_face.width, img_face.height, 32, img_face.width*4,
dafd796f0c95 * Added preliminary render tests, missing some SDL functions to work properly.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
280 RMASK, GMASK, BMASK, AMASK );
dafd796f0c95 * Added preliminary render tests, missing some SDL functions to work properly.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
281 if (SDL_ATassert( "SDL_CreateRGBSurfaceFrom", face != NULL))
dafd796f0c95 * Added preliminary render tests, missing some SDL functions to work properly.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
282 return;
dafd796f0c95 * Added preliminary render tests, missing some SDL functions to work properly.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
283
dafd796f0c95 * Added preliminary render tests, missing some SDL functions to work properly.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
284 /* Constant values. */
dafd796f0c95 * Added preliminary render tests, missing some SDL functions to work properly.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
285 rect.w = face->w;
dafd796f0c95 * Added preliminary render tests, missing some SDL functions to work properly.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
286 rect.h = face->h;
dafd796f0c95 * Added preliminary render tests, missing some SDL functions to work properly.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
287 ni = testsur->w - face->w;
dafd796f0c95 * Added preliminary render tests, missing some SDL functions to work properly.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
288 nj = testsur->h - face->h;
dafd796f0c95 * Added preliminary render tests, missing some SDL functions to work properly.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
289
dafd796f0c95 * Added preliminary render tests, missing some SDL functions to work properly.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
290 /* Loop blit. */
dafd796f0c95 * Added preliminary render tests, missing some SDL functions to work properly.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
291 for (j=0; j <= nj; j+=4) {
dafd796f0c95 * Added preliminary render tests, missing some SDL functions to work properly.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
292 for (i=0; i <= ni; i+=4) {
dafd796f0c95 * Added preliminary render tests, missing some SDL functions to work properly.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
293 /* Blitting. */
dafd796f0c95 * Added preliminary render tests, missing some SDL functions to work properly.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
294 rect.x = i;
dafd796f0c95 * Added preliminary render tests, missing some SDL functions to work properly.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
295 rect.y = j;
dafd796f0c95 * Added preliminary render tests, missing some SDL functions to work properly.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
296 ret = SDL_BlitSurface( face, NULL, testsur, &rect );
dafd796f0c95 * Added preliminary render tests, missing some SDL functions to work properly.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
297 if (SDL_ATassert( "SDL_BlitSurface", ret == 0))
dafd796f0c95 * Added preliminary render tests, missing some SDL functions to work properly.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
298 return;
dafd796f0c95 * Added preliminary render tests, missing some SDL functions to work properly.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
299 }
dafd796f0c95 * Added preliminary render tests, missing some SDL functions to work properly.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
300 }
dafd796f0c95 * Added preliminary render tests, missing some SDL functions to work properly.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
301
dafd796f0c95 * Added preliminary render tests, missing some SDL functions to work properly.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
302 /* See if it's the same. */
dafd796f0c95 * Added preliminary render tests, missing some SDL functions to work properly.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
303 if (SDL_ATassert( "Blitting output not the same (normal blit).",
dafd796f0c95 * Added preliminary render tests, missing some SDL functions to work properly.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
304 render_compare( testsur, &img_blit )==0 ))
dafd796f0c95 * Added preliminary render tests, missing some SDL functions to work properly.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
305 return;
dafd796f0c95 * Added preliminary render tests, missing some SDL functions to work properly.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
306
dafd796f0c95 * Added preliminary render tests, missing some SDL functions to work properly.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
307 /* Clear surface. */
dafd796f0c95 * Added preliminary render tests, missing some SDL functions to work properly.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
308 ret = SDL_FillRect( testsur, NULL,
dafd796f0c95 * Added preliminary render tests, missing some SDL functions to work properly.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
309 SDL_MapRGB( testsur->format, 0, 0, 0 ) );
dafd796f0c95 * Added preliminary render tests, missing some SDL functions to work properly.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
310 if (SDL_ATassert( "SDL_FillRect", ret == 0))
dafd796f0c95 * Added preliminary render tests, missing some SDL functions to work properly.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
311 return;
dafd796f0c95 * Added preliminary render tests, missing some SDL functions to work properly.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
312
dafd796f0c95 * Added preliminary render tests, missing some SDL functions to work properly.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
313 /* Test blitting with colour mod. */
dafd796f0c95 * Added preliminary render tests, missing some SDL functions to work properly.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
314 for (j=0; j <= nj; j+=4) {
dafd796f0c95 * Added preliminary render tests, missing some SDL functions to work properly.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
315 for (i=0; i <= ni; i+=4) {
dafd796f0c95 * Added preliminary render tests, missing some SDL functions to work properly.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
316 /* Set colour mod. */
dafd796f0c95 * Added preliminary render tests, missing some SDL functions to work properly.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
317 ret = SDL_SetSurfaceColorMod( face, (255/nj)*j, (255/ni)*i, (255/nj)*j );
dafd796f0c95 * Added preliminary render tests, missing some SDL functions to work properly.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
318 if (SDL_ATassert( "SDL_SetSurfaceColorMod", ret == 0))
dafd796f0c95 * Added preliminary render tests, missing some SDL functions to work properly.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
319 return;
dafd796f0c95 * Added preliminary render tests, missing some SDL functions to work properly.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
320
dafd796f0c95 * Added preliminary render tests, missing some SDL functions to work properly.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
321 /* Blitting. */
dafd796f0c95 * Added preliminary render tests, missing some SDL functions to work properly.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
322 rect.x = i;
dafd796f0c95 * Added preliminary render tests, missing some SDL functions to work properly.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
323 rect.y = j;
dafd796f0c95 * Added preliminary render tests, missing some SDL functions to work properly.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
324 ret = SDL_BlitSurface( face, NULL, testsur, &rect );
dafd796f0c95 * Added preliminary render tests, missing some SDL functions to work properly.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
325 if (SDL_ATassert( "SDL_BlitSurface", ret == 0))
dafd796f0c95 * Added preliminary render tests, missing some SDL functions to work properly.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
326 return;
dafd796f0c95 * Added preliminary render tests, missing some SDL functions to work properly.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
327 }
dafd796f0c95 * Added preliminary render tests, missing some SDL functions to work properly.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
328 }
dafd796f0c95 * Added preliminary render tests, missing some SDL functions to work properly.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
329
dafd796f0c95 * Added preliminary render tests, missing some SDL functions to work properly.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
330 /* See if it's the same. */
dafd796f0c95 * Added preliminary render tests, missing some SDL functions to work properly.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
331 if (SDL_ATassert( "Blitting output not the same (using SDL_SetSurfaceColorMod).",
dafd796f0c95 * Added preliminary render tests, missing some SDL functions to work properly.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
332 render_compare( testsur, &img_blitColour )==0 ))
dafd796f0c95 * Added preliminary render tests, missing some SDL functions to work properly.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
333 return;
dafd796f0c95 * Added preliminary render tests, missing some SDL functions to work properly.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
334
dafd796f0c95 * Added preliminary render tests, missing some SDL functions to work properly.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
335 /* Clear surface. */
dafd796f0c95 * Added preliminary render tests, missing some SDL functions to work properly.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
336 ret = SDL_FillRect( testsur, NULL,
dafd796f0c95 * Added preliminary render tests, missing some SDL functions to work properly.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
337 SDL_MapRGB( testsur->format, 0, 0, 0 ) );
dafd796f0c95 * Added preliminary render tests, missing some SDL functions to work properly.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
338 if (SDL_ATassert( "SDL_FillRect", ret == 0))
dafd796f0c95 * Added preliminary render tests, missing some SDL functions to work properly.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
339 return;
dafd796f0c95 * Added preliminary render tests, missing some SDL functions to work properly.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
340
dafd796f0c95 * Added preliminary render tests, missing some SDL functions to work properly.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
341 /* Restore colour. */
dafd796f0c95 * Added preliminary render tests, missing some SDL functions to work properly.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
342 ret = SDL_SetSurfaceColorMod( face, 255, 255, 255 );
dafd796f0c95 * Added preliminary render tests, missing some SDL functions to work properly.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
343 if (SDL_ATassert( "SDL_SetSurfaceColorMod", ret == 0))
dafd796f0c95 * Added preliminary render tests, missing some SDL functions to work properly.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
344 return;
dafd796f0c95 * Added preliminary render tests, missing some SDL functions to work properly.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
345
dafd796f0c95 * Added preliminary render tests, missing some SDL functions to work properly.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
346 /* Test blitting with colour mod. */
dafd796f0c95 * Added preliminary render tests, missing some SDL functions to work properly.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
347 for (j=0; j <= nj; j+=4) {
dafd796f0c95 * Added preliminary render tests, missing some SDL functions to work properly.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
348 for (i=0; i <= ni; i+=4) {
dafd796f0c95 * Added preliminary render tests, missing some SDL functions to work properly.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
349 /* Set alpha mod. */
dafd796f0c95 * Added preliminary render tests, missing some SDL functions to work properly.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
350 ret = SDL_SetSurfaceAlphaMod( face, (255/ni)*i );
dafd796f0c95 * Added preliminary render tests, missing some SDL functions to work properly.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
351 if (SDL_ATassert( "SDL_SetSurfaceAlphaMod", ret == 0))
dafd796f0c95 * Added preliminary render tests, missing some SDL functions to work properly.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
352 return;
dafd796f0c95 * Added preliminary render tests, missing some SDL functions to work properly.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
353
dafd796f0c95 * Added preliminary render tests, missing some SDL functions to work properly.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
354 /* Blitting. */
dafd796f0c95 * Added preliminary render tests, missing some SDL functions to work properly.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
355 rect.x = i;
dafd796f0c95 * Added preliminary render tests, missing some SDL functions to work properly.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
356 rect.y = j;
dafd796f0c95 * Added preliminary render tests, missing some SDL functions to work properly.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
357 ret = SDL_BlitSurface( face, NULL, testsur, &rect );
dafd796f0c95 * Added preliminary render tests, missing some SDL functions to work properly.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
358 if (SDL_ATassert( "SDL_BlitSurface", ret == 0))
dafd796f0c95 * Added preliminary render tests, missing some SDL functions to work properly.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
359 return;
dafd796f0c95 * Added preliminary render tests, missing some SDL functions to work properly.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
360 }
dafd796f0c95 * Added preliminary render tests, missing some SDL functions to work properly.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
361 }
dafd796f0c95 * Added preliminary render tests, missing some SDL functions to work properly.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
362
dafd796f0c95 * Added preliminary render tests, missing some SDL functions to work properly.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
363 /* See if it's the same. */
dafd796f0c95 * Added preliminary render tests, missing some SDL functions to work properly.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
364 if (SDL_ATassert( "Blitting output not the same (using SDL_SetSurfaceAlphaMod).",
dafd796f0c95 * Added preliminary render tests, missing some SDL functions to work properly.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
365 render_compare( testsur, &img_blitAlpha )==0 ))
dafd796f0c95 * Added preliminary render tests, missing some SDL functions to work properly.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
366 return;
dafd796f0c95 * Added preliminary render tests, missing some SDL functions to work properly.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
367
dafd796f0c95 * Added preliminary render tests, missing some SDL functions to work properly.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
368 /* Clean up. */
dafd796f0c95 * Added preliminary render tests, missing some SDL functions to work properly.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
369 SDL_FreeSurface( face );
dafd796f0c95 * Added preliminary render tests, missing some SDL functions to work properly.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
370
dafd796f0c95 * Added preliminary render tests, missing some SDL functions to work properly.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
371 SDL_ATend();
dafd796f0c95 * Added preliminary render tests, missing some SDL functions to work properly.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
372 }
dafd796f0c95 * Added preliminary render tests, missing some SDL functions to work properly.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
373
dafd796f0c95 * Added preliminary render tests, missing some SDL functions to work properly.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
374
dafd796f0c95 * Added preliminary render tests, missing some SDL functions to work properly.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
375 /**
dafd796f0c95 * Added preliminary render tests, missing some SDL functions to work properly.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
376 * @brief Tests a blend mode.
dafd796f0c95 * Added preliminary render tests, missing some SDL functions to work properly.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
377 */
dafd796f0c95 * Added preliminary render tests, missing some SDL functions to work properly.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
378 static int render_testBlitBlendMode( SDL_Surface *face, int mode )
dafd796f0c95 * Added preliminary render tests, missing some SDL functions to work properly.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
379 {
dafd796f0c95 * Added preliminary render tests, missing some SDL functions to work properly.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
380 int ret;
dafd796f0c95 * Added preliminary render tests, missing some SDL functions to work properly.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
381 int i, j, ni, nj;
dafd796f0c95 * Added preliminary render tests, missing some SDL functions to work properly.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
382 SDL_Rect rect;
dafd796f0c95 * Added preliminary render tests, missing some SDL functions to work properly.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
383
dafd796f0c95 * Added preliminary render tests, missing some SDL functions to work properly.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
384 /* Clear surface. */
dafd796f0c95 * Added preliminary render tests, missing some SDL functions to work properly.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
385 ret = SDL_FillRect( testsur, NULL,
dafd796f0c95 * Added preliminary render tests, missing some SDL functions to work properly.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
386 SDL_MapRGB( testsur->format, 0, 0, 0 ) );
dafd796f0c95 * Added preliminary render tests, missing some SDL functions to work properly.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
387 if (SDL_ATassert( "SDL_FillRect", ret == 0))
dafd796f0c95 * Added preliminary render tests, missing some SDL functions to work properly.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
388 return 1;
dafd796f0c95 * Added preliminary render tests, missing some SDL functions to work properly.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
389
dafd796f0c95 * Added preliminary render tests, missing some SDL functions to work properly.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
390 /* Steps to take. */
dafd796f0c95 * Added preliminary render tests, missing some SDL functions to work properly.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
391 ni = testsur->w - face->w;
dafd796f0c95 * Added preliminary render tests, missing some SDL functions to work properly.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
392 nj = testsur->h - face->h;
dafd796f0c95 * Added preliminary render tests, missing some SDL functions to work properly.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
393
dafd796f0c95 * Added preliminary render tests, missing some SDL functions to work properly.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
394 /* Constant values. */
dafd796f0c95 * Added preliminary render tests, missing some SDL functions to work properly.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
395 rect.w = face->w;
dafd796f0c95 * Added preliminary render tests, missing some SDL functions to work properly.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
396 rect.h = face->h;
dafd796f0c95 * Added preliminary render tests, missing some SDL functions to work properly.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
397
dafd796f0c95 * Added preliminary render tests, missing some SDL functions to work properly.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
398 /* Test blend mode. */
dafd796f0c95 * Added preliminary render tests, missing some SDL functions to work properly.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
399 for (j=0; j <= nj; j+=4) {
dafd796f0c95 * Added preliminary render tests, missing some SDL functions to work properly.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
400 for (i=0; i <= ni; i+=4) {
dafd796f0c95 * Added preliminary render tests, missing some SDL functions to work properly.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
401 /* Set blend mode. */
dafd796f0c95 * Added preliminary render tests, missing some SDL functions to work properly.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
402 ret = SDL_SetSurfaceBlendMode( face, mode );
dafd796f0c95 * Added preliminary render tests, missing some SDL functions to work properly.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
403 if (SDL_ATassert( "SDL_SetSurfaceBlendMode", ret == 0))
dafd796f0c95 * Added preliminary render tests, missing some SDL functions to work properly.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
404 return 1;
dafd796f0c95 * Added preliminary render tests, missing some SDL functions to work properly.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
405
dafd796f0c95 * Added preliminary render tests, missing some SDL functions to work properly.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
406 /* Blitting. */
dafd796f0c95 * Added preliminary render tests, missing some SDL functions to work properly.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
407 rect.x = i;
dafd796f0c95 * Added preliminary render tests, missing some SDL functions to work properly.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
408 rect.y = j;
dafd796f0c95 * Added preliminary render tests, missing some SDL functions to work properly.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
409 ret = SDL_BlitSurface( face, NULL, testsur, &rect );
dafd796f0c95 * Added preliminary render tests, missing some SDL functions to work properly.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
410 if (SDL_ATassert( "SDL_BlitSurface", ret == 0))
dafd796f0c95 * Added preliminary render tests, missing some SDL functions to work properly.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
411 return 1;
dafd796f0c95 * Added preliminary render tests, missing some SDL functions to work properly.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
412 }
dafd796f0c95 * Added preliminary render tests, missing some SDL functions to work properly.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
413 }
dafd796f0c95 * Added preliminary render tests, missing some SDL functions to work properly.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
414
dafd796f0c95 * Added preliminary render tests, missing some SDL functions to work properly.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
415 return 0;
dafd796f0c95 * Added preliminary render tests, missing some SDL functions to work properly.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
416 }
dafd796f0c95 * Added preliminary render tests, missing some SDL functions to work properly.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
417
dafd796f0c95 * Added preliminary render tests, missing some SDL functions to work properly.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
418
dafd796f0c95 * Added preliminary render tests, missing some SDL functions to work properly.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
419 /**
dafd796f0c95 * Added preliminary render tests, missing some SDL functions to work properly.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
420 * @brief Tests some more blitting routines.
dafd796f0c95 * Added preliminary render tests, missing some SDL functions to work properly.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
421 */
dafd796f0c95 * Added preliminary render tests, missing some SDL functions to work properly.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
422 static void render_testBlitBlend (void)
dafd796f0c95 * Added preliminary render tests, missing some SDL functions to work properly.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
423 {
dafd796f0c95 * Added preliminary render tests, missing some SDL functions to work properly.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
424 int ret;
dafd796f0c95 * Added preliminary render tests, missing some SDL functions to work properly.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
425 SDL_Rect rect;
dafd796f0c95 * Added preliminary render tests, missing some SDL functions to work properly.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
426 SDL_Surface *face;
dafd796f0c95 * Added preliminary render tests, missing some SDL functions to work properly.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
427 int i, j, ni, nj;
dafd796f0c95 * Added preliminary render tests, missing some SDL functions to work properly.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
428 int mode;
dafd796f0c95 * Added preliminary render tests, missing some SDL functions to work properly.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
429
dafd796f0c95 * Added preliminary render tests, missing some SDL functions to work properly.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
430 SDL_ATbegin( "Blit Blending Tests" );
dafd796f0c95 * Added preliminary render tests, missing some SDL functions to work properly.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
431
dafd796f0c95 * Added preliminary render tests, missing some SDL functions to work properly.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
432 /* Clear surface. */
dafd796f0c95 * Added preliminary render tests, missing some SDL functions to work properly.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
433 ret = SDL_FillRect( testsur, NULL,
dafd796f0c95 * Added preliminary render tests, missing some SDL functions to work properly.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
434 SDL_MapRGB( testsur->format, 0, 0, 0 ) );
dafd796f0c95 * Added preliminary render tests, missing some SDL functions to work properly.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
435 if (SDL_ATassert( "SDL_FillRect", ret == 0))
dafd796f0c95 * Added preliminary render tests, missing some SDL functions to work properly.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
436 return;
dafd796f0c95 * Added preliminary render tests, missing some SDL functions to work properly.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
437
dafd796f0c95 * Added preliminary render tests, missing some SDL functions to work properly.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
438 /* Create the blit surface. */
dafd796f0c95 * Added preliminary render tests, missing some SDL functions to work properly.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
439 face = SDL_CreateRGBSurfaceFrom( (void*)img_face.pixel_data,
dafd796f0c95 * Added preliminary render tests, missing some SDL functions to work properly.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
440 img_face.width, img_face.height, 32, img_face.width*4,
dafd796f0c95 * Added preliminary render tests, missing some SDL functions to work properly.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
441 RMASK, GMASK, BMASK, AMASK );
dafd796f0c95 * Added preliminary render tests, missing some SDL functions to work properly.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
442 if (SDL_ATassert( "SDL_CreateRGBSurfaceFrom", face != NULL))
dafd796f0c95 * Added preliminary render tests, missing some SDL functions to work properly.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
443 return;
dafd796f0c95 * Added preliminary render tests, missing some SDL functions to work properly.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
444
dafd796f0c95 * Added preliminary render tests, missing some SDL functions to work properly.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
445 /* Set alpha mod. */
dafd796f0c95 * Added preliminary render tests, missing some SDL functions to work properly.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
446 ret = SDL_SetSurfaceAlphaMod( face, 100 );
dafd796f0c95 * Added preliminary render tests, missing some SDL functions to work properly.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
447 if (SDL_ATassert( "SDL_SetSurfaceAlphaMod", ret == 0))
dafd796f0c95 * Added preliminary render tests, missing some SDL functions to work properly.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
448 return;
dafd796f0c95 * Added preliminary render tests, missing some SDL functions to work properly.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
449
dafd796f0c95 * Added preliminary render tests, missing some SDL functions to work properly.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
450 /* Steps to take. */
dafd796f0c95 * Added preliminary render tests, missing some SDL functions to work properly.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
451 ni = testsur->w - face->w;
dafd796f0c95 * Added preliminary render tests, missing some SDL functions to work properly.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
452 nj = testsur->h - face->h;
dafd796f0c95 * Added preliminary render tests, missing some SDL functions to work properly.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
453
dafd796f0c95 * Added preliminary render tests, missing some SDL functions to work properly.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
454 /* Constant values. */
dafd796f0c95 * Added preliminary render tests, missing some SDL functions to work properly.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
455 rect.w = face->w;
dafd796f0c95 * Added preliminary render tests, missing some SDL functions to work properly.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
456 rect.h = face->h;
dafd796f0c95 * Added preliminary render tests, missing some SDL functions to work properly.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
457
dafd796f0c95 * Added preliminary render tests, missing some SDL functions to work properly.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
458 /* Test None. */
dafd796f0c95 * Added preliminary render tests, missing some SDL functions to work properly.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
459 if (render_testBlitBlendMode( face, SDL_BLENDMODE_NONE ))
dafd796f0c95 * Added preliminary render tests, missing some SDL functions to work properly.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
460 return;
dafd796f0c95 * Added preliminary render tests, missing some SDL functions to work properly.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
461 if (SDL_ATassert( "Blitting blending output not the same (using SDL_BLENDMODE_NONE).",
dafd796f0c95 * Added preliminary render tests, missing some SDL functions to work properly.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
462 render_compare( testsur, &img_blendNone )==0 ))
dafd796f0c95 * Added preliminary render tests, missing some SDL functions to work properly.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
463 return;
dafd796f0c95 * Added preliminary render tests, missing some SDL functions to work properly.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
464
dafd796f0c95 * Added preliminary render tests, missing some SDL functions to work properly.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
465 /* Test Mask. */
dafd796f0c95 * Added preliminary render tests, missing some SDL functions to work properly.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
466 if (render_testBlitBlendMode( face, SDL_BLENDMODE_MASK ))
dafd796f0c95 * Added preliminary render tests, missing some SDL functions to work properly.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
467 return;
dafd796f0c95 * Added preliminary render tests, missing some SDL functions to work properly.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
468 if (SDL_ATassert( "Blitting blending output not the same (using SDL_BLENDMODE_MASK).",
dafd796f0c95 * Added preliminary render tests, missing some SDL functions to work properly.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
469 render_compare( testsur, &img_blendMask )==0 ))
dafd796f0c95 * Added preliminary render tests, missing some SDL functions to work properly.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
470 return;
dafd796f0c95 * Added preliminary render tests, missing some SDL functions to work properly.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
471
dafd796f0c95 * Added preliminary render tests, missing some SDL functions to work properly.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
472 /* Test Blend. */
dafd796f0c95 * Added preliminary render tests, missing some SDL functions to work properly.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
473 if (render_testBlitBlendMode( face, SDL_BLENDMODE_BLEND ))
dafd796f0c95 * Added preliminary render tests, missing some SDL functions to work properly.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
474 return;
dafd796f0c95 * Added preliminary render tests, missing some SDL functions to work properly.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
475 if (SDL_ATassert( "Blitting blending output not the same (using SDL_BLENDMODE_BLEND).",
dafd796f0c95 * Added preliminary render tests, missing some SDL functions to work properly.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
476 render_compare( testsur, &img_blendBlend )==0 ))
dafd796f0c95 * Added preliminary render tests, missing some SDL functions to work properly.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
477 return;
dafd796f0c95 * Added preliminary render tests, missing some SDL functions to work properly.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
478
dafd796f0c95 * Added preliminary render tests, missing some SDL functions to work properly.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
479 /* Test Add. */
dafd796f0c95 * Added preliminary render tests, missing some SDL functions to work properly.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
480 if (render_testBlitBlendMode( face, SDL_BLENDMODE_ADD ))
dafd796f0c95 * Added preliminary render tests, missing some SDL functions to work properly.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
481 return;
dafd796f0c95 * Added preliminary render tests, missing some SDL functions to work properly.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
482 if (SDL_ATassert( "Blitting blending output not the same (using SDL_BLENDMODE_ADD).",
dafd796f0c95 * Added preliminary render tests, missing some SDL functions to work properly.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
483 render_compare( testsur, &img_blendAdd )==0 ))
dafd796f0c95 * Added preliminary render tests, missing some SDL functions to work properly.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
484 return;
dafd796f0c95 * Added preliminary render tests, missing some SDL functions to work properly.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
485
dafd796f0c95 * Added preliminary render tests, missing some SDL functions to work properly.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
486 /* Test Mod. */
dafd796f0c95 * Added preliminary render tests, missing some SDL functions to work properly.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
487 if (render_testBlitBlendMode( face, SDL_BLENDMODE_MOD ))
dafd796f0c95 * Added preliminary render tests, missing some SDL functions to work properly.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
488 return;
dafd796f0c95 * Added preliminary render tests, missing some SDL functions to work properly.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
489 if (SDL_ATassert( "Blitting blending output not the same (using SDL_BLENDMODE_MOD).",
dafd796f0c95 * Added preliminary render tests, missing some SDL functions to work properly.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
490 render_compare( testsur, &img_blendMod )==0 ))
dafd796f0c95 * Added preliminary render tests, missing some SDL functions to work properly.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
491 return;
dafd796f0c95 * Added preliminary render tests, missing some SDL functions to work properly.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
492
dafd796f0c95 * Added preliminary render tests, missing some SDL functions to work properly.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
493 /* Clear surface. */
dafd796f0c95 * Added preliminary render tests, missing some SDL functions to work properly.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
494 ret = SDL_FillRect( testsur, NULL,
dafd796f0c95 * Added preliminary render tests, missing some SDL functions to work properly.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
495 SDL_MapRGB( testsur->format, 0, 0, 0 ) );
dafd796f0c95 * Added preliminary render tests, missing some SDL functions to work properly.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
496 if (SDL_ATassert( "SDL_FillRect", ret == 0))
dafd796f0c95 * Added preliminary render tests, missing some SDL functions to work properly.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
497 return;
dafd796f0c95 * Added preliminary render tests, missing some SDL functions to work properly.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
498
dafd796f0c95 * Added preliminary render tests, missing some SDL functions to work properly.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
499 /* Loop blit. */
dafd796f0c95 * Added preliminary render tests, missing some SDL functions to work properly.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
500 for (j=0; j <= nj; j+=4) {
dafd796f0c95 * Added preliminary render tests, missing some SDL functions to work properly.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
501 for (i=0; i <= ni; i+=4) {
dafd796f0c95 * Added preliminary render tests, missing some SDL functions to work properly.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
502
dafd796f0c95 * Added preliminary render tests, missing some SDL functions to work properly.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
503 /* Set colour mod. */
dafd796f0c95 * Added preliminary render tests, missing some SDL functions to work properly.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
504 ret = SDL_SetSurfaceColorMod( face, (255/nj)*j, (255/ni)*i, (255/nj)*j );
dafd796f0c95 * Added preliminary render tests, missing some SDL functions to work properly.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
505 if (SDL_ATassert( "SDL_SetSurfaceColorMod", ret == 0))
dafd796f0c95 * Added preliminary render tests, missing some SDL functions to work properly.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
506 return;
dafd796f0c95 * Added preliminary render tests, missing some SDL functions to work properly.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
507
dafd796f0c95 * Added preliminary render tests, missing some SDL functions to work properly.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
508 /* Set alpha mod. */
dafd796f0c95 * Added preliminary render tests, missing some SDL functions to work properly.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
509 ret = SDL_SetSurfaceAlphaMod( face, (100/ni)*i );
dafd796f0c95 * Added preliminary render tests, missing some SDL functions to work properly.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
510 if (SDL_ATassert( "SDL_SetSurfaceAlphaMod", ret == 0))
dafd796f0c95 * Added preliminary render tests, missing some SDL functions to work properly.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
511 return;
dafd796f0c95 * Added preliminary render tests, missing some SDL functions to work properly.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
512
dafd796f0c95 * Added preliminary render tests, missing some SDL functions to work properly.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
513 /* Crazy blending mode magic. */
dafd796f0c95 * Added preliminary render tests, missing some SDL functions to work properly.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
514 mode = (i/4*j/4) % 4;
dafd796f0c95 * Added preliminary render tests, missing some SDL functions to work properly.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
515 if (mode==0) mode = SDL_BLENDMODE_MASK;
dafd796f0c95 * Added preliminary render tests, missing some SDL functions to work properly.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
516 else if (mode==1) mode = SDL_BLENDMODE_BLEND;
dafd796f0c95 * Added preliminary render tests, missing some SDL functions to work properly.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
517 else if (mode==2) mode = SDL_BLENDMODE_ADD;
dafd796f0c95 * Added preliminary render tests, missing some SDL functions to work properly.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
518 else if (mode==3) mode = SDL_BLENDMODE_MOD;
dafd796f0c95 * Added preliminary render tests, missing some SDL functions to work properly.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
519 ret = SDL_SetSurfaceBlendMode( face, mode );
dafd796f0c95 * Added preliminary render tests, missing some SDL functions to work properly.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
520 if (SDL_ATassert( "SDL_SetSurfaceBlendMode", ret == 0))
dafd796f0c95 * Added preliminary render tests, missing some SDL functions to work properly.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
521 return;
dafd796f0c95 * Added preliminary render tests, missing some SDL functions to work properly.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
522
dafd796f0c95 * Added preliminary render tests, missing some SDL functions to work properly.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
523 /* Blitting. */
dafd796f0c95 * Added preliminary render tests, missing some SDL functions to work properly.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
524 rect.x = i;
dafd796f0c95 * Added preliminary render tests, missing some SDL functions to work properly.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
525 rect.y = j;
dafd796f0c95 * Added preliminary render tests, missing some SDL functions to work properly.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
526 ret = SDL_BlitSurface( face, NULL, testsur, &rect );
dafd796f0c95 * Added preliminary render tests, missing some SDL functions to work properly.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
527 if (SDL_ATassert( "SDL_BlitSurface", ret == 0))
dafd796f0c95 * Added preliminary render tests, missing some SDL functions to work properly.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
528 return;
dafd796f0c95 * Added preliminary render tests, missing some SDL functions to work properly.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
529 }
dafd796f0c95 * Added preliminary render tests, missing some SDL functions to work properly.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
530 }
dafd796f0c95 * Added preliminary render tests, missing some SDL functions to work properly.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
531
dafd796f0c95 * Added preliminary render tests, missing some SDL functions to work properly.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
532 /* Check to see if matches. */
dafd796f0c95 * Added preliminary render tests, missing some SDL functions to work properly.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
533 if (SDL_ATassert( "Blitting blending output not the same (using SDL_BLEND_*).",
dafd796f0c95 * Added preliminary render tests, missing some SDL functions to work properly.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
534 render_compare( testsur, &img_blendAll )==0 ))
dafd796f0c95 * Added preliminary render tests, missing some SDL functions to work properly.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
535 return;
dafd796f0c95 * Added preliminary render tests, missing some SDL functions to work properly.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
536
dafd796f0c95 * Added preliminary render tests, missing some SDL functions to work properly.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
537 /* Clean up. */
dafd796f0c95 * Added preliminary render tests, missing some SDL functions to work properly.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
538 SDL_FreeSurface( face );
dafd796f0c95 * Added preliminary render tests, missing some SDL functions to work properly.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
539
dafd796f0c95 * Added preliminary render tests, missing some SDL functions to work properly.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
540 SDL_ATend();
dafd796f0c95 * Added preliminary render tests, missing some SDL functions to work properly.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
541 }
dafd796f0c95 * Added preliminary render tests, missing some SDL functions to work properly.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
542 #endif
dafd796f0c95 * Added preliminary render tests, missing some SDL functions to work properly.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
543
dafd796f0c95 * Added preliminary render tests, missing some SDL functions to work properly.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
544
dafd796f0c95 * Added preliminary render tests, missing some SDL functions to work properly.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
545 /**
dafd796f0c95 * Added preliminary render tests, missing some SDL functions to work properly.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
546 * @brief Runs all the tests on the surface.
dafd796f0c95 * Added preliminary render tests, missing some SDL functions to work properly.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
547 *
dafd796f0c95 * Added preliminary render tests, missing some SDL functions to work properly.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
548 * @param testsur Surface to run tests on.
dafd796f0c95 * Added preliminary render tests, missing some SDL functions to work properly.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
549 */
dafd796f0c95 * Added preliminary render tests, missing some SDL functions to work properly.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
550 void render_runTests (void)
dafd796f0c95 * Added preliminary render tests, missing some SDL functions to work properly.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
551 {
dafd796f0c95 * Added preliminary render tests, missing some SDL functions to work properly.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
552 /* Software surface blitting. */
dafd796f0c95 * Added preliminary render tests, missing some SDL functions to work properly.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
553 render_testPrimitives();
dafd796f0c95 * Added preliminary render tests, missing some SDL functions to work properly.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
554 /*
dafd796f0c95 * Added preliminary render tests, missing some SDL functions to work properly.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
555 render_testPrimitivesBlend();
dafd796f0c95 * Added preliminary render tests, missing some SDL functions to work properly.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
556 render_testBlit();
dafd796f0c95 * Added preliminary render tests, missing some SDL functions to work properly.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
557 render_testBlitBlend();
dafd796f0c95 * Added preliminary render tests, missing some SDL functions to work properly.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
558 */
dafd796f0c95 * Added preliminary render tests, missing some SDL functions to work properly.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
559 }
dafd796f0c95 * Added preliminary render tests, missing some SDL functions to work properly.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
560
dafd796f0c95 * Added preliminary render tests, missing some SDL functions to work properly.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
561
dafd796f0c95 * Added preliminary render tests, missing some SDL functions to work properly.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
562 /**
dafd796f0c95 * Added preliminary render tests, missing some SDL functions to work properly.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
563 * @brief Entry point.
dafd796f0c95 * Added preliminary render tests, missing some SDL functions to work properly.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
564 *
dafd796f0c95 * Added preliminary render tests, missing some SDL functions to work properly.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
565 * This testsuite is tricky, we're creating a testsuite per driver, the thing
dafd796f0c95 * Added preliminary render tests, missing some SDL functions to work properly.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
566 * is we do quite a of stuff outside of the actual testcase which *could*
dafd796f0c95 * Added preliminary render tests, missing some SDL functions to work properly.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
567 * give issues. Don't like that very much, but no way around without creating
dafd796f0c95 * Added preliminary render tests, missing some SDL functions to work properly.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
568 * superfluous testsuites.
dafd796f0c95 * Added preliminary render tests, missing some SDL functions to work properly.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
569 */
dafd796f0c95 * Added preliminary render tests, missing some SDL functions to work properly.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
570 int main( int argc, const char *argv[] )
dafd796f0c95 * Added preliminary render tests, missing some SDL functions to work properly.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
571 {
dafd796f0c95 * Added preliminary render tests, missing some SDL functions to work properly.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
572 (void) argc;
dafd796f0c95 * Added preliminary render tests, missing some SDL functions to work properly.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
573 (void) argv;
dafd796f0c95 * Added preliminary render tests, missing some SDL functions to work properly.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
574 int i, j, nd, nr;
dafd796f0c95 * Added preliminary render tests, missing some SDL functions to work properly.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
575 int ret;
dafd796f0c95 * Added preliminary render tests, missing some SDL functions to work properly.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
576 const char *driver, *str;
dafd796f0c95 * Added preliminary render tests, missing some SDL functions to work properly.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
577 char msg[256];
dafd796f0c95 * Added preliminary render tests, missing some SDL functions to work properly.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
578 SDL_WindowID wid;
dafd796f0c95 * Added preliminary render tests, missing some SDL functions to work properly.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
579 SDL_RendererInfo renderer;
dafd796f0c95 * Added preliminary render tests, missing some SDL functions to work properly.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
580
dafd796f0c95 * Added preliminary render tests, missing some SDL functions to work properly.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
581 /* Initializes the SDL subsystems. */
dafd796f0c95 * Added preliminary render tests, missing some SDL functions to work properly.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
582 ret = SDL_Init(0);
dafd796f0c95 * Added preliminary render tests, missing some SDL functions to work properly.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
583 if (ret != 0)
dafd796f0c95 * Added preliminary render tests, missing some SDL functions to work properly.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
584 return -1;
dafd796f0c95 * Added preliminary render tests, missing some SDL functions to work properly.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
585
dafd796f0c95 * Added preliminary render tests, missing some SDL functions to work properly.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
586 /* Get number of drivers. */
dafd796f0c95 * Added preliminary render tests, missing some SDL functions to work properly.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
587 nd = SDL_GetNumVideoDrivers();
dafd796f0c95 * Added preliminary render tests, missing some SDL functions to work properly.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
588 if (ret < 0)
dafd796f0c95 * Added preliminary render tests, missing some SDL functions to work properly.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
589 goto err;
dafd796f0c95 * Added preliminary render tests, missing some SDL functions to work properly.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
590
dafd796f0c95 * Added preliminary render tests, missing some SDL functions to work properly.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
591 /* Now run on the video mode. */
dafd796f0c95 * Added preliminary render tests, missing some SDL functions to work properly.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
592 ret = SDL_InitSubSystem( SDL_INIT_VIDEO );
dafd796f0c95 * Added preliminary render tests, missing some SDL functions to work properly.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
593 if (ret != 0)
dafd796f0c95 * Added preliminary render tests, missing some SDL functions to work properly.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
594 goto err;
dafd796f0c95 * Added preliminary render tests, missing some SDL functions to work properly.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
595
dafd796f0c95 * Added preliminary render tests, missing some SDL functions to work properly.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
596 /*
dafd796f0c95 * Added preliminary render tests, missing some SDL functions to work properly.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
597 * Surface on video mode tests.
dafd796f0c95 * Added preliminary render tests, missing some SDL functions to work properly.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
598 */
dafd796f0c95 * Added preliminary render tests, missing some SDL functions to work properly.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
599 /* Run for all video modes. */
dafd796f0c95 * Added preliminary render tests, missing some SDL functions to work properly.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
600 for (i=0; i<nd; i++) {
dafd796f0c95 * Added preliminary render tests, missing some SDL functions to work properly.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
601 /* Get video mode. */
dafd796f0c95 * Added preliminary render tests, missing some SDL functions to work properly.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
602 driver = SDL_GetVideoDriver(i);
dafd796f0c95 * Added preliminary render tests, missing some SDL functions to work properly.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
603 if (driver == NULL)
dafd796f0c95 * Added preliminary render tests, missing some SDL functions to work properly.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
604 goto err;
dafd796f0c95 * Added preliminary render tests, missing some SDL functions to work properly.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
605 /* Hack to avoid dummy driver. */
dafd796f0c95 * Added preliminary render tests, missing some SDL functions to work properly.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
606 if (strcmp(driver,"dummy")==0)
dafd796f0c95 * Added preliminary render tests, missing some SDL functions to work properly.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
607 continue;
dafd796f0c95 * Added preliminary render tests, missing some SDL functions to work properly.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
608
dafd796f0c95 * Added preliminary render tests, missing some SDL functions to work properly.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
609 /*
dafd796f0c95 * Added preliminary render tests, missing some SDL functions to work properly.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
610 * Initialize testsuite.
dafd796f0c95 * Added preliminary render tests, missing some SDL functions to work properly.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
611 */
dafd796f0c95 * Added preliminary render tests, missing some SDL functions to work properly.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
612 snprintf( msg, sizeof(msg) , "Rendering with %s driver", driver );
dafd796f0c95 * Added preliminary render tests, missing some SDL functions to work properly.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
613 SDL_ATinit( msg );
dafd796f0c95 * Added preliminary render tests, missing some SDL functions to work properly.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
614
dafd796f0c95 * Added preliminary render tests, missing some SDL functions to work properly.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
615 /*
dafd796f0c95 * Added preliminary render tests, missing some SDL functions to work properly.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
616 * Initialize.
dafd796f0c95 * Added preliminary render tests, missing some SDL functions to work properly.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
617 */
dafd796f0c95 * Added preliminary render tests, missing some SDL functions to work properly.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
618 SDL_ATbegin( "Initializing video mode" );
dafd796f0c95 * Added preliminary render tests, missing some SDL functions to work properly.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
619 /* Initialize video mode. */
dafd796f0c95 * Added preliminary render tests, missing some SDL functions to work properly.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
620 ret = SDL_VideoInit( driver, 0 );
dafd796f0c95 * Added preliminary render tests, missing some SDL functions to work properly.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
621 if (SDL_ATvassert( ret==0, "SDL_VideoInit( %s, 0 )", driver ))
dafd796f0c95 * Added preliminary render tests, missing some SDL functions to work properly.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
622 goto err;
dafd796f0c95 * Added preliminary render tests, missing some SDL functions to work properly.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
623 /* Check to see if it's the one we want. */
dafd796f0c95 * Added preliminary render tests, missing some SDL functions to work properly.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
624 str = SDL_GetCurrentVideoDriver();
dafd796f0c95 * Added preliminary render tests, missing some SDL functions to work properly.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
625 if (SDL_ATassert( "SDL_GetCurrentVideoDriver", strcmp(driver,str)==0))
dafd796f0c95 * Added preliminary render tests, missing some SDL functions to work properly.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
626 goto err;
dafd796f0c95 * Added preliminary render tests, missing some SDL functions to work properly.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
627 /* Create window. */
dafd796f0c95 * Added preliminary render tests, missing some SDL functions to work properly.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
628 wid = SDL_CreateWindow( msg, SDL_WINDOWPOS_CENTERED, SDL_WINDOWPOS_CENTERED,
dafd796f0c95 * Added preliminary render tests, missing some SDL functions to work properly.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
629 80, 60, 0 );
dafd796f0c95 * Added preliminary render tests, missing some SDL functions to work properly.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
630 if (SDL_ATassert( "SDL_CreateWindow", wid!=0 ))
dafd796f0c95 * Added preliminary render tests, missing some SDL functions to work properly.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
631 goto err;
dafd796f0c95 * Added preliminary render tests, missing some SDL functions to work properly.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
632 /* Check title. */
dafd796f0c95 * Added preliminary render tests, missing some SDL functions to work properly.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
633 str = SDL_GetWindowTitle( wid );
dafd796f0c95 * Added preliminary render tests, missing some SDL functions to work properly.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
634 if (SDL_ATassert( "SDL_GetWindowTitle", strcmp(msg,str)==0))
dafd796f0c95 * Added preliminary render tests, missing some SDL functions to work properly.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
635 goto err;
dafd796f0c95 * Added preliminary render tests, missing some SDL functions to work properly.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
636 /* Get renderers. */
dafd796f0c95 * Added preliminary render tests, missing some SDL functions to work properly.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
637 nr = SDL_GetNumRenderDrivers();
dafd796f0c95 * Added preliminary render tests, missing some SDL functions to work properly.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
638 if (SDL_ATassert("SDL_GetNumRenderDrivers", nr>=0))
dafd796f0c95 * Added preliminary render tests, missing some SDL functions to work properly.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
639 goto err;
dafd796f0c95 * Added preliminary render tests, missing some SDL functions to work properly.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
640 SDL_ATend();
dafd796f0c95 * Added preliminary render tests, missing some SDL functions to work properly.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
641 for (j=0; j<nr; j++) {
dafd796f0c95 * Added preliminary render tests, missing some SDL functions to work properly.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
642
dafd796f0c95 * Added preliminary render tests, missing some SDL functions to work properly.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
643 /* Get renderer info. */
dafd796f0c95 * Added preliminary render tests, missing some SDL functions to work properly.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
644 ret = SDL_GetRenderDriverInfo( j, &renderer );
dafd796f0c95 * Added preliminary render tests, missing some SDL functions to work properly.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
645 if (ret != 0)
dafd796f0c95 * Added preliminary render tests, missing some SDL functions to work properly.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
646 goto err;
dafd796f0c95 * Added preliminary render tests, missing some SDL functions to work properly.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
647 /* Set testcase name. */
dafd796f0c95 * Added preliminary render tests, missing some SDL functions to work properly.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
648 snprintf( msg, sizeof(msg), "Renderer %s", renderer.name );
dafd796f0c95 * Added preliminary render tests, missing some SDL functions to work properly.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
649 SDL_ATbegin( msg );
dafd796f0c95 * Added preliminary render tests, missing some SDL functions to work properly.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
650 /* Set renderer. */
dafd796f0c95 * Added preliminary render tests, missing some SDL functions to work properly.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
651 ret = SDL_CreateRenderer( wid, j, 0 );
dafd796f0c95 * Added preliminary render tests, missing some SDL functions to work properly.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
652 if (SDL_ATassert( "SDL_CreateRenderer", ret==0 ))
dafd796f0c95 * Added preliminary render tests, missing some SDL functions to work properly.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
653 goto err;
dafd796f0c95 * Added preliminary render tests, missing some SDL functions to work properly.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
654
dafd796f0c95 * Added preliminary render tests, missing some SDL functions to work properly.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
655 /*
dafd796f0c95 * Added preliminary render tests, missing some SDL functions to work properly.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
656 * Run tests.
dafd796f0c95 * Added preliminary render tests, missing some SDL functions to work properly.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
657 */
dafd796f0c95 * Added preliminary render tests, missing some SDL functions to work properly.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
658 render_runTests();
dafd796f0c95 * Added preliminary render tests, missing some SDL functions to work properly.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
659
dafd796f0c95 * Added preliminary render tests, missing some SDL functions to work properly.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
660 SDL_ATend();
dafd796f0c95 * Added preliminary render tests, missing some SDL functions to work properly.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
661 }
dafd796f0c95 * Added preliminary render tests, missing some SDL functions to work properly.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
662
dafd796f0c95 * Added preliminary render tests, missing some SDL functions to work properly.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
663 /* Exit the current renderer. */
dafd796f0c95 * Added preliminary render tests, missing some SDL functions to work properly.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
664 SDL_VideoQuit();
dafd796f0c95 * Added preliminary render tests, missing some SDL functions to work properly.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
665
dafd796f0c95 * Added preliminary render tests, missing some SDL functions to work properly.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
666 /*
dafd796f0c95 * Added preliminary render tests, missing some SDL functions to work properly.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
667 * Finish testsuite.
dafd796f0c95 * Added preliminary render tests, missing some SDL functions to work properly.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
668 */
dafd796f0c95 * Added preliminary render tests, missing some SDL functions to work properly.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
669 SDL_ATfinish(1);
dafd796f0c95 * Added preliminary render tests, missing some SDL functions to work properly.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
670 }
dafd796f0c95 * Added preliminary render tests, missing some SDL functions to work properly.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
671
dafd796f0c95 * Added preliminary render tests, missing some SDL functions to work properly.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
672
dafd796f0c95 * Added preliminary render tests, missing some SDL functions to work properly.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
673 /* Exit SDL. */
dafd796f0c95 * Added preliminary render tests, missing some SDL functions to work properly.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
674 SDL_Quit();
dafd796f0c95 * Added preliminary render tests, missing some SDL functions to work properly.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
675
dafd796f0c95 * Added preliminary render tests, missing some SDL functions to work properly.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
676 return 0;
dafd796f0c95 * Added preliminary render tests, missing some SDL functions to work properly.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
677
dafd796f0c95 * Added preliminary render tests, missing some SDL functions to work properly.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
678 err:
dafd796f0c95 * Added preliminary render tests, missing some SDL functions to work properly.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
679 return -1;
dafd796f0c95 * Added preliminary render tests, missing some SDL functions to work properly.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
680 }
dafd796f0c95 * Added preliminary render tests, missing some SDL functions to work properly.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
681