annotate test/automated/render/render.c @ 3731:f5ddf1b670f0 gsoc2009_unit_tests

Converted another testcase to the render system.
author Edgar Simo <bobbens@gmail.com>
date Wed, 15 Jul 2009 08:50:24 +0000
parents dafd796f0c95
children ca544951b504
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
3731
f5ddf1b670f0 Converted another testcase to the render system.
Edgar Simo <bobbens@gmail.com>
parents: 3730
diff changeset
22 #define SCREEN_W 80
f5ddf1b670f0 Converted another testcase to the render system.
Edgar Simo <bobbens@gmail.com>
parents: 3730
diff changeset
23 #define SCREEN_H 60
f5ddf1b670f0 Converted another testcase to the render system.
Edgar Simo <bobbens@gmail.com>
parents: 3730
diff changeset
24
f5ddf1b670f0 Converted another testcase to the render system.
Edgar Simo <bobbens@gmail.com>
parents: 3730
diff changeset
25
3730
dafd796f0c95 * Added preliminary render tests, missing some SDL functions to work properly.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
26 /*
dafd796f0c95 * Added preliminary render tests, missing some SDL functions to work properly.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
27 * Prototypes.
dafd796f0c95 * Added preliminary render tests, missing some SDL functions to work properly.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
28 */
dafd796f0c95 * Added preliminary render tests, missing some SDL functions to work properly.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
29 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
30 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
31 /* Testcases. */
dafd796f0c95 * Added preliminary render tests, missing some SDL functions to work properly.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
32 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
33 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
34 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
35 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
36 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
37
dafd796f0c95 * Added preliminary render tests, missing some SDL functions to work properly.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
38
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 * 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
41 */
dafd796f0c95 * Added preliminary render tests, missing some SDL functions to work properly.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
42 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
43 {
dafd796f0c95 * Added preliminary render tests, missing some SDL functions to work properly.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
44 int ret;
dafd796f0c95 * Added preliminary render tests, missing some SDL functions to work properly.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
45 void *pix;
dafd796f0c95 * Added preliminary render tests, missing some SDL functions to work properly.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
46 SDL_Surface *testsur;
dafd796f0c95 * Added preliminary render tests, missing some SDL functions to work properly.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
47
dafd796f0c95 * Added preliminary render tests, missing some SDL functions to work properly.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
48 #if 0
dafd796f0c95 * Added preliminary render tests, missing some SDL functions to work properly.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
49
dafd796f0c95 * Added preliminary render tests, missing some SDL functions to work properly.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
50 /* Allocate pixel space. */
dafd796f0c95 * Added preliminary render tests, missing some SDL functions to work properly.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
51 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
52 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
53 return 1;
dafd796f0c95 * Added preliminary render tests, missing some SDL functions to work properly.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
54
dafd796f0c95 * Added preliminary render tests, missing some SDL functions to work properly.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
55 /* Read pixels. */
dafd796f0c95 * Added preliminary render tests, missing some SDL functions to work properly.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
56 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
57 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
58 return 1;
dafd796f0c95 * Added preliminary render tests, missing some SDL functions to work properly.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
59
dafd796f0c95 * Added preliminary render tests, missing some SDL functions to work properly.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
60 /* Create surface. */
dafd796f0c95 * Added preliminary render tests, missing some SDL functions to work properly.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
61 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
62 RMASK, GMASK, BMASK, AMASK );
dafd796f0c95 * Added preliminary render tests, missing some SDL functions to work properly.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
63 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
64 return 1;
dafd796f0c95 * Added preliminary render tests, missing some SDL functions to work properly.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
65
dafd796f0c95 * Added preliminary render tests, missing some SDL functions to work properly.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
66 /* Compare surface. */
dafd796f0c95 * Added preliminary render tests, missing some SDL functions to work properly.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
67 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
68 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
69 return 1;
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 /* Clean up. */
dafd796f0c95 * Added preliminary render tests, missing some SDL functions to work properly.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
72 SDL_FreeSurface( testsur );
dafd796f0c95 * Added preliminary render tests, missing some SDL functions to work properly.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
73 free(pix);
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 #endif
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 return 0;
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
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 * @brief Clears the screen.
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 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
84 {
dafd796f0c95 * Added preliminary render tests, missing some SDL functions to work properly.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
85 int ret;
dafd796f0c95 * Added preliminary render tests, missing some SDL functions to work properly.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
86
dafd796f0c95 * Added preliminary render tests, missing some SDL functions to work properly.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
87 /* Set colour. */
dafd796f0c95 * Added preliminary render tests, missing some SDL functions to work properly.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
88 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
89 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
90 return -1;
dafd796f0c95 * Added preliminary render tests, missing some SDL functions to work properly.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
91
dafd796f0c95 * Added preliminary render tests, missing some SDL functions to work properly.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
92 /* Clear screen. */
dafd796f0c95 * Added preliminary render tests, missing some SDL functions to work properly.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
93 ret = SDL_RenderFill( NULL );
dafd796f0c95 * Added preliminary render tests, missing some SDL functions to work properly.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
94 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
95 return -1;
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 return 0;
dafd796f0c95 * Added preliminary render tests, missing some SDL functions to work properly.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
98 }
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
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 * @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
103 */
dafd796f0c95 * Added preliminary render tests, missing some SDL functions to work properly.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
104 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
105 {
dafd796f0c95 * Added preliminary render tests, missing some SDL functions to work properly.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
106 int ret;
dafd796f0c95 * Added preliminary render tests, missing some SDL functions to work properly.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
107 int x, y;
dafd796f0c95 * Added preliminary render tests, missing some SDL functions to work properly.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
108 SDL_Rect rect;
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 /* Clear surface. */
dafd796f0c95 * Added preliminary render tests, missing some SDL functions to work properly.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
111 if (render_clearScreen())
dafd796f0c95 * Added preliminary render tests, missing some SDL functions to work properly.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
112 return;
dafd796f0c95 * Added preliminary render tests, missing some SDL functions to work properly.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
113
dafd796f0c95 * Added preliminary render tests, missing some SDL functions to work properly.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
114 /* Draw a rectangle. */
dafd796f0c95 * Added preliminary render tests, missing some SDL functions to work properly.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
115 rect.x = 40;
dafd796f0c95 * Added preliminary render tests, missing some SDL functions to work properly.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
116 rect.y = 0;
dafd796f0c95 * Added preliminary render tests, missing some SDL functions to work properly.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
117 rect.w = 40;
dafd796f0c95 * Added preliminary render tests, missing some SDL functions to work properly.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
118 rect.h = 80;
dafd796f0c95 * Added preliminary render tests, missing some SDL functions to work properly.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
119 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
120 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
121 return;
dafd796f0c95 * Added preliminary render tests, missing some SDL functions to work properly.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
122 ret = SDL_RenderFill( &rect );
dafd796f0c95 * Added preliminary render tests, missing some SDL functions to work properly.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
123 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
124 return;
dafd796f0c95 * Added preliminary render tests, missing some SDL functions to work properly.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
125
dafd796f0c95 * Added preliminary render tests, missing some SDL functions to work properly.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
126 /* Draw a rectangle. */
dafd796f0c95 * Added preliminary render tests, missing some SDL functions to work properly.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
127 rect.x = 10;
dafd796f0c95 * Added preliminary render tests, missing some SDL functions to work properly.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
128 rect.y = 10;
dafd796f0c95 * Added preliminary render tests, missing some SDL functions to work properly.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
129 rect.w = 60;
dafd796f0c95 * Added preliminary render tests, missing some SDL functions to work properly.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
130 rect.h = 40;
dafd796f0c95 * Added preliminary render tests, missing some SDL functions to work properly.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
131 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
132 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
133 return;
dafd796f0c95 * Added preliminary render tests, missing some SDL functions to work properly.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
134 ret = SDL_RenderFill( &rect );
dafd796f0c95 * Added preliminary render tests, missing some SDL functions to work properly.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
135 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
136 return;
dafd796f0c95 * Added preliminary render tests, missing some SDL functions to work properly.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
137
dafd796f0c95 * Added preliminary render tests, missing some SDL functions to work properly.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
138 /* 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
139 * X.X.X.X..
dafd796f0c95 * Added preliminary render tests, missing some SDL functions to work properly.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
140 * .X.X.X.X.
dafd796f0c95 * Added preliminary render tests, missing some SDL functions to work properly.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
141 * X.X.X.X.. */
dafd796f0c95 * Added preliminary render tests, missing some SDL functions to work properly.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
142 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
143 x = y % 2;
dafd796f0c95 * Added preliminary render tests, missing some SDL functions to work properly.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
144 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
145 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
146 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
147 return;
dafd796f0c95 * Added preliminary render tests, missing some SDL functions to work properly.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
148 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
149 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
150 return;
dafd796f0c95 * Added preliminary render tests, missing some SDL functions to work properly.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
151 }
dafd796f0c95 * Added preliminary render tests, missing some SDL functions to work properly.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
152 }
dafd796f0c95 * Added preliminary render tests, missing some SDL functions to work properly.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
153
dafd796f0c95 * Added preliminary render tests, missing some SDL functions to work properly.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
154 /* Draw some lines. */
dafd796f0c95 * Added preliminary render tests, missing some SDL functions to work properly.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
155 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
156 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
157 return;
dafd796f0c95 * Added preliminary render tests, missing some SDL functions to work properly.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
158 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
159 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
160 return;
dafd796f0c95 * Added preliminary render tests, missing some SDL functions to work properly.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
161 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
162 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
163 return;
dafd796f0c95 * Added preliminary render tests, missing some SDL functions to work properly.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
164 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
165 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
166 return;
dafd796f0c95 * Added preliminary render tests, missing some SDL functions to work properly.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
167 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
168 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
169 return;
dafd796f0c95 * Added preliminary render tests, missing some SDL functions to work properly.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
170 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
171 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
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 /* 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
175 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
176 return;
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
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 /**
dafd796f0c95 * Added preliminary render tests, missing some SDL functions to work properly.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
181 * @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
182 */
dafd796f0c95 * Added preliminary render tests, missing some SDL functions to work properly.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
183 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
184 {
dafd796f0c95 * Added preliminary render tests, missing some SDL functions to work properly.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
185 int ret;
dafd796f0c95 * Added preliminary render tests, missing some SDL functions to work properly.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
186 int i, j;
dafd796f0c95 * Added preliminary render tests, missing some SDL functions to work properly.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
187 SDL_Rect rect;
dafd796f0c95 * Added preliminary render tests, missing some SDL functions to work properly.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
188
dafd796f0c95 * Added preliminary render tests, missing some SDL functions to work properly.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
189 /* Clear surface. */
3731
f5ddf1b670f0 Converted another testcase to the render system.
Edgar Simo <bobbens@gmail.com>
parents: 3730
diff changeset
190 if (render_clearScreen())
3730
dafd796f0c95 * Added preliminary render tests, missing some SDL functions to work properly.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
191 return;
dafd796f0c95 * Added preliminary render tests, missing some SDL functions to work properly.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
192
dafd796f0c95 * Added preliminary render tests, missing some SDL functions to work properly.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
193 /* Create some rectangles for each blend mode. */
3731
f5ddf1b670f0 Converted another testcase to the render system.
Edgar Simo <bobbens@gmail.com>
parents: 3730
diff changeset
194 ret = SDL_SetRenderDrawColor( 255, 255, 255, 0 );
f5ddf1b670f0 Converted another testcase to the render system.
Edgar Simo <bobbens@gmail.com>
parents: 3730
diff changeset
195 if (SDL_ATassert( "SDL_SetRenderDrawColor", ret == 0))
f5ddf1b670f0 Converted another testcase to the render system.
Edgar Simo <bobbens@gmail.com>
parents: 3730
diff changeset
196 return;
f5ddf1b670f0 Converted another testcase to the render system.
Edgar Simo <bobbens@gmail.com>
parents: 3730
diff changeset
197 ret = SDL_SetRenderDrawBlendMode( SDL_BLENDMODE_NONE );
f5ddf1b670f0 Converted another testcase to the render system.
Edgar Simo <bobbens@gmail.com>
parents: 3730
diff changeset
198 if (SDL_ATassert( "SDL_SetSurfaceBlendMode", ret == 0))
f5ddf1b670f0 Converted another testcase to the render system.
Edgar Simo <bobbens@gmail.com>
parents: 3730
diff changeset
199 return;
f5ddf1b670f0 Converted another testcase to the render system.
Edgar Simo <bobbens@gmail.com>
parents: 3730
diff changeset
200 ret = SDL_RenderFill( NULL );
f5ddf1b670f0 Converted another testcase to the render system.
Edgar Simo <bobbens@gmail.com>
parents: 3730
diff changeset
201 if (SDL_ATassert( "SDL_RenderFill", ret == 0))
3730
dafd796f0c95 * Added preliminary render tests, missing some SDL functions to work properly.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
202 return;
dafd796f0c95 * Added preliminary render tests, missing some SDL functions to work properly.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
203 rect.x = 10;
dafd796f0c95 * Added preliminary render tests, missing some SDL functions to work properly.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
204 rect.y = 25;
dafd796f0c95 * Added preliminary render tests, missing some SDL functions to work properly.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
205 rect.w = 40;
dafd796f0c95 * Added preliminary render tests, missing some SDL functions to work properly.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
206 rect.h = 25;
3731
f5ddf1b670f0 Converted another testcase to the render system.
Edgar Simo <bobbens@gmail.com>
parents: 3730
diff changeset
207 ret = SDL_SetRenderDrawColor( 240, 10, 10, 75 );
f5ddf1b670f0 Converted another testcase to the render system.
Edgar Simo <bobbens@gmail.com>
parents: 3730
diff changeset
208 if (SDL_ATassert( "SDL_SetRenderDrawColor", ret == 0))
f5ddf1b670f0 Converted another testcase to the render system.
Edgar Simo <bobbens@gmail.com>
parents: 3730
diff changeset
209 return;
f5ddf1b670f0 Converted another testcase to the render system.
Edgar Simo <bobbens@gmail.com>
parents: 3730
diff changeset
210 ret = SDL_SetRenderDrawBlendMode( SDL_BLENDMODE_ADD );
f5ddf1b670f0 Converted another testcase to the render system.
Edgar Simo <bobbens@gmail.com>
parents: 3730
diff changeset
211 if (SDL_ATassert( "SDL_SetSurfaceBlendMode", ret == 0))
f5ddf1b670f0 Converted another testcase to the render system.
Edgar Simo <bobbens@gmail.com>
parents: 3730
diff changeset
212 return;
f5ddf1b670f0 Converted another testcase to the render system.
Edgar Simo <bobbens@gmail.com>
parents: 3730
diff changeset
213 ret = SDL_RenderFill( &rect );
f5ddf1b670f0 Converted another testcase to the render system.
Edgar Simo <bobbens@gmail.com>
parents: 3730
diff changeset
214 if (SDL_ATassert( "SDL_RenderFill", ret == 0))
3730
dafd796f0c95 * Added preliminary render tests, missing some SDL functions to work properly.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
215 return;
dafd796f0c95 * Added preliminary render tests, missing some SDL functions to work properly.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
216 rect.x = 30;
dafd796f0c95 * Added preliminary render tests, missing some SDL functions to work properly.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
217 rect.y = 40;
dafd796f0c95 * Added preliminary render tests, missing some SDL functions to work properly.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
218 rect.w = 45;
dafd796f0c95 * Added preliminary render tests, missing some SDL functions to work properly.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
219 rect.h = 15;
3731
f5ddf1b670f0 Converted another testcase to the render system.
Edgar Simo <bobbens@gmail.com>
parents: 3730
diff changeset
220 ret = SDL_SetRenderDrawColor( 10, 240, 10, 100 );
f5ddf1b670f0 Converted another testcase to the render system.
Edgar Simo <bobbens@gmail.com>
parents: 3730
diff changeset
221 if (SDL_ATassert( "SDL_SetRenderDrawColor", ret == 0))
f5ddf1b670f0 Converted another testcase to the render system.
Edgar Simo <bobbens@gmail.com>
parents: 3730
diff changeset
222 return;
f5ddf1b670f0 Converted another testcase to the render system.
Edgar Simo <bobbens@gmail.com>
parents: 3730
diff changeset
223 ret = SDL_SetRenderDrawBlendMode( SDL_BLENDMODE_BLEND );
f5ddf1b670f0 Converted another testcase to the render system.
Edgar Simo <bobbens@gmail.com>
parents: 3730
diff changeset
224 if (SDL_ATassert( "SDL_SetSurfaceBlendMode", ret == 0))
f5ddf1b670f0 Converted another testcase to the render system.
Edgar Simo <bobbens@gmail.com>
parents: 3730
diff changeset
225 return;
f5ddf1b670f0 Converted another testcase to the render system.
Edgar Simo <bobbens@gmail.com>
parents: 3730
diff changeset
226 ret = SDL_RenderFill( &rect );
f5ddf1b670f0 Converted another testcase to the render system.
Edgar Simo <bobbens@gmail.com>
parents: 3730
diff changeset
227 if (SDL_ATassert( "SDL_RenderFill", ret == 0))
3730
dafd796f0c95 * Added preliminary render tests, missing some SDL functions to work properly.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
228 return;
dafd796f0c95 * Added preliminary render tests, missing some SDL functions to work properly.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
229 rect.x = 25;
dafd796f0c95 * Added preliminary render tests, missing some SDL functions to work properly.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
230 rect.y = 25;
dafd796f0c95 * Added preliminary render tests, missing some SDL functions to work properly.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
231 rect.w = 25;
dafd796f0c95 * Added preliminary render tests, missing some SDL functions to work properly.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
232 rect.h = 25;
3731
f5ddf1b670f0 Converted another testcase to the render system.
Edgar Simo <bobbens@gmail.com>
parents: 3730
diff changeset
233 ret = SDL_SetRenderDrawColor( 10, 10, 240, 125 );
f5ddf1b670f0 Converted another testcase to the render system.
Edgar Simo <bobbens@gmail.com>
parents: 3730
diff changeset
234 if (SDL_ATassert( "SDL_SetRenderDrawColor", ret == 0))
f5ddf1b670f0 Converted another testcase to the render system.
Edgar Simo <bobbens@gmail.com>
parents: 3730
diff changeset
235 return;
f5ddf1b670f0 Converted another testcase to the render system.
Edgar Simo <bobbens@gmail.com>
parents: 3730
diff changeset
236 ret = SDL_SetRenderDrawBlendMode( SDL_BLENDMODE_MOD );
f5ddf1b670f0 Converted another testcase to the render system.
Edgar Simo <bobbens@gmail.com>
parents: 3730
diff changeset
237 if (SDL_ATassert( "SDL_SetSurfaceBlendMode", ret == 0))
f5ddf1b670f0 Converted another testcase to the render system.
Edgar Simo <bobbens@gmail.com>
parents: 3730
diff changeset
238 return;
f5ddf1b670f0 Converted another testcase to the render system.
Edgar Simo <bobbens@gmail.com>
parents: 3730
diff changeset
239 ret = SDL_RenderFill( &rect );
f5ddf1b670f0 Converted another testcase to the render system.
Edgar Simo <bobbens@gmail.com>
parents: 3730
diff changeset
240 if (SDL_ATassert( "SDL_RenderFill", ret == 0))
3730
dafd796f0c95 * Added preliminary render tests, missing some SDL functions to work properly.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
241 return;
dafd796f0c95 * Added preliminary render tests, missing some SDL functions to work properly.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
242
dafd796f0c95 * Added preliminary render tests, missing some SDL functions to work properly.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
243 /* Draw blended lines, lines for everyone. */
3731
f5ddf1b670f0 Converted another testcase to the render system.
Edgar Simo <bobbens@gmail.com>
parents: 3730
diff changeset
244 for (i=0; i<SCREEN_W; i+=2) {
f5ddf1b670f0 Converted another testcase to the render system.
Edgar Simo <bobbens@gmail.com>
parents: 3730
diff changeset
245 ret = SDL_SetRenderDrawColor( 60+2*i, 240-2*i, 50, 3*i );
f5ddf1b670f0 Converted another testcase to the render system.
Edgar Simo <bobbens@gmail.com>
parents: 3730
diff changeset
246 if (SDL_ATassert( "SDL_SetRenderDrawColor", ret == 0))
f5ddf1b670f0 Converted another testcase to the render system.
Edgar Simo <bobbens@gmail.com>
parents: 3730
diff changeset
247 return;
f5ddf1b670f0 Converted another testcase to the render system.
Edgar Simo <bobbens@gmail.com>
parents: 3730
diff changeset
248 ret = SDL_SetRenderDrawBlendMode((((i/2)%3)==0) ? SDL_BLENDMODE_BLEND :
f5ddf1b670f0 Converted another testcase to the render system.
Edgar Simo <bobbens@gmail.com>
parents: 3730
diff changeset
249 (((i/2)%3)==1) ? SDL_BLENDMODE_ADD : SDL_BLENDMODE_MOD );
f5ddf1b670f0 Converted another testcase to the render system.
Edgar Simo <bobbens@gmail.com>
parents: 3730
diff changeset
250 if (SDL_ATassert( "SDL_SetSurfaceBlendMode", ret == 0))
f5ddf1b670f0 Converted another testcase to the render system.
Edgar Simo <bobbens@gmail.com>
parents: 3730
diff changeset
251 return;
f5ddf1b670f0 Converted another testcase to the render system.
Edgar Simo <bobbens@gmail.com>
parents: 3730
diff changeset
252 ret = SDL_RenderLine( 0, 0, i, 59 );
f5ddf1b670f0 Converted another testcase to the render system.
Edgar Simo <bobbens@gmail.com>
parents: 3730
diff changeset
253 if (SDL_ATassert( "SDL_RenderLine", ret == 0))
3730
dafd796f0c95 * Added preliminary render tests, missing some SDL functions to work properly.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
254 return;
dafd796f0c95 * Added preliminary render tests, missing some SDL functions to work properly.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
255 }
3731
f5ddf1b670f0 Converted another testcase to the render system.
Edgar Simo <bobbens@gmail.com>
parents: 3730
diff changeset
256 for (i=0; i<SCREEN_H; i+=2) {
f5ddf1b670f0 Converted another testcase to the render system.
Edgar Simo <bobbens@gmail.com>
parents: 3730
diff changeset
257 ret = SDL_SetRenderDrawColor( 60+2*i, 240-2*i, 50, 3*i );
f5ddf1b670f0 Converted another testcase to the render system.
Edgar Simo <bobbens@gmail.com>
parents: 3730
diff changeset
258 if (SDL_ATassert( "SDL_SetRenderDrawColor", ret == 0))
f5ddf1b670f0 Converted another testcase to the render system.
Edgar Simo <bobbens@gmail.com>
parents: 3730
diff changeset
259 return;
f5ddf1b670f0 Converted another testcase to the render system.
Edgar Simo <bobbens@gmail.com>
parents: 3730
diff changeset
260 ret = SDL_SetRenderDrawBlendMode((((i/2)%3)==0) ? SDL_BLENDMODE_BLEND :
f5ddf1b670f0 Converted another testcase to the render system.
Edgar Simo <bobbens@gmail.com>
parents: 3730
diff changeset
261 (((i/2)%3)==1) ? SDL_BLENDMODE_ADD : SDL_BLENDMODE_MOD );
f5ddf1b670f0 Converted another testcase to the render system.
Edgar Simo <bobbens@gmail.com>
parents: 3730
diff changeset
262 if (SDL_ATassert( "SDL_SetSurfaceBlendMode", ret == 0))
f5ddf1b670f0 Converted another testcase to the render system.
Edgar Simo <bobbens@gmail.com>
parents: 3730
diff changeset
263 return;
f5ddf1b670f0 Converted another testcase to the render system.
Edgar Simo <bobbens@gmail.com>
parents: 3730
diff changeset
264 ret = SDL_RenderLine( 0, 0, 79, i );
f5ddf1b670f0 Converted another testcase to the render system.
Edgar Simo <bobbens@gmail.com>
parents: 3730
diff changeset
265 if (SDL_ATassert( "SDL_RenderLine", ret == 0))
3730
dafd796f0c95 * Added preliminary render tests, missing some SDL functions to work properly.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
266 return;
dafd796f0c95 * Added preliminary render tests, missing some SDL functions to work properly.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
267 }
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 /* Draw points. */
3731
f5ddf1b670f0 Converted another testcase to the render system.
Edgar Simo <bobbens@gmail.com>
parents: 3730
diff changeset
270 for (j=0; j<SCREEN_H; j+=3) {
f5ddf1b670f0 Converted another testcase to the render system.
Edgar Simo <bobbens@gmail.com>
parents: 3730
diff changeset
271 for (i=0; i<SCREEN_W; i+=3) {
f5ddf1b670f0 Converted another testcase to the render system.
Edgar Simo <bobbens@gmail.com>
parents: 3730
diff changeset
272 ret = SDL_SetRenderDrawColor( j*4, i*3, j*4, i*3 );
f5ddf1b670f0 Converted another testcase to the render system.
Edgar Simo <bobbens@gmail.com>
parents: 3730
diff changeset
273 if (SDL_ATassert( "SDL_SetRenderDrawColor", ret == 0))
f5ddf1b670f0 Converted another testcase to the render system.
Edgar Simo <bobbens@gmail.com>
parents: 3730
diff changeset
274 return;
f5ddf1b670f0 Converted another testcase to the render system.
Edgar Simo <bobbens@gmail.com>
parents: 3730
diff changeset
275 ret = SDL_SetRenderDrawBlendMode( ((((i+j)/3)%3)==0) ? SDL_BLENDMODE_BLEND :
f5ddf1b670f0 Converted another testcase to the render system.
Edgar Simo <bobbens@gmail.com>
parents: 3730
diff changeset
276 ((((i+j)/3)%3)==1) ? SDL_BLENDMODE_ADD : SDL_BLENDMODE_MOD );
f5ddf1b670f0 Converted another testcase to the render system.
Edgar Simo <bobbens@gmail.com>
parents: 3730
diff changeset
277 if (SDL_ATassert( "SDL_SetSurfaceBlendMode", ret == 0))
f5ddf1b670f0 Converted another testcase to the render system.
Edgar Simo <bobbens@gmail.com>
parents: 3730
diff changeset
278 return;
f5ddf1b670f0 Converted another testcase to the render system.
Edgar Simo <bobbens@gmail.com>
parents: 3730
diff changeset
279 ret = SDL_RenderPoint( i, j );
f5ddf1b670f0 Converted another testcase to the render system.
Edgar Simo <bobbens@gmail.com>
parents: 3730
diff changeset
280 if (SDL_ATassert( "SDL_RenderPoint", ret == 0))
f5ddf1b670f0 Converted another testcase to the render system.
Edgar Simo <bobbens@gmail.com>
parents: 3730
diff changeset
281 return;
3730
dafd796f0c95 * Added preliminary render tests, missing some SDL functions to work properly.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
282 }
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
dafd796f0c95 * Added preliminary render tests, missing some SDL functions to work properly.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
285 /* See if it's the same. */
3731
f5ddf1b670f0 Converted another testcase to the render system.
Edgar Simo <bobbens@gmail.com>
parents: 3730
diff changeset
286 if (render_compare( "Blended primitives output not the same.", &img_primitives ))
3730
dafd796f0c95 * Added preliminary render tests, missing some SDL functions to work properly.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
287 return;
dafd796f0c95 * Added preliminary render tests, missing some SDL functions to work properly.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
288 }
3731
f5ddf1b670f0 Converted another testcase to the render system.
Edgar Simo <bobbens@gmail.com>
parents: 3730
diff changeset
289 #if 0
3730
dafd796f0c95 * Added preliminary render tests, missing some SDL functions to work properly.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
290
dafd796f0c95 * Added preliminary render tests, missing some SDL functions to work properly.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
291
dafd796f0c95 * Added preliminary render tests, missing some SDL functions to work properly.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
292 /**
dafd796f0c95 * Added preliminary render tests, missing some SDL functions to work properly.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
293 * @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
294 */
dafd796f0c95 * Added preliminary render tests, missing some SDL functions to work properly.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
295 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
296 {
dafd796f0c95 * Added preliminary render tests, missing some SDL functions to work properly.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
297 int ret;
dafd796f0c95 * Added preliminary render tests, missing some SDL functions to work properly.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
298 SDL_Rect rect;
dafd796f0c95 * Added preliminary render tests, missing some SDL functions to work properly.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
299 SDL_Surface *face;
dafd796f0c95 * Added preliminary render tests, missing some SDL functions to work properly.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
300 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
301
dafd796f0c95 * Added preliminary render tests, missing some SDL functions to work properly.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
302 SDL_ATbegin( "Blit Tests" );
dafd796f0c95 * Added preliminary render tests, missing some SDL functions to work properly.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
303
dafd796f0c95 * Added preliminary render tests, missing some SDL functions to work properly.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
304 /* Clear surface. */
dafd796f0c95 * Added preliminary render tests, missing some SDL functions to work properly.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
305 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
306 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
307 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
308 return;
dafd796f0c95 * Added preliminary render tests, missing some SDL functions to work properly.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
309
dafd796f0c95 * Added preliminary render tests, missing some SDL functions to work properly.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
310 /* Create face surface. */
dafd796f0c95 * Added preliminary render tests, missing some SDL functions to work properly.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
311 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
312 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
313 RMASK, GMASK, BMASK, AMASK );
dafd796f0c95 * Added preliminary render tests, missing some SDL functions to work properly.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
314 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
315 return;
dafd796f0c95 * Added preliminary render tests, missing some SDL functions to work properly.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
316
dafd796f0c95 * Added preliminary render tests, missing some SDL functions to work properly.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
317 /* Constant values. */
dafd796f0c95 * Added preliminary render tests, missing some SDL functions to work properly.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
318 rect.w = face->w;
dafd796f0c95 * Added preliminary render tests, missing some SDL functions to work properly.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
319 rect.h = face->h;
dafd796f0c95 * Added preliminary render tests, missing some SDL functions to work properly.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
320 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
321 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
322
dafd796f0c95 * Added preliminary render tests, missing some SDL functions to work properly.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
323 /* Loop blit. */
dafd796f0c95 * Added preliminary render tests, missing some SDL functions to work properly.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
324 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
325 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
326 /* Blitting. */
dafd796f0c95 * Added preliminary render tests, missing some SDL functions to work properly.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
327 rect.x = i;
dafd796f0c95 * Added preliminary render tests, missing some SDL functions to work properly.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
328 rect.y = j;
dafd796f0c95 * Added preliminary render tests, missing some SDL functions to work properly.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
329 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
330 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
331 return;
dafd796f0c95 * Added preliminary render tests, missing some SDL functions to work properly.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
332 }
dafd796f0c95 * Added preliminary render tests, missing some SDL functions to work properly.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
333 }
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 /* 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
336 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
337 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
338 return;
dafd796f0c95 * Added preliminary render tests, missing some SDL functions to work properly.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
339
dafd796f0c95 * Added preliminary render tests, missing some SDL functions to work properly.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
340 /* Clear surface. */
dafd796f0c95 * Added preliminary render tests, missing some SDL functions to work properly.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
341 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
342 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
343 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
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 colour mod. */
dafd796f0c95 * Added preliminary render tests, missing some SDL functions to work properly.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
350 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
351 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
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_SetSurfaceColorMod).",
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_blitColour )==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 /* Clear surface. */
dafd796f0c95 * Added preliminary render tests, missing some SDL functions to work properly.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
369 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
370 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
371 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
372 return;
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 /* Restore colour. */
dafd796f0c95 * Added preliminary render tests, missing some SDL functions to work properly.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
375 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
376 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
377 return;
dafd796f0c95 * Added preliminary render tests, missing some SDL functions to work properly.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
378
dafd796f0c95 * Added preliminary render tests, missing some SDL functions to work properly.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
379 /* 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
380 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
381 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
382 /* Set alpha mod. */
dafd796f0c95 * Added preliminary render tests, missing some SDL functions to work properly.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
383 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
384 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
385 return;
dafd796f0c95 * Added preliminary render tests, missing some SDL functions to work properly.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
386
dafd796f0c95 * Added preliminary render tests, missing some SDL functions to work properly.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
387 /* Blitting. */
dafd796f0c95 * Added preliminary render tests, missing some SDL functions to work properly.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
388 rect.x = i;
dafd796f0c95 * Added preliminary render tests, missing some SDL functions to work properly.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
389 rect.y = j;
dafd796f0c95 * Added preliminary render tests, missing some SDL functions to work properly.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
390 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
391 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
392 return;
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 }
dafd796f0c95 * Added preliminary render tests, missing some SDL functions to work properly.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
395
dafd796f0c95 * Added preliminary render tests, missing some SDL functions to work properly.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
396 /* 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
397 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
398 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
399 return;
dafd796f0c95 * Added preliminary render tests, missing some SDL functions to work properly.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
400
dafd796f0c95 * Added preliminary render tests, missing some SDL functions to work properly.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
401 /* Clean up. */
dafd796f0c95 * Added preliminary render tests, missing some SDL functions to work properly.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
402 SDL_FreeSurface( face );
dafd796f0c95 * Added preliminary render tests, missing some SDL functions to work properly.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
403
dafd796f0c95 * Added preliminary render tests, missing some SDL functions to work properly.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
404 SDL_ATend();
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
dafd796f0c95 * Added preliminary render tests, missing some SDL functions to work properly.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
407
dafd796f0c95 * Added preliminary render tests, missing some SDL functions to work properly.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
408 /**
dafd796f0c95 * Added preliminary render tests, missing some SDL functions to work properly.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
409 * @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
410 */
dafd796f0c95 * Added preliminary render tests, missing some SDL functions to work properly.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
411 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
412 {
dafd796f0c95 * Added preliminary render tests, missing some SDL functions to work properly.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
413 int ret;
dafd796f0c95 * Added preliminary render tests, missing some SDL functions to work properly.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
414 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
415 SDL_Rect rect;
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 /* Clear surface. */
dafd796f0c95 * Added preliminary render tests, missing some SDL functions to work properly.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
418 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
419 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
420 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
421 return 1;
dafd796f0c95 * Added preliminary render tests, missing some SDL functions to work properly.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
422
dafd796f0c95 * Added preliminary render tests, missing some SDL functions to work properly.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
423 /* Steps to take. */
dafd796f0c95 * Added preliminary render tests, missing some SDL functions to work properly.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
424 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
425 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
426
dafd796f0c95 * Added preliminary render tests, missing some SDL functions to work properly.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
427 /* Constant values. */
dafd796f0c95 * Added preliminary render tests, missing some SDL functions to work properly.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
428 rect.w = face->w;
dafd796f0c95 * Added preliminary render tests, missing some SDL functions to work properly.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
429 rect.h = face->h;
dafd796f0c95 * Added preliminary render tests, missing some SDL functions to work properly.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
430
dafd796f0c95 * Added preliminary render tests, missing some SDL functions to work properly.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
431 /* Test blend mode. */
dafd796f0c95 * Added preliminary render tests, missing some SDL functions to work properly.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
432 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
433 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
434 /* Set blend mode. */
dafd796f0c95 * Added preliminary render tests, missing some SDL functions to work properly.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
435 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
436 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
437 return 1;
dafd796f0c95 * Added preliminary render tests, missing some SDL functions to work properly.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
438
dafd796f0c95 * Added preliminary render tests, missing some SDL functions to work properly.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
439 /* Blitting. */
dafd796f0c95 * Added preliminary render tests, missing some SDL functions to work properly.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
440 rect.x = i;
dafd796f0c95 * Added preliminary render tests, missing some SDL functions to work properly.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
441 rect.y = j;
dafd796f0c95 * Added preliminary render tests, missing some SDL functions to work properly.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
442 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
443 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
444 return 1;
dafd796f0c95 * Added preliminary render tests, missing some SDL functions to work properly.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
445 }
dafd796f0c95 * Added preliminary render tests, missing some SDL functions to work properly.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
446 }
dafd796f0c95 * Added preliminary render tests, missing some SDL functions to work properly.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
447
dafd796f0c95 * Added preliminary render tests, missing some SDL functions to work properly.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
448 return 0;
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
dafd796f0c95 * Added preliminary render tests, missing some SDL functions to work properly.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
451
dafd796f0c95 * Added preliminary render tests, missing some SDL functions to work properly.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
452 /**
dafd796f0c95 * Added preliminary render tests, missing some SDL functions to work properly.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
453 * @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
454 */
dafd796f0c95 * Added preliminary render tests, missing some SDL functions to work properly.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
455 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
456 {
dafd796f0c95 * Added preliminary render tests, missing some SDL functions to work properly.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
457 int ret;
dafd796f0c95 * Added preliminary render tests, missing some SDL functions to work properly.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
458 SDL_Rect rect;
dafd796f0c95 * Added preliminary render tests, missing some SDL functions to work properly.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
459 SDL_Surface *face;
dafd796f0c95 * Added preliminary render tests, missing some SDL functions to work properly.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
460 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
461 int mode;
dafd796f0c95 * Added preliminary render tests, missing some SDL functions to work properly.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
462
dafd796f0c95 * Added preliminary render tests, missing some SDL functions to work properly.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
463 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
464
dafd796f0c95 * Added preliminary render tests, missing some SDL functions to work properly.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
465 /* Clear surface. */
dafd796f0c95 * Added preliminary render tests, missing some SDL functions to work properly.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
466 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
467 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
468 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
469 return;
dafd796f0c95 * Added preliminary render tests, missing some SDL functions to work properly.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
470
dafd796f0c95 * Added preliminary render tests, missing some SDL functions to work properly.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
471 /* Create the blit surface. */
dafd796f0c95 * Added preliminary render tests, missing some SDL functions to work properly.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
472 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
473 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
474 RMASK, GMASK, BMASK, AMASK );
dafd796f0c95 * Added preliminary render tests, missing some SDL functions to work properly.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
475 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
476 return;
dafd796f0c95 * Added preliminary render tests, missing some SDL functions to work properly.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
477
dafd796f0c95 * Added preliminary render tests, missing some SDL functions to work properly.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
478 /* Set alpha mod. */
dafd796f0c95 * Added preliminary render tests, missing some SDL functions to work properly.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
479 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
480 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
481 return;
dafd796f0c95 * Added preliminary render tests, missing some SDL functions to work properly.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
482
dafd796f0c95 * Added preliminary render tests, missing some SDL functions to work properly.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
483 /* Steps to take. */
dafd796f0c95 * Added preliminary render tests, missing some SDL functions to work properly.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
484 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
485 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
486
dafd796f0c95 * Added preliminary render tests, missing some SDL functions to work properly.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
487 /* Constant values. */
dafd796f0c95 * Added preliminary render tests, missing some SDL functions to work properly.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
488 rect.w = face->w;
dafd796f0c95 * Added preliminary render tests, missing some SDL functions to work properly.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
489 rect.h = face->h;
dafd796f0c95 * Added preliminary render tests, missing some SDL functions to work properly.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
490
dafd796f0c95 * Added preliminary render tests, missing some SDL functions to work properly.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
491 /* Test None. */
dafd796f0c95 * Added preliminary render tests, missing some SDL functions to work properly.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
492 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
493 return;
dafd796f0c95 * Added preliminary render tests, missing some SDL functions to work properly.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
494 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
495 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
496 return;
dafd796f0c95 * Added preliminary render tests, missing some SDL functions to work properly.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
497
dafd796f0c95 * Added preliminary render tests, missing some SDL functions to work properly.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
498 /* Test Mask. */
dafd796f0c95 * Added preliminary render tests, missing some SDL functions to work properly.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
499 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
500 return;
dafd796f0c95 * Added preliminary render tests, missing some SDL functions to work properly.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
501 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
502 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
503 return;
dafd796f0c95 * Added preliminary render tests, missing some SDL functions to work properly.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
504
dafd796f0c95 * Added preliminary render tests, missing some SDL functions to work properly.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
505 /* Test Blend. */
dafd796f0c95 * Added preliminary render tests, missing some SDL functions to work properly.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
506 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
507 return;
dafd796f0c95 * Added preliminary render tests, missing some SDL functions to work properly.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
508 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
509 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
510 return;
dafd796f0c95 * Added preliminary render tests, missing some SDL functions to work properly.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
511
dafd796f0c95 * Added preliminary render tests, missing some SDL functions to work properly.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
512 /* Test Add. */
dafd796f0c95 * Added preliminary render tests, missing some SDL functions to work properly.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
513 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
514 return;
dafd796f0c95 * Added preliminary render tests, missing some SDL functions to work properly.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
515 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
516 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
517 return;
dafd796f0c95 * Added preliminary render tests, missing some SDL functions to work properly.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
518
dafd796f0c95 * Added preliminary render tests, missing some SDL functions to work properly.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
519 /* Test Mod. */
dafd796f0c95 * Added preliminary render tests, missing some SDL functions to work properly.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
520 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
521 return;
dafd796f0c95 * Added preliminary render tests, missing some SDL functions to work properly.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
522 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
523 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
524 return;
dafd796f0c95 * Added preliminary render tests, missing some SDL functions to work properly.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
525
dafd796f0c95 * Added preliminary render tests, missing some SDL functions to work properly.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
526 /* Clear surface. */
dafd796f0c95 * Added preliminary render tests, missing some SDL functions to work properly.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
527 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
528 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
529 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
530 return;
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 /* Loop blit. */
dafd796f0c95 * Added preliminary render tests, missing some SDL functions to work properly.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
533 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
534 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
535
dafd796f0c95 * Added preliminary render tests, missing some SDL functions to work properly.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
536 /* Set colour mod. */
dafd796f0c95 * Added preliminary render tests, missing some SDL functions to work properly.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
537 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
538 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
539 return;
dafd796f0c95 * Added preliminary render tests, missing some SDL functions to work properly.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
540
dafd796f0c95 * Added preliminary render tests, missing some SDL functions to work properly.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
541 /* Set alpha mod. */
dafd796f0c95 * Added preliminary render tests, missing some SDL functions to work properly.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
542 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
543 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
544 return;
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 /* Crazy blending mode magic. */
dafd796f0c95 * Added preliminary render tests, missing some SDL functions to work properly.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
547 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
548 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
549 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
550 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
551 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
552 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
553 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
554 return;
dafd796f0c95 * Added preliminary render tests, missing some SDL functions to work properly.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
555
dafd796f0c95 * Added preliminary render tests, missing some SDL functions to work properly.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
556 /* Blitting. */
dafd796f0c95 * Added preliminary render tests, missing some SDL functions to work properly.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
557 rect.x = i;
dafd796f0c95 * Added preliminary render tests, missing some SDL functions to work properly.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
558 rect.y = j;
dafd796f0c95 * Added preliminary render tests, missing some SDL functions to work properly.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
559 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
560 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
561 return;
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 }
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 /* 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
566 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
567 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
568 return;
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 /* Clean up. */
dafd796f0c95 * Added preliminary render tests, missing some SDL functions to work properly.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
571 SDL_FreeSurface( face );
dafd796f0c95 * Added preliminary render tests, missing some SDL functions to work properly.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
572
dafd796f0c95 * Added preliminary render tests, missing some SDL functions to work properly.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
573 SDL_ATend();
dafd796f0c95 * Added preliminary render tests, missing some SDL functions to work properly.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
574 }
dafd796f0c95 * Added preliminary render tests, missing some SDL functions to work properly.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
575 #endif
dafd796f0c95 * Added preliminary render tests, missing some SDL functions to work properly.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
576
dafd796f0c95 * Added preliminary render tests, missing some SDL functions to work properly.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
577
dafd796f0c95 * Added preliminary render tests, missing some SDL functions to work properly.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
578 /**
dafd796f0c95 * Added preliminary render tests, missing some SDL functions to work properly.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
579 * @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
580 *
dafd796f0c95 * Added preliminary render tests, missing some SDL functions to work properly.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
581 * @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
582 */
dafd796f0c95 * Added preliminary render tests, missing some SDL functions to work properly.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
583 void render_runTests (void)
dafd796f0c95 * Added preliminary render tests, missing some SDL functions to work properly.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
584 {
dafd796f0c95 * Added preliminary render tests, missing some SDL functions to work properly.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
585 /* Software surface blitting. */
dafd796f0c95 * Added preliminary render tests, missing some SDL functions to work properly.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
586 render_testPrimitives();
dafd796f0c95 * Added preliminary render tests, missing some SDL functions to work properly.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
587 /*
dafd796f0c95 * Added preliminary render tests, missing some SDL functions to work properly.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
588 render_testPrimitivesBlend();
dafd796f0c95 * Added preliminary render tests, missing some SDL functions to work properly.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
589 render_testBlit();
dafd796f0c95 * Added preliminary render tests, missing some SDL functions to work properly.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
590 render_testBlitBlend();
dafd796f0c95 * Added preliminary render tests, missing some SDL functions to work properly.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
591 */
dafd796f0c95 * Added preliminary render tests, missing some SDL functions to work properly.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
592 }
dafd796f0c95 * Added preliminary render tests, missing some SDL functions to work properly.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
593
dafd796f0c95 * Added preliminary render tests, missing some SDL functions to work properly.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
594
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 * @brief Entry point.
dafd796f0c95 * Added preliminary render tests, missing some SDL functions to work properly.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
597 *
dafd796f0c95 * Added preliminary render tests, missing some SDL functions to work properly.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
598 * 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
599 * 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
600 * 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
601 * superfluous testsuites.
dafd796f0c95 * Added preliminary render tests, missing some SDL functions to work properly.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
602 */
dafd796f0c95 * Added preliminary render tests, missing some SDL functions to work properly.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
603 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
604 {
dafd796f0c95 * Added preliminary render tests, missing some SDL functions to work properly.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
605 (void) argc;
dafd796f0c95 * Added preliminary render tests, missing some SDL functions to work properly.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
606 (void) argv;
dafd796f0c95 * Added preliminary render tests, missing some SDL functions to work properly.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
607 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
608 int ret;
dafd796f0c95 * Added preliminary render tests, missing some SDL functions to work properly.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
609 const char *driver, *str;
dafd796f0c95 * Added preliminary render tests, missing some SDL functions to work properly.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
610 char msg[256];
dafd796f0c95 * Added preliminary render tests, missing some SDL functions to work properly.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
611 SDL_WindowID wid;
dafd796f0c95 * Added preliminary render tests, missing some SDL functions to work properly.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
612 SDL_RendererInfo renderer;
dafd796f0c95 * Added preliminary render tests, missing some SDL functions to work properly.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
613
dafd796f0c95 * Added preliminary render tests, missing some SDL functions to work properly.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
614 /* Initializes the SDL subsystems. */
dafd796f0c95 * Added preliminary render tests, missing some SDL functions to work properly.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
615 ret = SDL_Init(0);
dafd796f0c95 * Added preliminary render tests, missing some SDL functions to work properly.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
616 if (ret != 0)
dafd796f0c95 * Added preliminary render tests, missing some SDL functions to work properly.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
617 return -1;
dafd796f0c95 * Added preliminary render tests, missing some SDL functions to work properly.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
618
dafd796f0c95 * Added preliminary render tests, missing some SDL functions to work properly.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
619 /* Get number of drivers. */
dafd796f0c95 * Added preliminary render tests, missing some SDL functions to work properly.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
620 nd = SDL_GetNumVideoDrivers();
dafd796f0c95 * Added preliminary render tests, missing some SDL functions to work properly.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
621 if (ret < 0)
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
dafd796f0c95 * Added preliminary render tests, missing some SDL functions to work properly.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
624 /* 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
625 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
626 if (ret != 0)
dafd796f0c95 * Added preliminary render tests, missing some SDL functions to work properly.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
627 goto err;
dafd796f0c95 * Added preliminary render tests, missing some SDL functions to work properly.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
628
dafd796f0c95 * Added preliminary render tests, missing some SDL functions to work properly.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
629 /*
dafd796f0c95 * Added preliminary render tests, missing some SDL functions to work properly.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
630 * 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
631 */
dafd796f0c95 * Added preliminary render tests, missing some SDL functions to work properly.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
632 /* 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
633 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
634 /* Get video mode. */
dafd796f0c95 * Added preliminary render tests, missing some SDL functions to work properly.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
635 driver = SDL_GetVideoDriver(i);
dafd796f0c95 * Added preliminary render tests, missing some SDL functions to work properly.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
636 if (driver == NULL)
dafd796f0c95 * Added preliminary render tests, missing some SDL functions to work properly.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
637 goto err;
dafd796f0c95 * Added preliminary render tests, missing some SDL functions to work properly.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
638 /* 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
639 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
640 continue;
dafd796f0c95 * Added preliminary render tests, missing some SDL functions to work properly.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
641
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 * Initialize testsuite.
dafd796f0c95 * Added preliminary render tests, missing some SDL functions to work properly.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
644 */
dafd796f0c95 * Added preliminary render tests, missing some SDL functions to work properly.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
645 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
646 SDL_ATinit( msg );
dafd796f0c95 * Added preliminary render tests, missing some SDL functions to work properly.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
647
dafd796f0c95 * Added preliminary render tests, missing some SDL functions to work properly.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
648 /*
dafd796f0c95 * Added preliminary render tests, missing some SDL functions to work properly.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
649 * Initialize.
dafd796f0c95 * Added preliminary render tests, missing some SDL functions to work properly.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
650 */
dafd796f0c95 * Added preliminary render tests, missing some SDL functions to work properly.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
651 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
652 /* Initialize video mode. */
dafd796f0c95 * Added preliminary render tests, missing some SDL functions to work properly.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
653 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
654 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
655 goto err;
dafd796f0c95 * Added preliminary render tests, missing some SDL functions to work properly.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
656 /* 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
657 str = SDL_GetCurrentVideoDriver();
dafd796f0c95 * Added preliminary render tests, missing some SDL functions to work properly.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
658 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
659 goto err;
dafd796f0c95 * Added preliminary render tests, missing some SDL functions to work properly.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
660 /* Create window. */
dafd796f0c95 * Added preliminary render tests, missing some SDL functions to work properly.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
661 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
662 80, 60, 0 );
dafd796f0c95 * Added preliminary render tests, missing some SDL functions to work properly.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
663 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
664 goto err;
dafd796f0c95 * Added preliminary render tests, missing some SDL functions to work properly.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
665 /* Check title. */
dafd796f0c95 * Added preliminary render tests, missing some SDL functions to work properly.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
666 str = SDL_GetWindowTitle( wid );
dafd796f0c95 * Added preliminary render tests, missing some SDL functions to work properly.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
667 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
668 goto err;
dafd796f0c95 * Added preliminary render tests, missing some SDL functions to work properly.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
669 /* Get renderers. */
dafd796f0c95 * Added preliminary render tests, missing some SDL functions to work properly.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
670 nr = SDL_GetNumRenderDrivers();
dafd796f0c95 * Added preliminary render tests, missing some SDL functions to work properly.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
671 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
672 goto err;
dafd796f0c95 * Added preliminary render tests, missing some SDL functions to work properly.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
673 SDL_ATend();
dafd796f0c95 * Added preliminary render tests, missing some SDL functions to work properly.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
674 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
675
dafd796f0c95 * Added preliminary render tests, missing some SDL functions to work properly.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
676 /* Get renderer info. */
dafd796f0c95 * Added preliminary render tests, missing some SDL functions to work properly.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
677 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
678 if (ret != 0)
dafd796f0c95 * Added preliminary render tests, missing some SDL functions to work properly.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
679 goto err;
dafd796f0c95 * Added preliminary render tests, missing some SDL functions to work properly.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
680 /* Set testcase name. */
dafd796f0c95 * Added preliminary render tests, missing some SDL functions to work properly.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
681 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
682 SDL_ATbegin( msg );
dafd796f0c95 * Added preliminary render tests, missing some SDL functions to work properly.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
683 /* Set renderer. */
dafd796f0c95 * Added preliminary render tests, missing some SDL functions to work properly.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
684 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
685 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
686 goto err;
dafd796f0c95 * Added preliminary render tests, missing some SDL functions to work properly.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
687
dafd796f0c95 * Added preliminary render tests, missing some SDL functions to work properly.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
688 /*
dafd796f0c95 * Added preliminary render tests, missing some SDL functions to work properly.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
689 * Run tests.
dafd796f0c95 * Added preliminary render tests, missing some SDL functions to work properly.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
690 */
dafd796f0c95 * Added preliminary render tests, missing some SDL functions to work properly.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
691 render_runTests();
dafd796f0c95 * Added preliminary render tests, missing some SDL functions to work properly.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
692
dafd796f0c95 * Added preliminary render tests, missing some SDL functions to work properly.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
693 SDL_ATend();
dafd796f0c95 * Added preliminary render tests, missing some SDL functions to work properly.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
694 }
dafd796f0c95 * Added preliminary render tests, missing some SDL functions to work properly.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
695
dafd796f0c95 * Added preliminary render tests, missing some SDL functions to work properly.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
696 /* Exit the current renderer. */
dafd796f0c95 * Added preliminary render tests, missing some SDL functions to work properly.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
697 SDL_VideoQuit();
dafd796f0c95 * Added preliminary render tests, missing some SDL functions to work properly.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
698
dafd796f0c95 * Added preliminary render tests, missing some SDL functions to work properly.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
699 /*
dafd796f0c95 * Added preliminary render tests, missing some SDL functions to work properly.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
700 * Finish testsuite.
dafd796f0c95 * Added preliminary render tests, missing some SDL functions to work properly.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
701 */
dafd796f0c95 * Added preliminary render tests, missing some SDL functions to work properly.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
702 SDL_ATfinish(1);
dafd796f0c95 * Added preliminary render tests, missing some SDL functions to work properly.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
703 }
dafd796f0c95 * Added preliminary render tests, missing some SDL functions to work properly.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
704
dafd796f0c95 * Added preliminary render tests, missing some SDL functions to work properly.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
705
dafd796f0c95 * Added preliminary render tests, missing some SDL functions to work properly.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
706 /* Exit SDL. */
dafd796f0c95 * Added preliminary render tests, missing some SDL functions to work properly.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
707 SDL_Quit();
dafd796f0c95 * Added preliminary render tests, missing some SDL functions to work properly.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
708
dafd796f0c95 * Added preliminary render tests, missing some SDL functions to work properly.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
709 return 0;
dafd796f0c95 * Added preliminary render tests, missing some SDL functions to work properly.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
710
dafd796f0c95 * Added preliminary render tests, missing some SDL functions to work properly.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
711 err:
dafd796f0c95 * Added preliminary render tests, missing some SDL functions to work properly.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
712 return -1;
dafd796f0c95 * Added preliminary render tests, missing some SDL functions to work properly.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
713 }
dafd796f0c95 * Added preliminary render tests, missing some SDL functions to work properly.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
714