annotate test/automated/render/render.c @ 3734:42356acbc993 gsoc2009_unit_tests

Finished last of the render testcases.
author Edgar Simo <bobbens@gmail.com>
date Sat, 18 Jul 2009 22:29:37 +0000
parents ca544951b504
children 27b4b4d71011
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
3734
42356acbc993 Finished last of the render testcases.
Edgar Simo <bobbens@gmail.com>
parents: 3733
diff changeset
25 #define FACE_W img_face.width
42356acbc993 Finished last of the render testcases.
Edgar Simo <bobbens@gmail.com>
parents: 3733
diff changeset
26 #define FACE_H img_face.height
42356acbc993 Finished last of the render testcases.
Edgar Simo <bobbens@gmail.com>
parents: 3733
diff changeset
27
3731
f5ddf1b670f0 Converted another testcase to the render system.
Edgar Simo <bobbens@gmail.com>
parents: 3730
diff changeset
28
3730
dafd796f0c95 * Added preliminary render tests, missing some SDL functions to work properly.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
29 /*
dafd796f0c95 * Added preliminary render tests, missing some SDL functions to work properly.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
30 * Prototypes.
dafd796f0c95 * Added preliminary render tests, missing some SDL functions to work properly.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
31 */
dafd796f0c95 * Added preliminary render tests, missing some SDL functions to work properly.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
32 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
33 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
34 /* Testcases. */
3734
42356acbc993 Finished last of the render testcases.
Edgar Simo <bobbens@gmail.com>
parents: 3733
diff changeset
35 static int render_testPrimitives (void);
42356acbc993 Finished last of the render testcases.
Edgar Simo <bobbens@gmail.com>
parents: 3733
diff changeset
36 static int render_testPrimitivesBlend (void);
42356acbc993 Finished last of the render testcases.
Edgar Simo <bobbens@gmail.com>
parents: 3733
diff changeset
37 static int render_testBlit (void);
42356acbc993 Finished last of the render testcases.
Edgar Simo <bobbens@gmail.com>
parents: 3733
diff changeset
38 static int render_testBlitBlendMode( SDL_TextureID tface, int mode );
42356acbc993 Finished last of the render testcases.
Edgar Simo <bobbens@gmail.com>
parents: 3733
diff changeset
39 static int render_testBlitBlend (void);
3730
dafd796f0c95 * Added preliminary render tests, missing some SDL functions to work properly.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
40
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 /**
dafd796f0c95 * Added preliminary render tests, missing some SDL functions to work properly.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
43 * 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
44 */
dafd796f0c95 * Added preliminary render tests, missing some SDL functions to work properly.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
45 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
46 {
3734
42356acbc993 Finished last of the render testcases.
Edgar Simo <bobbens@gmail.com>
parents: 3733
diff changeset
47 (void) msg;
42356acbc993 Finished last of the render testcases.
Edgar Simo <bobbens@gmail.com>
parents: 3733
diff changeset
48 (void) s;
42356acbc993 Finished last of the render testcases.
Edgar Simo <bobbens@gmail.com>
parents: 3733
diff changeset
49 #if 0
3730
dafd796f0c95 * Added preliminary render tests, missing some SDL functions to work properly.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
50 int ret;
dafd796f0c95 * Added preliminary render tests, missing some SDL functions to work properly.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
51 void *pix;
dafd796f0c95 * Added preliminary render tests, missing some SDL functions to work properly.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
52 SDL_Surface *testsur;
dafd796f0c95 * Added preliminary render tests, missing some SDL functions to work properly.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
53
dafd796f0c95 * Added preliminary render tests, missing some SDL functions to work properly.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
54 /* Allocate pixel space. */
dafd796f0c95 * Added preliminary render tests, missing some SDL functions to work properly.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
55 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
56 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
57 return 1;
dafd796f0c95 * Added preliminary render tests, missing some SDL functions to work properly.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
58
dafd796f0c95 * Added preliminary render tests, missing some SDL functions to work properly.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
59 /* Read pixels. */
dafd796f0c95 * Added preliminary render tests, missing some SDL functions to work properly.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
60 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
61 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
62 return 1;
dafd796f0c95 * Added preliminary render tests, missing some SDL functions to work properly.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
63
dafd796f0c95 * Added preliminary render tests, missing some SDL functions to work properly.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
64 /* Create surface. */
dafd796f0c95 * Added preliminary render tests, missing some SDL functions to work properly.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
65 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
66 RMASK, GMASK, BMASK, AMASK );
dafd796f0c95 * Added preliminary render tests, missing some SDL functions to work properly.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
67 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
68 return 1;
dafd796f0c95 * Added preliminary render tests, missing some SDL functions to work properly.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
69
dafd796f0c95 * Added preliminary render tests, missing some SDL functions to work properly.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
70 /* Compare surface. */
dafd796f0c95 * Added preliminary render tests, missing some SDL functions to work properly.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
71 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
72 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
73 return 1;
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 /* Clean up. */
dafd796f0c95 * Added preliminary render tests, missing some SDL functions to work properly.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
76 SDL_FreeSurface( testsur );
dafd796f0c95 * Added preliminary render tests, missing some SDL functions to work properly.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
77 free(pix);
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 #endif
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 return 0;
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
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 * @brief Clears the screen.
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 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
88 {
dafd796f0c95 * Added preliminary render tests, missing some SDL functions to work properly.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
89 int ret;
dafd796f0c95 * Added preliminary render tests, missing some SDL functions to work properly.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
90
dafd796f0c95 * Added preliminary render tests, missing some SDL functions to work properly.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
91 /* Set colour. */
dafd796f0c95 * Added preliminary render tests, missing some SDL functions to work properly.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
92 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
93 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
94 return -1;
dafd796f0c95 * Added preliminary render tests, missing some SDL functions to work properly.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
95
dafd796f0c95 * Added preliminary render tests, missing some SDL functions to work properly.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
96 /* Clear screen. */
dafd796f0c95 * Added preliminary render tests, missing some SDL functions to work properly.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
97 ret = SDL_RenderFill( NULL );
dafd796f0c95 * Added preliminary render tests, missing some SDL functions to work properly.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
98 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
99 return -1;
dafd796f0c95 * Added preliminary render tests, missing some SDL functions to work properly.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
100
3733
ca544951b504 Finished converting the blit testcase.
Edgar Simo <bobbens@gmail.com>
parents: 3731
diff changeset
101 /* Set defaults. */
ca544951b504 Finished converting the blit testcase.
Edgar Simo <bobbens@gmail.com>
parents: 3731
diff changeset
102 ret = SDL_SetRenderDrawBlendMode( SDL_BLENDMODE_NONE );
ca544951b504 Finished converting the blit testcase.
Edgar Simo <bobbens@gmail.com>
parents: 3731
diff changeset
103 if (SDL_ATassert( "SDL_SetRenderDrawBlendMode", ret == 0))
ca544951b504 Finished converting the blit testcase.
Edgar Simo <bobbens@gmail.com>
parents: 3731
diff changeset
104 return -1;
ca544951b504 Finished converting the blit testcase.
Edgar Simo <bobbens@gmail.com>
parents: 3731
diff changeset
105 ret = SDL_SetRenderDrawColor( 255, 255, 255, SDL_ALPHA_OPAQUE );
ca544951b504 Finished converting the blit testcase.
Edgar Simo <bobbens@gmail.com>
parents: 3731
diff changeset
106 if (SDL_ATassert( "SDL_SetRenderDrawColor", ret == 0))
ca544951b504 Finished converting the blit testcase.
Edgar Simo <bobbens@gmail.com>
parents: 3731
diff changeset
107 return -1;
ca544951b504 Finished converting the blit testcase.
Edgar Simo <bobbens@gmail.com>
parents: 3731
diff changeset
108
3730
dafd796f0c95 * Added preliminary render tests, missing some SDL functions to work properly.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
109 return 0;
dafd796f0c95 * Added preliminary render tests, missing some SDL functions to work properly.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
110 }
dafd796f0c95 * Added preliminary render tests, missing some SDL functions to work properly.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
111
dafd796f0c95 * Added preliminary render tests, missing some SDL functions to work properly.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
112
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 * @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
115 */
3734
42356acbc993 Finished last of the render testcases.
Edgar Simo <bobbens@gmail.com>
parents: 3733
diff changeset
116 static int render_testPrimitives (void)
3730
dafd796f0c95 * Added preliminary render tests, missing some SDL functions to work properly.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
117 {
dafd796f0c95 * Added preliminary render tests, missing some SDL functions to work properly.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
118 int ret;
dafd796f0c95 * Added preliminary render tests, missing some SDL functions to work properly.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
119 int x, y;
dafd796f0c95 * Added preliminary render tests, missing some SDL functions to work properly.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
120 SDL_Rect rect;
dafd796f0c95 * Added preliminary render tests, missing some SDL functions to work properly.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
121
dafd796f0c95 * Added preliminary render tests, missing some SDL functions to work properly.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
122 /* Clear surface. */
dafd796f0c95 * Added preliminary render tests, missing some SDL functions to work properly.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
123 if (render_clearScreen())
3734
42356acbc993 Finished last of the render testcases.
Edgar Simo <bobbens@gmail.com>
parents: 3733
diff changeset
124 return -1;
3730
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 = 40;
dafd796f0c95 * Added preliminary render tests, missing some SDL functions to work properly.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
128 rect.y = 0;
dafd796f0c95 * Added preliminary render tests, missing some SDL functions to work properly.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
129 rect.w = 40;
dafd796f0c95 * Added preliminary render tests, missing some SDL functions to work properly.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
130 rect.h = 80;
dafd796f0c95 * Added preliminary render tests, missing some SDL functions to work properly.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
131 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
132 if (SDL_ATassert( "SDL_SetRenderDrawColor", ret == 0))
3734
42356acbc993 Finished last of the render testcases.
Edgar Simo <bobbens@gmail.com>
parents: 3733
diff changeset
133 return -1;
3730
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))
3734
42356acbc993 Finished last of the render testcases.
Edgar Simo <bobbens@gmail.com>
parents: 3733
diff changeset
136 return -1;
3730
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 a rectangle. */
dafd796f0c95 * Added preliminary render tests, missing some SDL functions to work properly.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
139 rect.x = 10;
dafd796f0c95 * Added preliminary render tests, missing some SDL functions to work properly.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
140 rect.y = 10;
dafd796f0c95 * Added preliminary render tests, missing some SDL functions to work properly.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
141 rect.w = 60;
dafd796f0c95 * Added preliminary render tests, missing some SDL functions to work properly.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
142 rect.h = 40;
dafd796f0c95 * Added preliminary render tests, missing some SDL functions to work properly.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
143 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
144 if (SDL_ATassert( "SDL_SetRenderDrawColor", ret == 0))
3734
42356acbc993 Finished last of the render testcases.
Edgar Simo <bobbens@gmail.com>
parents: 3733
diff changeset
145 return -1;
3730
dafd796f0c95 * Added preliminary render tests, missing some SDL functions to work properly.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
146 ret = SDL_RenderFill( &rect );
dafd796f0c95 * Added preliminary render tests, missing some SDL functions to work properly.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
147 if (SDL_ATassert( "SDL_RenderRect", ret == 0))
3734
42356acbc993 Finished last of the render testcases.
Edgar Simo <bobbens@gmail.com>
parents: 3733
diff changeset
148 return -1;
3730
dafd796f0c95 * Added preliminary render tests, missing some SDL functions to work properly.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
149
dafd796f0c95 * Added preliminary render tests, missing some SDL functions to work properly.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
150 /* Draw some points like so:
dafd796f0c95 * Added preliminary render tests, missing some SDL functions to work properly.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
151 * X.X.X.X..
dafd796f0c95 * Added preliminary render tests, missing some SDL functions to work properly.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
152 * .X.X.X.X.
dafd796f0c95 * Added preliminary render tests, missing some SDL functions to work properly.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
153 * X.X.X.X.. */
dafd796f0c95 * Added preliminary render tests, missing some SDL functions to work properly.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
154 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
155 x = y % 2;
dafd796f0c95 * Added preliminary render tests, missing some SDL functions to work properly.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
156 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
157 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
158 if (SDL_ATassert( "SDL_SetRenderDrawColor", ret == 0))
3734
42356acbc993 Finished last of the render testcases.
Edgar Simo <bobbens@gmail.com>
parents: 3733
diff changeset
159 return -1;
3730
dafd796f0c95 * Added preliminary render tests, missing some SDL functions to work properly.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
160 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
161 if (SDL_ATassert( "SDL_RenderPoint", ret == 0))
3734
42356acbc993 Finished last of the render testcases.
Edgar Simo <bobbens@gmail.com>
parents: 3733
diff changeset
162 return -1;
3730
dafd796f0c95 * Added preliminary render tests, missing some SDL functions to work properly.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
163 }
dafd796f0c95 * Added preliminary render tests, missing some SDL functions to work properly.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
164 }
dafd796f0c95 * Added preliminary render tests, missing some SDL functions to work properly.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
165
dafd796f0c95 * Added preliminary render tests, missing some SDL functions to work properly.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
166 /* Draw some lines. */
dafd796f0c95 * Added preliminary render tests, missing some SDL functions to work properly.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
167 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
168 if (SDL_ATassert( "SDL_SetRenderDrawColor", ret == 0))
3734
42356acbc993 Finished last of the render testcases.
Edgar Simo <bobbens@gmail.com>
parents: 3733
diff changeset
169 return -1;
3730
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, 30, 80, 30 );
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))
3734
42356acbc993 Finished last of the render testcases.
Edgar Simo <bobbens@gmail.com>
parents: 3733
diff changeset
172 return -1;
3730
dafd796f0c95 * Added preliminary render tests, missing some SDL functions to work properly.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
173 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
174 if (SDL_ATassert( "SDL_SetRenderDrawColor", ret == 0))
3734
42356acbc993 Finished last of the render testcases.
Edgar Simo <bobbens@gmail.com>
parents: 3733
diff changeset
175 return -1;
3730
dafd796f0c95 * Added preliminary render tests, missing some SDL functions to work properly.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
176 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
177 if (SDL_ATassert( "SDL_RenderLine", ret == 0))
3734
42356acbc993 Finished last of the render testcases.
Edgar Simo <bobbens@gmail.com>
parents: 3733
diff changeset
178 return -1;
3730
dafd796f0c95 * Added preliminary render tests, missing some SDL functions to work properly.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
179 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
180 if (SDL_ATassert( "SDL_SetRenderDrawColor", ret == 0))
3734
42356acbc993 Finished last of the render testcases.
Edgar Simo <bobbens@gmail.com>
parents: 3733
diff changeset
181 return -1;
3730
dafd796f0c95 * Added preliminary render tests, missing some SDL functions to work properly.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
182 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
183 if (SDL_ATassert( "SDL_RenderLine", ret == 0))
3734
42356acbc993 Finished last of the render testcases.
Edgar Simo <bobbens@gmail.com>
parents: 3733
diff changeset
184 return -1;
3730
dafd796f0c95 * Added preliminary render tests, missing some SDL functions to work properly.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
185
dafd796f0c95 * Added preliminary render tests, missing some SDL functions to work properly.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
186 /* 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
187 if (render_compare( "Primitives output not the same.", &img_primitives ))
3734
42356acbc993 Finished last of the render testcases.
Edgar Simo <bobbens@gmail.com>
parents: 3733
diff changeset
188 return -1;
42356acbc993 Finished last of the render testcases.
Edgar Simo <bobbens@gmail.com>
parents: 3733
diff changeset
189
42356acbc993 Finished last of the render testcases.
Edgar Simo <bobbens@gmail.com>
parents: 3733
diff changeset
190 return 0;
3730
dafd796f0c95 * Added preliminary render tests, missing some SDL functions to work properly.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
191 }
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
dafd796f0c95 * Added preliminary render tests, missing some SDL functions to work properly.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
194 /**
dafd796f0c95 * Added preliminary render tests, missing some SDL functions to work properly.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
195 * @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
196 */
3734
42356acbc993 Finished last of the render testcases.
Edgar Simo <bobbens@gmail.com>
parents: 3733
diff changeset
197 static int render_testPrimitivesBlend (void)
3730
dafd796f0c95 * Added preliminary render tests, missing some SDL functions to work properly.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
198 {
dafd796f0c95 * Added preliminary render tests, missing some SDL functions to work properly.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
199 int ret;
dafd796f0c95 * Added preliminary render tests, missing some SDL functions to work properly.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
200 int i, j;
dafd796f0c95 * Added preliminary render tests, missing some SDL functions to work properly.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
201 SDL_Rect rect;
dafd796f0c95 * Added preliminary render tests, missing some SDL functions to work properly.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
202
dafd796f0c95 * Added preliminary render tests, missing some SDL functions to work properly.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
203 /* Clear surface. */
3731
f5ddf1b670f0 Converted another testcase to the render system.
Edgar Simo <bobbens@gmail.com>
parents: 3730
diff changeset
204 if (render_clearScreen())
3734
42356acbc993 Finished last of the render testcases.
Edgar Simo <bobbens@gmail.com>
parents: 3733
diff changeset
205 return -1;
3730
dafd796f0c95 * Added preliminary render tests, missing some SDL functions to work properly.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
206
3733
ca544951b504 Finished converting the blit testcase.
Edgar Simo <bobbens@gmail.com>
parents: 3731
diff changeset
207 /* See if we can actually run the test. */
3734
42356acbc993 Finished last of the render testcases.
Edgar Simo <bobbens@gmail.com>
parents: 3733
diff changeset
208 #if 0
3733
ca544951b504 Finished converting the blit testcase.
Edgar Simo <bobbens@gmail.com>
parents: 3731
diff changeset
209 ret = 0;
ca544951b504 Finished converting the blit testcase.
Edgar Simo <bobbens@gmail.com>
parents: 3731
diff changeset
210 ret |= SDL_SetRenderDrawBlendMode( SDL_BLENDMODE_BLEND );
ca544951b504 Finished converting the blit testcase.
Edgar Simo <bobbens@gmail.com>
parents: 3731
diff changeset
211 ret |= SDL_SetRenderDrawBlendMode( SDL_BLENDMODE_ADD );
ca544951b504 Finished converting the blit testcase.
Edgar Simo <bobbens@gmail.com>
parents: 3731
diff changeset
212 ret |= SDL_SetRenderDrawBlendMode( SDL_BLENDMODE_MOD );
ca544951b504 Finished converting the blit testcase.
Edgar Simo <bobbens@gmail.com>
parents: 3731
diff changeset
213 ret |= SDL_SetRenderDrawBlendMode( SDL_BLENDMODE_NONE );
ca544951b504 Finished converting the blit testcase.
Edgar Simo <bobbens@gmail.com>
parents: 3731
diff changeset
214 if (ret != 0)
3734
42356acbc993 Finished last of the render testcases.
Edgar Simo <bobbens@gmail.com>
parents: 3733
diff changeset
215 return -1;
42356acbc993 Finished last of the render testcases.
Edgar Simo <bobbens@gmail.com>
parents: 3733
diff changeset
216 #endif
3733
ca544951b504 Finished converting the blit testcase.
Edgar Simo <bobbens@gmail.com>
parents: 3731
diff changeset
217
3730
dafd796f0c95 * Added preliminary render tests, missing some SDL functions to work properly.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
218 /* 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
219 ret = SDL_SetRenderDrawColor( 255, 255, 255, 0 );
f5ddf1b670f0 Converted another testcase to the render system.
Edgar Simo <bobbens@gmail.com>
parents: 3730
diff changeset
220 if (SDL_ATassert( "SDL_SetRenderDrawColor", ret == 0))
3734
42356acbc993 Finished last of the render testcases.
Edgar Simo <bobbens@gmail.com>
parents: 3733
diff changeset
221 return -1;
3731
f5ddf1b670f0 Converted another testcase to the render system.
Edgar Simo <bobbens@gmail.com>
parents: 3730
diff changeset
222 ret = SDL_SetRenderDrawBlendMode( SDL_BLENDMODE_NONE );
3733
ca544951b504 Finished converting the blit testcase.
Edgar Simo <bobbens@gmail.com>
parents: 3731
diff changeset
223 if (SDL_ATassert( "SDL_SetRenderDrawBlendMode", ret == 0))
3734
42356acbc993 Finished last of the render testcases.
Edgar Simo <bobbens@gmail.com>
parents: 3733
diff changeset
224 return -1;
3731
f5ddf1b670f0 Converted another testcase to the render system.
Edgar Simo <bobbens@gmail.com>
parents: 3730
diff changeset
225 ret = SDL_RenderFill( NULL );
f5ddf1b670f0 Converted another testcase to the render system.
Edgar Simo <bobbens@gmail.com>
parents: 3730
diff changeset
226 if (SDL_ATassert( "SDL_RenderFill", ret == 0))
3734
42356acbc993 Finished last of the render testcases.
Edgar Simo <bobbens@gmail.com>
parents: 3733
diff changeset
227 return -1;
3730
dafd796f0c95 * Added preliminary render tests, missing some SDL functions to work properly.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
228 rect.x = 10;
dafd796f0c95 * Added preliminary render tests, missing some SDL functions to work properly.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
229 rect.y = 25;
dafd796f0c95 * Added preliminary render tests, missing some SDL functions to work properly.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
230 rect.w = 40;
dafd796f0c95 * Added preliminary render tests, missing some SDL functions to work properly.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
231 rect.h = 25;
3731
f5ddf1b670f0 Converted another testcase to the render system.
Edgar Simo <bobbens@gmail.com>
parents: 3730
diff changeset
232 ret = SDL_SetRenderDrawColor( 240, 10, 10, 75 );
f5ddf1b670f0 Converted another testcase to the render system.
Edgar Simo <bobbens@gmail.com>
parents: 3730
diff changeset
233 if (SDL_ATassert( "SDL_SetRenderDrawColor", ret == 0))
3734
42356acbc993 Finished last of the render testcases.
Edgar Simo <bobbens@gmail.com>
parents: 3733
diff changeset
234 return -1;
3731
f5ddf1b670f0 Converted another testcase to the render system.
Edgar Simo <bobbens@gmail.com>
parents: 3730
diff changeset
235 ret = SDL_SetRenderDrawBlendMode( SDL_BLENDMODE_ADD );
3733
ca544951b504 Finished converting the blit testcase.
Edgar Simo <bobbens@gmail.com>
parents: 3731
diff changeset
236 if (SDL_ATassert( "SDL_SetRenderDrawBlendMode", ret == 0))
3734
42356acbc993 Finished last of the render testcases.
Edgar Simo <bobbens@gmail.com>
parents: 3733
diff changeset
237 return -1;
3731
f5ddf1b670f0 Converted another testcase to the render system.
Edgar Simo <bobbens@gmail.com>
parents: 3730
diff changeset
238 ret = SDL_RenderFill( &rect );
f5ddf1b670f0 Converted another testcase to the render system.
Edgar Simo <bobbens@gmail.com>
parents: 3730
diff changeset
239 if (SDL_ATassert( "SDL_RenderFill", ret == 0))
3734
42356acbc993 Finished last of the render testcases.
Edgar Simo <bobbens@gmail.com>
parents: 3733
diff changeset
240 return -1;
3730
dafd796f0c95 * Added preliminary render tests, missing some SDL functions to work properly.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
241 rect.x = 30;
dafd796f0c95 * Added preliminary render tests, missing some SDL functions to work properly.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
242 rect.y = 40;
dafd796f0c95 * Added preliminary render tests, missing some SDL functions to work properly.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
243 rect.w = 45;
dafd796f0c95 * Added preliminary render tests, missing some SDL functions to work properly.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
244 rect.h = 15;
3731
f5ddf1b670f0 Converted another testcase to the render system.
Edgar Simo <bobbens@gmail.com>
parents: 3730
diff changeset
245 ret = SDL_SetRenderDrawColor( 10, 240, 10, 100 );
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))
3734
42356acbc993 Finished last of the render testcases.
Edgar Simo <bobbens@gmail.com>
parents: 3733
diff changeset
247 return -1;
3731
f5ddf1b670f0 Converted another testcase to the render system.
Edgar Simo <bobbens@gmail.com>
parents: 3730
diff changeset
248 ret = SDL_SetRenderDrawBlendMode( SDL_BLENDMODE_BLEND );
3733
ca544951b504 Finished converting the blit testcase.
Edgar Simo <bobbens@gmail.com>
parents: 3731
diff changeset
249 if (SDL_ATassert( "SDL_SetRenderDrawBlendMode", ret == 0))
3734
42356acbc993 Finished last of the render testcases.
Edgar Simo <bobbens@gmail.com>
parents: 3733
diff changeset
250 return -1;
3731
f5ddf1b670f0 Converted another testcase to the render system.
Edgar Simo <bobbens@gmail.com>
parents: 3730
diff changeset
251 ret = SDL_RenderFill( &rect );
f5ddf1b670f0 Converted another testcase to the render system.
Edgar Simo <bobbens@gmail.com>
parents: 3730
diff changeset
252 if (SDL_ATassert( "SDL_RenderFill", ret == 0))
3734
42356acbc993 Finished last of the render testcases.
Edgar Simo <bobbens@gmail.com>
parents: 3733
diff changeset
253 return -1;
3730
dafd796f0c95 * Added preliminary render tests, missing some SDL functions to work properly.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
254 rect.x = 25;
dafd796f0c95 * Added preliminary render tests, missing some SDL functions to work properly.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
255 rect.y = 25;
dafd796f0c95 * Added preliminary render tests, missing some SDL functions to work properly.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
256 rect.w = 25;
dafd796f0c95 * Added preliminary render tests, missing some SDL functions to work properly.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
257 rect.h = 25;
3731
f5ddf1b670f0 Converted another testcase to the render system.
Edgar Simo <bobbens@gmail.com>
parents: 3730
diff changeset
258 ret = SDL_SetRenderDrawColor( 10, 10, 240, 125 );
f5ddf1b670f0 Converted another testcase to the render system.
Edgar Simo <bobbens@gmail.com>
parents: 3730
diff changeset
259 if (SDL_ATassert( "SDL_SetRenderDrawColor", ret == 0))
3734
42356acbc993 Finished last of the render testcases.
Edgar Simo <bobbens@gmail.com>
parents: 3733
diff changeset
260 return -1;
3731
f5ddf1b670f0 Converted another testcase to the render system.
Edgar Simo <bobbens@gmail.com>
parents: 3730
diff changeset
261 ret = SDL_SetRenderDrawBlendMode( SDL_BLENDMODE_MOD );
3733
ca544951b504 Finished converting the blit testcase.
Edgar Simo <bobbens@gmail.com>
parents: 3731
diff changeset
262 if (SDL_ATassert( "SDL_SetRenderDrawBlendMode", ret == 0))
3734
42356acbc993 Finished last of the render testcases.
Edgar Simo <bobbens@gmail.com>
parents: 3733
diff changeset
263 return -1;
3731
f5ddf1b670f0 Converted another testcase to the render system.
Edgar Simo <bobbens@gmail.com>
parents: 3730
diff changeset
264 ret = SDL_RenderFill( &rect );
f5ddf1b670f0 Converted another testcase to the render system.
Edgar Simo <bobbens@gmail.com>
parents: 3730
diff changeset
265 if (SDL_ATassert( "SDL_RenderFill", ret == 0))
3734
42356acbc993 Finished last of the render testcases.
Edgar Simo <bobbens@gmail.com>
parents: 3733
diff changeset
266 return -1;
3730
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 /* Draw blended lines, lines for everyone. */
3731
f5ddf1b670f0 Converted another testcase to the render system.
Edgar Simo <bobbens@gmail.com>
parents: 3730
diff changeset
269 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
270 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
271 if (SDL_ATassert( "SDL_SetRenderDrawColor", ret == 0))
3734
42356acbc993 Finished last of the render testcases.
Edgar Simo <bobbens@gmail.com>
parents: 3733
diff changeset
272 return -1;
3731
f5ddf1b670f0 Converted another testcase to the render system.
Edgar Simo <bobbens@gmail.com>
parents: 3730
diff changeset
273 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
274 (((i/2)%3)==1) ? SDL_BLENDMODE_ADD : SDL_BLENDMODE_MOD );
3733
ca544951b504 Finished converting the blit testcase.
Edgar Simo <bobbens@gmail.com>
parents: 3731
diff changeset
275 if (SDL_ATassert( "SDL_SetRenderDrawBlendMode", ret == 0))
3734
42356acbc993 Finished last of the render testcases.
Edgar Simo <bobbens@gmail.com>
parents: 3733
diff changeset
276 return -1;
3731
f5ddf1b670f0 Converted another testcase to the render system.
Edgar Simo <bobbens@gmail.com>
parents: 3730
diff changeset
277 ret = SDL_RenderLine( 0, 0, i, 59 );
f5ddf1b670f0 Converted another testcase to the render system.
Edgar Simo <bobbens@gmail.com>
parents: 3730
diff changeset
278 if (SDL_ATassert( "SDL_RenderLine", ret == 0))
3734
42356acbc993 Finished last of the render testcases.
Edgar Simo <bobbens@gmail.com>
parents: 3733
diff changeset
279 return -1;
3730
dafd796f0c95 * Added preliminary render tests, missing some SDL functions to work properly.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
280 }
3731
f5ddf1b670f0 Converted another testcase to the render system.
Edgar Simo <bobbens@gmail.com>
parents: 3730
diff changeset
281 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
282 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
283 if (SDL_ATassert( "SDL_SetRenderDrawColor", ret == 0))
3734
42356acbc993 Finished last of the render testcases.
Edgar Simo <bobbens@gmail.com>
parents: 3733
diff changeset
284 return -1;
3731
f5ddf1b670f0 Converted another testcase to the render system.
Edgar Simo <bobbens@gmail.com>
parents: 3730
diff changeset
285 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
286 (((i/2)%3)==1) ? SDL_BLENDMODE_ADD : SDL_BLENDMODE_MOD );
3733
ca544951b504 Finished converting the blit testcase.
Edgar Simo <bobbens@gmail.com>
parents: 3731
diff changeset
287 if (SDL_ATassert( "SDL_SetRenderDrawBlendMode", ret == 0))
3734
42356acbc993 Finished last of the render testcases.
Edgar Simo <bobbens@gmail.com>
parents: 3733
diff changeset
288 return -1;
3731
f5ddf1b670f0 Converted another testcase to the render system.
Edgar Simo <bobbens@gmail.com>
parents: 3730
diff changeset
289 ret = SDL_RenderLine( 0, 0, 79, i );
f5ddf1b670f0 Converted another testcase to the render system.
Edgar Simo <bobbens@gmail.com>
parents: 3730
diff changeset
290 if (SDL_ATassert( "SDL_RenderLine", ret == 0))
3734
42356acbc993 Finished last of the render testcases.
Edgar Simo <bobbens@gmail.com>
parents: 3733
diff changeset
291 return -1;
3730
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
dafd796f0c95 * Added preliminary render tests, missing some SDL functions to work properly.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
294 /* Draw points. */
3731
f5ddf1b670f0 Converted another testcase to the render system.
Edgar Simo <bobbens@gmail.com>
parents: 3730
diff changeset
295 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
296 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
297 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
298 if (SDL_ATassert( "SDL_SetRenderDrawColor", ret == 0))
3734
42356acbc993 Finished last of the render testcases.
Edgar Simo <bobbens@gmail.com>
parents: 3733
diff changeset
299 return -1;
3731
f5ddf1b670f0 Converted another testcase to the render system.
Edgar Simo <bobbens@gmail.com>
parents: 3730
diff changeset
300 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
301 ((((i+j)/3)%3)==1) ? SDL_BLENDMODE_ADD : SDL_BLENDMODE_MOD );
3733
ca544951b504 Finished converting the blit testcase.
Edgar Simo <bobbens@gmail.com>
parents: 3731
diff changeset
302 if (SDL_ATassert( "SDL_SetRenderDrawBlendMode", ret == 0))
3734
42356acbc993 Finished last of the render testcases.
Edgar Simo <bobbens@gmail.com>
parents: 3733
diff changeset
303 return -1;
3731
f5ddf1b670f0 Converted another testcase to the render system.
Edgar Simo <bobbens@gmail.com>
parents: 3730
diff changeset
304 ret = SDL_RenderPoint( i, j );
f5ddf1b670f0 Converted another testcase to the render system.
Edgar Simo <bobbens@gmail.com>
parents: 3730
diff changeset
305 if (SDL_ATassert( "SDL_RenderPoint", ret == 0))
3734
42356acbc993 Finished last of the render testcases.
Edgar Simo <bobbens@gmail.com>
parents: 3733
diff changeset
306 return -1;
3730
dafd796f0c95 * Added preliminary render tests, missing some SDL functions to work properly.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
307 }
dafd796f0c95 * Added preliminary render tests, missing some SDL functions to work properly.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
308 }
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 /* See if it's the same. */
3731
f5ddf1b670f0 Converted another testcase to the render system.
Edgar Simo <bobbens@gmail.com>
parents: 3730
diff changeset
311 if (render_compare( "Blended primitives output not the same.", &img_primitives ))
3734
42356acbc993 Finished last of the render testcases.
Edgar Simo <bobbens@gmail.com>
parents: 3733
diff changeset
312 return -1;
42356acbc993 Finished last of the render testcases.
Edgar Simo <bobbens@gmail.com>
parents: 3733
diff changeset
313
42356acbc993 Finished last of the render testcases.
Edgar Simo <bobbens@gmail.com>
parents: 3733
diff changeset
314 return 0;
3730
dafd796f0c95 * Added preliminary render tests, missing some SDL functions to work properly.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
315 }
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
dafd796f0c95 * Added preliminary render tests, missing some SDL functions to work properly.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
318 /**
dafd796f0c95 * Added preliminary render tests, missing some SDL functions to work properly.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
319 * @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
320 */
3734
42356acbc993 Finished last of the render testcases.
Edgar Simo <bobbens@gmail.com>
parents: 3733
diff changeset
321 static int render_testBlit (void)
3730
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 int ret;
dafd796f0c95 * Added preliminary render tests, missing some SDL functions to work properly.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
324 SDL_Rect rect;
dafd796f0c95 * Added preliminary render tests, missing some SDL functions to work properly.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
325 SDL_Surface *face;
3733
ca544951b504 Finished converting the blit testcase.
Edgar Simo <bobbens@gmail.com>
parents: 3731
diff changeset
326 SDL_TextureID tface;
3730
dafd796f0c95 * Added preliminary render tests, missing some SDL functions to work properly.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
327 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
328
dafd796f0c95 * Added preliminary render tests, missing some SDL functions to work properly.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
329 /* Clear surface. */
3733
ca544951b504 Finished converting the blit testcase.
Edgar Simo <bobbens@gmail.com>
parents: 3731
diff changeset
330 if (render_clearScreen())
3734
42356acbc993 Finished last of the render testcases.
Edgar Simo <bobbens@gmail.com>
parents: 3733
diff changeset
331 return -1;
3730
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 /* Create face surface. */
dafd796f0c95 * Added preliminary render tests, missing some SDL functions to work properly.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
334 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
335 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
336 RMASK, GMASK, BMASK, AMASK );
dafd796f0c95 * Added preliminary render tests, missing some SDL functions to work properly.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
337 if (SDL_ATassert( "SDL_CreateRGBSurfaceFrom", face != NULL))
3734
42356acbc993 Finished last of the render testcases.
Edgar Simo <bobbens@gmail.com>
parents: 3733
diff changeset
338 return -1;
3733
ca544951b504 Finished converting the blit testcase.
Edgar Simo <bobbens@gmail.com>
parents: 3731
diff changeset
339 tface = SDL_CreateTextureFromSurface( 0, face );
ca544951b504 Finished converting the blit testcase.
Edgar Simo <bobbens@gmail.com>
parents: 3731
diff changeset
340 if (SDL_ATassert( "SDL_CreateTextureFromSurface", tface != 0))
3734
42356acbc993 Finished last of the render testcases.
Edgar Simo <bobbens@gmail.com>
parents: 3733
diff changeset
341 return -1;
3733
ca544951b504 Finished converting the blit testcase.
Edgar Simo <bobbens@gmail.com>
parents: 3731
diff changeset
342
ca544951b504 Finished converting the blit testcase.
Edgar Simo <bobbens@gmail.com>
parents: 3731
diff changeset
343 /* Clean up. */
ca544951b504 Finished converting the blit testcase.
Edgar Simo <bobbens@gmail.com>
parents: 3731
diff changeset
344 SDL_FreeSurface( face );
3730
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 /* Constant values. */
dafd796f0c95 * Added preliminary render tests, missing some SDL functions to work properly.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
347 rect.w = face->w;
dafd796f0c95 * Added preliminary render tests, missing some SDL functions to work properly.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
348 rect.h = face->h;
3733
ca544951b504 Finished converting the blit testcase.
Edgar Simo <bobbens@gmail.com>
parents: 3731
diff changeset
349 ni = SCREEN_W - face->w;
ca544951b504 Finished converting the blit testcase.
Edgar Simo <bobbens@gmail.com>
parents: 3731
diff changeset
350 nj = SCREEN_H - face->h;
3730
dafd796f0c95 * Added preliminary render tests, missing some SDL functions to work properly.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
351
dafd796f0c95 * Added preliminary render tests, missing some SDL functions to work properly.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
352 /* Loop blit. */
dafd796f0c95 * Added preliminary render tests, missing some SDL functions to work properly.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
353 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
354 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
355 /* Blitting. */
dafd796f0c95 * Added preliminary render tests, missing some SDL functions to work properly.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
356 rect.x = i;
dafd796f0c95 * Added preliminary render tests, missing some SDL functions to work properly.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
357 rect.y = j;
3733
ca544951b504 Finished converting the blit testcase.
Edgar Simo <bobbens@gmail.com>
parents: 3731
diff changeset
358 ret = SDL_RenderCopy( tface, NULL, &rect );
ca544951b504 Finished converting the blit testcase.
Edgar Simo <bobbens@gmail.com>
parents: 3731
diff changeset
359 if (SDL_ATassert( "SDL_RenderCopy", ret == 0))
3734
42356acbc993 Finished last of the render testcases.
Edgar Simo <bobbens@gmail.com>
parents: 3733
diff changeset
360 return -1;
3730
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
dafd796f0c95 * Added preliminary render tests, missing some SDL functions to work properly.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
364 /* See if it's the same. */
3733
ca544951b504 Finished converting the blit testcase.
Edgar Simo <bobbens@gmail.com>
parents: 3731
diff changeset
365 if (render_compare( "Blit output not the same.", &img_blit ))
3734
42356acbc993 Finished last of the render testcases.
Edgar Simo <bobbens@gmail.com>
parents: 3733
diff changeset
366 return -1;
3730
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. */
3733
ca544951b504 Finished converting the blit testcase.
Edgar Simo <bobbens@gmail.com>
parents: 3731
diff changeset
369 if (render_clearScreen())
3734
42356acbc993 Finished last of the render testcases.
Edgar Simo <bobbens@gmail.com>
parents: 3733
diff changeset
370 return -1;
3730
dafd796f0c95 * Added preliminary render tests, missing some SDL functions to work properly.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
371
dafd796f0c95 * Added preliminary render tests, missing some SDL functions to work properly.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
372 /* 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
373 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
374 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
375 /* Set colour mod. */
3733
ca544951b504 Finished converting the blit testcase.
Edgar Simo <bobbens@gmail.com>
parents: 3731
diff changeset
376 ret = SDL_SetTextureColorMod( tface, (255/nj)*j, (255/ni)*i, (255/nj)*j );
ca544951b504 Finished converting the blit testcase.
Edgar Simo <bobbens@gmail.com>
parents: 3731
diff changeset
377 if (SDL_ATassert( "SDL_SetTextureColorMod", ret == 0))
3734
42356acbc993 Finished last of the render testcases.
Edgar Simo <bobbens@gmail.com>
parents: 3733
diff changeset
378 return -1;
3730
dafd796f0c95 * Added preliminary render tests, missing some SDL functions to work properly.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
379
dafd796f0c95 * Added preliminary render tests, missing some SDL functions to work properly.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
380 /* Blitting. */
dafd796f0c95 * Added preliminary render tests, missing some SDL functions to work properly.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
381 rect.x = i;
dafd796f0c95 * Added preliminary render tests, missing some SDL functions to work properly.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
382 rect.y = j;
3733
ca544951b504 Finished converting the blit testcase.
Edgar Simo <bobbens@gmail.com>
parents: 3731
diff changeset
383 ret = SDL_RenderCopy( tface, NULL, &rect );
ca544951b504 Finished converting the blit testcase.
Edgar Simo <bobbens@gmail.com>
parents: 3731
diff changeset
384 if (SDL_ATassert( "SDL_RenderCopy", ret == 0))
3734
42356acbc993 Finished last of the render testcases.
Edgar Simo <bobbens@gmail.com>
parents: 3733
diff changeset
385 return -1;
3730
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 }
dafd796f0c95 * Added preliminary render tests, missing some SDL functions to work properly.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
388
dafd796f0c95 * Added preliminary render tests, missing some SDL functions to work properly.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
389 /* See if it's the same. */
3733
ca544951b504 Finished converting the blit testcase.
Edgar Simo <bobbens@gmail.com>
parents: 3731
diff changeset
390 if (render_compare( "Blit output not the same (using SDL_SetTextureColorMod).",
ca544951b504 Finished converting the blit testcase.
Edgar Simo <bobbens@gmail.com>
parents: 3731
diff changeset
391 &img_blitColour ))
3734
42356acbc993 Finished last of the render testcases.
Edgar Simo <bobbens@gmail.com>
parents: 3733
diff changeset
392 return -1;
3730
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 /* Clear surface. */
3733
ca544951b504 Finished converting the blit testcase.
Edgar Simo <bobbens@gmail.com>
parents: 3731
diff changeset
395 if (render_clearScreen())
3734
42356acbc993 Finished last of the render testcases.
Edgar Simo <bobbens@gmail.com>
parents: 3733
diff changeset
396 return -1;
3730
dafd796f0c95 * Added preliminary render tests, missing some SDL functions to work properly.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
397
dafd796f0c95 * Added preliminary render tests, missing some SDL functions to work properly.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
398 /* Restore colour. */
3733
ca544951b504 Finished converting the blit testcase.
Edgar Simo <bobbens@gmail.com>
parents: 3731
diff changeset
399 ret = SDL_SetTextureColorMod( tface, 255, 255, 255 );
ca544951b504 Finished converting the blit testcase.
Edgar Simo <bobbens@gmail.com>
parents: 3731
diff changeset
400 if (SDL_ATassert( "SDL_SetTextureColorMod", ret == 0))
3734
42356acbc993 Finished last of the render testcases.
Edgar Simo <bobbens@gmail.com>
parents: 3733
diff changeset
401 return -1;
3730
dafd796f0c95 * Added preliminary render tests, missing some SDL functions to work properly.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
402
dafd796f0c95 * Added preliminary render tests, missing some SDL functions to work properly.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
403 /* 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
404 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
405 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
406 /* Set alpha mod. */
3733
ca544951b504 Finished converting the blit testcase.
Edgar Simo <bobbens@gmail.com>
parents: 3731
diff changeset
407 ret = SDL_SetTextureAlphaMod( tface, (255/ni)*i );
ca544951b504 Finished converting the blit testcase.
Edgar Simo <bobbens@gmail.com>
parents: 3731
diff changeset
408 if (SDL_ATassert( "SDL_SetTextureAlphaMod", ret == 0))
3734
42356acbc993 Finished last of the render testcases.
Edgar Simo <bobbens@gmail.com>
parents: 3733
diff changeset
409 return -1;
3730
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 /* Blitting. */
dafd796f0c95 * Added preliminary render tests, missing some SDL functions to work properly.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
412 rect.x = i;
dafd796f0c95 * Added preliminary render tests, missing some SDL functions to work properly.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
413 rect.y = j;
3733
ca544951b504 Finished converting the blit testcase.
Edgar Simo <bobbens@gmail.com>
parents: 3731
diff changeset
414 ret = SDL_RenderCopy( tface, NULL, &rect );
ca544951b504 Finished converting the blit testcase.
Edgar Simo <bobbens@gmail.com>
parents: 3731
diff changeset
415 if (SDL_ATassert( "SDL_RenderCopy", ret == 0))
3734
42356acbc993 Finished last of the render testcases.
Edgar Simo <bobbens@gmail.com>
parents: 3733
diff changeset
416 return -1;
3730
dafd796f0c95 * Added preliminary render tests, missing some SDL functions to work properly.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
417 }
dafd796f0c95 * Added preliminary render tests, missing some SDL functions to work properly.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
418 }
dafd796f0c95 * Added preliminary render tests, missing some SDL functions to work properly.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
419
dafd796f0c95 * Added preliminary render tests, missing some SDL functions to work properly.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
420 /* See if it's the same. */
3733
ca544951b504 Finished converting the blit testcase.
Edgar Simo <bobbens@gmail.com>
parents: 3731
diff changeset
421 if (render_compare( "Blit output not the same (using SDL_SetSurfaceAlphaMod).",
ca544951b504 Finished converting the blit testcase.
Edgar Simo <bobbens@gmail.com>
parents: 3731
diff changeset
422 &img_blitAlpha ))
3734
42356acbc993 Finished last of the render testcases.
Edgar Simo <bobbens@gmail.com>
parents: 3733
diff changeset
423 return -1;
3730
dafd796f0c95 * Added preliminary render tests, missing some SDL functions to work properly.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
424
dafd796f0c95 * Added preliminary render tests, missing some SDL functions to work properly.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
425 /* Clean up. */
3733
ca544951b504 Finished converting the blit testcase.
Edgar Simo <bobbens@gmail.com>
parents: 3731
diff changeset
426 SDL_DestroyTexture( tface );
3734
42356acbc993 Finished last of the render testcases.
Edgar Simo <bobbens@gmail.com>
parents: 3733
diff changeset
427
42356acbc993 Finished last of the render testcases.
Edgar Simo <bobbens@gmail.com>
parents: 3733
diff changeset
428 return 0;
3730
dafd796f0c95 * Added preliminary render tests, missing some SDL functions to work properly.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
429 }
dafd796f0c95 * Added preliminary render tests, missing some SDL functions to work properly.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
430
dafd796f0c95 * Added preliminary render tests, missing some SDL functions to work properly.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
431
dafd796f0c95 * Added preliminary render tests, missing some SDL functions to work properly.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
432 /**
dafd796f0c95 * Added preliminary render tests, missing some SDL functions to work properly.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
433 * @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
434 */
3734
42356acbc993 Finished last of the render testcases.
Edgar Simo <bobbens@gmail.com>
parents: 3733
diff changeset
435 static int render_testBlitBlendMode( SDL_TextureID tface, int mode )
3730
dafd796f0c95 * Added preliminary render tests, missing some SDL functions to work properly.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
436 {
dafd796f0c95 * Added preliminary render tests, missing some SDL functions to work properly.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
437 int ret;
dafd796f0c95 * Added preliminary render tests, missing some SDL functions to work properly.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
438 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
439 SDL_Rect rect;
dafd796f0c95 * Added preliminary render tests, missing some SDL functions to work properly.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
440
dafd796f0c95 * Added preliminary render tests, missing some SDL functions to work properly.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
441 /* Clear surface. */
3734
42356acbc993 Finished last of the render testcases.
Edgar Simo <bobbens@gmail.com>
parents: 3733
diff changeset
442 if (render_clearScreen())
42356acbc993 Finished last of the render testcases.
Edgar Simo <bobbens@gmail.com>
parents: 3733
diff changeset
443 return -1;
3730
dafd796f0c95 * Added preliminary render tests, missing some SDL functions to work properly.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
444
dafd796f0c95 * Added preliminary render tests, missing some SDL functions to work properly.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
445 /* Steps to take. */
3734
42356acbc993 Finished last of the render testcases.
Edgar Simo <bobbens@gmail.com>
parents: 3733
diff changeset
446 ni = SCREEN_W - FACE_W;
42356acbc993 Finished last of the render testcases.
Edgar Simo <bobbens@gmail.com>
parents: 3733
diff changeset
447 nj = SCREEN_H - FACE_H;
3730
dafd796f0c95 * Added preliminary render tests, missing some SDL functions to work properly.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
448
dafd796f0c95 * Added preliminary render tests, missing some SDL functions to work properly.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
449 /* Constant values. */
3734
42356acbc993 Finished last of the render testcases.
Edgar Simo <bobbens@gmail.com>
parents: 3733
diff changeset
450 rect.w = FACE_W;
42356acbc993 Finished last of the render testcases.
Edgar Simo <bobbens@gmail.com>
parents: 3733
diff changeset
451 rect.h = FACE_H;
3730
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 /* Test blend mode. */
dafd796f0c95 * Added preliminary render tests, missing some SDL functions to work properly.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
454 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
455 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
456 /* Set blend mode. */
3734
42356acbc993 Finished last of the render testcases.
Edgar Simo <bobbens@gmail.com>
parents: 3733
diff changeset
457 ret = SDL_SetRenderDrawBlendMode( mode );
42356acbc993 Finished last of the render testcases.
Edgar Simo <bobbens@gmail.com>
parents: 3733
diff changeset
458 if (SDL_ATassert( "SDL_SetRenderDrawBlendMode", ret == 0))
42356acbc993 Finished last of the render testcases.
Edgar Simo <bobbens@gmail.com>
parents: 3733
diff changeset
459 return -1;
3730
dafd796f0c95 * Added preliminary render tests, missing some SDL functions to work properly.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
460
dafd796f0c95 * Added preliminary render tests, missing some SDL functions to work properly.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
461 /* Blitting. */
dafd796f0c95 * Added preliminary render tests, missing some SDL functions to work properly.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
462 rect.x = i;
dafd796f0c95 * Added preliminary render tests, missing some SDL functions to work properly.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
463 rect.y = j;
3734
42356acbc993 Finished last of the render testcases.
Edgar Simo <bobbens@gmail.com>
parents: 3733
diff changeset
464 ret = SDL_RenderCopy( tface, NULL, &rect );
42356acbc993 Finished last of the render testcases.
Edgar Simo <bobbens@gmail.com>
parents: 3733
diff changeset
465 if (SDL_ATassert( "SDL_RenderCopy", ret == 0))
42356acbc993 Finished last of the render testcases.
Edgar Simo <bobbens@gmail.com>
parents: 3733
diff changeset
466 return -1;
3730
dafd796f0c95 * Added preliminary render tests, missing some SDL functions to work properly.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
467 }
dafd796f0c95 * Added preliminary render tests, missing some SDL functions to work properly.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
468 }
dafd796f0c95 * Added preliminary render tests, missing some SDL functions to work properly.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
469
dafd796f0c95 * Added preliminary render tests, missing some SDL functions to work properly.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
470 return 0;
dafd796f0c95 * Added preliminary render tests, missing some SDL functions to work properly.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
471 }
dafd796f0c95 * Added preliminary render tests, missing some SDL functions to work properly.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
472
dafd796f0c95 * Added preliminary render tests, missing some SDL functions to work properly.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
473
dafd796f0c95 * Added preliminary render tests, missing some SDL functions to work properly.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
474 /**
dafd796f0c95 * Added preliminary render tests, missing some SDL functions to work properly.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
475 * @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
476 */
3734
42356acbc993 Finished last of the render testcases.
Edgar Simo <bobbens@gmail.com>
parents: 3733
diff changeset
477 static int render_testBlitBlend (void)
3730
dafd796f0c95 * Added preliminary render tests, missing some SDL functions to work properly.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
478 {
dafd796f0c95 * Added preliminary render tests, missing some SDL functions to work properly.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
479 int ret;
dafd796f0c95 * Added preliminary render tests, missing some SDL functions to work properly.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
480 SDL_Rect rect;
dafd796f0c95 * Added preliminary render tests, missing some SDL functions to work properly.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
481 SDL_Surface *face;
3734
42356acbc993 Finished last of the render testcases.
Edgar Simo <bobbens@gmail.com>
parents: 3733
diff changeset
482 SDL_TextureID tface;
3730
dafd796f0c95 * Added preliminary render tests, missing some SDL functions to work properly.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
483 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
484 int mode;
dafd796f0c95 * Added preliminary render tests, missing some SDL functions to work properly.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
485
3734
42356acbc993 Finished last of the render testcases.
Edgar Simo <bobbens@gmail.com>
parents: 3733
diff changeset
486 /* Clear surface. */
42356acbc993 Finished last of the render testcases.
Edgar Simo <bobbens@gmail.com>
parents: 3733
diff changeset
487 if (render_clearScreen())
42356acbc993 Finished last of the render testcases.
Edgar Simo <bobbens@gmail.com>
parents: 3733
diff changeset
488 return -1;
3730
dafd796f0c95 * Added preliminary render tests, missing some SDL functions to work properly.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
489
3734
42356acbc993 Finished last of the render testcases.
Edgar Simo <bobbens@gmail.com>
parents: 3733
diff changeset
490 /* Create face surface. */
3730
dafd796f0c95 * Added preliminary render tests, missing some SDL functions to work properly.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
491 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
492 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
493 RMASK, GMASK, BMASK, AMASK );
dafd796f0c95 * Added preliminary render tests, missing some SDL functions to work properly.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
494 if (SDL_ATassert( "SDL_CreateRGBSurfaceFrom", face != NULL))
3734
42356acbc993 Finished last of the render testcases.
Edgar Simo <bobbens@gmail.com>
parents: 3733
diff changeset
495 return -1;
42356acbc993 Finished last of the render testcases.
Edgar Simo <bobbens@gmail.com>
parents: 3733
diff changeset
496 tface = SDL_CreateTextureFromSurface( 0, face );
42356acbc993 Finished last of the render testcases.
Edgar Simo <bobbens@gmail.com>
parents: 3733
diff changeset
497 if (SDL_ATassert( "SDL_CreateTextureFromSurface", tface != 0))
42356acbc993 Finished last of the render testcases.
Edgar Simo <bobbens@gmail.com>
parents: 3733
diff changeset
498 return -1;
42356acbc993 Finished last of the render testcases.
Edgar Simo <bobbens@gmail.com>
parents: 3733
diff changeset
499
42356acbc993 Finished last of the render testcases.
Edgar Simo <bobbens@gmail.com>
parents: 3733
diff changeset
500 /* Clean up. */
42356acbc993 Finished last of the render testcases.
Edgar Simo <bobbens@gmail.com>
parents: 3733
diff changeset
501 SDL_FreeSurface( face );
3730
dafd796f0c95 * Added preliminary render tests, missing some SDL functions to work properly.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
502
dafd796f0c95 * Added preliminary render tests, missing some SDL functions to work properly.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
503 /* Set alpha mod. */
3734
42356acbc993 Finished last of the render testcases.
Edgar Simo <bobbens@gmail.com>
parents: 3733
diff changeset
504 ret = SDL_SetRenderDrawColor( 255, 255, 255, 100 );
42356acbc993 Finished last of the render testcases.
Edgar Simo <bobbens@gmail.com>
parents: 3733
diff changeset
505 if (SDL_ATassert( "SDL_SetRenderDrawColor", ret == 0))
42356acbc993 Finished last of the render testcases.
Edgar Simo <bobbens@gmail.com>
parents: 3733
diff changeset
506 return -1;
3730
dafd796f0c95 * Added preliminary render tests, missing some SDL functions to work properly.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
507
dafd796f0c95 * Added preliminary render tests, missing some SDL functions to work properly.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
508 /* Steps to take. */
3734
42356acbc993 Finished last of the render testcases.
Edgar Simo <bobbens@gmail.com>
parents: 3733
diff changeset
509 ni = SCREEN_W - FACE_W;
42356acbc993 Finished last of the render testcases.
Edgar Simo <bobbens@gmail.com>
parents: 3733
diff changeset
510 nj = SCREEN_H - FACE_H;
3730
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 /* Constant values. */
dafd796f0c95 * Added preliminary render tests, missing some SDL functions to work properly.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
513 rect.w = face->w;
dafd796f0c95 * Added preliminary render tests, missing some SDL functions to work properly.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
514 rect.h = face->h;
dafd796f0c95 * Added preliminary render tests, missing some SDL functions to work properly.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
515
dafd796f0c95 * Added preliminary render tests, missing some SDL functions to work properly.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
516 /* Test None. */
3734
42356acbc993 Finished last of the render testcases.
Edgar Simo <bobbens@gmail.com>
parents: 3733
diff changeset
517 if (render_testBlitBlendMode( tface, SDL_BLENDMODE_NONE ))
42356acbc993 Finished last of the render testcases.
Edgar Simo <bobbens@gmail.com>
parents: 3733
diff changeset
518 return -1;
42356acbc993 Finished last of the render testcases.
Edgar Simo <bobbens@gmail.com>
parents: 3733
diff changeset
519 /* See if it's the same. */
42356acbc993 Finished last of the render testcases.
Edgar Simo <bobbens@gmail.com>
parents: 3733
diff changeset
520 if (render_compare( "Blit blending output not the same (using SDL_BLENDMODE_NONE).",
42356acbc993 Finished last of the render testcases.
Edgar Simo <bobbens@gmail.com>
parents: 3733
diff changeset
521 &img_blitAlpha ))
42356acbc993 Finished last of the render testcases.
Edgar Simo <bobbens@gmail.com>
parents: 3733
diff changeset
522 return -1;
3730
dafd796f0c95 * Added preliminary render tests, missing some SDL functions to work properly.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
523
dafd796f0c95 * Added preliminary render tests, missing some SDL functions to work properly.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
524 /* Test Mask. */
3734
42356acbc993 Finished last of the render testcases.
Edgar Simo <bobbens@gmail.com>
parents: 3733
diff changeset
525 if (render_testBlitBlendMode( tface, SDL_BLENDMODE_MASK ))
42356acbc993 Finished last of the render testcases.
Edgar Simo <bobbens@gmail.com>
parents: 3733
diff changeset
526 return -1;
42356acbc993 Finished last of the render testcases.
Edgar Simo <bobbens@gmail.com>
parents: 3733
diff changeset
527 if (render_compare( "Blit blending output not the same (using SDL_BLENDMODE_MASK).",
42356acbc993 Finished last of the render testcases.
Edgar Simo <bobbens@gmail.com>
parents: 3733
diff changeset
528 &img_blendMask ))
42356acbc993 Finished last of the render testcases.
Edgar Simo <bobbens@gmail.com>
parents: 3733
diff changeset
529 return -1;
3730
dafd796f0c95 * Added preliminary render tests, missing some SDL functions to work properly.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
530
dafd796f0c95 * Added preliminary render tests, missing some SDL functions to work properly.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
531 /* Test Blend. */
3734
42356acbc993 Finished last of the render testcases.
Edgar Simo <bobbens@gmail.com>
parents: 3733
diff changeset
532 if (render_testBlitBlendMode( tface, SDL_BLENDMODE_BLEND ))
42356acbc993 Finished last of the render testcases.
Edgar Simo <bobbens@gmail.com>
parents: 3733
diff changeset
533 return -1;
42356acbc993 Finished last of the render testcases.
Edgar Simo <bobbens@gmail.com>
parents: 3733
diff changeset
534 if (render_compare( "Blit blending output not the same (using SDL_BLENDMODE_BLEND).",
42356acbc993 Finished last of the render testcases.
Edgar Simo <bobbens@gmail.com>
parents: 3733
diff changeset
535 &img_blendBlend ))
42356acbc993 Finished last of the render testcases.
Edgar Simo <bobbens@gmail.com>
parents: 3733
diff changeset
536 return -1;
3730
dafd796f0c95 * Added preliminary render tests, missing some SDL functions to work properly.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
537
dafd796f0c95 * Added preliminary render tests, missing some SDL functions to work properly.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
538 /* Test Add. */
3734
42356acbc993 Finished last of the render testcases.
Edgar Simo <bobbens@gmail.com>
parents: 3733
diff changeset
539 if (render_testBlitBlendMode( tface, SDL_BLENDMODE_ADD ))
42356acbc993 Finished last of the render testcases.
Edgar Simo <bobbens@gmail.com>
parents: 3733
diff changeset
540 return -1;
42356acbc993 Finished last of the render testcases.
Edgar Simo <bobbens@gmail.com>
parents: 3733
diff changeset
541 if (render_compare( "Blit blending output not the same (using SDL_BLENDMODE_ADD).",
42356acbc993 Finished last of the render testcases.
Edgar Simo <bobbens@gmail.com>
parents: 3733
diff changeset
542 &img_blendAdd ))
42356acbc993 Finished last of the render testcases.
Edgar Simo <bobbens@gmail.com>
parents: 3733
diff changeset
543 return -1;
3730
dafd796f0c95 * Added preliminary render tests, missing some SDL functions to work properly.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
544
dafd796f0c95 * Added preliminary render tests, missing some SDL functions to work properly.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
545 /* Test Mod. */
3734
42356acbc993 Finished last of the render testcases.
Edgar Simo <bobbens@gmail.com>
parents: 3733
diff changeset
546 if (render_testBlitBlendMode( tface, SDL_BLENDMODE_MOD ))
42356acbc993 Finished last of the render testcases.
Edgar Simo <bobbens@gmail.com>
parents: 3733
diff changeset
547 return -1;
42356acbc993 Finished last of the render testcases.
Edgar Simo <bobbens@gmail.com>
parents: 3733
diff changeset
548 if (render_compare( "Blit blending output not the same (using SDL_BLENDMODE_MOD).",
42356acbc993 Finished last of the render testcases.
Edgar Simo <bobbens@gmail.com>
parents: 3733
diff changeset
549 &img_blendMod ))
42356acbc993 Finished last of the render testcases.
Edgar Simo <bobbens@gmail.com>
parents: 3733
diff changeset
550 return -1;
3730
dafd796f0c95 * Added preliminary render tests, missing some SDL functions to work properly.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
551
dafd796f0c95 * Added preliminary render tests, missing some SDL functions to work properly.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
552 /* Clear surface. */
3734
42356acbc993 Finished last of the render testcases.
Edgar Simo <bobbens@gmail.com>
parents: 3733
diff changeset
553 if (render_clearScreen())
42356acbc993 Finished last of the render testcases.
Edgar Simo <bobbens@gmail.com>
parents: 3733
diff changeset
554 return -1;
3730
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 /* Loop blit. */
dafd796f0c95 * Added preliminary render tests, missing some SDL functions to work properly.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
557 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
558 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
559
dafd796f0c95 * Added preliminary render tests, missing some SDL functions to work properly.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
560 /* Set colour mod. */
3734
42356acbc993 Finished last of the render testcases.
Edgar Simo <bobbens@gmail.com>
parents: 3733
diff changeset
561 ret = SDL_SetRenderDrawColor( (255/nj)*j, (255/ni)*i, (255/nj)*j, (100/ni)*i );
42356acbc993 Finished last of the render testcases.
Edgar Simo <bobbens@gmail.com>
parents: 3733
diff changeset
562 if (SDL_ATassert( "SDL_SetRenderDrawColor", ret == 0))
42356acbc993 Finished last of the render testcases.
Edgar Simo <bobbens@gmail.com>
parents: 3733
diff changeset
563 return -1;
3730
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 /* Crazy blending mode magic. */
dafd796f0c95 * Added preliminary render tests, missing some SDL functions to work properly.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
566 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
567 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
568 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
569 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
570 else if (mode==3) mode = SDL_BLENDMODE_MOD;
3734
42356acbc993 Finished last of the render testcases.
Edgar Simo <bobbens@gmail.com>
parents: 3733
diff changeset
571 ret = SDL_SetRenderDrawBlendMode( mode );
42356acbc993 Finished last of the render testcases.
Edgar Simo <bobbens@gmail.com>
parents: 3733
diff changeset
572 if (SDL_ATassert( "SDL_SetRenderDrawBlendMode", ret == 0))
42356acbc993 Finished last of the render testcases.
Edgar Simo <bobbens@gmail.com>
parents: 3733
diff changeset
573 return -1;
3730
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 /* Blitting. */
dafd796f0c95 * Added preliminary render tests, missing some SDL functions to work properly.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
576 rect.x = i;
dafd796f0c95 * Added preliminary render tests, missing some SDL functions to work properly.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
577 rect.y = j;
3734
42356acbc993 Finished last of the render testcases.
Edgar Simo <bobbens@gmail.com>
parents: 3733
diff changeset
578 ret = SDL_RenderCopy( tface, NULL, &rect );
42356acbc993 Finished last of the render testcases.
Edgar Simo <bobbens@gmail.com>
parents: 3733
diff changeset
579 if (SDL_ATassert( "SDL_RenderCopy", ret == 0))
42356acbc993 Finished last of the render testcases.
Edgar Simo <bobbens@gmail.com>
parents: 3733
diff changeset
580 return -1;
3730
dafd796f0c95 * Added preliminary render tests, missing some SDL functions to work properly.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
581 }
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
dafd796f0c95 * Added preliminary render tests, missing some SDL functions to work properly.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
584 /* Check to see if matches. */
3734
42356acbc993 Finished last of the render testcases.
Edgar Simo <bobbens@gmail.com>
parents: 3733
diff changeset
585 if (render_compare( "Blit blending output not the same (using SDL_BLENDMODE_*).",
42356acbc993 Finished last of the render testcases.
Edgar Simo <bobbens@gmail.com>
parents: 3733
diff changeset
586 &img_blendAll ))
42356acbc993 Finished last of the render testcases.
Edgar Simo <bobbens@gmail.com>
parents: 3733
diff changeset
587 return -1;
3730
dafd796f0c95 * Added preliminary render tests, missing some SDL functions to work properly.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
588
dafd796f0c95 * Added preliminary render tests, missing some SDL functions to work properly.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
589 /* Clean up. */
3734
42356acbc993 Finished last of the render testcases.
Edgar Simo <bobbens@gmail.com>
parents: 3733
diff changeset
590 SDL_DestroyTexture( tface );
3730
dafd796f0c95 * Added preliminary render tests, missing some SDL functions to work properly.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
591
3734
42356acbc993 Finished last of the render testcases.
Edgar Simo <bobbens@gmail.com>
parents: 3733
diff changeset
592 return 0;
3730
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 /**
dafd796f0c95 * Added preliminary render tests, missing some SDL functions to work properly.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
597 * @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
598 *
3734
42356acbc993 Finished last of the render testcases.
Edgar Simo <bobbens@gmail.com>
parents: 3733
diff changeset
599 * @return 0 on success.
3730
dafd796f0c95 * Added preliminary render tests, missing some SDL functions to work properly.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
600 */
3734
42356acbc993 Finished last of the render testcases.
Edgar Simo <bobbens@gmail.com>
parents: 3733
diff changeset
601 int render_runTests (void)
3730
dafd796f0c95 * Added preliminary render tests, missing some SDL functions to work properly.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
602 {
3734
42356acbc993 Finished last of the render testcases.
Edgar Simo <bobbens@gmail.com>
parents: 3733
diff changeset
603 int ret;
42356acbc993 Finished last of the render testcases.
Edgar Simo <bobbens@gmail.com>
parents: 3733
diff changeset
604
42356acbc993 Finished last of the render testcases.
Edgar Simo <bobbens@gmail.com>
parents: 3733
diff changeset
605 /* No error. */
42356acbc993 Finished last of the render testcases.
Edgar Simo <bobbens@gmail.com>
parents: 3733
diff changeset
606 ret = 0;
42356acbc993 Finished last of the render testcases.
Edgar Simo <bobbens@gmail.com>
parents: 3733
diff changeset
607
3730
dafd796f0c95 * Added preliminary render tests, missing some SDL functions to work properly.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
608 /* Software surface blitting. */
3734
42356acbc993 Finished last of the render testcases.
Edgar Simo <bobbens@gmail.com>
parents: 3733
diff changeset
609 ret |= render_testPrimitives();
42356acbc993 Finished last of the render testcases.
Edgar Simo <bobbens@gmail.com>
parents: 3733
diff changeset
610 if (ret)
42356acbc993 Finished last of the render testcases.
Edgar Simo <bobbens@gmail.com>
parents: 3733
diff changeset
611 return -1;
42356acbc993 Finished last of the render testcases.
Edgar Simo <bobbens@gmail.com>
parents: 3733
diff changeset
612 ret |= render_testPrimitivesBlend();
42356acbc993 Finished last of the render testcases.
Edgar Simo <bobbens@gmail.com>
parents: 3733
diff changeset
613 if (ret)
42356acbc993 Finished last of the render testcases.
Edgar Simo <bobbens@gmail.com>
parents: 3733
diff changeset
614 return -1;
42356acbc993 Finished last of the render testcases.
Edgar Simo <bobbens@gmail.com>
parents: 3733
diff changeset
615 ret |= render_testBlit();
42356acbc993 Finished last of the render testcases.
Edgar Simo <bobbens@gmail.com>
parents: 3733
diff changeset
616 if (ret)
42356acbc993 Finished last of the render testcases.
Edgar Simo <bobbens@gmail.com>
parents: 3733
diff changeset
617 return -1;
42356acbc993 Finished last of the render testcases.
Edgar Simo <bobbens@gmail.com>
parents: 3733
diff changeset
618 ret |= render_testBlitBlend();
42356acbc993 Finished last of the render testcases.
Edgar Simo <bobbens@gmail.com>
parents: 3733
diff changeset
619
42356acbc993 Finished last of the render testcases.
Edgar Simo <bobbens@gmail.com>
parents: 3733
diff changeset
620 return ret;
3730
dafd796f0c95 * Added preliminary render tests, missing some SDL functions to work properly.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
621 }
dafd796f0c95 * Added preliminary render tests, missing some SDL functions to work properly.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
622
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 /**
dafd796f0c95 * Added preliminary render tests, missing some SDL functions to work properly.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
625 * @brief Entry point.
dafd796f0c95 * Added preliminary render tests, missing some SDL functions to work properly.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
626 *
dafd796f0c95 * Added preliminary render tests, missing some SDL functions to work properly.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
627 * 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
628 * 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
629 * 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
630 * superfluous testsuites.
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 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
633 {
dafd796f0c95 * Added preliminary render tests, missing some SDL functions to work properly.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
634 (void) argc;
dafd796f0c95 * Added preliminary render tests, missing some SDL functions to work properly.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
635 (void) argv;
dafd796f0c95 * Added preliminary render tests, missing some SDL functions to work properly.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
636 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
637 int ret;
dafd796f0c95 * Added preliminary render tests, missing some SDL functions to work properly.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
638 const char *driver, *str;
dafd796f0c95 * Added preliminary render tests, missing some SDL functions to work properly.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
639 char msg[256];
dafd796f0c95 * Added preliminary render tests, missing some SDL functions to work properly.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
640 SDL_WindowID wid;
dafd796f0c95 * Added preliminary render tests, missing some SDL functions to work properly.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
641 SDL_RendererInfo renderer;
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 /* Initializes the SDL subsystems. */
dafd796f0c95 * Added preliminary render tests, missing some SDL functions to work properly.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
644 ret = SDL_Init(0);
dafd796f0c95 * Added preliminary render tests, missing some SDL functions to work properly.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
645 if (ret != 0)
dafd796f0c95 * Added preliminary render tests, missing some SDL functions to work properly.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
646 return -1;
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 /* Get number of drivers. */
dafd796f0c95 * Added preliminary render tests, missing some SDL functions to work properly.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
649 nd = SDL_GetNumVideoDrivers();
dafd796f0c95 * Added preliminary render tests, missing some SDL functions to work properly.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
650 if (ret < 0)
dafd796f0c95 * Added preliminary render tests, missing some SDL functions to work properly.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
651 goto err;
dafd796f0c95 * Added preliminary render tests, missing some SDL functions to work properly.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
652
dafd796f0c95 * Added preliminary render tests, missing some SDL functions to work properly.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
653 /* 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
654 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
655 if (ret != 0)
dafd796f0c95 * Added preliminary render tests, missing some SDL functions to work properly.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
656 goto err;
dafd796f0c95 * Added preliminary render tests, missing some SDL functions to work properly.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
657
dafd796f0c95 * Added preliminary render tests, missing some SDL functions to work properly.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
658 /*
dafd796f0c95 * Added preliminary render tests, missing some SDL functions to work properly.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
659 * 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
660 */
dafd796f0c95 * Added preliminary render tests, missing some SDL functions to work properly.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
661 /* 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
662 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
663 /* Get video mode. */
dafd796f0c95 * Added preliminary render tests, missing some SDL functions to work properly.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
664 driver = SDL_GetVideoDriver(i);
dafd796f0c95 * Added preliminary render tests, missing some SDL functions to work properly.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
665 if (driver == NULL)
dafd796f0c95 * Added preliminary render tests, missing some SDL functions to work properly.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
666 goto err;
dafd796f0c95 * Added preliminary render tests, missing some SDL functions to work properly.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
667 /* 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
668 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
669 continue;
dafd796f0c95 * Added preliminary render tests, missing some SDL functions to work properly.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
670
dafd796f0c95 * Added preliminary render tests, missing some SDL functions to work properly.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
671 /*
dafd796f0c95 * Added preliminary render tests, missing some SDL functions to work properly.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
672 * Initialize testsuite.
dafd796f0c95 * Added preliminary render tests, missing some SDL functions to work properly.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
673 */
dafd796f0c95 * Added preliminary render tests, missing some SDL functions to work properly.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
674 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
675 SDL_ATinit( msg );
dafd796f0c95 * Added preliminary render tests, missing some SDL functions to work properly.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
676
dafd796f0c95 * Added preliminary render tests, missing some SDL functions to work properly.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
677 /*
dafd796f0c95 * Added preliminary render tests, missing some SDL functions to work properly.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
678 * Initialize.
dafd796f0c95 * Added preliminary render tests, missing some SDL functions to work properly.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
679 */
dafd796f0c95 * Added preliminary render tests, missing some SDL functions to work properly.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
680 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
681 /* Initialize video mode. */
dafd796f0c95 * Added preliminary render tests, missing some SDL functions to work properly.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
682 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
683 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
684 goto err;
dafd796f0c95 * Added preliminary render tests, missing some SDL functions to work properly.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
685 /* 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
686 str = SDL_GetCurrentVideoDriver();
dafd796f0c95 * Added preliminary render tests, missing some SDL functions to work properly.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
687 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
688 goto err;
dafd796f0c95 * Added preliminary render tests, missing some SDL functions to work properly.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
689 /* Create window. */
dafd796f0c95 * Added preliminary render tests, missing some SDL functions to work properly.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
690 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
691 80, 60, 0 );
dafd796f0c95 * Added preliminary render tests, missing some SDL functions to work properly.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
692 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
693 goto err;
dafd796f0c95 * Added preliminary render tests, missing some SDL functions to work properly.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
694 /* Check title. */
dafd796f0c95 * Added preliminary render tests, missing some SDL functions to work properly.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
695 str = SDL_GetWindowTitle( wid );
dafd796f0c95 * Added preliminary render tests, missing some SDL functions to work properly.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
696 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
697 goto err;
dafd796f0c95 * Added preliminary render tests, missing some SDL functions to work properly.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
698 /* Get renderers. */
dafd796f0c95 * Added preliminary render tests, missing some SDL functions to work properly.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
699 nr = SDL_GetNumRenderDrivers();
dafd796f0c95 * Added preliminary render tests, missing some SDL functions to work properly.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
700 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
701 goto err;
dafd796f0c95 * Added preliminary render tests, missing some SDL functions to work properly.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
702 SDL_ATend();
dafd796f0c95 * Added preliminary render tests, missing some SDL functions to work properly.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
703 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
704
dafd796f0c95 * Added preliminary render tests, missing some SDL functions to work properly.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
705 /* Get renderer info. */
dafd796f0c95 * Added preliminary render tests, missing some SDL functions to work properly.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
706 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
707 if (ret != 0)
dafd796f0c95 * Added preliminary render tests, missing some SDL functions to work properly.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
708 goto err;
dafd796f0c95 * Added preliminary render tests, missing some SDL functions to work properly.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
709 /* Set testcase name. */
dafd796f0c95 * Added preliminary render tests, missing some SDL functions to work properly.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
710 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
711 SDL_ATbegin( msg );
dafd796f0c95 * Added preliminary render tests, missing some SDL functions to work properly.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
712 /* Set renderer. */
dafd796f0c95 * Added preliminary render tests, missing some SDL functions to work properly.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
713 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
714 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
715 goto err;
dafd796f0c95 * Added preliminary render tests, missing some SDL functions to work properly.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
716
dafd796f0c95 * Added preliminary render tests, missing some SDL functions to work properly.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
717 /*
dafd796f0c95 * Added preliminary render tests, missing some SDL functions to work properly.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
718 * Run tests.
dafd796f0c95 * Added preliminary render tests, missing some SDL functions to work properly.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
719 */
3734
42356acbc993 Finished last of the render testcases.
Edgar Simo <bobbens@gmail.com>
parents: 3733
diff changeset
720 if (render_runTests())
42356acbc993 Finished last of the render testcases.
Edgar Simo <bobbens@gmail.com>
parents: 3733
diff changeset
721 continue;
3730
dafd796f0c95 * Added preliminary render tests, missing some SDL functions to work properly.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
722
dafd796f0c95 * Added preliminary render tests, missing some SDL functions to work properly.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
723 SDL_ATend();
dafd796f0c95 * Added preliminary render tests, missing some SDL functions to work properly.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
724 }
dafd796f0c95 * Added preliminary render tests, missing some SDL functions to work properly.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
725
dafd796f0c95 * Added preliminary render tests, missing some SDL functions to work properly.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
726 /* Exit the current renderer. */
dafd796f0c95 * Added preliminary render tests, missing some SDL functions to work properly.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
727 SDL_VideoQuit();
dafd796f0c95 * Added preliminary render tests, missing some SDL functions to work properly.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
728
dafd796f0c95 * Added preliminary render tests, missing some SDL functions to work properly.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
729 /*
dafd796f0c95 * Added preliminary render tests, missing some SDL functions to work properly.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
730 * Finish testsuite.
dafd796f0c95 * Added preliminary render tests, missing some SDL functions to work properly.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
731 */
dafd796f0c95 * Added preliminary render tests, missing some SDL functions to work properly.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
732 SDL_ATfinish(1);
dafd796f0c95 * Added preliminary render tests, missing some SDL functions to work properly.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
733 }
dafd796f0c95 * Added preliminary render tests, missing some SDL functions to work properly.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
734
dafd796f0c95 * Added preliminary render tests, missing some SDL functions to work properly.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
735
dafd796f0c95 * Added preliminary render tests, missing some SDL functions to work properly.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
736 /* Exit SDL. */
dafd796f0c95 * Added preliminary render tests, missing some SDL functions to work properly.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
737 SDL_Quit();
dafd796f0c95 * Added preliminary render tests, missing some SDL functions to work properly.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
738
dafd796f0c95 * Added preliminary render tests, missing some SDL functions to work properly.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
739 return 0;
dafd796f0c95 * Added preliminary render tests, missing some SDL functions to work properly.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
740
dafd796f0c95 * Added preliminary render tests, missing some SDL functions to work properly.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
741 err:
dafd796f0c95 * Added preliminary render tests, missing some SDL functions to work properly.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
742 return -1;
dafd796f0c95 * Added preliminary render tests, missing some SDL functions to work properly.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
743 }
dafd796f0c95 * Added preliminary render tests, missing some SDL functions to work properly.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
744