annotate test/automated/render/render.c @ 3753:5b48a529fd8a gsoc2009_unit_tests

More debugging information when test fails.
author Edgar Simo <bobbens@gmail.com>
date Thu, 06 Aug 2009 08:39:42 +0000
parents f7a3a47e6b50
children
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 );
3739
651b261e591d Wrapper around return codes to check to see if is supported.
Edgar Simo <bobbens@gmail.com>
parents: 3738
diff changeset
33 static int render_isSupported( int code );
3735
27b4b4d71011 Test for capabilities for each test.
Edgar Simo <bobbens@gmail.com>
parents: 3734
diff changeset
34 static int render_hasDrawColor (void);
27b4b4d71011 Test for capabilities for each test.
Edgar Simo <bobbens@gmail.com>
parents: 3734
diff changeset
35 static int render_hasBlendModes (void);
27b4b4d71011 Test for capabilities for each test.
Edgar Simo <bobbens@gmail.com>
parents: 3734
diff changeset
36 static int render_hasTexColor (void);
27b4b4d71011 Test for capabilities for each test.
Edgar Simo <bobbens@gmail.com>
parents: 3734
diff changeset
37 static int render_hasTexAlpha (void);
3730
dafd796f0c95 * Added preliminary render tests, missing some SDL functions to work properly.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
38 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
39 /* Testcases. */
3734
42356acbc993 Finished last of the render testcases.
Edgar Simo <bobbens@gmail.com>
parents: 3733
diff changeset
40 static int render_testPrimitives (void);
42356acbc993 Finished last of the render testcases.
Edgar Simo <bobbens@gmail.com>
parents: 3733
diff changeset
41 static int render_testPrimitivesBlend (void);
42356acbc993 Finished last of the render testcases.
Edgar Simo <bobbens@gmail.com>
parents: 3733
diff changeset
42 static int render_testBlit (void);
3735
27b4b4d71011 Test for capabilities for each test.
Edgar Simo <bobbens@gmail.com>
parents: 3734
diff changeset
43 static int render_testBlitColour (void);
27b4b4d71011 Test for capabilities for each test.
Edgar Simo <bobbens@gmail.com>
parents: 3734
diff changeset
44 static int render_testBlitAlpha (void);
3734
42356acbc993 Finished last of the render testcases.
Edgar Simo <bobbens@gmail.com>
parents: 3733
diff changeset
45 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
46 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
47
dafd796f0c95 * Added preliminary render tests, missing some SDL functions to work properly.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
48
dafd796f0c95 * Added preliminary render tests, missing some SDL functions to work properly.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
49 /**
3735
27b4b4d71011 Test for capabilities for each test.
Edgar Simo <bobbens@gmail.com>
parents: 3734
diff changeset
50 * @brief Compares screen pixels with image pixels.
27b4b4d71011 Test for capabilities for each test.
Edgar Simo <bobbens@gmail.com>
parents: 3734
diff changeset
51 *
27b4b4d71011 Test for capabilities for each test.
Edgar Simo <bobbens@gmail.com>
parents: 3734
diff changeset
52 * @param msg Message on failure.
27b4b4d71011 Test for capabilities for each test.
Edgar Simo <bobbens@gmail.com>
parents: 3734
diff changeset
53 * @param s Image to compare against.
27b4b4d71011 Test for capabilities for each test.
Edgar Simo <bobbens@gmail.com>
parents: 3734
diff changeset
54 * @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
55 */
dafd796f0c95 * Added preliminary render tests, missing some SDL functions to work properly.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
56 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
57 {
3734
42356acbc993 Finished last of the render testcases.
Edgar Simo <bobbens@gmail.com>
parents: 3733
diff changeset
58 (void) msg;
42356acbc993 Finished last of the render testcases.
Edgar Simo <bobbens@gmail.com>
parents: 3733
diff changeset
59 (void) s;
3730
dafd796f0c95 * Added preliminary render tests, missing some SDL functions to work properly.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
60 int ret;
dafd796f0c95 * Added preliminary render tests, missing some SDL functions to work properly.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
61 void *pix;
dafd796f0c95 * Added preliminary render tests, missing some SDL functions to work properly.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
62 SDL_Surface *testsur;
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 /* Allocate pixel space. */
dafd796f0c95 * Added preliminary render tests, missing some SDL functions to work properly.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
65 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
66 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
67 return 1;
dafd796f0c95 * Added preliminary render tests, missing some SDL functions to work properly.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
68
dafd796f0c95 * Added preliminary render tests, missing some SDL functions to work properly.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
69 /* Read pixels. */
3738
c875baafce36 Changed placeholder for SDL_ReadPixels.
Edgar Simo <bobbens@gmail.com>
parents: 3735
diff changeset
70 #if 0
3730
dafd796f0c95 * Added preliminary render tests, missing some SDL functions to work properly.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
71 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
72 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
73 return 1;
3738
c875baafce36 Changed placeholder for SDL_ReadPixels.
Edgar Simo <bobbens@gmail.com>
parents: 3735
diff changeset
74 #else
c875baafce36 Changed placeholder for SDL_ReadPixels.
Edgar Simo <bobbens@gmail.com>
parents: 3735
diff changeset
75 int i, j;
c875baafce36 Changed placeholder for SDL_ReadPixels.
Edgar Simo <bobbens@gmail.com>
parents: 3735
diff changeset
76 Uint8 *buf = pix;
c875baafce36 Changed placeholder for SDL_ReadPixels.
Edgar Simo <bobbens@gmail.com>
parents: 3735
diff changeset
77 const Uint8 *read_pix;
c875baafce36 Changed placeholder for SDL_ReadPixels.
Edgar Simo <bobbens@gmail.com>
parents: 3735
diff changeset
78 Uint8 *write_pix;
c875baafce36 Changed placeholder for SDL_ReadPixels.
Edgar Simo <bobbens@gmail.com>
parents: 3735
diff changeset
79 for (j=0; j<s->height; j++) {
c875baafce36 Changed placeholder for SDL_ReadPixels.
Edgar Simo <bobbens@gmail.com>
parents: 3735
diff changeset
80 for (i=0; i<s->width; i++) {
c875baafce36 Changed placeholder for SDL_ReadPixels.
Edgar Simo <bobbens@gmail.com>
parents: 3735
diff changeset
81 read_pix = &s->pixel_data[ (j*80 + i) * s->bytes_per_pixel ];
c875baafce36 Changed placeholder for SDL_ReadPixels.
Edgar Simo <bobbens@gmail.com>
parents: 3735
diff changeset
82 write_pix = &buf[ (j*80 + i) * 4 ];
c875baafce36 Changed placeholder for SDL_ReadPixels.
Edgar Simo <bobbens@gmail.com>
parents: 3735
diff changeset
83 write_pix[0] = read_pix[0];
c875baafce36 Changed placeholder for SDL_ReadPixels.
Edgar Simo <bobbens@gmail.com>
parents: 3735
diff changeset
84 write_pix[1] = read_pix[1];
c875baafce36 Changed placeholder for SDL_ReadPixels.
Edgar Simo <bobbens@gmail.com>
parents: 3735
diff changeset
85 write_pix[2] = read_pix[2];
c875baafce36 Changed placeholder for SDL_ReadPixels.
Edgar Simo <bobbens@gmail.com>
parents: 3735
diff changeset
86 write_pix[3] = SDL_ALPHA_OPAQUE;
c875baafce36 Changed placeholder for SDL_ReadPixels.
Edgar Simo <bobbens@gmail.com>
parents: 3735
diff changeset
87 }
c875baafce36 Changed placeholder for SDL_ReadPixels.
Edgar Simo <bobbens@gmail.com>
parents: 3735
diff changeset
88 }
c875baafce36 Changed placeholder for SDL_ReadPixels.
Edgar Simo <bobbens@gmail.com>
parents: 3735
diff changeset
89 #endif
3730
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 /* Create surface. */
dafd796f0c95 * Added preliminary render tests, missing some SDL functions to work properly.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
92 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
93 RMASK, GMASK, BMASK, AMASK );
dafd796f0c95 * Added preliminary render tests, missing some SDL functions to work properly.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
94 if (SDL_ATassert( "SDL_CreateRGBSurfaceFrom", testsur!=NULL ))
dafd796f0c95 * Added preliminary render tests, missing some SDL functions to work properly.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
95 return 1;
dafd796f0c95 * Added preliminary render tests, missing some SDL functions to work properly.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
96
dafd796f0c95 * Added preliminary render tests, missing some SDL functions to work properly.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
97 /* Compare surface. */
dafd796f0c95 * Added preliminary render tests, missing some SDL functions to work properly.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
98 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
99 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
100 return 1;
dafd796f0c95 * Added preliminary render tests, missing some SDL functions to work properly.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
101
dafd796f0c95 * Added preliminary render tests, missing some SDL functions to work properly.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
102 /* Clean up. */
dafd796f0c95 * Added preliminary render tests, missing some SDL functions to work properly.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
103 SDL_FreeSurface( testsur );
dafd796f0c95 * Added preliminary render tests, missing some SDL functions to work properly.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
104 free(pix);
dafd796f0c95 * Added preliminary render tests, missing some SDL functions to work properly.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
105
dafd796f0c95 * Added preliminary render tests, missing some SDL functions to work properly.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
106 return 0;
dafd796f0c95 * Added preliminary render tests, missing some SDL functions to work properly.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
107 }
dafd796f0c95 * Added preliminary render tests, missing some SDL functions to work properly.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
108
3735
27b4b4d71011 Test for capabilities for each test.
Edgar Simo <bobbens@gmail.com>
parents: 3734
diff changeset
109
27b4b4d71011 Test for capabilities for each test.
Edgar Simo <bobbens@gmail.com>
parents: 3734
diff changeset
110 /**
3739
651b261e591d Wrapper around return codes to check to see if is supported.
Edgar Simo <bobbens@gmail.com>
parents: 3738
diff changeset
111 * @brief Checks to see if functionality is supported.
651b261e591d Wrapper around return codes to check to see if is supported.
Edgar Simo <bobbens@gmail.com>
parents: 3738
diff changeset
112 */
651b261e591d Wrapper around return codes to check to see if is supported.
Edgar Simo <bobbens@gmail.com>
parents: 3738
diff changeset
113 static int render_isSupported( int code )
651b261e591d Wrapper around return codes to check to see if is supported.
Edgar Simo <bobbens@gmail.com>
parents: 3738
diff changeset
114 {
651b261e591d Wrapper around return codes to check to see if is supported.
Edgar Simo <bobbens@gmail.com>
parents: 3738
diff changeset
115 return (code == 0);
651b261e591d Wrapper around return codes to check to see if is supported.
Edgar Simo <bobbens@gmail.com>
parents: 3738
diff changeset
116 }
651b261e591d Wrapper around return codes to check to see if is supported.
Edgar Simo <bobbens@gmail.com>
parents: 3738
diff changeset
117
651b261e591d Wrapper around return codes to check to see if is supported.
Edgar Simo <bobbens@gmail.com>
parents: 3738
diff changeset
118
651b261e591d Wrapper around return codes to check to see if is supported.
Edgar Simo <bobbens@gmail.com>
parents: 3738
diff changeset
119 /**
3735
27b4b4d71011 Test for capabilities for each test.
Edgar Simo <bobbens@gmail.com>
parents: 3734
diff changeset
120 * @brief Test to see if we can vary the draw colour.
27b4b4d71011 Test for capabilities for each test.
Edgar Simo <bobbens@gmail.com>
parents: 3734
diff changeset
121 */
27b4b4d71011 Test for capabilities for each test.
Edgar Simo <bobbens@gmail.com>
parents: 3734
diff changeset
122 static int render_hasDrawColor (void)
27b4b4d71011 Test for capabilities for each test.
Edgar Simo <bobbens@gmail.com>
parents: 3734
diff changeset
123 {
3739
651b261e591d Wrapper around return codes to check to see if is supported.
Edgar Simo <bobbens@gmail.com>
parents: 3738
diff changeset
124 int ret, fail;
3735
27b4b4d71011 Test for capabilities for each test.
Edgar Simo <bobbens@gmail.com>
parents: 3734
diff changeset
125 Uint8 r, g, b, a;
27b4b4d71011 Test for capabilities for each test.
Edgar Simo <bobbens@gmail.com>
parents: 3734
diff changeset
126
3739
651b261e591d Wrapper around return codes to check to see if is supported.
Edgar Simo <bobbens@gmail.com>
parents: 3738
diff changeset
127 fail = 0;
651b261e591d Wrapper around return codes to check to see if is supported.
Edgar Simo <bobbens@gmail.com>
parents: 3738
diff changeset
128
3735
27b4b4d71011 Test for capabilities for each test.
Edgar Simo <bobbens@gmail.com>
parents: 3734
diff changeset
129 /* Set colour. */
3739
651b261e591d Wrapper around return codes to check to see if is supported.
Edgar Simo <bobbens@gmail.com>
parents: 3738
diff changeset
130 ret = SDL_SetRenderDrawColor( 100, 100, 100, 100 );
651b261e591d Wrapper around return codes to check to see if is supported.
Edgar Simo <bobbens@gmail.com>
parents: 3738
diff changeset
131 if (!render_isSupported(ret))
651b261e591d Wrapper around return codes to check to see if is supported.
Edgar Simo <bobbens@gmail.com>
parents: 3738
diff changeset
132 fail = 1;
651b261e591d Wrapper around return codes to check to see if is supported.
Edgar Simo <bobbens@gmail.com>
parents: 3738
diff changeset
133 ret = SDL_GetRenderDrawColor( &r, &g, &b, &a );
651b261e591d Wrapper around return codes to check to see if is supported.
Edgar Simo <bobbens@gmail.com>
parents: 3738
diff changeset
134 if (!render_isSupported(ret))
651b261e591d Wrapper around return codes to check to see if is supported.
Edgar Simo <bobbens@gmail.com>
parents: 3738
diff changeset
135 fail = 1;
3735
27b4b4d71011 Test for capabilities for each test.
Edgar Simo <bobbens@gmail.com>
parents: 3734
diff changeset
136 /* Restore natural. */
3739
651b261e591d Wrapper around return codes to check to see if is supported.
Edgar Simo <bobbens@gmail.com>
parents: 3738
diff changeset
137 ret = SDL_SetRenderDrawColor( 0, 0, 0, SDL_ALPHA_OPAQUE );
651b261e591d Wrapper around return codes to check to see if is supported.
Edgar Simo <bobbens@gmail.com>
parents: 3738
diff changeset
138 if (!render_isSupported(ret))
651b261e591d Wrapper around return codes to check to see if is supported.
Edgar Simo <bobbens@gmail.com>
parents: 3738
diff changeset
139 fail = 1;
3735
27b4b4d71011 Test for capabilities for each test.
Edgar Simo <bobbens@gmail.com>
parents: 3734
diff changeset
140
27b4b4d71011 Test for capabilities for each test.
Edgar Simo <bobbens@gmail.com>
parents: 3734
diff changeset
141 /* Something failed, consider not available. */
3739
651b261e591d Wrapper around return codes to check to see if is supported.
Edgar Simo <bobbens@gmail.com>
parents: 3738
diff changeset
142 if (fail)
3735
27b4b4d71011 Test for capabilities for each test.
Edgar Simo <bobbens@gmail.com>
parents: 3734
diff changeset
143 return 0;
27b4b4d71011 Test for capabilities for each test.
Edgar Simo <bobbens@gmail.com>
parents: 3734
diff changeset
144 /* Not set properly, consider failed. */
27b4b4d71011 Test for capabilities for each test.
Edgar Simo <bobbens@gmail.com>
parents: 3734
diff changeset
145 else if ((r != 100) || (g != 100) || (b != 100) || (a != 100))
27b4b4d71011 Test for capabilities for each test.
Edgar Simo <bobbens@gmail.com>
parents: 3734
diff changeset
146 return 0;
27b4b4d71011 Test for capabilities for each test.
Edgar Simo <bobbens@gmail.com>
parents: 3734
diff changeset
147 return 1;
27b4b4d71011 Test for capabilities for each test.
Edgar Simo <bobbens@gmail.com>
parents: 3734
diff changeset
148 }
27b4b4d71011 Test for capabilities for each test.
Edgar Simo <bobbens@gmail.com>
parents: 3734
diff changeset
149
27b4b4d71011 Test for capabilities for each test.
Edgar Simo <bobbens@gmail.com>
parents: 3734
diff changeset
150
27b4b4d71011 Test for capabilities for each test.
Edgar Simo <bobbens@gmail.com>
parents: 3734
diff changeset
151 /**
27b4b4d71011 Test for capabilities for each test.
Edgar Simo <bobbens@gmail.com>
parents: 3734
diff changeset
152 * @brief Test to see if we can vary the blend mode.
27b4b4d71011 Test for capabilities for each test.
Edgar Simo <bobbens@gmail.com>
parents: 3734
diff changeset
153 */
27b4b4d71011 Test for capabilities for each test.
Edgar Simo <bobbens@gmail.com>
parents: 3734
diff changeset
154 static int render_hasBlendModes (void)
27b4b4d71011 Test for capabilities for each test.
Edgar Simo <bobbens@gmail.com>
parents: 3734
diff changeset
155 {
3739
651b261e591d Wrapper around return codes to check to see if is supported.
Edgar Simo <bobbens@gmail.com>
parents: 3738
diff changeset
156 int fail;
3735
27b4b4d71011 Test for capabilities for each test.
Edgar Simo <bobbens@gmail.com>
parents: 3734
diff changeset
157 int ret;
27b4b4d71011 Test for capabilities for each test.
Edgar Simo <bobbens@gmail.com>
parents: 3734
diff changeset
158 int mode;
27b4b4d71011 Test for capabilities for each test.
Edgar Simo <bobbens@gmail.com>
parents: 3734
diff changeset
159
3739
651b261e591d Wrapper around return codes to check to see if is supported.
Edgar Simo <bobbens@gmail.com>
parents: 3738
diff changeset
160 fail = 0;
3735
27b4b4d71011 Test for capabilities for each test.
Edgar Simo <bobbens@gmail.com>
parents: 3734
diff changeset
161
3739
651b261e591d Wrapper around return codes to check to see if is supported.
Edgar Simo <bobbens@gmail.com>
parents: 3738
diff changeset
162 ret = SDL_SetRenderDrawBlendMode( SDL_BLENDMODE_BLEND );
651b261e591d Wrapper around return codes to check to see if is supported.
Edgar Simo <bobbens@gmail.com>
parents: 3738
diff changeset
163 if (!render_isSupported(ret))
651b261e591d Wrapper around return codes to check to see if is supported.
Edgar Simo <bobbens@gmail.com>
parents: 3738
diff changeset
164 fail = 1;
651b261e591d Wrapper around return codes to check to see if is supported.
Edgar Simo <bobbens@gmail.com>
parents: 3738
diff changeset
165 ret = SDL_GetRenderDrawBlendMode( &mode );
651b261e591d Wrapper around return codes to check to see if is supported.
Edgar Simo <bobbens@gmail.com>
parents: 3738
diff changeset
166 if (!render_isSupported(ret))
651b261e591d Wrapper around return codes to check to see if is supported.
Edgar Simo <bobbens@gmail.com>
parents: 3738
diff changeset
167 fail = 1;
651b261e591d Wrapper around return codes to check to see if is supported.
Edgar Simo <bobbens@gmail.com>
parents: 3738
diff changeset
168 ret = (mode != SDL_BLENDMODE_BLEND);
651b261e591d Wrapper around return codes to check to see if is supported.
Edgar Simo <bobbens@gmail.com>
parents: 3738
diff changeset
169 if (!render_isSupported(ret))
651b261e591d Wrapper around return codes to check to see if is supported.
Edgar Simo <bobbens@gmail.com>
parents: 3738
diff changeset
170 fail = 1;
651b261e591d Wrapper around return codes to check to see if is supported.
Edgar Simo <bobbens@gmail.com>
parents: 3738
diff changeset
171 ret = SDL_SetRenderDrawBlendMode( SDL_BLENDMODE_ADD );
651b261e591d Wrapper around return codes to check to see if is supported.
Edgar Simo <bobbens@gmail.com>
parents: 3738
diff changeset
172 if (!render_isSupported(ret))
651b261e591d Wrapper around return codes to check to see if is supported.
Edgar Simo <bobbens@gmail.com>
parents: 3738
diff changeset
173 fail = 1;
651b261e591d Wrapper around return codes to check to see if is supported.
Edgar Simo <bobbens@gmail.com>
parents: 3738
diff changeset
174 ret = SDL_GetRenderDrawBlendMode( &mode );
651b261e591d Wrapper around return codes to check to see if is supported.
Edgar Simo <bobbens@gmail.com>
parents: 3738
diff changeset
175 if (!render_isSupported(ret))
651b261e591d Wrapper around return codes to check to see if is supported.
Edgar Simo <bobbens@gmail.com>
parents: 3738
diff changeset
176 fail = 1;
651b261e591d Wrapper around return codes to check to see if is supported.
Edgar Simo <bobbens@gmail.com>
parents: 3738
diff changeset
177 ret = (mode != SDL_BLENDMODE_ADD);
651b261e591d Wrapper around return codes to check to see if is supported.
Edgar Simo <bobbens@gmail.com>
parents: 3738
diff changeset
178 if (!render_isSupported(ret))
651b261e591d Wrapper around return codes to check to see if is supported.
Edgar Simo <bobbens@gmail.com>
parents: 3738
diff changeset
179 fail = 1;
651b261e591d Wrapper around return codes to check to see if is supported.
Edgar Simo <bobbens@gmail.com>
parents: 3738
diff changeset
180 ret = SDL_SetRenderDrawBlendMode( SDL_BLENDMODE_MOD );
651b261e591d Wrapper around return codes to check to see if is supported.
Edgar Simo <bobbens@gmail.com>
parents: 3738
diff changeset
181 if (!render_isSupported(ret))
651b261e591d Wrapper around return codes to check to see if is supported.
Edgar Simo <bobbens@gmail.com>
parents: 3738
diff changeset
182 fail = 1;
651b261e591d Wrapper around return codes to check to see if is supported.
Edgar Simo <bobbens@gmail.com>
parents: 3738
diff changeset
183 ret = SDL_GetRenderDrawBlendMode( &mode );
651b261e591d Wrapper around return codes to check to see if is supported.
Edgar Simo <bobbens@gmail.com>
parents: 3738
diff changeset
184 if (!render_isSupported(ret))
651b261e591d Wrapper around return codes to check to see if is supported.
Edgar Simo <bobbens@gmail.com>
parents: 3738
diff changeset
185 fail = 1;
651b261e591d Wrapper around return codes to check to see if is supported.
Edgar Simo <bobbens@gmail.com>
parents: 3738
diff changeset
186 ret = (mode != SDL_BLENDMODE_MOD);
651b261e591d Wrapper around return codes to check to see if is supported.
Edgar Simo <bobbens@gmail.com>
parents: 3738
diff changeset
187 if (!render_isSupported(ret))
651b261e591d Wrapper around return codes to check to see if is supported.
Edgar Simo <bobbens@gmail.com>
parents: 3738
diff changeset
188 fail = 1;
651b261e591d Wrapper around return codes to check to see if is supported.
Edgar Simo <bobbens@gmail.com>
parents: 3738
diff changeset
189 ret = SDL_SetRenderDrawBlendMode( SDL_BLENDMODE_MASK );
651b261e591d Wrapper around return codes to check to see if is supported.
Edgar Simo <bobbens@gmail.com>
parents: 3738
diff changeset
190 if (!render_isSupported(ret))
651b261e591d Wrapper around return codes to check to see if is supported.
Edgar Simo <bobbens@gmail.com>
parents: 3738
diff changeset
191 fail = 1;
651b261e591d Wrapper around return codes to check to see if is supported.
Edgar Simo <bobbens@gmail.com>
parents: 3738
diff changeset
192 ret = SDL_GetRenderDrawBlendMode( &mode );
651b261e591d Wrapper around return codes to check to see if is supported.
Edgar Simo <bobbens@gmail.com>
parents: 3738
diff changeset
193 if (!render_isSupported(ret))
651b261e591d Wrapper around return codes to check to see if is supported.
Edgar Simo <bobbens@gmail.com>
parents: 3738
diff changeset
194 fail = 1;
651b261e591d Wrapper around return codes to check to see if is supported.
Edgar Simo <bobbens@gmail.com>
parents: 3738
diff changeset
195 ret = (mode != SDL_BLENDMODE_MASK);
651b261e591d Wrapper around return codes to check to see if is supported.
Edgar Simo <bobbens@gmail.com>
parents: 3738
diff changeset
196 if (!render_isSupported(ret))
651b261e591d Wrapper around return codes to check to see if is supported.
Edgar Simo <bobbens@gmail.com>
parents: 3738
diff changeset
197 fail = 1;
651b261e591d Wrapper around return codes to check to see if is supported.
Edgar Simo <bobbens@gmail.com>
parents: 3738
diff changeset
198 ret = SDL_SetRenderDrawBlendMode( SDL_BLENDMODE_NONE );
651b261e591d Wrapper around return codes to check to see if is supported.
Edgar Simo <bobbens@gmail.com>
parents: 3738
diff changeset
199 if (!render_isSupported(ret))
651b261e591d Wrapper around return codes to check to see if is supported.
Edgar Simo <bobbens@gmail.com>
parents: 3738
diff changeset
200 fail = 1;
651b261e591d Wrapper around return codes to check to see if is supported.
Edgar Simo <bobbens@gmail.com>
parents: 3738
diff changeset
201 ret = SDL_GetRenderDrawBlendMode( &mode );
651b261e591d Wrapper around return codes to check to see if is supported.
Edgar Simo <bobbens@gmail.com>
parents: 3738
diff changeset
202 if (!render_isSupported(ret))
651b261e591d Wrapper around return codes to check to see if is supported.
Edgar Simo <bobbens@gmail.com>
parents: 3738
diff changeset
203 fail = 1;
651b261e591d Wrapper around return codes to check to see if is supported.
Edgar Simo <bobbens@gmail.com>
parents: 3738
diff changeset
204 ret = (mode != SDL_BLENDMODE_NONE);
651b261e591d Wrapper around return codes to check to see if is supported.
Edgar Simo <bobbens@gmail.com>
parents: 3738
diff changeset
205 if (!render_isSupported(ret))
651b261e591d Wrapper around return codes to check to see if is supported.
Edgar Simo <bobbens@gmail.com>
parents: 3738
diff changeset
206 fail = 1;
651b261e591d Wrapper around return codes to check to see if is supported.
Edgar Simo <bobbens@gmail.com>
parents: 3738
diff changeset
207
651b261e591d Wrapper around return codes to check to see if is supported.
Edgar Simo <bobbens@gmail.com>
parents: 3738
diff changeset
208 return !fail;
3735
27b4b4d71011 Test for capabilities for each test.
Edgar Simo <bobbens@gmail.com>
parents: 3734
diff changeset
209 }
27b4b4d71011 Test for capabilities for each test.
Edgar Simo <bobbens@gmail.com>
parents: 3734
diff changeset
210
27b4b4d71011 Test for capabilities for each test.
Edgar Simo <bobbens@gmail.com>
parents: 3734
diff changeset
211
27b4b4d71011 Test for capabilities for each test.
Edgar Simo <bobbens@gmail.com>
parents: 3734
diff changeset
212 /**
27b4b4d71011 Test for capabilities for each test.
Edgar Simo <bobbens@gmail.com>
parents: 3734
diff changeset
213 * @brief Loads the test face.
27b4b4d71011 Test for capabilities for each test.
Edgar Simo <bobbens@gmail.com>
parents: 3734
diff changeset
214 */
27b4b4d71011 Test for capabilities for each test.
Edgar Simo <bobbens@gmail.com>
parents: 3734
diff changeset
215 static SDL_TextureID render_loadTestFace (void)
27b4b4d71011 Test for capabilities for each test.
Edgar Simo <bobbens@gmail.com>
parents: 3734
diff changeset
216 {
27b4b4d71011 Test for capabilities for each test.
Edgar Simo <bobbens@gmail.com>
parents: 3734
diff changeset
217 SDL_Surface *face;
27b4b4d71011 Test for capabilities for each test.
Edgar Simo <bobbens@gmail.com>
parents: 3734
diff changeset
218 SDL_TextureID tface;
27b4b4d71011 Test for capabilities for each test.
Edgar Simo <bobbens@gmail.com>
parents: 3734
diff changeset
219
27b4b4d71011 Test for capabilities for each test.
Edgar Simo <bobbens@gmail.com>
parents: 3734
diff changeset
220 /* Create face surface. */
27b4b4d71011 Test for capabilities for each test.
Edgar Simo <bobbens@gmail.com>
parents: 3734
diff changeset
221 face = SDL_CreateRGBSurfaceFrom( (void*)img_face.pixel_data,
27b4b4d71011 Test for capabilities for each test.
Edgar Simo <bobbens@gmail.com>
parents: 3734
diff changeset
222 img_face.width, img_face.height, 32, img_face.width*4,
27b4b4d71011 Test for capabilities for each test.
Edgar Simo <bobbens@gmail.com>
parents: 3734
diff changeset
223 RMASK, GMASK, BMASK, AMASK );
27b4b4d71011 Test for capabilities for each test.
Edgar Simo <bobbens@gmail.com>
parents: 3734
diff changeset
224 if (face == NULL)
27b4b4d71011 Test for capabilities for each test.
Edgar Simo <bobbens@gmail.com>
parents: 3734
diff changeset
225 return 0;
27b4b4d71011 Test for capabilities for each test.
Edgar Simo <bobbens@gmail.com>
parents: 3734
diff changeset
226 tface = SDL_CreateTextureFromSurface( 0, face );
27b4b4d71011 Test for capabilities for each test.
Edgar Simo <bobbens@gmail.com>
parents: 3734
diff changeset
227 SDL_FreeSurface(face);
27b4b4d71011 Test for capabilities for each test.
Edgar Simo <bobbens@gmail.com>
parents: 3734
diff changeset
228
27b4b4d71011 Test for capabilities for each test.
Edgar Simo <bobbens@gmail.com>
parents: 3734
diff changeset
229 return tface;
27b4b4d71011 Test for capabilities for each test.
Edgar Simo <bobbens@gmail.com>
parents: 3734
diff changeset
230 }
27b4b4d71011 Test for capabilities for each test.
Edgar Simo <bobbens@gmail.com>
parents: 3734
diff changeset
231
27b4b4d71011 Test for capabilities for each test.
Edgar Simo <bobbens@gmail.com>
parents: 3734
diff changeset
232
27b4b4d71011 Test for capabilities for each test.
Edgar Simo <bobbens@gmail.com>
parents: 3734
diff changeset
233 /**
27b4b4d71011 Test for capabilities for each test.
Edgar Simo <bobbens@gmail.com>
parents: 3734
diff changeset
234 * @brief Test to see if can set texture colour mode.
27b4b4d71011 Test for capabilities for each test.
Edgar Simo <bobbens@gmail.com>
parents: 3734
diff changeset
235 */
27b4b4d71011 Test for capabilities for each test.
Edgar Simo <bobbens@gmail.com>
parents: 3734
diff changeset
236 static int render_hasTexColor (void)
27b4b4d71011 Test for capabilities for each test.
Edgar Simo <bobbens@gmail.com>
parents: 3734
diff changeset
237 {
3739
651b261e591d Wrapper around return codes to check to see if is supported.
Edgar Simo <bobbens@gmail.com>
parents: 3738
diff changeset
238 int fail;
3735
27b4b4d71011 Test for capabilities for each test.
Edgar Simo <bobbens@gmail.com>
parents: 3734
diff changeset
239 int ret;
27b4b4d71011 Test for capabilities for each test.
Edgar Simo <bobbens@gmail.com>
parents: 3734
diff changeset
240 SDL_TextureID tface;
27b4b4d71011 Test for capabilities for each test.
Edgar Simo <bobbens@gmail.com>
parents: 3734
diff changeset
241 Uint8 r, g, b;
27b4b4d71011 Test for capabilities for each test.
Edgar Simo <bobbens@gmail.com>
parents: 3734
diff changeset
242
27b4b4d71011 Test for capabilities for each test.
Edgar Simo <bobbens@gmail.com>
parents: 3734
diff changeset
243 /* Get test face. */
27b4b4d71011 Test for capabilities for each test.
Edgar Simo <bobbens@gmail.com>
parents: 3734
diff changeset
244 tface = render_loadTestFace();
27b4b4d71011 Test for capabilities for each test.
Edgar Simo <bobbens@gmail.com>
parents: 3734
diff changeset
245 if (tface == 0)
27b4b4d71011 Test for capabilities for each test.
Edgar Simo <bobbens@gmail.com>
parents: 3734
diff changeset
246 return 0;
27b4b4d71011 Test for capabilities for each test.
Edgar Simo <bobbens@gmail.com>
parents: 3734
diff changeset
247
27b4b4d71011 Test for capabilities for each test.
Edgar Simo <bobbens@gmail.com>
parents: 3734
diff changeset
248 /* See if supported. */
3739
651b261e591d Wrapper around return codes to check to see if is supported.
Edgar Simo <bobbens@gmail.com>
parents: 3738
diff changeset
249 fail = 0;
651b261e591d Wrapper around return codes to check to see if is supported.
Edgar Simo <bobbens@gmail.com>
parents: 3738
diff changeset
250 ret = SDL_SetTextureColorMod( tface, 100, 100, 100 );
651b261e591d Wrapper around return codes to check to see if is supported.
Edgar Simo <bobbens@gmail.com>
parents: 3738
diff changeset
251 if (!render_isSupported(ret))
651b261e591d Wrapper around return codes to check to see if is supported.
Edgar Simo <bobbens@gmail.com>
parents: 3738
diff changeset
252 fail = 1;
651b261e591d Wrapper around return codes to check to see if is supported.
Edgar Simo <bobbens@gmail.com>
parents: 3738
diff changeset
253 ret = SDL_GetTextureColorMod( tface, &r, &g, &b );
651b261e591d Wrapper around return codes to check to see if is supported.
Edgar Simo <bobbens@gmail.com>
parents: 3738
diff changeset
254 if (!render_isSupported(ret))
651b261e591d Wrapper around return codes to check to see if is supported.
Edgar Simo <bobbens@gmail.com>
parents: 3738
diff changeset
255 fail = 1;
3735
27b4b4d71011 Test for capabilities for each test.
Edgar Simo <bobbens@gmail.com>
parents: 3734
diff changeset
256
27b4b4d71011 Test for capabilities for each test.
Edgar Simo <bobbens@gmail.com>
parents: 3734
diff changeset
257 /* Clean up. */
27b4b4d71011 Test for capabilities for each test.
Edgar Simo <bobbens@gmail.com>
parents: 3734
diff changeset
258 SDL_DestroyTexture( tface );
27b4b4d71011 Test for capabilities for each test.
Edgar Simo <bobbens@gmail.com>
parents: 3734
diff changeset
259
3739
651b261e591d Wrapper around return codes to check to see if is supported.
Edgar Simo <bobbens@gmail.com>
parents: 3738
diff changeset
260 if (fail)
3735
27b4b4d71011 Test for capabilities for each test.
Edgar Simo <bobbens@gmail.com>
parents: 3734
diff changeset
261 return 0;
27b4b4d71011 Test for capabilities for each test.
Edgar Simo <bobbens@gmail.com>
parents: 3734
diff changeset
262 else if ((r != 100) || (g != 100) || (b != 100))
27b4b4d71011 Test for capabilities for each test.
Edgar Simo <bobbens@gmail.com>
parents: 3734
diff changeset
263 return 0;
27b4b4d71011 Test for capabilities for each test.
Edgar Simo <bobbens@gmail.com>
parents: 3734
diff changeset
264 return 1;
27b4b4d71011 Test for capabilities for each test.
Edgar Simo <bobbens@gmail.com>
parents: 3734
diff changeset
265 }
27b4b4d71011 Test for capabilities for each test.
Edgar Simo <bobbens@gmail.com>
parents: 3734
diff changeset
266
27b4b4d71011 Test for capabilities for each test.
Edgar Simo <bobbens@gmail.com>
parents: 3734
diff changeset
267
27b4b4d71011 Test for capabilities for each test.
Edgar Simo <bobbens@gmail.com>
parents: 3734
diff changeset
268 /**
27b4b4d71011 Test for capabilities for each test.
Edgar Simo <bobbens@gmail.com>
parents: 3734
diff changeset
269 * @brief Test to see if we can vary the alpha of the texture.
27b4b4d71011 Test for capabilities for each test.
Edgar Simo <bobbens@gmail.com>
parents: 3734
diff changeset
270 */
27b4b4d71011 Test for capabilities for each test.
Edgar Simo <bobbens@gmail.com>
parents: 3734
diff changeset
271 static int render_hasTexAlpha (void)
27b4b4d71011 Test for capabilities for each test.
Edgar Simo <bobbens@gmail.com>
parents: 3734
diff changeset
272 {
3739
651b261e591d Wrapper around return codes to check to see if is supported.
Edgar Simo <bobbens@gmail.com>
parents: 3738
diff changeset
273 int fail;
3735
27b4b4d71011 Test for capabilities for each test.
Edgar Simo <bobbens@gmail.com>
parents: 3734
diff changeset
274 int ret;
27b4b4d71011 Test for capabilities for each test.
Edgar Simo <bobbens@gmail.com>
parents: 3734
diff changeset
275 SDL_TextureID tface;
27b4b4d71011 Test for capabilities for each test.
Edgar Simo <bobbens@gmail.com>
parents: 3734
diff changeset
276 Uint8 a;
27b4b4d71011 Test for capabilities for each test.
Edgar Simo <bobbens@gmail.com>
parents: 3734
diff changeset
277
27b4b4d71011 Test for capabilities for each test.
Edgar Simo <bobbens@gmail.com>
parents: 3734
diff changeset
278 /* Get test face. */
27b4b4d71011 Test for capabilities for each test.
Edgar Simo <bobbens@gmail.com>
parents: 3734
diff changeset
279 tface = render_loadTestFace();
27b4b4d71011 Test for capabilities for each test.
Edgar Simo <bobbens@gmail.com>
parents: 3734
diff changeset
280 if (tface == 0)
27b4b4d71011 Test for capabilities for each test.
Edgar Simo <bobbens@gmail.com>
parents: 3734
diff changeset
281 return 0;
27b4b4d71011 Test for capabilities for each test.
Edgar Simo <bobbens@gmail.com>
parents: 3734
diff changeset
282
27b4b4d71011 Test for capabilities for each test.
Edgar Simo <bobbens@gmail.com>
parents: 3734
diff changeset
283 /* See if supported. */
3739
651b261e591d Wrapper around return codes to check to see if is supported.
Edgar Simo <bobbens@gmail.com>
parents: 3738
diff changeset
284 fail = 0;
651b261e591d Wrapper around return codes to check to see if is supported.
Edgar Simo <bobbens@gmail.com>
parents: 3738
diff changeset
285 ret = SDL_SetTextureAlphaMod( tface, 100 );
651b261e591d Wrapper around return codes to check to see if is supported.
Edgar Simo <bobbens@gmail.com>
parents: 3738
diff changeset
286 if (!render_isSupported(ret))
651b261e591d Wrapper around return codes to check to see if is supported.
Edgar Simo <bobbens@gmail.com>
parents: 3738
diff changeset
287 fail = 1;
651b261e591d Wrapper around return codes to check to see if is supported.
Edgar Simo <bobbens@gmail.com>
parents: 3738
diff changeset
288 ret = SDL_GetTextureAlphaMod( tface, &a );
651b261e591d Wrapper around return codes to check to see if is supported.
Edgar Simo <bobbens@gmail.com>
parents: 3738
diff changeset
289 if (!render_isSupported(ret))
651b261e591d Wrapper around return codes to check to see if is supported.
Edgar Simo <bobbens@gmail.com>
parents: 3738
diff changeset
290 fail = 1;
3735
27b4b4d71011 Test for capabilities for each test.
Edgar Simo <bobbens@gmail.com>
parents: 3734
diff changeset
291
27b4b4d71011 Test for capabilities for each test.
Edgar Simo <bobbens@gmail.com>
parents: 3734
diff changeset
292 /* Clean up. */
27b4b4d71011 Test for capabilities for each test.
Edgar Simo <bobbens@gmail.com>
parents: 3734
diff changeset
293 SDL_DestroyTexture( tface );
27b4b4d71011 Test for capabilities for each test.
Edgar Simo <bobbens@gmail.com>
parents: 3734
diff changeset
294
3739
651b261e591d Wrapper around return codes to check to see if is supported.
Edgar Simo <bobbens@gmail.com>
parents: 3738
diff changeset
295 if (fail)
3735
27b4b4d71011 Test for capabilities for each test.
Edgar Simo <bobbens@gmail.com>
parents: 3734
diff changeset
296 return 0;
27b4b4d71011 Test for capabilities for each test.
Edgar Simo <bobbens@gmail.com>
parents: 3734
diff changeset
297 else if (a != 100)
27b4b4d71011 Test for capabilities for each test.
Edgar Simo <bobbens@gmail.com>
parents: 3734
diff changeset
298 return 0;
27b4b4d71011 Test for capabilities for each test.
Edgar Simo <bobbens@gmail.com>
parents: 3734
diff changeset
299 return 1;
27b4b4d71011 Test for capabilities for each test.
Edgar Simo <bobbens@gmail.com>
parents: 3734
diff changeset
300 }
27b4b4d71011 Test for capabilities for each test.
Edgar Simo <bobbens@gmail.com>
parents: 3734
diff changeset
301
27b4b4d71011 Test for capabilities for each test.
Edgar Simo <bobbens@gmail.com>
parents: 3734
diff changeset
302
3730
dafd796f0c95 * Added preliminary render tests, missing some SDL functions to work properly.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
303 /**
dafd796f0c95 * Added preliminary render tests, missing some SDL functions to work properly.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
304 * @brief Clears the screen.
3735
27b4b4d71011 Test for capabilities for each test.
Edgar Simo <bobbens@gmail.com>
parents: 3734
diff changeset
305 *
27b4b4d71011 Test for capabilities for each test.
Edgar Simo <bobbens@gmail.com>
parents: 3734
diff changeset
306 * @note We don't test for errors, but they shouldn't happen.
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 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
309 {
dafd796f0c95 * Added preliminary render tests, missing some SDL functions to work properly.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
310 int ret;
dafd796f0c95 * Added preliminary render tests, missing some SDL functions to work properly.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
311
dafd796f0c95 * Added preliminary render tests, missing some SDL functions to work properly.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
312 /* Set colour. */
dafd796f0c95 * Added preliminary render tests, missing some SDL functions to work properly.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
313 ret = SDL_SetRenderDrawColor( 0, 0, 0, SDL_ALPHA_OPAQUE );
3735
27b4b4d71011 Test for capabilities for each test.
Edgar Simo <bobbens@gmail.com>
parents: 3734
diff changeset
314 /*
3730
dafd796f0c95 * Added preliminary render tests, missing some SDL functions to work properly.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
315 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
316 return -1;
3735
27b4b4d71011 Test for capabilities for each test.
Edgar Simo <bobbens@gmail.com>
parents: 3734
diff changeset
317 */
3730
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 /* Clear screen. */
dafd796f0c95 * Added preliminary render tests, missing some SDL functions to work properly.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
320 ret = SDL_RenderFill( NULL );
3735
27b4b4d71011 Test for capabilities for each test.
Edgar Simo <bobbens@gmail.com>
parents: 3734
diff changeset
321 /*
3730
dafd796f0c95 * Added preliminary render tests, missing some SDL functions to work properly.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
322 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
323 return -1;
3735
27b4b4d71011 Test for capabilities for each test.
Edgar Simo <bobbens@gmail.com>
parents: 3734
diff changeset
324 */
3730
dafd796f0c95 * Added preliminary render tests, missing some SDL functions to work properly.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
325
3733
ca544951b504 Finished converting the blit testcase.
Edgar Simo <bobbens@gmail.com>
parents: 3731
diff changeset
326 /* Set defaults. */
ca544951b504 Finished converting the blit testcase.
Edgar Simo <bobbens@gmail.com>
parents: 3731
diff changeset
327 ret = SDL_SetRenderDrawBlendMode( SDL_BLENDMODE_NONE );
3735
27b4b4d71011 Test for capabilities for each test.
Edgar Simo <bobbens@gmail.com>
parents: 3734
diff changeset
328 /*
3733
ca544951b504 Finished converting the blit testcase.
Edgar Simo <bobbens@gmail.com>
parents: 3731
diff changeset
329 if (SDL_ATassert( "SDL_SetRenderDrawBlendMode", ret == 0))
ca544951b504 Finished converting the blit testcase.
Edgar Simo <bobbens@gmail.com>
parents: 3731
diff changeset
330 return -1;
3735
27b4b4d71011 Test for capabilities for each test.
Edgar Simo <bobbens@gmail.com>
parents: 3734
diff changeset
331 */
3733
ca544951b504 Finished converting the blit testcase.
Edgar Simo <bobbens@gmail.com>
parents: 3731
diff changeset
332 ret = SDL_SetRenderDrawColor( 255, 255, 255, SDL_ALPHA_OPAQUE );
3735
27b4b4d71011 Test for capabilities for each test.
Edgar Simo <bobbens@gmail.com>
parents: 3734
diff changeset
333 /*
3733
ca544951b504 Finished converting the blit testcase.
Edgar Simo <bobbens@gmail.com>
parents: 3731
diff changeset
334 if (SDL_ATassert( "SDL_SetRenderDrawColor", ret == 0))
ca544951b504 Finished converting the blit testcase.
Edgar Simo <bobbens@gmail.com>
parents: 3731
diff changeset
335 return -1;
3735
27b4b4d71011 Test for capabilities for each test.
Edgar Simo <bobbens@gmail.com>
parents: 3734
diff changeset
336 */
3733
ca544951b504 Finished converting the blit testcase.
Edgar Simo <bobbens@gmail.com>
parents: 3731
diff changeset
337
3730
dafd796f0c95 * Added preliminary render tests, missing some SDL functions to work properly.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
338 return 0;
dafd796f0c95 * Added preliminary render tests, missing some SDL functions to work properly.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
339 }
dafd796f0c95 * Added preliminary render tests, missing some SDL functions to work properly.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
340
dafd796f0c95 * Added preliminary render tests, missing some SDL functions to work properly.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
341
dafd796f0c95 * Added preliminary render tests, missing some SDL functions to work properly.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
342 /**
dafd796f0c95 * Added preliminary render tests, missing some SDL functions to work properly.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
343 * @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
344 */
3734
42356acbc993 Finished last of the render testcases.
Edgar Simo <bobbens@gmail.com>
parents: 3733
diff changeset
345 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
346 {
dafd796f0c95 * Added preliminary render tests, missing some SDL functions to work properly.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
347 int ret;
dafd796f0c95 * Added preliminary render tests, missing some SDL functions to work properly.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
348 int x, y;
dafd796f0c95 * Added preliminary render tests, missing some SDL functions to work properly.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
349 SDL_Rect rect;
dafd796f0c95 * Added preliminary render tests, missing some SDL functions to work properly.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
350
dafd796f0c95 * Added preliminary render tests, missing some SDL functions to work properly.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
351 /* Clear surface. */
dafd796f0c95 * Added preliminary render tests, missing some SDL functions to work properly.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
352 if (render_clearScreen())
3734
42356acbc993 Finished last of the render testcases.
Edgar Simo <bobbens@gmail.com>
parents: 3733
diff changeset
353 return -1;
3730
dafd796f0c95 * Added preliminary render tests, missing some SDL functions to work properly.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
354
3735
27b4b4d71011 Test for capabilities for each test.
Edgar Simo <bobbens@gmail.com>
parents: 3734
diff changeset
355 /* Need drawcolour or just skip test. */
27b4b4d71011 Test for capabilities for each test.
Edgar Simo <bobbens@gmail.com>
parents: 3734
diff changeset
356 if (!render_hasDrawColor())
27b4b4d71011 Test for capabilities for each test.
Edgar Simo <bobbens@gmail.com>
parents: 3734
diff changeset
357 return 0;
27b4b4d71011 Test for capabilities for each test.
Edgar Simo <bobbens@gmail.com>
parents: 3734
diff changeset
358
3730
dafd796f0c95 * Added preliminary render tests, missing some SDL functions to work properly.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
359 /* Draw a rectangle. */
dafd796f0c95 * Added preliminary render tests, missing some SDL functions to work properly.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
360 rect.x = 40;
dafd796f0c95 * Added preliminary render tests, missing some SDL functions to work properly.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
361 rect.y = 0;
dafd796f0c95 * Added preliminary render tests, missing some SDL functions to work properly.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
362 rect.w = 40;
dafd796f0c95 * Added preliminary render tests, missing some SDL functions to work properly.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
363 rect.h = 80;
dafd796f0c95 * Added preliminary render tests, missing some SDL functions to work properly.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
364 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
365 if (SDL_ATassert( "SDL_SetRenderDrawColor", ret == 0))
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 ret = SDL_RenderFill( &rect );
dafd796f0c95 * Added preliminary render tests, missing some SDL functions to work properly.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
368 if (SDL_ATassert( "SDL_RenderRect", ret == 0))
3734
42356acbc993 Finished last of the render testcases.
Edgar Simo <bobbens@gmail.com>
parents: 3733
diff changeset
369 return -1;
3730
dafd796f0c95 * Added preliminary render tests, missing some SDL functions to work properly.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
370
dafd796f0c95 * Added preliminary render tests, missing some SDL functions to work properly.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
371 /* Draw a rectangle. */
dafd796f0c95 * Added preliminary render tests, missing some SDL functions to work properly.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
372 rect.x = 10;
dafd796f0c95 * Added preliminary render tests, missing some SDL functions to work properly.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
373 rect.y = 10;
dafd796f0c95 * Added preliminary render tests, missing some SDL functions to work properly.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
374 rect.w = 60;
dafd796f0c95 * Added preliminary render tests, missing some SDL functions to work properly.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
375 rect.h = 40;
dafd796f0c95 * Added preliminary render tests, missing some SDL functions to work properly.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
376 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
377 if (SDL_ATassert( "SDL_SetRenderDrawColor", 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 ret = SDL_RenderFill( &rect );
dafd796f0c95 * Added preliminary render tests, missing some SDL functions to work properly.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
380 if (SDL_ATassert( "SDL_RenderRect", ret == 0))
3734
42356acbc993 Finished last of the render testcases.
Edgar Simo <bobbens@gmail.com>
parents: 3733
diff changeset
381 return -1;
3730
dafd796f0c95 * Added preliminary render tests, missing some SDL functions to work properly.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
382
dafd796f0c95 * Added preliminary render tests, missing some SDL functions to work properly.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
383 /* 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
384 * X.X.X.X..
dafd796f0c95 * Added preliminary render tests, missing some SDL functions to work properly.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
385 * .X.X.X.X.
dafd796f0c95 * Added preliminary render tests, missing some SDL functions to work properly.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
386 * X.X.X.X.. */
dafd796f0c95 * Added preliminary render tests, missing some SDL functions to work properly.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
387 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
388 x = y % 2;
dafd796f0c95 * Added preliminary render tests, missing some SDL functions to work properly.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
389 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
390 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
391 if (SDL_ATassert( "SDL_SetRenderDrawColor", ret == 0))
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 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
394 if (SDL_ATassert( "SDL_RenderPoint", ret == 0))
3734
42356acbc993 Finished last of the render testcases.
Edgar Simo <bobbens@gmail.com>
parents: 3733
diff changeset
395 return -1;
3730
dafd796f0c95 * Added preliminary render tests, missing some SDL functions to work properly.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
396 }
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
dafd796f0c95 * Added preliminary render tests, missing some SDL functions to work properly.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
399 /* Draw some lines. */
dafd796f0c95 * Added preliminary render tests, missing some SDL functions to work properly.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
400 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
401 if (SDL_ATassert( "SDL_SetRenderDrawColor", ret == 0))
3734
42356acbc993 Finished last of the render testcases.
Edgar Simo <bobbens@gmail.com>
parents: 3733
diff changeset
402 return -1;
3730
dafd796f0c95 * Added preliminary render tests, missing some SDL functions to work properly.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
403 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
404 if (SDL_ATassert( "SDL_RenderLine", ret == 0))
3734
42356acbc993 Finished last of the render testcases.
Edgar Simo <bobbens@gmail.com>
parents: 3733
diff changeset
405 return -1;
3730
dafd796f0c95 * Added preliminary render tests, missing some SDL functions to work properly.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
406 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
407 if (SDL_ATassert( "SDL_SetRenderDrawColor", ret == 0))
3734
42356acbc993 Finished last of the render testcases.
Edgar Simo <bobbens@gmail.com>
parents: 3733
diff changeset
408 return -1;
3730
dafd796f0c95 * Added preliminary render tests, missing some SDL functions to work properly.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
409 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
410 if (SDL_ATassert( "SDL_RenderLine", ret == 0))
3734
42356acbc993 Finished last of the render testcases.
Edgar Simo <bobbens@gmail.com>
parents: 3733
diff changeset
411 return -1;
3730
dafd796f0c95 * Added preliminary render tests, missing some SDL functions to work properly.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
412 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
413 if (SDL_ATassert( "SDL_SetRenderDrawColor", ret == 0))
3734
42356acbc993 Finished last of the render testcases.
Edgar Simo <bobbens@gmail.com>
parents: 3733
diff changeset
414 return -1;
3730
dafd796f0c95 * Added preliminary render tests, missing some SDL functions to work properly.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
415 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
416 if (SDL_ATassert( "SDL_RenderLine", ret == 0))
3734
42356acbc993 Finished last of the render testcases.
Edgar Simo <bobbens@gmail.com>
parents: 3733
diff changeset
417 return -1;
3730
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 /* 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
420 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
421 return -1;
42356acbc993 Finished last of the render testcases.
Edgar Simo <bobbens@gmail.com>
parents: 3733
diff changeset
422
42356acbc993 Finished last of the render testcases.
Edgar Simo <bobbens@gmail.com>
parents: 3733
diff changeset
423 return 0;
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
dafd796f0c95 * Added preliminary render tests, missing some SDL functions to work properly.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
426
dafd796f0c95 * Added preliminary render tests, missing some SDL functions to work properly.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
427 /**
dafd796f0c95 * Added preliminary render tests, missing some SDL functions to work properly.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
428 * @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
429 */
3734
42356acbc993 Finished last of the render testcases.
Edgar Simo <bobbens@gmail.com>
parents: 3733
diff changeset
430 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
431 {
dafd796f0c95 * Added preliminary render tests, missing some SDL functions to work properly.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
432 int ret;
dafd796f0c95 * Added preliminary render tests, missing some SDL functions to work properly.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
433 int i, j;
dafd796f0c95 * Added preliminary render tests, missing some SDL functions to work properly.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
434 SDL_Rect rect;
dafd796f0c95 * Added preliminary render tests, missing some SDL functions to work properly.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
435
dafd796f0c95 * Added preliminary render tests, missing some SDL functions to work properly.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
436 /* Clear surface. */
3731
f5ddf1b670f0 Converted another testcase to the render system.
Edgar Simo <bobbens@gmail.com>
parents: 3730
diff changeset
437 if (render_clearScreen())
3734
42356acbc993 Finished last of the render testcases.
Edgar Simo <bobbens@gmail.com>
parents: 3733
diff changeset
438 return -1;
3730
dafd796f0c95 * Added preliminary render tests, missing some SDL functions to work properly.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
439
3735
27b4b4d71011 Test for capabilities for each test.
Edgar Simo <bobbens@gmail.com>
parents: 3734
diff changeset
440 /* Need drawcolour and blendmode or just skip test. */
27b4b4d71011 Test for capabilities for each test.
Edgar Simo <bobbens@gmail.com>
parents: 3734
diff changeset
441 if (!render_hasDrawColor() || !render_hasBlendModes())
27b4b4d71011 Test for capabilities for each test.
Edgar Simo <bobbens@gmail.com>
parents: 3734
diff changeset
442 return 0;
3733
ca544951b504 Finished converting the blit testcase.
Edgar Simo <bobbens@gmail.com>
parents: 3731
diff changeset
443
3730
dafd796f0c95 * Added preliminary render tests, missing some SDL functions to work properly.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
444 /* 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
445 ret = SDL_SetRenderDrawColor( 255, 255, 255, 0 );
f5ddf1b670f0 Converted another testcase to the render system.
Edgar Simo <bobbens@gmail.com>
parents: 3730
diff changeset
446 if (SDL_ATassert( "SDL_SetRenderDrawColor", ret == 0))
3734
42356acbc993 Finished last of the render testcases.
Edgar Simo <bobbens@gmail.com>
parents: 3733
diff changeset
447 return -1;
3731
f5ddf1b670f0 Converted another testcase to the render system.
Edgar Simo <bobbens@gmail.com>
parents: 3730
diff changeset
448 ret = SDL_SetRenderDrawBlendMode( SDL_BLENDMODE_NONE );
3733
ca544951b504 Finished converting the blit testcase.
Edgar Simo <bobbens@gmail.com>
parents: 3731
diff changeset
449 if (SDL_ATassert( "SDL_SetRenderDrawBlendMode", ret == 0))
3734
42356acbc993 Finished last of the render testcases.
Edgar Simo <bobbens@gmail.com>
parents: 3733
diff changeset
450 return -1;
3731
f5ddf1b670f0 Converted another testcase to the render system.
Edgar Simo <bobbens@gmail.com>
parents: 3730
diff changeset
451 ret = SDL_RenderFill( NULL );
f5ddf1b670f0 Converted another testcase to the render system.
Edgar Simo <bobbens@gmail.com>
parents: 3730
diff changeset
452 if (SDL_ATassert( "SDL_RenderFill", ret == 0))
3734
42356acbc993 Finished last of the render testcases.
Edgar Simo <bobbens@gmail.com>
parents: 3733
diff changeset
453 return -1;
3730
dafd796f0c95 * Added preliminary render tests, missing some SDL functions to work properly.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
454 rect.x = 10;
dafd796f0c95 * Added preliminary render tests, missing some SDL functions to work properly.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
455 rect.y = 25;
dafd796f0c95 * Added preliminary render tests, missing some SDL functions to work properly.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
456 rect.w = 40;
dafd796f0c95 * Added preliminary render tests, missing some SDL functions to work properly.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
457 rect.h = 25;
3731
f5ddf1b670f0 Converted another testcase to the render system.
Edgar Simo <bobbens@gmail.com>
parents: 3730
diff changeset
458 ret = SDL_SetRenderDrawColor( 240, 10, 10, 75 );
f5ddf1b670f0 Converted another testcase to the render system.
Edgar Simo <bobbens@gmail.com>
parents: 3730
diff changeset
459 if (SDL_ATassert( "SDL_SetRenderDrawColor", ret == 0))
3734
42356acbc993 Finished last of the render testcases.
Edgar Simo <bobbens@gmail.com>
parents: 3733
diff changeset
460 return -1;
3731
f5ddf1b670f0 Converted another testcase to the render system.
Edgar Simo <bobbens@gmail.com>
parents: 3730
diff changeset
461 ret = SDL_SetRenderDrawBlendMode( SDL_BLENDMODE_ADD );
3733
ca544951b504 Finished converting the blit testcase.
Edgar Simo <bobbens@gmail.com>
parents: 3731
diff changeset
462 if (SDL_ATassert( "SDL_SetRenderDrawBlendMode", ret == 0))
3734
42356acbc993 Finished last of the render testcases.
Edgar Simo <bobbens@gmail.com>
parents: 3733
diff changeset
463 return -1;
3731
f5ddf1b670f0 Converted another testcase to the render system.
Edgar Simo <bobbens@gmail.com>
parents: 3730
diff changeset
464 ret = SDL_RenderFill( &rect );
f5ddf1b670f0 Converted another testcase to the render system.
Edgar Simo <bobbens@gmail.com>
parents: 3730
diff changeset
465 if (SDL_ATassert( "SDL_RenderFill", ret == 0))
3734
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 rect.x = 30;
dafd796f0c95 * Added preliminary render tests, missing some SDL functions to work properly.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
468 rect.y = 40;
dafd796f0c95 * Added preliminary render tests, missing some SDL functions to work properly.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
469 rect.w = 45;
dafd796f0c95 * Added preliminary render tests, missing some SDL functions to work properly.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
470 rect.h = 15;
3731
f5ddf1b670f0 Converted another testcase to the render system.
Edgar Simo <bobbens@gmail.com>
parents: 3730
diff changeset
471 ret = SDL_SetRenderDrawColor( 10, 240, 10, 100 );
f5ddf1b670f0 Converted another testcase to the render system.
Edgar Simo <bobbens@gmail.com>
parents: 3730
diff changeset
472 if (SDL_ATassert( "SDL_SetRenderDrawColor", ret == 0))
3734
42356acbc993 Finished last of the render testcases.
Edgar Simo <bobbens@gmail.com>
parents: 3733
diff changeset
473 return -1;
3731
f5ddf1b670f0 Converted another testcase to the render system.
Edgar Simo <bobbens@gmail.com>
parents: 3730
diff changeset
474 ret = SDL_SetRenderDrawBlendMode( SDL_BLENDMODE_BLEND );
3733
ca544951b504 Finished converting the blit testcase.
Edgar Simo <bobbens@gmail.com>
parents: 3731
diff changeset
475 if (SDL_ATassert( "SDL_SetRenderDrawBlendMode", ret == 0))
3734
42356acbc993 Finished last of the render testcases.
Edgar Simo <bobbens@gmail.com>
parents: 3733
diff changeset
476 return -1;
3731
f5ddf1b670f0 Converted another testcase to the render system.
Edgar Simo <bobbens@gmail.com>
parents: 3730
diff changeset
477 ret = SDL_RenderFill( &rect );
f5ddf1b670f0 Converted another testcase to the render system.
Edgar Simo <bobbens@gmail.com>
parents: 3730
diff changeset
478 if (SDL_ATassert( "SDL_RenderFill", ret == 0))
3734
42356acbc993 Finished last of the render testcases.
Edgar Simo <bobbens@gmail.com>
parents: 3733
diff changeset
479 return -1;
3730
dafd796f0c95 * Added preliminary render tests, missing some SDL functions to work properly.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
480 rect.x = 25;
dafd796f0c95 * Added preliminary render tests, missing some SDL functions to work properly.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
481 rect.y = 25;
dafd796f0c95 * Added preliminary render tests, missing some SDL functions to work properly.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
482 rect.w = 25;
dafd796f0c95 * Added preliminary render tests, missing some SDL functions to work properly.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
483 rect.h = 25;
3731
f5ddf1b670f0 Converted another testcase to the render system.
Edgar Simo <bobbens@gmail.com>
parents: 3730
diff changeset
484 ret = SDL_SetRenderDrawColor( 10, 10, 240, 125 );
f5ddf1b670f0 Converted another testcase to the render system.
Edgar Simo <bobbens@gmail.com>
parents: 3730
diff changeset
485 if (SDL_ATassert( "SDL_SetRenderDrawColor", ret == 0))
3734
42356acbc993 Finished last of the render testcases.
Edgar Simo <bobbens@gmail.com>
parents: 3733
diff changeset
486 return -1;
3731
f5ddf1b670f0 Converted another testcase to the render system.
Edgar Simo <bobbens@gmail.com>
parents: 3730
diff changeset
487 ret = SDL_SetRenderDrawBlendMode( SDL_BLENDMODE_MOD );
3733
ca544951b504 Finished converting the blit testcase.
Edgar Simo <bobbens@gmail.com>
parents: 3731
diff changeset
488 if (SDL_ATassert( "SDL_SetRenderDrawBlendMode", ret == 0))
3734
42356acbc993 Finished last of the render testcases.
Edgar Simo <bobbens@gmail.com>
parents: 3733
diff changeset
489 return -1;
3731
f5ddf1b670f0 Converted another testcase to the render system.
Edgar Simo <bobbens@gmail.com>
parents: 3730
diff changeset
490 ret = SDL_RenderFill( &rect );
f5ddf1b670f0 Converted another testcase to the render system.
Edgar Simo <bobbens@gmail.com>
parents: 3730
diff changeset
491 if (SDL_ATassert( "SDL_RenderFill", ret == 0))
3734
42356acbc993 Finished last of the render testcases.
Edgar Simo <bobbens@gmail.com>
parents: 3733
diff changeset
492 return -1;
3730
dafd796f0c95 * Added preliminary render tests, missing some SDL functions to work properly.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
493
dafd796f0c95 * Added preliminary render tests, missing some SDL functions to work properly.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
494 /* Draw blended lines, lines for everyone. */
3731
f5ddf1b670f0 Converted another testcase to the render system.
Edgar Simo <bobbens@gmail.com>
parents: 3730
diff changeset
495 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
496 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
497 if (SDL_ATassert( "SDL_SetRenderDrawColor", ret == 0))
3734
42356acbc993 Finished last of the render testcases.
Edgar Simo <bobbens@gmail.com>
parents: 3733
diff changeset
498 return -1;
3731
f5ddf1b670f0 Converted another testcase to the render system.
Edgar Simo <bobbens@gmail.com>
parents: 3730
diff changeset
499 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
500 (((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
501 if (SDL_ATassert( "SDL_SetRenderDrawBlendMode", ret == 0))
3734
42356acbc993 Finished last of the render testcases.
Edgar Simo <bobbens@gmail.com>
parents: 3733
diff changeset
502 return -1;
3731
f5ddf1b670f0 Converted another testcase to the render system.
Edgar Simo <bobbens@gmail.com>
parents: 3730
diff changeset
503 ret = SDL_RenderLine( 0, 0, i, 59 );
f5ddf1b670f0 Converted another testcase to the render system.
Edgar Simo <bobbens@gmail.com>
parents: 3730
diff changeset
504 if (SDL_ATassert( "SDL_RenderLine", ret == 0))
3734
42356acbc993 Finished last of the render testcases.
Edgar Simo <bobbens@gmail.com>
parents: 3733
diff changeset
505 return -1;
3730
dafd796f0c95 * Added preliminary render tests, missing some SDL functions to work properly.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
506 }
3731
f5ddf1b670f0 Converted another testcase to the render system.
Edgar Simo <bobbens@gmail.com>
parents: 3730
diff changeset
507 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
508 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
509 if (SDL_ATassert( "SDL_SetRenderDrawColor", ret == 0))
3734
42356acbc993 Finished last of the render testcases.
Edgar Simo <bobbens@gmail.com>
parents: 3733
diff changeset
510 return -1;
3731
f5ddf1b670f0 Converted another testcase to the render system.
Edgar Simo <bobbens@gmail.com>
parents: 3730
diff changeset
511 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
512 (((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
513 if (SDL_ATassert( "SDL_SetRenderDrawBlendMode", ret == 0))
3734
42356acbc993 Finished last of the render testcases.
Edgar Simo <bobbens@gmail.com>
parents: 3733
diff changeset
514 return -1;
3731
f5ddf1b670f0 Converted another testcase to the render system.
Edgar Simo <bobbens@gmail.com>
parents: 3730
diff changeset
515 ret = SDL_RenderLine( 0, 0, 79, i );
f5ddf1b670f0 Converted another testcase to the render system.
Edgar Simo <bobbens@gmail.com>
parents: 3730
diff changeset
516 if (SDL_ATassert( "SDL_RenderLine", ret == 0))
3734
42356acbc993 Finished last of the render testcases.
Edgar Simo <bobbens@gmail.com>
parents: 3733
diff changeset
517 return -1;
3730
dafd796f0c95 * Added preliminary render tests, missing some SDL functions to work properly.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
518 }
dafd796f0c95 * Added preliminary render tests, missing some SDL functions to work properly.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
519
dafd796f0c95 * Added preliminary render tests, missing some SDL functions to work properly.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
520 /* Draw points. */
3731
f5ddf1b670f0 Converted another testcase to the render system.
Edgar Simo <bobbens@gmail.com>
parents: 3730
diff changeset
521 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
522 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
523 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
524 if (SDL_ATassert( "SDL_SetRenderDrawColor", ret == 0))
3734
42356acbc993 Finished last of the render testcases.
Edgar Simo <bobbens@gmail.com>
parents: 3733
diff changeset
525 return -1;
3731
f5ddf1b670f0 Converted another testcase to the render system.
Edgar Simo <bobbens@gmail.com>
parents: 3730
diff changeset
526 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
527 ((((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
528 if (SDL_ATassert( "SDL_SetRenderDrawBlendMode", ret == 0))
3734
42356acbc993 Finished last of the render testcases.
Edgar Simo <bobbens@gmail.com>
parents: 3733
diff changeset
529 return -1;
3731
f5ddf1b670f0 Converted another testcase to the render system.
Edgar Simo <bobbens@gmail.com>
parents: 3730
diff changeset
530 ret = SDL_RenderPoint( i, j );
f5ddf1b670f0 Converted another testcase to the render system.
Edgar Simo <bobbens@gmail.com>
parents: 3730
diff changeset
531 if (SDL_ATassert( "SDL_RenderPoint", ret == 0))
3734
42356acbc993 Finished last of the render testcases.
Edgar Simo <bobbens@gmail.com>
parents: 3733
diff changeset
532 return -1;
3730
dafd796f0c95 * Added preliminary render tests, missing some SDL functions to work properly.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
533 }
dafd796f0c95 * Added preliminary render tests, missing some SDL functions to work properly.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
534 }
dafd796f0c95 * Added preliminary render tests, missing some SDL functions to work properly.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
535
dafd796f0c95 * Added preliminary render tests, missing some SDL functions to work properly.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
536 /* See if it's the same. */
3731
f5ddf1b670f0 Converted another testcase to the render system.
Edgar Simo <bobbens@gmail.com>
parents: 3730
diff changeset
537 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
538 return -1;
42356acbc993 Finished last of the render testcases.
Edgar Simo <bobbens@gmail.com>
parents: 3733
diff changeset
539
42356acbc993 Finished last of the render testcases.
Edgar Simo <bobbens@gmail.com>
parents: 3733
diff changeset
540 return 0;
3730
dafd796f0c95 * Added preliminary render tests, missing some SDL functions to work properly.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
541 }
dafd796f0c95 * Added preliminary render tests, missing some SDL functions to work properly.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
542
dafd796f0c95 * Added preliminary render tests, missing some SDL functions to work properly.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
543
dafd796f0c95 * Added preliminary render tests, missing some SDL functions to work properly.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
544 /**
dafd796f0c95 * Added preliminary render tests, missing some SDL functions to work properly.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
545 * @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
546 */
3734
42356acbc993 Finished last of the render testcases.
Edgar Simo <bobbens@gmail.com>
parents: 3733
diff changeset
547 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
548 {
dafd796f0c95 * Added preliminary render tests, missing some SDL functions to work properly.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
549 int ret;
dafd796f0c95 * Added preliminary render tests, missing some SDL functions to work properly.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
550 SDL_Rect rect;
dafd796f0c95 * Added preliminary render tests, missing some SDL functions to work properly.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
551 SDL_Surface *face;
3733
ca544951b504 Finished converting the blit testcase.
Edgar Simo <bobbens@gmail.com>
parents: 3731
diff changeset
552 SDL_TextureID tface;
3730
dafd796f0c95 * Added preliminary render tests, missing some SDL functions to work properly.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
553 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
554
dafd796f0c95 * Added preliminary render tests, missing some SDL functions to work properly.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
555 /* Clear surface. */
3733
ca544951b504 Finished converting the blit testcase.
Edgar Simo <bobbens@gmail.com>
parents: 3731
diff changeset
556 if (render_clearScreen())
3734
42356acbc993 Finished last of the render testcases.
Edgar Simo <bobbens@gmail.com>
parents: 3733
diff changeset
557 return -1;
3730
dafd796f0c95 * Added preliminary render tests, missing some SDL functions to work properly.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
558
3735
27b4b4d71011 Test for capabilities for each test.
Edgar Simo <bobbens@gmail.com>
parents: 3734
diff changeset
559 /* Need drawcolour or just skip test. */
27b4b4d71011 Test for capabilities for each test.
Edgar Simo <bobbens@gmail.com>
parents: 3734
diff changeset
560 if (!render_hasDrawColor())
27b4b4d71011 Test for capabilities for each test.
Edgar Simo <bobbens@gmail.com>
parents: 3734
diff changeset
561 return 0;
27b4b4d71011 Test for capabilities for each test.
Edgar Simo <bobbens@gmail.com>
parents: 3734
diff changeset
562
3730
dafd796f0c95 * Added preliminary render tests, missing some SDL functions to work properly.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
563 /* Create face surface. */
dafd796f0c95 * Added preliminary render tests, missing some SDL functions to work properly.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
564 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
565 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
566 RMASK, GMASK, BMASK, AMASK );
dafd796f0c95 * Added preliminary render tests, missing some SDL functions to work properly.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
567 if (SDL_ATassert( "SDL_CreateRGBSurfaceFrom", face != NULL))
3734
42356acbc993 Finished last of the render testcases.
Edgar Simo <bobbens@gmail.com>
parents: 3733
diff changeset
568 return -1;
3733
ca544951b504 Finished converting the blit testcase.
Edgar Simo <bobbens@gmail.com>
parents: 3731
diff changeset
569 tface = SDL_CreateTextureFromSurface( 0, face );
ca544951b504 Finished converting the blit testcase.
Edgar Simo <bobbens@gmail.com>
parents: 3731
diff changeset
570 if (SDL_ATassert( "SDL_CreateTextureFromSurface", tface != 0))
3734
42356acbc993 Finished last of the render testcases.
Edgar Simo <bobbens@gmail.com>
parents: 3733
diff changeset
571 return -1;
3733
ca544951b504 Finished converting the blit testcase.
Edgar Simo <bobbens@gmail.com>
parents: 3731
diff changeset
572
3730
dafd796f0c95 * Added preliminary render tests, missing some SDL functions to work properly.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
573 /* Constant values. */
dafd796f0c95 * Added preliminary render tests, missing some SDL functions to work properly.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
574 rect.w = face->w;
dafd796f0c95 * Added preliminary render tests, missing some SDL functions to work properly.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
575 rect.h = face->h;
3733
ca544951b504 Finished converting the blit testcase.
Edgar Simo <bobbens@gmail.com>
parents: 3731
diff changeset
576 ni = SCREEN_W - face->w;
ca544951b504 Finished converting the blit testcase.
Edgar Simo <bobbens@gmail.com>
parents: 3731
diff changeset
577 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
578
3747
f7a3a47e6b50 Fixed errors detected by valgrind.
Edgar Simo <bobbens@gmail.com>
parents: 3743
diff changeset
579 /* Clean up. */
f7a3a47e6b50 Fixed errors detected by valgrind.
Edgar Simo <bobbens@gmail.com>
parents: 3743
diff changeset
580 SDL_FreeSurface( face );
f7a3a47e6b50 Fixed errors detected by valgrind.
Edgar Simo <bobbens@gmail.com>
parents: 3743
diff changeset
581
3730
dafd796f0c95 * Added preliminary render tests, missing some SDL functions to work properly.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
582 /* Loop blit. */
dafd796f0c95 * Added preliminary render tests, missing some SDL functions to work properly.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
583 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
584 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
585 /* Blitting. */
dafd796f0c95 * Added preliminary render tests, missing some SDL functions to work properly.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
586 rect.x = i;
dafd796f0c95 * Added preliminary render tests, missing some SDL functions to work properly.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
587 rect.y = j;
3733
ca544951b504 Finished converting the blit testcase.
Edgar Simo <bobbens@gmail.com>
parents: 3731
diff changeset
588 ret = SDL_RenderCopy( tface, NULL, &rect );
ca544951b504 Finished converting the blit testcase.
Edgar Simo <bobbens@gmail.com>
parents: 3731
diff changeset
589 if (SDL_ATassert( "SDL_RenderCopy", ret == 0))
3734
42356acbc993 Finished last of the render testcases.
Edgar Simo <bobbens@gmail.com>
parents: 3733
diff changeset
590 return -1;
3730
dafd796f0c95 * Added preliminary render tests, missing some SDL functions to work properly.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
591 }
dafd796f0c95 * Added preliminary render tests, missing some SDL functions to work properly.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
592 }
dafd796f0c95 * Added preliminary render tests, missing some SDL functions to work properly.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
593
3735
27b4b4d71011 Test for capabilities for each test.
Edgar Simo <bobbens@gmail.com>
parents: 3734
diff changeset
594 /* Clean up. */
27b4b4d71011 Test for capabilities for each test.
Edgar Simo <bobbens@gmail.com>
parents: 3734
diff changeset
595 SDL_DestroyTexture( tface );
27b4b4d71011 Test for capabilities for each test.
Edgar Simo <bobbens@gmail.com>
parents: 3734
diff changeset
596
3730
dafd796f0c95 * Added preliminary render tests, missing some SDL functions to work properly.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
597 /* See if it's the same. */
3733
ca544951b504 Finished converting the blit testcase.
Edgar Simo <bobbens@gmail.com>
parents: 3731
diff changeset
598 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
599 return -1;
3730
dafd796f0c95 * Added preliminary render tests, missing some SDL functions to work properly.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
600
3735
27b4b4d71011 Test for capabilities for each test.
Edgar Simo <bobbens@gmail.com>
parents: 3734
diff changeset
601 return 0;
27b4b4d71011 Test for capabilities for each test.
Edgar Simo <bobbens@gmail.com>
parents: 3734
diff changeset
602 }
27b4b4d71011 Test for capabilities for each test.
Edgar Simo <bobbens@gmail.com>
parents: 3734
diff changeset
603
27b4b4d71011 Test for capabilities for each test.
Edgar Simo <bobbens@gmail.com>
parents: 3734
diff changeset
604
27b4b4d71011 Test for capabilities for each test.
Edgar Simo <bobbens@gmail.com>
parents: 3734
diff changeset
605 /**
27b4b4d71011 Test for capabilities for each test.
Edgar Simo <bobbens@gmail.com>
parents: 3734
diff changeset
606 * @brief Blits doing colour tests.
27b4b4d71011 Test for capabilities for each test.
Edgar Simo <bobbens@gmail.com>
parents: 3734
diff changeset
607 */
27b4b4d71011 Test for capabilities for each test.
Edgar Simo <bobbens@gmail.com>
parents: 3734
diff changeset
608 static int render_testBlitColour (void)
27b4b4d71011 Test for capabilities for each test.
Edgar Simo <bobbens@gmail.com>
parents: 3734
diff changeset
609 {
27b4b4d71011 Test for capabilities for each test.
Edgar Simo <bobbens@gmail.com>
parents: 3734
diff changeset
610 int ret;
27b4b4d71011 Test for capabilities for each test.
Edgar Simo <bobbens@gmail.com>
parents: 3734
diff changeset
611 SDL_Rect rect;
27b4b4d71011 Test for capabilities for each test.
Edgar Simo <bobbens@gmail.com>
parents: 3734
diff changeset
612 SDL_Surface *face;
27b4b4d71011 Test for capabilities for each test.
Edgar Simo <bobbens@gmail.com>
parents: 3734
diff changeset
613 SDL_TextureID tface;
27b4b4d71011 Test for capabilities for each test.
Edgar Simo <bobbens@gmail.com>
parents: 3734
diff changeset
614 int i, j, ni, nj;
27b4b4d71011 Test for capabilities for each test.
Edgar Simo <bobbens@gmail.com>
parents: 3734
diff changeset
615
3730
dafd796f0c95 * Added preliminary render tests, missing some SDL functions to work properly.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
616 /* Clear surface. */
3733
ca544951b504 Finished converting the blit testcase.
Edgar Simo <bobbens@gmail.com>
parents: 3731
diff changeset
617 if (render_clearScreen())
3734
42356acbc993 Finished last of the render testcases.
Edgar Simo <bobbens@gmail.com>
parents: 3733
diff changeset
618 return -1;
3730
dafd796f0c95 * Added preliminary render tests, missing some SDL functions to work properly.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
619
3735
27b4b4d71011 Test for capabilities for each test.
Edgar Simo <bobbens@gmail.com>
parents: 3734
diff changeset
620 /* Need drawcolour or just skip test. */
27b4b4d71011 Test for capabilities for each test.
Edgar Simo <bobbens@gmail.com>
parents: 3734
diff changeset
621 if (!render_hasTexColor())
27b4b4d71011 Test for capabilities for each test.
Edgar Simo <bobbens@gmail.com>
parents: 3734
diff changeset
622 return 0;
27b4b4d71011 Test for capabilities for each test.
Edgar Simo <bobbens@gmail.com>
parents: 3734
diff changeset
623
27b4b4d71011 Test for capabilities for each test.
Edgar Simo <bobbens@gmail.com>
parents: 3734
diff changeset
624 /* Create face surface. */
27b4b4d71011 Test for capabilities for each test.
Edgar Simo <bobbens@gmail.com>
parents: 3734
diff changeset
625 face = SDL_CreateRGBSurfaceFrom( (void*)img_face.pixel_data,
27b4b4d71011 Test for capabilities for each test.
Edgar Simo <bobbens@gmail.com>
parents: 3734
diff changeset
626 img_face.width, img_face.height, 32, img_face.width*4,
27b4b4d71011 Test for capabilities for each test.
Edgar Simo <bobbens@gmail.com>
parents: 3734
diff changeset
627 RMASK, GMASK, BMASK, AMASK );
27b4b4d71011 Test for capabilities for each test.
Edgar Simo <bobbens@gmail.com>
parents: 3734
diff changeset
628 if (SDL_ATassert( "SDL_CreateRGBSurfaceFrom", face != NULL))
27b4b4d71011 Test for capabilities for each test.
Edgar Simo <bobbens@gmail.com>
parents: 3734
diff changeset
629 return -1;
27b4b4d71011 Test for capabilities for each test.
Edgar Simo <bobbens@gmail.com>
parents: 3734
diff changeset
630 tface = SDL_CreateTextureFromSurface( 0, face );
27b4b4d71011 Test for capabilities for each test.
Edgar Simo <bobbens@gmail.com>
parents: 3734
diff changeset
631 if (SDL_ATassert( "SDL_CreateTextureFromSurface", tface != 0))
27b4b4d71011 Test for capabilities for each test.
Edgar Simo <bobbens@gmail.com>
parents: 3734
diff changeset
632 return -1;
27b4b4d71011 Test for capabilities for each test.
Edgar Simo <bobbens@gmail.com>
parents: 3734
diff changeset
633
27b4b4d71011 Test for capabilities for each test.
Edgar Simo <bobbens@gmail.com>
parents: 3734
diff changeset
634 /* Constant values. */
27b4b4d71011 Test for capabilities for each test.
Edgar Simo <bobbens@gmail.com>
parents: 3734
diff changeset
635 rect.w = face->w;
27b4b4d71011 Test for capabilities for each test.
Edgar Simo <bobbens@gmail.com>
parents: 3734
diff changeset
636 rect.h = face->h;
27b4b4d71011 Test for capabilities for each test.
Edgar Simo <bobbens@gmail.com>
parents: 3734
diff changeset
637 ni = SCREEN_W - face->w;
27b4b4d71011 Test for capabilities for each test.
Edgar Simo <bobbens@gmail.com>
parents: 3734
diff changeset
638 nj = SCREEN_H - face->h;
27b4b4d71011 Test for capabilities for each test.
Edgar Simo <bobbens@gmail.com>
parents: 3734
diff changeset
639
3747
f7a3a47e6b50 Fixed errors detected by valgrind.
Edgar Simo <bobbens@gmail.com>
parents: 3743
diff changeset
640 /* Clean up. */
f7a3a47e6b50 Fixed errors detected by valgrind.
Edgar Simo <bobbens@gmail.com>
parents: 3743
diff changeset
641 SDL_FreeSurface( face );
f7a3a47e6b50 Fixed errors detected by valgrind.
Edgar Simo <bobbens@gmail.com>
parents: 3743
diff changeset
642
3730
dafd796f0c95 * Added preliminary render tests, missing some SDL functions to work properly.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
643 /* 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
644 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
645 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
646 /* Set colour mod. */
3733
ca544951b504 Finished converting the blit testcase.
Edgar Simo <bobbens@gmail.com>
parents: 3731
diff changeset
647 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
648 if (SDL_ATassert( "SDL_SetTextureColorMod", ret == 0))
3734
42356acbc993 Finished last of the render testcases.
Edgar Simo <bobbens@gmail.com>
parents: 3733
diff changeset
649 return -1;
3730
dafd796f0c95 * Added preliminary render tests, missing some SDL functions to work properly.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
650
dafd796f0c95 * Added preliminary render tests, missing some SDL functions to work properly.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
651 /* Blitting. */
dafd796f0c95 * Added preliminary render tests, missing some SDL functions to work properly.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
652 rect.x = i;
dafd796f0c95 * Added preliminary render tests, missing some SDL functions to work properly.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
653 rect.y = j;
3733
ca544951b504 Finished converting the blit testcase.
Edgar Simo <bobbens@gmail.com>
parents: 3731
diff changeset
654 ret = SDL_RenderCopy( tface, NULL, &rect );
ca544951b504 Finished converting the blit testcase.
Edgar Simo <bobbens@gmail.com>
parents: 3731
diff changeset
655 if (SDL_ATassert( "SDL_RenderCopy", ret == 0))
3734
42356acbc993 Finished last of the render testcases.
Edgar Simo <bobbens@gmail.com>
parents: 3733
diff changeset
656 return -1;
3730
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
3735
27b4b4d71011 Test for capabilities for each test.
Edgar Simo <bobbens@gmail.com>
parents: 3734
diff changeset
660 /* Clean up. */
27b4b4d71011 Test for capabilities for each test.
Edgar Simo <bobbens@gmail.com>
parents: 3734
diff changeset
661 SDL_DestroyTexture( tface );
27b4b4d71011 Test for capabilities for each test.
Edgar Simo <bobbens@gmail.com>
parents: 3734
diff changeset
662
3730
dafd796f0c95 * Added preliminary render tests, missing some SDL functions to work properly.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
663 /* See if it's the same. */
3733
ca544951b504 Finished converting the blit testcase.
Edgar Simo <bobbens@gmail.com>
parents: 3731
diff changeset
664 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
665 &img_blitColour ))
3734
42356acbc993 Finished last of the render testcases.
Edgar Simo <bobbens@gmail.com>
parents: 3733
diff changeset
666 return -1;
3730
dafd796f0c95 * Added preliminary render tests, missing some SDL functions to work properly.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
667
3735
27b4b4d71011 Test for capabilities for each test.
Edgar Simo <bobbens@gmail.com>
parents: 3734
diff changeset
668 return 0;
27b4b4d71011 Test for capabilities for each test.
Edgar Simo <bobbens@gmail.com>
parents: 3734
diff changeset
669 }
27b4b4d71011 Test for capabilities for each test.
Edgar Simo <bobbens@gmail.com>
parents: 3734
diff changeset
670
27b4b4d71011 Test for capabilities for each test.
Edgar Simo <bobbens@gmail.com>
parents: 3734
diff changeset
671
27b4b4d71011 Test for capabilities for each test.
Edgar Simo <bobbens@gmail.com>
parents: 3734
diff changeset
672 /**
27b4b4d71011 Test for capabilities for each test.
Edgar Simo <bobbens@gmail.com>
parents: 3734
diff changeset
673 * @brief Tests blitting with alpha.
27b4b4d71011 Test for capabilities for each test.
Edgar Simo <bobbens@gmail.com>
parents: 3734
diff changeset
674 */
27b4b4d71011 Test for capabilities for each test.
Edgar Simo <bobbens@gmail.com>
parents: 3734
diff changeset
675 static int render_testBlitAlpha (void)
27b4b4d71011 Test for capabilities for each test.
Edgar Simo <bobbens@gmail.com>
parents: 3734
diff changeset
676 {
27b4b4d71011 Test for capabilities for each test.
Edgar Simo <bobbens@gmail.com>
parents: 3734
diff changeset
677 int ret;
27b4b4d71011 Test for capabilities for each test.
Edgar Simo <bobbens@gmail.com>
parents: 3734
diff changeset
678 SDL_Rect rect;
27b4b4d71011 Test for capabilities for each test.
Edgar Simo <bobbens@gmail.com>
parents: 3734
diff changeset
679 SDL_Surface *face;
27b4b4d71011 Test for capabilities for each test.
Edgar Simo <bobbens@gmail.com>
parents: 3734
diff changeset
680 SDL_TextureID tface;
27b4b4d71011 Test for capabilities for each test.
Edgar Simo <bobbens@gmail.com>
parents: 3734
diff changeset
681 int i, j, ni, nj;
27b4b4d71011 Test for capabilities for each test.
Edgar Simo <bobbens@gmail.com>
parents: 3734
diff changeset
682
3730
dafd796f0c95 * Added preliminary render tests, missing some SDL functions to work properly.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
683 /* Clear surface. */
3733
ca544951b504 Finished converting the blit testcase.
Edgar Simo <bobbens@gmail.com>
parents: 3731
diff changeset
684 if (render_clearScreen())
3734
42356acbc993 Finished last of the render testcases.
Edgar Simo <bobbens@gmail.com>
parents: 3733
diff changeset
685 return -1;
3730
dafd796f0c95 * Added preliminary render tests, missing some SDL functions to work properly.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
686
3735
27b4b4d71011 Test for capabilities for each test.
Edgar Simo <bobbens@gmail.com>
parents: 3734
diff changeset
687 /* Need alpha or just skip test. */
27b4b4d71011 Test for capabilities for each test.
Edgar Simo <bobbens@gmail.com>
parents: 3734
diff changeset
688 if (!render_hasTexAlpha())
27b4b4d71011 Test for capabilities for each test.
Edgar Simo <bobbens@gmail.com>
parents: 3734
diff changeset
689 return 0;
27b4b4d71011 Test for capabilities for each test.
Edgar Simo <bobbens@gmail.com>
parents: 3734
diff changeset
690
27b4b4d71011 Test for capabilities for each test.
Edgar Simo <bobbens@gmail.com>
parents: 3734
diff changeset
691 /* Create face surface. */
27b4b4d71011 Test for capabilities for each test.
Edgar Simo <bobbens@gmail.com>
parents: 3734
diff changeset
692 face = SDL_CreateRGBSurfaceFrom( (void*)img_face.pixel_data,
27b4b4d71011 Test for capabilities for each test.
Edgar Simo <bobbens@gmail.com>
parents: 3734
diff changeset
693 img_face.width, img_face.height, 32, img_face.width*4,
27b4b4d71011 Test for capabilities for each test.
Edgar Simo <bobbens@gmail.com>
parents: 3734
diff changeset
694 RMASK, GMASK, BMASK, AMASK );
27b4b4d71011 Test for capabilities for each test.
Edgar Simo <bobbens@gmail.com>
parents: 3734
diff changeset
695 if (SDL_ATassert( "SDL_CreateRGBSurfaceFrom", face != NULL))
27b4b4d71011 Test for capabilities for each test.
Edgar Simo <bobbens@gmail.com>
parents: 3734
diff changeset
696 return -1;
27b4b4d71011 Test for capabilities for each test.
Edgar Simo <bobbens@gmail.com>
parents: 3734
diff changeset
697 tface = SDL_CreateTextureFromSurface( 0, face );
27b4b4d71011 Test for capabilities for each test.
Edgar Simo <bobbens@gmail.com>
parents: 3734
diff changeset
698 if (SDL_ATassert( "SDL_CreateTextureFromSurface", tface != 0))
3734
42356acbc993 Finished last of the render testcases.
Edgar Simo <bobbens@gmail.com>
parents: 3733
diff changeset
699 return -1;
3730
dafd796f0c95 * Added preliminary render tests, missing some SDL functions to work properly.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
700
3735
27b4b4d71011 Test for capabilities for each test.
Edgar Simo <bobbens@gmail.com>
parents: 3734
diff changeset
701 /* Constant values. */
27b4b4d71011 Test for capabilities for each test.
Edgar Simo <bobbens@gmail.com>
parents: 3734
diff changeset
702 rect.w = face->w;
27b4b4d71011 Test for capabilities for each test.
Edgar Simo <bobbens@gmail.com>
parents: 3734
diff changeset
703 rect.h = face->h;
27b4b4d71011 Test for capabilities for each test.
Edgar Simo <bobbens@gmail.com>
parents: 3734
diff changeset
704 ni = SCREEN_W - face->w;
27b4b4d71011 Test for capabilities for each test.
Edgar Simo <bobbens@gmail.com>
parents: 3734
diff changeset
705 nj = SCREEN_H - face->h;
27b4b4d71011 Test for capabilities for each test.
Edgar Simo <bobbens@gmail.com>
parents: 3734
diff changeset
706
3747
f7a3a47e6b50 Fixed errors detected by valgrind.
Edgar Simo <bobbens@gmail.com>
parents: 3743
diff changeset
707 /* Clean up. */
f7a3a47e6b50 Fixed errors detected by valgrind.
Edgar Simo <bobbens@gmail.com>
parents: 3743
diff changeset
708 SDL_FreeSurface( face );
f7a3a47e6b50 Fixed errors detected by valgrind.
Edgar Simo <bobbens@gmail.com>
parents: 3743
diff changeset
709
3735
27b4b4d71011 Test for capabilities for each test.
Edgar Simo <bobbens@gmail.com>
parents: 3734
diff changeset
710 /* Clear surface. */
27b4b4d71011 Test for capabilities for each test.
Edgar Simo <bobbens@gmail.com>
parents: 3734
diff changeset
711 if (render_clearScreen())
27b4b4d71011 Test for capabilities for each test.
Edgar Simo <bobbens@gmail.com>
parents: 3734
diff changeset
712 return -1;
27b4b4d71011 Test for capabilities for each test.
Edgar Simo <bobbens@gmail.com>
parents: 3734
diff changeset
713
27b4b4d71011 Test for capabilities for each test.
Edgar Simo <bobbens@gmail.com>
parents: 3734
diff changeset
714 /* Test blitting with alpha mod. */
3730
dafd796f0c95 * Added preliminary render tests, missing some SDL functions to work properly.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
715 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
716 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
717 /* Set alpha mod. */
3733
ca544951b504 Finished converting the blit testcase.
Edgar Simo <bobbens@gmail.com>
parents: 3731
diff changeset
718 ret = SDL_SetTextureAlphaMod( tface, (255/ni)*i );
ca544951b504 Finished converting the blit testcase.
Edgar Simo <bobbens@gmail.com>
parents: 3731
diff changeset
719 if (SDL_ATassert( "SDL_SetTextureAlphaMod", ret == 0))
3734
42356acbc993 Finished last of the render testcases.
Edgar Simo <bobbens@gmail.com>
parents: 3733
diff changeset
720 return -1;
3730
dafd796f0c95 * Added preliminary render tests, missing some SDL functions to work properly.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
721
dafd796f0c95 * Added preliminary render tests, missing some SDL functions to work properly.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
722 /* Blitting. */
dafd796f0c95 * Added preliminary render tests, missing some SDL functions to work properly.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
723 rect.x = i;
dafd796f0c95 * Added preliminary render tests, missing some SDL functions to work properly.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
724 rect.y = j;
3733
ca544951b504 Finished converting the blit testcase.
Edgar Simo <bobbens@gmail.com>
parents: 3731
diff changeset
725 ret = SDL_RenderCopy( tface, NULL, &rect );
ca544951b504 Finished converting the blit testcase.
Edgar Simo <bobbens@gmail.com>
parents: 3731
diff changeset
726 if (SDL_ATassert( "SDL_RenderCopy", ret == 0))
3734
42356acbc993 Finished last of the render testcases.
Edgar Simo <bobbens@gmail.com>
parents: 3733
diff changeset
727 return -1;
3730
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
3735
27b4b4d71011 Test for capabilities for each test.
Edgar Simo <bobbens@gmail.com>
parents: 3734
diff changeset
731 /* Clean up. */
27b4b4d71011 Test for capabilities for each test.
Edgar Simo <bobbens@gmail.com>
parents: 3734
diff changeset
732 SDL_DestroyTexture( tface );
27b4b4d71011 Test for capabilities for each test.
Edgar Simo <bobbens@gmail.com>
parents: 3734
diff changeset
733
3730
dafd796f0c95 * Added preliminary render tests, missing some SDL functions to work properly.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
734 /* See if it's the same. */
3733
ca544951b504 Finished converting the blit testcase.
Edgar Simo <bobbens@gmail.com>
parents: 3731
diff changeset
735 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
736 &img_blitAlpha ))
3734
42356acbc993 Finished last of the render testcases.
Edgar Simo <bobbens@gmail.com>
parents: 3733
diff changeset
737 return -1;
3730
dafd796f0c95 * Added preliminary render tests, missing some SDL functions to work properly.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
738
3734
42356acbc993 Finished last of the render testcases.
Edgar Simo <bobbens@gmail.com>
parents: 3733
diff changeset
739 return 0;
3730
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
dafd796f0c95 * Added preliminary render tests, missing some SDL functions to work properly.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
742
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 * @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
745 */
3734
42356acbc993 Finished last of the render testcases.
Edgar Simo <bobbens@gmail.com>
parents: 3733
diff changeset
746 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
747 {
dafd796f0c95 * Added preliminary render tests, missing some SDL functions to work properly.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
748 int ret;
dafd796f0c95 * Added preliminary render tests, missing some SDL functions to work properly.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
749 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
750 SDL_Rect rect;
dafd796f0c95 * Added preliminary render tests, missing some SDL functions to work properly.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
751
dafd796f0c95 * Added preliminary render tests, missing some SDL functions to work properly.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
752 /* Clear surface. */
3734
42356acbc993 Finished last of the render testcases.
Edgar Simo <bobbens@gmail.com>
parents: 3733
diff changeset
753 if (render_clearScreen())
42356acbc993 Finished last of the render testcases.
Edgar Simo <bobbens@gmail.com>
parents: 3733
diff changeset
754 return -1;
3730
dafd796f0c95 * Added preliminary render tests, missing some SDL functions to work properly.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
755
dafd796f0c95 * Added preliminary render tests, missing some SDL functions to work properly.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
756 /* Steps to take. */
3734
42356acbc993 Finished last of the render testcases.
Edgar Simo <bobbens@gmail.com>
parents: 3733
diff changeset
757 ni = SCREEN_W - FACE_W;
42356acbc993 Finished last of the render testcases.
Edgar Simo <bobbens@gmail.com>
parents: 3733
diff changeset
758 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
759
dafd796f0c95 * Added preliminary render tests, missing some SDL functions to work properly.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
760 /* Constant values. */
3734
42356acbc993 Finished last of the render testcases.
Edgar Simo <bobbens@gmail.com>
parents: 3733
diff changeset
761 rect.w = FACE_W;
42356acbc993 Finished last of the render testcases.
Edgar Simo <bobbens@gmail.com>
parents: 3733
diff changeset
762 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
763
dafd796f0c95 * Added preliminary render tests, missing some SDL functions to work properly.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
764 /* Test blend mode. */
dafd796f0c95 * Added preliminary render tests, missing some SDL functions to work properly.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
765 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
766 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
767 /* Set blend mode. */
3734
42356acbc993 Finished last of the render testcases.
Edgar Simo <bobbens@gmail.com>
parents: 3733
diff changeset
768 ret = SDL_SetRenderDrawBlendMode( mode );
42356acbc993 Finished last of the render testcases.
Edgar Simo <bobbens@gmail.com>
parents: 3733
diff changeset
769 if (SDL_ATassert( "SDL_SetRenderDrawBlendMode", ret == 0))
42356acbc993 Finished last of the render testcases.
Edgar Simo <bobbens@gmail.com>
parents: 3733
diff changeset
770 return -1;
3730
dafd796f0c95 * Added preliminary render tests, missing some SDL functions to work properly.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
771
dafd796f0c95 * Added preliminary render tests, missing some SDL functions to work properly.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
772 /* Blitting. */
dafd796f0c95 * Added preliminary render tests, missing some SDL functions to work properly.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
773 rect.x = i;
dafd796f0c95 * Added preliminary render tests, missing some SDL functions to work properly.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
774 rect.y = j;
3734
42356acbc993 Finished last of the render testcases.
Edgar Simo <bobbens@gmail.com>
parents: 3733
diff changeset
775 ret = SDL_RenderCopy( tface, NULL, &rect );
42356acbc993 Finished last of the render testcases.
Edgar Simo <bobbens@gmail.com>
parents: 3733
diff changeset
776 if (SDL_ATassert( "SDL_RenderCopy", ret == 0))
42356acbc993 Finished last of the render testcases.
Edgar Simo <bobbens@gmail.com>
parents: 3733
diff changeset
777 return -1;
3730
dafd796f0c95 * Added preliminary render tests, missing some SDL functions to work properly.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
778 }
dafd796f0c95 * Added preliminary render tests, missing some SDL functions to work properly.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
779 }
dafd796f0c95 * Added preliminary render tests, missing some SDL functions to work properly.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
780
dafd796f0c95 * Added preliminary render tests, missing some SDL functions to work properly.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
781 return 0;
dafd796f0c95 * Added preliminary render tests, missing some SDL functions to work properly.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
782 }
dafd796f0c95 * Added preliminary render tests, missing some SDL functions to work properly.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
783
dafd796f0c95 * Added preliminary render tests, missing some SDL functions to work properly.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
784
dafd796f0c95 * Added preliminary render tests, missing some SDL functions to work properly.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
785 /**
dafd796f0c95 * Added preliminary render tests, missing some SDL functions to work properly.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
786 * @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
787 */
3734
42356acbc993 Finished last of the render testcases.
Edgar Simo <bobbens@gmail.com>
parents: 3733
diff changeset
788 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
789 {
dafd796f0c95 * Added preliminary render tests, missing some SDL functions to work properly.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
790 int ret;
dafd796f0c95 * Added preliminary render tests, missing some SDL functions to work properly.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
791 SDL_Rect rect;
dafd796f0c95 * Added preliminary render tests, missing some SDL functions to work properly.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
792 SDL_Surface *face;
3734
42356acbc993 Finished last of the render testcases.
Edgar Simo <bobbens@gmail.com>
parents: 3733
diff changeset
793 SDL_TextureID tface;
3730
dafd796f0c95 * Added preliminary render tests, missing some SDL functions to work properly.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
794 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
795 int mode;
dafd796f0c95 * Added preliminary render tests, missing some SDL functions to work properly.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
796
3734
42356acbc993 Finished last of the render testcases.
Edgar Simo <bobbens@gmail.com>
parents: 3733
diff changeset
797 /* Clear surface. */
42356acbc993 Finished last of the render testcases.
Edgar Simo <bobbens@gmail.com>
parents: 3733
diff changeset
798 if (render_clearScreen())
42356acbc993 Finished last of the render testcases.
Edgar Simo <bobbens@gmail.com>
parents: 3733
diff changeset
799 return -1;
3730
dafd796f0c95 * Added preliminary render tests, missing some SDL functions to work properly.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
800
3735
27b4b4d71011 Test for capabilities for each test.
Edgar Simo <bobbens@gmail.com>
parents: 3734
diff changeset
801 /* Need drawcolour and blendmode or just skip test. */
27b4b4d71011 Test for capabilities for each test.
Edgar Simo <bobbens@gmail.com>
parents: 3734
diff changeset
802 if (!render_hasBlendModes() || !render_hasTexColor() || !render_hasTexAlpha())
27b4b4d71011 Test for capabilities for each test.
Edgar Simo <bobbens@gmail.com>
parents: 3734
diff changeset
803 return 0;
27b4b4d71011 Test for capabilities for each test.
Edgar Simo <bobbens@gmail.com>
parents: 3734
diff changeset
804
3734
42356acbc993 Finished last of the render testcases.
Edgar Simo <bobbens@gmail.com>
parents: 3733
diff changeset
805 /* Create face surface. */
3730
dafd796f0c95 * Added preliminary render tests, missing some SDL functions to work properly.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
806 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
807 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
808 RMASK, GMASK, BMASK, AMASK );
dafd796f0c95 * Added preliminary render tests, missing some SDL functions to work properly.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
809 if (SDL_ATassert( "SDL_CreateRGBSurfaceFrom", face != NULL))
3734
42356acbc993 Finished last of the render testcases.
Edgar Simo <bobbens@gmail.com>
parents: 3733
diff changeset
810 return -1;
42356acbc993 Finished last of the render testcases.
Edgar Simo <bobbens@gmail.com>
parents: 3733
diff changeset
811 tface = SDL_CreateTextureFromSurface( 0, face );
42356acbc993 Finished last of the render testcases.
Edgar Simo <bobbens@gmail.com>
parents: 3733
diff changeset
812 if (SDL_ATassert( "SDL_CreateTextureFromSurface", tface != 0))
42356acbc993 Finished last of the render testcases.
Edgar Simo <bobbens@gmail.com>
parents: 3733
diff changeset
813 return -1;
42356acbc993 Finished last of the render testcases.
Edgar Simo <bobbens@gmail.com>
parents: 3733
diff changeset
814
3747
f7a3a47e6b50 Fixed errors detected by valgrind.
Edgar Simo <bobbens@gmail.com>
parents: 3743
diff changeset
815 /* Steps to take. */
f7a3a47e6b50 Fixed errors detected by valgrind.
Edgar Simo <bobbens@gmail.com>
parents: 3743
diff changeset
816 ni = SCREEN_W - FACE_W;
f7a3a47e6b50 Fixed errors detected by valgrind.
Edgar Simo <bobbens@gmail.com>
parents: 3743
diff changeset
817 nj = SCREEN_H - FACE_H;
f7a3a47e6b50 Fixed errors detected by valgrind.
Edgar Simo <bobbens@gmail.com>
parents: 3743
diff changeset
818
f7a3a47e6b50 Fixed errors detected by valgrind.
Edgar Simo <bobbens@gmail.com>
parents: 3743
diff changeset
819 /* Constant values. */
f7a3a47e6b50 Fixed errors detected by valgrind.
Edgar Simo <bobbens@gmail.com>
parents: 3743
diff changeset
820 rect.w = face->w;
f7a3a47e6b50 Fixed errors detected by valgrind.
Edgar Simo <bobbens@gmail.com>
parents: 3743
diff changeset
821 rect.h = face->h;
f7a3a47e6b50 Fixed errors detected by valgrind.
Edgar Simo <bobbens@gmail.com>
parents: 3743
diff changeset
822
3734
42356acbc993 Finished last of the render testcases.
Edgar Simo <bobbens@gmail.com>
parents: 3733
diff changeset
823 /* Clean up. */
42356acbc993 Finished last of the render testcases.
Edgar Simo <bobbens@gmail.com>
parents: 3733
diff changeset
824 SDL_FreeSurface( face );
3730
dafd796f0c95 * Added preliminary render tests, missing some SDL functions to work properly.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
825
dafd796f0c95 * Added preliminary render tests, missing some SDL functions to work properly.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
826 /* Set alpha mod. */
3734
42356acbc993 Finished last of the render testcases.
Edgar Simo <bobbens@gmail.com>
parents: 3733
diff changeset
827 ret = SDL_SetRenderDrawColor( 255, 255, 255, 100 );
42356acbc993 Finished last of the render testcases.
Edgar Simo <bobbens@gmail.com>
parents: 3733
diff changeset
828 if (SDL_ATassert( "SDL_SetRenderDrawColor", ret == 0))
42356acbc993 Finished last of the render testcases.
Edgar Simo <bobbens@gmail.com>
parents: 3733
diff changeset
829 return -1;
3730
dafd796f0c95 * Added preliminary render tests, missing some SDL functions to work properly.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
830
dafd796f0c95 * Added preliminary render tests, missing some SDL functions to work properly.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
831 /* Test None. */
3734
42356acbc993 Finished last of the render testcases.
Edgar Simo <bobbens@gmail.com>
parents: 3733
diff changeset
832 if (render_testBlitBlendMode( tface, SDL_BLENDMODE_NONE ))
42356acbc993 Finished last of the render testcases.
Edgar Simo <bobbens@gmail.com>
parents: 3733
diff changeset
833 return -1;
42356acbc993 Finished last of the render testcases.
Edgar Simo <bobbens@gmail.com>
parents: 3733
diff changeset
834 /* See if it's the same. */
42356acbc993 Finished last of the render testcases.
Edgar Simo <bobbens@gmail.com>
parents: 3733
diff changeset
835 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
836 &img_blitAlpha ))
42356acbc993 Finished last of the render testcases.
Edgar Simo <bobbens@gmail.com>
parents: 3733
diff changeset
837 return -1;
3730
dafd796f0c95 * Added preliminary render tests, missing some SDL functions to work properly.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
838
dafd796f0c95 * Added preliminary render tests, missing some SDL functions to work properly.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
839 /* Test Mask. */
3734
42356acbc993 Finished last of the render testcases.
Edgar Simo <bobbens@gmail.com>
parents: 3733
diff changeset
840 if (render_testBlitBlendMode( tface, SDL_BLENDMODE_MASK ))
42356acbc993 Finished last of the render testcases.
Edgar Simo <bobbens@gmail.com>
parents: 3733
diff changeset
841 return -1;
42356acbc993 Finished last of the render testcases.
Edgar Simo <bobbens@gmail.com>
parents: 3733
diff changeset
842 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
843 &img_blendMask ))
42356acbc993 Finished last of the render testcases.
Edgar Simo <bobbens@gmail.com>
parents: 3733
diff changeset
844 return -1;
3730
dafd796f0c95 * Added preliminary render tests, missing some SDL functions to work properly.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
845
dafd796f0c95 * Added preliminary render tests, missing some SDL functions to work properly.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
846 /* Test Blend. */
3734
42356acbc993 Finished last of the render testcases.
Edgar Simo <bobbens@gmail.com>
parents: 3733
diff changeset
847 if (render_testBlitBlendMode( tface, SDL_BLENDMODE_BLEND ))
42356acbc993 Finished last of the render testcases.
Edgar Simo <bobbens@gmail.com>
parents: 3733
diff changeset
848 return -1;
42356acbc993 Finished last of the render testcases.
Edgar Simo <bobbens@gmail.com>
parents: 3733
diff changeset
849 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
850 &img_blendBlend ))
42356acbc993 Finished last of the render testcases.
Edgar Simo <bobbens@gmail.com>
parents: 3733
diff changeset
851 return -1;
3730
dafd796f0c95 * Added preliminary render tests, missing some SDL functions to work properly.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
852
dafd796f0c95 * Added preliminary render tests, missing some SDL functions to work properly.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
853 /* Test Add. */
3734
42356acbc993 Finished last of the render testcases.
Edgar Simo <bobbens@gmail.com>
parents: 3733
diff changeset
854 if (render_testBlitBlendMode( tface, SDL_BLENDMODE_ADD ))
42356acbc993 Finished last of the render testcases.
Edgar Simo <bobbens@gmail.com>
parents: 3733
diff changeset
855 return -1;
42356acbc993 Finished last of the render testcases.
Edgar Simo <bobbens@gmail.com>
parents: 3733
diff changeset
856 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
857 &img_blendAdd ))
42356acbc993 Finished last of the render testcases.
Edgar Simo <bobbens@gmail.com>
parents: 3733
diff changeset
858 return -1;
3730
dafd796f0c95 * Added preliminary render tests, missing some SDL functions to work properly.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
859
dafd796f0c95 * Added preliminary render tests, missing some SDL functions to work properly.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
860 /* Test Mod. */
3734
42356acbc993 Finished last of the render testcases.
Edgar Simo <bobbens@gmail.com>
parents: 3733
diff changeset
861 if (render_testBlitBlendMode( tface, SDL_BLENDMODE_MOD ))
42356acbc993 Finished last of the render testcases.
Edgar Simo <bobbens@gmail.com>
parents: 3733
diff changeset
862 return -1;
42356acbc993 Finished last of the render testcases.
Edgar Simo <bobbens@gmail.com>
parents: 3733
diff changeset
863 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
864 &img_blendMod ))
42356acbc993 Finished last of the render testcases.
Edgar Simo <bobbens@gmail.com>
parents: 3733
diff changeset
865 return -1;
3730
dafd796f0c95 * Added preliminary render tests, missing some SDL functions to work properly.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
866
dafd796f0c95 * Added preliminary render tests, missing some SDL functions to work properly.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
867 /* Clear surface. */
3734
42356acbc993 Finished last of the render testcases.
Edgar Simo <bobbens@gmail.com>
parents: 3733
diff changeset
868 if (render_clearScreen())
42356acbc993 Finished last of the render testcases.
Edgar Simo <bobbens@gmail.com>
parents: 3733
diff changeset
869 return -1;
3730
dafd796f0c95 * Added preliminary render tests, missing some SDL functions to work properly.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
870
dafd796f0c95 * Added preliminary render tests, missing some SDL functions to work properly.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
871 /* Loop blit. */
dafd796f0c95 * Added preliminary render tests, missing some SDL functions to work properly.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
872 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
873 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
874
dafd796f0c95 * Added preliminary render tests, missing some SDL functions to work properly.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
875 /* Set colour mod. */
3734
42356acbc993 Finished last of the render testcases.
Edgar Simo <bobbens@gmail.com>
parents: 3733
diff changeset
876 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
877 if (SDL_ATassert( "SDL_SetRenderDrawColor", ret == 0))
42356acbc993 Finished last of the render testcases.
Edgar Simo <bobbens@gmail.com>
parents: 3733
diff changeset
878 return -1;
3730
dafd796f0c95 * Added preliminary render tests, missing some SDL functions to work properly.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
879
dafd796f0c95 * Added preliminary render tests, missing some SDL functions to work properly.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
880 /* Crazy blending mode magic. */
dafd796f0c95 * Added preliminary render tests, missing some SDL functions to work properly.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
881 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
882 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
883 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
884 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
885 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
886 ret = SDL_SetRenderDrawBlendMode( mode );
42356acbc993 Finished last of the render testcases.
Edgar Simo <bobbens@gmail.com>
parents: 3733
diff changeset
887 if (SDL_ATassert( "SDL_SetRenderDrawBlendMode", ret == 0))
42356acbc993 Finished last of the render testcases.
Edgar Simo <bobbens@gmail.com>
parents: 3733
diff changeset
888 return -1;
3730
dafd796f0c95 * Added preliminary render tests, missing some SDL functions to work properly.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
889
dafd796f0c95 * Added preliminary render tests, missing some SDL functions to work properly.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
890 /* Blitting. */
dafd796f0c95 * Added preliminary render tests, missing some SDL functions to work properly.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
891 rect.x = i;
dafd796f0c95 * Added preliminary render tests, missing some SDL functions to work properly.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
892 rect.y = j;
3734
42356acbc993 Finished last of the render testcases.
Edgar Simo <bobbens@gmail.com>
parents: 3733
diff changeset
893 ret = SDL_RenderCopy( tface, NULL, &rect );
42356acbc993 Finished last of the render testcases.
Edgar Simo <bobbens@gmail.com>
parents: 3733
diff changeset
894 if (SDL_ATassert( "SDL_RenderCopy", ret == 0))
42356acbc993 Finished last of the render testcases.
Edgar Simo <bobbens@gmail.com>
parents: 3733
diff changeset
895 return -1;
3730
dafd796f0c95 * Added preliminary render tests, missing some SDL functions to work properly.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
896 }
dafd796f0c95 * Added preliminary render tests, missing some SDL functions to work properly.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
897 }
dafd796f0c95 * Added preliminary render tests, missing some SDL functions to work properly.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
898
3735
27b4b4d71011 Test for capabilities for each test.
Edgar Simo <bobbens@gmail.com>
parents: 3734
diff changeset
899 /* Clean up. */
27b4b4d71011 Test for capabilities for each test.
Edgar Simo <bobbens@gmail.com>
parents: 3734
diff changeset
900 SDL_DestroyTexture( tface );
27b4b4d71011 Test for capabilities for each test.
Edgar Simo <bobbens@gmail.com>
parents: 3734
diff changeset
901
3730
dafd796f0c95 * Added preliminary render tests, missing some SDL functions to work properly.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
902 /* Check to see if matches. */
3734
42356acbc993 Finished last of the render testcases.
Edgar Simo <bobbens@gmail.com>
parents: 3733
diff changeset
903 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
904 &img_blendAll ))
42356acbc993 Finished last of the render testcases.
Edgar Simo <bobbens@gmail.com>
parents: 3733
diff changeset
905 return -1;
3730
dafd796f0c95 * Added preliminary render tests, missing some SDL functions to work properly.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
906
3734
42356acbc993 Finished last of the render testcases.
Edgar Simo <bobbens@gmail.com>
parents: 3733
diff changeset
907 return 0;
3730
dafd796f0c95 * Added preliminary render tests, missing some SDL functions to work properly.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
908 }
dafd796f0c95 * Added preliminary render tests, missing some SDL functions to work properly.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
909
dafd796f0c95 * Added preliminary render tests, missing some SDL functions to work properly.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
910
dafd796f0c95 * Added preliminary render tests, missing some SDL functions to work properly.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
911 /**
dafd796f0c95 * Added preliminary render tests, missing some SDL functions to work properly.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
912 * @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
913 *
3734
42356acbc993 Finished last of the render testcases.
Edgar Simo <bobbens@gmail.com>
parents: 3733
diff changeset
914 * @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
915 */
3734
42356acbc993 Finished last of the render testcases.
Edgar Simo <bobbens@gmail.com>
parents: 3733
diff changeset
916 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
917 {
3734
42356acbc993 Finished last of the render testcases.
Edgar Simo <bobbens@gmail.com>
parents: 3733
diff changeset
918 int ret;
42356acbc993 Finished last of the render testcases.
Edgar Simo <bobbens@gmail.com>
parents: 3733
diff changeset
919
42356acbc993 Finished last of the render testcases.
Edgar Simo <bobbens@gmail.com>
parents: 3733
diff changeset
920 /* No error. */
42356acbc993 Finished last of the render testcases.
Edgar Simo <bobbens@gmail.com>
parents: 3733
diff changeset
921 ret = 0;
42356acbc993 Finished last of the render testcases.
Edgar Simo <bobbens@gmail.com>
parents: 3733
diff changeset
922
3743
848b5263ab05 * Added some verbosity output.
Edgar Simo <bobbens@gmail.com>
parents: 3741
diff changeset
923 /* Test functionality first. */
848b5263ab05 * Added some verbosity output.
Edgar Simo <bobbens@gmail.com>
parents: 3741
diff changeset
924 if (render_hasDrawColor())
848b5263ab05 * Added some verbosity output.
Edgar Simo <bobbens@gmail.com>
parents: 3741
diff changeset
925 SDL_ATprintVerbose( 1, " Draw Color supported\n" );
848b5263ab05 * Added some verbosity output.
Edgar Simo <bobbens@gmail.com>
parents: 3741
diff changeset
926 if (render_hasBlendModes())
848b5263ab05 * Added some verbosity output.
Edgar Simo <bobbens@gmail.com>
parents: 3741
diff changeset
927 SDL_ATprintVerbose( 1, " Blend Modes supported\n" );
848b5263ab05 * Added some verbosity output.
Edgar Simo <bobbens@gmail.com>
parents: 3741
diff changeset
928 if (render_hasTexColor())
848b5263ab05 * Added some verbosity output.
Edgar Simo <bobbens@gmail.com>
parents: 3741
diff changeset
929 SDL_ATprintVerbose( 1, " Texture Color Mod supported\n" );
848b5263ab05 * Added some verbosity output.
Edgar Simo <bobbens@gmail.com>
parents: 3741
diff changeset
930 if (render_hasTexAlpha())
848b5263ab05 * Added some verbosity output.
Edgar Simo <bobbens@gmail.com>
parents: 3741
diff changeset
931 SDL_ATprintVerbose( 1, " Texture Alpha Mod supported\n" );
848b5263ab05 * Added some verbosity output.
Edgar Simo <bobbens@gmail.com>
parents: 3741
diff changeset
932
3730
dafd796f0c95 * Added preliminary render tests, missing some SDL functions to work properly.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
933 /* Software surface blitting. */
3735
27b4b4d71011 Test for capabilities for each test.
Edgar Simo <bobbens@gmail.com>
parents: 3734
diff changeset
934 ret = render_testPrimitives();
27b4b4d71011 Test for capabilities for each test.
Edgar Simo <bobbens@gmail.com>
parents: 3734
diff changeset
935 if (ret)
27b4b4d71011 Test for capabilities for each test.
Edgar Simo <bobbens@gmail.com>
parents: 3734
diff changeset
936 return -1;
27b4b4d71011 Test for capabilities for each test.
Edgar Simo <bobbens@gmail.com>
parents: 3734
diff changeset
937 ret = render_testPrimitivesBlend();
27b4b4d71011 Test for capabilities for each test.
Edgar Simo <bobbens@gmail.com>
parents: 3734
diff changeset
938 if (ret)
27b4b4d71011 Test for capabilities for each test.
Edgar Simo <bobbens@gmail.com>
parents: 3734
diff changeset
939 return -1;
27b4b4d71011 Test for capabilities for each test.
Edgar Simo <bobbens@gmail.com>
parents: 3734
diff changeset
940 ret = render_testBlit();
3734
42356acbc993 Finished last of the render testcases.
Edgar Simo <bobbens@gmail.com>
parents: 3733
diff changeset
941 if (ret)
42356acbc993 Finished last of the render testcases.
Edgar Simo <bobbens@gmail.com>
parents: 3733
diff changeset
942 return -1;
3735
27b4b4d71011 Test for capabilities for each test.
Edgar Simo <bobbens@gmail.com>
parents: 3734
diff changeset
943 ret = render_testBlitColour();
3734
42356acbc993 Finished last of the render testcases.
Edgar Simo <bobbens@gmail.com>
parents: 3733
diff changeset
944 if (ret)
42356acbc993 Finished last of the render testcases.
Edgar Simo <bobbens@gmail.com>
parents: 3733
diff changeset
945 return -1;
3735
27b4b4d71011 Test for capabilities for each test.
Edgar Simo <bobbens@gmail.com>
parents: 3734
diff changeset
946 ret = render_testBlitAlpha();
3734
42356acbc993 Finished last of the render testcases.
Edgar Simo <bobbens@gmail.com>
parents: 3733
diff changeset
947 if (ret)
42356acbc993 Finished last of the render testcases.
Edgar Simo <bobbens@gmail.com>
parents: 3733
diff changeset
948 return -1;
3735
27b4b4d71011 Test for capabilities for each test.
Edgar Simo <bobbens@gmail.com>
parents: 3734
diff changeset
949 ret = render_testBlitBlend();
27b4b4d71011 Test for capabilities for each test.
Edgar Simo <bobbens@gmail.com>
parents: 3734
diff changeset
950
3734
42356acbc993 Finished last of the render testcases.
Edgar Simo <bobbens@gmail.com>
parents: 3733
diff changeset
951
42356acbc993 Finished last of the render testcases.
Edgar Simo <bobbens@gmail.com>
parents: 3733
diff changeset
952 return ret;
3730
dafd796f0c95 * Added preliminary render tests, missing some SDL functions to work properly.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
953 }
dafd796f0c95 * Added preliminary render tests, missing some SDL functions to work properly.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
954
dafd796f0c95 * Added preliminary render tests, missing some SDL functions to work properly.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
955
dafd796f0c95 * Added preliminary render tests, missing some SDL functions to work properly.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
956 /**
dafd796f0c95 * Added preliminary render tests, missing some SDL functions to work properly.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
957 * @brief Entry point.
dafd796f0c95 * Added preliminary render tests, missing some SDL functions to work properly.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
958 *
dafd796f0c95 * Added preliminary render tests, missing some SDL functions to work properly.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
959 * 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
960 * 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
961 * 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
962 * superfluous testsuites.
dafd796f0c95 * Added preliminary render tests, missing some SDL functions to work properly.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
963 */
3740
e451d5d288e9 Merged into one big app, while keeping modular applications also.
Edgar Simo <bobbens@gmail.com>
parents: 3739
diff changeset
964 #ifdef TEST_STANDALONE
3730
dafd796f0c95 * Added preliminary render tests, missing some SDL functions to work properly.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
965 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
966 {
dafd796f0c95 * Added preliminary render tests, missing some SDL functions to work properly.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
967 (void) argc;
dafd796f0c95 * Added preliminary render tests, missing some SDL functions to work properly.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
968 (void) argv;
3740
e451d5d288e9 Merged into one big app, while keeping modular applications also.
Edgar Simo <bobbens@gmail.com>
parents: 3739
diff changeset
969 #else /* TEST_STANDALONE */
e451d5d288e9 Merged into one big app, while keeping modular applications also.
Edgar Simo <bobbens@gmail.com>
parents: 3739
diff changeset
970 int test_render (void)
e451d5d288e9 Merged into one big app, while keeping modular applications also.
Edgar Simo <bobbens@gmail.com>
parents: 3739
diff changeset
971 {
e451d5d288e9 Merged into one big app, while keeping modular applications also.
Edgar Simo <bobbens@gmail.com>
parents: 3739
diff changeset
972 #endif /* TEST_STANDALONE */
3753
5b48a529fd8a More debugging information when test fails.
Edgar Simo <bobbens@gmail.com>
parents: 3747
diff changeset
973 int failed;
3730
dafd796f0c95 * Added preliminary render tests, missing some SDL functions to work properly.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
974 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
975 int ret;
dafd796f0c95 * Added preliminary render tests, missing some SDL functions to work properly.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
976 const char *driver, *str;
dafd796f0c95 * Added preliminary render tests, missing some SDL functions to work properly.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
977 char msg[256];
dafd796f0c95 * Added preliminary render tests, missing some SDL functions to work properly.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
978 SDL_WindowID wid;
dafd796f0c95 * Added preliminary render tests, missing some SDL functions to work properly.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
979 SDL_RendererInfo renderer;
dafd796f0c95 * Added preliminary render tests, missing some SDL functions to work properly.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
980
dafd796f0c95 * Added preliminary render tests, missing some SDL functions to work properly.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
981 /* Initializes the SDL subsystems. */
dafd796f0c95 * Added preliminary render tests, missing some SDL functions to work properly.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
982 ret = SDL_Init(0);
dafd796f0c95 * Added preliminary render tests, missing some SDL functions to work properly.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
983 if (ret != 0)
dafd796f0c95 * Added preliminary render tests, missing some SDL functions to work properly.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
984 return -1;
dafd796f0c95 * Added preliminary render tests, missing some SDL functions to work properly.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
985
dafd796f0c95 * Added preliminary render tests, missing some SDL functions to work properly.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
986 /* Get number of drivers. */
dafd796f0c95 * Added preliminary render tests, missing some SDL functions to work properly.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
987 nd = SDL_GetNumVideoDrivers();
3743
848b5263ab05 * Added some verbosity output.
Edgar Simo <bobbens@gmail.com>
parents: 3741
diff changeset
988 if (nd < 0)
3730
dafd796f0c95 * Added preliminary render tests, missing some SDL functions to work properly.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
989 goto err;
3743
848b5263ab05 * Added some verbosity output.
Edgar Simo <bobbens@gmail.com>
parents: 3741
diff changeset
990 SDL_ATprintVerbose( 1, "%d Video Drivers found\n", nd );
3730
dafd796f0c95 * Added preliminary render tests, missing some SDL functions to work properly.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
991
dafd796f0c95 * Added preliminary render tests, missing some SDL functions to work properly.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
992 /* 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
993 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
994 if (ret != 0)
dafd796f0c95 * Added preliminary render tests, missing some SDL functions to work properly.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
995 goto err;
dafd796f0c95 * Added preliminary render tests, missing some SDL functions to work properly.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
996
dafd796f0c95 * Added preliminary render tests, missing some SDL functions to work properly.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
997 /*
dafd796f0c95 * Added preliminary render tests, missing some SDL functions to work properly.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
998 * 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
999 */
dafd796f0c95 * Added preliminary render tests, missing some SDL functions to work properly.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
1000 /* Run for all video modes. */
3753
5b48a529fd8a More debugging information when test fails.
Edgar Simo <bobbens@gmail.com>
parents: 3747
diff changeset
1001 failed = 0;
3730
dafd796f0c95 * Added preliminary render tests, missing some SDL functions to work properly.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
1002 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
1003 /* Get video mode. */
dafd796f0c95 * Added preliminary render tests, missing some SDL functions to work properly.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
1004 driver = SDL_GetVideoDriver(i);
dafd796f0c95 * Added preliminary render tests, missing some SDL functions to work properly.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
1005 if (driver == NULL)
dafd796f0c95 * Added preliminary render tests, missing some SDL functions to work properly.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
1006 goto err;
3743
848b5263ab05 * Added some verbosity output.
Edgar Simo <bobbens@gmail.com>
parents: 3741
diff changeset
1007 SDL_ATprintVerbose( 1, " %d) %s\n", i+1, driver );
3730
dafd796f0c95 * Added preliminary render tests, missing some SDL functions to work properly.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
1008 /* 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
1009 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
1010 continue;
dafd796f0c95 * Added preliminary render tests, missing some SDL functions to work properly.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
1011
dafd796f0c95 * Added preliminary render tests, missing some SDL functions to work properly.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
1012 /*
dafd796f0c95 * Added preliminary render tests, missing some SDL functions to work properly.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
1013 * Initialize testsuite.
dafd796f0c95 * Added preliminary render tests, missing some SDL functions to work properly.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
1014 */
dafd796f0c95 * Added preliminary render tests, missing some SDL functions to work properly.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
1015 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
1016 SDL_ATinit( msg );
dafd796f0c95 * Added preliminary render tests, missing some SDL functions to work properly.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
1017
dafd796f0c95 * Added preliminary render tests, missing some SDL functions to work properly.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
1018 /*
dafd796f0c95 * Added preliminary render tests, missing some SDL functions to work properly.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
1019 * Initialize.
dafd796f0c95 * Added preliminary render tests, missing some SDL functions to work properly.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
1020 */
dafd796f0c95 * Added preliminary render tests, missing some SDL functions to work properly.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
1021 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
1022 /* Initialize video mode. */
dafd796f0c95 * Added preliminary render tests, missing some SDL functions to work properly.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
1023 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
1024 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
1025 goto err;
dafd796f0c95 * Added preliminary render tests, missing some SDL functions to work properly.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
1026 /* 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
1027 str = SDL_GetCurrentVideoDriver();
dafd796f0c95 * Added preliminary render tests, missing some SDL functions to work properly.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
1028 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
1029 goto err;
dafd796f0c95 * Added preliminary render tests, missing some SDL functions to work properly.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
1030 /* Create window. */
dafd796f0c95 * Added preliminary render tests, missing some SDL functions to work properly.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
1031 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
1032 80, 60, 0 );
dafd796f0c95 * Added preliminary render tests, missing some SDL functions to work properly.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
1033 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
1034 goto err;
dafd796f0c95 * Added preliminary render tests, missing some SDL functions to work properly.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
1035 /* Check title. */
dafd796f0c95 * Added preliminary render tests, missing some SDL functions to work properly.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
1036 str = SDL_GetWindowTitle( wid );
dafd796f0c95 * Added preliminary render tests, missing some SDL functions to work properly.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
1037 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
1038 goto err;
dafd796f0c95 * Added preliminary render tests, missing some SDL functions to work properly.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
1039 /* Get renderers. */
dafd796f0c95 * Added preliminary render tests, missing some SDL functions to work properly.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
1040 nr = SDL_GetNumRenderDrivers();
dafd796f0c95 * Added preliminary render tests, missing some SDL functions to work properly.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
1041 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
1042 goto err;
3743
848b5263ab05 * Added some verbosity output.
Edgar Simo <bobbens@gmail.com>
parents: 3741
diff changeset
1043 SDL_ATprintVerbose( 1, " %d Render Drivers\n", nr );
3730
dafd796f0c95 * Added preliminary render tests, missing some SDL functions to work properly.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
1044 SDL_ATend();
dafd796f0c95 * Added preliminary render tests, missing some SDL functions to work properly.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
1045 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
1046
dafd796f0c95 * Added preliminary render tests, missing some SDL functions to work properly.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
1047 /* Get renderer info. */
dafd796f0c95 * Added preliminary render tests, missing some SDL functions to work properly.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
1048 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
1049 if (ret != 0)
dafd796f0c95 * Added preliminary render tests, missing some SDL functions to work properly.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
1050 goto err;
dafd796f0c95 * Added preliminary render tests, missing some SDL functions to work properly.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
1051 /* Set testcase name. */
dafd796f0c95 * Added preliminary render tests, missing some SDL functions to work properly.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
1052 snprintf( msg, sizeof(msg), "Renderer %s", renderer.name );
3743
848b5263ab05 * Added some verbosity output.
Edgar Simo <bobbens@gmail.com>
parents: 3741
diff changeset
1053 SDL_ATprintVerbose( 1, " %d) %s\n", j+1, renderer.name );
3730
dafd796f0c95 * Added preliminary render tests, missing some SDL functions to work properly.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
1054 SDL_ATbegin( msg );
dafd796f0c95 * Added preliminary render tests, missing some SDL functions to work properly.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
1055 /* Set renderer. */
dafd796f0c95 * Added preliminary render tests, missing some SDL functions to work properly.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
1056 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
1057 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
1058 goto err;
dafd796f0c95 * Added preliminary render tests, missing some SDL functions to work properly.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
1059
dafd796f0c95 * Added preliminary render tests, missing some SDL functions to work properly.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
1060 /*
dafd796f0c95 * Added preliminary render tests, missing some SDL functions to work properly.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
1061 * Run tests.
dafd796f0c95 * Added preliminary render tests, missing some SDL functions to work properly.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
1062 */
3753
5b48a529fd8a More debugging information when test fails.
Edgar Simo <bobbens@gmail.com>
parents: 3747
diff changeset
1063 ret = render_runTests();
5b48a529fd8a More debugging information when test fails.
Edgar Simo <bobbens@gmail.com>
parents: 3747
diff changeset
1064 if (ret)
3734
42356acbc993 Finished last of the render testcases.
Edgar Simo <bobbens@gmail.com>
parents: 3733
diff changeset
1065 continue;
3730
dafd796f0c95 * Added preliminary render tests, missing some SDL functions to work properly.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
1066
dafd796f0c95 * Added preliminary render tests, missing some SDL functions to work properly.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
1067 SDL_ATend();
dafd796f0c95 * Added preliminary render tests, missing some SDL functions to work properly.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
1068 }
dafd796f0c95 * Added preliminary render tests, missing some SDL functions to work properly.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
1069
dafd796f0c95 * Added preliminary render tests, missing some SDL functions to work properly.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
1070 /* Exit the current renderer. */
dafd796f0c95 * Added preliminary render tests, missing some SDL functions to work properly.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
1071 SDL_VideoQuit();
dafd796f0c95 * Added preliminary render tests, missing some SDL functions to work properly.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
1072
dafd796f0c95 * Added preliminary render tests, missing some SDL functions to work properly.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
1073 /*
dafd796f0c95 * Added preliminary render tests, missing some SDL functions to work properly.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
1074 * Finish testsuite.
dafd796f0c95 * Added preliminary render tests, missing some SDL functions to work properly.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
1075 */
3753
5b48a529fd8a More debugging information when test fails.
Edgar Simo <bobbens@gmail.com>
parents: 3747
diff changeset
1076 failed += SDL_ATfinish();
3730
dafd796f0c95 * Added preliminary render tests, missing some SDL functions to work properly.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
1077 }
dafd796f0c95 * Added preliminary render tests, missing some SDL functions to work properly.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
1078
dafd796f0c95 * Added preliminary render tests, missing some SDL functions to work properly.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
1079
dafd796f0c95 * Added preliminary render tests, missing some SDL functions to work properly.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
1080 /* Exit SDL. */
dafd796f0c95 * Added preliminary render tests, missing some SDL functions to work properly.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
1081 SDL_Quit();
dafd796f0c95 * Added preliminary render tests, missing some SDL functions to work properly.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
1082
3753
5b48a529fd8a More debugging information when test fails.
Edgar Simo <bobbens@gmail.com>
parents: 3747
diff changeset
1083 return failed;
3730
dafd796f0c95 * Added preliminary render tests, missing some SDL functions to work properly.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
1084
dafd796f0c95 * Added preliminary render tests, missing some SDL functions to work properly.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
1085 err:
3753
5b48a529fd8a More debugging information when test fails.
Edgar Simo <bobbens@gmail.com>
parents: 3747
diff changeset
1086 return 1;
3730
dafd796f0c95 * Added preliminary render tests, missing some SDL functions to work properly.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
1087 }
dafd796f0c95 * Added preliminary render tests, missing some SDL functions to work properly.
Edgar Simo <bobbens@gmail.com>
parents:
diff changeset
1088